Пример #1
0
        /// <summary>
        /// 修改该实体的状态
        /// </summary>
        /// <param name="stats"></param>
        /// <returns></returns>
        public CSException SetStats(string stats)
        {
            try
            {
                var delstring = EP_TEPEP01.GetDicByCName("危险源数据状态").Where(x => x.Value == stats).FirstOrDefault().Key;
                this.STATS = delstring;

                return(new CSException());
            }
            catch (Exception ex)
            {
                return(new CSException(ex.Message));
            }
        }
Пример #2
0
 public static CSException SetStatsAndSave(int ID, string stats)
 {
     try
     {
         var db  = new SAFEDB();
         var res = (from x in db.TH_THAZA01
                    where x.ID == ID
                    select x).First();
         var delstring = EP_TEPEP01.GetDicByCName("危险源数据状态").Where(x => x.Value == stats).FirstOrDefault().Key;
         res.HAZA_CATEGORY = delstring;
         db.SaveChanges();
         return(new CSException());
     }
     catch (Exception ex)
     {
         return(new CSException(ex.Message));
     }
 }
Пример #3
0
 /// <summary>
 /// 修改该实体的状态并保存
 /// </summary>
 /// <param name="stats"></param>
 /// <returns></returns>
 public CSException SetStatsAndSave(string stats)
 {
     try
     {
         var delstring = EP_TEPEP01.GetDicByCName("危险源数据状态").Where(x => x.Value == stats).FirstOrDefault().Key;
         this.STATS = delstring;
         var db  = new SAFEDB();
         var res = (from x in db.TH_HAZALOCA
                    where x.ID == this.ID
                    select x).FirstOrDefault();
         res.STATS = this.STATS;
         db.SaveChanges();
         return(new CSException());
     }
     catch (Exception ex)
     {
         return(new CSException(ex.Message));
     }
 }
Пример #4
0
        public static void CalcLVL(decimal L, decimal E, decimal C, out decimal D, out string lvl)
        {
            var int_D     = L * E * C;
            var valueList = EP_TEPEP01.GetListByCName("危险分数分级表");

            foreach (var rank in valueList)
            {
                var Minval = int.Parse(rank.CODE_DESC_1);
                var Maxval = int.Parse(rank.CODE_DESC_2);
                if (int_D >= Minval && int_D <= Maxval)
                {
                    D   = int_D;
                    lvl = rank.CODE;
                    return;
                }
            }
            D   = 0;
            lvl = "1D";
        }
Пример #5
0
        /// <summary>
        /// 根据现在该工作的状态进行该树的维护
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public string CheckNode(IWORKFLOW_NODE node)
        {
            var vr_cate_dic    = EP_TEPEP01.GetDicByCName("节点状态");
            var vr_cate_cdic   = EP_TEPEP01.GetCDicByCName("节点状态");
            var this_cate_cdic = EP_TEPEP01.GetCDicByCName("危险源数据状态");

            if (node.NODE_CATEGORY == vr_cate_cdic["否决"])
            {
                this.HAZA_CATEGORY = this_cate_cdic["删除"];
                this.SaveEdit();
            }
            else if (node.NODE_CATEGORY == vr_cate_cdic["结束"])
            {
                try
                {
                    var oldhaza = this.GetOfficalHAZA01InThisHAZAID();

                    oldhaza.HAZA_CATEGORY = this_cate_cdic["历史"];
                    var re1 = oldhaza.SaveEdit();
                }
                catch { }

                this.HAZA_CATEGORY = this_cate_cdic["正式"];
                this.SaveEdit();
            }
            else if (node.NODE_CATEGORY == vr_cate_cdic["开始"])//当一个节点审核开始,该项目中的其他审核节点进入删除状态,同一时间只存在一个审核节点
            {
                try
                {
                    var otherveriHaza = this.GetVeriHAZA01InThisHAZAID();
                    otherveriHaza.HAZA_CATEGORY = this_cate_cdic["历史"];
                    var re1 = otherveriHaza.SaveEdit();
                }
                catch { }
            }
            return(this.HAZA_CATEGORY);
        }
