コード例 #1
0
        public object GetHtml([FromBody] JObject json)
        {
            try
            {
                string      res  = json.Value <string>("json");
                dynamic     dy   = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string      name = dy.data.name;
                DataItemBLL di   = new DataItemBLL();
                //先获取到字典项
                DataItemEntity DataItems = di.GetEntityByCode("Standard");

                DataItemDetailBLL did = new DataItemDetailBLL();
                //根据字典项获取值
                IEnumerable <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId);

                List <DataItemDetailEntity> dlist = didList.Where(it => it.ItemName == name).ToList();
                if (dlist.Count > 0)
                {
                    string path = did.GetItemValue("imgUrl") + "/Content/SecurityDynamics/Phone.html?url=" + dlist[0].Description + "&top=" + did.GetItemValue("imgUrl");
                    return(new { Code = 0, Count = 1, Info = "获取数据成功", url = path });
                }
                else
                {
                    return(new { Code = 0, Count = 1, Info = "获取数据成功", url = "" });
                }
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
コード例 #2
0
 public ActionResult Index()
 {
     string ItemCode = Request["ItemCode"];
     var data = dataItemBLL.GetEntityByCode(ItemCode);
     ViewBag.itemId = data.ItemId;
     ViewBag.isTree = data.IsTree;
     return View();
 }
コード例 #3
0
        /// <summary>
        /// 获取字典值
        /// </summary>
        /// <param name="Code">数据字典值</param>
        /// <returns></returns>
        public ActionResult GetCmbJson(string Code)
        {
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity DataItems = di.GetEntityByCode(Code);

            DataItemDetailBLL did = new DataItemDetailBLL();
            //根据字典项获取值
            IEnumerable <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId);

            return(Content(didList.ToJson()));
        }
コード例 #4
0
 /// <summary>
 /// 根据编码获取项目
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public DataItemEntity GetDataItemEntityByCode(string code)
 {
     if (!string.IsNullOrEmpty(code))
     {
         DataItemEntity entity = CacheFactory.GetCacheInstance().GetCache <DataItemEntity>("__" + code);
         if (entity == null)
         {
             entity = _dataItemBll.GetEntityByCode(code);
             CacheFactory.GetCacheInstance().WriteCache(entity, "__" + code);
         }
         return(entity);
     }
     return(default(DataItemEntity));
 }
コード例 #5
0
        public ActionResult GetLableStatistics()
        {
            var dt = lablemanagebll.GetLableStatistics();
            List <LablemanageEntity> lblist = lablemanagebll.GetList("").Where(it => it.IsBind == 1).ToList();;
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity DataItems = di.GetEntityByCode("LabelType");

            DataItemDetailBLL did = new DataItemDetailBLL();
            //根据字典项获取值
            List <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId).ToList();
            List <KbsEntity>            klist   = new List <KbsEntity>();
            int Znum = 0;

            foreach (var item in didList)
            {
                KbsEntity kbs = new KbsEntity();
                kbs.Name = item.ItemName;
                int num   = 0;
                int zxnum = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["labletypeid"].ToString() == item.ItemValue)
                    {
                        num   = Convert.ToInt32(dt.Rows[i]["cou"]);
                        zxnum = lblist.Where(it => it.LableTypeId == item.ItemValue && it.State == "在线").Count();
                        break;
                    }
                }
                kbs.Num  = num;
                Znum    += num;
                kbs.Num2 = zxnum;
                klist.Add(kbs);
            }
            for (int j = 0; j < klist.Count; j++)
            {
                double Proportion = 0;
                if (Znum != 0)
                {
                    Proportion = (double)klist[j].Num / Znum;
                    Proportion = Proportion * 100;
                }
                klist[j].Proportion = Proportion.ToString("0") + "%";
            }
            return(Content(klist.ToJson()));
        }
