Ejemplo n.º 1
0
        public string GetAllRiskSate()
        {
            RiskBLL riskBLL = new RiskBLL();                                //安全风险
            SaftyCheckDataRecordBLL saBLL  = new SaftyCheckDataRecordBLL(); //安全检查
            HTBaseInfoBLL           htBLL  = new HTBaseInfoBLL();           //事故隐患
            List <object>           data   = new List <object>();
            OrganizeBLL             orgBll = new OrganizeBLL();
            DataTable dt = orgBll.GetDTList();

            ClassificationBLL classBLL = new ClassificationBLL();

            foreach (DataRow dr in dt.Rows)
            {
                Operator user = new Operator
                {
                    OrganizeId   = dr["orgid"].ToString(),
                    OrganizeCode = dr["encode"].ToString(),
                    RoleName     = "公司级用户,公司领导"
                };
                //计算事故隐患总得分
                decimal htScore = htBLL.GetHiddenWarning(user, "");
                decimal jcScore = saBLL.GetSafeCheckSumCount(user);
                decimal fxScore = riskBLL.GetRiskValueByTime(user, "");

                List <ClassificationEntity> list = classBLL.GetList(user.OrganizeId).ToList();
                if (list.Count == 0)
                {
                    list = classBLL.GetList("0").ToList();
                }
                data.Add(new { name = dr[1].ToString(), code = dr[0].ToString(), fxScore = fxScore, jcScore = jcScore, htScore = htScore, score = htScore * decimal.Parse(list[0].WeightCoeffcient) + jcScore * decimal.Parse(list[1].WeightCoeffcient) + fxScore * decimal.Parse(list[2].WeightCoeffcient) });
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(data));
        }
Ejemplo n.º 2
0
        public string GetRiskTrend(string orgCode = "", string orgId = "")
        {
            List <decimal> yValues = new List <decimal>();
            List <string>  xValues = new List <string>();

            if (CacheFactory.Cache().GetCache <List <string> >("RiskTrend_X_" + orgCode) != null)
            {
                xValues = CacheFactory.Cache().GetCache <List <string> >("RiskTrend_X_" + orgCode);
                yValues = CacheFactory.Cache().GetCache <List <decimal> >("RiskTrend_Y_" + orgCode);
            }
            else
            {
                RiskBLL riskBLL = new RiskBLL();                               //安全风险
                SaftyCheckDataRecordBLL saBLL = new SaftyCheckDataRecordBLL(); //安全检查
                HTBaseInfoBLL           htBLL = new HTBaseInfoBLL();           //事故隐患
                string time = DateTime.Now.AddMonths(-13).ToString("yyyy-MM-01");

                Operator user = OperatorProvider.Provider.Current();
                if (!string.IsNullOrEmpty(orgCode))
                {
                    user = new Operator
                    {
                        OrganizeId   = orgId,
                        OrganizeCode = orgCode,
                        RoleName     = "公司级用户,公司领导"
                    };
                }

                //ClassificationBLL classBLL = new ClassificationBLL();
                //List<ClassificationEntity> list = classBLL.GetList(user.OrganizeId).ToList();

                //if (list.Count == 0)
                //{
                //    list = classBLL.GetList("0").ToList();
                //}
                for (int j = 1; j <= 12; j++)
                {
                    //decimal totalScore = 0;
                    ////计算事故隐患总得分
                    string startDate = DateTime.Parse(time).AddMonths(j).ToString("yyyy-MM-dd");
                    //decimal score = htBLL.GetHiddenWarning(user, startDate);
                    //totalScore = score * decimal.Parse(list[0].WeightCoeffcient);
                    ////计算安全检查总得分
                    //score = saBLL.GetSafeCheckWarningM(user, startDate, 1);
                    //totalScore += score * decimal.Parse(list[1].WeightCoeffcient);
                    ////计算安全风险总得分
                    //score = riskBLL.GetRiskValueByTime(user, startDate);
                    //totalScore += score * decimal.Parse(list[2].WeightCoeffcient);

                    //yValues.Add(Math.Round(totalScore, 1));
                    //xValues.Add(DateTime.Parse(startDate).ToString("yyyy.MM"));

                    yValues.Add(0);
                    xValues.Add(DateTime.Parse(startDate).ToString("yyyy.MM"));
                }
                CacheFactory.Cache().WriteCache <List <string> >(xValues, "RiskTrend_X_" + orgCode, DateTime.Now.AddDays(2));
                CacheFactory.Cache().WriteCache <List <decimal> >(yValues, "RiskTrend_Y_" + orgCode, DateTime.Now.AddDays(2));
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(new { x = xValues, y = yValues }));
        }
