public ActionResult SavePeopleReview(string keyValue, PeopleReviewEntity entity) { try { peoplereviewbll.SaveForm(keyValue, entity); return Success("操作成功。"); } catch (Exception ex) { return Error(ex.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)); }
public void ExportReport(string keyValue) { try { var userInfo = OperatorProvider.Provider.Current(); //获取当前用户 string strDocPath = Server.MapPath("~/Resource/ExcelTemplate/人员资质审批表华润版本.doc"); string fileName = "相关方施工人员进厂申请表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc"; Aspose.Words.Document doc = new Aspose.Words.Document(strDocPath); DocumentBuilder builder = new DocumentBuilder(doc); DataSet ds = new DataSet(); DataTable dtPro = new DataTable("project"); dtPro.Columns.Add("createdate");//申请时间 dtPro.Columns.Add("outsourcingproject");//单位名称 dtPro.Columns.Add("outsouringengineer");//工程名称 dtPro.Columns.Add("predicttime");//计划工期 dtPro.Columns.Add("engineerdirector");//施工负责人 dtPro.Columns.Add("workpeoplecount"); //施工人数 dtPro.Columns.Add("engineerletdeptid"); //用工部门 dtPro.Columns.Add("linkman"); //联系人 dtPro.Columns.Add("ygauditidea");//用工部门审核意见 dtPro.Columns.Add("ygauditdate");//用工部门审核时间 dtPro.Columns.Add("ehsauditidea");//EHS部审核意见 dtPro.Columns.Add("ehsauditdate");//EHS部审核时间 dtPro.Columns.Add("bgsauditidea");//办公室审核意见 dtPro.Columns.Add("bgsauditdate");//办公室审核时间 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(); row["createdate"] =Convert.ToDateTime(p.CREATEDATE).ToString("yyyy年MM月dd日"); row["outsourcingproject"] = pro.OUTSOURCINGNAME; row["outsouringengineer"] = eng.ENGINEERNAME; row["predicttime"] = eng.PREDICTTIME; row["engineerdirector"] = eng.ENGINEERDIRECTOR; row["engineerletdeptid"] = eng.ENGINEERLETDEPT; row["linkman"] = pro.LINKMAN; row["workpeoplecount"] = aptitudeinvestigatepeoplebll.GetList("").Where(t => t.PEOPLEREVIEWID == keyValue).Count(); List<AptitudeinvestigateauditEntity> list = auditbll.GetAuditList(keyValue).OrderByDescending(x => x.AUDITTIME).ToList(); string pic = Server.MapPath("~/content/Images/no_1.png");//默认图片 if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { var filepath = list[i].AUDITSIGNIMG == null ? "" : (Server.MapPath("~/") + list[i].AUDITSIGNIMG.ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString(); var stime = Convert.ToDateTime(list[i].AUDITTIME); if (i == 0) { row["ygauditidea"] = list[i].AUDITOPINION; //zauditusername = list[i].AuditUserName; builder.MoveToMergeField("ygauditusername"); row["ygauditdate"] = stime.ToString("yyyy年MM月dd日"); } else if (i == 1) { row["ehsauditidea"] = list[i].AUDITOPINION; //sauditusername = list[i].AuditUserName; builder.MoveToMergeField("ehsauditusername"); row["ehsauditdate"] = stime.ToString("yyyy年MM月dd日"); } else if (i == 2) { row["bgsauditidea"] = list[i].AUDITOPINION; //aauditusername = list[i].AuditUserName; builder.MoveToMergeField("bgsauditusername"); row["bgsauditdate"] = stime.ToString("yyyy年MM月dd日"); } if (!System.IO.File.Exists(filepath)) { filepath = pic; } builder.InsertImage(filepath, 80, 35); } } dtPro.Rows.Add(row); doc.MailMerge.Execute(dtPro); doc.MailMerge.DeleteFields(); doc.Save(resp, Server.UrlEncode(fileName), ContentDisposition.Attachment, Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Doc)); } catch (Exception ex) { throw; } }
/// <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; } }