public HttpResponseMessage GetData(Info info)
        {
            string result = null;

            try
            {
                DateTime BeginDate = DateTime.Parse(info.fldBeginDate);

                DateTime EndDate = DateTime.Parse(info.fldEndDate);



                if (info.type == "SpaceID0")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID0_Midd>      query      = new List <tblEQISO_SpaceID0_Midd>();
                        List <tblEQISO_SpaceID0_Item_Midd> query_Item = new List <tblEQISO_SpaceID0_Item_Midd>();

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQISO_SpaceID0_Midd
                                     where x.fldDate >= BeginDate &&
                                     x.fldDate <= EndDate
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQISO_SpaceID0_Midd
                                     where x.fldDate >= BeginDate &&
                                     x.fldDate <= EndDate &&
                                     info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode + "." + x.fldPCode)
                                     select x).ToList();
                        }



                        if (info.fldItemCode != null)
                        {
                            query_Item = (from x in query
                                          join y in db.tblEQISO_SpaceID0_Item_Midd
                                          on x.fldAutoID equals y.fldFKID
                                          select y).ToList();

                            if (info.fldItemCode != "All")
                            {
                                string[] ItemCodeList = info.fldItemCode.Split(',');

                                query_Item = (from x in query_Item
                                              where ItemCodeList.Contains(x.fldItemCode)
                                              select x).ToList();
                            }
                        }


                        ReturnData rd = new ReturnData();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblEQISO_SpaceID0_Midd>      query2      = new List <tblEQISO_SpaceID0_Midd>();
                            List <tblEQISO_SpaceID0_Item_Midd> query_Item2 = new List <tblEQISO_SpaceID0_Item_Midd>();

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQISO_SpaceID0_Midd
                                          where x.fldDate >= BeginDate &&
                                          x.fldDate <= EndDate
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblEQISO_SpaceID0_Midd
                                          where x.fldDate >= BeginDate &&
                                          x.fldDate <= EndDate &&
                                          info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode + "." + x.fldPCode)
                                          select x).ToList();
                            }



                            if (info.fldItemCode != null)
                            {
                                query_Item2 = (from x in query2
                                               join y in db.tblEQISO_SpaceID0_Item_Midd
                                               on x.fldAutoID equals y.fldFKID
                                               select y).ToList();

                                if (info.fldItemCode != "All")
                                {
                                    string[] ItemCodeList = info.fldItemCode.Split(',');

                                    query_Item2 = (from x in query_Item2
                                                   where ItemCodeList.Contains(x.fldItemCode)
                                                   select x).ToList();
                                }
                            }

                            rd.tongqi      = query2;
                            rd.tongqi_Item = query_Item2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "SpaceID1")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID1_Midd>      query      = new List <tblEQISO_SpaceID1_Midd>();
                        List <tblEQISO_SpaceID1_Item_Midd> query_Item = new List <tblEQISO_SpaceID1_Item_Midd>();

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQISO_SpaceID1_Midd
                                     where x.fldYear == info.fldYear
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQISO_SpaceID1_Midd
                                     where x.fldYear == info.fldYear &&
                                     info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                     select x).ToList();
                        }



                        if (info.fldItemCode != null)
                        {
                            query_Item = (from x in query
                                          join y in db.tblEQISO_SpaceID1_Item_Midd
                                          on x.fldAutoID equals y.fldFKID
                                          select y).ToList();

                            if (info.fldItemCode != "All")
                            {
                                string[] ItemCodeList = info.fldItemCode.Split(',');

                                query_Item = (from x in query_Item
                                              where ItemCodeList.Contains(x.fldItemCode)
                                              select x).ToList();
                            }
                        }


                        ReturnData1 rd = new ReturnData1();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblEQISO_SpaceID1_Midd>      query2      = new List <tblEQISO_SpaceID1_Midd>();
                            List <tblEQISO_SpaceID1_Item_Midd> query_Item2 = new List <tblEQISO_SpaceID1_Item_Midd>();

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQISO_SpaceID1_Midd
                                          where x.fldYear == info.fldYear
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblEQISO_SpaceID1_Midd
                                          where x.fldYear == info.fldYear &&
                                          info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                          select x).ToList();
                            }



                            if (info.fldItemCode != null)
                            {
                                query_Item2 = (from x in query2
                                               join y in db.tblEQISO_SpaceID1_Item_Midd
                                               on x.fldAutoID equals y.fldFKID
                                               select y).ToList();

                                if (info.fldItemCode != "All")
                                {
                                    string[] ItemCodeList = info.fldItemCode.Split(',');

                                    query_Item2 = (from x in query_Item2
                                                   where ItemCodeList.Contains(x.fldItemCode)
                                                   select x).ToList();
                                }
                            }

                            rd.tongqi      = query2;
                            rd.tongqi_Item = query_Item2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "SpaceID2")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID2_Midd>      query      = new List <tblEQISO_SpaceID2_Midd>();
                        List <tblEQISO_SpaceID2_Item_Midd> query_Item = new List <tblEQISO_SpaceID2_Item_Midd>();

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQISO_SpaceID2_Midd
                                     where x.fldYear == info.fldYear
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQISO_SpaceID2_Midd
                                     where x.fldYear == info.fldYear &&
                                     info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                     select x).ToList();
                        }



                        if (info.fldItemCode != null)
                        {
                            query_Item = (from x in query
                                          join y in db.tblEQISO_SpaceID2_Item_Midd
                                          on x.fldAutoID equals y.fldFKID
                                          select y).ToList();

                            if (info.fldItemCode != "All")
                            {
                                string[] ItemCodeList = info.fldItemCode.Split(',');

                                query_Item = (from x in query_Item
                                              where ItemCodeList.Contains(x.fldItemCode)
                                              select x).ToList();
                            }
                        }


                        ReturnData2 rd = new ReturnData2();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblEQISO_SpaceID2_Midd>      query2      = new List <tblEQISO_SpaceID2_Midd>();
                            List <tblEQISO_SpaceID2_Item_Midd> query_Item2 = new List <tblEQISO_SpaceID2_Item_Midd>();

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQISO_SpaceID2_Midd
                                          where x.fldYear == info.fldYear
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblEQISO_SpaceID2_Midd
                                          where x.fldYear == info.fldYear &&
                                          info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                          select x).ToList();
                            }



                            if (info.fldItemCode != null)
                            {
                                query_Item2 = (from x in query2
                                               join y in db.tblEQISO_SpaceID2_Item_Midd
                                               on x.fldAutoID equals y.fldFKID
                                               select y).ToList();

                                if (info.fldItemCode != "All")
                                {
                                    string[] ItemCodeList = info.fldItemCode.Split(',');

                                    query_Item2 = (from x in query_Item2
                                                   where ItemCodeList.Contains(x.fldItemCode)
                                                   select x).ToList();
                                }
                            }

                            rd.tongqi      = query2;
                            rd.tongqi_Item = query_Item2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "SpaceID3")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID3_Midd> query;

                        query = (from x in db.tblEQISO_SpaceID3_Midd
                                 select x).ToList();

                        ReturnData3 rd = new ReturnData3();

                        rd.dangqi = query;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblEQISO_SpaceID3_Midd> query2;

                            query2 = (from x in db.tblEQISO_SpaceID3_Midd
                                      select x).ToList();

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "SpaceID4")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID4_Midd> query;

                        query = (from x in db.tblEQISO_SpaceID4_Midd
                                 where info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                 select x).ToList();

                        ReturnData4 rd = new ReturnData4();

                        rd.dangqi = query;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblEQISO_SpaceID4_Midd> query2;

                            query2 = (from x in db.tblEQISO_SpaceID4_Midd
                                      where info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                      select x).ToList();

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "SpaceID5")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID5_Midd>      query      = new List <tblEQISO_SpaceID5_Midd>();
                        List <tblEQISO_SpaceID5_Item_Midd> query_Item = new List <tblEQISO_SpaceID5_Item_Midd>();

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQISO_SpaceID5_Midd
                                     where x.fldYear == info.fldYear
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQISO_SpaceID5_Midd
                                     where x.fldYear == info.fldYear &&
                                     info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                     select x).ToList();
                        }



                        if (info.fldItemCode != null)
                        {
                            query_Item = (from x in query
                                          join y in db.tblEQISO_SpaceID5_Item_Midd
                                          on x.fldAutoID equals y.fldFKID
                                          select y).ToList();

                            if (info.fldItemCode != "All")
                            {
                                string[] ItemCodeList = info.fldItemCode.Split(',');

                                query_Item = (from x in query_Item
                                              where ItemCodeList.Contains(x.fldItemCode)
                                              select x).ToList();
                            }
                        }


                        ReturnData5 rd = new ReturnData5();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblEQISO_SpaceID5_Midd>      query2      = new List <tblEQISO_SpaceID5_Midd>();
                            List <tblEQISO_SpaceID5_Item_Midd> query_Item2 = new List <tblEQISO_SpaceID5_Item_Midd>();

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQISO_SpaceID5_Midd
                                          where x.fldYear == info.fldYear
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblEQISO_SpaceID5_Midd
                                          where x.fldYear == info.fldYear &&
                                          info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldEntCode)
                                          select x).ToList();
                            }



                            if (info.fldItemCode != null)
                            {
                                query_Item2 = (from x in query2
                                               join y in db.tblEQISO_SpaceID5_Item_Midd
                                               on x.fldAutoID equals y.fldFKID
                                               select y).ToList();

                                if (info.fldItemCode != "All")
                                {
                                    string[] ItemCodeList = info.fldItemCode.Split(',');

                                    query_Item2 = (from x in query_Item2
                                                   where ItemCodeList.Contains(x.fldItemCode)
                                                   select x).ToList();
                                }
                            }

                            rd.tongqi      = query2;
                            rd.tongqi_Item = query_Item2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "SpaceID6")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID6_Midd> query;

                        query = (from x in db.tblEQISO_SpaceID6_Midd
                                 select x).ToList();

                        ReturnData6 rd = new ReturnData6();

                        rd.dangqi = query;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblEQISO_SpaceID6_Midd> query2;

                            query2 = (from x in db.tblEQISO_SpaceID6_Midd
                                      select x).ToList();


                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