Ejemplo n.º 3
0
 public ActionResult Make(string keyValue, CheckNoticeEntity sn)
 {
     try
     {
         SaftyCheckDataRecordBLL    srbll  = new SaftyCheckDataRecordBLL();
         SaftyCheckDataRecordEntity entity = srbll.GetEntity(sn.CheckId);
         if (entity != null)
         {
             sn.StartDate = entity.CheckBeginTime;
             sn.EndDate   = entity.CheckEndTime;
         }
         SaftyCheckContentBLL scbll = new SaftyCheckContentBLL();
         scbll.SaveNotice(keyValue, sn);
         return(Success("操作成功"));
     }
     catch (Exception ex)
     {
         return(Error(ex.Message));
     }
 }
Ejemplo n.º 4
0
        public string GetWarnValue(string time = "", string orgCode = "", string orgId = "")
        {
            RiskBLL riskBLL = new RiskBLL();                                      //安全风险
            SaftyCheckDataRecordBLL saBLL        = new SaftyCheckDataRecordBLL(); //安全检查
            HTBaseInfoBLL           htBLL        = new HTBaseInfoBLL();           //事故隐患
            Operator                    user     = OperatorProvider.Provider.Current();
            ClassificationBLL           classBLL = new ClassificationBLL();
            List <ClassificationEntity> list     = classBLL.GetList(user.OrganizeId).ToList();

            if (list.Count == 0)
            {
                list = classBLL.GetList("0").ToList();
            }
            decimal totalScore = 0; int count = 0;

            if (user.RoleName.Contains("省级用户") || user.RoleName.Contains("集团用户"))
            {
                if (!string.IsNullOrEmpty(orgCode))
                {
                    user = new Operator
                    {
                        OrganizeId   = orgId,
                        OrganizeCode = orgCode,
                        RoleName     = "公司级用户,公司领导"
                    };
                    totalScore = desktopbll.GetScore(user, time);
                }
                else
                {
                    OrganizeBLL orgBll = new OrganizeBLL();
                    DataTable   dt     = orgBll.GetDTList();
                    foreach (DataRow dr in dt.Rows)
                    {
                        user = new Operator
                        {
                            OrganizeId   = dr[2].ToString(),
                            OrganizeCode = dr[0].ToString(),
                            RoleName     = "公司级用户,公司领导"
                        };
                        totalScore += desktopbll.GetScore(user, time);
                    }
                    totalScore = totalScore / dt.Rows.Count;
                }
            }
            else
            {
                totalScore = desktopbll.GetScore(user, time);
            }
            DataItemDetailBLL itemBLL = new DataItemDetailBLL();
            string            val     = itemBLL.GetItemValue("基础预警区间分值设置");

            count = 0;
            if (!string.IsNullOrEmpty(val))
            {
                string[] arr = val.Split('|');
                int      j   = 0;
                foreach (string str in arr)
                {
                    string[] arrVal = str.Split(',');
                    if (totalScore > decimal.Parse(arrVal[0]) && totalScore <= decimal.Parse(arrVal[1]))
                    {
                        count = j;
                        break;
                    }
                    j++;
                }
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(new { score = Math.Round(totalScore, 1), index = count }));
        }
Ejemplo n.º 5
0
        public string GetSafeCheckWarningM()
        {
            SaftyCheckDataRecordBLL saBLL = new SaftyCheckDataRecordBLL();

            return(saBLL.GetSafeCheckWarningS());
        }