コード例 #6
0
        public ActionResult GetUserOnlineGroupJson()
        {
            string      sql = string.Format("select t.labletypename,t.labletypeid,count(1)as num from bis_lableonlinelog d join bis_lablemanage t on d.lableid=t.lableid where d.isout=0 and t.type=0 and t.state='在线' group by t.labletypename,t.labletypeid ");
            var         dt  = Opertickebll.GetDataTable(sql);
            DataItemBLL di  = new DataItemBLL();
            //先获取到字典项
            DataItemEntity    DataItems = di.GetEntityByCode("LabelType");
            DataItemDetailBLL did       = new DataItemDetailBLL();
            //根据字典项获取值
            List <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId).Where(a => a.ItemName != "厂外车辆" && a.ItemName != "厂内车辆").ToList();
            List <KbsEntity>            klist   = new List <KbsEntity>();
            int Znum = 0;

            foreach (var item in didList)
            {
                KbsEntity kbs = new KbsEntity();
                kbs.Name = item.ItemName;
                int num = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["labletypeid"].ToString() == item.ItemValue)
                    {
                        num = Convert.ToInt32(dt.Rows[i]["num"]);
                        break;
                    }
                }
                kbs.Num = num;
                Znum   += num;
                klist.Add(kbs);
            }
            for (int j = 0; j < klist.Count; j++)
            {
                double Proportion = 0;
                if (Znum != 0)
                {
                    Proportion = (double)klist[j].Num / Znum;
                    Proportion = Proportion * 100;
                }
                klist[j].Num2       = Znum;
                klist[j].Proportion = Proportion.ToString("0.00") + "%";
            }
            return(Content(klist.ToJson()));
        }
コード例 #7
0
        /// <summary>
        /// 导出到Excel
        /// </summary>
        /// <param name="queryJson"></param>
        /// <returns></returns>
        public ActionResult Excel(string queryJson)
        {
            string column       = "IDNUM,OCCDETAILID,USERNAME,USERNAMEPINYIN,INSPECTIONTIME,ISSICK,SICKTYPE,ISENDEMIC,ISUNUSUAL,UNUSUALNOTE";
            string stringcolumn = "ISSICK,SICKTYPE";

            string[] columns       = column.Split(',');
            string[] stringcolumns = stringcolumn.Split(',');

            string   wheresql = "";
            Operator user     = ERCHTMS.Code.OperatorProvider.Provider.Current();

            if (user.IsSystem)
            {
                wheresql = "";
            }
            else
            {
                string where = new ERCHTMS.Busines.AuthorizeManage.AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value);
                wheresql    += " and " + where;
            }

            DataTable dt    = occupationalstaffdetailbll.GetTable(queryJson, wheresql);
            DataTable Newdt = AsposeExcelHelper.UpdateDataTable(dt, columns, stringcolumns);//把所有字段转换成string 方便修改

            //先获取职业病数据
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity    DataItems = di.GetEntityByCode("SICKTYPE");
            DataItemDetailBLL did       = new DataItemDetailBLL();
            //根据字典项获取值
            IEnumerable <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId);

            //循环修改信息
            for (int i = 0; i < Newdt.Rows.Count; i++)
            {
                Newdt.Rows[i]["IDNUM"]          = i + 1;
                Newdt.Rows[i]["INSPECTIONTIME"] = Convert.ToDateTime(Newdt.Rows[i]["INSPECTIONTIME"]).ToString("yyyy-MM-dd");
                if (Convert.ToInt32(Newdt.Rows[i]["ISSICK"]) == 1)
                {
                    Newdt.Rows[i]["ISSICK"] = "是";
                    foreach (DataItemDetailEntity item in didList)
                    {
                        if (item.ItemValue == Newdt.Rows[i]["SICKTYPE"].ToString())
                        {
                            Newdt.Rows[i]["SICKTYPE"] = item.ItemName;
                        }
                    }
                }
                else
                {
                    Newdt.Rows[i]["ISSICK"]   = "否";
                    Newdt.Rows[i]["SICKTYPE"] = "";
                }
            }

            string FileUrl = "";

            var    queryParam = queryJson.ToJObject();
            string keyord     = queryParam["keyword"].ToString();

            if (keyord.ToInt() == 1) //查询职业病
            {
                FileUrl = @"\Resource\ExcelTemplate\职业健康职业病人员列表_导出模板.xlsx";
                AsposeExcelHelper.ExecuteResult(Newdt, FileUrl, "职业病人员列表", "职业病人员列表");
            }
            else if (keyord.ToInt() == 2)  //查询异常人员
            {
                FileUrl = @"\Resource\ExcelTemplate\职业健康异常人员列表_导出模板.xlsx";
                AsposeExcelHelper.ExecuteResult(Newdt, FileUrl, "异常人员列表", "异常人员列表");
            }
            else if (keyord.ToInt() == 3)  //查询体检人员
            {
                FileUrl = @"\Resource\ExcelTemplate\职业健康体检人员列表_导出模板.xlsx";
                AsposeExcelHelper.ExecuteResult(Newdt, FileUrl, "体检人员列表", "体检人员列表");
            }



            return(Success("导出成功。"));
        }
