/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, JobApprovalFormEntity entity, List <ManyPowerCheckEntity> data, string arr) { try { service.SaveForm(keyValue, entity, data, arr); if (entity.IsSubmit == 1) { UserBLL userbll = new UserBLL(); DangerousJobFlowDetailEntity flow = DangerousJobFlowDetailIService.GetList().Where(t => t.BusinessId == entity.Id && t.Status == 0).FirstOrDefault(); string userids = DangerousJobFlowDetailIService.GetCurrentStepUser(entity.Id, flow.Id); DataTable dt = userbll.GetUserTable(userids.Split(',')); entity = service.GetEntity(entity.Id); entity.JobLevelName = dataitemdetailbll.GetItemName("DangerousJobCheck", entity.JobLevel); JPushApi.PushMessage(string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("account")).ToArray()), string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("realname")).ToArray()), "WXZY001", entity.JobLevelName + "审批单(" + entity.JobTypeName + ")申请待您审批,请您及时处理。", entity.CreateUserName + "于" + entity.CreateDate.Value.ToString("yyyy年MM月dd日") + "申请的" + entity.JobLevelName + "审批单(" + entity.JobTypeName + ")需要您进行审批,请您及时处理。", entity.Id); } //if (entity.FlowState == "1") //{ // UserBLL userbll = new UserBLL(); // UserEntity userEntity = userbll.GetEntity(entity.DutyPersonId);//获取责任人用户信息 // JPushApi.PushMessage(userEntity.Account, entity.DutyPerson, "GZDB001", "例行安全工作", entity.Id); //} } catch (Exception ex) { throw ex; } }
/// <summary> /// 安全风险审批单审核保存表单(新增、修改) /// </summary> /// <param name="keyValue">主表主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void ApprovalFormCheckSaveForm(string keyValue, DangerousJobFlowDetailEntity entity) { try { service.ApprovalFormCheckSaveForm(keyValue, entity); JobApprovalFormBLL bll = new JobApprovalFormBLL(); UserBLL userbll = new UserBLL(); var data = bll.GetEntity(keyValue); data.JobLevelName = dataitemdetailbll.GetItemName("DangerousJobCheck", data.JobLevel); if (data.JobState == 4)//审核不通过 { JPushApi.PushMessage(userbll.GetEntity(data.CreateUserId).Account, data.CreateUserName, "WXZY002", data.JobLevelName + "审批单(" + data.JobTypeName + ")申请审批未通过,请您知晓。", "您于" + data.CreateDate.Value.ToString("yyyy年MM月dd日") + "申请的" + data.JobLevelName + "审批单(" + data.JobTypeName + ")安全证审批未通过,如您还需进行作业,请重新进行申请。", data.Id); } else if (data.JobState == 1)//下一步审批人 { DangerousJobFlowDetailEntity flow = service.GetList().Where(t => t.BusinessId == keyValue && t.Status == 0).FirstOrDefault(); string userids = service.GetCurrentStepUser(keyValue, flow.Id); DataTable dt = userbll.GetUserTable(userids.Split(',')); JPushApi.PushMessage(string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("account")).ToArray()), string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("realname")).ToArray()), "WXZY001", data.JobLevelName + "审批单(" + data.JobTypeName + ")申请待您审批,请您及时处理。", data.CreateUserName + "于" + data.CreateDate.Value.ToString("yyyy年MM月dd日") + "申请的" + data.JobLevelName + "审批单(" + data.JobTypeName + ")需要您进行审批,请您及时处理。", data.Id); } else { //审批通过 DataTable dt = userbll.GetUserTable((data.CreateUserId + "," + data.JobPersonId).Split(',')); JPushApi.PushMessage(string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("account")).ToArray()), string.Join(",", dt.AsEnumerable().Select(t => t.Field <string>("realname")).ToArray()), "WXZY003", data.JobLevelName + "审批单(" + data.JobTypeName + ")申请已审批通过,请您查收。", "您于" + data.CreateDate.Value.ToString("yyyy年MM月dd日") + "申请的" + data.JobLevelName + "审批单(" + data.JobTypeName + ")已审批通过,请您合理安排作业时间。", data.Id); } } catch (Exception) { throw; } }
public ActionResult ExportInfo(string keyValue) { try { HttpResponse resp = System.Web.HttpContext.Current.Response; //报告对象 string fileName = "起重吊装作业_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc"; string strDocPath = Request.PhysicalApplicationPath + @"Resource\ExcelTemplate\起重吊装作业导出模板.docx"; Aspose.Words.Document doc = new Aspose.Words.Document(strDocPath); DocumentBuilder builder = new DocumentBuilder(doc); DataTable dt = new DataTable(); dt.Columns.Add("APPLYCODE"); //编号 dt.Columns.Add("CHARGEPERSONNAME"); //工作负责人 dt.Columns.Add("GUARDIANNAME"); //监护人 dt.Columns.Add("QUALITY"); //起吊重物质量 dt.Columns.Add("TOOLNAME"); //吊装工具名称 dt.Columns.Add("CONSTRUCTIONUNITNAME"); //吊装施工单位 dt.Columns.Add("CONSTRUCTIONADDRESS"); //吊装施工地点 dt.Columns.Add("HOISTCONTENT"); //吊装内容 dt.Columns.Add("WORKDATE"); //作业时间 dt.Columns.Add("APPLYCOMPANYNAME"); //申请单位 dt.Columns.Add("APPLYUSERNAME"); //申请人 dt.Columns.Add("APPLYDATE"); //申请日期 dt.Columns.Add("approve1"); //技术支持部专业 dt.Columns.Add("approvedate1"); dt.Columns.Add("approve2"); //技术支持部 dt.Columns.Add("approvedate2"); dt.Columns.Add("approve3"); //分管领导 dt.Columns.Add("approvedate3"); DataRow row = dt.NewRow(); LifthoistjobEntity entity = lifthoistjobbll.GetEntity(keyValue); row["APPLYCODE"] = entity.APPLYCODESTR; row["CHARGEPERSONNAME"] = entity.CHARGEPERSONNAME; row["GUARDIANNAME"] = entity.GUARDIANNAME; row["QUALITY"] = entity.QUALITY; row["TOOLNAME"] = dataitemdetailbll.GetItemName("ToolName", entity.TOOLNAME); row["CONSTRUCTIONUNITNAME"] = entity.CONSTRUCTIONUNITNAME; row["CONSTRUCTIONADDRESS"] = entity.CONSTRUCTIONADDRESS; row["HOISTCONTENT"] = entity.HOISTCONTENT; row["WORKDATE"] = "自" + Convert.ToDateTime(entity.WORKSTARTDATE).ToString("yyyy年MM月dd日HH时mm分") + "到" + Convert.ToDateTime(entity.WORKENDDATE).ToString("yyyy年MM月dd日HH时mm分"); row["APPLYCOMPANYNAME"] = entity.APPLYCOMPANYNAME; row["APPLYUSERNAME"] = entity.APPLYUSERNAME; row["APPLYDATE"] = Convert.ToDateTime(entity.APPLYDATE).ToString("yyyy-MM-dd HH:mm"); IList <LifthoistauditrecordEntity> auditlist = lifthoistauditrecordbll.GetList(keyValue).Where(t => t.DISABLE != 1).OrderBy(t => t.AUDITDATE).ToList(); for (int i = 0; i < auditlist.Count; i++) { var filepath = auditlist[i].AUDITSIGNIMG == null?Server.MapPath("~/content/Images/no_1.png") : (Server.MapPath("~/") + auditlist[i].AUDITSIGNIMG.ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString(); if (!System.IO.File.Exists(filepath)) { filepath = Server.MapPath("~/content/Images/no_1.png"); } var stime = Convert.ToDateTime(auditlist[i].AUDITDATE).ToString("yyyy-MM-dd HH:mm"); switch (i) { case 0: builder.MoveToMergeField("approve1"); builder.InsertImage(filepath, 80, 35); row["approvedate1"] = stime; break; case 1: builder.MoveToMergeField("approve2"); builder.InsertImage(filepath, 80, 35); row["approvedate2"] = stime; break; case 2: builder.MoveToMergeField("approve3"); builder.InsertImage(filepath, 80, 35); row["approvedate3"] = stime; break; default: break; } } dt.Rows.Add(row); doc.MailMerge.Execute(dt); DataTable dtperson = new DataTable("U"); dtperson.Columns.Add("BelongDeptName"); dtperson.Columns.Add("CertificateNum"); dtperson.Columns.Add("PersonName"); dtperson.Columns.Add("PersonType"); List <LifthoistpersonEntity> listperson = lifthoistpersonbll.GetRelateList(keyValue).ToList(); foreach (var item in listperson) { DataRow dtrow = dtperson.NewRow(); dtrow["BelongDeptName"] = item.BelongDeptName; dtrow["CertificateNum"] = item.CertificateNum; dtrow["PersonName"] = item.PersonName; dtrow["PersonType"] = item.PersonName; DataTable liftfazls = fileInfoBLL.GetFiles(item.Id); if (liftfazls != null && liftfazls.Rows.Count > 0) { foreach (DataRow rowitem in liftfazls.Rows) { string image = "ico,gif,jpeg,jpg,png,psd"; if (image.Contains(rowitem["filepath"].ToString().Split('.')[1].ToLower())) { var filepath = rowitem["filepath"] == null?Server.MapPath("~/content/Images/no_1.png") : (Server.MapPath("~/") + rowitem["filepath"].ToString().Replace("~/", "").ToString()).Replace(@"\/", "/").ToString(); if (!System.IO.File.Exists(filepath)) { filepath = Server.MapPath("~/content/Images/no_1.png"); } builder.MoveToMergeField("lifthoistpersonfile"); builder.InsertImage(filepath, 80, 35); } } } dtperson.Rows.Add(dtrow); } doc.MailMerge.ExecuteWithRegions(dtperson); doc.MailMerge.DeleteFields(); doc.Save(resp, Server.UrlEncode(fileName), ContentDisposition.Attachment, Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Doc)); return(Success("导出成功!")); } catch (Exception ex) { return(Error(ex.ToString())); } }