Пример #1
0
 public object GetObsInfo([FromBody] JObject json)
 {
     try
     {
         string              res       = json.Value <string>("json");
         dynamic             dy        = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string              userId    = dy.userid;
         string              obsid     = dy.data.obsid;
         ObserverecordEntity obsRecord = observerecordbll.GetEntity(obsid);
         //观察类别
         var typeData = observerecordbll.GetObsTypeData(obsid);
         //安全行为
         List <object> SafeData = new List <object>();
         //不安全行为
         List <object> NotSafeData = new List <object>();
         var           data        = dataitemdetailbll.GetDataItemListByItemCode("'ObsType'").ToList();
         for (int i = 0; i < data.Count; i++)
         {
             var safeData = observesafetybll.GetDataByType("1", data[i].ItemName, obsid);
             if (safeData.Rows.Count > 0)
             {
                 var item = new { name = data[i].ItemName, list = safeData };
                 SafeData.Add(item);
             }
             var notSafe = observesafetybll.GetDataByType("0", data[i].ItemName, obsid);
             if (notSafe.Rows.Count > 0)
             {
                 var notItem = new { name = data[i].ItemName, list = notSafe };
                 NotSafeData.Add(notItem);
             }
         }
         //获取相关附件
         var    files  = new FileInfoBLL().GetFiles(obsid);
         string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
         foreach (DataRow dr in files.Rows)
         {
             dr["filepath"] = dr["filepath"].ToString().Replace("~/", webUrl + "/");
         }
         var result = new
         {
             obsRecordEntity = obsRecord,
             obsTypeData     = typeData,
             SafeData        = SafeData,
             NotSafeData     = NotSafeData,
             files           = files
         };
         return(new
         {
             Code = 0,
             Count = 1,
             Info = "获取数据成功",
             data = result
         });
     }
     catch (Exception ex)
     {
         return(new { Code = -1, Count = 0, Info = ex.Message });
     }
 }
Пример #2
0
        public ActionResult CarOut(string keyValue, string Note, int type, List <PersongpsEntity> pergps)
        {
            //根据危化品类型添加二级节点
            var    data = dataItemDetailBLL.GetDataItemListByItemCode("'SocketUrl'");
            string IP   = "";
            int    Port = 0;

            foreach (var item in data)
            {
                if (item.ItemName == "IP")
                {
                    IP = item.ItemValue;
                }
                else if (item.ItemName == "Port")
                {
                    Port = Convert.ToInt32(item.ItemValue);
                }
            }
            visitcarbll.CarOut(keyValue, Note, type, pergps);
            CarAlgorithmEntity Car = new CarAlgorithmEntity();

            Car.ID    = keyValue;
            Car.State = 1;
            SocketHelper.SendMsg(Car.ToJson(), IP, Port);

            DataItemDetailBLL pdata = new DataItemDetailBLL();
            string            key   = string.Empty;       // "21049470";
            string            sign  = string.Empty;       // "4gZkNoh3W92X6C66Rb6X";
            var pitem = pdata.GetItemValue("Hikappkey");  //海康服务器密钥
            var url   = pdata.GetItemValue("HikBaseUrl"); //海康服务器地址

            if (!string.IsNullOrEmpty(pitem))
            {
                key  = pitem.Split('|')[0];
                sign = pitem.Split('|')[1];
            }

            if (type == 0)
            {
                VisitcarEntity car = visitcarbll.GetEntity(keyValue);
                HikOut(url, key, sign, car.CarNo);
            }
            else if (type == 1)
            {
                OperticketmanagerBLL    obll = new OperticketmanagerBLL();
                OperticketmanagerEntity op   = obll.GetEntity(keyValue);
                HikOut(url, key, sign, op.Platenumber);
            }
            else if (type == 2)
            {
                HazardouscarBLL    hbll = new HazardouscarBLL();
                HazardouscarEntity ha   = hbll.GetEntity(keyValue);
                HikOut(url, key, sign, ha.CarNo);
            }
            return(Success("操作成功。"));
        }
Пример #3
0
        public ActionResult GetDataItemListJson(string EnCode, string Remark = "")
        {
            var data = dataItemDetailBLL.GetDataItemListByItemCode("'" + EnCode + "'");

            if (!string.IsNullOrWhiteSpace(Remark))
            {
                data = data.Where(x => x.ItemCode == Remark);
            }
            return(Content(data.ToJson()));
        }
Пример #4
0
        public ActionResult SubmitDForm(string keyValue, PlanCheckEntity pEntity)
        {
            //当前用户
            Operator curUser = OperatorProvider.Provider.Current();
            //参与人员
            var    errorMsg    = "";
            string wfFlag      = string.Empty; //流程标识
            string participant = string.Empty; //获取流程下一节点的参与人员

            var entity = planApplybll.GetEntity(pEntity.ApplyId);

            if (pEntity.CheckResult == "0")
            {//不通过,退回
                var appEntity = planApplybll.GetEntity(keyValue);
                wfFlag = "2";
                string createuserid = appEntity.CREATEUSERID;
                var    userEntity   = userbll.GetEntity(createuserid);
                participant = userEntity.Account;  //申请用户
                errorMsg    = "上报用户";
            }
            else
            {                   //部门负责人,核准通过
                wfFlag   = "1"; // 1级审核=>2级审核
                errorMsg = "EHS部门负责人";
                //EHS部门encode
                DataItemModel ehsDepart = dataitemdetailbll.GetDataItemListByItemCode("'EHSDepartment'").Where(p => p.ItemName == curUser.OrganizeId).ToList().FirstOrDefault();
                if (ehsDepart != null)
                {
                    var deptUser = userbll.GetUserListByRole(ehsDepart.ItemValue, "'100104'", "");
                    if (deptUser != null)
                    {
                        participant = string.Join(",", deptUser.Select(x => x.Account));
                    }
                }
            }
            //保存基本信息
            pEntity.ID = Guid.NewGuid().ToString();
            planCheckbll.SaveForm("", pEntity);
            if (!string.IsNullOrEmpty(participant))
            {
                entity.CheckUserAccount = participant;
                planApplybll.SaveForm(keyValue, entity);
                int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId);
                if (count > 0)
                {
                    htworkflowbll.UpdateFlowStateByObjectId("hrs_planapply", "flowstate", keyValue);  //更新业务流程状态
                }
            }
            else
            {
                return(Error("请联系系统管理员,确认" + errorMsg + "!"));
            }

            return(Success("操作成功。"));
        }
Пример #5
0
        public ActionResult Index()
        {
            ViewBag.ehsDepartCode = "";
            //当前用户
            Operator      curUser   = OperatorProvider.Provider.Current();
            DataItemModel ehsDepart = dataitemdetailbll.GetDataItemListByItemCode("'EHSDepartment'").Where(p => p.ItemName == curUser.OrganizeId).ToList().FirstOrDefault();

            if (ehsDepart != null)
            {
                ViewBag.ehsDepartCode = ehsDepart.ItemValue;
            }
            return(View());
        }
Пример #6
0
 public object GetDataItemListJson([FromBody] JObject json)
 {
     try
     {
         string  res = json.Value <string>("json");
         dynamic dy  = JsonConvert.DeserializeObject <ExpandoObject>(res);
         //获取用户Id
         string userId = dy.userid;
         OperatorProvider.AppUserId = userId;  //设置当前用户
         Operator curUser = OperatorProvider.Provider.Current();
         if (null == curUser)
         {
             return(new { code = -1, count = 0, info = "请求失败,请登录!" });
         }
         string EnCode = dy.data.EnCode;//ID
         var    data   = dataItemDetailBLL.GetDataItemListByItemCode("'" + EnCode + "'");
         string Remark = dy.data.Remark;
         if (!string.IsNullOrEmpty(Remark))
         {
             data = data.Where(t => t.ItemCode == Remark).OrderBy(t => t.SortCode).ToList();
         }
         return(new { Code = 0, Count = 1, Info = "获取数据成功", data = data });
     }
     catch (Exception ex)
     {
         return(new { Code = -1, Count = 0, Info = ex.Message });
     }
 }
