Пример #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));
        }
Пример #2
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 });
        }