コード例 #8
0
        public ActionResult GetOccpuationalTreeJson(string Code, int checkMode = 0, int mode = 0, string deptIds = "0")
        {
            DataItemBLL di = new DataItemBLL();
            //先获取到字典项
            DataItemEntity DataItems = di.GetEntityByCode(Code);

            DataItemDetailBLL did = new DataItemDetailBLL();
            //根据字典项获取值
            List <DataItemDetailEntity> didList = did.GetList(DataItems.ItemId).OrderBy(t => t.ItemValue).ToList();


            string      parentId = "0";
            OrganizeBLL orgBLL   = new OrganizeBLL();
            var         treeList = new List <TreeEntity>();

            //获取所有父节点集合
            List <DataItemDetailEntity> parentList = didList.Where(it => it.ItemValue.Length == 3).ToList();

            //获取所有子节点节点集合
            List <DataItemDetailEntity> SunList = didList.Where(it => it.ItemValue.Length > 3).ToList();

            foreach (DataItemDetailEntity oe in parentList)
            {
                treeList.Add(new TreeEntity
                {
                    id              = oe.ItemValue,
                    text            = oe.ItemName,
                    value           = oe.ItemValue,
                    parentId        = "0",
                    isexpand        = true,
                    complete        = true,
                    showcheck       = false,
                    hasChildren     = true,
                    Attribute       = "Sort",
                    AttributeValue  = "Parent",
                    AttributeA      = "manager",
                    AttributeValueA = "" + "," + "" + ",1"
                });
            }

            foreach (DataItemDetailEntity item in SunList)
            {
                int      chkState = 0;
                string[] arrids   = deptIds.Split(',');
                if (arrids.Contains(item.ItemValue))
                {
                    chkState = 1;
                }
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                tree.id              = item.ItemValue;
                tree.text            = item.ItemName;
                tree.value           = item.ItemValue;
                tree.isexpand        = true;
                tree.complete        = true;
                tree.checkstate      = chkState;
                tree.showcheck       = checkMode == 0 ? false : true;
                tree.hasChildren     = hasChildren;
                tree.parentId        = item.ItemValue.Substring(0, 3);
                tree.Attribute       = "Sort";
                tree.AttributeValue  = "Sun";
                tree.AttributeA      = "manager";
                tree.AttributeValueA = "" + "," + "" + "," + "2";
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson()));
        }