Пример #7
0
        public ViewResult Edit(string id, string view)
        {
            Operator user  = ERCHTMS.Code.OperatorProvider.Provider.Current();
            var      model = default(CheckRecordEntity);

            ViewBag.id     = id;
            ViewBag.deptid = user.DeptId;
            ViewBag.view   = view;
            if (string.IsNullOrEmpty(id))
            {
                model = new CheckRecordEntity()
                {
                    CheckTime = DateTime.Now, CheckUser = user.UserName, CheckItems = new List <CheckItemEntity>()
                };
            }
            else
            {
                var bll = new CheckRecordBLL();
                model = bll.GetDetail(id);
            }

            ViewBag.json = Newtonsoft.Json.JsonConvert.SerializeObject(model.CheckItems);
            DataItemDetailBLL dataitembll = new DataItemDetailBLL();
            var list1 = dataitembll.GetDataItemListByItemCode("预警指标卡类别");
            var data1 = list1.Select(x => new SelectListItem()
            {
                Value = x.ItemValue, Text = x.ItemName
            });

            ViewData["Category"] = data1;
            return(View(model));
        }
Пример #8
0
        public string GetIsUpdate()
        {
            var issystem = OperatorProvider.Provider.Current().IsSystem;

            if (!issystem)
            {//如果不是系统管理员
                DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
                string            postname          = OperatorProvider.Provider.Current().PostName;
                var data = dataItemDetailBLL.GetDataItemListByItemCode("'NOSA'").ToList();
                foreach (var item in data)
                {
                    string value = item.ItemValue;
                    if (postname.Contains(value))
                    {
                        return("true");
                    }
                }

                //if (OperatorProvider.Provider.Current().RoleName.Contains("公司级用户"))
                //{
                //    return "true";
                //}

                return("flase");
            }
            else
            {
                return("true");
            }
        }
Пример #9
0
        public string GetIsDept()
        {
            var issystem = OperatorProvider.Provider.Current().IsSystem;

            if (!issystem)
            {//如果不是系统管理员
                var deptid   = OperatorProvider.Provider.Current().DeptId;
                var deptname = OperatorProvider.Provider.Current().DeptCode;
                DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
                var data = dataItemDetailBLL.GetDataItemListByItemCode("'SelectDept'").ToList();
                foreach (var item in data)
                {
                    string   value  = item.ItemValue;
                    string[] values = value.Split('|');
                    for (int i = 0; i < values.Length; i++)
                    {
                        if (values[i] == deptname)
                        {
                            return(deptid + ",true");
                        }
                    }
                }

                if (OperatorProvider.Provider.Current().RoleName.Contains("公司级用户"))
                {
                    return(deptid + ",true");
                }

                return(deptid + ",flase");
            }
            else
            {
                return(",true");
            }
        }
Пример #10
0
        public ActionResult GetInitDataJson()
        {
            //违章类型 违章等级 作业类型
            string itemCode = "'LllegalType','LllegalLevel','LllegalBusType'";
            //集合
            var itemlist = dataitemdetailbll.GetDataItemListByItemCode(itemCode);
            //返回值
            var josnData = new
            {
                LllegalType    = itemlist.Where(p => p.EnCode == "LllegalType"),   //违章类型
                LllegalLevel   = itemlist.Where(p => p.EnCode == "LllegalLevel"),  //违章级别
                LIIegalBusType = itemlist.Where(p => p.EnCode == "LllegalBusType") //作业类型
            };

            return(Content(josnData.ToJson()));
        }
Пример #11
0
        private void ReleaseGPSEquipment(string keyValue)
        {
            #region 定位数据发送
            int    Port    = 0;
            string IP      = CacheFactory.Cache().GetCache <string>("SocketUrl:IP");
            string PostStr = CacheFactory.Cache().GetCache <string>("SocketUrl:Port");
            if (!string.IsNullOrEmpty(PostStr))
            {
                Port = Convert.ToInt32(PostStr);
            }
            if (string.IsNullOrEmpty(IP) || Port == 0)
            {
                var data = dataItemDetailBLL.GetDataItemListByItemCode("'SocketUrl'");
                foreach (var item in data)
                {
                    if (item.ItemName == "IP")
                    {
                        IP = item.ItemValue;
                        CacheFactory.Cache().WriteCache <string>(item.ItemValue, "SocketUrl:IP");
                    }
                    else if (item.ItemName == "Port")
                    {
                        Port = Convert.ToInt32(item.ItemValue);
                        CacheFactory.Cache().WriteCache <string>(item.ItemValue, "SocketUrl:Port");
                    }
                }
            }
            CarAlgorithmEntity car = new CarAlgorithmEntity();
            car.ID    = keyValue;
            car.State = 1;
            SocketHelper.SendMsg(car.ToJson(), IP, Port);

            #endregion
        }
Пример #12
0
        public ActionResult GetOutsourceUserList()
        {
            string            sql   = string.Empty;
            DataTable         data  = new DataTable();
            DataItemDetailBLL pdata = new DataItemDetailBLL();
            var list = pdata.GetDataItemListByItemCode("KbshomeCount");

            if (list != null)
            {
                var item = list.Where(a => a.EnabledMark == 1).FirstOrDefault();
                if (item.ItemValue == "EquipmentManage")
                { //关联设备进出记录
                    sql = string.Format(@"select d.deptname,count(1) as num from bis_hikinoutlog d  join base_department t on d.deptid=t.departmentid and t.nature='承包商' and d.isout=0 group  by d.deptid,d.deptname");
                }
                else if (item.ItemValue == "LableManage")
                {//关联标签
                    sql = string.Format(@"select d.deptname,count(1) as num from bis_lableonlinelog d join  base_department t on d.deptid=t.departmentid and t.nature='承包商' and d.isout=0 group  by d.deptid,d.deptname");
                }
            }
            if (!string.IsNullOrEmpty(sql))
            {
                data = Opertickebll.GetDataTable(sql);
            }
            return(Content(data.ToJson()));
        }
Пример #13
0
        public ActionResult GetListJson(Pagination pagination, string queryJson)
        {
            string orgcode = OperatorProvider.Provider.Current().OrganizeCode;
            var    watch   = CommonHelper.TimerStart();

            pagination.p_kid         = "ID";
            pagination.p_fields      = "NO,info.createuserid,info.createuserdeptcode,info.createuserorgcode,info.NAME,TYPE,ORGNAME,DEPTNAME,POSTNAME,SHOULDNUM,UNIT,TIMENUM,TIMETYPE,RECENTTIME,NEXTTIME,ISSUENUM,'' InStock,yj.value";
            pagination.p_tablename   = "BIS_LABORINFO info left join (select name,value from bis_laboreamyj where createuserorgcode='" + orgcode + "') yj on info.name=yj.name";
            pagination.conditionJson = " 1=1";
            Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();

            if (user.IsSystem)
            {
                pagination.conditionJson = "1=1";
            }
            else
            {
                if (laborinfobll.GetPer())
                {
                    pagination.conditionJson += " and CREATEUSERORGCODE='" + user.OrganizeCode + "'";
                }
                else
                {
                    string where              = new ERCHTMS.Busines.AuthorizeManage.AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value);
                    pagination.conditionJson += " and " + where;
                }
            }

            var data = laborinfobll.GetPageList(pagination, queryJson);

            DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();

            var datadetail = dataItemDetailBLL.GetDataItemListByItemCode("'LaborName'");

            for (int i = 0; i < data.Rows.Count; i++)
            {
                DataItemModel dm = datadetail.Where(it => it.ItemName == data.Rows[i]["NAME"].ToString()).FirstOrDefault();
                if (dm != null)
                {
                    data.Rows[i]["InStock"] = dm.ItemValue.ToString();
                }
            }
            var JsonData = new
            {
                rows     = data,
                total    = pagination.total,
                page     = pagination.page,
                records  = pagination.records,
                costtime = CommonHelper.TimerEnd(watch),
            };

            return(Content(JsonData.ToJson()));
        }
Пример #14
0
 public object getProgrammeCaseList()
 {
     try
     {
         var itemlist = dataitemdetailbll.GetDataItemListByItemCode("'EvolveSituation'");
         return(new { code = 0, info = "获取数据成功", count = itemlist.Count(), data = itemlist.Select(x => new { programmecasevalue = x.ItemValue, programmecasename = x.ItemName }) });
     }
     catch (Exception ex)
     {
         return(new { Code = -1, Count = 0, Info = ex.Message });
     }
 }