Ejemplo n.º 6
0
        public object getHomeWarning([FromBody] JObject json)
        {
            string  res    = json.Value <string>("json");
            dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
            string  userId = dy.userid;

            //获取用户基本信息
            OperatorProvider.AppUserId = userId;  //设置当前用户
            Operator user = OperatorProvider.Provider.Current();

            DesktopBLL desktopbll                = new DesktopBLL();
            RiskBLL    riskBLL                   = new RiskBLL();                 //安全风险
            SaftyCheckDataRecordBLL     saBLL    = new SaftyCheckDataRecordBLL(); //安全检查
            HTBaseInfoBLL               htBLL    = new HTBaseInfoBLL();           //事故隐患
            ClassificationBLL           classBLL = new ClassificationBLL();
            DataItemDetailBLL           itemBLL  = new DataItemDetailBLL();
            List <ClassificationEntity> list     = classBLL.GetList(user.OrganizeId).ToList();

            if (list.Count == 0)
            {
                list = classBLL.GetList("0").ToList();
            }
            decimal totalScore     = 0;
            decimal yhscore        = 0;
            decimal aqjcscore      = 0;
            decimal aqfxscore      = 0;
            decimal yhzlstardard   = 0;
            decimal aqjcstardard   = 0;
            decimal aqfxstardard   = 0;
            decimal qualifiedscore = 0;

            decimal yhscore1   = 0;
            decimal aqjcscore1 = 0;
            decimal aqfxscore1 = 0;

            string val   = itemBLL.GetItemValue("基础预警区间分值设置");
            int    count = 0;

            if (user.RoleName.Contains("省级"))
            {
                DataTable dtDepts = new DepartmentBLL().GetAllFactory(user);
                foreach (DataRow dr in dtDepts.Rows)
                {
                    user = new Operator
                    {
                        OrganizeId   = dr[2].ToString(),
                        OrganizeCode = dr[0].ToString(),
                    };
                    totalScore += desktopbll.GetScore(user, "");


                    //计算事故隐患总得分
                    decimal score = htBLL.GetHiddenWarning(user, "");
                    totalScore   += score * decimal.Parse(list[0].WeightCoeffcient);
                    yhscore1     += score * decimal.Parse(list[0].WeightCoeffcient);
                    yhzlstardard += score;
                    //计算安全检查总得分
                    score         = saBLL.GetSafeCheckSumCount(user);
                    totalScore   += score * decimal.Parse(list[1].WeightCoeffcient);
                    aqjcscore1   += score * decimal.Parse(list[1].WeightCoeffcient);
                    aqjcstardard += score;
                    //计算安全风险总得分
                    score         = riskBLL.GetRiskValueByTime(user, "");
                    totalScore   += score * decimal.Parse(list[2].WeightCoeffcient);
                    aqfxscore1   += score * decimal.Parse(list[2].WeightCoeffcient);
                    aqfxstardard += score;
                }

                totalScore = totalScore / dtDepts.Rows.Count;
                yhscore    = yhscore1 / dtDepts.Rows.Count;
                aqjcscore  = aqjcscore1 / dtDepts.Rows.Count;
                aqfxscore  = aqfxscore1 / dtDepts.Rows.Count;

                yhzlstardard = yhzlstardard / dtDepts.Rows.Count;
                aqjcstardard = aqjcstardard / dtDepts.Rows.Count;
                aqfxstardard = aqfxstardard / dtDepts.Rows.Count;
            }
            else
            {
                //计算事故隐患总得分
                decimal score = htBLL.GetHiddenWarning(user, "");
                totalScore   = score * decimal.Parse(list[0].WeightCoeffcient);
                yhscore      = score * decimal.Parse(list[0].WeightCoeffcient);
                yhzlstardard = score;
                //计算安全检查总得分
                score        = saBLL.GetSafeCheckSumCount(user);
                totalScore  += score * decimal.Parse(list[1].WeightCoeffcient);
                aqjcscore    = score * decimal.Parse(list[1].WeightCoeffcient);
                aqjcstardard = score;
                //计算安全风险总得分
                score        = riskBLL.GetRiskValueByTime(user, "");
                totalScore  += score * decimal.Parse(list[2].WeightCoeffcient);
                aqfxscore    = score * decimal.Parse(list[2].WeightCoeffcient);
                aqfxstardard = score;
            }
            count = 0;
            if (!string.IsNullOrEmpty(val))
            {
                string[] arr = val.Split('|');
                int      j   = 0;
                foreach (string str in arr)
                {
                    string[] arrVal = str.Split(',');

                    if (totalScore > decimal.Parse(arrVal[0]) && totalScore <= decimal.Parse(arrVal[1]))
                    {
                        count = j;
                        break;
                    }
                    j++;
                }
                qualifiedscore = decimal.Parse(arr[2].Split(',')[0].ToString());
            }
            string warningtext = string.Empty;

            switch (count)
            {
            case 0:
                warningtext = "危险";
                break;

            case 1:
                warningtext = "较危险";
                break;

            case 2:
                warningtext = "较安全";
                break;

            case 3:
                warningtext = "安全";
                break;
            }
            bool isyhzlsucess = Math.Round(yhzlstardard, 1) >= qualifiedscore ? true : false;
            bool isaqjcsucess = Math.Round(aqjcstardard, 1) >= qualifiedscore ? true : false;
            bool isaqfxsucess = Math.Round(aqfxstardard, 1) >= qualifiedscore ? true : false;

            return(new { code = 0, data = new { score = Math.Round(totalScore, 1), yhscore = Math.Round(yhscore, 1), aqjcscore = Math.Round(aqjcscore, 1), aqfxscore = Math.Round(aqfxscore, 1), index = count, warningtext = warningtext, isyhzlsucess = isyhzlsucess, isaqjcsucess = isaqjcsucess, isaqfxsucess = isaqfxsucess }, count = 0 });
        }
