Beispiel #1
0
        public object IntegralInfo([FromBody] JObject json)
        {
            try
            {
                string  res    = json.Value <string>("json");
                dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId = dy.userid;
                string  uId    = dy.data.uid;        //人员Id
                OperatorProvider.AppUserId = userId; //设置当前用户
                UserEntity user = new UserBLL().GetEntity(uId);
                DataTable  dt   = new UserScoreBLL().GetList(uId);

                DataItemDetailBLL itemBll = new DataItemDetailBLL();
                ERCHTMS.Entity.SystemManage.DataItemDetailEntity entity = itemBll.GetEntity("csjf");
                decimal score = new UserScoreBLL().GetUserScore(uId, DateTime.Now.Year.ToString());
                score = entity == null ? score : int.Parse(entity.ItemValue) + score;
                return(new { Code = 0, Count = 0, Info = "操作成功", data = new { score = score, Details = dt } });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
        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));
        }
Beispiel #3
0
 /// <summary>
 /// 同步修改海康安防平台人员组织信息
 /// </summary>
 public void HikUpdateUserInfo(TransferEntity entity)
 {
     try
     {
         DataItemDetailBLL itemBll  = new DataItemDetailBLL();
         string            KMIndex  = itemBll.GetItemValue("KMIndexUrl");
         string            HikHttps = itemBll.GetItemValue("HikHttps");
         List <UserEntity> list     = new List <UserEntity>();
         if (!string.IsNullOrEmpty(KMIndex) || !string.IsNullOrEmpty(HikHttps))
         {//只允许执行该操作(可门电厂、黄金埠)
             if (entity != null && entity.IsConfirm == 0)
             {
                 UserEntity ue = userBLL.GetEntity(entity.UserId);
                 ue.DepartmentId = entity.OutDeptId;
                 HikUpdateUserInfo(ue);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// 删除附件
        /// </summary>
        /// <param name="fileInfoIds"></param>
        public bool DeleteFile(string fileInfoIds)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(fileInfoIds))
            {
                string ids = "";

                string[] strArray = fileInfoIds.Split(',');

                foreach (string s in strArray)
                {
                    ids += "'" + s + "',";
                    var entity = fileInfoBLL.GetEntity(s);
                    if (entity != null)
                    {
                        // var filePath = ctx.Server.MapPath(entity.FilePath);
                        var filePath = new DataItemDetailBLL().GetItemValue("imgPath") +
                                       entity.FilePath.Replace("~", "");
                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(ids))
                {
                    ids = ids.Substring(0, ids.Length - 1);
                }
                int count = fileInfoBLL.DeleteFileForm(ids);

                result = count > 0 ? true : false;
            }

            return(result);
        }
Beispiel #5
0
 public object GetEveryEntity([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 id     = dy.data.Id;//ID
         var    data   = everydaypatrolbll.GetEntity(id);
         string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
         if (data.Signature.IndexOf("http") > -1)
         {
             data.Signature = data.Signature;
         }
         else
         {
             data.Signature = webUrl + data.Signature;
         }
         EverydayPatrolApp everydayPatrolApp = new EverydayPatrolApp();
         everydayPatrolApp.Jurisdiction               = "1,1,1";
         everydayPatrolApp.EverydayPatrolEntity       = data;
         everydayPatrolApp.EverydayPatrolDetailEntity = GetEverydayPatrolDetailGrid(id);
         everydayPatrolApp.AffirmRecordEntity         = GetAffirmRecordGrid(id);
         return(new { Code = 0, Count = 1, Info = "获取数据成功", data = everydayPatrolApp });
     }
     catch (Exception ex)
     {
         return(new { Code = -1, Count = 0, Info = ex.Message });
     }
 }
Beispiel #6
0
        public TemporaryUserEntity ImgToBase64(string imgData)
        {
            TemporaryUserEntity UserEntity = new TemporaryUserEntity();
            string fileurl = string.Empty;

            if (!string.IsNullOrEmpty(imgData))
            {//拍照的照片
                UserEntity.ImgData = imgData;
                DataItemDetailBLL dd   = new DataItemDetailBLL();
                string            path = dd.GetItemValue("imgPath") + "\\Resource\\" + "TemporaryUser";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string sdd    = imgData.Substring(0, imgData.IndexOf(',') + 1);
                string base64 = imgData.Replace(sdd, "");
                byte[] arr2   = Convert.FromBase64String(base64);
                using (MemoryStream ms2 = new MemoryStream(arr2))
                {//将png格式图片存储为jpg格式文件
                    System.Drawing.Bitmap bmp2 = new System.Drawing.Bitmap(ms2);
                    bmp2 = KiResizelmage(bmp2, 600, 450);
                    string fileName = Guid.NewGuid().ToString() + ".jpg";
                    bmp2.Save(path + "\\" + fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                    fileurl = "\\Resource\\" + "TemporaryUser" + "\\" + fileName;
                }
                string srcPath = Server.MapPath("~" + fileurl);
                if (System.IO.File.Exists(srcPath))
                {
                    //读jpg图片转为Base64String
                    var nbase64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(srcPath));
                    UserEntity.ImgData = nbase64;
                }
                UserEntity.UserImg = fileurl;
            }
            return(UserEntity);
        }
        public object GetSpecialAuditList([FromBody] JObject json)
        {
            try
            {
                string  res      = json.Value <string>("json");
                dynamic dy       = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId   = dy.userid;
                string  keyValue = res.Contains("id") ? dy.data.id : "";
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator user = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!" });
                }

                var obj = aptitudeinvestigateauditbll.GetAuditList(keyValue).Where(p => p.REMARK != "0").ToList();
                if (obj == null)
                {
                    return(new { Code = -1, Count = 0, Info = "没有查询到数据!" });
                }
                else
                {
                    string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
                    foreach (var item in obj)
                    {
                        item.AUDITSIGNIMG = item.AUDITSIGNIMG.Replace("../../", webUrl + "/");
                    }
                    return(new { Code = 0, Count = -1, Info = "获取数据成功", data = obj });
                }
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
Beispiel #8
0
 /// <summary>
 /// 上传附件
 /// </summary>
 /// <param name="folderId"></param>
 /// <param name="foldername"></param>
 /// <param name="fileList"></param>
 public void UploadifyFile(string folderId, HttpFileCollection fileList, ref string path)
 {
     try
     {
         if (fileList.Count > 0)
         {
             for (int i = 0; i < fileList.AllKeys.Length; i++)
             {
                 if (fileList.AllKeys[i] != "sign")
                 {
                     HttpPostedFile file = fileList[i];
                     //获取文件完整文件名(包含绝对路径)
                     //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名}
                     string userId         = OperatorProvider.Provider.Current().UserId;
                     string fileGuid       = Guid.NewGuid().ToString();
                     long   filesize       = file.ContentLength;
                     string FileEextension = Path.GetExtension(file.FileName);
                     string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
                     string dir            = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\ResourceFile";
                     string newFileName    = fileGuid + FileEextension;
                     string newFilePath    = dir + "\\" + newFileName;
                     //创建文件夹
                     if (!Directory.Exists(dir))
                     {
                         Directory.CreateDirectory(dir);
                     }
                     FileInfoEntity fileInfoEntity = new FileInfoEntity();
                     if (!System.IO.File.Exists(newFilePath))
                     {
                         //保存文件
                         file.SaveAs(newFilePath);
                         //文件信息写入数据库
                         fileInfoEntity.Create();
                         fileInfoEntity.FileId         = fileGuid;
                         fileInfoEntity.RecId          = folderId; //关联ID
                         fileInfoEntity.FileName       = file.FileName;
                         fileInfoEntity.FilePath       = "~/Resource/ResourceFile/" + newFileName;
                         fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                         fileInfoEntity.FileExtensions = FileEextension;
                         fileInfoEntity.FileType       = FileEextension.Replace(".", "");
                         fileinfobll.SaveForm("", fileInfoEntity);
                     }
                 }
                 else
                 {
                     HttpPostedFile file           = fileList[i];
                     string         fileOverName   = System.IO.Path.GetFileName(file.FileName);
                     string         fileName       = System.IO.Path.GetFileNameWithoutExtension(file.FileName);
                     string         FileEextension = Path.GetExtension(file.FileName);
                     //if (fileName == scEntity.ID)
                     //{
                     string dir         = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\sign";
                     string newFileName = fileName + FileEextension;
                     string newFilePath = dir + "\\" + newFileName;
                     file.SaveAs(newFilePath);
                     //scEntity.SIGNPIC = "/Resource/sign/" + fileOverName;
                     //    break;
                     //}
                     path = fileOverName;
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
        public object GetForm([FromBody] JObject json)
        {
            try
            {
                string res = json.Value <string>("json");
                var    dy  = JsonConvert.DeserializeAnonymousType(res, new
                {
                    userid = string.Empty,
                    data   = new LifthoistViewModel()
                });
                //获取用户Id
                string userId = dy.userid;
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, info = "请求失败,请登录!" });
                }
                if (dy.data == null)
                {
                    return(new { code = -1, info = "请求失败,data参数为空!" });
                }
                LifthoistViewModel retData = new LifthoistViewModel();
                string[]           pops    = null;
                if (dy.data.pagetype == "1")
                {
                    #region 凭吊证详情处理
                    //需要排的除段
                    pops = new string[] { "deletefileids", "qualitytype", "guardianid", "guardianname", "hoistcontent", "liftschemes" };
                    LifthoistcertEntity certEntity = lifthoistcertbll.GetEntity(dy.data.id);
                    if (certEntity == null)
                    {
                        throw new ArgumentException("无法找到当前业务信息,请检查参数是否有误!");
                    }
                    retData = JsonConvert.DeserializeObject <LifthoistViewModel>(JsonConvert.SerializeObject(certEntity));
                    //取人员资料
                    DataTable persondatas = fileInfoBLL.GetFiles(certEntity.ID + "1");
                    if (persondatas != null && persondatas.Rows.Count > 0)
                    {
                        retData.persondatas = new List <Photo>();
                        foreach (DataRow item in persondatas.Rows)
                        {
                            Photo p = new Photo();
                            p.fileid   = item[0].ToString();
                            p.filename = item[1].ToString();
                            p.fileurl  = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1);
                            retData.persondatas.Add(p);
                        }
                    }
                    //取设备资料
                    DataTable driverdatas = fileInfoBLL.GetFiles(certEntity.ID + "2");
                    if (driverdatas != null && driverdatas.Rows.Count > 0)
                    {
                        retData.driverdatas = new List <Photo>();
                        foreach (DataRow item in driverdatas.Rows)
                        {
                            Photo p = new Photo();
                            p.fileid   = item[0].ToString();
                            p.filename = item[1].ToString();
                            p.fileurl  = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1);
                            retData.driverdatas.Add(p);
                        }
                    }
                    string[] signs = null;
                    string   urls  = string.Empty;
                    //处理签字
                    if (!string.IsNullOrEmpty(retData.chargepersonsign))
                    {
                        signs = retData.chargepersonsign.Split(',');
                        urls  = string.Empty;
                        foreach (var s in signs)
                        {
                            if (!string.IsNullOrEmpty(s))
                            {
                                if (s.Contains("http://"))
                                {
                                    urls += "," + s;
                                }
                                else
                                {
                                    urls += "," + dataitemdetailbll.GetItemValue("imgUrl") + s.Substring(1);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(urls))
                        {
                            retData.chargepersonsign = urls.Substring(1);
                        }
                    }
                    if (!string.IsNullOrEmpty(retData.hoistareapersonsigns))
                    {
                        signs = retData.hoistareapersonsigns.Split(',');
                        urls  = string.Empty;
                        foreach (var s in signs)
                        {
                            if (!string.IsNullOrEmpty(s))
                            {
                                if (s.Contains("http://"))
                                {
                                    urls += "," + s;
                                }
                                else
                                {
                                    urls += "," + dataitemdetailbll.GetItemValue("imgUrl") + s.Substring(1);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(urls))
                        {
                            retData.hoistareapersonsigns = urls.Substring(1);
                        }
                    }
                    //安全措施
                    var safetys = lifthoistsafetybll.GetList(string.Format("LIFTHOISTCERTID = '{0}'", certEntity.ID));
                    if (safetys != null)
                    {
                        retData.safetys = safetys.ToList();
                    }
                    #endregion
                }
                else
                {
                    #region 起重吊装作业详情处理
                    //需要排的除段
                    pops = new string[] { "lifthoistjobid", "deletefileids", "drivername", "drivernumber", "fulltimename", "fulltimenumber", "persondatas", "driverdatas", "safetys", "chargepersonsign", "hoistareapersonnames", "hoistareapersonids", "hoistareapersonsigns" };
                    LifthoistjobEntity jobEntity = lifthoistjobbll.GetEntity(dy.data.id);
                    if (jobEntity == null)
                    {
                        throw new ArgumentException("无法找到当前业务信息,请检查参数是否有误!");
                    }
                    retData = JsonConvert.DeserializeObject <LifthoistViewModel>(JsonConvert.SerializeObject(jobEntity));
                    //取起吊方案
                    DataTable liftschemes = fileInfoBLL.GetFiles(jobEntity.ID);
                    if (liftschemes != null && liftschemes.Rows.Count > 0)
                    {
                        retData.liftschemes = new List <Photo>();
                        foreach (DataRow item in liftschemes.Rows)
                        {
                            Photo p = new Photo();
                            p.fileid   = item[0].ToString();
                            p.filename = item[1].ToString();
                            p.fileurl  = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1);
                            retData.liftschemes.Add(p);
                        }
                    }

                    DataTable liftfazls = fileInfoBLL.GetFiles(jobEntity.FAZLFILES);
                    if (liftfazls != null && liftfazls.Rows.Count > 0)
                    {
                        retData.liftfazls = new List <Photo>();
                        foreach (DataRow item in liftfazls.Rows)
                        {
                            Photo p = new Photo();
                            p.fileid   = item[0].ToString();
                            p.filename = item[1].ToString();
                            p.fileurl  = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1);
                            retData.liftfazls.Add(p);
                        }
                    }
                    #endregion

                    #region 流程
                    string modulename = string.Empty;
                    if (jobEntity.QUALITYTYPE == "0")
                    {
                        modulename = "(起重吊装作业30T以下)审核";
                    }
                    else
                    {
                        modulename = "(起重吊装作业30T以上)审核";
                    }
                    var nodelist = lifthoistjobbll.GetAppFlowList(jobEntity.ID, modulename);
                    retData.CheckFlow = nodelist;
                    #endregion
                }
                //审核记录
                var records = lifthoistauditrecordbll.GetList(dy.data.id);
                if (records != null)
                {
                    string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
                    foreach (var item in records)
                    {
                        item.AUDITSIGNIMG = item.AUDITSIGNIMG.Replace("../../", webUrl + "/");
                    }
                    retData.auditrecords = records.ToList();
                }
                //作业安全风险分析
                var riskrecord = highriskrecordbll.GetList(dy.data.id).ToList();
                if (riskrecord != null)
                {
                    retData.riskrecord = riskrecord.ToList();
                }
                //起重吊装人员信息
                var lifthoistperson = lifthoistpersonbll.GetRelateList(dy.data.id).ToList();
                if (lifthoistperson != null)
                {
                    foreach (var item in lifthoistperson)
                    {
                        DataTable liftfazls = fileInfoBLL.GetFiles(item.Id);
                        if (liftfazls != null && liftfazls.Rows.Count > 0)
                        {
                            List <Photo> files = new List <Photo>();
                            foreach (DataRow rowitem in liftfazls.Rows)
                            {
                                Photo p = new Photo();
                                p.fileid   = rowitem[0].ToString();
                                p.filename = rowitem[1].ToString();
                                p.fileurl  = dataitemdetailbll.GetItemValue("imgUrl") + rowitem[2].ToString().Substring(1);
                                files.Add(p);
                            }
                            item.lifthoistpersonfile = files;
                        }
                        //var liftfazls = fileInfoBLL.GetFileList(item.Id);
                        //foreach (var file in liftfazls)
                        //{
                        //    file.FilePath = dataitemdetailbll.GetItemValue("imgUrl") + file.FilePath.Substring(1);
                        //}
                    }
                    retData.lifthoistperson = lifthoistperson.ToList();
                }
                JsonSerializerSettings settings = new JsonSerializerSettings
                {
                    ContractResolver = new LowercaseContractResolver(null, pops, false),
                    DateFormatString = "yyyy-MM-dd HH:mm", //格式化日期
                };
                string retDataJson = JsonConvert.SerializeObject(retData, Formatting.Indented, settings);
                return(new { code = 0, info = string.Empty, data = JObject.Parse(retDataJson) });
            }
            catch (Exception ex)
            {
                return(new { code = -1, info = ex.Message });
            }
        }
Beispiel #10
0
        public object GetEngineerDetails([FromBody] JObject json)
        {
            string  res    = json.Value <string>("json");
            dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
            string  userid = dy.userid;

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

            if (null == curUser)
            {
                return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() });
            }
            try
            {
                string id      = dy.data ?? "";
                var    disBll  = new DistrictBLL();
                var    didBll  = new DataItemDetailBLL();
                var    deptBll = new DepartmentBLL();
                var    data    = outsouringengineerbll.GetEntity(id);
                if (!string.IsNullOrWhiteSpace(data.ENGINEERAREA))
                {
                    var area = disBll.GetEntity(data.ENGINEERAREA);
                    if (area != null)
                    {
                        data.ENGINEERAREANAME = area.DistrictName;
                    }
                }
                if (!string.IsNullOrWhiteSpace(data.ENGINEERTYPE))
                {
                    var listType = didBll.GetDataItem("ProjectType", data.ENGINEERTYPE).ToList();
                    if (listType != null && listType.Count > 0)
                    {
                        data.ENGINEERTYPENAME = listType[0].ItemName;
                    }
                }
                if (!string.IsNullOrWhiteSpace(data.ENGINEERLEVEL))
                {
                    var listLevel = didBll.GetDataItem("ProjectLevel", data.ENGINEERLEVEL).ToList();
                    if (listLevel != null && listLevel.Count > 0)
                    {
                        data.ENGINEERLEVELNAME = listLevel[0].ItemName;
                    }
                }
                if (!string.IsNullOrWhiteSpace(data.OUTPROJECTID))
                {
                    var dept = deptbll.GetEntity(data.OUTPROJECTID);
                    data.OUTPROJECTCODE = dept.EnCode;
                    data.OUTPROJECTNAME = dept.FullName;
                }
                //return Json(new
                //{
                //    code = 0,
                //    info = "获取数据成功",
                //    count = 0,
                //    data = data
                //}, new JsonSerializerSettings() { DateFormatString = "yyyy-MM-dd HH:mm:ss" });

                JsonSerializerSettings settings = new JsonSerializerSettings
                {
                    //ContractResolver = new LowercaseContractResolver(dict_props), //转小写,并对指定的列进行自定义名进行更换
                    DateFormatString = "yyyy-MM-dd HH:mm:ss", //格式化日期
                    //NullValueHandling = NullValueHandling.Ignore 值为空则在JSON中体现
                };
                return(new { code = 0, info = "获取数据成功", count = 1, data = JObject.Parse(JsonConvert.SerializeObject(data, Formatting.None, settings)) });
                //return new
                //{
                //    code = 0,
                //    info = "获取数据成功",
                //    count = 0,
                //    data = data
                //};
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = "获取失败,错误:" + ex.Message, data = new object() });
            }
        }
Beispiel #11
0
        public object ApproveForm()
        {
            try
            {
                string   res      = HttpContext.Current.Request["json"];
                dynamic  dy       = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string   userid   = dy.userid;
                string   keyValue = dy.data.keyvalue;
                Operator curUser  = ERCHTMS.Code.OperatorProvider.Provider.Current();

                AptitudeinvestigateauditEntity aentity = new AptitudeinvestigateauditEntity
                {
                    AUDITRESULT   = dy.data.auditresult,
                    AUDITTIME     = Convert.ToDateTime(dy.data.audittime),
                    AUDITPEOPLE   = dy.data.auditpeople,
                    AUDITPEOPLEID = dy.data.auditpeopleid,
                    AUDITDEPTID   = dy.data.auditdeptid,
                    AUDITDEPT     = dy.data.auditdept,
                    AUDITOPINION  = dy.data.auditopinion,
                    AUDITSIGNIMG  = dy.data.auditsignimg
                };
                string state = string.Empty;

                string moduleName = "日常考核";

                DailyexamineEntity entity = dailyexaminebll.GetEntity(keyValue);
                /// <param name="currUser">当前登录人</param>
                /// <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
                /// <param name="moduleName">模块名称</param>
                /// <param name="createdeptid">创建人部门ID</param>
                ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, entity.CreateUserDeptId);


                #region                                                                                                                                 //审核信息表
                AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity();
                aidEntity.AUDITRESULT   = aentity.AUDITRESULT;                                                                                          //通过
                aidEntity.AUDITTIME     = Convert.ToDateTime(aentity.AUDITTIME.Value.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss")); //审核时间
                aidEntity.AUDITPEOPLE   = aentity.AUDITPEOPLE;                                                                                          //审核人员姓名
                aidEntity.AUDITPEOPLEID = aentity.AUDITPEOPLEID;                                                                                        //审核人员id
                aidEntity.APTITUDEID    = keyValue;                                                                                                     //关联的业务ID
                aidEntity.AUDITDEPTID   = aentity.AUDITDEPTID;                                                                                          //审核部门id
                aidEntity.AUDITDEPT     = aentity.AUDITDEPT;                                                                                            //审核部门
                aidEntity.AUDITOPINION  = aentity.AUDITOPINION;                                                                                         //审核意见
                aidEntity.FlowId        = entity.FlowID;
                aidEntity.AUDITSIGNIMG  = string.IsNullOrWhiteSpace(aentity.AUDITSIGNIMG) ? "" : aentity.AUDITSIGNIMG.ToString().Replace(new DataItemDetailBLL().GetItemValue("imgUrl"), "");

                HttpFileCollection files = HttpContext.Current.Request.Files;
                if (files.Count > 0)
                {
                    for (int i = 0; i < files.AllKeys.Length; i++)
                    {
                        HttpPostedFile file           = files[i];
                        string         fileOverName   = System.IO.Path.GetFileName(file.FileName);
                        string         fileName       = System.IO.Path.GetFileNameWithoutExtension(file.FileName);
                        string         FileEextension = Path.GetExtension(file.FileName);
                        //if (fileName == aidEntity.ID)
                        //{
                        string dir         = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\sign";
                        string newFileName = fileName + FileEextension;
                        string newFilePath = dir + "\\" + newFileName;
                        file.SaveAs(newFilePath);
                        aidEntity.AUDITSIGNIMG = "/Resource/sign/" + fileOverName;
                        break;
                        //}
                    }
                }
                aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity);
                #endregion

                #region  //保存日常考核
                //审核通过
                if (aentity.AUDITRESULT == "0")
                {
                    //0表示流程未完成,1表示流程结束
                    if (null != mpcEntity)
                    {
                        entity.FlowDept     = mpcEntity.CHECKDEPTID;
                        entity.FlowDeptName = mpcEntity.CHECKDEPTNAME;
                        entity.FlowRole     = mpcEntity.CHECKROLEID;
                        entity.FlowRoleName = mpcEntity.CHECKROLENAME;
                        entity.IsSaved      = 1;
                        entity.FlowID       = mpcEntity.ID;
                        entity.IsOver       = 0;
                        entity.FlowName     = mpcEntity.CHECKDEPTNAME + "审核中";
                    }
                    else
                    {
                        entity.FlowDept     = "";
                        entity.FlowDeptName = "";
                        entity.FlowRole     = "";
                        entity.FlowRoleName = "";
                        entity.IsSaved      = 1;
                        entity.IsOver       = 1;
                        entity.FlowName     = "";
                    }
                }
                else //审核不通过
                {
                    entity.FlowDept     = "";
                    entity.FlowDeptName = "";
                    entity.FlowRole     = "";
                    entity.FlowRoleName = "";
                    entity.FlowID       = "";
                    entity.IsOver       = 0; //处于登记阶段
                    entity.IsSaved      = 0; //是否完成状态赋值为未完成
                    entity.FlowName     = "";
                }
                //更新日常考核基本状态信息
                dailyexaminebll.SaveForm(keyValue, entity);
                #endregion

                #region    //审核不通过
                if (aentity.AUDITRESULT == "1")
                {
                    //添加历史记录
                    HistorydailyexamineEntity hsentity = new HistorydailyexamineEntity();
                    hsentity.CreateUserId       = entity.CreateUserId;
                    hsentity.CreateUserDeptCode = entity.CreateUserDeptCode;
                    hsentity.CreateUserOrgCode  = entity.CreateUserOrgCode;
                    hsentity.CreateDate         = entity.CreateDate;
                    hsentity.CreateUserName     = entity.CreateUserName;
                    hsentity.CreateUserDeptId   = entity.CreateUserDeptId;
                    hsentity.ModifyDate         = entity.ModifyDate;
                    hsentity.ModifyUserId       = entity.ModifyUserId;
                    hsentity.ModifyUserName     = entity.ModifyUserName;
                    hsentity.ExamineCode        = entity.ExamineCode;
                    hsentity.ExamineDept        = entity.ExamineDept;
                    hsentity.ExamineDeptId      = entity.ExamineDeptId;
                    hsentity.ExamineToDeptId    = entity.ExamineToDeptId;
                    hsentity.ExamineToDept      = entity.ExamineToDept;
                    hsentity.ExamineType        = entity.ExamineType; //关联ID
                    hsentity.ExamineMoney       = Convert.ToDouble(entity.ExamineMoney);
                    hsentity.ExaminePerson      = entity.ExaminePerson;
                    hsentity.ExaminePersonId    = entity.ExaminePersonId; //关联ID
                    hsentity.ExamineTime        = entity.ExamineTime;
                    hsentity.ExamineContent     = entity.ExamineContent;
                    hsentity.ExamineBasis       = entity.ExamineBasis;
                    hsentity.Remark             = entity.Remark;
                    hsentity.ContractId         = entity.Id;//关联ID
                    hsentity.IsSaved            = 2;
                    hsentity.IsOver             = entity.IsOver;
                    hsentity.FlowDeptName       = entity.FlowDeptName;
                    hsentity.FlowDept           = entity.FlowDept;
                    hsentity.FlowRoleName       = entity.FlowRoleName;
                    hsentity.FlowRole           = entity.FlowRole;
                    hsentity.FlowName           = entity.FlowName;
                    hsentity.Id = "";

                    historydailyexaminebll.SaveForm(hsentity.Id, hsentity);

                    //获取当前业务对象的所有审核记录
                    var shlist = aptitudeinvestigateauditbll.GetAuditList(keyValue);
                    //批量更新审核记录关联ID
                    foreach (AptitudeinvestigateauditEntity mode in shlist)
                    {
                        mode.APTITUDEID = hsentity.Id; //对应新的ID
                        aptitudeinvestigateauditbll.SaveForm(mode.ID, mode);
                    }
                    //批量更新附件记录关联ID
                    var flist = fileinfobll.GetImageListByObject(keyValue);
                    foreach (FileInfoEntity fmode in flist)
                    {
                        fmode.RecId = hsentity.Id; //对应新的ID
                        fileinfobll.SaveForm("", fmode);
                    }
                }
                #endregion

                return(new { Code = 0, Count = 0, Info = "保存成功" });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
        public object SaveCommitApply()
        {
            try
            {
                //string res = json.Value<string>("json");
                string             res            = HttpContext.Current.Request["json"];
                dynamic            dy             = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string             userId         = dy.userid;
                string             deleteids      = dy.deleteids;//删除附件id集合
                string             applyentity    = JsonConvert.SerializeObject(dy.applyentity);
                SafetychangeEntity change         = JsonConvert.DeserializeObject <SafetychangeEntity>(applyentity);
                string             riskrecordlist = res.Contains("riskrecord") ? JsonConvert.SerializeObject(dy.riskrecord) : "";
                var riskrecord = JsonConvert.DeserializeObject <List <HighRiskRecordEntity> >(riskrecordlist);
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator currUser = OperatorProvider.Provider.Current();
                change.ISACCEPOVER = 0;
                change.ISAPPLYOVER = 0;
                ManyPowerCheckEntity mpcEntity = null;
                string Type = dy.type;
                if (string.IsNullOrEmpty(change.ID))
                {
                    change.ID = Guid.NewGuid().ToString();
                }
                switch (Type)
                {
                case "0":
                    highriskrecordbll.RemoveFormByWorkId(change.ID);
                    if (riskrecord != null)
                    {
                        var num = 0;
                        foreach (var item in riskrecord)
                        {
                            item.CreateDate = DateTime.Now.AddSeconds(-num);
                            item.WorkId     = change.ID;
                            highriskrecordbll.SaveForm("", item);
                            num++;
                        }
                    }
                    if (change.ISCOMMIT == 0)
                    {
                        safetychangebll.SaveForm(change.ID, change);
                    }
                    else
                    {
                        string workUnitId = change.WORKUNITID;
                        //电厂内部审核流程
                        if (change.WORKUNITTYPE == "0")
                        {
                            string moduleName = "(内部)设施变动申请审核";
                            mpcEntity = peoplereviewbll.CheckAuditForNextByWorkUnit(currUser, moduleName, workUnitId, change.NodeId, false);
                        }
                        else
                        {
                            //外包审核流程
                            string moduleName = "(外包)设施变动申请审核";
                            mpcEntity = peoplereviewbll.CheckAuditForNextByOutsourcing(currUser, moduleName, workUnitId, change.NodeId, false, true);
                        }

                        if (null != mpcEntity)
                        {
                            change.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                            change.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                            change.FLOWROLE     = mpcEntity.CHECKROLEID;
                            change.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                            change.NodeId       = mpcEntity.ID;
                            change.NodeName     = mpcEntity.FLOWNAME;

                            new ScaffoldBLL().SendMessage(change.FLOWDEPT, change.FLOWROLE, "ZY011", change.ID);
                        }
                        else
                        {
                            //未配置审核项
                            change.FLOWDEPT     = "";
                            change.FLOWDEPTNAME = "";
                            change.FLOWROLE     = "";
                            change.FLOWROLENAME = "";
                            change.NodeId       = "";
                            change.NodeName     = "已完结";
                            //entity.ISACCEPOVER = 1;
                            change.ISCOMMIT    = 1;
                            change.ISAPPLYOVER = 1;    //申请审核完成
                        }
                        safetychangebll.SaveForm(change.ID, change);
                    }
                    break;

                case "1":
                    if (change.ISACCPCOMMIT == 0)
                    {
                        safetychangebll.SaveForm(change.ID, change);
                    }
                    else
                    {
                        string workUnitId = change.WORKUNITID;
                        //电厂内部验收审核流程
                        if (change.WORKUNITTYPE == "0")
                        {
                            string moduleName = "(内部)设施变动验收审核";
                            mpcEntity = peoplereviewbll.CheckAuditForNextByWorkUnit(currUser, moduleName, workUnitId, change.NodeId, false);
                        }
                        else
                        {
                            string moduleName = "(外包)设施变动验收审核";
                            //外包验收审核流程
                            mpcEntity = peoplereviewbll.CheckAuditForNextByOutsourcing(currUser, moduleName, workUnitId, change.NodeId, false, true);
                        }

                        if (null != mpcEntity)
                        {
                            change.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                            change.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                            change.FLOWROLE     = mpcEntity.CHECKROLEID;
                            change.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                            change.NodeId       = mpcEntity.ID;
                            change.NodeName     = mpcEntity.FLOWNAME;
                            change.ISCOMMIT     = 1;
                            change.ISAPPLYOVER  = 1;   //申请审核完成

                            new ScaffoldBLL().SendMessage(change.FLOWDEPT, change.FLOWROLE, "ZY012", change.ID);
                        }
                        else
                        {
                            //未配置审核项
                            change.FLOWDEPT     = "";
                            change.FLOWDEPTNAME = "";
                            change.FLOWROLE     = "";
                            change.FLOWROLENAME = "";
                            change.NodeId       = "";
                            change.NodeName     = "已完结";
                            //entity.ISACCEPOVER = 1;
                            change.ISCOMMIT     = 1;
                            change.ISACCPCOMMIT = 1;
                            change.ISACCEPOVER  = 1;   //验收审核完成
                            change.ISAPPLYOVER  = 1;   //申请审核完成
                        }
                        safetychangebll.SaveForm(change.ID, change);
                    }
                    break;

                default:
                    break;
                }

                if (!string.IsNullOrEmpty(deleteids))
                {
                    DeleteFile(deleteids);
                }
                HttpFileCollection files = HttpContext.Current.Request.Files;
                if (files.Count > 0)
                {
                    for (int i = 0; i < files.AllKeys.Length; i++)
                    {
                        HttpPostedFile file = files[i];
                        //原始文件名
                        string fileName       = System.IO.Path.GetFileName(file.FileName);
                        long   filesize       = file.ContentLength;
                        string FileEextension = Path.GetExtension(fileName);
                        string fileGuid       = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Guid.NewGuid().ToString();
                        string dir            = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\Upfile";
                        string newFileName    = fileGuid + FileEextension;
                        string newFilePath    = dir + "\\" + newFileName;
                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        FileInfoEntity fileInfoEntity = new FileInfoEntity();
                        if (!System.IO.File.Exists(newFilePath))
                        {
                            //保存文件
                            file.SaveAs(newFilePath);
                            //文件信息写入数据库
                            fileInfoEntity.Create();
                            fileInfoEntity.FileId         = fileGuid;
                            fileInfoEntity.RecId          = change.ID;
                            fileInfoEntity.FileName       = fileName;
                            fileInfoEntity.FilePath       = "~/Resource/Upfile/" + newFileName;
                            fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                            fileInfoEntity.FileExtensions = FileEextension;
                            fileInfoEntity.FileType       = FileEextension.TrimStart('.');
                            FileInfoBLL fileInfoBLL = new FileInfoBLL();
                            fileInfoBLL.SaveForm("", fileInfoEntity);
                        }
                    }
                }
                #region MyRegion
                #endregion


                return(new { code = 0, count = 1, info = "提交成功" });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
        public object AppSubmitAccpAudit()
        {
            try
            {
                string             res         = HttpContext.Current.Request["json"];
                dynamic            dy          = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string             userId      = dy.userid;
                string             applyentity = JsonConvert.SerializeObject(dy.data.applyentity);
                SafetychangeEntity change      = JsonConvert.DeserializeObject <SafetychangeEntity>(applyentity);

                string auditstr = JsonConvert.SerializeObject(dy.data.aiditentity);
                ScaffoldauditrecordEntity auditentity = JsonConvert.DeserializeObject <ScaffoldauditrecordEntity>(auditstr);
                string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");

                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator currUser   = OperatorProvider.Provider.Current();
                string   moduleName = string.Empty;
                if (change.WORKUNITTYPE == "0")
                {
                    moduleName = "(内部)设施变动验收审核";
                }
                else
                {
                    moduleName = "(外包)设施变动验收审核";
                }
                auditentity.FlowId = change.NodeId;
                ManyPowerCheckEntity mpcEntity = peoplereviewbll.CheckAuditForNextByWorkUnit(currUser, moduleName, change.WORKUNITID, change.NodeId, false);
                //同意进行下一步
                if (auditentity.AuditState == 0)
                {
                    //下一步流程不为空
                    if (null != mpcEntity)
                    {
                        change.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                        change.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                        change.FLOWROLE     = mpcEntity.CHECKROLEID;
                        change.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                        change.NodeId       = mpcEntity.ID;
                        change.NodeName     = mpcEntity.FLOWNAME;
                        change.ISCOMMIT     = 1;
                        change.ISACCPCOMMIT = 1;

                        new ScaffoldBLL().SendMessage(change.FLOWDEPT, change.FLOWROLE, "ZY012", change.ID);
                    }
                    else
                    {
                        change.FLOWDEPT     = " ";
                        change.FLOWDEPTNAME = " ";
                        change.FLOWROLE     = " ";
                        change.FLOWROLENAME = " ";
                        //change.NodeId = " ";
                        change.NodeName     = "已完结";
                        change.ISAPPLYOVER  = 1;
                        change.ISCOMMIT     = 1;
                        change.ISACCPCOMMIT = 1;
                        change.ISACCEPOVER  = 1;
                    }
                }
                else
                {
                    change.FLOWDEPT     = " ";
                    change.FLOWDEPTNAME = " ";
                    change.FLOWROLE     = " ";
                    change.FLOWROLENAME = " ";
                    //change.NodeId = " ";
                    change.NodeName     = "已完结";
                    change.ISAPPLYOVER  = 1;
                    change.ISCOMMIT     = 1;
                    change.ISACCPCOMMIT = 1;
                    change.ISACCEPOVER  = 2;

                    //审批不通过,推消息到申请人
                    var high = safetychangebll.GetEntity(change.ID);
                    if (high != null)
                    {
                        UserEntity userEntity = new UserBLL().GetEntity(high.CREATEUSERID);
                        if (userEntity != null)
                        {
                            JPushApi.PushMessage(userEntity.Account, userEntity.RealName, "ZY014", change.ID);
                        }
                    }
                }
                safetychangebll.SaveForm(change.ID, change);
                auditentity.ScaffoldId   = change.ID;
                auditentity.AuditDate    = DateTime.Now;
                auditentity.AuditSignImg = string.IsNullOrWhiteSpace(auditentity.AuditSignImg) ? "" : auditentity.AuditSignImg.Replace(webUrl, "").ToString();
                HttpFileCollection files = HttpContext.Current.Request.Files;
                if (files.Count > 0)
                {
                    for (int i = 0; i < files.AllKeys.Length; i++)
                    {
                        HttpPostedFile file           = files[i];
                        string         fileOverName   = System.IO.Path.GetFileName(file.FileName);
                        string         fileName       = System.IO.Path.GetFileNameWithoutExtension(file.FileName);
                        string         FileEextension = Path.GetExtension(file.FileName);
                        if (fileName == auditentity.Id)
                        {
                            string dir         = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\sign";
                            string newFileName = fileName + FileEextension;
                            string newFilePath = dir + "\\" + newFileName;
                            file.SaveAs(newFilePath);
                            auditentity.AuditSignImg = "/Resource/sign/" + fileOverName;
                            break;
                        }
                    }
                }
                auditentity.Id = null;
                scaffoldauditrecordbll.SaveForm("", auditentity);
                return(new { code = 0, count = 1, info = "提交成功" });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
Beispiel #14
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, PeopleReviewEntity entity)
 {
     try
     {
         List <string> userids = service.SaveForm(keyValue, entity);
         //对接培训平台
         if (userids.Count > 0)
         {
             try
             {
                 string           way  = new DataItemDetailBLL().GetItemValue("WhatWay");
                 Operator         user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                 DepartmentEntity org  = new DepartmentBLL().GetEntity(user.OrganizeId);
                 foreach (var item in userids)
                 {
                     var userInfo   = new UserBLL().GetUserInfoEntity(item);
                     var userEntity = new UserBLL().GetEntity(item);
                     if (org.IsTrain == 1)
                     {
                         //对接.net培训平台
                         if (way == "0")
                         {
                         }
                         //对接java培训平台
                         if (way == "1")
                         {
                             DepartmentEntity dept = new DepartmentBLL().GetEntity(userInfo.DepartmentId);
                             if (dept != null)
                             {
                                 string deptId = dept.DepartmentId;
                                 string enCode = dept.EnCode;
                                 if (!string.IsNullOrWhiteSpace(dept.DeptKey))
                                 {
                                     string[] arr = dept.DeptKey.Split('|');
                                     deptId = arr[0];
                                     if (arr.Length > 1)
                                     {
                                         enCode = arr[1];
                                     }
                                 }
                                 Task.Run(() =>
                                 {
                                     object obj = new
                                     {
                                         action     = "add",
                                         time       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                         userId     = userInfo.UserId,
                                         userName   = userInfo.RealName,
                                         account    = userInfo.Account,
                                         deptId     = deptId,
                                         deptCode   = enCode,
                                         password   = "******", //为null时不要修改密码!
                                         sex        = userInfo.Gender,
                                         idCard     = userInfo.IdentifyID,
                                         email      = userInfo.Email,
                                         mobile     = userInfo.Mobile,
                                         birth      = userInfo.Birthday == null ? "" : userInfo.Birthday.Value.ToString("yyyy-MM-dd"), //生日
                                         postName   = userInfo.DutyName,                                                               //岗位
                                         age        = userInfo.Age,                                                                    //年龄
                                         native     = userInfo.Native,                                                                 //籍贯
                                         nation     = userInfo.Nation,                                                                 //民族
                                         encode     = userInfo.EnCode,                                                                 //工号
                                         companyId  = org.InnerPhone,
                                         role       = userInfo.IsTrainAdmin == null ? 0 : userInfo.IsTrainAdmin,                       //角色(0:学员,1:培训管理员)
                                         postId     = userEntity.DutyId,
                                         jobTitle   = userEntity.JobTitle,
                                         techLevel  = userEntity.TechnicalGrade,
                                         workType   = userEntity.Craft,
                                         trainRoles = userEntity.TrainRoleId
                                     };
                                     List <object> list = new List <object>();
                                     list.Add(obj);
                                     Busines.JPush.JPushApi.PushMessage(list, 1);
                                 });
                             }
                         }
                     }
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #15
0
        public string GetWarnValue(string time = "", string orgCode = "", string orgId = "")
        {
            RiskBLL riskBLL = new RiskBLL();                                      //安全风险
            SaftyCheckDataRecordBLL saBLL        = new SaftyCheckDataRecordBLL(); //安全检查
            HTBaseInfoBLL           htBLL        = new HTBaseInfoBLL();           //事故隐患
            Operator                    user     = OperatorProvider.Provider.Current();
            ClassificationBLL           classBLL = new ClassificationBLL();
            List <ClassificationEntity> list     = classBLL.GetList(user.OrganizeId).ToList();

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

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

            count = 0;
            if (!string.IsNullOrEmpty(val))
            {
                string[] arr = val.Split('|');
                int      j   = 0;
                foreach (string str in arr)
                {
                    string[] arrVal = str.Split(',');
                    if (totalScore > decimal.Parse(arrVal[0]) && totalScore <= decimal.Parse(arrVal[1]))
                    {
                        count = j;
                        break;
                    }
                    j++;
                }
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(new { score = Math.Round(totalScore, 1), index = count }));
        }
Beispiel #16
0
        public object GetToolDetail([FromBody] JObject json)
        {
            try
            {
                string  res = json.Value <string>("json");
                dynamic dy  = JsonConvert.DeserializeObject <ExpandoObject>(res);

                int pageSize = res.Contains("pagesize") ? int.Parse(dy.data.pagesize.ToString()) : 10;   //每页条数

                int pageIndex = res.Contains("pageindex") ? int.Parse(dy.data.pageindex.ToString()) : 1; //请求页码

                string userId   = dy.userid;
                string keyValue = res.Contains("id") ? dy.data.id : "";
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!" });
                }
                ToolequipmentEntity toolequipment = toolequipmentBll.GetEntity(keyValue);
                object data    = new object();
                int    records = -1;
                if (toolequipment != null)
                {
                    object obj = new
                    {
                        id                    = toolequipment.Id,
                        createuserid          = toolequipment.CreateUserId,
                        createuserdeptcode    = toolequipment.CreateUserDeptCode,
                        createuserorgcode     = toolequipment.CreateUserOrgCode,
                        createdate            = toolequipment.CreateDate,
                        createusername        = toolequipment.CreateUserName,
                        modifydate            = toolequipment.ModifyDate,
                        modifyuserid          = toolequipment.ModifyUserId,
                        modifyusername        = toolequipment.ModifyUserName,
                        equipmentvalue        = toolequipment.EquipmentValue,
                        equipmentname         = toolequipment.EquipmentName,
                        equipmenttype         = toolequipment.EquipmentType,
                        equipmentno           = toolequipment.EquipmentNo,
                        securitymanageruser   = toolequipment.SecurityManagerUser,
                        securitymanageruserid = toolequipment.SecurityManagerUserId,
                        telephone             = toolequipment.Telephone,
                        specifications        = toolequipment.Specifications,
                        district              = toolequipment.District,
                        districtid            = toolequipment.DistrictId,
                        districtcode          = toolequipment.DistrictCode,
                        depositary            = toolequipment.Depositary,
                        checkdate             = toolequipment.CheckDate,
                        nextcheckdate         = toolequipment.NextCheckDate,
                        validitydate          = toolequipment.ValidityDate,
                        operuser              = toolequipment.OperUser,
                        operuserid            = toolequipment.OperUserId,
                        ischeck               = toolequipment.IsCheck,
                        outputdeptname        = toolequipment.OutputDeptName,
                        factoryno             = toolequipment.FactoryNo,
                        factorydate           = toolequipment.FactoryDate,
                        state                 = toolequipment.State,
                        controluserid         = toolequipment.ControlUserId,
                        controlusername       = toolequipment.ControlUserName,
                        controldept           = toolequipment.ControlDept,
                        controldeptid         = toolequipment.ControlDeptId,
                        controldeptcode       = toolequipment.ControlDeptCode,
                        checkdatecycle        = toolequipment.CheckDateCycle,
                        acceptance            = toolequipment.Acceptance,
                        tooltype              = toolequipment.ToolType,
                        appraise              = toolequipment.Appraise,
                        descriptionfileid     = toolequipment.DescriptionFileId,
                        contractfileid        = toolequipment.ContractFileId,
                        belongdept            = toolequipment.BelongDept,
                        belongdeptid          = toolequipment.BelongDeptId,
                        belongdeptcode        = toolequipment.BelongDeptCode
                    };
                    List <FileInfoEntity> descriptionfile = fileInfoBLL.GetFileList(toolequipment.DescriptionFileId);
                    List <FileInfoEntity> contractfile    = fileInfoBLL.GetFileList(toolequipment.ContractFileId);
                    string        strurl  = new DataItemDetailBLL().GetItemValue("imgUrl");
                    List <object> objects = new List <object>();

                    foreach (FileInfoEntity itemEntity in descriptionfile)
                    {
                        objects.Add(new
                        {
                            fileid   = itemEntity.FileId,
                            filepath = strurl + itemEntity.FilePath.Replace("~", ""),
                            filename = itemEntity.FileName,
                            recid    = itemEntity.RecId
                        });
                    }

                    foreach (FileInfoEntity itemEntity in contractfile)
                    {
                        objects.Add(new
                        {
                            fileid   = itemEntity.FileId,
                            filepath = strurl + itemEntity.FilePath.Replace("~", ""),
                            filename = itemEntity.FileName,
                            recid    = itemEntity.RecId
                        });
                    }


                    DataTable     recordlist  = GetToolRecordList(toolequipment.Id, pageIndex, pageSize, out records);
                    List <object> recordfiles = new List <object>();
                    if (recordlist.Rows.Count > 0)
                    {
                        foreach (DataRow recordEntity in recordlist.Rows)
                        {
                            List <FileInfoEntity> fileinfos = fileInfoBLL.GetFileList(recordEntity["Id"].ToString());
                            if (fileinfos.Count > 0)
                            {
                                foreach (var fileInfoEntity in fileinfos)
                                {
                                    recordfiles.Add(new
                                    {
                                        fileid   = fileInfoEntity.FileId,
                                        filepath = strurl + fileInfoEntity.FilePath.Replace("~", ""),
                                        filename = fileInfoEntity.FileName,
                                        recid    = fileInfoEntity.RecId
                                    });
                                }
                            }
                        }
                    }

                    //检查记录信息与附件信息
                    object toolrecord = new
                    {
                        recordlist = recordlist,
                        recordfile = recordfiles
                    };
                    data = new
                    {
                        tooldetail = obj,
                        toolrecord = toolrecord,
                        toolfile   = objects,
                    };
                }


                //var recordentity = toolrecordbll.GetList("").Where(p => p.ToolEquipmentId == keyValue).ToList();
                //List<object> toolrecord = new List<object>();
                //foreach (var entity in recordentity)
                //{
                //    toolrecord.Add(new
                //    {
                //        id = entity.Id,
                //        createuserid = entity.CreateUserId,
                //        createuserdeptcode = entity.CreateUserDeptCode,
                //        createuserorgcode = entity.CreateUserOrgCode,
                //        createdate = entity.CreateDate,
                //        createusername = entity.CreateUserName,
                //        modifydate = entity.ModifyDate,
                //        modifyuserid = entity.ModifyUserId,
                //        modifyusername = entity.ModifyUserName,
                //        nextcheckdate = entity.NextCheckDate,
                //        equipmentname = entity.EquipmentName,
                //        equipmentno = entity.EquipmentNo,
                //        operuserid = entity.OperUserId,
                //        voltagelevel = entity.VoltageLevel,
                //        operuser = entity.OperUser,
                //        appraise = entity.Appraise,
                //        trialvoltage = entity.TrialVoltage,
                //        checkdate = entity.CheckDate,
                //        toolequipmentid = entity.ToolEquipmentId,
                //        specification = entity.Specification,
                //        checkproject = entity.CheckProject
                //    });
                //}


                return(new { Code = 0, Count = records, Info = "获取数据成功", data = data });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
Beispiel #17
0
        /// <summary>
        /// 上传附件
        /// </summary>
        /// <param name="folderId"></param>
        /// <param name="foldername"></param>
        /// <param name="fileList"></param>
        public void UploadifyFile(string descriptionfileid, string contractfileid, string recordid, HttpFileCollection fileList)
        {
            try
            {
                string folderId = "";
                if (fileList.Count > 0)
                {
                    foreach (string key in fileList.AllKeys)
                    {
                        if (key.ToLower().Contains("description"))
                        {
                            folderId = descriptionfileid;
                        }
                        else if (key.ToLower().Contains("contract"))
                        {
                            folderId = contractfileid;
                        }
                        else if (key.ToLower().Contains("record"))
                        {
                            folderId = recordid;
                        }

                        HttpPostedFile file = fileList[key];
                        //获取文件完整文件名(包含绝对路径)
                        //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名}
                        string fileGuid       = Guid.NewGuid().ToString();
                        long   filesize       = file.ContentLength;
                        string FileEextension = Path.GetExtension(file.FileName);
                        string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
                        string dir            = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\ht\\images\\" + uploadDate;
                        string newFileName    = fileGuid + FileEextension;
                        string newFilePath    = dir + "\\" + newFileName;
                        //创建文件夹
                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }
                        FileInfoEntity fileInfoEntity = new FileInfoEntity();
                        if (!System.IO.File.Exists(newFilePath))
                        {
                            //保存文件
                            file.SaveAs(newFilePath);
                            //文件信息写入数据库
                            fileInfoEntity.Create();
                            fileInfoEntity.FileId         = fileGuid;
                            fileInfoEntity.FolderId       = "ht/images";
                            fileInfoEntity.RecId          = folderId; //关联ID
                            fileInfoEntity.FileName       = file.FileName;
                            fileInfoEntity.FilePath       = "~/Resource/ht/images/" + uploadDate + '/' + newFileName;
                            fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                            fileInfoEntity.FileExtensions = FileEextension;
                            fileInfoEntity.FileType       = FileEextension.Replace(".", "");
                            fileInfoBLL.SaveForm("", fileInfoEntity);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
        /// 获取电子围栏内所有摄像头信息
        /// </summary>
        public string GetElectricFenceCameraList(SafeworkcontrolEntity data)
        {
            string ComerId = string.Empty;

            try
            {
                //三维监控点位服务接口地址
                DataItemDetailBLL pdata   = new DataItemDetailBLL();
                var             ThreeDApi = pdata.GetItemValue("kbsThreeMonitoringPoints");
                space           sp        = new space();
                spacedata       sds       = new spacedata();
                List <spacegeo> geolist   = new List <spacegeo>();
                List <spacepnt> pntlist   = new List <spacepnt>();
                var             comList   = new KbscameramanageBLL().GetPageList("").Where(a => a.State == "在线" && a.CameraType == "枪机" && a.MonitoringArea != null).ToList();
                spacegeo        geo       = new spacegeo();
                geo.id = data.ID;
                if (data.Areacode != null)
                {//电子围栏坐标点
                    PositionsEntity alist = JsonConvert.DeserializeObject <PositionsEntity>(data.Areacode);
                    List <double>   dlist = new List <double>();
                    if (data.Areastate == 0)
                    {//矩形
                        geo.type     = 1;
                        geo.distance = 0;
                        //第一个点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        //第二个点
                        dlist.Add(alist.positions[1].x);
                        dlist.Add(alist.positions[0].z);
                        //第三个点
                        dlist.Add(alist.positions[1].x);
                        dlist.Add(alist.positions[1].z);
                        //第四个点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[1].z);
                        //回到原点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        geo.coor = dlist;
                        geolist.Add(geo);
                    }
                    else if (data.Areastate == 1)
                    {//圆形
                        geo.type = 0;
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        geo.distance = Convert.ToInt32(data.Radius);
                        geo.coor     = dlist;
                        geolist.Add(geo);
                    }
                    else if (data.Areastate == 2)
                    {//手绘多边形
                        foreach (var ac in alist.positions)
                        {
                            dlist.Add(ac.x);
                            dlist.Add(ac.z);
                        }
                        //闭合回到原点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        geo.coor     = dlist;
                        geo.type     = 1;
                        geo.distance = 0;
                        geolist.Add(geo);
                    }

                    foreach (var com in comList)
                    {//摄像头坐标点集
                        PositionsEntity alist1 = JsonConvert.DeserializeObject <PositionsEntity>(com.MonitoringArea);
                        if (alist1.floorID == alist.floorID)
                        {
                            List <double> dlist1 = new List <double>();
                            foreach (var ac in alist1.positions)
                            {
                                dlist1.Add(ac.x);
                                dlist1.Add(ac.z);
                            }
                            //闭合回到原点
                            dlist1.Add(alist1.positions[0].x);
                            dlist1.Add(alist1.positions[0].z);
                            spacepnt pnt = new spacepnt()
                            {
                                id   = com.CameraId,
                                x    = 0,
                                y    = 0,
                                coor = dlist1
                            };
                            pntlist.Add(pnt);
                        }
                    }
                }
                sds.geo = geolist;
                sds.pnt = pntlist;
                sp.type = "2";
                sp.data = sds;
                string          rtn = HttpUtillibKbs.HttpThreeDPost(ThreeDApi, JsonConvert.SerializeObject(sp));
                List <RtnSpace> rss = JsonConvert.DeserializeObject <List <RtnSpace> >(rtn);
                foreach (var item in rss)
                {
                    if (string.IsNullOrEmpty(item.pntId))
                    {
                        continue;
                    }
                    ComerId += item.pntId + ',';
                }
                return(ComerId);
            }
            catch (Exception er)
            {
                return(ComerId);
            }
        }
Beispiel #19
0
        /// <summary>
        /// 风险清单导出(重大风险)
        /// </summary>
        /// <param name="queryJson"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public ActionResult ExportExcel(string queryJson, string fileName)
        {
            Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
            //string path = "~/Resource/Temp";
            string fName  = "安全风险清单" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            var    IsGdxy = new DataItemDetailBLL().GetDataItemListByItemCode("'VManager'").ToList();

            if (IsGdxy.Count > 0)
            {
                wb.Open(Server.MapPath("~/Resource/ExcelTemplate/风险措施库导出模板.xls"));
            }
            else
            {
                wb.Open(Server.MapPath("~/Resource/ExcelTemplate/风险措施库通用导出模板.xls"));
            }

            var      queryParam = queryJson.ToJObject();
            var      riskType   = queryParam["riskType"].ToString();
            var      IndexState = queryParam["IndexState"].ToString();
            Operator user       = ERCHTMS.Code.OperatorProvider.Provider.Current();
            string   authType   = new AuthorizeBLL().GetOperAuthorzeType(user, HttpContext.Request.Cookies["currentmoduleId"].Value, "search");

            if (string.IsNullOrWhiteSpace(riskType))
            {
                DataSet       ds       = new DataSet();
                List <string> typeList = new List <string>()
                {
                    "作业", "设备", "区域", "管理", "岗位", "工器具及危化品"
                };
                for (int i = 0; i < typeList.Count; i++)
                {
                    DataTable exportTable = new DataTable();
                    exportTable           = riskbll.GetPageExportList(queryJson, typeList[i], authType, IndexState);
                    exportTable.TableName = i.ToString();
                    ds.Tables.Add(exportTable);
                    for (int j = 0; j < wb.Worksheets.Count; j++)
                    {
                        if (wb.Worksheets[j].Name == typeList[i])
                        {
                            wb.Worksheets[j].Cells.ImportDataTable(exportTable, false, 2, 0);
                        }
                    }
                }
                //AsposeExcelHelper.ExecuteResultX(ds, path, typeList, fName);
            }
            else
            {
                DataTable exportTable = riskbll.GetPageExportList(queryJson, riskType, authType, IndexState);
                for (int j = 0; j < wb.Worksheets.Count; j++)
                {
                    if (wb.Worksheets[j].Name == riskType)
                    {
                        wb.Worksheets[j].Cells.ImportDataTable(exportTable, false, 2, 0);
                    }
                }
            }
            HttpResponse resp = System.Web.HttpContext.Current.Response;

            System.Threading.Thread.Sleep(400);
            wb.Save(Server.MapPath("~/Resource/Temp/" + fName));
            //wb.Save(Server.UrlEncode(fName), Aspose.Cells.FileFormatType.Excel2003, Aspose.Cells.SaveType.OpenInBrowser, resp);
            return(Success("导出成功。", fName));
        }
Beispiel #20
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);
        }
        private void ExportDataByCode(string keyValue, string tempPath, string fileName)
        {
            var userInfo = OperatorProvider.Provider.Current();  //获取当前用户
            string strDocPath = Server.MapPath(tempPath);
            Aspose.Words.Document doc = new Aspose.Words.Document(strDocPath);
            DataSet ds = new DataSet();
            DataTable dtPro = new DataTable("project");
            dtPro.Columns.Add("untilname");//单位名称
            dtPro.Columns.Add("legalperson");//法人代表
            dtPro.Columns.Add("projectname");//工程名称
            dtPro.Columns.Add("nowtime");
            dtPro.Columns.Add("itemopinion");
            dtPro.Columns.Add("itemhead");  //项目负责人
            dtPro.Columns.Add("techhead"); //生成技术负责人
            dtPro.Columns.Add("safehead"); //安全监督负责人

            dtPro.Columns.Add("contractperiod");//合同期限
            dtPro.Columns.Add("dutydept");//项目管理部门
            dtPro.Columns.Add("applyperson");//制表人
            dtPro.Columns.Add("applytime");//制表时间
            dtPro.Columns.Add("outhead"); 
            
            DataTable dt = new DataTable("people");
            dt.Columns.Add("no");
            dt.Columns.Add("name");
            dt.Columns.Add("sex");
            dt.Columns.Add("idcard");
            dt.Columns.Add("worktype");
            dt.Columns.Add("health");
            dt.Columns.Add("workyear");
            dt.Columns.Add("education");
            dt.Columns.Add("birthday");
            dt.Columns.Add("cardno");

            HttpResponse resp = System.Web.HttpContext.Current.Response;

            PeopleReviewEntity p = peoplereviewbll.GetEntity(keyValue);

            OutsouringengineerEntity eng = Outsouringengineernll.GetEntity(p.OUTENGINEERID);
            OutsourcingprojectEntity pro = Outsourcingprojectbll.GetOutProjectInfo(eng.OUTPROJECTID);

            DataRow row = dtPro.NewRow();
            var comList = new CompactBLL().GetComoactTimeByProjectId(eng.ID);
            if (comList.Rows.Count > 0)
            {
                var startTime = string.Empty;
                DateTime r = new DateTime();
                if (DateTime.TryParse(comList.Rows[0]["mintime"].ToString(), out r))
                {
                    startTime = r.ToString("yyyy年MM月dd日");
                }
                var endTime = string.Empty;
                DateTime e= new DateTime();
                if (DateTime.TryParse(comList.Rows[0]["maxtime"].ToString(), out e))
                {
                    endTime = e.ToString("yyyy年MM月dd日");
                }
                row["contractperiod"] = startTime + "至" + endTime;
            }
            row["untilname"] = pro.OUTSOURCINGNAME;
            row["legalperson"] = pro.LEGALREP;

            row["projectname"] = eng.ENGINEERNAME;
            row["nowtime"] = DateTime.Now.ToString("yyyy-MM-dd");
            row["dutydept"] = eng.ENGINEERLETDEPT;
            row["applyperson"] = p.CREATEUSERNAME;
            row["applytime"] = p.CREATEDATE.Value.ToString("yyyy年MM月dd日");
            var sendDeptid = eng.ENGINEERLETDEPTID;
            List<AptitudeinvestigateauditEntity> list = auditbll.GetAuditList(keyValue).OrderByDescending(x => x.AUDITTIME).ToList();
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (sendDeptid == list[i].AUDITDEPTID)
                    {
                        var person = new UserBLL().GetEntity(list[i].AUDITPEOPLEID);
                        if (person != null)
                        {
                            //if (person.RoleName.Contains("负责人"))
                            //{
                                row["itemopinion"] = list[i].AUDITOPINION;
                                row["itemhead"] = list[i].AUDITPEOPLE;
                            //}
                        }
                    }
                    if (eng.OUTPROJECTID == list[i].AUDITDEPTID)
                    {
                        var person = new UserBLL().GetEntity(list[i].AUDITPEOPLEID);
                        if (person != null)
                        {
                            if (person.RoleName.Contains("负责人"))
                            {
                                row["outhead"] = list[i].AUDITPEOPLE;
                            }
                        }
                    }
                    string val = new DataItemDetailBLL().GetItemValue(userInfo.OrganizeCode);

                    if (!string.IsNullOrEmpty(val))
                    {
                        var deptList = val.Split(',');
                        if (deptList.Length > 1)
                        {
                            if (list[i].AUDITDEPTID.ToString() == deptList[0])
                            {
                                row["techhead"] = list[i].AUDITPEOPLE;
                            }
                            if (list[i].AUDITDEPTID == deptList[1])
                            {
                                row["safehead"] = list[i].AUDITPEOPLE;
                            }
                        }
                    }
                }
            }
            dtPro.Rows.Add(row);
            List<AptitudeinvestigatepeopleEntity> PeopleList = new AptitudeinvestigatepeopleBLL().GetList("").Where(x => x.PEOPLEREVIEWID == keyValue).ToList();
            if (PeopleList.Count > 0)
            {
                for (int i = 0; i < PeopleList.Count; i++)
                {
                    DataRow dtrow = dt.NewRow();
                    dtrow["no"] = (i + 1);
                    dtrow["name"] = PeopleList[i].REALNAME;
                    dtrow["sex"] = PeopleList[i].GENDER;
                    dtrow["idcard"] = PeopleList[i].IDENTIFYID;
                    dtrow["worktype"] = PeopleList[i].WORKOFTYPE;
                    dtrow["health"] = PeopleList[i].STATEOFHEALTH;
                    dtrow["workyear"] = PeopleList[i].WORKYEAR;
                    dtrow["education"] = PeopleList[i].DEGREESID;
                    dtrow["birthday"] = PeopleList[i].BIRTHDAY == null ? "" : PeopleList[i].BIRTHDAY.Value.ToString("yyyy-MM-dd");
                    string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                    {
                        UserId = PeopleList[i].ID
                    });
                    var cardlist = new CertificateinspectorsBLL().GetList(queryJson).ToList();
                    for (int j = 0; j < cardlist.Count; j++)
                    {
                        dtrow["cardno"] += cardlist[j].CREDENTIALSCODE + ",";
                    }
                    if (dtrow["cardno"].ToString().Length > 0) {
                        dtrow["cardno"] = dtrow["cardno"].ToString().Substring(0, dtrow["cardno"].ToString().Length - 1);
                    }
                    dt.Rows.Add(dtrow);
                }
            }
            ds.Tables.Add(dt);
            ds.Tables.Add(dtPro);
            doc.MailMerge.Execute(dtPro);
            doc.MailMerge.ExecuteWithRegions(dt);
            doc.MailMerge.DeleteFields();
            doc.Save(resp, Server.UrlEncode(fileName), ContentDisposition.Attachment, Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Doc));
        }
Beispiel #22
0
        public string GetIndexWarnValue(string startDate = "", string endDate = "", string orgCode = "", string orgId = "")
        {
            Operator user = OperatorProvider.Provider.Current();
            decimal  totalScore = 0; int count = 0;

            try
            {
                string key   = "WarnScore_" + user.OrganizeCode;
                string score = CacheFactory.Cache().GetCache <string>(key);

                if (string.IsNullOrEmpty(score))
                {
                    if (string.IsNullOrEmpty(startDate) && string.IsNullOrEmpty(endDate))
                    {
                        startDate = DateTime.Now.Year.ToString() + "-01" + "-01";
                        endDate   = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
                    }

                    SafetyAssessedArguments entity = new SafetyAssessedArguments();
                    entity.startDate = startDate;
                    entity.endDate   = endDate;
                    if (user.RoleName.Contains("省级用户") || user.RoleName.Contains("集团用户"))
                    {
                        if (!string.IsNullOrEmpty(orgCode))
                        {
                            entity.orgId   = orgId;
                            entity.orgCode = orgCode;
                            totalScore     = desktopbll.GetSafetyAssessedValue(entity);
                        }
                        else
                        {
                            OrganizeBLL orgBll = new OrganizeBLL();
                            DataTable   dt     = orgBll.GetDTList();
                            foreach (DataRow dr in dt.Rows)
                            {
                                entity.orgId   = dr[2].ToString();
                                entity.orgCode = dr[0].ToString();
                                totalScore    += desktopbll.GetSafetyAssessedValue(entity);
                            }
                            totalScore = totalScore / dt.Rows.Count;
                        }
                    }
                    else
                    {
                        entity.orgId   = user.OrganizeId;
                        entity.orgCode = user.OrganizeCode;
                        totalScore     = desktopbll.GetSafetyAssessedValue(entity);
                    }
                    CacheFactory.Cache().WriteCache <string>(totalScore.ToString(), key, DateTime.Now.AddDays(1));
                }
                else
                {
                    totalScore = decimal.Parse(score);
                }

                string[] scorearr = new string[4];

                DataItemDetailBLL itemBLL = new DataItemDetailBLL();
                string            val     = itemBLL.GetItemValue("基础预警区间分值设置");
                count = 0;
                if (!string.IsNullOrEmpty(val))
                {
                    string[] arr = val.Split('|');
                    for (int i = 0; i < arr.Length; i++)
                    {
                        string[] arrVal = arr[i].Split(',');
                        scorearr[i] = arrVal[1];  //取后一个数字
                    }
                    int j = 0;
                    foreach (string str in arr)
                    {
                        string[] arrVal = str.Split(',');

                        if (totalScore > decimal.Parse(arrVal[0]) && totalScore <= decimal.Parse(arrVal[1]))
                        {
                            count = j;
                            break;
                        }
                        j++;
                    }
                }

                return(Newtonsoft.Json.JsonConvert.SerializeObject(new { score = Math.Round(totalScore, 1), index = count, scorearry = scorearr }));
            }
            catch (Exception ex)
            {
                return(Newtonsoft.Json.JsonConvert.SerializeObject(ex));
            }
        }
        public object SafeRewardApply()
        {
            try
            {
                string res   = ctx.Request["json"];
                var    dyObj = JsonConvert.DeserializeAnonymousType(res, new
                {
                    userid = string.Empty,
                    data   = new RewardModel()
                });
                string userId = dyObj.userid;        //当前用户ID
                OperatorProvider.AppUserId = userId; //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!" });
                }
                string keyValue = !string.IsNullOrEmpty(dyObj.data.keyvalue) ? dyObj.data.keyvalue : Guid.NewGuid().ToString();
                if (dyObj.data.rewentity != null && (string.IsNullOrEmpty(dyObj.data.rewentity.ApplyState) || dyObj.data.rewentity.ApplyState == "0"))
                {
                    var year       = DateTime.Now.ToString("yyyy");
                    var month      = DateTime.Now.ToString("MM");
                    var day        = DateTime.Now.ToString("dd");
                    var rewardCode = "Q/CRPHZHB 2208.06.01-JL01-" + year + month + day + safereward.GetRewardCode();
                    dyObj.data.rewentity.SafeRewardCode = !string.IsNullOrEmpty(dyObj.data.rewentity.SafeRewardCode) ? dyObj.data.rewentity.SafeRewardCode : rewardCode;


                    //删除图片
                    string delFileIds = !string.IsNullOrEmpty(dyObj.data.delfileids) ? dyObj.data.delfileids : "";
                    if (!string.IsNullOrEmpty(delFileIds))
                    {
                        DeleteFile(delFileIds);
                    }
                    HttpFileCollection files = ctx.Request.Files;//上传的文件
                    //上传设备图片
                    UploadifyFile(keyValue, files);
                    int?rewardmoney = 0;
                    if (saferewarddetailbll.Remove(keyValue) > 0)
                    {
                        foreach (SaferewarddetailEntity data in dyObj.data.rewarddetailentity)
                        {
                            rewardmoney  += data.RewardNum;
                            data.RewardId = keyValue;
                            saferewarddetailbll.SaveForm("", data);
                        }
                    }
                    dyObj.data.rewentity.RewardMoney = rewardmoney;
                    safereward.SaveForm(keyValue, dyObj.data.rewentity);
                }

                if (!string.IsNullOrEmpty(keyValue) && dyObj.data.entity != null)
                {
                    if (!string.IsNullOrEmpty(dyObj.data.entity.AUDITSIGNIMG))
                    {
                        string strurl = new DataItemDetailBLL().GetItemValue("imgUrl");
                        dyObj.data.entity.AUDITSIGNIMG = dyObj.data.entity.AUDITSIGNIMG.Replace(strurl, "../../");
                    }
                    safereward.CommitApply(keyValue, dyObj.data.entity, dyObj.data.leadershipid);
                }
            }
            catch (Exception)
            {
                return(new { code = -1, count = 0, info = "保存失败" });
            }

            return(new { code = 0, count = 0, info = "保存成功" });
        }
Beispiel #24
0
        public object SaveOrCommitData()
        {
            try
            {
                string  res       = HttpContext.Current.Request["json"];
                dynamic dy        = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId    = dy.userid;
                string  deleteids = dy.data.deleteids; //删除附件id集合
                OperatorProvider.AppUserId = userId;   //设置当前用户
                var user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                //消息实体
                string messageentity = JsonConvert.SerializeObject(dy.data.messageentity);
                var    entity        = JsonConvert.DeserializeObject <MessageEntity>(messageentity);

                //保存成功之后推送消息
                if (messagebll.SaveForm(entity.Id, entity))
                {
                    JPushApi.PublicMessage(entity);
                }
                string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
                //处理附件
                if (!string.IsNullOrEmpty(deleteids))
                {
                    DeleteFile(deleteids);
                }
                HttpFileCollection files = HttpContext.Current.Request.Files;
                if (files.Count > 0)
                {
                    for (int i = 0; i < files.AllKeys.Length; i++)
                    {
                        HttpPostedFile file = files[i];
                        //原始文件名
                        string fileName       = System.IO.Path.GetFileName(file.FileName);
                        long   filesize       = file.ContentLength;
                        string FileEextension = Path.GetExtension(fileName);
                        string fileGuid       = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Guid.NewGuid().ToString();
                        string dir            = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\Upfile";
                        string newFileName    = fileGuid + FileEextension;
                        string newFilePath    = dir + "\\" + newFileName;
                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        FileInfoEntity fileInfoEntity = new FileInfoEntity();
                        if (!System.IO.File.Exists(newFilePath))
                        {
                            //保存文件
                            file.SaveAs(newFilePath);
                            //文件信息写入数据库
                            fileInfoEntity.Create();
                            fileInfoEntity.FileId         = fileGuid;
                            fileInfoEntity.RecId          = entity.Id;
                            fileInfoEntity.FileName       = fileName;
                            fileInfoEntity.FilePath       = "~/Resource/Upfile/" + newFileName;
                            fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                            fileInfoEntity.FileExtensions = FileEextension;
                            fileInfoEntity.FileType       = FileEextension.TrimStart('.');
                            FileInfoBLL fileInfoBLL = new FileInfoBLL();
                            fileInfoBLL.SaveForm("", fileInfoEntity);
                        }
                    }
                }
                return(new { code = 0, count = 0, info = "操作成功" });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
        public object GetInfo([FromBody] JObject json)
        {
            try
            {
                string  res     = json.Value <string>("json");
                dynamic dy      = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId  = dy.userid;
                string  applyid = dy.applyid;

                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator user   = OperatorProvider.Provider.Current();
                var      change = safetychangebll.GetEntity(applyid);
                List <ScaffoldauditrecordEntity> scalist     = scaffoldauditrecordbll.GetApplyAuditList(applyid, 0);
                List <ScaffoldauditrecordEntity> scaAccplist = scaffoldauditrecordbll.GetApplyAuditList(applyid, 1);
                var files = new FileInfoBLL().GetFiles(applyid);//获取相关附件

                string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
                foreach (DataRow dr in files.Rows)
                {
                    dr["filepath"] = dr["filepath"].ToString().Replace("~/", webUrl + "/");
                }
                foreach (var item in scalist)
                {
                    item.AuditSignImg = string.IsNullOrWhiteSpace(item.AuditSignImg) ? "" : webUrl + item.AuditSignImg.ToString().Replace("../../", "/");
                }
                foreach (var item in scaAccplist)
                {
                    item.AuditSignImg = string.IsNullOrWhiteSpace(item.AuditSignImg) ? "" : webUrl + item.AuditSignImg.ToString().Replace("../../", "/");
                }
                var riskrecord = highriskrecordbll.GetList(applyid).ToList();

                List <string> modulename = new List <string>();
                //0:电厂内部 1外包单位
                if (change.WORKUNITTYPE == "0")
                {
                    modulename.Add("(内部)设施变动申请审核");
                    modulename.Add("(内部)设施变动验收审核");
                }
                else
                {
                    modulename.Add("(外包)设施变动申请审核");
                    modulename.Add("(外包)设施变动验收审核");
                }

                bool isendflow = false;
                if ((change.ISCOMMIT == 1 && change.ISAPPLYOVER == 2) || (change.ISCOMMIT == 1 && change.ISAPPLYOVER == 1 && change.ISACCPCOMMIT == 1 && change.ISACCEPOVER == 2) ||
                    (change.ISCOMMIT == 1 && change.ISAPPLYOVER == 1 && change.ISACCPCOMMIT == 1 && change.ISACCEPOVER == 1))
                {
                    isendflow = true;
                }
                var nodelist = safetychangebll.GetAppFlowList(change.ID, modulename, change.NodeId, isendflow, change.WORKUNITID);

                var data = new
                {
                    applyentity    = change,
                    applyauditlist = scalist,
                    accpauditlist  = scaAccplist,
                    Files          = files,
                    riskrecord     = riskrecord,
                    checkflow      = nodelist
                };
                Dictionary <string, string> dict_props = new Dictionary <string, string>();
                //Id 转换前的列名  keyvalue 转换后的列名
                //dict_props.Add("Id", "keyvalue");

                JsonSerializerSettings settings = new JsonSerializerSettings
                {
                    ContractResolver = new LowercaseContractResolver(dict_props), //转小写,并对指定的列进行自定义名进行更换
                    DateFormatString = "yyyy-MM-dd HH:mm",                        //格式化日期
                    //NullValueHandling = NullValueHandling.Ignore 值为空则在JSON中体现
                };
                return(new { code = 0, info = "获取数据成功", count = 1, data = JObject.Parse(JsonConvert.SerializeObject(data, Formatting.None, settings)) });
                //return new { code = 0, count = 1, info = "获取数据成功", data = data };
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
Beispiel #26
0
        public JsonResult DoImport()
        {
            var success = true;
            var message = string.Empty;

            try
            {
                if (this.Request.Files.Count == 0)
                {
                    throw new Exception("请上传文件");
                }
                if (!this.Request.Files[0].FileName.EndsWith(".xlsx"))
                {
                    throw new Exception("请上传 Excel 文件");
                }

                var book  = new Workbook(this.Request.Files[0].InputStream);
                var sheet = book.Worksheets[0];
                var user  = OperatorProvider.Provider.Current();

                var     templates = new List <JobTemplateEntity>();
                var     date      = DateTime.Now;
                UserBLL userBLL   = new UserBLL();
                var     users     = userBLL.GetDeptUsers(user.DeptId).ToList();
                for (int i = 2; i <= sheet.Cells.MaxDataRow; i++)
                {
                    var entity = new JobTemplateEntity();
                    entity.JobId      = Guid.NewGuid().ToString();
                    entity.JobContent = sheet.Cells[i, 0].StringValue;
                    if (string.IsNullOrEmpty(entity.JobContent))
                    {
                        if (templates.Count > 0 && string.IsNullOrEmpty(sheet.Cells[i, 1].StringValue))
                        {
                            break;
                        }
                        success  = false;
                        message += "第" + (i + 1) + "行,未填写工作任务</br>";
                        continue;
                        //return Json(new { success, message });
                    }
                    var sss = sheet.Cells[i, 1].StringValue;
                    if (!string.IsNullOrEmpty(sheet.Cells[i, 1].StringValue))
                    {
                        var itemdetialbll = new DataItemDetailBLL();
                        var itembll       = new DataItemBLL();
                        var type          = itembll.GetEntityByName("任务库任务类型");
                        var content       = itemdetialbll.GetList(type.ItemId).ToList();
                        var typename      = sheet.Cells[i, 1].StringValue.Trim();
                        var gettype       = content.FirstOrDefault(row => row.ItemName == typename);
                        if (gettype == null)
                        {
                            success  = false;
                            message += "第" + (i + 1) + "行,不存在该类型</br>";
                            continue;
                            //return Json(new { success, message });
                        }
                        entity.jobplantype   = gettype.ItemName;
                        entity.jobplantypeid = gettype.ItemId;
                    }
                    else
                    {
                        success  = false;
                        message += "第" + (i + 1) + "行,任务类型不能为空</br>";
                        continue;
                        //return Json(new { success, message });
                    }
                    entity.RiskLevel = sheet.Cells[i, 2].StringValue;
                    if (string.IsNullOrEmpty(entity.RiskLevel))
                    {
                        success  = false;
                        message += "第" + (i + 1) + "行,未填写风险等级</br>";
                        continue;
                        // return Json(new { success, message });
                    }

                    var jobperson = sheet.Cells[i, 3].StringValue;
                    if (jobperson.Contains(","))
                    {
                        var person     = string.Empty;
                        var personid   = string.Empty;
                        var personList = jobperson.Split(',');
                        for (int j = 0; j < personList.Length; j++)
                        {
                            var ckjobperson = users.FirstOrDefault(row => row.RealName == personList[j]);
                            if (ckjobperson == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行," + personList[j] + "作业人错误</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                            if (j >= personList.Length - 1)
                            {
                                person   += personList[j];
                                personid += ckjobperson.DepartmentId;
                            }
                            else
                            {
                                person   += personList[j] + ",";
                                personid += ckjobperson.DepartmentId + ",";
                            }
                        }

                        entity.JobPerson   = person;
                        entity.JobPersonId = personid;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(jobperson))
                        {
                            var ckjobperson = users.FirstOrDefault(row => row.RealName == jobperson);
                            if (ckjobperson == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行," + jobperson + "作业人错误</br>";
                                continue;
                                // return Json(new { success, message });
                            }
                            entity.JobPerson   = jobperson;
                            entity.JobPersonId = ckjobperson == null ? null : ckjobperson.UserId;
                        }
                    }
                    //string otherperson = sheet.Cells[i, 3].StringValue;
                    //if (!string.IsNullOrEmpty(otherperson))
                    //{
                    //    var ckotherperson = users.FirstOrDefault(row => row.RealName == otherperson);
                    //    if (ckotherperson == null)
                    //    {
                    //        success = false;
                    //        message = "选填作业人错误";
                    //        return Json(new { success, message });
                    //    }
                    //}
                    //if (otherperson == jobperson)
                    //{
                    //    success = false;
                    //    message = "作业人不能相同";
                    //    return Json(new { success, message });
                    //}
                    //entity.otherperson = otherperson;
                    entity.Device = sheet.Cells[i, 4].StringValue;
                    var getNow = DateTime.Now.ToString("yyyy-MM-dd");
                    //entity.JobStartTime = sheet.Cells[i, 5].StringValue == "" ? Convert.ToDateTime(getNow + " 08:30") : Convert.ToDateTime(getNow + " " + sheet.Cells[i, 5].StringValue);
                    //entity.JobEndTime = sheet.Cells[i, 6].StringValue == "" ? Convert.ToDateTime(getNow + " 17:30") : Convert.ToDateTime(getNow + " " + sheet.Cells[i, 6].StringValue);
                    entity.JobStartTime = Convert.ToDateTime(getNow + " 08:30");
                    entity.JobEndTime   = Convert.ToDateTime(getNow + " 17:30");
                    if (!string.IsNullOrEmpty(sheet.Cells[i, 5].StringValue))
                    {
                        //每年,二月、九月,15日,白班  每月,第一个、第三个,星期五,白班
                        var Cycle = sheet.Cells[i, 5].StringValue.Trim();

                        var cycleType = Cycle.Split(',');
                        if (cycleType[0] != "每天" && cycleType[0] != "每周" && cycleType[0] != "每月" && cycleType[0] != "每年")
                        {
                            success  = false;
                            message += "第" + (i + 1) + "行,周期规则错误</br>";
                            continue;
                            // return Json(new { success, message });
                        }

                        entity.Cycle = cycleType[0];
                        var ck   = false;
                        var data = string.Empty;
                        for (int j = 1; j < cycleType.Length; j++)
                        {
                            //if (cycleType[j] == "白班" || cycleType[j] == "夜班")
                            //{
                            //    entity.worksetname = cycleType[j];

                            //}
                            //else
                            if (cycleType[j] == "截止")
                            {
                                entity.isend = true;
                            }
                            else
                            if (cycleType[j] == "最后一天")
                            {
                                if ((Cycle.Contains("每月") || Cycle.Contains("每年")) && Cycle.Contains("日"))
                                {
                                    entity.islastday = true;
                                }
                                else
                                {
                                    success  = false;
                                    message += "第" + (i + 1) + "行,周期规则错误</br>";
                                    continue;
                                    //return Json(new { success, message });
                                }
                            }
                            else
                            if (cycleType[j].Contains("双休"))
                            {
                                if ((Cycle.Contains("每月") || Cycle.Contains("每年")) && Cycle.Contains("日"))
                                {
                                    entity.isweek = true;
                                }
                                else if (Cycle.Contains("每天"))
                                {
                                    entity.isweek = true;
                                }
                                else
                                {
                                    success  = false;
                                    message += "第" + (i + 1) + "行,周期规则错误</br>";
                                    continue;
                                    //return Json(new { success, message });
                                }
                            }
                            else
                            {
                                data += cycleType[j].Replace('日', ' ').Trim().Replace('、', ',') + ";";
                                ck    = true;
                            }
                        }

                        if (ck)
                        {
                            data             = data.Substring(0, data.Length - 1);
                            entity.CycleDate = data;
                        }
                        else
                        {
                            entity.CycleDate = data;
                        }
                    }
                    else
                    {
                        if (entity.jobplantype != "临时任务")
                        {
                            success  = false;
                            message += "第" + (i + 1) + "行,周期不能为空</br>";
                            continue;
                            //return Json(new { success, message });
                        }
                    }
                    entity.Dangerous = sheet.Cells[i, 6].StringValue;
                    entity.Measure   = sheet.Cells[i, 7].StringValue;
                    var EnableTraining = sheet.Cells[i, 8].StringValue;
                    entity.EnableTraining = EnableTraining == "是";
                    //entity.EnableTraining = false;
                    entity.worksetname = sheet.Cells[i, 9].StringValue;
                    if (entity.jobplantype == "设备巡回检查")
                    {
                        entity.TaskType = "巡回检查";
                    }
                    else if (entity.jobplantype == "定期工作")
                    {
                        entity.TaskType = "定期工作";
                    }
                    else
                    {
                        entity.TaskType = "日常工作";
                    }
                    var          setupid      = string.Empty;
                    var          createuserid = string.Empty;
                    WorkOrderBLL orderbll     = new WorkOrderBLL();
                    orderbll.GetWorkSettingByDept(user.DeptId, out setupid, out createuserid);
                    WorkSettingBLL settingbll = new WorkSettingBLL();
                    var            setting    = settingbll.GetList("");
                    var            getbanci   = setting.Where(x => x.WorkSetupId == setupid && x.CreateUserId == createuserid);
                    if (entity.worksetname.Contains(","))
                    {
                        var setname   = string.Empty;
                        var setnameid = string.Empty;
                        var setList   = entity.worksetname.Split(',');
                        for (int j = 0; j < setList.Length; j++)
                        {
                            var ckset = getbanci.FirstOrDefault(x => x.Name == entity.worksetname);
                            if (ckset == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行,不存在该班次" + setList[j] + "</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                            if (j >= setList.Length - 1)
                            {
                                setname   += setList[j];
                                setnameid += ckset.WorkSettingId;
                            }
                            else
                            {
                                setname   += setList[j] + ",";
                                setnameid += ckset.WorkSettingId + ",";
                            }
                        }

                        entity.worksetname = setname;
                        entity.worksetid   = setnameid;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(entity.worksetname))
                        {
                            if (entity.jobplantype != "临时任务")
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行,班次不能为空</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                        }
                        else
                        {
                            var ckset = getbanci.FirstOrDefault(x => x.Name == entity.worksetname);
                            if (ckset == null)
                            {
                                success  = false;
                                message += "第" + (i + 1) + "行,不存在该班次" + entity.worksetname + "</br>";
                                continue;
                                //return Json(new { success, message });
                            }
                            entity.worksetname = ckset.Name;
                            entity.worksetid   = ckset.WorkSettingId;
                        }
                    }
                    entity.DeptId     = user.DeptId;
                    entity.CreateDate = date.AddMinutes(i);
                    entity.DangerType = "job";
                    templates.Add(entity);
                }
                if (!success)
                {
                    return(Json(new { success, message }));
                }
                foreach (var item in templates)
                {
                    if (item.DangerousList == null)
                    {
                        item.DangerousList = new List <JobDangerousEntity>();
                    }
                    if (!string.IsNullOrEmpty(item.Dangerous))
                    {
                        var dangerArray        = item.Dangerous.Split('。');
                        var dangerMeasureArray = item.Measure?.Split('。');
                        for (int i = 0; i < dangerArray.Length; i++)
                        {
                            var danger = dangerArray[i];
                            if (string.IsNullOrEmpty(danger))
                            {
                                continue;
                            }
                            var templateDangerousEntity = new JobDangerousEntity {
                                Content = danger
                            };
                            if (dangerMeasureArray != null && dangerMeasureArray.Length > i)
                            {
                                templateDangerousEntity.MeasureList = new List <JobMeasureEntity>();
                                var dangerMeasure = dangerMeasureArray[i];
                                if (!string.IsNullOrEmpty(dangerMeasure))
                                {
                                    var measureArray = dangerMeasure.Split(';');
                                    foreach (var measure in measureArray)
                                    {
                                        if (string.IsNullOrEmpty(measure))
                                        {
                                            continue;
                                        }
                                        templateDangerousEntity.MeasureList.Add(new JobMeasureEntity {
                                            Content = measure
                                        });
                                    }
                                }
                            }
                            item.DangerousList.Add(templateDangerousEntity);
                        }
                    }
                    foreach (var item1 in item.DangerousList)
                    {
                        if (string.IsNullOrEmpty(item1.JobDangerousId))
                        {
                            item1.JobDangerousId = Guid.NewGuid().ToString();
                        }
                        item1.CreateTime = DateTime.Now;
                        item1.JobId      = item.JobId;
                        if (item1.MeasureList == null)
                        {
                            item1.MeasureList = new List <JobMeasureEntity>();
                        }
                        foreach (var item2 in item1.MeasureList)
                        {
                            if (string.IsNullOrEmpty(item2.JobMeasureId))
                            {
                                item2.JobMeasureId = Guid.NewGuid().ToString();
                            }
                            item2.CreateTime     = DateTime.Now;
                            item2.JobDangerousId = item1.JobDangerousId;
                        }
                    }

                    item.CreateUserId = user.UserId;
                    item.CreateUser   = user.UserName;
                    workmeetingbll.UpdateJobTemplate(item);
                }
                // workmeetingbll.AddJobTemplates(templates);
            }
            catch (Exception ex)
            {
                success = false;
                message = HttpUtility.JavaScriptStringEncode(ex.Message);
            }

            return(Json(new { success, message }));
        }
        public object GetApplyList([FromBody] JObject json)
        {
            try
            {
                string  path       = new DataItemDetailBLL().GetItemValue("imgUrl");
                string  res        = json.Value <string>("json");
                dynamic dy         = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId     = dy.userid;
                string  starttime  = dy.data.starttime; //开始时间
                string  endtime    = dy.data.endtime;   //结束时间
                string  applyno    = dy.data.applyno;
                string  applytype  = dy.data.applytype;
                string  status     = dy.data.status;
                string  actiontype = dy.data.actiontype;//0全部 1 我的
                long    pageIndex  = dy.data.pageindex;
                long    pageSize   = dy.data.pagesize;
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator   currUser   = OperatorProvider.Provider.Current();
                Pagination pagination = new Pagination();
                pagination.page          = int.Parse(pageIndex.ToString());
                pagination.rows          = int.Parse(pageSize.ToString());
                pagination.p_kid         = "t.id applyid";
                pagination.p_fields      = @"t.createuserid,
                                           t.createdate,t.changetype,t.projectname,t.changename,
                                           t.applyunit,t.applychangetime,t.returntime,t.applytype,
                                           t.applyunitid,t.applypeople,t.applypeopleid,
                                           t.applytime, t.workunit,t.workunitid,t.applyno,
                                           t.iscommit,t.isaccepover,t.isapplyover,
                                           t.flowdept,t.nodename,t.nodeid,t.isaccpcommit,
                                           t.flowrole,t.flowdeptname,t.flowrolename,t.acceptime,t.workplace,'' as approveusername,
                                        case 
                                                 when t.iscommit=0 then 0
                                                 when t.iscommit=1 and (t.isapplyover=0 or t.isapplyover is null)  then 1
                                                 when t.iscommit=1 and t.isapplyover=2  then 2
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=0 and (t.isaccepover=0 or t.isaccepover is null) then 3
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and (t.isaccepover=0 or t.isaccepover is null) then 4
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=2 then 5
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=1 then 6 else 7 end applystate,
                                         case 
                                                 when t.iscommit=0 then '变动申请中'
                                                 when t.iscommit=1 and (t.isapplyover=0 or t.isapplyover is null) then '变动审核(批)中'
                                                 when t.iscommit=1 and t.isapplyover=2  then '变动审核(批)未通过'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=0 and (t.isaccepover=0 or t.isaccepover is null) then '变动审核(批)通过待验收'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and (t.isaccepover=0 or t.isaccepover is null) then '验收审核中'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=2 then '验收审核(批)未通过'
                                                 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=1 then '验收审核(批)通过' else '' end applystatename";
                pagination.p_tablename   = @"   bis_safetychange t";
                pagination.sidx          = "t.createdate"; //排序字段
                pagination.sord          = "desc";         //排序方式
                pagination.conditionJson = "1=1";

                string role     = currUser.RoleName;
                string deptId   = string.Empty;
                string deptName = string.Empty;

                //公司级用户取机构对象
                if (role.Contains("公司级用户"))
                {
                    deptId   = currUser.OrganizeId;   //机构ID
                    deptName = currUser.OrganizeName; //机构名称
                }
                else
                {
                    deptId   = currUser.DeptId;   //部门ID
                    deptName = currUser.DeptName; //部门ID
                }
                if (actiontype == "0")
                {
                    if (currUser.IsSystem)
                    {
                    }
                    else if (currUser.RoleName.Contains("厂级部门用户") || currUser.RoleName.Contains("公司级用户"))
                    {
                        pagination.conditionJson += " and t.createuserorgcode='" + currUser.OrganizeCode + "'";
                    }
                    else if (currUser.RoleName.Contains("承包商级用户") || currUser.RoleName.Contains("班组级用户"))
                    {
                        pagination.conditionJson += " and workunitcode='" + currUser.DeptCode + "'";
                    }
                    else
                    {
                        pagination.conditionJson += string.Format(" and workunitcode in(select encode from base_department  where encode like '{0}%' or senddeptid='{1}')", currUser.DeptCode, currUser.DeptId);
                    }
                }
                else
                {
                    string strWhere = string.Empty;

                    strWhere += string.Format(@"  select distinct a.id from bis_safetychange a  where a.createuserid ='{0}' ", currUser.UserId);
                    pagination.conditionJson += string.Format(" and t.id in ({0})", strWhere);
                }

                string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                    st        = starttime,
                    et        = endtime,
                    status    = status,
                    ApplyType = applytype,
                    applyno   = applyno
                });
                DataTable dt = safetychangebll.GetPageList(pagination, queryJson);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string str = new ScaffoldBLL().GetUserName(dt.Rows[i]["flowdept"].ToString(), dt.Rows[i]["flowrolename"].ToString());
                    dt.Rows[i]["approveusername"] = str.Split('|')[0];
                }
                return(new { code = 0, count = pagination.records, info = "获取数据成功", data = dt });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
Beispiel #28
0
        public object GetForm([FromBody] JObject json)
        {
            try
            {
                string  res      = json.Value <string>("json");
                dynamic dy       = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId   = dy.userid;
                string  keyvalue = dy.data.keyvalue;
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!" });
                }
                var    dailyExamineEntity = dailyexaminebll.GetEntity(keyvalue);
                var    files  = new FileInfoBLL().GetFiles(keyvalue);//获取相关附件
                string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
                foreach (DataRow dr in files.Rows)
                {
                    dr["filepath"] = dr["filepath"].ToString().Replace("~/", webUrl + "/");
                }

                List <AptitudeinvestigateauditEntity> AptitudeList = aptitudeinvestigateauditbll.GetAuditList(dailyExamineEntity.Id);
                for (int i = 0; i < AptitudeList.Count; i++)
                {
                    if (string.IsNullOrWhiteSpace(AptitudeList[i].AUDITSIGNIMG))
                    {
                        AptitudeList[i].AUDITSIGNIMG = string.Empty;
                    }
                    else
                    {
                        AptitudeList[i].AUDITSIGNIMG = webUrl + AptitudeList[i].AUDITSIGNIMG.ToString().Replace("../../", "/").ToString();
                    }
                }
                //查询审核流程图
                List <CheckFlowData> nodeList = new AptitudeinvestigateinfoBLL().GetAppFlowList(keyvalue, "8", curUser);
                return(new
                {
                    Code = 0,
                    Count = 1,
                    Info = "获取数据成功",
                    data = new
                    {
                        dailyexamineentity = new
                        {
                            examinecode = dailyExamineEntity.ExamineCode,
                            examinetodept = dailyExamineEntity.ExamineToDept,
                            examinetodeptid = dailyExamineEntity.ExamineToDeptId,
                            examinetype = dailyExamineEntity.ExamineType,
                            examinemoney = dailyExamineEntity.ExamineMoney,
                            examinecontent = dailyExamineEntity.ExamineContent,
                            examinebasis = dailyExamineEntity.ExamineBasis,
                            remark = dailyExamineEntity.Remark,
                            examineperson = dailyExamineEntity.ExaminePerson,
                            examinepersonid = dailyExamineEntity.ExaminePersonId,
                            examinetime = dailyExamineEntity.ExamineTime.Value.ToString("yyyy-MM-dd"),
                            examinedept = dailyExamineEntity.ExamineDept,
                            examinedeptid = dailyExamineEntity.ExamineDeptId
                        },
                        files = files,
                        auditinfo = AptitudeList.Select(g => new
                        {
                            auditresult = g.AUDITRESULT,
                            audittime = g.AUDITTIME.Value.ToString("yyyy-MM-dd"),
                            auditopinion = g.AUDITOPINION,
                            auditdept = g.AUDITDEPT,
                            auditpeople = g.AUDITPEOPLE,
                            auditsignimg = g.AUDITSIGNIMG
                        }).ToList(),
                        nodeList = nodeList
                    }
                });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
Beispiel #29
0
        /// <summary>
        /// 获取数据字典常量类
        /// </summary>
        /// <returns></returns>
        private void GetDataItemConst(out string strcode, out string strvalue)
        {
            var dataList = new DataItemDetailBLL().GetDataItemList();
            var sord     = (from c in dataList orderby c.EnCode select c.EnCode).Distinct();

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("using System.ComponentModel;\r\n");
            sb.AppendLine("namespace LeaRun.Application.Entity\r\n{");

            sb.AppendLine("    /// <summary>");
            sb.AppendLine("    /// 数据字典值变量");
            sb.AppendLine("    /// </summary>");
            sb.AppendLine("    public class DataItemValues");
            sb.AppendLine("    {");

            foreach (string itemSort in sord)
            {
                var dataItemList = dataList.Where(t => t.EnCode.Equals(itemSort)).OrderBy(t => t.SortCode);
                foreach (DataItemModel itemList in dataItemList)
                {
                    string pname = itemList.EnCode + "_" + itemList.ItemValue;
                    pname = Regex.Replace(pname, @"[\s\-\.\;\:]+", "");
                    sb.AppendLine("\r\n        /// <summary>");
                    sb.AppendLine("        ///  " + itemList.EnCode + "." + itemList.ItemName);
                    sb.AppendLine("        /// </summary>");
                    sb.AppendLine("        [Description(\"" + itemList.ItemName + "\")]");
                    sb.AppendLine("        public const string " + pname + " = \"" +
                                  itemList.ItemValue + "\";");
                }
            }

            sb.AppendLine("    }\r\n}");
            strvalue = sb.ToString();


            var its = new DataItemBLL().GetList();

            StringBuilder sb2 = new StringBuilder();

            sb2.AppendLine("using System.ComponentModel;\r\n");
            sb2.AppendLine("namespace LeaRun.Application.Entity\r\n{");

            sb2.AppendLine("    /// <summary>");
            sb2.AppendLine("    /// 数据字典类型常量");
            sb2.AppendLine("    /// </summary>");
            sb2.AppendLine("    public class DataItemCodes");
            sb2.AppendLine("    {");

            foreach (DataItemEntity itemList in its)
            {
                string pname = itemList.ItemCode;
                pname = Regex.Replace(pname, @"[\s\-\.\;\:]+", "");
                sb2.AppendLine("\r\n        /// <summary>");
                sb2.AppendLine("        ///  " + itemList.ItemCode + "." + itemList.ItemName);
                sb2.AppendLine("        /// </summary>");
                sb2.AppendLine("        [Description(\"" + itemList.ItemName + "\")]");
                sb2.AppendLine("        public const string " + pname + " = \"" +
                               pname + "\";");
            }

            sb2.AppendLine("    }\r\n}");
            strcode = sb2.ToString();
        }
Beispiel #30
0
        public ActionResult ExportScoreRank(string condition, string queryJson)
        {
            Operator          user    = ERCHTMS.Code.OperatorProvider.Provider.Current();
            DataItemDetailBLL itemBll = new DataItemDetailBLL();
            var        item           = itemBll.GetEntity(user.OrganizeId);
            string     val            = item == null ? "100" : item.ItemValue;
            Pagination pagination     = new Pagination();

            pagination.page          = 1;
            pagination.rows          = 100000000;
            pagination.p_kid         = "u.userid";
            pagination.p_fields      = "REALNAME,GENDER,identifyid,DEPTNAME,(nvl(score,0)+" + val + ") score";
            pagination.p_tablename   = "v_userinfo u left join (select a.userid,nvl(sum(score),0) as score from base_user a left join bis_userscore b on a.userid=b.userid where year='" + DateTime.Now.Year + "' group by a.userid) t on u.userid=t.userid";
            pagination.conditionJson = "1=1 ";
            pagination.sidx          = "score";
            pagination.sord          = "desc";

            string title = "人员安全积分排名";

            if (user.IsSystem)
            {
                pagination.conditionJson = "1=1";
            }
            else
            {
                string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "departmentcode", "organizecode");
                if (!string.IsNullOrEmpty(where))
                {
                    pagination.conditionJson += " and " + where;
                }
            }
            var data = userscorebll.GetPageJsonList(pagination, queryJson);

            //设置导出格式
            ExcelConfig excelconfig = new ExcelConfig();

            excelconfig.Title           = title;
            excelconfig.TitleFont       = "微软雅黑";
            excelconfig.TitlePoint      = 25;
            excelconfig.FileName        = title + ".xls";
            excelconfig.IsAllSizeColumn = true;
            //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出
            List <ColumnEntity> listColumnEntity = new List <ColumnEntity>();

            excelconfig.ColumnEntity = listColumnEntity;
            ColumnEntity columnentity = new ColumnEntity();

            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "realname", ExcelColumn = "姓名", Alignment = "center"
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "gender", ExcelColumn = "性别", Alignment = "center"
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "identifyid", ExcelColumn = "身份证号", Alignment = "center"
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "deptname", ExcelColumn = "单位/部门", Alignment = "center"
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "score", ExcelColumn = "积分", Alignment = "center"
            });
            //调用导出方法
            ExcelHelper.ExcelDownload(data, excelconfig);
            return(Success("导出成功。"));
        }