Пример #15
0
        public ActionResult Index()
        {
            ViewBag.IsQx = "0";
            //当前用户
            Operator      curUser = OperatorProvider.Provider.Current();
            DataItemModel Depart  = dataitemdetailbll.GetDataItemListByItemCode("'HealthDeptQx'").Where(p => p.ItemName == curUser.OrganizeId).ToList().FirstOrDefault();

            if (Depart != null)
            {
                if (Depart.ItemValue.Contains(curUser.DeptId))
                {
                    ViewBag.IsQx = "1";
                }
            }
            return(View());
        }
Пример #16
0
 public object GetObsType([FromBody] JObject json)
 {
     try
     {
         string  res    = json.Value <string>("json");
         dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string  userId = dy.userid;
         string  type   = dy.data.type;
         var     data   = dataitemdetailbll.GetDataItemListByItemCode("'" + type + "'").ToList();
         return(new { code = 0, count = data.Count, info = "获取数据成功", data = data });
     }
     catch (Exception ex)
     {
         return(new { code = -1, count = 0, info = ex.Message });
     }
 }
Пример #17
0
        public object GetExamineTypeDataJson([FromBody] JObject json)
        {
            try
            {
                string  res = json.Value <string>("json");
                dynamic dy  = JsonConvert.DeserializeObject <ExpandoObject>(res);
                //获取用户Id
                string userId = dy.userid;
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!" });
                }

                //集合
                var data = dataitemdetailbll.GetDataItemListByItemCode("'ExamineType'");


                var treeList = new List <TreeEntity>();
                foreach (DataItemModel item in data)
                {
                    TreeEntity tree        = new TreeEntity();
                    bool       hasChildren = data.Where(p => p.ItemCode == item.ItemValue).ToList().Count() == 0 ? false : true;
                    tree.id             = item.ItemValue;
                    tree.text           = item.ItemName;
                    tree.value          = item.ItemValue;
                    tree.isexpand       = true;
                    tree.complete       = true;
                    tree.hasChildren    = hasChildren;
                    tree.parentId       = item.ItemCode;
                    tree.Attribute      = "Code";
                    tree.AttributeValue = item.ItemValue;
                    treeList.Add(tree);
                }
                if (treeList.Count > 0)
                {
                    treeList[0].isexpand = true;
                }

                return(new { code = 0, info = "获取数据成功", data = treeList });
            }
            catch (Exception ex)
            {
                return(new { code = -1, info = ex.Message, count = 0 });
            }
        }
Пример #18
0
        public ActionResult GetQueryConditionJson()
        {
            Operator CreateUser = OperatorProvider.Provider.Current();

            //流程状态
            string itemCode = "'FindQuestionFlowState'";
            //集合
            var itemlist = dataitemdetailbll.GetDataItemListByItemCode(itemCode);

            //返回值
            var josnData = new
            {
                FlowState = itemlist.Where(p => p.EnCode == "FindQuestionFlowState")  //发现问题流程状态
            };

            return(Content(josnData.ToJson()));
        }
Пример #19
0
        public ActionResult GetSafeworkItemJson(string itemcode)
        {
            List <ComboxsEntity> Rlist = new List <ComboxsEntity>();
            DataItemDetailBLL    pdata = new DataItemDetailBLL();
            var list = pdata.GetDataItemListByItemCode(itemcode);

            if (list != null)
            {
                foreach (var item in list)
                {
                    ComboxsEntity y1 = new ComboxsEntity();
                    y1.itemName  = item.ItemName;
                    y1.itemValue = item.ItemValue;
                    y1.Key       = item.SimpleSpelling;
                    Rlist.Add(y1);
                }
            }
            return(ToJsonResult(Rlist));
        }
Пример #20
0
        /// <summary>
        /// 作业实时分布统计图
        /// </summary>
        /// <returns></returns>
        public ActionResult GetWorkRealTimeDistribution()
        {
            string            sql   = string.Format(@"select tasktype,count(1) as num from bis_safeworkcontrol d where (
(Actualstarttime<=to_date('{0}','yyyy-mm-dd hh24:mi:ss') and  
ActualEndTime >=to_date('{0}','yyyy-mm-dd hh24:mi:ss')
)or( Actualstarttime<=to_date('{0}','yyyy-mm-dd hh24:mi:ss') and  ActualEndTime is null)) and state=1  group by d.tasktype", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            DataTable         dt    = Opertickebll.GetDataTable(sql);
            DataItemDetailBLL pdata = new DataItemDetailBLL();
            var list = pdata.GetDataItemListByItemCode("SafeWorkType");
            List <KbsEntity> klist = new List <KbsEntity>();
            int Znum = 0;

            foreach (var item in list)
            {
                KbsEntity kbs = new KbsEntity();
                kbs.Name = item.ItemName;
                int num = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (item.ItemValue == dt.Rows[i][0].ToString())
                    {
                        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].Proportion = Proportion.ToString("0.00") + "%";
            }
            dt.Dispose();
            return(Content(klist.ToJson()));
        }
Пример #21
0
        /// <summary>
        /// 导出到Excel
        /// </summary>
        /// <param name="queryJson"></param>
        /// <returns></returns>
        public ActionResult Excel(string queryJson)
        {
            string   wheresql = "";
            Operator user     = ERCHTMS.Code.OperatorProvider.Provider.Current();

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

            DataTable         dt = laborinfobll.GetTable(queryJson, wheresql);
            DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();

            var datadetail = dataItemDetailBLL.GetDataItemListByItemCode("'LaborName'");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][0]          = i + 1;
                dt.Rows[i]["TimeType"] = dt.Rows[i]["TimeNum"].ToString() + dt.Rows[i]["TimeType"].ToString();
                DataItemModel dm = datadetail.Where(it => it.ItemName == dt.Rows[i]["NAME"].ToString()).FirstOrDefault();
                if (dm != null)
                {
                    dt.Rows[i]["InStock"] = dm.ItemValue.ToString();
                }
                else
                {
                    dt.Rows[i]["InStock"] = "";
                }
            }

            string FileUrl = @"\Resource\ExcelTemplate\劳动防护用品管理_导出.xls";

            AsposeExcelHelper.ExecuteResult(dt, FileUrl, "劳动防护用品管理清单", "劳动防护用品管理列表");

            return(Success("导出成功。"));
        }
Пример #22
0
        /// <summary>
        /// 判断是否有权限 厂领导/Ehs与人力资源部
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public bool IsPer()
        {
            bool IsPermission = false;

            if (OperatorProvider.Provider.Current().IsSystem)
            {
                return(true);
            }

            //获取当前操作用户
            var Appuser = OperatorProvider.Provider.Current();   //获取用户基本信息
            //EHS部与人力资源部配置在字典中 通过字典查找
            var Perdeptname = Appuser.DeptCode;
            DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
            var data = dataItemDetailBLL.GetDataItemListByItemCode("'SelectDept'").ToList();

            if (data != null)
            {
                foreach (var Peritem in data)
                {
                    string   value  = Peritem.ItemValue;
                    string[] values = value.Split('|');
                    for (int i = 0; i < values.Length; i++)
                    {
                        if (values[i] == Perdeptname) //如果部门编码对应则是有权限的人
                        {
                            return(true);
                        }
                    }
                }
            }

            //如果是厂领导也有权限
            if (Appuser.RoleName.Contains("厂级部门用户") || Appuser.RoleName.Contains("公司领导"))
            {
                IsPermission = true;
            }

            return(IsPermission);
        }
Пример #23
0
        public ActionResult GetNameList()
        {
            //获取到已选数据
            List <LaborprotectionEntity> laborlist = laborprotectionbll.GetLaborList();

            DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
            var data = dataItemDetailBLL.GetDataItemListByItemCode("'LaborName'").ToList();

            for (int i = 0; i < data.Count; i++)
            {
                //如果当前没有这个数据 则加入到集合中
                if (laborlist.Where(it => it.Name == data[i].ItemName).Count() == 0)
                {
                    LaborprotectionEntity lb = new LaborprotectionEntity();
                    lb.ID   = i.ToString();
                    lb.Name = data[i].ItemName;
                    laborlist.Add(lb);
                }
            }

            return(ToJsonResult(laborlist));;
        }