コード例 #9
0
ファイル: ReportController.cs プロジェクト: paddy235/ERCHTMS
        public string GetReport()
        {
            BulletinBLL      bulletinbll      = new BulletinBLL();
            Bulletin_dealBLL bulletin_dealbll = new Bulletin_dealBLL();
            WSSJBGBLL        wssjbgbll        = new WSSJBGBLL();
            //查询条件
            var TimeStart     = Request["TimeStart"] ?? "";
            var TimeEnd       = Request["TimeEnd"] ?? "";
            var dlrsswtype    = Request["dlrsswtype"] ?? "";
            var sgtype        = Request["sgtype"] ?? "";
            var wssjtype      = Request["wssjtype"] ?? "";
            var bjnf          = Request["bjnf"] ?? "";
            var type          = int.Parse(Request["type"] ?? "0");
            var returnListObj = new List <Object>();
            var data          = new object();
            //统计时间
            var times = DateTime.Now;
            var timee = DateTime.Now;

            if (TimeStart.Length > 0)
            {
                times = DateTime.Parse(TimeStart);
            }
            if (TimeEnd.Length > 0)
            {
                timee = DateTime.Parse(TimeEnd).AddDays(1);
            }
            //事故事件类型统计

            var count  = 0;
            var count1 = 0;
            var count2 = 0;

            #region 权限
            string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "CREATEUSERDEPTCODE", "CREATEUSERORGCODE");
            string sqlwhere = " and IsSubmit_Deal=1 ";
            if (!string.IsNullOrEmpty(where))
            {
                sqlwhere += " and " + where;
            }
            else
            {
                Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                sqlwhere += string.Format(" and CREATEUSERDEPTCODE like '{0}%'", user.DeptCode);
            }
            #endregion
            switch (type)
            {
            //按事故事件类型统计
            case 0:
                var list = bulletin_dealbll.GetList(sqlwhere).Where(e => e.SGTYPE_DEAL != null && (TimeStart.Length > 0 ? e.HAPPENTIME_DEAL >= times : 1 == 1) &&
                                                                    (TimeEnd.Length > 0 ? e.HAPPENTIME_DEAL <= timee : 1 == 1));
                if (list != null)
                {
                    count = list.Count();
                    var date = list.ToList().GroupBy(e => e.SGTYPENAME_DEAL);
                    foreach (var item in date)
                    {
                        var itemCount = decimal.Parse(item.Count().ToString());
                        returnListObj.Add(new { text = item.Key, value = itemCount, bfb = decimal.Round((itemCount / count) * 100, 2) });
                    }
                }
                break;

            //按事故等级统计
            case 1:
                var list1 = bulletin_dealbll.GetList(sqlwhere).Where(e => e.SGTYPENAME_DEAL.Contains("事故") && e.SGLEVEL_DEAL != null && (TimeStart.Length > 0 ? e.HAPPENTIME_DEAL >= times : 1 == 1) &&
                                                                     (TimeEnd.Length > 0 ? e.HAPPENTIME_DEAL <= timee : 1 == 1) && (sgtype.Length > 0 ? e.SGTYPE_DEAL == sgtype : 1 == 1));
                if (list1 != null)
                {
                    count = list1.Count();
                    var date = list1.ToList().GroupBy(e => e.SGLEVELNAME_DEAL);
                    foreach (var item in date)
                    {
                        var itemCount = decimal.Parse(item.Count().ToString());
                        returnListObj.Add(new { text = item.Key, value = itemCount, bfb = decimal.Round((itemCount / count) * 100, 2) });
                    }
                }

                break;

            //按伤亡人数统计
            case 2:
                var list2 = bulletin_dealbll.GetList(sqlwhere).Where(e => e.SGTYPENAME_DEAL.Contains("人身伤亡事故") && e.SGLEVEL_DEAL != null && (TimeStart.Length > 0 ? e.HAPPENTIME_DEAL >= times : 1 == 1) &&
                                                                     (TimeEnd.Length > 0 ? e.HAPPENTIME_DEAL <= timee : 1 == 1) && (sgtype.Length > 0 ? e.SGTYPE_DEAL == sgtype : 1 == 1));
                count = list2.Count();
                if (list2 != null && count > 0)
                {
                    var query = from l in list2
                                group l by new { l.SGLEVELNAME_DEAL } into tab
                        select new
                    {
                        text  = tab.Key.SGLEVELNAME_DEAL,
                        value = tab.Count(),
                        swnum = list2.Where(e => e.SGLEVELNAME_DEAL == tab.Key.SGLEVELNAME_DEAL).Sum(p => p.SWNUM_DEAL),
                        zsnum = list2.Where(e => e.SGLEVELNAME_DEAL == tab.Key.SGLEVELNAME_DEAL).Sum(p => p.ZSNUM_DEAL),
                        sznum = list2.Where(e => e.SGLEVELNAME_DEAL == tab.Key.SGLEVELNAME_DEAL).Sum(p => p.SZNUM_DEAL),
                        qsnum = list2.Where(e => e.SGLEVELNAME_DEAL == tab.Key.SGLEVELNAME_DEAL).Sum(p => p.QSNUM_DEAL)
                    };
                    returnListObj.AddRange(query);
                }
                break;

            //人身伤害事故类别统计
            case 3:
                var list3 = bulletin_dealbll.GetList(sqlwhere).Where(e => e.SGTYPENAME_DEAL.Contains("人身伤亡事故") && e.RSSHSGTYPE_DEAL != null && (TimeStart.Length > 0 ? e.HAPPENTIME_DEAL >= times : 1 == 1) &&
                                                                     (TimeEnd.Length > 0 ? e.HAPPENTIME_DEAL <= timee : 1 == 1) && (sgtype.Length > 0 ? e.SGTYPE_DEAL == sgtype : 1 == 1));
                count = list3.Count();
                if (list3 != null && count > 0)
                {
                    var query = from l in list3
                                group l by new { l.RSSHSGTYPENAME_DEAL } into tab
                        select new
                    {
                        text  = tab.Key.RSSHSGTYPENAME_DEAL,
                        value = tab.Count(),
                        swnum = list3.Where(e => e.RSSHSGTYPENAME_DEAL == tab.Key.RSSHSGTYPENAME_DEAL).Sum(p => p.SWNUM_DEAL),
                        zsnum = list3.Where(e => e.RSSHSGTYPENAME_DEAL == tab.Key.RSSHSGTYPENAME_DEAL).Sum(p => p.ZSNUM_DEAL),
                        sznum = list3.Where(e => e.RSSHSGTYPENAME_DEAL == tab.Key.RSSHSGTYPENAME_DEAL).Sum(p => p.SZNUM_DEAL),
                        qsnum = list3.Where(e => e.RSSHSGTYPENAME_DEAL == tab.Key.RSSHSGTYPENAME_DEAL).Sum(p => p.QSNUM_DEAL)
                    };
                    var listnow = query.ToList();
                    returnListObj.AddRange(query);
                }
                break;

            //伤亡事故原因统计
            case 4:
                var listXXX = bulletin_dealbll.GetList(sqlwhere);
                var list4   = bulletin_dealbll.GetList(sqlwhere).Where(e => (TimeStart.Length > 0 ? e.HAPPENTIME_DEAL >= times : 1 == 1) &&
                                                                       (TimeEnd.Length > 0 ? e.HAPPENTIME_DEAL <= timee : 1 == 1) && (e.SGTYPENAME_DEAL != null ? e.SGTYPENAME_DEAL.Contains("人身伤亡事故") : e.SGTYPENAME_DEAL != null) &&
                                                                       (sgtype.Length > 0 ? e.SGTYPE_DEAL == sgtype : 1 == 1));
                count = list4.Count();

                var xwtext  = "A不安全行为";
                int xwswnum = 0;
                int xwzsnum = 0;
                int xwsznum = 0;
                int xwqsnum = 0;
                int xwvalue = 0;
                var zttext  = "B不安全状态";
                int ztswnum = 0;
                int ztzsnum = 0;
                int ztsznum = 0;
                int ztqsnum = 0;
                int ztvalue = 0;
                //查询包含不安全行为的数据有多少条
                #region  安全行为的数据
                var entityXW     = dataItemBLL.GetEntityByCode("AEM_BAQXW");
                var listXWdetail = dataItemDetailBLL.GetListByCode(entityXW.ItemCode);
                foreach (DataRow row in listXWdetail.Rows)
                {
                    count1++;
                    //是否包含
                    var itemname = row["ItemName"].ToString();
                    var listxw   = list4.Where(e => (e.BAQXWNAME != null) && e.BAQXWNAME.Contains(row["ItemName"].ToString())).ToList();
                    int swnum1   = 0;
                    int zsnum1   = 0;
                    int sznum1   = 0;
                    int qsnum1   = 0;
                    int value1   = 0;
                    if (listxw != null)
                    {
                        value1 = listxw.Count();
                        foreach (var item in listxw)
                        {
                            xwswnum += item.SWNUM_DEAL.Value;
                            xwzsnum += item.ZSNUM_DEAL.Value;
                            xwsznum += item.SZNUM_DEAL.Value;
                            xwqsnum += item.QSNUM_DEAL.Value;

                            swnum1 += item.SWNUM_DEAL.Value;
                            zsnum1 += item.ZSNUM_DEAL.Value;
                            sznum1 += item.SZNUM_DEAL.Value;
                            qsnum1 += item.QSNUM_DEAL.Value;
                        }
                        xwvalue += value1;
                        returnListObj.Add(new { type = 1, text = row["ItemName"].ToString(), value = value1, swnum = swnum1, zsnum = zsnum1, sznum = sznum1, qsnum = qsnum1 });
                    }
                    else
                    {
                        returnListObj.Add(new { type = 1, text = row["ItemName"].ToString(), value = value1, swnum = swnum1, zsnum = zsnum1, sznum = sznum1, qsnum = qsnum1 });
                    }
                }
                returnListObj.Insert(0, new { type = 1, text = xwtext, value = xwvalue, swnum = xwsznum, zsnum = xwzsnum, sznum = xwsznum, qsnum = xwqsnum });

                #endregion


                #region  安全状态的数据
                var entityZT     = dataItemBLL.GetEntityByCode("AEM_BAQZT");
                var listZTdetail = dataItemDetailBLL.GetListByCode(entityZT.ItemCode);
                foreach (DataRow row in listZTdetail.Rows)
                {
                    count2++;
                    count1++;
                    //是否包含
                    var listzt = list4.Where(e => (e.BAQZTNAME != null) && e.BAQZTNAME.Contains(row["ItemName"].ToString()));
                    int swnum2 = 0;
                    int zsnum2 = 0;
                    int sznum2 = 0;
                    int qsnum2 = 0;
                    int value2 = 0;
                    if (listzt != null)
                    {
                        value2 = listzt.Count();
                        foreach (var item in listzt)
                        {
                            ztswnum += item.SWNUM_DEAL.Value;
                            ztzsnum += item.ZSNUM_DEAL.Value;
                            ztsznum += item.SZNUM_DEAL.Value;
                            ztqsnum += item.QSNUM_DEAL.Value;

                            swnum2 += item.SWNUM_DEAL.Value;
                            zsnum2 += item.ZSNUM_DEAL.Value;
                            sznum2 += item.SZNUM_DEAL.Value;
                            qsnum2 += item.QSNUM_DEAL.Value;
                        }
                        ztvalue += value2;

                        returnListObj.Add(new { type = 1, text = row["ItemName"].ToString(), value = value2, swnum = swnum2, zsnum = zsnum2, sznum = sznum2, qsnum = qsnum2 });
                    }
                    else
                    {
                        returnListObj.Add(new { type = 1, text = row["ItemName"].ToString(), value = value2, swnum = swnum2, zsnum = zsnum2, sznum = sznum2, qsnum = qsnum2 });
                    }
                }
                returnListObj.Insert(count1 - count2 + 1, new { type = 1, text = zttext, value = ztvalue, swnum = ztsznum, zsnum = ztzsnum, sznum = ztsznum, qsnum = ztqsnum });
                #endregion


                #region 间接原因
                var entityJJYY = dataItemBLL.GetEntityByCode("AEM_JJYY");
                var listJJYY   = dataItemDetailBLL.GetListByCode(entityJJYY.ItemCode);
                foreach (DataRow row in listJJYY.Rows)
                {
                    count2++;
                    //是否包含
                    var listjjyy = list4.Where(e => (e.JJYYNAME != null) && e.JJYYNAME.Contains(row["ItemName"].ToString()));
                    int swnum3   = 0;
                    int zsnum3   = 0;
                    int sznum3   = 0;
                    int qsnum3   = 0;
                    int value3   = 0;
                    if (listjjyy != null)
                    {
                        value3 = listjjyy.Count();
                        foreach (var item in listjjyy)
                        {
                            swnum3 += item.SWNUM_DEAL.Value;
                            zsnum3 += item.ZSNUM_DEAL.Value;
                            sznum3 += item.SZNUM_DEAL.Value;
                            qsnum3 += item.QSNUM_DEAL.Value;
                        }
                        //xwvalue += value3;
                        returnListObj.Add(new { type = 2, text = row["ItemName"].ToString(), value = value3, swnum = swnum3, zsnum = zsnum3, sznum = sznum3, qsnum = qsnum3 });
                    }
                    else
                    {
                        returnListObj.Add(new { type = 2, text = row["ItemName"].ToString(), value = value3, swnum = swnum3, zsnum = zsnum3, sznum = sznum3, qsnum = qsnum3 });
                    }
                }
                #endregion
                count1 = count1 + 2;
                break;

            //按年份统计
            case 5:
                var listYear = new List <int>();
                if (bjnf.Length > 0 && bjnf != "0")
                {
                    //近五年
                    if (bjnf == "1")
                    {
                        timee = DateTime.Now;
                        for (int i = 1; i < 5; i++)
                        {
                            listYear.Add(times.Year - i);
                        }
                        times = DateTime.Now.AddYears(-5);
                    }
                    //近十年
                    if (bjnf == "2")
                    {
                        timee = DateTime.Now;
                        for (int i = 1; i < 10; i++)
                        {
                            listYear.Add(times.Year - i);
                        }
                        times = DateTime.Now.AddYears(-10);
                    }
                }
                var list5 = bulletin_dealbll.GetList(sqlwhere).Where(e => e.HAPPENTIME_DEAL != null &&
                                                                     (TimeStart.Length > 0 ? e.HAPPENTIME_DEAL.Value.Year >= times.Year : 1 == 1) &&
                                                                     (TimeEnd.Length > 0 ? e.HAPPENTIME_DEAL.Value.Year <= timee.Year : 1 == 1) &&
                                                                     (sgtype == "-1" ? e.SGTYPENAME_DEAL.Contains("事件") : 1 == 1) && //所有的事件
                                                                     (sgtype == "-2" ? e.SGTYPENAME_DEAL.Contains("事故") : 1 == 1) && //所有的事故
                                                                     ((sgtype.Length > 0 && sgtype != "-1" && sgtype != "-2") ? e.SGTYPE_DEAL == sgtype : 1 == 1) //选择了具体的事故或者事件
                                                                     );
                count = list5.Count();
                if (list5 != null && count > 0)
                {
                    var query = from l in list5
                                group l by new { l.HAPPENTIME_DEAL.Value.Year } into tab
                        select new
                    {
                        text  = tab.Key.Year,
                        value = list5.Where(e => e.HAPPENTIME_DEAL.Value.Year == tab.Key.Year).Count(),
                        swnum = list5.Where(e => e.HAPPENTIME_DEAL.Value.Year == tab.Key.Year).Sum(p => p.SWNUM_DEAL),
                        zsnum = list5.Where(e => e.HAPPENTIME_DEAL.Value.Year == tab.Key.Year).Sum(p => p.ZSNUM_DEAL),
                        sznum = list5.Where(e => e.HAPPENTIME_DEAL.Value.Year == tab.Key.Year).Sum(p => p.SZNUM_DEAL),
                        qsnum = list5.Where(e => e.HAPPENTIME_DEAL.Value.Year == tab.Key.Year).Sum(p => p.QSNUM_DEAL)
                    };
                    var listQuery = query.ToList();
                    foreach (var item in query)
                    {
                        if (listYear.Contains(item.text))
                        {
                            continue;
                        }
                        else
                        {
                            listYear.Remove(item.text);
                        }
                    }
                    foreach (var item in listYear)
                    {
                        returnListObj.Add(new { text = item, value = 0, swnum = 0, zsnum = 0, sznum = 0, qsnum = 0 });
                    }

                    returnListObj.AddRange(query);
                }
                break;

            //按未遂事件类型统计
            case 6:
                var list6 = wssjbgbll_deal.GetList(sqlwhere).Where(e => e.WssjType_Deal != null && (TimeStart.Length > 0 ? e.HappenTime_Deal >= times : 1 == 1) &&
                                                                   (TimeEnd.Length > 0 ? e.HappenTime_Deal <= timee : 1 == 1));
                count = list6.Count();
                if (list6 != null && count > 0)
                {
                    var date = list6.ToList().GroupBy(e => e.WssjTypeName_Deal);
                    foreach (var item in date)
                    {
                        var itemCount = decimal.Parse(item.Count().ToString());
                        returnListObj.Add(new { text = item.Key, value = itemCount, bfb = decimal.Round((itemCount / count) * 100, 2) });
                    }
                }
                break;

            //年度变化统计
            case 7:
                var listYearWS = new List <int>();
                if (bjnf.Length > 0 && bjnf != "0")
                {
                    //近五年
                    if (bjnf == "1")
                    {
                        timee = DateTime.Now;
                        for (int i = 1; i < 5; i++)
                        {
                            listYearWS.Add(times.Year - i);
                        }
                        times = DateTime.Now.AddYears(-5);
                    }
                    //近十年
                    if (bjnf == "2")
                    {
                        timee = DateTime.Now;
                        for (int i = 1; i < 10; i++)
                        {
                            listYearWS.Add(times.Year - i);
                        }
                        times = DateTime.Now.AddYears(-10);
                    }
                }

                var list7 = wssjbgbll_deal.GetList(sqlwhere).Where(e => e.HappenTime_Deal != null && (bjnf != "0" ? e.HappenTime_Deal.Value.Year >= times.Year : 1 == 1) &&
                                                                   (bjnf != "0" ? e.HappenTime_Deal.Value.Year <= timee.Year : 1 == 1) && wssjtype.Length > 0 ? e.WssjType_Deal == wssjtype : 1 == 1);
                count = list7.Count();
                if (list7 != null && count > 0)
                {
                    var date = list7.ToList().GroupBy(e => e.HappenTime_Deal.Value.Year);
                    foreach (var item in date)
                    {
                        var itemCount = decimal.Parse(item.Count().ToString());
                        returnListObj.Add(new { text = item.Key, value = itemCount });
                        listYearWS.Remove(item.Key);
                    }
                }


                foreach (var item in listYearWS)
                {
                    returnListObj.Add(new { text = item, value = 0 });
                }

                break;

            default:
                break;
            }

            data = new { list = returnListObj, count = count, count1 = count1, count2 = count2 };
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(data);
            return(json);
        }
