From caf61d8f859829eae5417f21f3052ff09fb5197b Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Mon, 4 Mar 2024 17:20:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?BUG=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/config/Minio.java | 3 +- .../com/biutag/entity/system/Holiday.java | 19 ++------- mailbox-lan/pom.xml | 6 +++ .../biutag/lan/config/AdminInterceptor.java | 11 +++-- .../biutag/lan/controller/HomeController.java | 32 ++++++++++++--- .../java/com/biutag/lan/domain/vo/WorkVo.java | 6 +++ .../lan/flow/node/FirstApprovalFlow.java | 6 +-- .../lan/flow/node/FirstDistributeFlow.java | 12 ++++++ .../biutag/lan/flow/node/FirstSignFlow.java | 19 +++++++-- .../biutag/lan/flow/node/SecondSignFlow.java | 6 ++- .../biutag/lan/flow/node/ThreeVerifyFlow.java | 2 +- .../com/biutag/lan/mapper/WorkMapper.java | 4 +- .../biutag/lan/service/IHolidayService.java | 9 ++++ .../lan/service/MailApprovalService.java | 4 ++ .../lan/service/MailCountersignService.java | 5 +++ .../service/MailExtensionApprovalService.java | 5 +++ .../com/biutag/lan/service/MailService.java | 21 ++++++---- .../com/biutag/lan/service/WorkService.java | 16 +++++++- .../lan/service/impl/HolidayServiceImpl.java | 41 ++++++++++++++++--- .../service/impl/PoliceUserServiceImpl.java | 33 ++++++++------- .../src/main/resources/application.yml | 2 +- .../src/main/resources/mapper/WorkMapper.xml | 39 +++++++++++++----- .../test/java/com/biutag/lan/FlowTest.java | 11 ++++- .../controller/LoginController.java | 4 +- sql/240304.sql | 2 + truncate.sql | 4 +- 26 files changed, 236 insertions(+), 86 deletions(-) create mode 100644 sql/240304.sql diff --git a/mailbox-common/src/main/java/com/biutag/config/Minio.java b/mailbox-common/src/main/java/com/biutag/config/Minio.java index 0252ec4..cfd620a 100644 --- a/mailbox-common/src/main/java/com/biutag/config/Minio.java +++ b/mailbox-common/src/main/java/com/biutag/config/Minio.java @@ -2,6 +2,7 @@ package com.biutag.config; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import com.biutag.exception.MinioOperateException; import com.biutag.util.IOUtil; import io.minio.*; @@ -47,7 +48,7 @@ public class Minio { public String upload(InputStream is, String originName) { try { String filepath = DateUtil.format(new Date(), "YYMMdd") + "/" + IdUtil.nanoId(8) + - Optional.ofNullable(originName).map(item -> "_" + item).orElse(""); + (StrUtil.isNotBlank(originName) && originName.contains(".") ? originName.substring(originName.lastIndexOf(".")) : ""); PutObjectArgs putObjectArgs = PutObjectArgs.builder() .object(filepath) .bucket(properties.getBucketName()) diff --git a/mailbox-common/src/main/java/com/biutag/entity/system/Holiday.java b/mailbox-common/src/main/java/com/biutag/entity/system/Holiday.java index 0f92282..f007bd5 100644 --- a/mailbox-common/src/main/java/com/biutag/entity/system/Holiday.java +++ b/mailbox-common/src/main/java/com/biutag/entity/system/Holiday.java @@ -3,11 +3,9 @@ package com.biutag.entity.system; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.util.Date; @Data @ApiModel("节假日实体") @@ -16,22 +14,13 @@ public class Holiday implements Serializable { private static final long serialVersionUID = 1L; @TableId(value="id", type= IdType.AUTO) - @ApiModelProperty(value = "") private Long id; - @ApiModelProperty(value = "") - private String holidayName; - @ApiModelProperty(value = "") - private String startDate; + private String date; - @ApiModelProperty(value = "") - private String endDate; + private String holidayFlag; + private String detail; - - @ApiModelProperty(value = "") - private String holidayType; - - @ApiModelProperty(value = "") - private Integer isWorkday; + private Integer year; } \ No newline at end of file diff --git a/mailbox-lan/pom.xml b/mailbox-lan/pom.xml index ad5fa77..ea9d3bc 100644 --- a/mailbox-lan/pom.xml +++ b/mailbox-lan/pom.xml @@ -120,6 +120,12 @@ junit test + + org.jetbrains + annotations + 24.1.0 + compile + diff --git a/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java b/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java index 66fdfdc..b1b6f9b 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java @@ -11,8 +11,10 @@ import com.biutag.entity.system.PoliceUser; import com.biutag.enums.ErrorEnum; import com.biutag.exception.BusinessException; import com.biutag.exception.LoginException; +import com.biutag.lan.service.IDeptService; import com.biutag.lan.service.IRoleService; import com.biutag.lan.mapper.PoliceUserMapper; +import com.biutag.lan.vo.system.DeptVo; import com.biutag.util.StringUtils; import com.biutag.util.YmlUtils; import jakarta.annotation.Resource; @@ -41,6 +43,9 @@ public class AdminInterceptor implements HandlerInterceptor { @Resource IRoleService roleService; + @Resource + IDeptService deptService; + /** * 前置处理器 * @@ -162,7 +167,6 @@ public class AdminInterceptor implements HandlerInterceptor { String errMsg = ErrorEnum.TOKEN_INVALID.getMsg(); throw new LoginException(errCode, errMsg); } - // 用户校验 PoliceUser adminUser = policeUserMapper.selectOne( new QueryWrapper() @@ -170,7 +174,6 @@ public class AdminInterceptor implements HandlerInterceptor { .eq("id", Integer.parseInt(id.toString())) .eq("is_delete", 0) .last("limit 1")); - // 删除校验 if (StringUtils.isNull(adminUser)) { Integer errCode = ErrorEnum.TOKEN_INVALID.getCode(); @@ -187,16 +190,16 @@ public class AdminInterceptor implements HandlerInterceptor { if (StrUtil.isBlank(adminUser.getRoleIds())) { throw new BusinessException("用户角色为空"); } + DeptVo deptVo = deptService.detail(Integer.parseInt(adminUser.getDeptIds())); // 写入线程 AdminThreadLocal.put("adminId", id); //AdminThreadLocal.put("username", adminUser.getUsername()); AdminThreadLocal.put("empNo", adminUser.getEmpNo()); - AdminThreadLocal.put("name", adminUser.getName()); + AdminThreadLocal.put("name", deptVo.getName()); AdminThreadLocal.put("roleIds", adminUser.getRoleIds()); AdminThreadLocal.put("deptIds", adminUser.getDeptIds()); AdminThreadLocal.put("deptName", adminUser.getDeptName()); // AdminThreadLocal.put("postIds", adminUser.getPostIds()); - AdminThreadLocal.put("roleName", roleService.detail(Integer.parseInt(adminUser.getRoleIds())).getName()); // 权限校验 diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java index 156d674..df5bc1d 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java @@ -3,11 +3,14 @@ package com.biutag.lan.controller; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.biutag.aop.NotPower; import com.biutag.core.AjaxResult; import com.biutag.enums.RoleEnum; import com.biutag.lan.config.AdminThreadLocal; +import com.biutag.lan.domain.Work; import com.biutag.lan.domain.bo.MailTotal; +import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.flow.FlowNodeEnum; import com.biutag.lan.service.MailMarkService; import com.biutag.lan.service.MailService; @@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -42,13 +46,30 @@ public class HomeController { Integer roleId = AdminThreadLocal.getRoleId(); Integer deptId = AdminThreadLocal.getDeptId(); if (roleId.equals(RoleEnum.MUNICIPAL_DEPT_CLASSES.getRoleId())) { - unSignTotal = mailSourceService.countByUnSign().intValue(); + unSignTotal = (int) workService.count(new LambdaQueryWrapper().in(Work::getFlowName, + // 待签收、待下发、信件退回 + Arrays.asList(FlowNameEnum.PENDING_SIGN.getName(), FlowNameEnum.PENDING_DISTRIBUTE.getName(), + FlowNameEnum.MAIL_RETURN.getName())) + .eq(Work::getSignRoleId, roleId) + .eq(Work::getWorkState, Work.State.todo.name())); } if (roleId.equals(RoleEnum.SECOND_DEPT_CLASSES.getRoleId())) { - unSignTotal = workService.count(FlowNodeEnum.SECOND_SIGN.getKey(), deptId); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .in(Work::getFlowName, + // 待签收、待下发、信件退回 + Arrays.asList(FlowNameEnum.PENDING_SIGN.getName(), FlowNameEnum.PENDING_DISTRIBUTE.getName(), FlowNameEnum.MAIL_RETURN.getName())) + .eq(Work::getSignRoleId, roleId) + .eq(Work::getSignDeptId, deptId) + .eq(Work::getWorkState, Work.State.todo.name()); + unSignTotal = (int) workService.count(queryWrapper); } if (roleId.equals(RoleEnum.THREE_DEPT_CLASSES.getRoleId())) { - unSignTotal = workService.count(FlowNodeEnum.THREE_SIGN.getKey(), deptId); + unSignTotal = (int) workService.count(new LambdaQueryWrapper().in(Work::getFlowName, + // 待签收 + Collections.singletonList(FlowNameEnum.PENDING_SIGN.getName())) + .eq(Work::getSignRoleId, roleId) + .eq(Work::getSignDeptId, deptId) + .eq(Work::getWorkState, Work.State.todo.name())); } Integer contactWriterTotal = workService.count(FlowNodeEnum.CONTACT_WRITER.getKey(), deptId); Integer interviewWriterTotal = workService.count(FlowNodeEnum.INTERVIEW_WRITER.getKey(), deptId); @@ -61,11 +82,10 @@ public class HomeController { FlowNodeEnum.SECOND_REPORTING.getKey(), FlowNodeEnum.FIRST_APPROVAL.getKey(), FlowNodeEnum.COUNTERSIGN.getKey()), deptId); - return AjaxResult.success(Arrays.asList(MailTotal.of("未签收", "un_sign", unSignTotal), - MailTotal.of("联系群众", "contact_writer", contactWriterTotal), + return AjaxResult.success(Arrays.asList(MailTotal.of("待签收下发", "un_sign", unSignTotal), + MailTotal.of("待联系群众", "contact_writer", contactWriterTotal), MailTotal.of("待接访群众", "interview_writer", interviewWriterTotal), MailTotal.of("待核查办理", "verify", verifyTotal), - // TODO MailTotal.of("申请延期", "extension", extensionTotal), MailTotal.of("待办结审批", "approval", approvalTotal) )); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/WorkVo.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/WorkVo.java index 6eccc65..6ad0ce3 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/WorkVo.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/WorkVo.java @@ -84,6 +84,12 @@ public class WorkVo { @ExcelProperty("流程限时") private Long flowLimitedRemainingTime; + private LocalDateTime flowLimitedLastHandlerTime; + + private Long limitedTime; + + private LocalDateTime createTime; + /** * 办理单位ID(三级单位) */ diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java index f540b2f..7f7d459 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java @@ -80,8 +80,8 @@ public class FirstApprovalFlow extends Flow { } mailService.updateById(mail); // 认定办结 - MailMark mailMark = new MailMark().setMailId(mailId) - .setSecondDeptId(mail.getSecondDeptId()) + MailMark mailMark = mailMarkService.getById(mailId); + mailMark.setSecondDeptId(mail.getSecondDeptId()) .setSecondDeptName(mail.getSecondDeptName()) .setThreeDeptId(mail.getThreeDeptId()) .setThreeDeptName(mail.getThreeDeptName()) @@ -89,7 +89,7 @@ public class FirstApprovalFlow extends Flow { .setCompletionTime(now) .setResolved(problemSolvingStatus ? AppConstants.TRUE : AppConstants.FALSE) .setSatisfied("非常满意".equals(satisfactionStatus) || "基本满意".equals(satisfactionStatus) ? AppConstants.TRUE : AppConstants.FALSE); - mailMarkService.save(mailMark); + mailMarkService.updateById(mailMark); } public Flow mailReturn(String mailId, JSONObject data) { diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstDistributeFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstDistributeFlow.java index 54b6275..08ae340 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstDistributeFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstDistributeFlow.java @@ -1,13 +1,16 @@ package com.biutag.lan.flow.node; import com.alibaba.fastjson2.JSONObject; +import com.biutag.constants.AppConstants; import com.biutag.enums.RoleEnum; import com.biutag.lan.domain.Mail; +import com.biutag.lan.domain.MailMark; import com.biutag.lan.domain.Work; import com.biutag.lan.flow.Flow; import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.flow.FlowNodeEnum; import com.biutag.lan.service.IDeptService; +import com.biutag.lan.service.MailMarkService; import com.biutag.lan.service.MailService; import com.biutag.lan.service.WorkService; import com.biutag.lan.vo.system.DeptVo; @@ -31,6 +34,7 @@ public class FirstDistributeFlow extends Flow { private final MailService mailService; private final WorkService workService; private final IDeptService deptService; + private final MailMarkService mailMarkService; @Transactional(rollbackFor = Exception.class) @Override @@ -77,6 +81,14 @@ public class FirstDistributeFlow extends Flow { .setFirstDistributeInfo(firstDistributeInfo.toJSONString()) .setMainDeptLevel(mainDeptLevel); mailService.updateById(mail); + + MailMark mailMark = new MailMark() + .setMailId(mailId) + .setSecondDeptId(mail.getSecondDeptId()) + .setSecondDeptName(mail.getSecondDeptName()) + .setCompleted(AppConstants.FALSE) + .setCompletionTime(now); + mailMarkService.save(mailMark); return nextNode; } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java index d6eda91..d1a7f6e 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstSignFlow.java @@ -11,9 +11,7 @@ import com.biutag.lan.enums.MailState; import com.biutag.lan.flow.Flow; import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.flow.FlowNodeEnum; -import com.biutag.lan.service.MailService; -import com.biutag.lan.service.MailSourceService; -import com.biutag.lan.service.WorkService; +import com.biutag.lan.service.*; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -31,6 +29,9 @@ public class FirstSignFlow extends Flow { private final MailService mailService; private final MailSourceService mailSourceService; private final WorkService workService; + private final MailApprovalService mailApprovalService; + private final MailExtensionApprovalService mailExtensionApprovalService; + private final MailCountersignService mailCountersignService; @Override @Transactional(rollbackFor = Exception.class) @@ -73,6 +74,7 @@ public class FirstSignFlow extends Flow { String mailSecondCategory = data.getString("mailSecondCategory"); String mailThreeCategory = data.getString("mailThreeCategory"); String mailCategory = data.getString("mailCategory"); + validMailExists(mailId); Mail mail = mailSource.toMail() // 办理中 .setMailState(MailState.processing.getValue()) @@ -97,6 +99,7 @@ public class FirstSignFlow extends Flow { Assert.notNull(threeDeptId, "三级办理单位不能为空"); LocalDateTime now = LocalDateTime.now(); MailSource mailSource = mailSourceService.getById(mailId); + validMailExists(mailId); Mail mail = mailSource.toMail() .setMailFirstCategory(mailFirstCategory) .setMailCategory(mailFirstCategory) @@ -118,6 +121,7 @@ public class FirstSignFlow extends Flow { Assert.hasText(invalidationReason, "判定理由不能为空"); LocalDateTime now = LocalDateTime.now(); MailSource mailSource = mailSourceService.getById(mailId); + validMailExists(mailId); Mail mail = mailSource.toMail() .setMailFirstCategory(mailFirstCategory) .setMailCategory(mailFirstCategory) @@ -132,4 +136,13 @@ public class FirstSignFlow extends Flow { return null; } + private void validMailExists(String mailId) { + if (mailService.exists(mailId)) { + // 如果存在则删除相关数据 + mailService.removeById(mailId); + mailApprovalService.remove(mailId); + mailExtensionApprovalService.remove(mailId); + mailCountersignService.remove(mailId); + } + } } 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 2b297f0..143822e 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 @@ -2,7 +2,6 @@ package com.biutag.lan.flow.node; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; -import com.biutag.enums.RoleEnum; import com.biutag.exception.BusinessException; import com.biutag.lan.config.AdminThreadLocal; import com.biutag.lan.domain.Mail; @@ -12,6 +11,7 @@ import com.biutag.lan.flow.ActionEnum; import com.biutag.lan.flow.Flow; import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.flow.FlowNodeEnum; +import com.biutag.lan.service.MailMarkService; import com.biutag.lan.service.MailReturnService; import com.biutag.lan.service.MailService; import com.biutag.lan.service.WorkService; @@ -36,6 +36,8 @@ public class SecondSignFlow extends Flow { private final MailReturnService mailReturnService; + private final MailMarkService mailMarkService; + @Override @Transactional(rollbackFor = Exception.class) public Flow next(String nextActionKey, String mailId, JSONObject data) { @@ -88,6 +90,8 @@ public class SecondSignFlow extends Flow { } // 更新信件 mailService.updateById(mail); + // 删除统计表 + mailMarkService.removeById(mailId); return null; } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java index 55292df..10c2800 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java @@ -172,7 +172,7 @@ public class ThreeVerifyFlow extends Flow { .setFlowName(nextNode.getFlowNode().getFullName()); // 当前节点操作对象 if (ActionEnum.offline.name().equals(nextActionKey)) { - mail.setCurrentOperator(String.format("%s专班", mail.getSecondDeptId())); + mail.setCurrentOperator(String.format("%s专班", mail.getSecondDeptName())); } else { String leaderEmpNo = data.getString("leaderEmpNo"); PoliceUser policeUser = policeUserService.getOneByEmpNo(leaderEmpNo); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/mapper/WorkMapper.java b/mailbox-lan/src/main/java/com/biutag/lan/mapper/WorkMapper.java index 2cff7a5..1637f52 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/mapper/WorkMapper.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/mapper/WorkMapper.java @@ -15,14 +15,14 @@ import java.util.Collection; public interface WorkMapper extends BaseMapper { - Page selectPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + Page selectPageBy(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); Page selectQueryPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); Integer selectCountByFlowKey(Collection flowKeys, Integer deptId); @Select("select count(w.id) from work w left join mail m on w.mail_id = m.id where m.flow_key = #{flowKey} and w.sign_dept_id = #{deptId}") - Integer selectCount(String flowKey, Integer deptId); + Integer selectCountBy(String flowKey, Integer deptId); @Select("select count(w.id) from work w left join mail m on w.mail_id = m.id where m.extension_flag = #{extensionFlag} and w.sign_dept_id = #{deptId}") Integer selectCountByExtensionFlag(Boolean extensionFlag, Integer deptId); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/IHolidayService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/IHolidayService.java index a24450f..8824653 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/IHolidayService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/IHolidayService.java @@ -1,5 +1,6 @@ package com.biutag.lan.service; +import com.biutag.entity.system.Holiday; import com.biutag.lan.validate.commons.PageValidate; import com.biutag.lan.validate.system.HolidayCreateValidate; import com.biutag.lan.validate.system.HolidayUpdateValidate; @@ -8,6 +9,10 @@ import com.biutag.lan.vo.system.HolidayListedVo; import com.biutag.lan.vo.system.HolidayDetailVo; import com.biutag.core.PageResult; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; + /** * 节假日服务接口类 * @author oumyye @@ -24,6 +29,8 @@ public interface IHolidayService { */ PageResult list(PageValidate pageValidate, HolidaySearchValidate searchValidate); + List list(List dates); + /** * 节假日详情 * @@ -57,4 +64,6 @@ public interface IHolidayService { */ void del(Integer id); + long getFlowRemainingTime(long limitedTime, LocalDateTime flowLimitedLastHandlerTime); + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailApprovalService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailApprovalService.java index 5e2a9ef..aed56de 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailApprovalService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailApprovalService.java @@ -44,4 +44,8 @@ public class MailApprovalService extends ServiceImpl().eq(MailApproval::getMailId, mailId).eq(MailApproval::getFlowKey, flowKey)); } + + public boolean remove(String mailId) { + return remove(new LambdaQueryWrapper().eq(MailApproval::getMailId, mailId)); + } } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailCountersignService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailCountersignService.java index 4b271cc..55d5e53 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailCountersignService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailCountersignService.java @@ -3,6 +3,7 @@ package com.biutag.lan.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.biutag.lan.domain.MailCountersign; +import com.biutag.lan.domain.MailExtensionApproval; import com.biutag.lan.mapper.MailCountersignMapper; import org.springframework.stereotype.Service; @@ -19,4 +20,8 @@ public class MailCountersignService extends ServiceImpl().eq(MailCountersign::getMailId, mailId)); } + public boolean remove(String mailId) { + return remove(new LambdaQueryWrapper().eq(MailCountersign::getMailId, mailId)); + } + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java index 98e1967..2b93f45 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java @@ -3,6 +3,7 @@ package com.biutag.lan.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.biutag.lan.config.AdminThreadLocal; +import com.biutag.lan.domain.MailApproval; import com.biutag.lan.domain.MailExtensionApproval; import com.biutag.lan.mapper.MailExtensionApprovalMapper; import org.springframework.stereotype.Service; @@ -30,4 +31,8 @@ public class MailExtensionApprovalService extends ServiceImpl().eq(MailExtensionApproval::getMailId, mailId)); + } } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java index 8e47981..125eff9 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java @@ -1,5 +1,6 @@ package com.biutag.lan.service; +import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; @@ -7,7 +8,9 @@ import cn.hutool.extra.spring.SpringUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.biutag.constants.AppConstants; import com.biutag.entity.system.Dept; +import com.biutag.entity.system.Holiday; import com.biutag.enums.RoleEnum; import com.biutag.exception.BusinessException; import com.biutag.lan.config.AdminThreadLocal; @@ -65,6 +68,8 @@ public class MailService extends ServiceImpl { private final IMailLabelService mailLabelService; + private final IHolidayService holidayService; + @Lazy @Autowired private List flowNodes; @@ -88,9 +93,6 @@ public class MailService extends ServiceImpl { .findFirst().orElse(null); } MailVo mailVo = MailVo.of(mail); - - - List flows = mailFlowService.list(mailId) // 时间倒叙 .stream().sorted(Comparator.comparing(MailFlow::getCreateTime).reversed()).collect(Collectors.toList()); @@ -100,7 +102,6 @@ public class MailService extends ServiceImpl { .setFlows(flows); // 部门会签 mailVo.setCountersigns(mailCountersignService.list(mailId)); - // 审批 List list = mailApprovalService.list(mailId); if (!list.isEmpty()) { @@ -137,7 +138,7 @@ public class MailService extends ServiceImpl { limitedTime += mail.getExtensionDays() * 24 * 60 * 60; } // 剩余时间 - long flowRemainingTime = limitedTime - Duration.between(mail.getFlowLimitedLastHandlerTime(), LocalDateTime.now()).getSeconds(); + long flowRemainingTime = holidayService.getFlowRemainingTime(limitedTime, mail.getFlowLimitedLastHandlerTime()); // 剩余时间百分比 int flowRemainingTimePercentage = flowRemainingTime <= 0 ? 0 : Long.valueOf(flowRemainingTime * 100 / limitedTime).intValue(); @@ -242,6 +243,8 @@ public class MailService extends ServiceImpl { countersignDeptIds = countersignDeptIds.stream().distinct().collect(Collectors.toList()); LocalDateTime now = LocalDateTime.now(); Mail mail = getById(mailId); + + List countersigns = mailCountersignService.list(mailId); // 更新信件 mail.setUpdateTime(now) .setFlowKey(nextNode.getFlowNode().getKey()) @@ -251,8 +254,8 @@ public class MailService extends ServiceImpl { .setCountersignPromoterDeptId(AdminThreadLocal.getDeptId()) .setCountersignPromoterDeptName(AdminThreadLocal.getDeptName()) .setCountersignRequirement(countersignRequirement) - .setCountersignTotal(countersignDeptIds.size()) - .setCountersignCompleted(0); + .setCountersignTotal(countersignDeptIds.size() + countersigns.size()) + .setCountersignCompleted(countersigns.size()); updateById(mail); Integer roleId = AdminThreadLocal.getRoleId(); @@ -348,4 +351,8 @@ public class MailService extends ServiceImpl { return DateUtil.format(new Date(), "yyyyMMddHHMM") + MailSource.Source.get(source).getKey() + zeroString + seqVal; } + public boolean exists(String mailId) { + return exists(new LambdaQueryWrapper().eq(Mail::getId, mailId)); + } + } 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 bae5cd2..262438b 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 @@ -1,6 +1,7 @@ package com.biutag.lan.service; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -17,8 +18,10 @@ import com.biutag.lan.domain.vo.MailExcel; import com.biutag.lan.domain.vo.QueryMailVo; import com.biutag.lan.domain.vo.WorkVo; import com.biutag.lan.enums.WorkType; +import com.biutag.lan.flow.Flow; import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.flow.FlowNodeEnum; +import com.biutag.lan.flow.node.FirstSignFlow; import com.biutag.lan.mapper.MailCategoryMapper; import com.biutag.lan.mapper.MailLabelMapper; import com.biutag.lan.mapper.MailMapper; @@ -59,6 +62,8 @@ public class WorkService extends ServiceImpl { @Resource private DeptMapper deptMapper; + private final IHolidayService holidayService; + public boolean saveBatch(List mailSources) { LocalDateTime now = LocalDateTime.now(); List list = mailSources.stream().map(mail -> { @@ -239,7 +244,7 @@ public class WorkService extends ServiceImpl { } // 排序 queryWrapper.orderByDesc("w.update_time"); - Page workVoPage = baseMapper.selectPage(page, queryWrapper); + Page workVoPage = baseMapper.selectPageBy(page, queryWrapper); workVoPage.getRecords().forEach(item -> { // 会签中 if (FlowNameEnum.COUNTERSIGNING.getName().equals(item.getFlowName())) { @@ -249,6 +254,12 @@ public class WorkService extends ServiceImpl { item.setFlowName(String.format("%s(%s/%s)", item.getFlowName(), item.getCountersignCompleted(), item.getCountersignTotal())); } } + if (Objects.nonNull(item.getLimitedTime())) { + item.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTime(item.getLimitedTime(), item.getFlowLimitedLastHandlerTime())); + } else { + Flow flow = SpringUtil.getBean(FirstSignFlow.class); + item.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTime(flow.getFlowNode().getLimitedTime(), item.getCreateTime())); + } }); return workVoPage; } @@ -291,7 +302,7 @@ public class WorkService extends ServiceImpl { } public Integer count(String flowKey, Integer deptId) { - return baseMapper.selectCount(flowKey, deptId); + return baseMapper.selectCountBy(flowKey, deptId); } public Integer count(Collection flowKeys, Integer deptId) { @@ -461,4 +472,5 @@ public class WorkService extends ServiceImpl { EasyExcel.read(file.getInputStream(), MailExcel.class, excelService).sheet().doRead(); return AjaxResult.success(excelService.getResult()); } + } \ No newline at end of file diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/HolidayServiceImpl.java b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/HolidayServiceImpl.java index 40c08a0..382ed8e 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/HolidayServiceImpl.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/HolidayServiceImpl.java @@ -1,8 +1,11 @@ package com.biutag.lan.service.impl; +import cn.hutool.core.date.DatePattern; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.biutag.constants.AppConstants; import com.biutag.lan.validate.commons.PageValidate; import com.biutag.lan.service.IHolidayService; import com.biutag.lan.validate.system.HolidayCreateValidate; @@ -19,6 +22,8 @@ import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import java.time.Duration; +import java.time.LocalDateTime; import java.util.*; /** @@ -73,6 +78,12 @@ public class HolidayServiceImpl implements IHolidayService { return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list); } + @Override + public List list(List dates) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().in(Holiday::getDate, dates); + return holidayMapper.selectList(queryWrapper); + } + /** * 节假日详情 * @@ -103,9 +114,6 @@ public class HolidayServiceImpl implements IHolidayService { @Override public void add(HolidayCreateValidate createValidate) { Holiday model = new Holiday(); - model.setStartDate(createValidate.getStartDate()); - model.setHolidayName(createValidate.getHolidayName()); - model.setEndDate(createValidate.getEndDate()); holidayMapper.insert(model); } @@ -125,9 +133,6 @@ public class HolidayServiceImpl implements IHolidayService { Assert.notNull(model, "数据不存在!"); model.setId(updateValidate.getId()); - model.setStartDate(updateValidate.getStartDate()); - model.setHolidayName(updateValidate.getHolidayName()); - model.setEndDate(updateValidate.getEndDate()); holidayMapper.updateById(model); } @@ -149,4 +154,28 @@ public class HolidayServiceImpl implements IHolidayService { holidayMapper.delete(new QueryWrapper().eq("id", id)); } + /** + * 获取剩余时间 + * @return + */ + public long getFlowRemainingTime(long limitedTime, LocalDateTime flowLimitedLastHandlerTime) { + // 86400 s 一天 + if (limitedTime < 86400) { + return limitedTime - Duration.between(flowLimitedLastHandlerTime, LocalDateTime.now()).getSeconds(); + } + LocalDateTime now = LocalDateTime.now(); + String nowDate = now.format(DatePattern.NORM_DATE_FORMATTER); + ArrayList dates = new ArrayList<>(); + for (LocalDateTime dateTime = flowLimitedLastHandlerTime; dateTime.isBefore(now); dateTime = dateTime.plusDays(1)) { + dates.add(dateTime.format(DatePattern.NORM_DATE_FORMATTER)); + } + List list = list(dates); + long holidays = list.stream().filter(item -> item.getHolidayFlag().equals(AppConstants.YES) && !item.getDate().equals(nowDate)).count(); + long todaySeconds = list.stream().anyMatch(item -> item.getHolidayFlag().equals(AppConstants.YES) && item.getDate().equals(nowDate)) ? 0 : + // 当天的时间差 + Duration.between(now, now.toLocalDate().atStartOfDay()).getSeconds(); + limitedTime += 86400 * holidays + todaySeconds; + return limitedTime - Duration.between(flowLimitedLastHandlerTime, LocalDateTime.now()).getSeconds(); + } + } 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 0e1c224..00c82fa 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 @@ -13,6 +13,7 @@ import com.biutag.exception.OperateException; import com.biutag.lan.config.AdminThreadLocal; import com.biutag.lan.enums.PostEnums; import com.biutag.lan.mapper.PoliceUserMapper; +import com.biutag.lan.service.IDeptService; import com.biutag.lan.service.IPermService; import com.biutag.lan.service.IPoliceUserService; import com.biutag.lan.validate.commons.PageValidate; @@ -20,10 +21,7 @@ import com.biutag.lan.validate.system.PoliceUserCreateValidate; import com.biutag.lan.validate.system.PoliceUserSearchValidate; import com.biutag.lan.validate.system.PoliceUserUpInfoValidate; import com.biutag.lan.validate.system.PoliceUserUpdateValidate; -import com.biutag.lan.vo.system.PoliceUserDetailVo; -import com.biutag.lan.vo.system.PoliceUserInformVo; -import com.biutag.lan.vo.system.PoliceUserListedVo; -import com.biutag.lan.vo.system.PoliceUserSelvesVo; +import com.biutag.lan.vo.system.*; import com.biutag.mapper.system.MenuMapper; import com.biutag.mapper.system.PoliceDepartMapper; import com.biutag.mapper.system.PolicePositionMapper; @@ -61,6 +59,9 @@ public class PoliceUserServiceImpl implements IPoliceUserService { @Resource IPermService iPermService; + @Resource + IDeptService deptService; + /** * 管理员列表 * @@ -74,7 +75,7 @@ public class PoliceUserServiceImpl implements IPoliceUserService { Integer page = pageValidate.getPageNo(); Integer limit = pageValidate.getPageSize(); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(StrUtil.isNotBlank(searchValidate.getEmpNo()), "u.emp_no", searchValidate.getEmpNo()) + queryWrapper.eq(StrUtil.isNotBlank(searchValidate.getEmpNo()), "u.emp_no", StrUtil.trim(searchValidate.getEmpNo())) .like(StrUtil.isNotBlank(searchValidate.getName()), "u.name", searchValidate.getName()) .like(StrUtil.isNotBlank(searchValidate.getIdCode()), "u.id_code", searchValidate.getIdCode()) .eq(Objects.nonNull(searchValidate.getRole()), "u.role_ids", searchValidate.getRole()) @@ -134,7 +135,6 @@ public class PoliceUserServiceImpl implements IPoliceUserService { .like("emp_no", searchName).or() .like("mobile", searchName) .orderByDesc( "sort"); - return policeUserMapper.selectList(queryWrapper); } @@ -276,8 +276,10 @@ public class PoliceUserServiceImpl implements IPoliceUserService { PoliceUser model = new PoliceUser(); model.setRoleIds(createValidate.getRoleIds().toString()); - this.batchSaveRoleByEmpNo(createValidate.getEmpNo(), Arrays.asList(createValidate.getRoleIds())); + DeptVo deptVo = deptService.detail(createValidate.getDeptIds()); model.setDeptIds(createValidate.getDeptIds().toString()); + model.setDeptName(deptVo.getName()); + this.batchSaveDepartByEmpNo(createValidate.getEmpNo(), Arrays.asList(createValidate.getDeptIds())); model.setPostIds(createValidate.getPostIds().toString()); this.batchSavePositionByEmpNo(createValidate.getEmpNo(), Arrays.asList(createValidate.getPostIds())); @@ -331,18 +333,15 @@ public class PoliceUserServiceImpl implements IPoliceUserService { Assert.notNull(policeUser, "警号已存在换一个吧!"); PoliceUser model = new PoliceUser(); model.setId(updateValidate.getId()); - if(Objects.nonNull(updateValidate.getRoleIds())) { - model.setRoleIds(updateValidate.getRoleIds().toString()); - if(!policeUser.getRoleIds().equals(model.getRoleIds())){ - this.batchSaveRoleByEmpNo(updateValidate.getEmpNo(), Collections.singletonList(updateValidate.getRoleIds())); - } + model.setRoleIds(updateValidate.getRoleIds().toString()); + if(!policeUser.getRoleIds().equals(model.getRoleIds())){ + this.batchSaveRoleByEmpNo(updateValidate.getEmpNo(), Collections.singletonList(updateValidate.getRoleIds())); } - if(StringUtils.isNotNull(updateValidate.getDeptIds())) { - if(!policeUser.getDeptIds().equals(model.getDeptIds())){ - this.batchSaveDepartByEmpNo(updateValidate.getEmpNo(), Collections.singletonList(updateValidate.getDeptIds())); - } - } + DeptVo deptVo = deptService.detail(updateValidate.getDeptIds()); + model.setDeptIds(updateValidate.getDeptIds().toString()); + model.setDeptName(deptVo.getName()); + if(StringUtils.isNotNull(updateValidate.getPostIds())) { if(!policeUser.getPostIds().equals(model.getPostIds())){ this.batchSavePositionByEmpNo(updateValidate.getEmpNo(), Collections.singletonList(updateValidate.getPostIds())); diff --git a/mailbox-lan/src/main/resources/application.yml b/mailbox-lan/src/main/resources/application.yml index 913a229..3b331aa 100644 --- a/mailbox-lan/src/main/resources/application.yml +++ b/mailbox-lan/src/main/resources/application.yml @@ -32,7 +32,7 @@ sa-token: token-name: admin # token的名称 timeout: 2592000 # token有效期单位s(默认30天,-1代表永不过期) active-timeout: -1 # token临时有效期(指定时间无操作掉线) - is-concurrent: true # 是否允许同一账号并发登录 + is-concurrent: false # 是否允许同一账号并发登录 is-share: false # 多人同登账号共用token token-style: random-64 # token生成的风格 is-print: false # 打印版本字符画 diff --git a/mailbox-lan/src/main/resources/mapper/WorkMapper.xml b/mailbox-lan/src/main/resources/mapper/WorkMapper.xml index 3e3f78d..042da3f 100644 --- a/mailbox-lan/src/main/resources/mapper/WorkMapper.xml +++ b/mailbox-lan/src/main/resources/mapper/WorkMapper.xml @@ -4,16 +4,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + select w.id, + w.contact_name, + w.contact_phone, + w.contact_id_card, + w.content, + w.source, + w.mail_time, + w.mail_id, + w.work_type, + w.flow_name, + m.mail_state, + m.mail_category, + m.mail_level, + m.three_dept_id, + m.three_dept_name, + m.flow_key, + m.mail_labels, + m.countersign_total, + m.countersign_completed, + m.flow_name mail_flow_name, + m.current_operator, + f.limited_time, + m.flow_limited_last_handler_time, + w.create_time + from work w + left join mail m on w.mail_id = m.id + left join flow_node f on m.flow_key = f.key + ${ew.getCustomSqlSegment}