Пример #24
0
        /// <summary>
        /// 判断是否可以获取到权限
        /// </summary>
        /// <returns></returns>
        public bool GetPer()
        {
            var deptid   = OperatorProvider.Provider.Current().DeptId;
            var deptname = OperatorProvider.Provider.Current().DeptCode;
            DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
            var data = dataItemDetailBLL.GetDataItemListByItemCode("'SelectDept'").ToList();

            foreach (var item in data)
            {
                string   value  = item.ItemValue;
                string[] values = value.Split('|');
                for (int i = 0; i < values.Length; i++)
                {
                    if (values[i] == deptname)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #25
0
        public ActionResult GetListJson(string queryJson)
        {
            var data = laboreamyjbll.GetList(queryJson).ToList();
            //获取字典中模拟的数据
            DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
            var datadetail = dataItemDetailBLL.GetDataItemListByItemCode("'LaborName'");
            List <LaboreamyjEntity> lylist = new List <LaboreamyjEntity>();

            foreach (DataItemModel item in datadetail)
            {
                if (data.Where(it => it.Name == item.ItemName).Count() == 0)
                {
                    LaboreamyjEntity ly = new LaboreamyjEntity();
                    ly.Name = item.ItemName;
                    string[] ec = item.ItemCode.Split('|');
                    ly.Type = ec[0];
                    ly.No   = ec[1];
                    ly.Unit = item.Description;
                    data.Add(ly);
                }
            }
            return(ToJsonResult(data));
        }
Пример #26
0
        public string ImportCamera()
        {
            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;


                DistrictBLL           districtbll = new DistrictBLL();
                List <DistrictEntity> AreaList    = districtbll.GetListByOrgIdAndParentId("", "");


                DataItemDetailBLL    dataItemDetailBLL = new DataItemDetailBLL();
                List <DataItemModel> data = dataItemDetailBLL.GetDataItemListByItemCode("'CameraType'").ToList();



                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string CameraID     = dt.Rows[i][0].ToString();
                    string CameraName   = dt.Rows[i][1].ToString();
                    string CameraType   = dt.Rows[i][2].ToString();
                    string CameraTypeId = "";
                    //区域
                    string AreaName  = dt.Rows[i][3].ToString();
                    string AreaValue = "";
                    string AreaCode  = "";
                    //楼层编号
                    string FloorNo     = dt.Rows[i][4].ToString();
                    string CameraPoint = dt.Rows[i][5].ToString();
                    string CameraIp    = dt.Rows[i][6].ToString();

                    if (string.IsNullOrEmpty(CameraID))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "摄像头ID为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (string.IsNullOrEmpty(CameraName))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "摄像头名称为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (string.IsNullOrEmpty(CameraType))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "摄像头类别为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (string.IsNullOrEmpty(AreaName))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "区域名称为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (string.IsNullOrEmpty(FloorNo))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "楼层编号为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (string.IsNullOrEmpty(CameraPoint))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "摄像头坐标为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (string.IsNullOrEmpty(CameraIp))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "IP地址为空,未能导入.";
                        error++;
                        continue;
                    }
                    var IP    = @"(^(\d+)\.(\d+)\.(\d+)\.(\d+)$)";//@"/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g";
                    var point = @"(^\d{1,9}(.\d{1,2});\d{1,9}(.\d{1,2})$)";

                    ////验证是否是IP
                    if (!Regex.IsMatch(CameraIp, IP))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行IP地址格式填写错误,未能导入.";
                        error++;
                        continue;
                    }

                    ////验证是否是坐标
                    if (!Regex.IsMatch(CameraPoint, point))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行坐标格式填写错误,格式应为xx.xx;xx.xx,未能导入.";
                        error++;
                        continue;
                    }


                    var ct = data.Where(it => it.ItemName == CameraType).FirstOrDefault();
                    if (ct == null)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行摄像头类别填写错误,未找到对应的摄像头类别,未能导入.";
                        error++;
                        continue;
                    }

                    CameraTypeId = ct.ItemValue;

                    var area = AreaList.Where(it => it.DistrictName == AreaName).FirstOrDefault();
                    if (area == null)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行区域名称填写错误,未找到对应的区域,未能导入.";
                        error++;
                        continue;
                    }

                    AreaValue = area.DistrictID;
                    AreaCode  = area.DistrictCode;

                    KbscameramanageEntity kbs = new KbscameramanageEntity();
                    kbs.AreaCode     = AreaCode;
                    kbs.AreaName     = AreaName;
                    kbs.CameraId     = CameraID;
                    kbs.CameraName   = CameraName;
                    kbs.CameraType   = CameraType;
                    kbs.FloorNo      = FloorNo;
                    kbs.OperuserName = OperatorProvider.Provider.Current().UserName;
                    kbs.AreaId       = AreaValue;
                    kbs.CameraIP     = CameraIp;
                    kbs.CameraPoint  = CameraPoint;
                    kbs.CameraTypeId = Convert.ToInt32(CameraTypeId);
                    kbs.State        = "在线";


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

            return(message);
        }
Пример #27
0
        public ActionResult GetWarningInfo()
        {
            var data = dataitemdetailbll.GetDataItemListByItemCode("'aqyj'").FirstOrDefault();

            return(ToJsonResult(data));
        }
