Esempio n. 1
0
        public TH_THAZA01(string editstring, string haza_id)
        {
            var new_haza = new TH_THAZA01("new");

            this.REC_CREATETIME = new_haza.REC_CREATETIME;
            this.ID             = new_haza.ID;
            this.HAZA_CATEGORY  = new_haza.HAZA_CATEGORY;
            this.HAZA_ID        = haza_id;
        }
Esempio n. 2
0
        /// <summary>
        /// 因为liststr更新而刷新hazalvl的函数
        /// </summary>
        /// <param name="str_risk_list"></param>
        public void ReCalcHAZA_LVL(string str_risk_list)
        {
            this.RISKLIST = this.GetRiskList();
            decimal haza_d;
            string  hazalvl;

            TH_THAZA01.ReCalcHAZA_LVL(this.RISKLIST, out haza_d, out hazalvl);
            this.HAZA_D   = haza_d;
            this.HAZA_LVL = hazalvl;
        }
Esempio n. 3
0
        /// <summary>
        /// 因为list更新而刷新hazalvl的函数
        /// </summary>
        /// <param name="risk_list"></param>
        public void ReCalcHAZA_LVL(List <TH_TRISK01> risk_list)
        {
            var     re0 = this.Fill_RiskString();
            decimal haza_d;
            string  hazalvl;

            TH_THAZA01.ReCalcHAZA_LVL(this.RISKLIST, out haza_d, out hazalvl);
            this.HAZA_D   = haza_d;
            this.HAZA_LVL = hazalvl;
        }
        public TH_THAZA02 SetEditFLOW(TH_THAZA01 haza01new, TH_THAZA01 haza01old, IWORKFLOW_NODE workflow_node)
        {
            var newhaza02 = new TH_THAZA02(haza01new);

            if (haza01new.HAZA_LVL.CompareTo("4A") >= 0 || haza01old.HAZA_LVL.CompareTo("4A") >= 0)
            {
                newhaza02.CLASS_A = "Y";
            }
            else
            {
                newhaza02.CLASS_A = "N";
            }
            newhaza02.STATS        = workflow_node.ORDER_ID;
            newhaza02.AUDITSTEP_ID = workflow_node.NODE_ID;
            return(newhaza02);
        }
        public TH_THAZA02 SetAddFLOW(TH_THAZA01 haza01, IWORKFLOW_NODE workflow_node)
        {
            var newhaza02 = new TH_THAZA02(haza01);

            //判断新增项是否与A有关
            if (haza01.HAZA_LVL.CompareTo("4A") >= 0)
            {
                newhaza02.CLASS_A = "Y";
            }
            else
            {
                newhaza02.CLASS_A = "N";
            }
            newhaza02.STATS        = workflow_node.ORDER_ID;
            newhaza02.AUDITSTEP_ID = workflow_node.NODE_ID;
            return(newhaza02);
        }
 public TH_THAZA02(TH_THAZA01 haza01)
 {
     this.THAZA01 = haza01.ID;
     this.FLOW_ID = Guid.NewGuid().ToString("N").Substring(0, 8);
 }
Esempio n. 7
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>()));
            }
        }