From 02c132ac41f3ff5dec4d9e7206cd94dbd0325f90 Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Fri, 1 Mar 2024 20:27:00 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E7=BB=86=E8=8A=82=E5=AE=8C=E5=96=84=202.?= =?UTF-8?q?=20BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/biutag/enums/RoleEnum.java | 9 +++++ .../biutag/lan/controller/FileController.java | 6 ++- .../biutag/lan/flow/node/SecondSignFlow.java | 2 +- .../lan/flow/node/ThreeContactWriterFlow.java | 1 - .../com/biutag/lan/service/WorkService.java | 38 ++++++++++++++----- .../service/impl/PoliceUserServiceImpl.java | 27 ++++++++----- .../system/PoliceUserUpdateValidate.java | 3 -- .../lan/vo/system/PoliceUserInformVo.java | 2 + .../src/test/java/com/biutag/lan/AESTest.java | 37 +++++++++++------- 9 files changed, 87 insertions(+), 38 deletions(-) diff --git a/mailbox-common/src/main/java/com/biutag/enums/RoleEnum.java b/mailbox-common/src/main/java/com/biutag/enums/RoleEnum.java index 099ab47..aca4416 100644 --- a/mailbox-common/src/main/java/com/biutag/enums/RoleEnum.java +++ b/mailbox-common/src/main/java/com/biutag/enums/RoleEnum.java @@ -29,4 +29,13 @@ public enum RoleEnum { private String name; + public static RoleEnum get(Integer roleId) { + for (RoleEnum value : values()) { + if (value.getRoleId().equals(roleId)) { + return value; + } + } + return null; + } + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java index be5d664..2fcc698 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java @@ -47,7 +47,11 @@ public class FileController { @GetMapping("stream/**") public void download(HttpServletRequest request, HttpServletResponse response) throws IOException { String requestURI = request.getRequestURI(); - response.setContentType("application/octet-stream"); + if (requestURI.toLowerCase().endsWith(".pdf")) { + response.setContentType("application/pdf"); + } else { + response.setContentType("application/octet-stream"); + } minio.get(requestURI.substring("/api/file/stream/".length()), response.getOutputStream()); } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondSignFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondSignFlow.java index 9c44343..2b297f0 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondSignFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SecondSignFlow.java @@ -72,7 +72,7 @@ public class SecondSignFlow extends Flow { // 主责单位 if (work.getMainDeptFlag()) { mail.setUpdateTime(now) - .setFlowKey(FlowNodeEnum.FIRST_DISTRIBUTE.getKey()) + .setFlowKey(FlowNodeEnum.FIRST_SIGN.getKey()) .setFlowName(FlowNameEnum.MAIL_RETURN.getName()); } else { JSONObject firstDistributeInfo = JSON.parseObject(mail.getFirstDistributeInfo()); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeContactWriterFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeContactWriterFlow.java index 0ec6d35..3d8fd09 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeContactWriterFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeContactWriterFlow.java @@ -71,7 +71,6 @@ public class ThreeContactWriterFlow extends Flow { mail.setFlowKey(FlowNodeEnum.VERIFY.getKey()) .setFlowName(FlowNodeEnum.VERIFY.getFullName()); } - // 更新我的工作 Work work = workService.getOne(mailId, RoleEnum.THREE_DEPT_CLASSES.getRoleId(), AdminThreadLocal.getDeptId()); work.setFlowName(FlowNameEnum.INTERVIEW_WRITER.getName()).setUpdateTime(now); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java index c7763cd..bae5cd2 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java @@ -194,17 +194,35 @@ public class WorkService extends ServiceImpl { query.isNull("m.flow_key").or().ne("m.flow_key", FlowNodeEnum.COMPLETION.getKey()); }); Integer roleId = AdminThreadLocal.getRoleId(); + Integer deptId = AdminThreadLocal.getDeptId(); + String empNo = AdminThreadLocal.getEmpNo(); // 与角色相关的件 - if (roleId.equals(RoleEnum.MUNICIPAL_DEPT_CLASSES.getRoleId()) || - roleId.equals(RoleEnum.SECOND_DEPT_CLASSES.getRoleId()) || - roleId.equals(RoleEnum.THREE_DEPT_CLASSES.getRoleId())) { - Integer deptId = AdminThreadLocal.getDeptId(); - queryWrapper.eq("w.sign_role_id", roleId) - // 如果不是市局专班,则需要查询签收部门ID - .eq(!RoleEnum.MUNICIPAL_DEPT_CLASSES.getRoleId().equals(roleId), "w.sign_dept_id", deptId); - } else { - String empNo = AdminThreadLocal.getEmpNo(); - queryWrapper.eq("w.police_emp_no", empNo); + switch (roleId) { + // 市局专班 + case 1: { + queryWrapper.eq("w.sign_role_id", roleId); + break; + } + // 二级机构专班 + case 2: { + queryWrapper.eq("w.sign_role_id", roleId) + .eq("w.sign_dept_id", deptId); + break; + } + // 三级机构专班 + case 3: { + // 三级机构即是领导又是专班的情况 + queryWrapper.and(query -> { + query.eq("w.sign_role_id", roleId) + .eq("w.sign_dept_id", deptId) + .or() + .eq("w.police_emp_no", empNo); + }); + break; + } + default: { + queryWrapper.eq("w.police_emp_no", empNo); + } } if (StrUtil.isNotBlank(todoQuery.getContactField()) && StrUtil.isNotBlank(todoQuery.getContactFieldValue())) { switch (todoQuery.getContactField()) { diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java index a02636a..f9f4965 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.biutag.core.PageResult; import com.biutag.entity.system.*; +import com.biutag.enums.RoleEnum; import com.biutag.exception.OperateException; import com.biutag.lan.config.AdminThreadLocal; import com.biutag.lan.enums.PostEnums; @@ -226,14 +227,22 @@ public class PoliceUserServiceImpl implements IPoliceUserService { .eq("is_delete", 0) .eq("id", adminId) .last("limit 1")); - - PoliceUserInformVo policeUserInformVo = new PoliceUserInformVo(); - BeanUtils.copyProperties(sysAdmin, policeUserInformVo); - policeUserInformVo.setAvatar(UrlUtils.toAbsoluteUrl(sysAdmin.getAvatar())); - policeUserInformVo.setUpdateTime(TimeUtils.timestampToDate(sysAdmin.getUpdateTime())); - policeUserInformVo.setCreateTime(TimeUtils.timestampToDate(sysAdmin.getCreateTime())); - policeUserInformVo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLastLoginTime())); - policeUserInformVo.setRoleName(AdminThreadLocal.getRoleName()); + PoliceUserInformVo informVo = new PoliceUserInformVo(); + BeanUtils.copyProperties(sysAdmin, informVo); + informVo.setAvatar(UrlUtils.toAbsoluteUrl(sysAdmin.getAvatar())); + informVo.setUpdateTime(TimeUtils.timestampToDate(sysAdmin.getUpdateTime())); + informVo.setCreateTime(TimeUtils.timestampToDate(sysAdmin.getCreateTime())); + informVo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLastLoginTime())); + informVo.setRoleName(AdminThreadLocal.getRoleName()); + Integer roleId = AdminThreadLocal.getRoleId(); + if (RoleEnum.MUNICIPAL_DEPT_CLASSES.getRoleId().equals(roleId)) { + informVo.setFullName(String.format("市局专班 %s", informVo.getName())); + } else if(RoleEnum.SECOND_DEPT_CLASSES.getRoleId().equals(roleId) || + RoleEnum.THREE_DEPT_CLASSES.getRoleId().equals(roleId)) { + informVo.setFullName(String.format("%s专班 %s", informVo.getDeptName(), informVo.getName())); + } else { + informVo.setFullName(String.format("%s %s", informVo.getDeptName(), informVo.getName())); + } // 角色权限 List auths = new LinkedList<>(); @@ -265,7 +274,7 @@ public class PoliceUserServiceImpl implements IPoliceUserService { // 返回数据 PoliceUserSelvesVo vo = new PoliceUserSelvesVo(); - vo.setUser(policeUserInformVo); + vo.setUser(informVo); vo.setPermissions(auths); return vo; } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/validate/system/PoliceUserUpdateValidate.java b/mailbox-lan/src/main/java/com/biutag/lan/validate/system/PoliceUserUpdateValidate.java index fbb9bbf..516ba18 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/validate/system/PoliceUserUpdateValidate.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/validate/system/PoliceUserUpdateValidate.java @@ -32,9 +32,6 @@ public class PoliceUserUpdateValidate implements Serializable { @ApiModelProperty(value = "姓名", required = true) private String name; - - @NotEmpty(message = "手机号不能为空") - @Length(min = 2, max = 30, message = "手机号必须在2~30个字符内") @ApiModelProperty(value = "手机号", required = true) private String mobile; diff --git a/mailbox-lan/src/main/java/com/biutag/lan/vo/system/PoliceUserInformVo.java b/mailbox-lan/src/main/java/com/biutag/lan/vo/system/PoliceUserInformVo.java index 13b3288..a4d933a 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/vo/system/PoliceUserInformVo.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/vo/system/PoliceUserInformVo.java @@ -54,4 +54,6 @@ public class PoliceUserInformVo implements Serializable { private String name; + private String fullName; + } diff --git a/mailbox-lan/src/test/java/com/biutag/lan/AESTest.java b/mailbox-lan/src/test/java/com/biutag/lan/AESTest.java index dfdf8d5..1cbb95f 100644 --- a/mailbox-lan/src/test/java/com/biutag/lan/AESTest.java +++ b/mailbox-lan/src/test/java/com/biutag/lan/AESTest.java @@ -8,7 +8,9 @@ import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; @@ -18,7 +20,7 @@ import java.util.Map; public class AESTest { - public static void main(String[] args) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException, NoSuchPaddingException, NoSuchAlgorithmException { + public static void main(String[] args) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException, NoSuchPaddingException, NoSuchAlgorithmException, UnsupportedEncodingException { Map datamap = new HashMap<>(); datamap.put("timeStamp", "1709208164"); datamap.put("mobiles", "15608487213"); @@ -27,24 +29,33 @@ public class AESTest { datamap.put("appendID", ""); datamap.put("sendTime", ""); datamap.put("validTime", ""); - String key = "fzzd12345678dxpt"; // 16字节密钥 - SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES"); - // 创建AES加密实例 - Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); String s = "{\"timeStamp\":\"1709208164\",\"orderNo\":\"TEST001\",\"mobiles\":\"15608487213\",\"appendID\":\"\",\"validTime\":\"\",\"content\":\"123\",\"sendTime\":\"\"}"; - // 加密 - cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); - byte[] encryptedBytes = cipher.doFinal(Base64.getEncoder().encodeToString(JSON.toJSONString(datamap).getBytes(StandardCharsets.UTF_8)).getBytes()); - // Base64编码加密后的数据 - String base64Encoded = Base64.getEncoder().encodeToString(encryptedBytes); - System.out.println(base64Encoded); + String encrypt = encrypt(s); + System.out.println(encrypt); System.out.println("---------------------------------------"); String s1 = "dk0vL%2FHI%2FMgeyko9w%2F2buBdoNASCWHQLuc0VdNhlEPotf8P%2Fr%2F7iP9srgLBRnrignGZCXWeaZ8cf%0D%0AqexHGp4GO7LTM0tEg9IwOEOJdMJIbuF1qcdjr%2Fb8OqeLkpNP1Ai6UevoO6fcNoZ0yBOHceS8zZ%2Ba%0D%0Ak8fQtrgakYQV7KszrVOz%2B9EcGPFGLfWmFCsFwK1P8hPqywvtpZprdXSj4d2NrnhWCbt%2BZVt9GX2u%0D%0AAPRkQuYQAmNFFGZM1iF0Jx2vt%2BoN"; - System.out.println(URLDecoder.decode(s1)); + System.out.println(URLDecoder.decode(s1, "UTF-8")); } - + public static String encrypt(String val) { + try { + // 加密 + String key = "fzzd12345678dxpt"; // 16字节密钥 + SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES"); + // 创建AES加密实例 + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + byte[] encryptedBytes = cipher.doFinal(Base64.getEncoder().encodeToString(val.getBytes()).getBytes()); + + // Base64编码加密后的数据 + String base64Encoded = Base64.getEncoder().encodeToString(encryptedBytes); + return base64Encoded; + } catch (NoSuchPaddingException | IllegalBlockSizeException | NoSuchAlgorithmException | BadPaddingException | + InvalidKeyException e) { + throw new RuntimeException(e); + } + } }