Пример #28
0
        public string ImportInfo(int mode)
        {
            if (OperatorProvider.Provider.Current().IsSystem)
            {
                return("超级管理员无此操作权限");
            }
            var    curUser      = OperatorProvider.Provider.Current();
            string orgId        = curUser.OrganizeId;//所属公司
            string message      = "请选择格式正确的文件(excel数据文件)再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            try
            {
                List <string> listIds = new List <string>();
                if (count > 0)
                {
                    HttpPostedFileBase    file            = HttpContext.Request.Files[0];
                    string                hiddenDirectory = string.Empty;
                    Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();

                    #region 过滤文件
                    if (string.IsNullOrEmpty(file.FileName))
                    {
                        return(message);
                    }
                    if (!(file.FileName.ToLower().Substring(file.FileName.ToLower().IndexOf('.')).Contains("xls") || file.FileName.ToLower().Substring(file.FileName.ToLower().IndexOf('.')).Contains("xlsx")))
                    {
                        return(message);
                    }
                    string fileName1 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                    file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName1));
                    wb.Open(Server.MapPath("~/Resource/temp/" + fileName1));
                    #endregion
                    Worksheet          sheets    = wb.Worksheets[0];
                    Aspose.Cells.Cells cells     = sheets.Cells;
                    DataTable          dt        = cells.ExportDataTable(1, 0, cells.MaxDataRow, cells.MaxColumn + 1, true);
                    string             labledept = mode == 0 ? "部门" : "外协单位";
                    if (dt.Columns.Contains("部门") && mode > 0)
                    {
                        return("当前模板不适用与外协单位违章档案扣分数据导入!");
                    }
                    if (dt.Columns.Contains("外协单位") && mode == 0)
                    {
                        return("当前模板不适用与生产部门违章档案扣分数据导入!");
                    }
                    //记录错误信息
                    List <string>           resultlist = new List <string>();
                    List <UserEntity>       ulist      = userbll.GetList().OrderBy(p => p.SortCode).ToList();
                    List <DepartmentEntity> dlist      = departmentBLL.GetList().OrderBy(p => p.SortCode).ToList();
                    var lllegaltypelist = dataitemdetailbll.GetDataItemListByItemCode("'LllegalType'");
                    int total           = 0;
                    #region 违章部分
                    if (sheets.Name.Contains("违章"))//违章扣分信息导入
                    {
                        #region 对象装载
                        List <ImportLllegalPunish> list = new List <ImportLllegalPunish>();
                        //先获取到职务列表;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string resultmessage = "第" + (i + 1).ToString() + "行数据"; //显示错误
                            bool   isadddobj     = true;
                            //姓名
                            string username = dt.Columns.Contains("姓名") ? dt.Rows[i]["姓名"].ToString().Trim() : string.Empty;
                            //部门
                            string deptname = dt.Columns.Contains("部门") ? dt.Rows[i]["部门"].ToString().Trim() : string.Empty;
                            if (mode > 0)
                            {
                                deptname = dt.Columns.Contains("外协单位") ? dt.Rows[i]["外协单位"].ToString().Trim() : string.Empty;  //外协单位
                            }
                            //专业/班组
                            string teamname = dt.Columns.Contains("专业/班组") ? dt.Rows[i]["专业/班组"].ToString().Trim() : string.Empty;
                            //岗位/职务
                            string dutyname = dt.Columns.Contains("岗位/职务") ? dt.Rows[i]["岗位/职务"].ToString().Trim() : string.Empty;
                            //违章过程描述
                            string lllegaldescribe = dt.Columns.Contains("违章过程描述") ? dt.Rows[i]["违章过程描述"].ToString().Trim() : string.Empty;
                            //违章分类
                            string lllegaltypename = dt.Columns.Contains("违章分类") ? dt.Rows[i]["违章分类"].ToString().Trim() : string.Empty;
                            //处罚时间
                            string punishdate = dt.Columns.Contains("处罚时间") ? dt.Rows[i]["处罚时间"].ToString().Trim() : string.Empty;
                            //处罚结果(元)
                            string punishresult = dt.Columns.Contains("处罚结果(元)") ? dt.Rows[i]["处罚结果(元)"].ToString() : string.Empty;
                            //处罚积分(分)
                            string punishpoint = dt.Columns.Contains("处罚积分(分)") ? dt.Rows[i]["处罚积分(分)"].ToString() : string.Empty;

                            string relevanceid = string.Empty;
                            try
                            {
                                #region 对象集合
                                ImportLllegalPunish entity = new ImportLllegalPunish();
                                //序号
                                entity.serialnumber    = i + 1; //序号
                                entity.lllegaldescribe = lllegaldescribe;
                                entity.lllegaltypename = lllegaltypename;
                                //部门/承包商层级
                                if (!string.IsNullOrEmpty(deptname))
                                {
                                    var deptlist = dlist.Where(p => p.FullName == deptname && p.Nature != "专业" && p.Nature != "班组");
                                    if (deptlist.Count() > 0)
                                    {
                                        var deptentity = deptlist.FirstOrDefault();
                                        entity.deptid   = deptentity.DepartmentId;
                                        entity.deptname = deptentity.FullName;
                                        entity.nature   = deptentity.Nature;
                                        var parentdeptEntity = dlist.Where(p => p.DepartmentId == deptentity.ParentId).FirstOrDefault();
                                        if (deptentity.Nature == "承包商" && parentdeptEntity.Nature != "部门")
                                        {
                                            var rpdeptEntity = GetRootContractor(deptentity, dlist);
                                            entity.deptid   = rpdeptEntity.DepartmentId;
                                            entity.deptname = rpdeptEntity.FullName;
                                            entity.nature   = rpdeptEntity.Nature;
                                            entity.teamid   = deptentity.DepartmentId;
                                            entity.teamname = deptentity.FullName;
                                            entity.tnature  = deptentity.Nature;
                                        }
                                    }
                                }
                                //专业/班组
                                if (!string.IsNullOrEmpty(teamname))
                                {
                                    var deptlist = dlist.Where(p => p.FullName == teamname && (p.Nature == "专业" || p.Nature == "班组" || p.Nature == "承包商"));
                                    if (deptlist.Count() > 0)
                                    {
                                        string parentcode = string.Empty;
                                        if (!string.IsNullOrEmpty(entity.deptid))
                                        {
                                            parentcode = dlist.Where(p => p.DepartmentId == entity.deptid).FirstOrDefault().EnCode;
                                            var deptentity = deptlist.FirstOrDefault();
                                            //专业和班组、承包商的专业和班组必须来自于对应的部门
                                            if (deptentity.EnCode.StartsWith(parentcode) && deptentity.EnCode != parentcode)
                                            {
                                                entity.teamid   = deptentity.DepartmentId;
                                                entity.teamname = deptentity.FullName;
                                                entity.tnature  = deptentity.Nature;
                                            }
                                        }
                                    }
                                }

                                #region 人员
                                if (!string.IsNullOrEmpty(username))
                                {
                                    List <UserEntity> userlist = ulist.Where(p => p.RealName == username.Trim() || p.Account == username.Trim() || p.Mobile == username.Trim() || p.Telephone == username.Trim()).ToList();
                                    if (!string.IsNullOrEmpty(entity.deptid) && !string.IsNullOrEmpty(entity.teamid))
                                    {
                                        userlist = userlist.Where(p => p.DepartmentId == entity.teamid).ToList();
                                        if (userlist.Count() > 0)
                                        {
                                            var checkUserEntity = userlist.FirstOrDefault();
                                            entity.userid   = checkUserEntity.UserId;
                                            entity.username = checkUserEntity.RealName;
                                            entity.dutyid   = checkUserEntity.DutyId;
                                            entity.dutyname = checkUserEntity.DutyName;
                                        }
                                    }
                                    if (!string.IsNullOrEmpty(entity.deptid) && string.IsNullOrEmpty(entity.teamid))
                                    {
                                        userlist = userlist.Where(p => p.DepartmentId == entity.deptid).ToList();
                                        if (userlist.Count() > 0)
                                        {
                                            var checkUserEntity = userlist.FirstOrDefault();
                                            entity.userid   = checkUserEntity.UserId;
                                            entity.username = checkUserEntity.RealName;
                                            entity.dutyid   = checkUserEntity.DutyId;
                                            entity.dutyname = checkUserEntity.DutyName;
                                        }
                                    }
                                }
                                #endregion

                                //处罚时间
                                if (!string.IsNullOrEmpty(punishdate))
                                {
                                    entity.punishdate = punishdate;
                                }
                                else
                                {
                                    entity.punishdate = DateTime.Now.ToString("yyyy-MM-dd");
                                }

                                //违章类型
                                if (!string.IsNullOrEmpty(lllegaltypename))
                                {
                                    var checktypeEntity = lllegaltypelist.Where(p => p.ItemName == lllegaltypename.ToString()).FirstOrDefault();
                                    if (null != checktypeEntity)
                                    {
                                        entity.lllegaltypename = checktypeEntity.ItemName;
                                        entity.lllegaltype     = checktypeEntity.ItemDetailId;
                                    }
                                }
                                #endregion

                                #region 必填验证

                                if (!string.IsNullOrEmpty(username))
                                {
                                    if (!string.IsNullOrEmpty(entity.teamid) && string.IsNullOrEmpty(entity.userid))
                                    {
                                        resultmessage += "人员不存在于专业/班组中、";
                                        isadddobj      = false;
                                    }
                                    else if (!string.IsNullOrEmpty(entity.deptid) && string.IsNullOrEmpty(entity.teamid) && string.IsNullOrEmpty(entity.userid))
                                    {
                                        resultmessage += "人员不存在于" + labledept + "中、";
                                        isadddobj      = false;
                                    }
                                    else
                                    {
                                        if (string.IsNullOrEmpty(entity.userid))
                                        {
                                            resultmessage += "人员填写错误或不存在、";
                                            isadddobj      = false;
                                        }
                                    }
                                }

                                if (string.IsNullOrEmpty(deptname))
                                {
                                    resultmessage += labledept + "为空、";
                                    isadddobj      = false;
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(entity.deptid))
                                    {
                                        resultmessage += labledept + "填写错误或不存在、";
                                        isadddobj      = false;
                                    }
                                }

                                if (!string.IsNullOrEmpty(teamname))
                                {
                                    if (!string.IsNullOrEmpty(entity.deptid) && string.IsNullOrEmpty(entity.teamid))
                                    {
                                        resultmessage += "专业/班组不存在于对应的" + labledept + "、";
                                        isadddobj      = false;
                                    }
                                }

                                if (!string.IsNullOrEmpty(entity.nature))
                                {
                                    if ((mode == 0 && entity.nature == "承包商"))
                                    {
                                        resultmessage += "生产部门导入模板中不应存在外协单位数据、";
                                        isadddobj      = false;
                                    }
                                    if ((mode == 1 && entity.nature != "承包商"))
                                    {
                                        resultmessage += "外协单位导入模板中不应存在生产部门数据、";
                                        isadddobj      = false;
                                    }
                                }

                                if (string.IsNullOrEmpty(lllegaldescribe))
                                {
                                    resultmessage += "违章过程描述为空、";
                                    isadddobj      = false;
                                }
                                if (string.IsNullOrEmpty(lllegaltypename))
                                {
                                    resultmessage += "违章分类为空、";
                                    isadddobj      = false;
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(entity.lllegaltype))
                                    {
                                        resultmessage += "违章分类不存在、";
                                        isadddobj      = false;
                                    }
                                }

                                if (string.IsNullOrEmpty(punishresult))
                                {
                                    resultmessage += "处罚结果(元)为空、";
                                    isadddobj      = false;
                                }
                                else
                                {
                                    entity.punishresult = int.Parse(punishresult);
                                }

                                if (string.IsNullOrEmpty(punishpoint))
                                {
                                    resultmessage += "处罚积分(分)为空、";
                                    isadddobj      = false;
                                }
                                else
                                {
                                    entity.punishpoint = int.Parse(punishpoint);
                                }

                                if (isadddobj)
                                {
                                    list.Add(entity);
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(resultmessage))
                                    {
                                        resultmessage = resultmessage.Substring(0, resultmessage.Length - 1) + ",无法正常导入";
                                        resultlist.Add(resultmessage);
                                    }
                                }
                                #endregion
                            }
                            catch
                            {
                                resultmessage += "出现数据异常,无法正常导入";
                                resultlist.Add(resultmessage);
                            }
                        }
                        if (resultlist.Count > 0)
                        {
                            foreach (string str in resultlist)
                            {
                                falseMessage += str + "</br>";
                            }
                        }
                        #endregion
                        #region 问题数据集合

                        foreach (ImportLllegalPunish entity in list)
                        {
                            string keyValue  = string.Empty;
                            int    excuteVal = 0;
                            //违章档案扣分信息
                            LllegalDeductMarksEntity baseentity = new LllegalDeductMarksEntity();

                            //获取已存在的违章问题
                            if (!string.IsNullOrEmpty(entity.userid))
                            {
                                var llist = lllegaldeductmarksbll.GetLllegalRecorList(entity.punishdate, entity.userid, entity.lllegaldescribe, entity.deptid, entity.teamid);

                                if (llist.Count() > 0)
                                {
                                    var otherwz = llist.Where(p => p.CREATEUSERID != curUser.UserId);
                                    //其他人创建的
                                    if (otherwz.Count() > 0)
                                    {
                                        falseMessage += "人员为'" + entity.username + "'于" + entity.punishdate + "处罚的数据因已被其他人创建而无法覆盖,不予操作</br>";
                                        excuteVal     = -1;
                                    }
                                    else //自己创建
                                    {
                                        baseentity = llist.FirstOrDefault();
                                        //先删除,后新增
                                        lllegaldeductmarksbll.RemoveForm(baseentity.ID);
                                        baseentity = new LllegalDeductMarksEntity();
                                        excuteVal  = 1;
                                    }
                                }
                                else
                                {
                                    excuteVal = 1;
                                }
                            }
                            else
                            {
                                excuteVal = 1;
                            }

                            if (excuteVal > 0)
                            {
                                baseentity.APPSIGN         = "3"; //标识导入的
                                baseentity.USERID          = entity.userid;
                                baseentity.USERNAME        = entity.username;
                                baseentity.DEPTID          = entity.deptid;
                                baseentity.DEPTNAME        = entity.deptname;
                                baseentity.TEAMID          = entity.teamid;
                                baseentity.TEAMNAME        = entity.teamname;
                                baseentity.DUTYNAME        = entity.dutyname;
                                baseentity.LLLEGALDESCRIBE = entity.lllegaldescribe;
                                baseentity.LLLEGALTYPE     = entity.lllegaltype;
                                baseentity.LLLEGALTYPENAME = entity.lllegaltypename;
                                baseentity.PUNISHDATE      = Convert.ToDateTime(entity.punishdate);
                                baseentity.PUNISHRESULT    = entity.punishresult;
                                baseentity.PUNISHPOINT     = entity.punishpoint;
                                lllegaldeductmarksbll.SaveForm("", baseentity);
                                total += 1;
                            }
                        }
                        #endregion
                    }
                    #endregion
                    count    = dt.Rows.Count;
                    message  = "共有" + count.ToString() + "条记录,成功导入" + total.ToString() + "条,失败" + (count - total).ToString() + "条";
                    message += "</br>" + falseMessage;
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return(message);
        }