예제 #2
0
        public HttpResponseMessage GetData(Info info)
        {
            string result = null;

            try
            {
                if (info.type == "ItemOver")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblV_EQIW_D_ItemOver_Midd> query;

                        query = (from x in db.tblV_EQIW_D_ItemOver_Midd
                                 where x.fldTimeType == info.fldTimeType &&
                                 x.fldDate.Contains(info.fldYear)
                                 select x).ToList();

                        ReturnData rd = new ReturnData();

                        rd.dangqi = query;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblV_EQIW_D_ItemOver_Midd> query2;

                            query2 = (from x in db.tblV_EQIW_D_ItemOver_Midd
                                      where x.fldTimeType == info.fldTimeType &&
                                      x.fldDate.Contains(year.ToString())
                                      select x).ToList();

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }


                if (info.type == "CityItemOver")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblV_EQIW_D_CityItemOver_Midd> query;

                        query = (from x in db.tblV_EQIW_D_CityItemOver_Midd
                                 where x.fldTimeType == info.fldTimeType &&
                                 x.fldDate.Contains(info.fldYear) &&
                                 info.fldSTCode.Contains(x.fldSTCode)
                                 select x).ToList();

                        ReturnData2 rd = new ReturnData2();

                        rd.dangqi = query;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblV_EQIW_D_CityItemOver_Midd> query2;

                            query2 = (from x in db.tblV_EQIW_D_CityItemOver_Midd
                                      where x.fldTimeType == info.fldTimeType &&
                                      x.fldDate.Contains(year.ToString()) &&
                                      info.fldSTCode.Contains(x.fldSTCode)
                                      select x).ToList();

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }


                if (info.type == "BaseData")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIW_D_BaseData_Midd>      query;
                        List <tblEQIW_D_BaseData_Item_Midd> query_Item;

                        DateTime fldBeginDate = DateTime.Parse(info.fldBeginDate);

                        DateTime fldEndDate = DateTime.Parse(info.fldEndDate);

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIW_D_BaseData_Midd
                                     where x.fldappdate >= fldBeginDate &&
                                     x.fldappdate <= fldEndDate
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQIW_D_BaseData_Midd
                                     where x.fldappdate >= fldBeginDate &&
                                     x.fldappdate <= fldEndDate
                                     select x).ToList();
                        }


                        query_Item = (from x in query
                                      join y in db.tblEQIW_D_BaseData_Item_Midd
                                      on x.fldAutoID equals y.fldFKID
                                      select y).ToList();

                        ReturnData3 rd = new ReturnData3();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;


                        result = rule.JsonStr("ok", "", rd);
                    }
                }


                if (info.type == "DayOfData")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIW_D_DayOfData_Midd>      query;
                        List <tblEQIW_D_DayOfData_Item_Midd> query_Item;

                        DateTime fldBeginDate = DateTime.Parse(info.fldBeginDate);

                        DateTime fldEndDate = DateTime.Parse(info.fldEndDate);

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIW_D_DayOfData_Midd
                                     where DateTime.Parse(x.fldDate) >= fldBeginDate &&
                                     DateTime.Parse(x.fldDate) <= fldEndDate
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQIW_D_DayOfData_Midd
                                     where DateTime.Parse(x.fldDate) >= fldBeginDate &&
                                     DateTime.Parse(x.fldDate) <= fldEndDate
                                     select x).ToList();
                        }


                        query_Item = (from x in query
                                      join y in db.tblEQIW_D_DayOfData_Item_Midd
                                      on x.fldAutoID equals y.fldFKID
                                      select y).ToList();

                        ReturnData4 rd = new ReturnData4();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;


                        result = rule.JsonStr("ok", "", rd);
                    }
                }


                if (info.type == "YearBook")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblV_EQIW_D_YearBook_Midd>      query      = new List <tblV_EQIW_D_YearBook_Midd>();
                        List <tblV_EQIW_D_YearBook_Item_Midd> query_Item = new List <tblV_EQIW_D_YearBook_Item_Midd>();

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblV_EQIW_D_YearBook_Midd
                                     where x.STatType == info.STatType &&
                                     x.fldTimeType == info.fldTimeType
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblV_EQIW_D_YearBook_Midd
                                     where x.STatType == info.STatType &&
                                     x.fldTimeType == info.fldTimeType &&
                                     info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldRCode + "." + x.fldRSCode)
                                     select x).ToList();
                        }

                        if (info.fldItemCode != null)
                        {
                            query_Item = (from x in query
                                          join y in db.tblV_EQIW_D_YearBook_Item_Midd
                                          on x.fldAutoID equals y.fldFKID
                                          select y).ToList();

                            if (info.fldItemCode != "All")
                            {
                                string[] ItemCodeList = info.fldItemCode.Split(',');

                                query_Item = (from x in query_Item
                                              where ItemCodeList.Contains(x.fldItemCode)
                                              select x).ToList();
                            }
                        }


                        ReturnData5 rd = new ReturnData5();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblV_EQIW_D_YearBook_Midd>      query2      = new List <tblV_EQIW_D_YearBook_Midd>();
                            List <tblV_EQIW_D_YearBook_Item_Midd> query_Item2 = new List <tblV_EQIW_D_YearBook_Item_Midd>();

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblV_EQIW_D_YearBook_Midd
                                          where x.STatType == info.STatType &&
                                          x.fldTimeType == info.fldTimeType
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblV_EQIW_D_YearBook_Midd
                                          where x.STatType == info.STatType &&
                                          x.fldTimeType == info.fldTimeType &&
                                          info.fldSTCode.Contains(x.fldCityCode + "." + x.fldSTCode + "." + x.fldRCode + "." + x.fldRSCode)
                                          select x).ToList();
                            }

                            if (info.fldItemCode != null)
                            {
                                query_Item2 = (from x in query2
                                               join y in db.tblV_EQIW_D_YearBook_Item_Midd
                                               on x.fldAutoID equals y.fldFKID
                                               select y).ToList();

                                if (info.fldItemCode != "All")
                                {
                                    string[] ItemCodeList = info.fldItemCode.Split(',');

                                    query_Item2 = (from x in query_Item2
                                                   where ItemCodeList.Contains(x.fldItemCode)
                                                   select x).ToList();
                                }
                            }

                            rd.tongqi      = query2;
                            rd.tongqi_Item = query_Item2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }


                if (info.type == "City")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblV_EQIW_D_City_Midd>      query      = new List <tblV_EQIW_D_City_Midd>();
                        List <tblV_EQIW_D_City_Item_Midd> query_Item = new List <tblV_EQIW_D_City_Item_Midd>();


                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.fldTimeType, BeginDate, EndDate);

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblV_EQIW_D_City_Midd
                                     where x.fldTimeType == info.fldTimeType &&
                                     list.Contains(x.fldAppDate) &&
                                     x.STatType == info.STatType
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblV_EQIW_D_City_Midd
                                     where x.fldTimeType == info.fldTimeType &&
                                     info.fldSTCode.Contains(x.fldSTCode) &&
                                     list.Contains(x.fldAppDate) &&
                                     x.STatType == info.STatType
                                     select x).ToList();
                        }

                        if (info.fldItemCode != null)
                        {
                            query_Item = (from x in query
                                          join y in db.tblV_EQIW_D_City_Item_Midd
                                          on x.fldAutoID equals y.fldFKID
                                          select y).ToList();

                            if (info.fldItemCode != "All")
                            {
                                string[] ItemCodeList = info.fldItemCode.Split(',');

                                query_Item = (from x in query_Item
                                              where ItemCodeList.Contains(x.fldItemCode)
                                              select x).ToList();
                            }
                        }



                        ReturnData6 rd = new ReturnData6();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblV_EQIW_D_City_Midd>      query2      = new List <tblV_EQIW_D_City_Midd>();
                            List <tblV_EQIW_D_City_Item_Midd> query_Item2 = new List <tblV_EQIW_D_City_Item_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            list = ConvertDate(info.fldTimeType, BeginDate, EndDate);


                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblV_EQIW_D_City_Midd
                                          where x.fldTimeType == info.fldTimeType &&
                                          list.Contains(x.fldAppDate) &&
                                          x.STatType == info.STatType
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblV_EQIW_D_City_Midd
                                          where x.fldTimeType == info.fldTimeType &&
                                          info.fldSTCode.Contains(x.fldSTCode) &&
                                          list.Contains(x.fldAppDate) &&
                                          x.STatType == info.STatType
                                          select x).ToList();
                            }

                            if (info.fldItemCode != null)
                            {
                                query_Item2 = (from x in query2
                                               join y in db.tblV_EQIW_D_City_Item_Midd
                                               on x.fldAutoID equals y.fldFKID
                                               select y).ToList();

                                if (info.fldItemCode != "All")
                                {
                                    string[] ItemCodeList = info.fldItemCode.Split(',');

                                    query_Item2 = (from x in query_Item2
                                                   where ItemCodeList.Contains(x.fldItemCode)
                                                   select x).ToList();
                                }
                            }

                            rd.tongqi      = query2;
                            rd.tongqi_Item = query_Item2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }


                if (info.type == "Section")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblV_EQIW_D_Section_Midd>      query      = new List <tblV_EQIW_D_Section_Midd>();
                        List <tblV_EQIW_D_Section_Item_Midd> query_Item = new List <tblV_EQIW_D_Section_Item_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.fldTimeType, BeginDate, EndDate);

                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblV_EQIW_D_Section_Midd
                                     where x.fldTimeType == info.fldTimeType &&
                                     list.Contains(x.fldAppDate) &&
                                     x.STatType == info.STatType
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblV_EQIW_D_Section_Midd
                                     where x.fldTimeType == info.fldTimeType &&
                                     list.Contains(x.fldAppDate) &&
                                     info.fldSTCode.Contains(x.fldSTCode + "." + x.fldRCode + "." + x.fldRSCode) &&
                                     x.STatType == info.STatType
                                     select x).ToList();
                        }



                        if (info.fldItemCode != null)
                        {
                            query_Item = (from x in query
                                          join y in db.tblV_EQIW_D_Section_Item_Midd
                                          on x.fldAutoID equals y.fldFKID
                                          select y).ToList();

                            if (info.fldItemCode != "All")
                            {
                                string[] ItemCodeList = info.fldItemCode.Split(',');

                                query_Item = (from x in query_Item
                                              where ItemCodeList.Contains(x.fldItemCode)
                                              select x).ToList();
                            }
                        }



                        ReturnData7 rd = new ReturnData7();
                        rd.dangqi      = query;
                        rd.dangqi_Item = query_Item;

                        if (info.IsYear == "1")
                        {
                            int year = int.Parse(info.fldYear) - 1;

                            List <tblV_EQIW_D_Section_Midd>      query2      = new List <tblV_EQIW_D_Section_Midd>();
                            List <tblV_EQIW_D_Section_Item_Midd> query_Item2 = new List <tblV_EQIW_D_Section_Item_Midd>();


                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            list = ConvertDate(info.fldTimeType, BeginDate, EndDate);


                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblV_EQIW_D_Section_Midd
                                          where x.fldTimeType == info.fldTimeType &&
                                          list.Contains(x.fldAppDate) &&
                                          x.STatType == info.STatType
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblV_EQIW_D_Section_Midd
                                          where x.fldTimeType == info.fldTimeType &&
                                          list.Contains(x.fldAppDate) &&
                                          info.fldSTCode.Contains(x.fldSTCode + "." + x.fldRCode + "." + x.fldRSCode) &&
                                          x.STatType == info.STatType
                                          select x).ToList();
                            }


                            if (info.fldItemCode != null)
                            {
                                query_Item2 = (from x in query2
                                               join y in db.tblV_EQIW_D_Section_Item_Midd
                                               on x.fldAutoID equals y.fldFKID
                                               select y).ToList();

                                if (info.fldItemCode != "All")
                                {
                                    string[] ItemCodeList = info.fldItemCode.Split(',');

                                    query_Item2 = (from x in query_Item2
                                                   where ItemCodeList.Contains(x.fldItemCode)
                                                   select x).ToList();
                                }
                            }

                            rd.tongqi      = query2;
                            rd.tongqi_Item = query_Item2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