Ejemplo n.º 7
0
        public object getWarningInfo([FromBody] JObject json)
        {
            string  res        = json.Value <string>("json");
            dynamic dy         = JsonConvert.DeserializeObject <ExpandoObject>(res);
            string  userId     = dy.userid;
            string  startmonth = dy.data.startmonth; //检索对应得月份  格式"2017-11"

            string starDate = startmonth + "-01";    //起始时间

            //获取用户基本信息
            OperatorProvider.AppUserId = userId;  //设置当前用户
            Operator user = OperatorProvider.Provider.Current();

            decimal riskscore   = 0; //安全风险得分
            decimal safetyscore = 0; //安全检查得分
            decimal hiddenscore = 0; //隐患排查得分

            /*计算对应的分项总分*/
            RiskBLL riskBLL = new RiskBLL();
            SaftyCheckDataRecordBLL saftybll = new SaftyCheckDataRecordBLL();

            if (user.RoleName.Contains("省级"))
            {
                DataTable dtDepts = new DepartmentBLL().GetAllFactory(user);
                foreach (DataRow dr in dtDepts.Rows)
                {
                    user = new Operator
                    {
                        OrganizeId   = dr[2].ToString(),
                        OrganizeCode = dr[0].ToString(),
                        DeptCode     = dr[0].ToString()
                    };
                    //安全风险得分 增加自己的总分(非权重计算的)

                    riskscore += riskBLL.GetRiskValueByTime(user, starDate);

                    //安全检查得分 增加自己的总分(非权重计算的)

                    safetyscore += saftybll.GetSafeCheckWarningM(user, starDate, 1);

                    //隐患排查得分 增加自己的总分(非权重计算的)
                    hiddenscore += new HTBaseInfoBLL().GetHiddenWarning(user, starDate);
                }
                riskscore   = riskscore / dtDepts.Rows.Count;
                safetyscore = safetyscore / dtDepts.Rows.Count;
                hiddenscore = hiddenscore / dtDepts.Rows.Count;

                riskscore   = Math.Round(riskscore, 2);
                safetyscore = Math.Round(safetyscore, 2);
                hiddenscore = Math.Round(hiddenscore, 2);
            }
            //获取结果集
            DataTable dt = new DataTable();

            dt.Columns.Add("indexname");             //分项指标
            dt.Columns.Add("score");                 //总得分
            dt.Columns.Add("weight");                //权重
            dt.Columns.Add("lastscore");             //加权重所得
            decimal           totalscore        = 0; //合计总得分
            ClassificationBLL classificationbll = new ClassificationBLL();
            var list = classificationbll.GetList(user.OrganizeId);

            if (list.Count() == 0)
            {
                list = classificationbll.GetList("0");
            }
            foreach (ClassificationEntity entity in list)
            {
                DataRow row = dt.NewRow();
                row["indexname"] = entity.ClassificationIndex;
                row["weight"]    = entity.WeightCoeffcient;
                switch (entity.ClassificationCode)
                {
                case "01":     //隐患排查
                    row["score"] = hiddenscore;

                    break;

                case "02":    //安全检查
                    row["score"] = safetyscore;
                    break;

                case "03":     //安全风险
                    row["score"] = riskscore;
                    break;
                }
                row["lastscore"] = Convert.ToDecimal(row["score"].ToString()) * Convert.ToDecimal(entity.WeightCoeffcient); //增加权重系数,计算得分
                totalscore      += Convert.ToDecimal(row["lastscore"].ToString());                                          //累加权重系数后所得分项总分
                dt.Rows.Add(row);
            }

            return(new
            {
                code = 0,
                count = 0,
                data = dt,
                score = totalscore
            });
        }