Пример #29
0
        public string ImportData()
        {
            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;
                DataItemDetailBLL    dataItemDetailBLL = new DataItemDetailBLL();
                List <DataItemModel> data              = dataItemDetailBLL.GetDataItemListByItemCode("'CarNo'").ToList();


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //车牌号
                    string CarNo = dt.Rows[i][0].ToString();
                    //车辆品牌系列
                    string Model = dt.Rows[i][1].ToString();
                    ////驾驶人
                    //string Dirver = dt.Rows[i][2].ToString();
                    ////驾驶人电话
                    //string Phone = dt.Rows[i][3].ToString();
                    //最近年检日期
                    string Time = dt.Rows[i][2].ToString();
                    //起始时间
                    string StartTime = dt.Rows[i][3].ToString();
                    ////结束时间
                    string EndTime = dt.Rows[i][4].ToString();
                    //荷载人数
                    string Num = dt.Rows[i][5].ToString();

                    if (CarNo.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号为空,未能导入.";
                        error++;
                        continue;
                    }

                    CarNo = CarNo.Trim().ToUpper();//英文转换为大写


                    string s    = CarNo.Substring(0, 1);
                    bool   flag = false;
                    foreach (var d in data)
                    {
                        if (d.ItemName == s)
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (flag == false)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号输入格式错误,第一位请输入正确的省缩写,未能导入.";
                        error++;
                        continue;
                    }

                    //判断车牌号位数是否合法
                    if (!Regex.IsMatch(CarNo.Trim(), "(^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$)"))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号填写错误,未能导入.";
                        error++;
                        continue;
                    }

                    if (Model.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "内部编号为空,未能导入.";
                        error++;
                        continue;
                    }
                    //if (Dirver.Trim() == "")
                    //{
                    //    falseMessage += "</br>" + "第" + (i + 2) + "驾驶人为空,未能导入.";
                    //    error++;
                    //    continue;
                    //}
                    //if (Phone.Trim() == "")
                    //{
                    //    falseMessage += "</br>" + "第" + (i + 2) + "驾驶人电话为空,未能导入.";
                    //    error++;
                    //    continue;
                    //}
                    if (Time.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "最近年检日期为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (StartTime.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "起始时间为空,未能导入.";
                        error++;
                        continue;
                    }
                    if (EndTime.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "结束时间为空,未能导入.";
                        error++;
                        continue;
                    }
                    if (Num.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "荷载人数为空,未能导入.";
                        error++;
                        continue;
                    }
                    DateTime dtime;
                    try
                    {
                        DateTime.TryParse(Time, out dtime);

                        if (dtime.ToString("yyyy-MM-dd") == "0001-01-01")
                        {
                            falseMessage += "</br>" + "第" + (i + 2) + "最近年检日期格式不对,请输入yyyy-MM-dd格式,未能导入.";
                            error++;
                            continue;
                        }
                    }
                    catch (Exception e)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "最近年检日期格式不对,请输入yyyy-MM-dd格式,未能导入.";
                        error++;
                        continue;
                    }

                    DateTime Stime;


                    DateTime.TryParse(StartTime, out Stime);

                    if (Stime.ToString("yyyy-MM-dd") == "0001-01-01")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "起始时间格式不对,请输入yyyy-MM-dd格式,未能导入.";
                        error++;
                        continue;
                    }



                    DateTime Etime;


                    DateTime.TryParse(StartTime, out Etime);

                    if (Etime.ToString("yyyy-MM-dd") == "0001-01-01")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "结束时间格式不对,请输入yyyy-MM-dd格式,未能导入.";
                        error++;
                        continue;
                    }


                    if (carinfobll.GetCarNoIsRepeat(CarNo, ""))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号数据已存在,请勿重复录入.";
                        error++;
                        continue;
                    }

                    Etime = Convert.ToDateTime(Etime.ToString("yyyy-MM-dd 23:59:59"));
                    Stime = Convert.ToDateTime(Stime.ToString("yyyy-MM-dd 00:00:00"));

                    CarinfoEntity hf = new CarinfoEntity();
                    hf.CarNo   = CarNo.Trim();
                    hf.GpsId   = "";
                    hf.GpsName = "";
                    //hf.Dirver = Dirver;
                    hf.InsperctionDate = dtime;
                    hf.Model           = Model;
                    hf.NumberLimit     = Convert.ToInt32(Num);
                    hf.Endtime         = Etime;
                    hf.Starttime       = Stime;
                    //hf.Phone = Phone;
                    hf.NextInsperctionDate = dtime.AddDays(-1).AddYears(1);
                    hf.Type = 0;


                    try
                    {
                        DataItemDetailBLL pdata = new DataItemDetailBLL();
                        var pitem = pdata.GetItemValue("Hikappkey");  //海康服务器密钥
                        var url   = pdata.GetItemValue("HikBaseUrl"); //海康服务器地址
                        carinfobll.SaveForm("", hf, pitem, url);
                    }
                    catch
                    {
                        error++;
                    }
                }
                count    = dt.Rows.Count;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }

            return(message);
        }
