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'