From fcd6a6860f65d22fa0dafcbcc17c7ca69d9492a3 Mon Sep 17 00:00:00 2001 From: zhaoyu Date: Sun, 17 Dec 2023 09:31:34 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E5=A4=84=E4=BD=9C=E4=B8=9A=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gf/AppGFHighWorkController.java | 230 ++++++++++++++++-- 1 file changed, 207 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/zcloud/controller/gf/AppGFHighWorkController.java b/src/main/java/com/zcloud/controller/gf/AppGFHighWorkController.java index f2791176..c003d0c9 100644 --- a/src/main/java/com/zcloud/controller/gf/AppGFHighWorkController.java +++ b/src/main/java/com/zcloud/controller/gf/AppGFHighWorkController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartRequest; import javax.annotation.Resource; import java.io.File; @@ -42,6 +43,8 @@ public class AppGFHighWorkController extends BaseController { private GFHighWorkToMeasuresService GFhighWorkToMeasuresService; @Autowired private SendMessageUtil sendMessageUtil; + @Autowired + private Smb smb; /**获取编码 * @param * @throws Exception @@ -78,6 +81,18 @@ public class AppGFHighWorkController extends BaseController { String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); + PageData pd2 = new PageData(); + Calendar calendar = Calendar.getInstance(); + DecimalFormat dft=new DecimalFormat("00"); + int year = calendar.get(Calendar.YEAR); + String month = dft.format(calendar.get(Calendar.MONTH) + 1); + String day = dft.format(calendar.get(Calendar.DAY_OF_MONTH)); + pd2.put("CREATDATE",year + "-" + month + "-" + day); + pd2.put("CORPINFO_ID",pd.get("CORPINFO_ID")); + pd2 = GFhighworkService.getCode(pd2); //根据ID读取 + String code = "GK"+year + month + day + dft.format((Integer.parseInt(pd2.get("code").toString())+1)); + pd = this.getPageData(); + pd.put("CHECK_NO", code); pd.put("HIGHWORK_ID", this.get32UUID()); //主键 pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间 pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 @@ -128,7 +143,7 @@ public class AppGFHighWorkController extends BaseController { } /**删除 - * @param out + * @param * @throws Exception */ @RequestMapping(value="/delete") @@ -222,7 +237,7 @@ public class AppGFHighWorkController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); + smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd2.put("GUARDIAN_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd2.put("GUARDIAN_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); @@ -298,7 +313,7 @@ public class AppGFHighWorkController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); + smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd2.put("CONFESS_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd2.put("CONFESS_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); @@ -316,9 +331,7 @@ public class AppGFHighWorkController extends BaseController { @RequestMapping(value="/editAcceptconfess") @ResponseBody @Transactional - public Object editAcceptconfess( - @RequestParam(value="FFILE",required=false) MultipartFile[] files - ) throws Exception { + public Object editAcceptconfess(MultipartRequest request) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); @@ -327,22 +340,191 @@ public class AppGFHighWorkController extends BaseController { pd2 = GFhighworkService.findById(pd); pd2.put("OPERATOR", pd.get("OPERATOR")); //修改人 pd2.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - if (files != null && files.length > 0) { - MultipartFile file = files[0]; + List fileList = new ArrayList(); + String signertime = ""; + String SIGNTIME[] = pd.getString("SIGNTIME").split(","); - String ffile = DateUtil.getDays(); - String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); - - pd2.put("ACCEPT_CONFESS_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); - pd2.put("ACCEPT_CONFESS_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); -// pd2.put("GUARDIAN_CONTENT", pd.get("CONTENT")); -// pd2.put("APPLY_STATUS", pd.get("APPLY_STATUS")); - GFhighworkService.edit(pd2); + for (int i = 0; i < SIGNTIME.length; i++) { + signertime = SIGNTIME[i]; + fileList.add(request.getFile("file"+i)); + MultipartFile[] fileArr = new MultipartFile[fileList.size()]; + saveImg(fileList.toArray(fileArr),signertime,pd.getString("HIGHWORK_ID"),pd.getString("CORPINFO_ID"),pd.getString("ACCEPT_CONFESS_USER_ID"),pd.getString("ACCEPT_CONFESS_DEPARTMENT_ID")); + fileList.clear(); } map.put("result", errInfo); return map; } + private void saveImg(MultipartFile[] files,String signertime, String HIGHWORK_ID, String CORPINFO_ID, String ACCEPT_CONFESS_USER_ID, String ACCEPT_CONFESS_DEPARTMENT_ID) throws Exception{ + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + PageData pd = new PageData(); + pd = this.getPageData(); + MultipartFile file = files[i]; + String ffile = DateUtil.getDays(); + String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + smb.sshSftp(file, fileName,Const.FILEPATHFILE + CORPINFO_ID + "/" + ffile); + pd.put("ACCEPT_CONFESS_USER_SIGNER_TIME", signertime); + pd.put("ACCEPT_CONFESS_ID", this.get32UUID()); + pd.put("OPERATOR", pd.get("OPERATOR")); //修改人 + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + pd.put("ACCEPT_CONFESS_USER_SIGNER_PATH", Const.FILEPATHFILE + CORPINFO_ID + "/" + ffile + "/" + fileName); + pd.put("ISDELETE", '0'); + pd.put("CORPINFO_ID", CORPINFO_ID); + pd.put("HIGHWORK_ID", HIGHWORK_ID); + pd.put("ACCEPT_CONFESS_USER_ID", ACCEPT_CONFESS_USER_ID); + pd.put("ACCEPT_CONFESS_DEPARTMENT_ID", ACCEPT_CONFESS_DEPARTMENT_ID); + pd.put("ACCEPT_USER_ID",""); + pd.put("ACCEPT_DEPARTMENT_ID", ""); + highworkacceptuserService.save(pd); + } + } + } + + /**修改 + * @param + * @throws Exception + */ + @RequestMapping(value="/editAcceptStatus") + @ResponseBody + @Transactional + public Object editAcceptStatus(MultipartRequest request) throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + PageData pd2 = new PageData(); + pd2 = GFhighworkService.findById(pd); + pd2.put("OPERATOR", pd.get("OPERATOR")); //修改人 + pd2.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 +// pd2.put("OTHER_PROTECTIVE_MEASURES", pd.get("OTHER_PROTECTIVE_MEASURES")); //修改人 +// pd2.put("HAZARD_IDENTIFICATION", pd.get("HAZARD_IDENTIFICATION")); //修改人 + PageData log = new PageData(); + log.put("HIGHWORKLOG_ID", this.get32UUID()); +// log.put("ACTION", "审核打回"); + log.put("HIGHWORK_ID", pd.get("HIGHWORK_ID")); + log.put("CREATOR",pd.get("ACTION_USER")); + log.put("CREATTIME", DateUtil.date2Str(new Date())); + + String status = pd.get("STATUS").toString(); + String OTHER_PROTECTIVE_MEASURES = pd2.getString("OTHER_PROTECTIVE_MEASURES"); + if ("2".equals(status) || "3".equals(status) || "4".equals(status) || "5".equals(status)) { + OTHER_PROTECTIVE_MEASURES = (StringUtils.isNotBlank(pd2.getString("OTHER_PROTECTIVE_MEASURES")) ? pd2.getString("OTHER_PROTECTIVE_MEASURES") : "") + + (StringUtils.isNotBlank(pd.getString("OTHER_PROTECTIVE_MEASURES")) ? (pd.getString("OTHER_PROTECTIVE_MEASURES") + ";_;") : ";_;"); +// pd2.put("OTHER_PROTECTIVE_MEASURES", (StringUtils.isNotBlank(pd2.getString("OTHER_PROTECTIVE_MEASURES")) ? pd2.getString("OTHER_PROTECTIVE_MEASURES") : "") + +// (StringUtils.isNotBlank(pd.getString("OTHER_PROTECTIVE_MEASURES")) ? (pd.getString("OTHER_PROTECTIVE_MEASURES") + ";_;") : ";_;")); +// pd2.put("HAZARD_IDENTIFICATION", (StringUtils.isNotBlank(pd2.getString("HAZARD_IDENTIFICATION")) ? pd2.getString("HAZARD_IDENTIFICATION") : "") + +// (StringUtils.isNotBlank(pd.getString("HAZARD_IDENTIFICATION")) ? (pd.getString("HAZARD_IDENTIFICATION") + ";_;") : ";_;")); + } else if ("-2".equals(status) || "-3".equals(status) || "-4".equals(status) || "-5".equals(status) || "-6".equals(status)) { + //打回清空数据 + pd2.put("OTHER_PROTECTIVE_MEASURES", ""); +// pd2.put("HAZARD_IDENTIFICATION", ""); + } + switch (status) { + + case "6"://验收人 + List fileList = new ArrayList(); + String signertime = ""; + String SIGNTIME[] = pd.getString("SIGNTIME").split(","); + + for (int i = 0; i < SIGNTIME.length; i++) { + signertime = SIGNTIME[i]; + fileList.add(request.getFile("file"+i)); + MultipartFile[] fileArr = new MultipartFile[fileList.size()]; + saveAcceptImg(fileList.toArray(fileArr),signertime,pd.getString("HIGHWORK_ID"),pd.getString("CORPINFO_ID"),pd.getString("ACCEPT_USER_ID"),pd.getString("ACCEPT_DEPARTMENT_ID")); + fileList.clear(); + } + pd2.put("ACCEPT_CONTENT", pd.get("CONTENT")); + pd2.put("OTHER_PROTECTIVE_MEASURES", OTHER_PROTECTIVE_MEASURES); + pd2.put("APPLY_STATUS", pd.get("APPLY_STATUS")); + GFhighworkService.edit(pd2); + log.put("ACTION", "验收通过"); + + // 发短信 + PageData mes = new PageData(); + mes.put("RECEIVER_ID", pd2.get("CREATOR"));// 收信人userid + mes.put("templateCode", "GK_Y06");// 短信模板编码 + mes.put("SMSCode", "SMS_227250920");// 短信模板编码 + mes.put("CORPINFO_ID", pd2.get("CORPINFO_ID"));// 企业id + // 参数集合 + List paramsList = new ArrayList(); + // 第1个参数 + PageData params1 = new PageData(); + params1.put("name", "number");// 存入短信模板中的参数名称 + params1.put("value", pd2.get("CHECK_NO"));// 存入上面参数名称所传递的值 + paramsList.add(params1); + // 第2个参数 + PageData params2 = new PageData(); + params2.put("name", "type");// 存入短信模板中的参数名称 + params2.put("value", "高空作业");// 存入上面参数名称所传递的值 + paramsList.add(params2); + sendMessageUtil.sendMessages(mes, paramsList); + + break; + case "-6"://验收人打回 + log.put("ACTION", "验收人打回"); + pd2.put("APPLY_STATUS", pd.get("APPLY_STATUS")); + pd2.put("ACCEPT_CONTENT", pd.get("CONTENT")); + GFhighworkService.edit(pd2); + + + // 发短信 + PageData mes3 = new PageData(); + mes3.put("RECEIVER_ID", pd2.get("CREATOR"));// 收信人userid + mes3.put("templateCode", "GK_N06");// 短信模板编码 + mes3.put("SMSCode", "SMS_223580715");// 短信模板编码 + mes3.put("CORPINFO_ID", pd2.get("CORPINFO_ID"));// 企业id + // 参数集合 + List paramsList3 = new ArrayList(); + // 第1个参数 + PageData params10 = new PageData(); + params10.put("name", "params1");// 存入短信模板中的参数名称 + params10.put("value", pd2.get("CHECK_NO"));// 存入上面参数名称所传递的值 + paramsList3.add(params10); + // 第2个参数 + PageData params11 = new PageData(); + params11.put("name", "params2");// 存入短信模板中的参数名称 + params11.put("value", "高空作业");// 存入上面参数名称所传递的值 + paramsList3.add(params11); + // 第3个参数 + PageData params12 = new PageData(); + params12.put("name", "params3");// 存入短信模板中的参数名称 + params12.put("value", "验收人");// 存入上面参数名称所传递的值 + paramsList3.add(params12); + sendMessageUtil.sendMessages(mes3, paramsList3); + break; + default: + break; + } + GFhighWorkLogService.save(log); + map.put("result", errInfo); + return map; + } + private void saveAcceptImg(MultipartFile[] files,String signertime, String HIGHWORK_ID, String CORPINFO_ID, String ACCEPT_USER_ID, String ACCEPT_DEPARTMENT_ID) throws Exception{ + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + PageData cpd = new PageData(); + cpd = this.getPageData(); + MultipartFile file = files[i]; + String ffile = DateUtil.getDays(); + String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + smb.sshSftp(file, fileName,Const.FILEPATHFILE + CORPINFO_ID + "/" + ffile); + cpd.put("ACCEPT_USER_SIGNER_TIME", signertime); + cpd.put("ACCEPT_CONFESS_ID", this.get32UUID()); + cpd.put("OPERATOR", cpd.get("OPERATOR")); //修改人 + cpd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + cpd.put("ACCEPT_USER_SIGNER_PATH", Const.FILEPATHFILE + CORPINFO_ID + "/" + ffile + "/" + fileName); + cpd.put("ISDELETE", '0'); + cpd.put("CORPINFO_ID", CORPINFO_ID); + cpd.put("HIGHWORK_ID", HIGHWORK_ID); + cpd.put("ACCEPT_USER_ID", ACCEPT_USER_ID); + cpd.put("ACCEPT_CONFESS_DEPARTMENT_ID", ""); + cpd.put("ACCEPT_CONFESS_USER_ID", ""); + cpd.put("ACCEPT_DEPARTMENT_ID", ACCEPT_DEPARTMENT_ID); + highworkacceptuserService.save(cpd); + } + } + } + /**修改 * @param * @throws Exception @@ -394,7 +576,7 @@ public class AppGFHighWorkController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); + smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd2.put("CONSTRUCTION_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd2.put("CONSTRUCTION_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); @@ -417,7 +599,7 @@ public class AppGFHighWorkController extends BaseController { PageData measures = new PageData(); measures.put("HIGHWORKTOMEASURES_ID", this.get32UUID()); // 主键 measures.put("HIGHWORK_ID", pd2.get("HIGHWORK_ID")); - measures.put("BUS_HIGHWORK_MEASURES_ID", json.get("HIGHWORK_MEASURES_ID")); + measures.put("BUS_HIGHWORK_MEASURES_ID", json.get("BUS_HIGHWORK_MEASURES_ID")); measures.put("STATUS", json.get("STATUS")); measures.put("CONFIRM_ID", pd.get("OPERATOR")); measures.put("CONFIRM_NAME", pd.get("ACTION_USER")); @@ -481,7 +663,7 @@ public class AppGFHighWorkController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); + smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd2.put("LEADER_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd2.put("LEADER_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); @@ -547,7 +729,7 @@ public class AppGFHighWorkController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); + smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd2.put("AUDIT_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd2.put("AUDIT_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); @@ -605,7 +787,7 @@ public class AppGFHighWorkController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); + smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd2.put("APPROVE_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd2.put("APPROVE_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); @@ -653,7 +835,7 @@ public class AppGFHighWorkController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); + smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd2.put("ACCEPT_USER_SIGNER_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd2.put("ACCEPT_USER_SIGNER_TIME", pd.get("SIGNER_TIME")); @@ -943,6 +1125,8 @@ public class AppGFHighWorkController extends BaseController { pd = GFhighworkService.findById(pd); //根据ID读取 map.put("measuresList", GFhighworkService.listAllMeasures(pd)); map.put("pd", pd); + map.put("imgList1",highworkacceptuserService.findById(pd)); + map.put("imgList",highworkacceptuserService.findByIds(pd)); map.put("result", errInfo); return map; }