コード例 #10
0
        public string ImportDataItem()
        {
            int    error        = 0;
            string message      = "请选择格式正确的文件再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[0];
                if (string.IsNullOrEmpty(file.FileName))
                {
                    return(message);
                }
                if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx")))
                {
                    return(message);
                }
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName));
                DataTable dt    = ExcelHelper.ExcelImport(Server.MapPath("~/Resource/temp/" + fileName));
                int       order = 1;

                //先获取字典
                DataItemBLL       di         = new DataItemBLL();
                DataItemEntity    Resk       = di.GetEntityByCode("Risk");
                DataItemDetailBLL detabll    = new DataItemDetailBLL();
                string[]          names      = { "粉尘", "化学因素", "物理因素", "放射性因素", "生物因素", "其他因素" };
                string[]          namevalues = { "01", "02", "03", "04", "05", "06" };

                string value = "";
                int    index = 1;
                string fname = file.FileName.Substring(0, file.FileName.IndexOf('.'));
                for (int i = 0; i < names.Length; i++)
                {
                    if (fname == names[i])
                    {
                        value = namevalues[i];
                    }
                }

                if (value != "")
                {
                    DataItemDetailEntity dide = new DataItemDetailEntity();
                    dide.ItemId    = Resk.ItemId;
                    dide.ItemValue = value;
                    dide.ItemName  = fname;
                    dide.SortCode  = index;
                    dide.ParentId  = "0";
                    try
                    {
                        detabll.SaveForm("", dide);
                    }
                    catch (Exception)
                    {
                        error++;
                    }

                    foreach (DataRow dr in dt.Rows)
                    {
                        DataItemDetailEntity did = new DataItemDetailEntity();
                        did.ItemId = Resk.ItemId;
                        if (index < 10)
                        {
                            did.ItemValue = value + "00" + index;
                        }
                        else if (index < 100)
                        {
                            did.ItemValue = value + "0" + index;
                        }
                        else
                        {
                            did.ItemValue = value + index;
                        }
                        did.ItemName = dr[0].ToString();
                        did.SortCode = index;
                        did.ParentId = "0";
                        index++;
                        try
                        {
                            detabll.SaveForm("", did);
                        }
                        catch (Exception)
                        {
                            error++;
                        }
                    }
                }



                count    = dt.Rows.Count - 1;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }
            return(message);
        }