Пример #6
0
        /// <summary>
        /// haza01的文件导入函数,从npoi的sheet转化成list
        /// </summary>
        /// <param name="HSSFSheet"></param>
        /// <returns></returns>
        public static CSException <List <TH_THAZA01> > BuildListByNPOISheet(NPOI.HSSF.UserModel.HSSFSheet HSSFSheet, string userid)
        {
            try
            {
                var risk_status_Dic = EP_TEPEP01.GetDicByCName("风险状态");

                var rowcount = HSSFSheet.LastRowNum;//有一行是标题,但是还是+1,因为从0开始算。如果没有标题还是+1,因为这个不是统计总行,而是行数的最后一行的代码
                var hazaList = new List <TH_THAZA01>();
                for (var i = 1; i < rowcount + 1; i++)
                {
                    try
                    {
                        string force_haza_lvl;
                        var    row = HSSFSheet.GetRow(i);
                        if (row.Cells.Count() < 9)
                        {
                            break;
                        }
                        //读取sheet对应行所有数据
                        //一边读数据一边新建risk
                        var newrisk            = new TH_TRISK01("insert");
                        var haza_loca_deptCode = row.Cells[0].ToString().Trim();
                        if (haza_loca_deptCode == "END")
                        {
                            //根据要求,加了这个标记的行作为结束行
                            break;
                        }
                        var haza_loca_name    = "";
                        var haza_name         = "";
                        var risk_status_Cname = "";
                        try
                        {
                            newrisk.RISK_DEPT      = haza_loca_deptCode;
                            haza_loca_name         = row.Cells[1].ToString().Trim();
                            haza_name              = row.Cells[2].ToString().Trim();
                            risk_status_Cname      = row.Cells[3].ToString();
                            newrisk.RISK_STATUS    = risk_status_Dic.Where(x => x.Value == risk_status_Cname).First().Key;
                            newrisk.RISK_DECONTENT = row.Cells[4].ToString().Trim();
                            newrisk.RISK_MOD       = row.Cells[5].ToString().Trim();
                            newrisk.RISK_L         = decimal.Parse(row.Cells[6].ToString().Trim());
                            newrisk.RISK_E         = decimal.Parse(row.Cells[7].ToString().Trim());
                            newrisk.RISK_C         = decimal.Parse(row.Cells[8].ToString().Trim());
                            newrisk.CalcLVL();
                            newrisk.RISK_SOL = row.Cells[9].ToString().Trim().Replace("、", "");
                            if (row.PhysicalNumberOfCells > 10)
                            {
                                force_haza_lvl = row.Cells[10].ToString().Trim();
                            }
                            else
                            {
                                force_haza_lvl = "";
                            }
                        }
                        catch
                        {
                            throw new Exception("数据中有空白行,不符合规范");
                        }

                        //看危险源区域是否已经录入
                        var locare = TH_HAZALOCA.FindLoca(haza_loca_deptCode, haza_loca_name);
                        if (!locare.Flag)
                        {
                            throw new Exception("没有找到危险源区域");
                        }
                        //危险源区域获得
                        var hazaloca = locare.Entity;

                        var re_inList = TH_THAZA01.FindInList(hazaloca, haza_name, hazaList);
                        var re_inDB   = TH_THAZA01.FindInDB(hazaloca, haza_name);


                        if (re_inDB.Flag && re_inList.Flag)//在数据库和表中同时找到两项,则优先加入临时程序表中
                        {
                            var hazard = hazaList[(int)re_inList.StatusNum];
                            //直接添加一个风险进入

                            hazard.RISKLIST.Add(newrisk);
                            hazard.ReCalcHAZA_LVL(hazard.RISKLIST);
                            if (force_haza_lvl != "")
                            {
                                var lvldic = EP_TEPEP01.GetDicByCName("危险源等级");
                                hazard.HAZA_LVL = lvldic.Where(x => x.Value == force_haza_lvl).First().Key;
                            }
                        }
                        else if (re_inDB.Flag && !re_inList.Flag)//在数据库中存在
                        {
                            re_inDB.Entity.ReCalcHAZA_LVL(re_inDB.Entity.HAZA_RISK_String);
                            re_inDB.Entity.RISKLIST.Add(newrisk);
                            re_inDB.Entity.ReCalcHAZA_LVL(re_inDB.Entity.RISKLIST);
                            if (force_haza_lvl != "")
                            {
                                var lvldic = EP_TEPEP01.GetDicByCName("危险源等级");
                                re_inDB.Entity.HAZA_LVL = lvldic.Where(x => x.Value == force_haza_lvl).First().Key;
                            }
                            hazaList.Add(re_inDB.Entity);
                        }
                        else if (!re_inDB.Flag && re_inList.Flag)//在列表中
                        {
                            var hazard = hazaList[(int)re_inList.StatusNum];
                            //直接添加一个风险进入
                            hazard.RISKLIST.Add(newrisk);
                            hazard.ReCalcHAZA_LVL(hazard.RISKLIST);
                            if (force_haza_lvl != "")
                            {
                                var lvldic = EP_TEPEP01.GetDicByCName("危险源等级");
                                hazard.HAZA_LVL = lvldic.Where(x => x.Value == force_haza_lvl).First().Key;
                            }
                        }
                        else if (!re_inDB.Flag && !re_inList.Flag)//该危险源在已有资源中不存在,是个完全新危险源
                        {
                            //新建危险源
                            var newhaza = new TH_THAZA01("insert");
                            newhaza.HAZA_LOCA   = hazaloca.ID;
                            newhaza.REC_CREATOR = userid;
                            newhaza.HAZA_DEPT   = haza_loca_deptCode;
                            newhaza.HAZA_NAME   = haza_name;
                            newhaza.RISKLIST    = new List <TH_TRISK01>();
                            //马上添加一个新的风险
                            newhaza.RISKLIST.Add(newrisk);
                            newhaza.ReCalcHAZA_LVL(newhaza.RISKLIST);
                            if (force_haza_lvl != null && force_haza_lvl != "")
                            {
                                try
                                {
                                    var lvldic = EP_TEPEP01.GetDicByCName("危险源等级");
                                    newhaza.HAZA_LVL = lvldic.Where(x => x.Value == force_haza_lvl).First().Key;
                                }
                                catch
                                {
                                    throw new Exception("强制危险源等级错误");
                                }
                            }
                            //新危险源添加入List
                            hazaList.Add(newhaza);
                        }
                    }
                    catch (Exception ex)
                    {
                        var cell     = HSSFSheet.GetRow(i).Cells.Select(x => { return(x.ToString()); });
                        var jsoncell = JsonHelper.SerializeObject(cell);
                        var errmsg   = String.Format("至第{0}行录入成功,第{1}行录入失败 原因:{2},\n错误行信息:{3}", i, i + 1, ex.Message, jsoncell);
                        return(new CSException <List <TH_THAZA01> >(false, errmsg, hazaList));
                    }
                }
                //返回加完的hazalist
                return(new CSException <List <TH_THAZA01> >(true, hazaList));
            }

            catch (Exception ex)
            {
                return(new CSException <List <TH_THAZA01> >(false, ex.Message, new List <TH_THAZA01>()));
            }
        }