public ActionResult CheckNumAudit(string keyValueids, string queryJson) { Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current(); foreach (string keyValue in queryJson.Split(',')) { FivesafetycheckauditEntity applyentity = fivesafetycheckauditbll.GetEntity(keyValue); if (applyentity.ACCEPTREUSLT != "0" && applyentity.ACTIONRESULT == "0" && applyentity.ACCEPTUSERID == curUser.UserId) // 已整改完,未验收的,验收人为当前用户的数据执行批量验收操作 { applyentity.ACCEPTCONTENT = ""; applyentity.ACCEPTREUSLT = "0"; fivesafetycheckauditbll.SaveForm(keyValue, applyentity); #region 更新主表信息 string checkid = applyentity.CHECKID; var checkentity = fivesafetycheckbll.GetEntity(checkid); DataTable dt = fivesafetycheckauditbll.GetDataTable("select id from BIS_FIVESAFETYCHECKAUDIT where checkpass = '******' and (ACCEPTREUSLT is null or ACCEPTREUSLT = '1') and checkid = '" + checkid + "' "); // 所有的验收已完成,更新主表信息为已完成 if (dt.Rows.Count == 0) { checkentity.ISOVER = 3; } fivesafetycheckbll.SaveForm(checkid, checkentity); } #endregion } return(Success("操作成功。")); }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, FivesafetycheckauditEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public string ImportQuestion(string keyvalue) { if (OperatorProvider.Provider.Current().IsSystem) { return("超级管理员无此操作权限"); } string orgId = OperatorProvider.Provider.Current().OrganizeId;//所属公司 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)); Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); wb.Open(Server.MapPath("~/Resource/temp/" + fileName)); Aspose.Cells.Cells cells = wb.Worksheets[0].Cells; DataTable dt = cells.ExportDataTable(1, 0, cells.MaxDataRow, cells.MaxColumn + 1, false); for (int i = 1; i < dt.Rows.Count; i++) { //序号 string sortnum = dt.Rows[i][0].ToString(); //发现问题 string findquestion = dt.Rows[i][1].ToString(); //整改措施 string actioncontent = dt.Rows[i][2].ToString(); //责任部门 string dutydept = dt.Rows[i][3].ToString(); //责任人 string dutyusername = dt.Rows[i][4].ToString(); //要求完成时间 string finishdate = dt.Rows[i][5].ToString(); //验收人 string acceptuser = dt.Rows[i][6].ToString(); //整改完成情况 string actionresult = dt.Rows[i][7].ToString(); //实际完成时间 string actualdate = dt.Rows[i][8].ToString(); //备注 string beizhu = dt.Rows[i][9].ToString(); //---****值存在空验证*****-- if (string.IsNullOrEmpty(findquestion) || string.IsNullOrEmpty(actioncontent) || string.IsNullOrEmpty(dutydept) || string.IsNullOrEmpty(dutyusername) || string.IsNullOrEmpty(finishdate) || string.IsNullOrEmpty(acceptuser)) { falseMessage += "</br>" + "第" + (i + 2) + "行值存在空,未能导入."; error++; continue; } if (actionresult == "已完成" && string.IsNullOrEmpty(actualdate)) { falseMessage += "</br>" + "第" + (i + 2) + "行值,整改完成情况为已完成时必须填实际完成时间."; error++; continue; } FivesafetycheckauditEntity pe = new FivesafetycheckauditEntity(); pe.ID = Guid.NewGuid().ToString(); pe.FINDQUESTION = findquestion; pe.ACTIONCONTENT = actioncontent; pe.CHECKPASS = "******"; pe.CHECKID = keyvalue; pe.DUTYDEPT = dutydept; if (!string.IsNullOrEmpty(dutydept)) { string[] ar = dutydept.Split('/'); //int resultdept = 0; DataTable deptentity = null; string deptid = ""; foreach (string arstr in ar) { if (deptid == "") { deptentity = fivesafetycheckbll.GetInfoBySql("select departmentid,encode from base_department where fullname = '" + arstr + "' "); } else { deptentity = fivesafetycheckbll.GetInfoBySql("select departmentid,encode from base_department where PARENTID = '" + deptid + "' and fullname = '" + arstr + "' "); } if (deptentity.Rows.Count == 0) { //resultdept = 1; break; } else { deptid = deptentity.Rows[0]["departmentid"].ToString(); } } //var deptentity = fivesafetycheckbll.GetInfoBySql("select departmentid,encode from base_department where fullname = '" + dutydept + "' "); if (deptentity.Rows.Count > 0) { pe.DUTYDEPTCODE = deptentity.Rows[0]["encode"].ToString(); pe.DUTYDEPTID = deptentity.Rows[0]["departmentid"].ToString(); } else { // 如果查询不到部门,智能提醒检查 刘畅 string stdept = fivesafetycheckbll.GetDeptByName(dutydept); if (stdept != "" && stdept != null) { falseMessage += "</br>" + "第" + (i + 2) + "行责任部门未在系统中查到,智能识别判断您输入的可能是<" + stdept + ">."; } else { falseMessage += "</br>" + "第" + (i + 2) + "行责任部门未在系统中查到,未能导入."; } error++; continue; } } pe.DUTYUSERNAME = dutyusername; if (!string.IsNullOrEmpty(dutyusername)) { if (dutyusername.IndexOf('/') > -1) { var deptentity = fivesafetycheckbll.GetInfoBySql("select userid,mobile from base_user where realname = '" + dutyusername.Split('/')[0] + "' "); if (deptentity.Rows.Count == 1) { pe.DUTYUSERID = deptentity.Rows[0]["userid"].ToString(); } else if (deptentity.Rows.Count > 1) { deptentity = fivesafetycheckbll.GetInfoBySql("select userid,mobile from base_user where realname = '" + dutyusername.Split('/')[0] + "' and mobile='" + dutyusername.Split('/')[1] + "' "); if (deptentity.Rows[0]["mobile"].ToString() == dutyusername.Split('/')[1]) { pe.DUTYUSERID = deptentity.Rows[0]["userid"].ToString(); } else { falseMessage += "</br>" + "第" + (i + 2) + "行责任人未在系统中查到,未能导入."; error++; continue; } } else { falseMessage += "</br>" + "第" + (i + 2) + "行责任人未在系统中查到,未能导入."; error++; continue; } } else { var deptentity = fivesafetycheckbll.GetInfoBySql("select userid from base_user where realname = '" + dutyusername + "' "); if (deptentity.Rows.Count > 0) { pe.DUTYUSERID = deptentity.Rows[0]["userid"].ToString(); } else { falseMessage += "</br>" + "第" + (i + 2) + "行责任人未在系统中查到,未能导入."; error++; continue; } } } pe.ACCEPTUSER = acceptuser; if (!string.IsNullOrEmpty(acceptuser)) { if (acceptuser.IndexOf('/') > -1) { var deptentity = fivesafetycheckbll.GetInfoBySql("select userid,mobile from base_user where realname = '" + acceptuser.Split('/')[0] + "' "); if (deptentity.Rows.Count == 1) { pe.ACCEPTUSERID = deptentity.Rows[0]["userid"].ToString(); } else if (deptentity.Rows.Count > 1) { deptentity = fivesafetycheckbll.GetInfoBySql("select userid,mobile from base_user where realname = '" + acceptuser.Split('/')[0] + "' and mobile='" + acceptuser.Split('/')[1] + "' "); if (deptentity.Rows[0]["mobile"].ToString() == acceptuser.Split('/')[1]) { pe.ACCEPTUSERID = deptentity.Rows[0]["userid"].ToString(); } else { falseMessage += "</br>" + "第" + (i + 2) + "行验收人未在系统中查到,未能导入."; error++; continue; } } else { falseMessage += "</br>" + "第" + (i + 2) + "行验收人未在系统中查到,未能导入."; error++; continue; } } else { var deptentity = fivesafetycheckbll.GetInfoBySql("select userid from base_user where realname = '" + acceptuser + "' "); if (deptentity.Rows.Count > 0) { pe.ACCEPTUSERID = deptentity.Rows[0]["userid"].ToString(); } else { falseMessage += "</br>" + "第" + (i + 2) + "行验收人未在系统中查到,未能导入."; error++; continue; } } } try { if (!string.IsNullOrEmpty(finishdate)) { pe.FINISHDATE = DateTime.Parse(DateTime.Parse(finishdate).ToString("yyyy-MM-dd")); } } catch { falseMessage += "</br>" + "第" + (i + 2) + "行要求完成时间有误,未能导入."; error++; continue; } try { if (!string.IsNullOrEmpty(actualdate)) { pe.ACTUALDATE = DateTime.Parse(DateTime.Parse(finishdate).ToString("yyyy-MM-dd")); } } catch { falseMessage += "</br>" + "第" + (i + 2) + "行实际完成时间有误,未能导入."; error++; continue; } //完成情况 if (!string.IsNullOrEmpty(actionresult)) { if (actionresult == "已完成") { pe.ACTIONRESULT = "0"; pe.CHECKPASS = "******"; pe.ACCEPTREUSLT = "0"; } else if (actionresult == "未完成") { pe.ACTIONRESULT = "1"; pe.ACTUALDATE = null; } else { falseMessage += "</br>" + "第" + (i + 2) + "行整改完成情况有误,未能导入."; error++; continue; } } //备注 if (beizhu.Length > 2000) { falseMessage += "</br>" + "第" + (i + 2) + "行备注文本过长,未能导入."; error++; continue; } else { pe.BEIZHU = beizhu; } try { fivesafetycheckauditbll.SaveForm(pe.ID, pe); } catch { falseMessage += "</br>" + "第" + (i + 2) + "行保存失败,未能导入."; error++; continue; } } count = dt.Rows.Count - 1; message = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条"; message += "</br>" + falseMessage; } return(message); }
public ActionResult ApplyForm(string keyValue, string istype, FivesafetycheckauditEntity entity) { FivesafetycheckauditEntity applyentity = fivesafetycheckauditbll.GetEntity(keyValue); if (istype == "0") // 0:整改 1:验收 { applyentity.BEIZHU = entity.BEIZHU; applyentity.ACTUALDATE = entity.ACTUALDATE; applyentity.ACTIONRESULT = entity.ACTIONRESULT; if (entity.ACTIONRESULT == "0") { applyentity.ACCEPTREUSLT = ""; applyentity.ACCEPTCONTENT = ""; } } else { applyentity.ACCEPTCONTENT = entity.ACCEPTCONTENT; applyentity.ACCEPTREUSLT = entity.ACCEPTREUSLT; if (entity.ACCEPTREUSLT == "1") //不同意 { applyentity.ACTIONRESULT = "1"; applyentity.ACTUALDATE = null; JPushApi.PushMessage(new UserBLL().GetEntity(applyentity.DUTYUSERID).Account, applyentity.DUTYUSERNAME, "WDJC001", applyentity.ID); } } fivesafetycheckauditbll.SaveForm(keyValue, applyentity); #region 更新主表信息 string checkid = applyentity.CHECKID; var checkentity = fivesafetycheckbll.GetEntity(checkid); if (istype == "0") // 0:整改 1:验收 { //整改同意,需要判断是否全部整改完 if (entity.ACTIONRESULT == "0") { DataTable dt = fivesafetycheckauditbll.GetDataTable("select id from BIS_FIVESAFETYCHECKAUDIT where checkpass = '******' and (ACTIONRESULT is null or ACTIONRESULT = '1') and checkid = '" + checkid + "' "); // 所有的整改已完成,更新主表信息为验收中 if (dt.Rows.Count == 0) { checkentity.ISOVER = 2; } } } else { if (entity.ACCEPTREUSLT == "0") //同意 { DataTable dt = fivesafetycheckauditbll.GetDataTable("select id from BIS_FIVESAFETYCHECKAUDIT where checkpass = '******' and (ACCEPTREUSLT is null or ACCEPTREUSLT = '1') and checkid = '" + checkid + "' "); // 所有的验收已完成,更新主表信息为已完成 if (dt.Rows.Count == 0) { checkentity.ISOVER = 3; } } else // 不同意将直接改成整改中 { checkentity.ISOVER = 1; } } fivesafetycheckbll.SaveForm(checkid, checkentity); #endregion return(Success("操作成功。")); }
public ActionResult SaveForm(string keyValue, FivesafetycheckauditEntity entity) { fivesafetycheckauditbll.SaveForm(keyValue, entity); return(Success("操作成功。")); }