Exemplo n.º 1
0
        public HttpResponseMessage DelCacheData_EQIA_R(List <Del_Info_EQIA_R> info)
        {
            string result = null;
            int    num    = 0;

            try
            {
                using (MiddleContext db = new MiddleContext())
                {
                    foreach (var item in info)
                    {
                        var query = (from x in db.tblHM_EQIA_R_Midd
                                     where x.fldFKID == item.fldAutoID
                                     select x).ToList();


                        //删除数据表数据
                        db.tblHM_EQIA_R_Midd.RemoveRange(query);



                        //删除参数表数据
                        var query3 = (from x in db.tblHM_EQIA_R_Info_Midd
                                      where x.fldAutoID == item.fldAutoID
                                      select x).ToList();

                        db.tblHM_EQIA_R_Info_Midd.RemoveRange(query3);


                        num = db.SaveChanges();
                    }
                }

                result = rule.JsonStr("ok", "执行成功!", num);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        public HttpResponseMessage DelCacheData(List <Del_Info> info)
        {
            string result = null;
            int    num    = 0;

            try
            {
                using (MiddleContext db = new MiddleContext())
                {
                    foreach (var item in info)
                    {
                        if (item.SpaceID == 0)
                        {
                            var query = (from x in db.tblEQISO_SpaceID0_Midd
                                         where x.fldFKID == item.fldAutoID
                                         select x).ToList();



                            //删除因子表数据
                            foreach (var item2 in query)
                            {
                                var query2 = (from x in db.tblEQISO_SpaceID0_Item_Midd
                                              where x.fldFKID == item2.fldAutoID
                                              select x).ToList();

                                db.tblEQISO_SpaceID0_Item_Midd.RemoveRange(query2);
                            }



                            //删除数据表数据
                            db.tblEQISO_SpaceID0_Midd.RemoveRange(query);



                            //删除参数表数据
                            var query3 = (from x in db.tblEQIW_D_Info_Midd
                                          where x.fldAutoID == item.fldAutoID
                                          select x).ToList();

                            db.tblEQIW_D_Info_Midd.RemoveRange(query3);


                            num = db.SaveChanges();
                        }



                        if (item.SpaceID == 1)
                        {
                            var query = (from x in db.tblEQISO_SpaceID1_Midd
                                         where x.fldFKID == item.fldAutoID
                                         select x).ToList();



                            //删除因子表数据
                            foreach (var item2 in query)
                            {
                                var query2 = (from x in db.tblEQISO_SpaceID1_Item_Midd
                                              where x.fldFKID == item2.fldAutoID
                                              select x).ToList();

                                db.tblEQISO_SpaceID1_Item_Midd.RemoveRange(query2);
                            }



                            //删除数据表数据
                            db.tblEQISO_SpaceID1_Midd.RemoveRange(query);



                            //删除参数表数据
                            var query3 = (from x in db.tblEQIW_D_Info_Midd
                                          where x.fldAutoID == item.fldAutoID
                                          select x).ToList();

                            db.tblEQIW_D_Info_Midd.RemoveRange(query3);


                            num = db.SaveChanges();
                        }



                        if (item.SpaceID == 2)
                        {
                            var query = (from x in db.tblEQISO_SpaceID2_Midd
                                         where x.fldFKID == item.fldAutoID
                                         select x).ToList();



                            //删除因子表数据
                            foreach (var item2 in query)
                            {
                                var query2 = (from x in db.tblEQISO_SpaceID2_Item_Midd
                                              where x.fldFKID == item2.fldAutoID
                                              select x).ToList();

                                db.tblEQISO_SpaceID2_Item_Midd.RemoveRange(query2);
                            }



                            //删除数据表数据
                            db.tblEQISO_SpaceID2_Midd.RemoveRange(query);



                            //删除参数表数据
                            var query3 = (from x in db.tblEQIW_D_Info_Midd
                                          where x.fldAutoID == item.fldAutoID
                                          select x).ToList();

                            db.tblEQIW_D_Info_Midd.RemoveRange(query3);


                            num = db.SaveChanges();
                        }



                        if (item.SpaceID == 3)
                        {
                            var query = (from x in db.tblEQISO_SpaceID3_Midd
                                         where x.fldFKID == item.fldAutoID
                                         select x).ToList();


                            //删除数据表数据
                            db.tblEQISO_SpaceID3_Midd.RemoveRange(query);



                            //删除参数表数据
                            var query3 = (from x in db.tblEQIW_D_Info_Midd
                                          where x.fldAutoID == item.fldAutoID
                                          select x).ToList();

                            db.tblEQIW_D_Info_Midd.RemoveRange(query3);


                            num = db.SaveChanges();
                        }



                        if (item.SpaceID == 4)
                        {
                            var query = (from x in db.tblEQISO_SpaceID4_Midd
                                         where x.fldFKID == item.fldAutoID
                                         select x).ToList();


                            //删除数据表数据
                            db.tblEQISO_SpaceID4_Midd.RemoveRange(query);



                            //删除参数表数据
                            var query3 = (from x in db.tblEQIW_D_Info_Midd
                                          where x.fldAutoID == item.fldAutoID
                                          select x).ToList();

                            db.tblEQIW_D_Info_Midd.RemoveRange(query3);


                            num = db.SaveChanges();
                        }



                        if (item.SpaceID == 5)
                        {
                            var query = (from x in db.tblEQISO_SpaceID5_Midd
                                         where x.fldFKID == item.fldAutoID
                                         select x).ToList();



                            //删除因子表数据
                            foreach (var item2 in query)
                            {
                                var query2 = (from x in db.tblEQISO_SpaceID5_Item_Midd
                                              where x.fldFKID == item2.fldAutoID
                                              select x).ToList();

                                db.tblEQISO_SpaceID5_Item_Midd.RemoveRange(query2);
                            }



                            //删除数据表数据
                            db.tblEQISO_SpaceID5_Midd.RemoveRange(query);



                            //删除参数表数据
                            var query3 = (from x in db.tblEQIW_D_Info_Midd
                                          where x.fldAutoID == item.fldAutoID
                                          select x).ToList();

                            db.tblEQIW_D_Info_Midd.RemoveRange(query3);


                            num = db.SaveChanges();
                        }



                        if (item.SpaceID == 6)
                        {
                            var query = (from x in db.tblEQISO_SpaceID6_Midd
                                         where x.fldFKID == item.fldAutoID
                                         select x).ToList();


                            //删除数据表数据
                            db.tblEQISO_SpaceID6_Midd.RemoveRange(query);



                            //删除参数表数据
                            var query3 = (from x in db.tblEQIW_D_Info_Midd
                                          where x.fldAutoID == item.fldAutoID
                                          select x).ToList();

                            db.tblEQIW_D_Info_Midd.RemoveRange(query3);


                            num = db.SaveChanges();
                        }
                    }
                }



                result = rule.JsonStr("ok", "执行成功!", num);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        public HttpResponseMessage ExeCacheData(Info info)
        {
            string    result = null;
            DataTable dt     = new DataTable();
            int       info_Midd_fldAutoID = 0;

            try
            {
                //第一步
                #region 初始化变量

                tblEQIW_D_Info_Midd info_Midd = new tblEQIW_D_Info_Midd();

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

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

                #endregion



                //第二步
                #region 处理参数表,检查此条件下是否已经进行过缓存

                using (MiddleContext db = new MiddleContext())
                {
                    var query = (from x in db.tblEQIW_D_Info_Midd
                                 where x.TimeType == info.TimeType &&
                                 x.BeginDate == BeginDate &&
                                 x.EndDate == EndDate &&
                                 x.fldRSC == info.fldRSC &&
                                 x.fldRSCode == info.fldRSCode &&
                                 x.fldRStandardName == info.fldRStandardName &&
                                 x.fldRLevel == info.fldRLevel &&
                                 x.fldLStandardName == info.fldLStandardName &&
                                 x.fldLLevel == info.fldLLevel &&
                                 x.fldItemCode == info.fldItemCode &&
                                 x.DecCarry == info.DecCarry &&
                                 x.IsPre == info.IsPre &&
                                 x.IsYear == info.IsYear &&
                                 x.IsTotal == info.IsTotal &&
                                 x.IsDetail == info.IsDetail &&
                                 x.IsTLI == info.IsTLI &&
                                 x.TLIType == info.TLIType &&
                                 x.AppriseID == info.AppriseID &&
                                 x.SpaceID == info.SpaceID &&
                                 x.STatType == info.STatType &&
                                 x.fldSource == info.fldSource &&
                                 x.CalculateID == info.CalculateID
                                 select x).Count();

                    if (query > 0)
                    {
                        result = rule.JsonStr("ok", "此条件下已经进行过数据缓存。", "");
                        return(new HttpResponseMessage {
                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                        });
                    }
                }

                #endregion



                //第三步
                #region 执行通用存储过程,返回数据



                if (info.STatType == 2)
                {
                    SqlParameter[] paras = new SqlParameter[]
                    {
                        new SqlParameter("@TimeType", info.TimeType),
                        new SqlParameter("@BeginDate", info.BeginDate),
                        new SqlParameter("@EndDate", info.EndDate),
                        new SqlParameter("@fldRSC", info.fldRSC),
                        new SqlParameter("@fldRSCode", info.fldRSCode),
                        new SqlParameter("@fldRStandardName", info.fldRStandardName),
                        new SqlParameter("@fldRLevel", info.fldRLevel),
                        new SqlParameter("@fldLStandardName", info.fldLStandardName),
                        new SqlParameter("@fldLLevel", info.fldLLevel),
                        new SqlParameter("@fldItemCode", info.fldItemCode),
                        new SqlParameter("@DecCarry", info.DecCarry),
                        new SqlParameter("@IsPre", info.IsPre),
                        new SqlParameter("@IsYear", info.IsYear),
                        new SqlParameter("@IsTotal", info.IsTotal),
                        new SqlParameter("@IsDetail", info.IsDetail),
                        new SqlParameter("@IsTLI", info.IsTLI),
                        new SqlParameter("@TLIType", info.TLIType),
                        new SqlParameter("@AppriseID", info.AppriseID),
                        new SqlParameter("@SpaceID", info.SpaceID),
                        new SqlParameter("@STatType", info.STatType),
                        new SqlParameter("@fldSource", int.Parse(info.fldSource)),
                        new SqlParameter("@CalculateID", info.CalculateID),
                        new SqlParameter("@CategoryID", info.CategoryID)
                    };

                    dt = rule.RunProcedure("usp_tblEQIW_DX_Report_Apprise", paras.ToList(), null);
                }
                else
                {
                    SqlParameter[] paras = new SqlParameter[]
                    {
                        new SqlParameter("@TimeType", info.TimeType),
                        new SqlParameter("@BeginDate", info.BeginDate),
                        new SqlParameter("@EndDate", info.EndDate),
                        new SqlParameter("@fldRSC", info.fldRSC),
                        new SqlParameter("@fldRSCode", info.fldRSCode),
                        new SqlParameter("@fldRStandardName", info.fldRStandardName),
                        new SqlParameter("@fldRLevel", info.fldRLevel),
                        new SqlParameter("@fldLStandardName", info.fldLStandardName),
                        new SqlParameter("@fldLLevel", info.fldLLevel),
                        new SqlParameter("@fldItemCode", info.fldItemCode),
                        new SqlParameter("@DecCarry", info.DecCarry),
                        new SqlParameter("@IsPre", info.IsPre),
                        new SqlParameter("@IsYear", info.IsYear),
                        new SqlParameter("@IsTotal", info.IsTotal),
                        new SqlParameter("@IsDetail", info.IsDetail),
                        new SqlParameter("@IsTLI", info.IsTLI),
                        new SqlParameter("@TLIType", info.TLIType),
                        new SqlParameter("@AppriseID", info.AppriseID),
                        new SqlParameter("@SpaceID", info.SpaceID),
                        new SqlParameter("@STatType", info.STatType),
                        new SqlParameter("@fldSource", int.Parse(info.fldSource)),
                        new SqlParameter("@CalculateID", info.CalculateID)
                    };

                    dt = rule.RunProcedure("usp_tblEQIW_D_Report_Apprise", paras.ToList(), null);
                }

                if (dt == null || dt.Rows.Count == 0)
                {
                    result = rule.JsonStr("ok", "此条件集合下并未返回数据", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }

                #endregion



                //第四步
                #region 如果存储过程返回数据,那么将条件写入参数表

                using (MiddleContext db = new MiddleContext())
                {
                    info_Midd.TimeType         = info.TimeType;
                    info_Midd.BeginDate        = BeginDate;
                    info_Midd.EndDate          = EndDate;
                    info_Midd.fldRSC           = info.fldRSC;
                    info_Midd.fldRSCode        = info.fldRSCode;
                    info_Midd.fldRStandardName = info.fldRStandardName;
                    info_Midd.fldRLevel        = info.fldRLevel;
                    info_Midd.fldLStandardName = info.fldLStandardName;
                    info_Midd.fldLLevel        = info.fldLLevel;
                    info_Midd.fldItemCode      = info.fldItemCode;
                    info_Midd.DecCarry         = info.DecCarry;
                    info_Midd.IsPre            = info.IsPre;
                    info_Midd.IsYear           = info.IsYear;
                    info_Midd.IsTotal          = info.IsTotal;
                    info_Midd.IsDetail         = info.IsDetail;
                    info_Midd.IsTLI            = info.IsTLI;
                    info_Midd.TLIType          = info.TLIType;
                    info_Midd.AppriseID        = info.AppriseID;
                    info_Midd.SpaceID          = info.SpaceID;
                    info_Midd.STatType         = info.STatType;
                    info_Midd.fldSource        = info.fldSource;
                    info_Midd.CalculateID      = info.CalculateID;

                    db.tblEQIW_D_Info_Midd.Add(info_Midd);
                    db.SaveChanges();
                }

                info_Midd_fldAutoID = info_Midd.fldAutoID;

                #endregion



                //第五步
                #region 相关数据处理



                // 综合评价 - 城市评价
                if (info.SpaceID == 3 && info.AppriseID == 1)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIW_D_City_Midd> list = new List <tblEQIW_D_City_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIW_D_City_Midd data = new tblEQIW_D_City_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.STatType    = info.STatType.ToString();
                            data.fldTimeType = info.TimeType;

                            if (item["fldAppDate"].ToString() == "平均")
                            {
                                data.fldBeginDate = DateTime.Parse(info.BeginDate);
                                data.fldEndDate   = DateTime.Parse(info.EndDate);
                            }

                            data.fldCityCode      = item["fldCityCode"].ToString();
                            data.fldCityName      = item["fldCityName"].ToString();
                            data.fldSTCode        = item["fldSTCode"].ToString();
                            data.fldSTName        = item["fldSTName"].ToString();
                            data.fldAppDate       = item["fldAppDate"].ToString();
                            data.fldSCategory     = item["fldSCategory"].ToString();
                            data.fldSetCount      = item["fldSetCount"].ToString();
                            data.fldRSCount       = item["fldRSCount"].ToString();
                            data.fldYJCheckItem   = item["fldYJCheckItem"].ToString();
                            data.fldWJCheckItem   = item["fldWJCheckItem"].ToString();
                            data.fldAllSL         = item["fldAllSL"].ToString();
                            data.fldStdSL         = item["fldStdSL"].ToString();
                            data.fldScale         = item["fldScale"].ToString();
                            data.fldFStdSL        = item["fldFStdSL"].ToString();
                            data.fldFScale        = item["fldFScale"].ToString();
                            data.fldCount         = item["fldCount"].ToString();
                            data.fldStdCount      = item["fldStdCount"].ToString();
                            data.fldstdScale      = item["fldstdScale"].ToString();
                            data.fldFstdCount     = item["fldFstdCount"].ToString();
                            data.fldFstdScale     = item["fldFstdScale"].ToString();
                            data.fldStdSecion     = item["fldStdSecion"].ToString();
                            data.fldSectionScale  = item["fldSectionScale"].ToString();
                            data.fldFStdSecion    = item["fldFStdSecion"].ToString();
                            data.fldFSectionScale = item["fldFSectionScale"].ToString();
                            data.fldSections      = item["fldSections"].ToString();
                            data.fldFSections     = item["fldFSections"].ToString();
                            data.fld1Count        = item["fld1Count"].ToString();
                            data.fld1Scale        = item["fld1Scale"].ToString();
                            data.fld2Count        = item["fld2Count"].ToString();
                            data.fld2Scale        = item["fld2Scale"].ToString();
                            data.fld3Count        = item["fld3Count"].ToString();
                            data.fld3Scale        = item["fld3Scale"].ToString();
                            data.fld4Count        = item["fld4Count"].ToString();
                            data.fld4Scale        = item["fld4Scale"].ToString();
                            data.fld5Count        = item["fld5Count"].ToString();
                            data.fld5Scale        = item["fld5Scale"].ToString();
                            data.fld6Count        = item["fld6Count"].ToString();
                            data.fld6Scale        = item["fld6Scale"].ToString();

                            list.Add(data);
                            db.tblEQIW_D_City_Midd.Add(data);
                            db.SaveChanges();



                            // 因子表相关操作
                            List <tblEQIW_D_City_Item_Midd> data_item_list = new List <tblEQIW_D_City_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains(item2 + "_Value"))
                                {
                                    tblEQIW_D_City_Item_Midd data_item = new tblEQIW_D_City_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode = item2;
                                    data_item.fld_Value   = item[item2 + "_Value"].ToString();

                                    if (item.Table.Columns.Contains(item2 + "_Min"))
                                    {
                                        data_item.fld_Min = item[item2 + "_Min"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_Max"))
                                    {
                                        data_item.fld_Max = item[item2 + "_Max"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_AvgValueStage"))
                                    {
                                        data_item.fld_AvgValueStage = item[item2 + "_AvgValueStage"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_MaxValueStage"))
                                    {
                                        data_item.fld_MaxValueStage = item[item2 + "_MaxValueStage"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_Count"))
                                    {
                                        data_item.fld_MaxValueStage = item[item2 + "_Count"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_OutCount"))
                                    {
                                        data_item.fld_OutCount = item[item2 + "_OutCount"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_OutScale"))
                                    {
                                        data_item.fld_OutScale = item[item2 + "_OutScale"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_AvgOut"))
                                    {
                                        data_item.fld_AvgOut = item[item2 + "_AvgOut"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_MaxOut"))
                                    {
                                        data_item.fld_MaxOut = item[item2 + "_MaxOut"].ToString();
                                    }


                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblEQIW_D_City_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }


                // 综合评价 - 断面评价
                if (info.SpaceID == 3 && info.AppriseID == 0)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIW_D_Section_Midd> list = new List <tblEQIW_D_Section_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIW_D_Section_Midd data = new tblEQIW_D_Section_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.STatType    = info.STatType.ToString();
                            data.fldTimeType = info.TimeType;

                            if (item["fldAppDate"].ToString() == "平均")
                            {
                                data.fldBeginDate = DateTime.Parse(info.BeginDate);
                                data.fldEndDate   = DateTime.Parse(info.EndDate);
                            }

                            data.fldSectionInfo  = item["fldSectionInfo"].ToString();
                            data.fldWaterArea    = item["fldWaterArea"].ToString();
                            data.fldRSWaterWork  = item["fldRSWaterWork"].ToString();
                            data.fldCityCode     = item["fldCityCode"].ToString();
                            data.fldCityName     = item["fldCityName"].ToString();
                            data.fldSTCode       = item["fldSTCode"].ToString();
                            data.fldSTName       = item["fldSTName"].ToString();
                            data.fldRCode        = item["fldRCode"].ToString();
                            data.fldRName        = item["fldRName"].ToString();
                            data.fldRSCode       = item["fldRSCode"].ToString();
                            data.fldRSName       = item["fldRSName"].ToString();
                            data.fldJD           = item["fldJD"].ToString();
                            data.fldWD           = item["fldWD"].ToString();
                            data.fldSCategory    = item["fldSCategory"].ToString();
                            data.fldLevel        = item["fldLevel"].ToString();
                            data.fldRSC          = item["fldRSC"].ToString();
                            data.fldAppDate      = item["fldAppDate"].ToString();
                            data.fldFun          = item["fldFun"].ToString();
                            data.fldItemCount    = item["fldItemCount"].ToString();
                            data.fldOverCount    = item["fldOverCount"].ToString();
                            data.fldTDCheckCount = item["fldTDCheckCount"].ToString();
                            data.fldYJCheckCount = item["fldYJCheckCount"].ToString();
                            //data.fldYJCheckItem = item["fldYJCheckItem"].ToString();
                            data.fldWJCheckCount = item["fldWJCheckCount"].ToString();
                            //data.fldWJCheckItem = item["fldWJCheckItem"].ToString();
                            data.fldAllCheckCount = item["fldAllCheckCount"].ToString();
                            data.fldAllSL         = item["fldAllSL"].ToString();
                            data.fldAllScale      = item["fldAllScale"].ToString();
                            data.fldStandSL       = item["fldStandSL"].ToString();
                            data.fldScaleSL       = item["fldScaleSL"].ToString();
                            data.fldFStandSL      = item["fldFStandSL"].ToString();
                            data.fldFScaleSL      = item["fldFScaleSL"].ToString();
                            data.fldPC            = item["fldPC"].ToString();
                            data.fldStandPC       = item["fldStandPC"].ToString();
                            data.fldScalePC       = item["fldScalePC"].ToString();
                            data.fldFStandPC      = item["fldFStandPC"].ToString();
                            data.fldFScalePC      = item["fldFScalePC"].ToString();
                            data.fldStage         = item["fldStage"].ToString();
                            data.fldSectionApp    = item["fldSectionApp"].ToString();
                            data.fldStand         = item["fldStand"].ToString();
                            data.fldSingleStageD  = item["fldSingleStageD"].ToString();
                            data.fldSingleItemD   = item["fldSingleItemD"].ToString();
                            data.fldSingleTimesD  = item["fldSingleTimesD"].ToString();
                            data.fldSingleStageF  = item["fldSingleStageF"].ToString();
                            data.fldSingleItemF   = item["fldSingleItemF"].ToString();
                            data.fldSingleTimesF  = item["fldSingleTimesF"].ToString();
                            data.fldWPI           = item["fldWPI"].ToString();
                            data.fldAvgWPI        = item["fldAvgWPI"].ToString();
                            data.fldOverItem      = item["fldOverItem"].ToString();
                            data.fldFOverItem     = item["fldFOverItem"].ToString();
                            data.fldOverTimes     = item["fldOverTimes"].ToString();
                            data.fldOverScale     = item["fldOverScale"].ToString();
                            data.fldOverNum       = item["fldOverNum"].ToString();
                            //data.fldOverNum2 = item["fldOverNum2"].ToString();
                            data.fldFOverTimes        = item["fldFOverTimes"].ToString();
                            data.fldFOverScale        = item["fldFOverScale"].ToString();
                            data.fldFOverNum          = item["fldFOverNum"].ToString();
                            data.C314_TLI             = item["314_TLI"].ToString();
                            data.C313_TLI             = item["313_TLI"].ToString();
                            data.C464_TLI             = item["464_TLI"].ToString();
                            data.C501_TLI             = item["501_TLI"].ToString();
                            data.C466_TLI             = item["466_TLI"].ToString();
                            data.fldTSI               = item["fldTSI"].ToString();
                            data.fldTSIRange          = item["fldTSIRange"].ToString();
                            data.fldOutItem           = item["fldOutItem"].ToString();
                            data.fldOverCheckItem     = item["fldOverCheckItem"].ToString();
                            data.fldOverCheckItem_UN  = item["fldOverCheckItem_UN"].ToString();
                            data.fldOverCheckTimes    = item["fldOverCheckTimes"].ToString();
                            data.fldOverCheckTimes_UN = item["fldOverCheckTimes_UN"].ToString();
                            data.fldRemark            = item["fldRemark"].ToString();

                            list.Add(data);
                            db.tblEQIW_D_Section_Midd.Add(data);
                            db.SaveChanges();



                            // 因子表相关操作
                            List <tblEQIW_D_Section_Item_Midd> data_item_list = new List <tblEQIW_D_Section_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains(item2 + "_Value"))
                                {
                                    tblEQIW_D_Section_Item_Midd data_item = new tblEQIW_D_Section_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode = item2;
                                    data_item.fld_Value   = item[item2 + "_Value"].ToString();

                                    if (item.Table.Columns.Contains(item2 + "_Stage"))
                                    {
                                        data_item.fld_Stage = item[item2 + "_Stage"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_CPI"))
                                    {
                                        data_item.fld_CPI = item[item2 + "_CPI"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_CFI"))
                                    {
                                        data_item.fld_CFI = item[item2 + "_CFI"].ToString();
                                    }

                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblEQIW_D_Section_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }


                // 因子超标
                if (info.SpaceID == 2)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIW_D_ItemOver_Midd> list = new List <tblEQIW_D_ItemOver_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIW_D_ItemOver_Midd data = new tblEQIW_D_ItemOver_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldTimeType = info.TimeType;

                            data.fldItemName          = item["fldItemName"].ToString();
                            data.fldDate              = item["fldDate"].ToString();
                            data.fldRCount            = item["fldRCount"].ToString();
                            data.fldOutCount          = item["fldOutCount"].ToString();
                            data.fldScale             = item["fldScale"].ToString();
                            data.fldMin               = item["fldMin"].ToString();
                            data.fldMax               = item["fldMax"].ToString();
                            data.fldMaxOut            = item["fldMaxOut"].ToString();
                            data.fldYPCount           = item["fldYPCount"].ToString();
                            data.fldYPOutCount        = item["fldYPOutCount"].ToString();
                            data.fldYPScale           = item["fldYPScale"].ToString();
                            data.fldYPMaxScale        = item["fldYPMaxScale"].ToString();
                            data.fldYPOutSection      = item["fldYPOutSection"].ToString();
                            data.fldYPOutSectionScale = item["fldYPOutSectionScale"].ToString();
                            data.fldYPMinValue        = item["fldYPMinValue"].ToString();
                            data.fldYPMaxValue        = item["fldYPMaxValue"].ToString();
                            data.fldYPOverValue       = item["fldYPOverValue"].ToString();
                            data.fldYPValue           = item["fldYPValue"].ToString();

                            list.Add(data);
                        }

                        db.tblEQIW_D_ItemOver_Midd.AddRange(list);
                        db.SaveChanges();
                    }
                }


                // 城市因子超标
                if (info.SpaceID == 20)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIW_D_CityItemOver_Midd> list = new List <tblEQIW_D_CityItemOver_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIW_D_CityItemOver_Midd data = new tblEQIW_D_CityItemOver_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldTimeType = info.TimeType;

                            data.fldSTCode            = item["fldSTCode"].ToString();
                            data.fldSTName            = item["fldSTName"].ToString();
                            data.fldItemName          = item["fldItemName"].ToString();
                            data.fldDate              = item["fldDate"].ToString();
                            data.fldRCount            = item["fldRCount"].ToString();
                            data.fldOutCount          = item["fldOutCount"].ToString();
                            data.fldScale             = item["fldScale"].ToString();
                            data.fldMin               = item["fldMin"].ToString();
                            data.fldMax               = item["fldMax"].ToString();
                            data.fldMaxOut            = item["fldMaxOut"].ToString();
                            data.fldYPCount           = item["fldYPCount"].ToString();
                            data.fldYPOutCount        = item["fldYPOutCount"].ToString();
                            data.fldYPScale           = item["fldYPScale"].ToString();
                            data.fldYPMaxScale        = item["fldYPMaxScale"].ToString();
                            data.fldYPOutSection      = item["fldYPOutSection"].ToString();
                            data.fldYPOutSectionScale = item["fldYPOutSectionScale"].ToString();
                            data.fldYPMinValue        = item["fldYPMinValue"].ToString();
                            data.fldYPMaxValue        = item["fldYPMaxValue"].ToString();
                            data.fldYPOverValue       = item["fldYPOverValue"].ToString();
                            data.fldYPValue           = item["fldYPValue"].ToString();

                            list.Add(data);
                        }

                        db.tblEQIW_D_CityItemOver_Midd.AddRange(list);
                        db.SaveChanges();
                    }
                }


                // 年鉴
                if (info.SpaceID == 1)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIW_D_YearBook_Midd> list = new List <tblEQIW_D_YearBook_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIW_D_YearBook_Midd data = new tblEQIW_D_YearBook_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.STatType    = info.STatType.ToString();
                            data.fldTimeType = info.TimeType;

                            data.fldCityCode  = item["fldCityCode"].ToString();
                            data.fldCityName  = item["fldCityName"].ToString();
                            data.fldSTCode    = item["fldSTCode"].ToString();
                            data.fldSTName    = item["fldSTName"].ToString();
                            data.fldRCode     = item["fldRCode"].ToString();
                            data.fldRName     = item["fldRName"].ToString();
                            data.fldRSCode    = item["fldRSCode"].ToString();
                            data.fldRSName    = item["fldRSName"].ToString();
                            data.fldSCategory = item["fldSCategory"].ToString();
                            data.fldRSC       = item["fldRSC"].ToString();
                            data.fldDate      = item["fldDate"].ToString();
                            data.fldStage     = item["fldStage"].ToString();
                            data.fldOutItems  = item["fldOutItems"].ToString();
                            data.fldFOutItems = item["fldFOutItems"].ToString();

                            list.Add(data);
                            db.tblEQIW_D_YearBook_Midd.Add(data);
                            db.SaveChanges();

                            // 因子表相关操作
                            List <tblEQIW_D_YearBook_Item_Midd> data_item_list = new List <tblEQIW_D_YearBook_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains("fld" + item2))
                                {
                                    tblEQIW_D_YearBook_Item_Midd data_item = new tblEQIW_D_YearBook_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode = item2;
                                    data_item.fld_Value   = item["fld" + item2].ToString();

                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblEQIW_D_YearBook_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }



                #endregion



                result = rule.JsonStr("ok", "执行成功!", info_Midd.fldAutoID);
            }
            catch (Exception e)
            {
                if (info_Midd_fldAutoID > 0)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        var query = (from x in db.tblEQIW_D_Info_Midd
                                     where x.fldAutoID == info_Midd_fldAutoID
                                     select x).FirstOrDefault();
                        db.tblEQIW_D_Info_Midd.Remove(query);
                        db.SaveChanges();
                    }
                }

                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Exemplo n.º 4
0
        public HttpResponseMessage ExeCacheData(Info info)
        {
            string    result = null;
            DataTable dt     = new DataTable();
            int       info_Midd_fldAutoID = 0;

            try
            {
                //第一步
                #region 初始化变量

                tblEQIA_R_Info_Midd info_Midd = new tblEQIA_R_Info_Midd();

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

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

                #endregion


                //第二步
                #region 处理参数表,检查此条件下是否已经进行过缓存

                using (MiddleContext db = new MiddleContext())
                {
                    var query = (from x in db.tblEQIA_R_Info_Midd
                                 where x.TimeType == info.TimeType &&
                                 x.BeginDate == BeginDate &&
                                 x.EndDate == EndDate &&
                                 x.fldPCode == info.fldPCode &&
                                 x.fldStandardName == info.fldStandardName &&
                                 x.fldLevel == info.fldLevel &&
                                 x.fldItemCode == info.fldItemCode &&
                                 x.DecCarry == info.DecCarry &&
                                 x.IsPre == info.IsPre &&
                                 x.IsYear == info.IsYear &&
                                 x.IsTotal == info.IsTotal &&
                                 x.IsDetail == info.IsDetail &&
                                 x.fldSource == info.fldSource &&
                                 x.AppriseID == info.AppriseID &&
                                 x.STatType == info.STatType &&
                                 x.CityID == info.CityID &&
                                 x.CalculateID == info.CalculateID &&
                                 x.ItemValueType == info.ItemValueType
                                 select x).Count();

                    if (query > 0)
                    {
                        result = rule.JsonStr("ok", "此条件下已经进行过数据缓存。", "");
                        return(new HttpResponseMessage {
                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                        });
                    }
                }

                #endregion


                //第三步
                #region 执行通用存储过程,返回数据



                if (info.STatType == 0)
                {
                    SqlParameter[] paras = new SqlParameter[]
                    {
                        new SqlParameter("@TimeType", info.TimeType),
                        new SqlParameter("@BeginDate", info.BeginDate),
                        new SqlParameter("@EndDate", info.EndDate),
                        new SqlParameter("@fldPCode", info.fldPCode),
                        new SqlParameter("@fldStandardName", info.fldStandardName),
                        new SqlParameter("@fldLevel", info.fldLevel),
                        new SqlParameter("@fldItemCode", info.fldItemCode),
                        new SqlParameter("@DecCarry", info.DecCarry),
                        new SqlParameter("@IsPre", info.IsPre),
                        new SqlParameter("@IsYear", info.IsYear),
                        new SqlParameter("@IsTotal", info.IsTotal),
                        new SqlParameter("@IsDetail", info.IsDetail),
                        new SqlParameter("@fldSource", info.fldSource),
                        new SqlParameter("@AppriseID", info.AppriseID),
                        new SqlParameter("@STatType", info.STatType),
                        new SqlParameter("@CityID", info.CityID),
                        new SqlParameter("@CalculateID", info.CalculateID),
                        new SqlParameter("@ItemValueType", info.ItemValueType)
                    };

                    dt = rule.RunProcedure("usp_tblEQIA_R_Report_AppriseStat", paras.ToList(), null);
                }


                if (dt == null || dt.Rows.Count == 0)
                {
                    result = rule.JsonStr("ok", "此条件集合下并未返回数据", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }

                #endregion


                //第四步
                #region 如果存储过程返回数据,那么将条件写入参数表

                using (MiddleContext db = new MiddleContext())
                {
                    info_Midd.TimeType        = info.TimeType;
                    info_Midd.BeginDate       = BeginDate;
                    info_Midd.EndDate         = EndDate;
                    info_Midd.fldPCode        = info.fldPCode;
                    info_Midd.fldStandardName = info.fldStandardName;
                    info_Midd.fldLevel        = info.fldLevel;
                    info_Midd.fldItemCode     = info.fldItemCode;
                    info_Midd.DecCarry        = info.DecCarry;
                    info_Midd.IsPre           = info.IsPre;
                    info_Midd.IsYear          = info.IsYear;
                    info_Midd.IsTotal         = info.IsTotal;
                    info_Midd.IsDetail        = info.IsDetail;
                    info_Midd.fldSource       = info.fldSource;
                    info_Midd.AppriseID       = info.AppriseID;
                    info_Midd.STatType        = info.STatType;
                    info_Midd.CityID          = info.CityID;
                    info_Midd.CalculateID     = info.CalculateID;
                    info_Midd.ItemValueType   = info.ItemValueType;

                    db.tblEQIA_R_Info_Midd.Add(info_Midd);
                    db.SaveChanges();
                }

                info_Midd_fldAutoID = info_Midd.fldAutoID;

                #endregion



                //第五步
                #region 相关数据处理
                List <Model.tblEQIA_R_Item> list_item = new List <tblEQIA_R_Item>();
                using (MiddleContext db = new MiddleContext())
                {
                    list_item = (from x in db.tblEQIA_R_Item
                                 select x).ToList();


                    list_item = (from x in list_item
                                 where info.fldItemCode.Split(',').Contains(x.fldItemCode)
                                 select x).ToList();
                }


                // 日 - 城市评价
                if (info.TimeType == "day" && info.AppriseID == 1)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_R_City_DayStat_Midd> list = new List <tblEQIA_R_City_DayStat_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIA_R_City_DayStat_Midd data = new tblEQIA_R_City_DayStat_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;


                            data.fldSTCode    = item["fldSTCode"].ToString();
                            data.fldSTName    = item["fldSTName"].ToString();
                            data.fldAppDate   = DateTime.Parse(item["fldAppDate"].ToString());
                            data.fldMaxDAPI   = item["fldMaxDAPI"].ToString();
                            data.fldItem      = item["fldItem"].ToString();
                            data.fldOverItems = item["fldOverItems"].ToString();
                            data.fldDAQL      = item["fldDAQL"].ToString();


                            list.Add(data);
                            db.tblEQIA_R_City_DayStat_Midd.Add(data);
                            db.SaveChanges();



                            // 因子表相关操作
                            List <tblEQIA_R_City_DayStat_Item_Midd> data_item_list = new List <tblEQIA_R_City_DayStat_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                tblEQIA_R_City_DayStat_Item_Midd data_item = new tblEQIA_R_City_DayStat_Item_Midd();

                                data_item.fldFKID = int.Parse(data.fldAutoID.ToString());

                                data_item.fldItemCode = item2;
                                data_item.fldSTCode   = item["fldSTCode"].ToString();
                                data_item.fldAppDate  = DateTime.Parse(item["fldAppDate"].ToString());



                                data_item.fldItemAVG = item["AVG_" + (from x in list_item where item2 == x.fldItemCode select x.fldItemName).FirstOrDefault()].ToString();
                                data_item.fldItemAQI = item["AQI_" + (from x in list_item where item2 == x.fldItemCode select x.fldItemName).FirstOrDefault()].ToString();



                                data_item_list.Add(data_item);
                            }

                            db.tblEQIA_R_City_DayStat_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }


                // 日 - 点位评价
                if (info.TimeType == "day" && info.AppriseID == 0)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_R_Point_DayStat_Midd> list = new List <tblEQIA_R_Point_DayStat_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIA_R_Point_DayStat_Midd data = new tblEQIA_R_Point_DayStat_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldSTCode     = item["fldSTCode"].ToString();
                            data.fldSTName     = item["fldSTName"].ToString();
                            data.fldPCode      = item["fldPCode"].ToString();
                            data.fldPName      = item["fldPName"].ToString();
                            data.fldPointLevel = item["fldPointLevel"].ToString();
                            data.fldAppDate    = DateTime.Parse(item["fldAppDate"].ToString());
                            data.fldMaxDAPI    = item["fldMaxDAPI"].ToString();
                            data.fldItem       = item["fldItem"].ToString();
                            data.fldOverItems  = item["fldOverItems"].ToString();

                            list.Add(data);
                            db.tblEQIA_R_Point_DayStat_Midd.Add(data);
                            db.SaveChanges();



                            // 因子表相关操作
                            List <tblEQIA_R_Point_DayStat_Item_Midd> data_item_list = new List <tblEQIA_R_Point_DayStat_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                tblEQIA_R_Point_DayStat_Item_Midd data_item = new tblEQIA_R_Point_DayStat_Item_Midd();

                                data_item.fldFKID = int.Parse(data.fldAutoID.ToString());

                                data_item.fldItemCode = item2;
                                data_item.fldSTCode   = item["fldSTCode"].ToString();
                                data_item.fldPCode    = item["fldPCode"].ToString();
                                data_item.fldAppDate  = DateTime.Parse(item["fldAppDate"].ToString());
                                data_item.fldItemAVG  = item["AVG_" + (from x in list_item where item2 == x.fldItemCode select x.fldItemName).FirstOrDefault()].ToString();
                                data_item.fldItemAQI  = item["AQI_" + (from x in list_item where item2 == x.fldItemCode select x.fldItemName).FirstOrDefault()].ToString();

                                data_item_list.Add(data_item);
                            }

                            db.tblEQIA_R_Point_DayStat_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }

                // 季度、年、月 - 点位评价
                if ((info.TimeType == "sea" && info.AppriseID == 0) || (info.TimeType == "month" && info.AppriseID == 0) || (info.TimeType == "year" && info.AppriseID == 0))
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_R_Point_TotalDateStat_Midd> list = new List <tblEQIA_R_Point_TotalDateStat_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIA_R_Point_TotalDateStat_Midd data = new tblEQIA_R_Point_TotalDateStat_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID     = info_Midd.fldAutoID;
                            data.fldTimeType = info.TimeType;

                            data.fldSTCode     = item["fldSTCode"].ToString();
                            data.fldSTName     = item["fldSTName"].ToString();
                            data.fldPCode      = item["fldPCode"].ToString();
                            data.fldPName      = item["fldPName"].ToString();
                            data.fldPointLevel = item["fldPointLevel"].ToString();

                            data.fldAppDate  = item["fldAppDate"].ToString();
                            data.fldSumCount = item["fldSumCount"].ToString();
                            data.fldCount    = item["fldCount"].ToString();
                            data.fldYLCount  = item["fldYLCount"].ToString();
                            data.fldYCount   = item["fld1Count"].ToString();
                            data.fldLCount   = item["fld2Count"].ToString();
                            data.fldQDCount  = item["fld3Count"].ToString();
                            data.fldZDCount  = item["fld4Count"].ToString();
                            data.fldZZDCount = item["fld5Count"].ToString();
                            data.fldYZCount  = item["fld6Count"].ToString();
                            data.fldWPI      = item["fldWPI"].ToString();
                            data.fldMCPI     = item["fldMCPI"].ToString();
                            data.fldCFI      = item["fldCFI"].ToString();
                            data.fldLevel    = item["fldLevel"].ToString();

                            list.Add(data);
                            db.tblEQIA_R_Point_TotalDateStat_Midd.Add(data);
                            db.SaveChanges();



                            // 因子表相关操作
                            List <tblEQIA_R_Point_TotalDateStat_Item_Midd> data_item_list = new List <tblEQIA_R_Point_TotalDateStat_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                tblEQIA_R_Point_TotalDateStat_Item_Midd data_item = new tblEQIA_R_Point_TotalDateStat_Item_Midd();

                                data_item.fldFKID = int.Parse(data.fldAutoID.ToString());

                                data_item.fldItemCode       = item2;
                                data_item.fldSTCode         = item["fldSTCode"].ToString();
                                data_item.fldPCode          = item["fldPCode"].ToString();
                                data_item.fldTimeType       = item["fldType"].ToString();
                                data_item.fldAppDate        = item["fldAppDate"].ToString();
                                data_item.fldItemAVG        = item["AVG_" + item2].ToString();
                                data_item.fldItemSD         = item["Sd_" + item2].ToString();
                                data_item.fldItemMin        = item["Min_" + item2].ToString();
                                data_item.fldItemMax        = item["Max_" + item2].ToString();
                                data_item.fldItemLevels     = item["Levels_" + item2].ToString();
                                data_item.fldItemAllDays    = item["AllDays_" + item2].ToString();
                                data_item.fldItemCurDays    = item["CurDays_" + item2].ToString();
                                data_item.fldItemStdDays    = item["StdDays_" + item2].ToString();
                                data_item.fldItem1LevelDays = item["1LevelDays" + item2].ToString();
                                data_item.fldItemStand      = item["Stand" + item2].ToString();
                                data_item.fldItemOvers      = item["Overs" + item2].ToString();
                                data_item.fldItemMinOut     = item["MinOut" + item2].ToString();
                                data_item.fldItemMaxOut     = item["MaxOut_" + item2].ToString();
                                data_item.fldItemCFI        = item["CFI_" + item2].ToString();
                                data_item.fldItemCFIW       = item["CFI_W_" + item2].ToString();
                                data_item.fldItemCPI        = item["CPI_" + item2].ToString();
                                data_item.fldItemLoad       = item["Load_" + item2].ToString();
                                data_item.fldItemBFW        = item["BFW_" + item2].ToString();
                                data_item.fldItemBFW90      = item["BFW90_" + item2].ToString();
                                data_item.fldItemBFW98      = item["BFW98_" + item2].ToString();

                                data_item_list.Add(data_item);
                            }

                            db.tblEQIA_R_Point_TotalDateStat_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }

                // 季度、年、月 - 城市评价
                if ((info.TimeType == "sea" && info.AppriseID == 1) || (info.TimeType == "month" && info.AppriseID == 1) || (info.TimeType == "year" && info.AppriseID == 1))
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQIA_R_City_TotalDateStat_Midd> list = new List <tblEQIA_R_City_TotalDateStat_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQIA_R_City_TotalDateStat_Midd data = new tblEQIA_R_City_TotalDateStat_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID     = info_Midd.fldAutoID;
                            data.fldTimeType = info.TimeType;

                            data.fldSTCode   = item["fldSTCode"].ToString();
                            data.fldSTName   = item["fldSTName"].ToString();
                            data.fldAppDate  = item["fldAppDate"].ToString();
                            data.fldSumCount = item["fldSumCount"].ToString();
                            data.fldCount    = item["fldCount"].ToString();
                            data.fldYLCount  = item["fldYLCount"].ToString();
                            data.fldYCount   = item["fld1Count"].ToString();
                            data.fldLCount   = item["fld2Count"].ToString();
                            data.fldQDCount  = item["fld3Count"].ToString();
                            data.fldZDCount  = item["fld4Count"].ToString();
                            data.fldZZDCount = item["fld5Count"].ToString();
                            data.fldYZCount  = item["fld6Count"].ToString();
                            data.fldWPI      = item["fldWPI"].ToString();
                            data.fldMCPI     = item["fldMCPI"].ToString();
                            data.fldCFI      = item["fldCFI"].ToString();
                            data.fldLevel    = item["fldLevel"].ToString();

                            list.Add(data);
                            db.tblEQIA_R_City_TotalDateStat_Midd.Add(data);
                            db.SaveChanges();



                            // 因子表相关操作
                            List <tblEQIA_R_City_TotalDateStat_Item_Midd> data_item_list = new List <tblEQIA_R_City_TotalDateStat_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                tblEQIA_R_City_TotalDateStat_Item_Midd data_item = new tblEQIA_R_City_TotalDateStat_Item_Midd();

                                data_item.fldFKID = int.Parse(data.fldAutoID.ToString());

                                data_item.fldItemCode       = item2;
                                data_item.fldSTCode         = item["fldSTCode"].ToString();
                                data_item.fldTimeType       = item["fldType"].ToString();
                                data_item.fldAppDate        = item["fldAppDate"].ToString();
                                data_item.fldItemAVG        = item["AVG_" + item2].ToString();
                                data_item.fldItemSD         = item["Sd_" + item2].ToString();
                                data_item.fldItemMin        = item["Min_" + item2].ToString();
                                data_item.fldItemMax        = item["Max_" + item2].ToString();
                                data_item.fldItemLevels     = item["Levels_" + item2].ToString();
                                data_item.fldItemAllDays    = item["AllDays_" + item2].ToString();
                                data_item.fldItemCurDays    = item["CurDays_" + item2].ToString();
                                data_item.fldItemStdDays    = item["StdDays_" + item2].ToString();
                                data_item.fldItem1LevelDays = item["1LevelDays" + item2].ToString();
                                data_item.fldItemStand      = item["Stand" + item2].ToString();
                                data_item.fldItemOvers      = item["Overs" + item2].ToString();
                                data_item.fldItemMinOut     = item["MinOut" + item2].ToString();
                                data_item.fldItemMaxOut     = item["MaxOut_" + item2].ToString();
                                data_item.fldItemCFI        = item["CFI_" + item2].ToString();
                                data_item.fldItemCFIW       = item["CFI_W_" + item2].ToString();
                                data_item.fldItemCPI        = item["CPI_" + item2].ToString();
                                data_item.fldItemLoad       = item["Load_" + item2].ToString();
                                data_item.fldItemBFW        = item["BFW_" + item2].ToString();
                                data_item.fldItemBFW90      = item["BFW90_" + item2].ToString();
                                data_item.fldItemBFW98      = item["BFW98_" + item2].ToString();

                                data_item_list.Add(data_item);
                            }

                            db.tblEQIA_R_City_TotalDateStat_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }

                #endregion


                result = rule.JsonStr("ok", "执行成功!", info_Midd.fldAutoID);
            }
            catch (Exception e)
            {
                if (info_Midd_fldAutoID > 0)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        var query = (from x in db.tblEQIA_R_Info_Midd
                                     where x.fldAutoID == info_Midd_fldAutoID
                                     select x).FirstOrDefault();
                        db.tblEQIA_R_Info_Midd.Remove(query);
                        db.SaveChanges();
                    }
                }

                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Exemplo n.º 5
0
        public HttpResponseMessage ExeCacheData_EQISO(Info_EQISO info)
        {
            string    result = null;
            DataTable dt     = new DataTable();

            try
            {
                //第一步
                #region 初始化变量

                tblHM_EQISO_Info_Midd info_Midd = new tblHM_EQISO_Info_Midd();

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

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

                #endregion



                //第二步
                #region 处理参数表,检查此条件下是否已经进行过缓存

                using (MiddleContext db = new MiddleContext())
                {
                    var query = (from x in db.tblHM_EQISO_Info_Midd
                                 where x.BeginDate == BeginDate &&
                                 x.EndDate == EndDate &&
                                 x.fldPCode == info.fldPCode &&
                                 x.fldStandardName == info.fldStandardName &&
                                 x.fldLevel == info.fldLevel &&
                                 x.fldItemCode == info.fldItemCode &&
                                 x.DecCarry == info.DecCarry
                                 select x).Count();

                    if (query > 0)
                    {
                        result = rule.JsonStr("ok", "此条件下已经进行过数据缓存。", "");
                        return(new HttpResponseMessage {
                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                        });
                    }
                }

                #endregion



                //第三步
                #region 执行通用存储过程,返回数据

                SqlParameter[] paras = new SqlParameter[]
                {
                    new SqlParameter("@BeginDate", info.BeginDate),
                    new SqlParameter("@EndDate", info.EndDate),
                    new SqlParameter("@fldPCode", info.fldPCode),
                    new SqlParameter("@fldStandardName", info.fldStandardName),
                    new SqlParameter("@fldLevel", info.fldLevel),
                    new SqlParameter("@fldItemCode", info.fldItemCode),
                    new SqlParameter("@DecCarry", info.DecCarry)
                };

                dt = rule.RunProcedure_V2("usp_tblEQISO_Report_LevelApprise", paras.ToList(), null, "HMEntityContext");

                if (dt == null || dt.Rows.Count == 0)
                {
                    result = rule.JsonStr("ok", "此条件集合下并未返回数据", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }

                #endregion



                //第四步
                #region 如果存储过程返回数据,那么将条件写入参数表

                using (MiddleContext db = new MiddleContext())
                {
                    info_Midd.BeginDate       = BeginDate;
                    info_Midd.EndDate         = EndDate;
                    info_Midd.fldPCode        = info.fldPCode;
                    info_Midd.fldStandardName = info.fldStandardName;
                    info_Midd.fldLevel        = info.fldLevel;
                    info_Midd.fldItemCode     = info.fldItemCode;
                    info_Midd.DecCarry        = info.DecCarry;

                    db.tblHM_EQISO_Info_Midd.Add(info_Midd);
                    db.SaveChanges();
                }

                #endregion



                //第五步
                #region 相关数据处理



                if (true)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblHM_EQISO_Midd> list = new List <tblHM_EQISO_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblHM_EQISO_Midd data = new tblHM_EQISO_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldSTName = item["fldSTName"].ToString();
                            data.fldPCount = item["fldPCount"].ToString();
                            data.fldScale  = item["fldScale"].ToString();
                            data.fldRange  = item["fldRange"].ToString();
                            data.fldPiAvg  = item["fldPiAvg"].ToString();
                            data.fld1Level = item["fld1Level"].ToString();
                            data.fld2Level = item["fld2Level"].ToString();

                            list.Add(data);
                        }

                        db.tblHM_EQISO_Midd.AddRange(list);
                        db.SaveChanges();
                    }
                }

                #endregion


                result = rule.JsonStr("ok", "执行成功!", info_Midd.fldAutoID);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Exemplo n.º 6
0
        public HttpResponseMessage ExeCacheData_EQIW_RLD(Info_EQIW_RLD info)
        {
            string    result = null;
            DataTable dt     = new DataTable();

            try
            {
                //第一步
                #region 初始化变量

                tblHM_EQIW_RLD_Info_Midd info_Midd = new tblHM_EQIW_RLD_Info_Midd();

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

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



                DateTime?EBeginDate = null;

                DateTime?EEndDate = null;


                DateTime EBeginDate2 = new DateTime();

                DateTime EEndDate2 = new DateTime();

                if (!(info.EBeginDate == "" || info.EEndDate == ""))
                {
                    DateTime.TryParse(info.EBeginDate, out EBeginDate2);

                    DateTime.TryParse(info.EEndDate, out EEndDate2);

                    EBeginDate = EBeginDate2;

                    EEndDate = EEndDate2;
                }



                #endregion



                //第二步
                #region 处理参数表,检查此条件下是否已经进行过缓存

                using (MiddleContext db = new MiddleContext())
                {
                    var query = (from x in db.tblHM_EQIW_RLD_Info_Midd
                                 where x.TimeType == info.TimeType &&
                                 x.BeginDate == BeginDate &&
                                 x.EndDate == EndDate &&
                                 x.EBeginDate == EBeginDate &&
                                 x.EEndDate == EEndDate &&
                                 x.fldRSC == info.fldRSC &&
                                 x.fldRSCode == info.fldRSCode &&
                                 x.fldStandardName == info.fldStandardName &&
                                 x.fldLevel == info.fldLevel &&
                                 x.fldStandardNameG == info.fldStandardNameG &&
                                 x.fldLevelG == info.fldLevelG &&
                                 x.fldItemCode == info.fldItemCode &&
                                 x.DecCarry == info.DecCarry &&
                                 x.IsPre == info.IsPre &&
                                 x.IsYear == info.IsYear &&
                                 x.IsTotal == info.IsTotal &&
                                 x.IsDetail == info.IsDetail &&
                                 x.AppriseID == info.AppriseID &&
                                 x.SpaceID == info.SpaceID &&
                                 x.STatType == info.STatType &&
                                 x.Para1ID == info.Para1ID &&
                                 x.Para2ID == info.Para2ID &&
                                 x.Source == info.Source
                                 select x).Count();

                    if (query > 0)
                    {
                        result = rule.JsonStr("ok", "此条件下已经进行过数据缓存。", "");
                        return(new HttpResponseMessage {
                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                        });
                    }
                }

                #endregion



                //第三步
                #region 执行通用存储过程,返回数据

                SqlParameter[] paras = new SqlParameter[]
                {
                    new SqlParameter("@TimeType", info.TimeType),
                    new SqlParameter("@BeginDate", info.BeginDate),
                    new SqlParameter("@EndDate", info.EndDate),
                    new SqlParameter("@EBeginDate", info.EBeginDate),
                    new SqlParameter("@EEndDate", info.EEndDate),
                    new SqlParameter("@fldRSC", info.fldRSC),
                    new SqlParameter("@fldRSCode", info.fldRSCode),
                    new SqlParameter("@fldStandardName", info.fldStandardName),
                    new SqlParameter("@fldLevel", info.fldLevel),
                    new SqlParameter("@fldStandardNameG", info.fldStandardNameG),
                    new SqlParameter("@fldLevelG", info.fldLevelG),
                    new SqlParameter("@fldItemCode", info.fldItemCode),
                    new SqlParameter("@DecCarry", info.DecCarry),
                    new SqlParameter("@IsPre", info.IsPre),
                    new SqlParameter("@IsYear", info.IsYear),
                    new SqlParameter("@IsTotal", info.IsTotal),
                    new SqlParameter("@IsDetail", info.IsDetail),
                    new SqlParameter("@AppriseID", info.AppriseID),
                    new SqlParameter("@SpaceID", info.SpaceID),
                    new SqlParameter("@STatType", info.STatType),
                    new SqlParameter("@Para1ID", info.Para1ID),
                    new SqlParameter("@Para2ID", info.Para2ID),
                    new SqlParameter("@Source", info.Source)
                };

                dt = rule.RunProcedure_V2("usp_tblEQIW_RLD_Report_HMApprirse", paras.ToList(), null, "HMEntityContext");

                if (dt == null || dt.Rows.Count == 0)
                {
                    result = rule.JsonStr("ok", "此条件集合下并未返回数据", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }

                #endregion



                //第四步
                #region 如果存储过程返回数据,那么将条件写入参数表

                using (MiddleContext db = new MiddleContext())
                {
                    info_Midd.TimeType         = info.TimeType;
                    info_Midd.BeginDate        = BeginDate;
                    info_Midd.EndDate          = EndDate;
                    info_Midd.EBeginDate       = EBeginDate;
                    info_Midd.EEndDate         = EEndDate;
                    info_Midd.fldRSC           = info.fldRSC;
                    info_Midd.fldRSCode        = info.fldRSCode;
                    info_Midd.fldStandardName  = info.fldStandardName;
                    info_Midd.fldLevel         = info.fldLevel;
                    info_Midd.fldStandardNameG = info.fldStandardNameG;
                    info_Midd.fldLevelG        = info.fldLevelG;
                    info_Midd.fldItemCode      = info.fldItemCode;
                    info_Midd.DecCarry         = info.DecCarry;
                    info_Midd.IsPre            = info.IsPre;
                    info_Midd.IsYear           = info.IsYear;
                    info_Midd.IsTotal          = info.IsTotal;
                    info_Midd.IsDetail         = info.IsDetail;
                    info_Midd.AppriseID        = info.AppriseID;
                    info_Midd.SpaceID          = info.SpaceID;
                    info_Midd.STatType         = info.STatType;
                    info_Midd.Para1ID          = info.Para1ID;
                    info_Midd.Para2ID          = info.Para2ID;
                    info_Midd.Source           = info.Source;

                    db.tblHM_EQIW_RLD_Info_Midd.Add(info_Midd);
                    db.SaveChanges();
                }

                #endregion



                //第五步
                #region 相关数据处理



                //年鉴格式
                if (info.STatType == 1)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblHM_EQIW_RLD_STatType1_Midd> list = new List <tblHM_EQIW_RLD_STatType1_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblHM_EQIW_RLD_STatType1_Midd data = new tblHM_EQIW_RLD_STatType1_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldWaterArea = item["fldWaterArea"].ToString();
                            data.fldLevel     = item["fldLevel"].ToString();
                            data.fldAtt       = item["fldAtt"].ToString();
                            data.fldSTCode    = item["fldSTCode"].ToString();
                            data.fldSTName    = item["fldSTName"].ToString();
                            data.fldRCode     = item["fldRCode"].ToString();
                            data.fldRName     = item["fldRName"].ToString();
                            data.fldRSCode    = item["fldRSCode"].ToString();
                            data.fldRSName    = item["fldRSName"].ToString();
                            data.fldDate      = item["fldDate"].ToString();
                            data.fldFun       = item["fldFun"].ToString();
                            data.fldStage     = item["fldStage"].ToString();

                            db.tblHM_EQIW_RLD_STatType1_Midd.Add(data);
                            db.SaveChanges();


                            List <tblHM_EQIW_RLD_STatType1_Item_Midd> data_item_list = new List <tblHM_EQIW_RLD_STatType1_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains("fld" + item2))
                                {
                                    tblHM_EQIW_RLD_STatType1_Item_Midd data_item = new tblHM_EQIW_RLD_STatType1_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode  = item2;
                                    data_item.fldItemValue = item["fld" + item2].ToString();
                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblHM_EQIW_RLD_STatType1_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }



                //断面或者河流综合评价
                if (info.STatType == 3)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblHM_EQIW_RLD_STatType3_Midd> list = new List <tblHM_EQIW_RLD_STatType3_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblHM_EQIW_RLD_STatType3_Midd data = new tblHM_EQIW_RLD_STatType3_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            //data.AppriseID = info.AppriseID.ToString();
                            //data.STatType = info.STatType.ToString();

                            data.fldWaterArea  = item["fldWaterArea"].ToString();
                            data.fldSTCode     = item["fldSTCode"].ToString();
                            data.fldSTName     = item["fldSTName"].ToString();
                            data.fldRCode      = item["fldRCode"].ToString();
                            data.fldRName      = item["fldRName"].ToString();
                            data.fldRSCode     = item["fldRSCode"].ToString();
                            data.fldRSName     = item["fldRSName"].ToString();
                            data.fldLevel      = item["fldLevel"].ToString();
                            data.fldAtt        = item["fldAtt"].ToString();
                            data.fldRSC        = item["fldRSC"].ToString();
                            data.fldAppDate    = item["fldAppDate"].ToString();
                            data.fldType       = item["fldType"].ToString();
                            data.fldFun        = item["fldFun"].ToString();
                            data.fldStage      = item["fldStage"].ToString();
                            data.fldSectionApp = item["fldSectionApp"].ToString();
                            data.fldStand      = item["fldStand"].ToString();

                            db.tblHM_EQIW_RLD_STatType3_Midd.Add(data);
                            db.SaveChanges();


                            List <tblHM_EQIW_RLD_STatType3_Item_Midd> data_item_list = new List <tblHM_EQIW_RLD_STatType3_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains(item2 + "_Value"))
                                {
                                    tblHM_EQIW_RLD_STatType3_Item_Midd data_item = new tblHM_EQIW_RLD_STatType3_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode = item2;
                                    data_item.fld_Value   = item[item2 + "_Value"].ToString();


                                    if (item.Table.Columns.Contains(item2 + "_Stage"))
                                    {
                                        data_item.fld_Stage = item[item2 + "_Stage"].ToString();
                                    }


                                    if (item.Table.Columns.Contains(item2 + "_STG"))
                                    {
                                        data_item.fld_STG = item[item2 + "_STG"].ToString();
                                    }


                                    if (item.Table.Columns.Contains(item2 + "_Over"))
                                    {
                                        data_item.fld_Over = item[item2 + "_Over"].ToString();
                                    }


                                    if (item.Table.Columns.Contains(item2 + "_OutScale"))
                                    {
                                        data_item.fld_OutScale = item[item2 + "_OutScale"].ToString();
                                    }


                                    if (item.Table.Columns.Contains(item2 + "_Min"))
                                    {
                                        data_item.fld_Min = item[item2 + "_Min"].ToString();
                                    }


                                    if (item.Table.Columns.Contains(item2 + "_Max"))
                                    {
                                        data_item.fld_Max = item[item2 + "_Max"].ToString();
                                    }

                                    if (item.Table.Columns.Contains(item2 + "_MaxOut"))
                                    {
                                        data_item.fld_MaxOut = item[item2 + "_MaxOut"].ToString();
                                    }


                                    if (item.Table.Columns.Contains(item2 + "_MaxDate"))
                                    {
                                        data_item.fld_MaxDate = item[item2 + "_MaxDate"].ToString();
                                    }


                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblHM_EQIW_RLD_STatType3_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }



                #endregion



                result = rule.JsonStr("ok", "执行成功!", info_Midd.fldAutoID);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        public HttpResponseMessage ExeCacheData(Info info)
        {
            string    result = null;
            DataTable dt     = new DataTable();

            try
            {
                //第一步
                #region 初始化变量

                tblEQISO_Info_Midd info_Midd = new tblEQISO_Info_Midd();

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

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

                #endregion



                //第二步
                #region 处理参数表,检查此条件下是否已经进行过缓存

                using (MiddleContext db = new MiddleContext())
                {
                    var query = (from x in db.tblEQISO_Info_Midd
                                 where x.TimeType == info.TimeType &&
                                 x.BeginDate == BeginDate &&
                                 x.EndDate == EndDate &&
                                 x.fldRSCode == info.fldRSCode &&
                                 x.fldStandardName == info.fldStandardName &&
                                 x.fldLevel == info.fldLevel &&
                                 x.fldItemCode == info.fldItemCode &&
                                 x.DecCarry == info.DecCarry &&
                                 x.AppriseID == info.AppriseID &&
                                 x.SpaceID == info.SpaceID &&
                                 x.STatType == info.STatType
                                 select x).Count();

                    if (query > 0)
                    {
                        result = rule.JsonStr("ok", "此条件下已经进行过数据缓存。", "");
                        return(new HttpResponseMessage {
                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                        });
                    }
                }

                #endregion



                //第三步
                #region 执行通用存储过程,返回数据

                SqlParameter[] paras = new SqlParameter[]
                {
                    new SqlParameter("@TimeType", info.TimeType),
                    new SqlParameter("@BeginDate", info.BeginDate),
                    new SqlParameter("@EndDate", info.EndDate),
                    new SqlParameter("@fldRSCode", info.fldRSCode),
                    new SqlParameter("@fldStandardName", info.fldStandardName),
                    new SqlParameter("@fldLevel", info.fldLevel),
                    new SqlParameter("@fldItemCode", info.fldItemCode),
                    new SqlParameter("@DecCarry", info.DecCarry),
                    new SqlParameter("@AppriseID", info.AppriseID),
                    new SqlParameter("@SpaceID", info.SpaceID),
                    new SqlParameter("@STatType", info.STatType)
                };

                dt = rule.RunProcedure("usp_tblEQISO_Report_Apprise", paras.ToList(), null);

                if (dt == null || dt.Rows.Count == 0)
                {
                    result = rule.JsonStr("ok", "此条件集合下并未返回数据", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }

                #endregion



                //第四步
                #region 如果存储过程返回数据,那么将条件写入参数表

                using (MiddleContext db = new MiddleContext())
                {
                    info_Midd.TimeType        = info.TimeType;
                    info_Midd.BeginDate       = BeginDate;
                    info_Midd.EndDate         = EndDate;
                    info_Midd.fldRSCode       = info.fldRSCode;
                    info_Midd.fldStandardName = info.fldStandardName;
                    info_Midd.fldLevel        = info.fldLevel;
                    info_Midd.fldItemCode     = info.fldItemCode;
                    info_Midd.DecCarry        = info.DecCarry;
                    info_Midd.AppriseID       = info.AppriseID;
                    info_Midd.SpaceID         = info.SpaceID;
                    info_Midd.STatType        = info.STatType;


                    db.tblEQISO_Info_Midd.Add(info_Midd);
                    db.SaveChanges();
                }

                #endregion



                //第五步
                #region 相关数据处理



                //原始数据表
                if (info.SpaceID == 0)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID0_Midd> list = new List <tblEQISO_SpaceID0_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQISO_SpaceID0_Midd data = new tblEQISO_SpaceID0_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldCityCode = item["fldCityCode"].ToString();
                            data.fldCityName = item["fldCityName"].ToString();
                            data.fldSTCode   = item["fldSTCode"].ToString();
                            data.fldSTName   = item["fldSTName"].ToString();
                            data.fldEntCode  = item["fldEntCode"].ToString();
                            data.fldEntName  = item["fldEntName"].ToString();
                            data.fldAddress  = item["fldAddress"].ToString();
                            data.fldPCode    = item["fldPCode"].ToString();
                            data.fldPName    = item["fldPName"].ToString();
                            data.fldLevel    = item["fldLevel"].ToString();
                            data.fldDate     = Convert.ToDateTime(item["fldYear"].ToString() + "-" + item["fldMonth"].ToString() + "-" + item["fldDay"].ToString());

                            db.tblEQISO_SpaceID0_Midd.Add(data);
                            db.SaveChanges();


                            List <tblEQISO_SpaceID0_Item_Midd> data_item_list = new List <tblEQISO_SpaceID0_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains("fld" + item2))
                                {
                                    tblEQISO_SpaceID0_Item_Midd data_item = new tblEQISO_SpaceID0_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode  = item2;
                                    data_item.fldItemValue = item["fld" + item2].ToString();
                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblEQISO_SpaceID0_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }



                //基本统计表
                if (info.SpaceID == 1)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID1_Midd> list = new List <tblEQISO_SpaceID1_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQISO_SpaceID1_Midd data = new tblEQISO_SpaceID1_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.AppriseID = info.AppriseID.ToString();
                            data.STatType  = info.STatType.ToString();

                            data.fldYear     = item["fldYear"].ToString();
                            data.fldCityCode = item["fldCityCode"].ToString();
                            data.fldCityName = item["fldCityName"].ToString();
                            data.fldSTCode   = item["fldSTCode"].ToString();
                            data.fldSTName   = item["fldSTName"].ToString();
                            data.fldEntCode  = item["fldEntCode"].ToString();
                            data.fldEntName  = item["fldEntName"].ToString();
                            data.fldAddress  = item["fldAddress"].ToString();
                            data.fldDate     = item["fldDate"].ToString();

                            db.tblEQISO_SpaceID1_Midd.Add(data);
                            db.SaveChanges();


                            List <tblEQISO_SpaceID1_Item_Midd> data_item_list = new List <tblEQISO_SpaceID1_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains("fld" + item2))
                                {
                                    tblEQISO_SpaceID1_Item_Midd data_item = new tblEQISO_SpaceID1_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode  = item2;
                                    data_item.fldItemValue = item["fld" + item2].ToString();
                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblEQISO_SpaceID1_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }



                //指数统计表
                if (info.SpaceID == 2)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID2_Midd> list = new List <tblEQISO_SpaceID2_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQISO_SpaceID2_Midd data = new tblEQISO_SpaceID2_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.AppriseID = info.AppriseID.ToString();
                            data.STatType  = info.STatType.ToString();

                            data.fldYear      = item["fldYear"].ToString();
                            data.fldCityCode  = item["fldCityCode"].ToString();
                            data.fldCityName  = item["fldCityName"].ToString();
                            data.fldSTCode    = item["fldSTCode"].ToString();
                            data.fldSTName    = item["fldSTName"].ToString();
                            data.fldEntCode   = item["fldEntCode"].ToString();
                            data.fldEntName   = item["fldEntName"].ToString();
                            data.fldAddress   = item["fldAddress"].ToString();
                            data.fldPCode     = item["fldPCode"].ToString();
                            data.fldPName     = item["fldPName"].ToString();
                            data.fldLevel     = item["fldLevel"].ToString();
                            data.fldSOType    = item["fldSOType"].ToString();
                            data.fldWPI_W     = item["fldWPI_W"].ToString();
                            data.fldWPI_Y     = item["fldWPI_Y"].ToString();
                            data.fldWPI_Avg   = item["fldWPI_Avg"].ToString();
                            data.fldWPI_Max   = item["fldWPI_Max"].ToString();
                            data.fldWPI       = item["fldWPI"].ToString();
                            data.fldLevelApp  = item["fldLevelApp"].ToString();
                            data.fldPCount    = item["fldPCount"].ToString();
                            data.fldStdCount  = item["fldStdCount"].ToString();
                            data.fldStdScale  = item["fldStdScale"].ToString();
                            data.fldItemOvers = item["fldItemOvers"].ToString();
                            data.fldMaxPiApp  = item["fldMaxPiApp"].ToString();
                            data.fldPnItem    = item["fldPnItem"].ToString();
                            data.fldPiItem    = item["fldPiItem"].ToString();

                            db.tblEQISO_SpaceID2_Midd.Add(data);
                            db.SaveChanges();


                            List <tblEQISO_SpaceID2_Item_Midd> data_item_list = new List <tblEQISO_SpaceID2_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains("fld" + item2))
                                {
                                    tblEQISO_SpaceID2_Item_Midd data_item = new tblEQISO_SpaceID2_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode  = item2;
                                    data_item.fldItemValue = item["fld" + item2].ToString();

                                    if (item.Table.Columns.Contains("fld" + item2 + "_Count"))
                                    {
                                        data_item.Count = item["fld" + item2 + "_Count"].ToString();
                                    }

                                    if (item.Table.Columns.Contains("fld" + item2 + "_Val"))
                                    {
                                        data_item.Val = item["fld" + item2 + "_Val"].ToString();
                                    }

                                    if (item.Table.Columns.Contains("fld" + item2 + "_OutCount"))
                                    {
                                        data_item.OutCount = item["fld" + item2 + "_OutCount"].ToString();
                                    }

                                    if (item.Table.Columns.Contains("fld" + item2 + "_OutScale"))
                                    {
                                        data_item.OutScale = item["fld" + item2 + "_OutScale"].ToString();
                                    }

                                    if (item.Table.Columns.Contains("fld" + item2 + "_CheckCount"))
                                    {
                                        data_item.CheckCount = item["fld" + item2 + "_CheckCount"].ToString();
                                    }

                                    if (item.Table.Columns.Contains("fld" + item2 + "_fldCheckScale"))
                                    {
                                        data_item.fldCheckScale = item["fld" + item2 + "_fldCheckScale"].ToString();
                                    }

                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblEQISO_SpaceID2_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }



                //项目各级别统计
                if (info.SpaceID == 3)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID3_Midd> list = new List <tblEQISO_SpaceID3_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQISO_SpaceID3_Midd data = new tblEQISO_SpaceID3_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldItemName = item["fldItemName"].ToString();
                            data.fldSOType   = item["fldSOType"].ToString();
                            data.fld1Count   = item["fld1Count"].ToString();
                            data.fld1Scale   = item["fld1Scale"].ToString();
                            data.fld2Count   = item["fld2Count"].ToString();
                            data.fld2Scale   = item["fld2Scale"].ToString();
                            data.fld3Count   = item["fld3Count"].ToString();
                            data.fld3Scale   = item["fld3Scale"].ToString();
                            data.fld4Count   = item["fld4Count"].ToString();
                            data.fld4Scale   = item["fld4Scale"].ToString();
                            data.fld5Count   = item["fld5Count"].ToString();
                            data.fld5Scale   = item["fld5Scale"].ToString();
                            data.fldCount    = item["fldCount"].ToString();
                            data.fldOutScale = item["fldOutScale"].ToString();
                            data.fldCFI      = item["fldCFI"].ToString();
                            data.fldMin      = item["fldMin"].ToString();
                            data.fldMax      = item["fldMax"].ToString();
                            data.fldAvg      = item["fldAvg"].ToString();
                            data.fldMaxOut   = item["fldMaxOut"].ToString();

                            list.Add(data);
                        }

                        db.tblEQISO_SpaceID3_Midd.AddRange(list);
                        db.SaveChanges();
                    }
                }



                //污染指数统计
                if (info.SpaceID == 4)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID4_Midd> list = new List <tblEQISO_SpaceID4_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQISO_SpaceID4_Midd data = new tblEQISO_SpaceID4_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.AppriseID = info.AppriseID.ToString();
                            data.STatType  = info.STatType.ToString();

                            data.fldCityCode = item["fldCityCode"].ToString();
                            data.fldCityName = item["fldCityName"].ToString();
                            data.fldSTCode   = item["fldSTCode"].ToString();
                            data.fldSTName   = item["fldSTName"].ToString();
                            data.fldEntCode  = item["fldEntCode"].ToString();
                            data.fldEntName  = item["fldEntName"].ToString();
                            data.fldAddress  = item["fldAddress"].ToString();
                            data.fldType     = item["fldType"].ToString();
                            data.fldSOType   = item["fldSOType"].ToString();
                            data.fldCount    = item["fldCount"].ToString();
                            data.fld1Count   = item["fld1Count"].ToString();
                            data.fld1Scale   = item["fld1Scale"].ToString();
                            data.fld2Count   = item["fld2Count"].ToString();
                            data.fld2Scale   = item["fld2Scale"].ToString();
                            data.fld3Count   = item["fld3Count"].ToString();
                            data.fld3Scale   = item["fld3Scale"].ToString();
                            data.fld4Count   = item["fld4Count"].ToString();
                            data.fld4Scale   = item["fld4Scale"].ToString();
                            data.fld5Count   = item["fld5Count"].ToString();
                            data.fld5Scale   = item["fld5Scale"].ToString();

                            list.Add(data);
                        }

                        db.tblEQISO_SpaceID4_Midd.AddRange(list);
                        db.SaveChanges();
                    }
                }



                //污染级别统计表
                if (info.SpaceID == 5)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID5_Midd> list = new List <tblEQISO_SpaceID5_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQISO_SpaceID5_Midd data = new tblEQISO_SpaceID5_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.AppriseID = info.AppriseID.ToString();
                            data.STatType  = info.STatType.ToString();

                            data.fldYear     = item["fldYear"].ToString();
                            data.fldCityCode = item["fldCityCode"].ToString();
                            data.fldCityName = item["fldCityName"].ToString();
                            data.fldSTCode   = item["fldSTCode"].ToString();
                            data.fldSTName   = item["fldSTName"].ToString();
                            data.fldEntCode  = item["fldEntCode"].ToString();
                            data.fldEntName  = item["fldEntName"].ToString();
                            data.fldAddress  = item["fldAddress"].ToString();
                            data.fldPCode    = item["fldPCode"].ToString();
                            data.fldPName    = item["fldPName"].ToString();
                            data.fldLevel    = item["fldLevel"].ToString();
                            data.fldSOType   = item["fldSOType"].ToString();
                            data.fldWPI_W    = item["fldWPI_W"].ToString();
                            data.fldWPI_Y    = item["fldWPI_Y"].ToString();
                            data.fldWPI_Avg  = item["fldWPI_Avg"].ToString();
                            data.fldWPI_Max  = item["fldWPI_Max"].ToString();
                            data.fldWPI      = item["fldWPI"].ToString();

                            db.tblEQISO_SpaceID5_Midd.Add(data);
                            db.SaveChanges();


                            List <tblEQISO_SpaceID5_Item_Midd> data_item_list = new List <tblEQISO_SpaceID5_Item_Midd>();

                            foreach (var item2 in info.fldItemCode.Split(','))
                            {
                                if (item.Table.Columns.Contains("fld" + item2))
                                {
                                    tblEQISO_SpaceID5_Item_Midd data_item = new tblEQISO_SpaceID5_Item_Midd();

                                    data_item.fldFKID = data.fldAutoID;

                                    data_item.fldItemCode  = item2;
                                    data_item.fldItemValue = item["fld" + item2].ToString();
                                    data_item_list.Add(data_item);
                                }
                            }

                            db.tblEQISO_SpaceID5_Item_Midd.AddRange(data_item_list);
                            db.SaveChanges();
                        }
                    }
                }



                //土壤质量状况评价
                if (info.SpaceID == 6)
                {
                    using (MiddleContext db = new MiddleContext())
                    {
                        List <tblEQISO_SpaceID6_Midd> list = new List <tblEQISO_SpaceID6_Midd>();

                        foreach (DataRow item in dt.Rows)
                        {
                            tblEQISO_SpaceID6_Midd data = new tblEQISO_SpaceID6_Midd();

                            //将参数实体的主键值,设置给数据表的FKID,从而确定数据是从哪个参数下生成的
                            data.fldFKID = info_Midd.fldAutoID;

                            data.fldStatType = item["fldStatType"].ToString();
                            data.fldSOType   = item["fldSOType"].ToString();
                            data.fld1Count   = item["fld1Count"].ToString();
                            data.fld1Scale   = item["fld1Scale"].ToString();
                            data.fld2Count   = item["fld2Count"].ToString();
                            data.fld2Scale   = item["fld2Scale"].ToString();
                            data.fld3Count   = item["fld3Count"].ToString();
                            data.fld3Scale   = item["fld3Scale"].ToString();
                            data.fld4Count   = item["fld4Count"].ToString();
                            data.fld4Scale   = item["fld4Scale"].ToString();
                            data.fld5Count   = item["fld5Count"].ToString();
                            data.fld5Scale   = item["fld5Scale"].ToString();
                            data.fldCount    = item["fldCount"].ToString();

                            list.Add(data);
                        }

                        db.tblEQISO_SpaceID6_Midd.AddRange(list);
                        db.SaveChanges();
                    }
                }



                #endregion



                result = rule.JsonStr("ok", "执行成功!", info_Midd.fldAutoID);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

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