예제 #3
0
        public HttpResponseMessage GetData(Info info)
        {
            string result = null;

            try
            {
                if (info.type == "BaseData")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_BaseData_Midd> query = new List <tblEQIA_P_BaseData_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);



                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIA_P_BaseData_Midd
                                     where x.STatType == info.STatType &&
                                     x.fldSDate >= BeginDate &&
                                     x.fldEDate <= EndDate
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQIA_P_BaseData_Midd
                                     where x.STatType == info.STatType &&
                                     x.fldSDate >= BeginDate &&
                                     x.fldEDate <= EndDate &&
                                     info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode)
                                     select x).ToList();
                        }



                        ReturnData rd = new ReturnData();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_BaseData_Midd> query2 = new List <tblEQIA_P_BaseData_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);
                            int year = int.Parse(info.fldYear) - 1;

                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQIA_P_BaseData_Midd
                                          where x.STatType == info.STatType &&
                                          x.fldSDate >= BeginDate &&
                                          x.fldEDate <= EndDate
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblEQIA_P_BaseData_Midd
                                          where x.STatType == info.STatType &&
                                          x.fldSDate >= BeginDate &&
                                          x.fldEDate <= EndDate &&
                                          info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode)
                                          select x).ToList();
                            }

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "ResultStat")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_ResultStat_Midd> query = new List <tblEQIA_P_ResultStat_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);



                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIA_P_ResultStat_Midd
                                     where x.TimeType == info.TimeType &&
                                     x.AppriseID == info.AppriseID &&
                                     list.Contains(x.fldAppDate)
                                     select x).ToList();
                        }
                        else
                        {
                            if (info.AppriseID == "0")
                            {
                                query = (from x in db.tblEQIA_P_ResultStat_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         list.Contains(x.fldAppDate) &&
                                         info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode)
                                         select x).ToList();
                            }

                            if (info.AppriseID == "1")
                            {
                                query = (from x in db.tblEQIA_P_ResultStat_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         list.Contains(x.fldAppDate) &&
                                         info.fldSTCode.Contains(x.fldSTCode)
                                         select x).ToList();
                            }
                        }



                        ReturnData1 rd = new ReturnData1();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_ResultStat_Midd> query2 = new List <tblEQIA_P_ResultStat_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQIA_P_ResultStat_Midd
                                          where x.TimeType == info.TimeType &&
                                          x.AppriseID == info.AppriseID &&
                                          list.Contains(x.fldAppDate)
                                          select x).ToList();
                            }
                            else
                            {
                                if (info.AppriseID == "0")
                                {
                                    query2 = (from x in db.tblEQIA_P_ResultStat_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              list.Contains(x.fldAppDate) &&
                                              info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode)
                                              select x).ToList();
                                }

                                if (info.AppriseID == "1")
                                {
                                    query2 = (from x in db.tblEQIA_P_ResultStat_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              list.Contains(x.fldAppDate) &&
                                              info.fldSTCode.Contains(x.fldSTCode)
                                              select x).ToList();
                                }
                            }

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "STatType2")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_STatType2_Midd> query = new List <tblEQIA_P_STatType2_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);



                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIA_P_STatType2_Midd
                                     where x.TimeType == info.TimeType &&
                                     x.AppriseID == info.AppriseID
                                     select x).ToList();
                        }
                        else
                        {
                            if (info.AppriseID == "0")
                            {
                                query = (from x in db.tblEQIA_P_STatType2_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode)
                                         select x).ToList();
                            }


                            if (info.AppriseID == "1")
                            {
                                query = (from x in db.tblEQIA_P_STatType2_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode)
                                         select x).ToList();
                            }
                        }



                        ReturnData2 rd = new ReturnData2();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_STatType2_Midd> query2 = new List <tblEQIA_P_STatType2_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQIA_P_STatType2_Midd
                                          where x.TimeType == info.TimeType &&
                                          x.AppriseID == info.AppriseID
                                          select x).ToList();
                            }
                            else
                            {
                                if (info.AppriseID == "0")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType2_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode)
                                              select x).ToList();
                                }


                                if (info.AppriseID == "1")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType2_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode)
                                              select x).ToList();
                                }
                            }

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "STatType3")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_STatType3_Midd> query = new List <tblEQIA_P_STatType3_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);


                        query = (from x in db.tblEQIA_P_STatType3_Midd
                                 where x.TimeType == info.TimeType &&
                                 x.AppriseID == info.AppriseID &&
                                 list.Contains(x.fldDate)
                                 select x).ToList();


                        ReturnData3 rd = new ReturnData3();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_STatType3_Midd> query2 = new List <tblEQIA_P_STatType3_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            query2 = (from x in db.tblEQIA_P_STatType3_Midd
                                      where x.TimeType == info.TimeType &&
                                      x.AppriseID == info.AppriseID &&
                                      list.Contains(x.fldDate)
                                      select x).ToList();

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "STatType4")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_STatType4_Midd> query = new List <tblEQIA_P_STatType4_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);


                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIA_P_STatType4_Midd
                                     where x.fldSDate >= BeginDate &&
                                     x.fldEDate <= EndDate
                                     select x).ToList();
                        }
                        else
                        {
                            query = (from x in db.tblEQIA_P_STatType4_Midd
                                     where x.fldSDate >= BeginDate &&
                                     x.fldEDate <= EndDate &&
                                     info.fldSTCode.Contains(x.fldSTCode)
                                     select x).ToList();
                        }


                        ReturnData4 rd = new ReturnData4();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_STatType4_Midd> query2 = new List <tblEQIA_P_STatType4_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQIA_P_STatType4_Midd
                                          where x.fldSDate >= BeginDate &&
                                          x.fldEDate <= EndDate
                                          select x).ToList();
                            }
                            else
                            {
                                query2 = (from x in db.tblEQIA_P_STatType4_Midd
                                          where x.fldSDate >= BeginDate &&
                                          x.fldEDate <= EndDate &&
                                          info.fldSTCode.Contains(x.fldSTCode)
                                          select x).ToList();
                            }

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "STatType5")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_STatType5_Midd> query = new List <tblEQIA_P_STatType5_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);



                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIA_P_STatType5_Midd
                                     where x.TimeType == info.TimeType &&
                                     x.AppriseID == info.AppriseID &&
                                     x.fldYear == info.fldYear
                                     select x).ToList();
                        }
                        else
                        {
                            if (info.AppriseID == "0")
                            {
                                query = (from x in db.tblEQIA_P_STatType5_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode) &&
                                         x.fldYear == info.fldYear
                                         select x).ToList();
                            }

                            if (info.AppriseID == "1")
                            {
                                query = (from x in db.tblEQIA_P_STatType5_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode) &&
                                         x.fldYear == info.fldYear
                                         select x).ToList();
                            }
                        }


                        ReturnData5 rd = new ReturnData5();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_STatType5_Midd> query2 = new List <tblEQIA_P_STatType5_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);


                            int year = int.Parse(info.fldYear) - 1;


                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQIA_P_STatType5_Midd
                                          where x.TimeType == info.TimeType &&
                                          x.AppriseID == info.AppriseID &&
                                          x.fldYear == year.ToString()
                                          select x).ToList();
                            }
                            else
                            {
                                if (info.AppriseID == "0")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType5_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode) &&
                                              x.fldYear == year.ToString()
                                              select x).ToList();
                                }

                                if (info.AppriseID == "1")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType5_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode) &&
                                              x.fldYear == year.ToString()
                                              select x).ToList();
                                }
                            }


                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "STatType6")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_STatType6_Midd> query = new List <tblEQIA_P_STatType6_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);



                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIA_P_STatType6_Midd
                                     where x.TimeType == info.TimeType &&
                                     x.AppriseID == info.AppriseID &&
                                     x.fldYear == info.fldYear
                                     select x).ToList();
                        }
                        else
                        {
                            if (info.AppriseID == "0")
                            {
                                query = (from x in db.tblEQIA_P_STatType6_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode) &&
                                         x.fldYear == info.fldYear
                                         select x).ToList();
                            }

                            if (info.AppriseID == "1")
                            {
                                query = (from x in db.tblEQIA_P_STatType6_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode) &&
                                         x.fldYear == info.fldYear
                                         select x).ToList();
                            }
                        }



                        ReturnData6 rd = new ReturnData6();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_STatType6_Midd> query2 = new List <tblEQIA_P_STatType6_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            int year = int.Parse(info.fldYear) - 1;


                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQIA_P_STatType6_Midd
                                          where x.TimeType == info.TimeType &&
                                          x.AppriseID == info.AppriseID &&
                                          x.fldYear == year.ToString()
                                          select x).ToList();
                            }
                            else
                            {
                                if (info.AppriseID == "0")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType6_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode) &&
                                              x.fldYear == year.ToString()
                                              select x).ToList();
                                }

                                if (info.AppriseID == "1")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType6_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode) &&
                                              x.fldYear == year.ToString()
                                              select x).ToList();
                                }
                            }

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }



                if (info.type == "STatType7")
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_P_STatType7_Midd> query = new List <tblEQIA_P_STatType7_Midd>();

                        DateTime BeginDate = DateTime.Parse(info.fldBeginDate);
                        DateTime EndDate   = DateTime.Parse(info.fldEndDate);

                        List <string> list = ConvertDate(info.TimeType, BeginDate, EndDate);


                        if (info.fldSTCode == "-1")
                        {
                            query = (from x in db.tblEQIA_P_STatType7_Midd
                                     where x.TimeType == info.TimeType &&
                                     x.AppriseID == info.AppriseID &&
                                     x.fldYear == info.fldYear
                                     select x).ToList();
                        }
                        else
                        {
                            if (info.AppriseID == "0")
                            {
                                query = (from x in db.tblEQIA_P_STatType7_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode) &&
                                         x.fldYear == info.fldYear
                                         select x).ToList();
                            }

                            if (info.AppriseID == "1")
                            {
                                query = (from x in db.tblEQIA_P_STatType7_Midd
                                         where x.TimeType == info.TimeType &&
                                         x.AppriseID == info.AppriseID &&
                                         info.fldSTCode.Contains(x.fldSTCode) &&
                                         x.fldYear == info.fldYear
                                         select x).ToList();
                            }
                        }


                        ReturnData7 rd = new ReturnData7();
                        rd.dangqi = query;


                        if (info.IsYear == "1")
                        {
                            List <tblEQIA_P_STatType7_Midd> query2 = new List <tblEQIA_P_STatType7_Midd>();

                            BeginDate = BeginDate.AddYears(-1);
                            EndDate   = EndDate.AddYears(-1);

                            int year = int.Parse(info.fldYear) - 1;


                            list = ConvertDate(info.TimeType, BeginDate, EndDate);

                            if (info.fldSTCode == "-1")
                            {
                                query2 = (from x in db.tblEQIA_P_STatType7_Midd
                                          where x.TimeType == info.TimeType &&
                                          x.AppriseID == info.AppriseID &&
                                          x.fldYear == year.ToString()
                                          select x).ToList();
                            }
                            else
                            {
                                if (info.AppriseID == "0")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType7_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode + "." + x.fldPCode) &&
                                              x.fldYear == year.ToString()
                                              select x).ToList();
                                }

                                if (info.AppriseID == "1")
                                {
                                    query2 = (from x in db.tblEQIA_P_STatType7_Midd
                                              where x.TimeType == info.TimeType &&
                                              x.AppriseID == info.AppriseID &&
                                              info.fldSTCode.Contains(x.fldSTCode) &&
                                              x.fldYear == year.ToString()
                                              select x).ToList();
                                }
                            }

                            rd.tongqi = query2;
                        }

                        result = rule.JsonStr("ok", "", rd);
                    }
                }
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }