From 6c16f4dc8e1a5bef7b5bbc7abbc26c74aaab9aae Mon Sep 17 00:00:00 2001 From: liujun Date: Mon, 26 Feb 2024 15:17:24 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=9B=86=E5=9B=A2=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8A=E4=BC=A0=E6=89=BF=E8=AF=BA=E4=B9=A6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=202=E3=80=81=E6=96=87=E4=BB=B6=E5=8D=95?= =?UTF-8?q?=E4=BC=A0=E5=8F=98=E5=A4=9A=E4=BC=A0=203=E3=80=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E4=B8=8B=E8=BD=BD=E9=99=84=E8=BF=91=E5=90=88?= =?UTF-8?q?=E9=9B=86=204=E3=80=81=E4=BF=AE=E6=94=B9=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9C=AA=E6=B8=85=E7=A9=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/xgf/FlowTrainController.java | 37 ++++++ .../controller/xgf/XgfUserController.java | 17 +++ .../zcloud/service/xgf/XgfUserService.java | 3 + .../service/xgf/impl/XgfUserServiceImpl.java | 25 ++++ src/main/java/com/zcloud/util/Warden.java | 117 +++++++++++++++++- .../datasource/xgf/XgfUserDetailsMapper.xml | 14 ++- .../mybatis/datasource/xgf/XgfUserMapper.xml | 3 +- 7 files changed, 206 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zcloud/controller/xgf/FlowTrainController.java b/src/main/java/com/zcloud/controller/xgf/FlowTrainController.java index 353793ec..b81c7e6e 100644 --- a/src/main/java/com/zcloud/controller/xgf/FlowTrainController.java +++ b/src/main/java/com/zcloud/controller/xgf/FlowTrainController.java @@ -164,4 +164,41 @@ public class FlowTrainController extends BaseController { map.put("result", "success"); return map; } + /** + * 获取流程节点名称 + * @date 2024-02-23 + * @author liu jun + */ + @RequestMapping(value = "/getPintName") + @ResponseBody + public Object getPintName() throws Exception { + PageData request = this.getPageData(); + if (StringUtils.isEmpty(request.getString("FLOWS_TYPE"))) + throw new Exception("FLOWS_TYPE不能为空"); + Map map = new HashMap(); + if ("1".equals(request.getString("FLOWS_TYPE"))) { + switch (request.getString("FLOWS_STEP")) { + case "0": + map.put("Department", "指定主管部门"); + map.put("User", "指定主管部门审批人"); + map.put("UploadFile", "承诺书"); + break; + case "1": + case "2": + map.put("Department", "指定监管部门"); + map.put("User", "指定监管部门审批人"); + break; + default: + throw new Exception("FLOWS_STEP不合法"); + } + } else{ + if (request.getString("FLOWS_STEP").equals("0")) { + map.put("Department", "监管部门"); + map.put("User", "监管部门审批人"); + } + } + + map.put("result", "success"); + return map; + } } diff --git a/src/main/java/com/zcloud/controller/xgf/XgfUserController.java b/src/main/java/com/zcloud/controller/xgf/XgfUserController.java index 30e5c597..15352eb0 100644 --- a/src/main/java/com/zcloud/controller/xgf/XgfUserController.java +++ b/src/main/java/com/zcloud/controller/xgf/XgfUserController.java @@ -10,7 +10,9 @@ import com.zcloud.util.Jurisdiction; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; 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 javax.annotation.Resource; import java.util.HashMap; @@ -57,6 +59,21 @@ public class XgfUserController extends BaseController { return response; } + + /** + * 人员信息审核 + */ + @RequestMapping(value = "/approvePlus") + @ResponseBody + public Object approvePlus(@RequestParam(value="chengNuoShu",required=false) MultipartFile[] chengNuoShu) throws Exception { + PageData request = this.getPageData(); + xgfUserService.approvePlus(request,chengNuoShu); + PageData response = new PageData(); + response.put("result", "success"); + response.put("data", request); + return response; + } + @RequestMapping(value = "/regulatoryUserList") @ResponseBody public Object regulatoryUserList() throws Exception{ diff --git a/src/main/java/com/zcloud/service/xgf/XgfUserService.java b/src/main/java/com/zcloud/service/xgf/XgfUserService.java index eb0c20a5..75b28f95 100644 --- a/src/main/java/com/zcloud/service/xgf/XgfUserService.java +++ b/src/main/java/com/zcloud/service/xgf/XgfUserService.java @@ -2,6 +2,7 @@ package com.zcloud.service.xgf; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; +import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -30,4 +31,6 @@ public interface XgfUserService { Object getApproveInfo(PageData request); Object getFlowInfo(PageData request); + + void approvePlus(PageData request, MultipartFile[] chengNuoShu) throws Exception; } diff --git a/src/main/java/com/zcloud/service/xgf/impl/XgfUserServiceImpl.java b/src/main/java/com/zcloud/service/xgf/impl/XgfUserServiceImpl.java index 2b5935c4..1376e98e 100644 --- a/src/main/java/com/zcloud/service/xgf/impl/XgfUserServiceImpl.java +++ b/src/main/java/com/zcloud/service/xgf/impl/XgfUserServiceImpl.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.ArrayList; @@ -138,6 +139,9 @@ public class XgfUserServiceImpl implements XgfUserService { x.put("STUDY_STATUS", entity.getString("STUDY_STATUS")); xgfUserMapper.edit(x); + // 2024-02-26 created by liu jun 清空上传文件信息 + x.put("ATTORNEY", ""); + x.put("COMMITMENT_LETTER", ""); xgfUserDetailsMapper.edit(x); } @@ -291,6 +295,9 @@ public class XgfUserServiceImpl implements XgfUserService { condition.put("APPOINT_DEPARTMENT_NAME", request.getString("APPOINT_DEPARTMENT_NAME")); condition.put("APPOINT_USER_ID", request.getString("APPOINT_USER_ID")); condition.put("APPOINT_USER_NAME", request.getString("APPOINT_USER_NAME")); + if (request.get("APPOINT_ANNEX") != null) { + condition.put("APPOINT_ANNEX", request.getString("APPOINT_ANNEX")); + } condition.put("FLOWS_ID", x); // 保存审批记录 @@ -453,6 +460,15 @@ public class XgfUserServiceImpl implements XgfUserService { return info; } + @Override + @Transactional + public void approvePlus(PageData request, MultipartFile[] chengNuoShu) throws Exception { + if (chengNuoShu != null && chengNuoShu.length > 0) { + request.put("APPOINT_ANNEX", Warden.saveFile(Warden.createZip(chengNuoShu),Jurisdiction.getCORPINFO_ID())); + } + this.approve(request); + } + /* 获取当前用户是否有权限审批 */ private String getPower(PageData x) { switch (Integer.parseInt(x.get("CHECK_STEP").toString())) { @@ -549,6 +565,14 @@ public class XgfUserServiceImpl implements XgfUserService { condition.put("XGF_USER_ID", flows.getString("FLOWS_ID")); PageData user = xgfUserMapper.findById(condition); user.put("CHECK_STEP", 1); + // created by liu jun 2024-02-26 如果有委托书则保存委托书 + if (StringUtils.isNotBlank(info.getString("APPOINT_ANNEX"))) { + condition.clear(); + condition.put("XGF_USER_DETAILS_ID", flows.getString("FLOWS_ID")); + PageData userInfo = xgfUserDetailsMapper.findById(condition); + userInfo.put("COMMITMENT_LETTER", info.getString("APPOINT_ANNEX")); + xgfUserDetailsMapper.edit(userInfo); + } xgfUserMapper.edit(user); return "0"; } @@ -881,6 +905,7 @@ public class XgfUserServiceImpl implements XgfUserService { nextNode.put("APPROVER_TIME", DateUtil.getTime()); nextNode.put("APPROVER_CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); nextNode.put("APPROVER_OPINION", info.get("OPINION")); + nextNode.put("APPOINT_ANNEX", info.getString("APPOINT_ANNEX")); if ("1".equals(Jurisdiction.getCORPINFO_ID())) { nextNode.put("APPROVER_CORPINFO_NAME", "秦皇岛股份有限公司"); } else { diff --git a/src/main/java/com/zcloud/util/Warden.java b/src/main/java/com/zcloud/util/Warden.java index 8f2b9c81..7163ff0a 100644 --- a/src/main/java/com/zcloud/util/Warden.java +++ b/src/main/java/com/zcloud/util/Warden.java @@ -5,24 +5,32 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; +import org.springframework.http.MediaType; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; public class Warden { @@ -294,5 +302,106 @@ public class Warden { } } + public static String saveFile(MultipartFile[] files, String number) throws Exception{ + if (files.length == 0) throw new RuntimeException("文件为空"); + MultipartFile file = files[0]; + String ffile = DateUtil.getDays(); + String fileName = get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + Smb.sshSftp(file, fileName, Const.FILEPATHFILE + number + "/" + ffile); + return Const.FILEPATHFILE + number + "/" + ffile + "/" + fileName; + } + + public static String saveFile(MultipartFile file, String CORPINFO_ID) throws Exception{ + MultipartFile[] files = new MultipartFile[1]; + files[0] = file; + return saveFile(files, CORPINFO_ID); + } + + /** + * 压缩文件 + */ + public static MultipartFile createZip(MultipartFile[] chenNuoShu) throws Exception{ + return zipFiles(convertToFile(chenNuoShu)); + } + + public static List convertToFile(MultipartFile[] files) throws Exception { + List lstFile = new ArrayList<>(); + if (files.length == 0) { + throw new RuntimeException("文件为空"); + } + for (MultipartFile file : files) { + if (file.equals("") || file.getSize() <= 0) { + continue; + } else { + InputStream ins; + ins = file.getInputStream(); + File toFile = new File(file.getOriginalFilename()); + inputStreamToFile(ins, toFile); + lstFile.add(toFile); + ins.close(); + } + } + return lstFile; + } + + /** + * 获取流文件 + * + * @param ins + * @param file + */ + public static void inputStreamToFile(InputStream ins, File file) { + try { + OutputStream os = Files.newOutputStream(file.toPath()); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static MultipartFile zipFiles(List srcFiles) throws IOException { + Date date = new Date(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dxfFileName = formatter.format(date).replace(" ", "_").replace(":", "-"); + + FileInputStream fileInputStream; + ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); + try (ZipOutputStream zipOut = new ZipOutputStream(byteOutStream)) { + + for (File file : srcFiles) { + fileInputStream = new FileInputStream(file); + ZipEntry zipEntry = new ZipEntry(file.getName()); + zipOut.putNextEntry(zipEntry); + int len; + byte[] buffer = new byte[1024]; + while ((len = fileInputStream.read(buffer)) > 0) { + zipOut.write(buffer, 0, len); + } + fileInputStream.close(); + } + zipOut.flush(); + zipOut.closeEntry(); + zipOut.close(); + + + InputStream inputStream = new ByteArrayInputStream(byteOutStream.toByteArray()); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem item = factory.createItem("file", MediaType.MULTIPART_FORM_DATA_VALUE, true, LocalDateTime.now() + ".zip"); + OutputStream os = item.getOutputStream(); + IOUtils.copy(inputStream, os); + + return new CommonsMultipartFile(item); + } catch (IOException e) { + e.printStackTrace(); + } + throw new IOException("压缩文件失败"); + } } diff --git a/src/main/resources/mybatis/datasource/xgf/XgfUserDetailsMapper.xml b/src/main/resources/mybatis/datasource/xgf/XgfUserDetailsMapper.xml index 7fb9f491..ed640710 100644 --- a/src/main/resources/mybatis/datasource/xgf/XgfUserDetailsMapper.xml +++ b/src/main/resources/mybatis/datasource/xgf/XgfUserDetailsMapper.xml @@ -65,7 +65,8 @@ f.SOCIAL_NUMBER, f.zzName, f.ANNEX, - f.ATTORNEY + f.ATTORNEY, + f.COMMITMENT_LETTER @@ -126,7 +127,8 @@ SOCIAL_NUMBER, zzName, ANNEX, - ATTORNEY + ATTORNEY, + COMMITMENT_LETTER @@ -187,7 +189,8 @@ #{SOCIAL_NUMBER}, #{zzName}, #{ANNEX}, - #{ATTORNEY} + #{ATTORNEY}, + #{COMMITMENT_LETTER} @@ -272,7 +275,8 @@ SOCIAL_NUMBER = #{SOCIAL_NUMBER}, zzName = #{zzName}, ANNEX = #{ANNEX}, - ATTORNEY = #{ATTORNEY} + ATTORNEY = #{ATTORNEY}, + COMMITMENT_LETTER = #{COMMITMENT_LETTER} where XGF_USER_DETAILS_ID = #{XGF_USER_DETAILS_ID} @@ -285,7 +289,7 @@ f where - f.XFG_USER_DETAILS_ID = #{XFG_USER_DETAILS_ID} + f.XGF_USER_DETAILS_ID = #{XGF_USER_DETAILS_ID} diff --git a/src/main/resources/mybatis/datasource/xgf/XgfUserMapper.xml b/src/main/resources/mybatis/datasource/xgf/XgfUserMapper.xml index 44a11118..2de37005 100644 --- a/src/main/resources/mybatis/datasource/xgf/XgfUserMapper.xml +++ b/src/main/resources/mybatis/datasource/xgf/XgfUserMapper.xml @@ -298,7 +298,8 @@ b.zzName, b.POLITICAL_TIME, b.ANNEX, - b.ATTORNEY + b.ATTORNEY, + b.COMMITMENT_LETTER from xgf_user a left join xgf_user_details b on a.XGF_USER_ID = b.XGF_USER_ID where a.IS_DELETE = '0'