Пример #30
0
        public List <RouteconfigEntity> IniRoute()
        {
            List <RouteconfigEntity> rlist = new List <RouteconfigEntity>();
            //危化品
            RouteconfigEntity Hazadous = new RouteconfigEntity();

            Hazadous.Level     = 1;
            Hazadous.GID       = "";
            Hazadous.IsEnable  = 0;
            Hazadous.IsPier    = 0;
            Hazadous.ParentId  = "0";
            Hazadous.ItemName  = "危化品车辆路线";
            Hazadous.PointList = "";
            Hazadous.Sort      = 1;
            Hazadous.LineType  = 0;
            Hazadous.Create();
            rlist.Add(Hazadous);
            DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL();
            //根据危化品类型添加二级节点
            var data = dataItemDetailBLL.GetDataItemListByItemCode("'HazardousCar'");
            int i    = 1;

            foreach (var item in data)
            {
                RouteconfigEntity Hazadousdetail = new RouteconfigEntity();
                Hazadousdetail.Level     = 2;
                Hazadousdetail.GID       = item.ItemDetailId;
                Hazadousdetail.IsEnable  = 0;
                Hazadousdetail.IsPier    = 0;
                Hazadousdetail.ParentId  = Hazadous.ID;
                Hazadousdetail.ItemName  = item.ItemName;
                Hazadousdetail.PointList = "";
                Hazadousdetail.Sort      = i;
                Hazadousdetail.LineType  = 0;
                Hazadousdetail.Create();
                i++;
                rlist.Add(Hazadousdetail);
                RouteconfigEntity HazadousLine1 = new RouteconfigEntity();
                HazadousLine1.Level     = 3;
                HazadousLine1.GID       = item.ItemDetailId;
                HazadousLine1.IsEnable  = 0;
                HazadousLine1.IsPier    = 0;
                HazadousLine1.ParentId  = Hazadousdetail.ID;
                HazadousLine1.ItemName  = "1号路线";
                HazadousLine1.PointList = "";
                HazadousLine1.Sort      = 1;
                HazadousLine1.LineType  = 0;
                HazadousLine1.Create();

                RouteconfigEntity HazadousLine2 = new RouteconfigEntity();
                HazadousLine2.Level     = 3;
                HazadousLine2.GID       = item.ItemDetailId;
                HazadousLine2.IsEnable  = 0;
                HazadousLine2.IsPier    = 0;
                HazadousLine2.ParentId  = Hazadousdetail.ID;
                HazadousLine2.ItemName  = "2号路线";
                HazadousLine2.PointList = "";
                HazadousLine2.Sort      = 2;
                HazadousLine2.LineType  = 0;
                HazadousLine2.Create();

                rlist.Add(HazadousLine1);
                rlist.Add(HazadousLine2);
            }


            RouteconfigEntity WlCar = new RouteconfigEntity();

            WlCar.Level     = 1;
            WlCar.GID       = "";
            WlCar.IsEnable  = 0;
            WlCar.IsPier    = 0;
            WlCar.ParentId  = "0";
            WlCar.ItemName  = "物料销售车辆";
            WlCar.PointList = "";
            WlCar.Sort      = 2;
            WlCar.LineType  = 0;
            WlCar.Create();
            rlist.Add(WlCar);

            var wllist = routeconfigbll.GetWlList();

            i = 1;
            foreach (var item in wllist)
            {
                RouteconfigEntity WlCardetail = new RouteconfigEntity();
                WlCardetail.Level     = 2;
                WlCardetail.GID       = item.ItemDetailId;
                WlCardetail.IsEnable  = 0;
                WlCardetail.IsPier    = 0;
                WlCardetail.ParentId  = WlCar.ID;
                WlCardetail.ItemName  = item.ItemName + "提货";
                WlCardetail.PointList = "";
                WlCardetail.Sort      = i;
                WlCardetail.LineType  = 0;
                WlCardetail.Create();
                rlist.Add(WlCardetail);
                i++;
                RouteconfigEntity WlLine1 = new RouteconfigEntity();
                WlLine1.Level     = 3;
                WlLine1.GID       = item.ItemDetailId;
                WlLine1.IsEnable  = 0;
                WlLine1.IsPier    = 0;
                WlLine1.ParentId  = WlCardetail.ID;
                WlLine1.ItemName  = "1号路线";
                WlLine1.PointList = "";
                WlLine1.Sort      = 1;
                WlLine1.LineType  = 0;
                WlLine1.Create();

                RouteconfigEntity WlLine2 = new RouteconfigEntity();
                WlLine2.Level     = 3;
                WlLine2.GID       = item.ItemDetailId;
                WlLine2.IsEnable  = 0;
                WlLine2.IsPier    = 0;
                WlLine2.ParentId  = WlCardetail.ID;
                WlLine2.ItemName  = "2号路线";
                WlLine2.PointList = "";
                WlLine2.Sort      = 2;
                WlLine2.LineType  = 0;
                WlLine2.Create();

                rlist.Add(WlLine1);
                rlist.Add(WlLine2);
            }

            foreach (var item in wllist)
            {
                RouteconfigEntity WlCarMtdetail = new RouteconfigEntity();
                WlCarMtdetail.Level     = 2;
                WlCarMtdetail.GID       = item.ItemDetailId + "MT";
                WlCarMtdetail.IsEnable  = 0;
                WlCarMtdetail.IsPier    = 0;
                WlCarMtdetail.ParentId  = WlCar.ID;
                WlCarMtdetail.ItemName  = item.ItemName + "提货(码头)";
                WlCarMtdetail.PointList = "";
                WlCarMtdetail.Sort      = i;
                WlCarMtdetail.LineType  = 0;
                WlCarMtdetail.Create();
                rlist.Add(WlCarMtdetail);
                i++;
                RouteconfigEntity WlLine1 = new RouteconfigEntity();
                WlLine1.Level     = 3;
                WlLine1.GID       = item.ItemDetailId + "MT";
                WlLine1.IsEnable  = 0;
                WlLine1.IsPier    = 0;
                WlLine1.ParentId  = WlCarMtdetail.ID;
                WlLine1.ItemName  = "1号路线";
                WlLine1.PointList = "";
                WlLine1.Sort      = 1;
                WlLine1.LineType  = 0;
                WlLine1.Create();

                RouteconfigEntity WlLine2 = new RouteconfigEntity();
                WlLine2.Level     = 3;
                WlLine2.GID       = item.ItemDetailId + "MT";
                WlLine2.IsEnable  = 0;
                WlLine2.IsPier    = 0;
                WlLine2.ParentId  = WlCarMtdetail.ID;
                WlLine2.ItemName  = "2号路线";
                WlLine2.PointList = "";
                WlLine2.Sort      = 2;
                WlLine2.LineType  = 0;
                WlLine2.Create();

                rlist.Add(WlLine1);
                rlist.Add(WlLine2);
            }

            RouteconfigEntity WlZydetail = new RouteconfigEntity();

            WlZydetail.Level     = 2;
            WlZydetail.GID       = "Zy";
            WlZydetail.IsEnable  = 0;
            WlZydetail.IsPier    = 0;
            WlZydetail.ParentId  = WlCar.ID;
            WlZydetail.ItemName  = "转运(纯称重)";
            WlZydetail.PointList = "";
            WlZydetail.Sort      = i;
            WlZydetail.LineType  = 0;
            WlZydetail.Create();
            rlist.Add(WlZydetail);
            i++;
            RouteconfigEntity WlZyLine1 = new RouteconfigEntity();

            WlZyLine1.Level     = 3;
            WlZyLine1.GID       = "Zy";
            WlZyLine1.IsEnable  = 0;
            WlZyLine1.IsPier    = 0;
            WlZyLine1.ParentId  = WlZydetail.ID;
            WlZyLine1.ItemName  = "1号路线";
            WlZyLine1.PointList = "";
            WlZyLine1.Sort      = 1;
            WlZyLine1.LineType  = 0;
            WlZyLine1.Create();

            RouteconfigEntity WlZyLine2 = new RouteconfigEntity();

            WlZyLine2.Level     = 3;
            WlZyLine2.GID       = "Zy";
            WlZyLine2.IsEnable  = 0;
            WlZyLine2.IsPier    = 0;
            WlZyLine2.ParentId  = WlZydetail.ID;
            WlZyLine2.ItemName  = "2号路线";
            WlZyLine2.PointList = "";
            WlZyLine2.Sort      = 2;
            WlZyLine2.LineType  = 0;
            WlZyLine2.Create();

            rlist.Add(WlZyLine1);
            rlist.Add(WlZyLine2);


            RouteconfigEntity WlZyMtdetail = new RouteconfigEntity();

            WlZyMtdetail.Level     = 2;
            WlZyMtdetail.GID       = "ZyMt";
            WlZyMtdetail.IsEnable  = 0;
            WlZyMtdetail.IsPier    = 0;
            WlZyMtdetail.ParentId  = WlCar.ID;
            WlZyMtdetail.ItemName  = "物料转运(码头)";
            WlZyMtdetail.PointList = "";
            WlZyMtdetail.Sort      = i;
            WlZyMtdetail.LineType  = 0;
            WlZyMtdetail.Create();
            rlist.Add(WlZyMtdetail);
            i++;
            RouteconfigEntity WlZyMtLine1 = new RouteconfigEntity();

            WlZyMtLine1.Level     = 3;
            WlZyMtLine1.GID       = "ZyMt";
            WlZyMtLine1.IsEnable  = 0;
            WlZyMtLine1.IsPier    = 0;
            WlZyMtLine1.ParentId  = WlZyMtdetail.ID;
            WlZyMtLine1.ItemName  = "1号路线";
            WlZyMtLine1.PointList = "";
            WlZyMtLine1.Sort      = 1;
            WlZyMtLine1.LineType  = 0;
            WlZyMtLine1.Create();

            RouteconfigEntity WlZyMtLine2 = new RouteconfigEntity();

            WlZyMtLine2.Level     = 3;
            WlZyMtLine2.GID       = "ZyMt";
            WlZyMtLine2.IsEnable  = 0;
            WlZyMtLine2.IsPier    = 0;
            WlZyMtLine2.ParentId  = WlZyMtdetail.ID;
            WlZyMtLine2.ItemName  = "2号路线";
            WlZyMtLine2.PointList = "";
            WlZyMtLine2.Sort      = 2;
            WlZyMtLine2.LineType  = 0;
            WlZyMtLine2.Create();

            rlist.Add(WlZyMtLine1);
            rlist.Add(WlZyMtLine2);


            ////拜访车辆
            //RouteconfigEntity Visit = new RouteconfigEntity();
            //Visit.Level = 1;
            //Visit.GID = "";
            //Visit.IsEnable = 0;
            //Visit.IsPier = 0;
            //Visit.ParentId = "0";
            //Visit.ItemName = "拜访车辆";
            //Visit.PointList = "";
            //Visit.Sort = 3;
            //Visit.Create();
            //rlist.Add(Visit);

            //RouteconfigEntity Visitdetail = new RouteconfigEntity();
            //Visitdetail.Level = 2;
            //Visitdetail.GID = "Visit";
            //Visitdetail.IsEnable = 0;
            //Visitdetail.IsPier = 0;
            //Visitdetail.ParentId = Visit.ID;
            //Visitdetail.ItemName = "拜访路线";
            //Visitdetail.PointList = "";
            //Visitdetail.Sort = 1;
            //Visitdetail.Create();
            //rlist.Add(Visitdetail);

            //RouteconfigEntity VisitLine1 = new RouteconfigEntity();
            //VisitLine1.Level = 3;
            //VisitLine1.GID = "Visit";
            //VisitLine1.IsEnable = 0;
            //VisitLine1.IsPier = 0;
            //VisitLine1.ParentId = Visitdetail.ID;
            //VisitLine1.ItemName = "1号路线";
            //VisitLine1.PointList = "";
            //VisitLine1.Sort = 1;
            //VisitLine1.Create();

            //RouteconfigEntity VisitLine2 = new RouteconfigEntity();
            //VisitLine2.Level = 3;
            //VisitLine2.GID = "Visit";
            //VisitLine2.IsEnable = 0;
            //VisitLine2.IsPier = 0;
            //VisitLine2.ParentId = Visitdetail.ID;
            //VisitLine2.ItemName = "2号路线";
            //VisitLine2.PointList = "";
            //VisitLine2.Sort = 2;
            //VisitLine2.Create();

            //rlist.Add(VisitLine1);
            //rlist.Add(VisitLine2);


            //其他车辆
            RouteconfigEntity Other = new RouteconfigEntity();

            Other.Level     = 1;
            Other.GID       = "";
            Other.IsEnable  = 0;
            Other.IsPier    = 0;
            Other.ParentId  = "0";
            Other.ItemName  = "其他车辆";
            Other.PointList = "";
            Other.Sort      = 4;
            Other.LineType  = 0;
            Other.Create();
            rlist.Add(Other);

            RouteconfigEntity Otherdetail = new RouteconfigEntity();

            Otherdetail.Level     = 2;
            Otherdetail.GID       = "Other";
            Otherdetail.IsEnable  = 0;
            Otherdetail.IsPier    = 0;
            Otherdetail.ParentId  = Other.ID;
            Otherdetail.ItemName  = "其他路线";
            Otherdetail.PointList = "";
            Otherdetail.Sort      = 1;
            Otherdetail.LineType  = 0;
            Otherdetail.Create();
            rlist.Add(Otherdetail);

            RouteconfigEntity OtherLine1 = new RouteconfigEntity();

            OtherLine1.Level     = 3;
            OtherLine1.GID       = "Other";
            OtherLine1.IsEnable  = 0;
            OtherLine1.IsPier    = 0;
            OtherLine1.ParentId  = Otherdetail.ID;
            OtherLine1.ItemName  = "1号路线";
            OtherLine1.PointList = "";
            OtherLine1.Sort      = 1;
            OtherLine1.LineType  = 0;
            OtherLine1.Create();

            RouteconfigEntity OtherLine2 = new RouteconfigEntity();

            OtherLine2.Level     = 3;
            OtherLine2.GID       = "Other";
            OtherLine2.IsEnable  = 0;
            OtherLine2.IsPier    = 0;
            OtherLine2.ParentId  = Otherdetail.ID;
            OtherLine2.ItemName  = "2号路线";
            OtherLine2.PointList = "";
            OtherLine2.Sort      = 2;
            OtherLine2.LineType  = 0;
            OtherLine2.Create();

            rlist.Add(OtherLine1);
            rlist.Add(OtherLine2);

            routeconfigbll.SaveList(rlist);

            return(rlist);
        }