diff --git a/mailbox-common/src/main/java/com/biutag/util/StringUtils.java b/mailbox-common/src/main/java/com/biutag/util/StringUtils.java index 9222e70..bbf8aba 100644 --- a/mailbox-common/src/main/java/com/biutag/util/StringUtils.java +++ b/mailbox-common/src/main/java/com/biutag/util/StringUtils.java @@ -535,4 +535,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { return sbuf.toString(); } + public static String nullToEmpty(Object value) { + return value == null ? "" : value.toString(); + } + + public static String parseTimeStr(long time) { + if (time <= 0) { + return "未超时"; + } + if (time < 60) { + return String.format("超时%s秒", time); + } + if (time < 3600) { + long m = time % 60; + if (m == 0) { + return String.format("超时%s分", time / 60); + } + return String.format("超时%s分%s秒", time / 60, m); + } + if (time < 86400) { + long m = time % 3600; + if (m == 0) { + return String.format("超时%s时", time / 3600); + } + return String.format("超时%s时%s分", time / 3600, m / 60); + } + long m = time % 86400; + if (m == 0) { + return String.format("超时%s天", time / 86400); + } + return String.format("超时%s天%s时", time / 86400, m / 3600); + } + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java index 5ec4a7c..39c059d 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java @@ -7,12 +7,9 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.biutag.aop.NotPower; -import com.biutag.constants.AppConstants; import com.biutag.core.AjaxResult; -import com.biutag.entity.system.PoliceUser; -import com.biutag.enums.RoleEnum; -import com.biutag.exception.BusinessException; import com.biutag.lan.aop.Log; import com.biutag.lan.domain.Mail; import com.biutag.lan.domain.MailBlame; @@ -23,16 +20,11 @@ import com.biutag.lan.domain.validate.commons.MailIdValidate; import com.biutag.lan.domain.vo.DetermineMail; import com.biutag.lan.domain.vo.MailFlowDetail; import com.biutag.lan.domain.vo.MailTimeoutInfo; -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.MailBlameService; -import com.biutag.lan.service.MailMarkService; -import com.biutag.lan.service.MailService; -import com.biutag.lan.service.MailSourceService; +import com.biutag.lan.domain.vo.QueryMailVo; +import com.biutag.lan.service.*; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.simpleframework.xml.core.Validate; @@ -60,6 +52,23 @@ public class MailController { private final MailBlameService mailBlameService; + private final MailQueryService mailQueryService; + + @Operation(summary = "信件查询列表") + @NotPower + @GetMapping + public AjaxResult> list(Page page, MailQuery mailQuery) { + return AjaxResult.success(mailQueryService.page(page, mailQuery)); + } + + @Operation(summary = "台账导出") + @Log(title="信件:台账导出") + @NotPower + @PostMapping("exportLedger") + public void exportLedger(HttpServletResponse response, @RequestBody MailQuery mailQuery) { + mailQueryService.exportLedger(response, mailQuery); + } + @Operation(summary = "查看信件详情") @Log(title="查看信件详情") @NotPower diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java index b209ebc..244c6bf 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java @@ -42,12 +42,6 @@ public class WorkController { return AjaxResult.success(workService.page(workState, page, todoQuery)); } - @Operation(summary = "信件查询列表") - @NotPower - @GetMapping("query") - public AjaxResult> list(Page page, MailQuery mailQuery) { - return AjaxResult.success(workService.queryPage(page, mailQuery)); - } @Operation(summary = "信件导出") @NotPower @@ -56,13 +50,7 @@ public class WorkController { workService.export(response, data); } - @Operation(summary = "台账导出") - @Log(title="信件:台账导出") - @NotPower - @PostMapping("exportLedger") - public void exportLedger(HttpServletResponse response, @RequestBody MailQuery mailQuery) { - workService.exportLedger(response, mailQuery); - } + @Operation(summary = "信件导入") @NotPower diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java index cb932c2..73e20a2 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java @@ -126,6 +126,8 @@ public class Mail { private String firstDeptId; + private String firstDeptName; + /** * 二级单位ID(主责) */ diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMail.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMail.java index 847bdf6..1b473fd 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMail.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMail.java @@ -29,6 +29,7 @@ public class QueryMail { private String source; private String secondDeptId; private String threeDeptId; + private String firstDeptName; private String secondDeptName; private String threeDeptName; // 当前处理对象 diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMailVo.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMailVo.java index 6e6549c..314f3b9 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMailVo.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/QueryMailVo.java @@ -60,7 +60,7 @@ public class QueryMailVo { * 信件一级类目 */ @ExcelProperty("信件分类") - private String mailCategory = "未分类"; + private String mailCategory = "/"; private String mailFirstCategory; @@ -100,6 +100,8 @@ public class QueryMailVo { @ExcelProperty("办理单位ID-三级") private String threeDeptId; + private String firstDeptName; + private String secondDeptName; @ExcelProperty("办理单位") diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java index ae4f5fd..0e01db7 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java @@ -135,6 +135,7 @@ public class DistributeFlow extends Flow { .setFlowLimitedLastHandlerTime(now) .setDistributeTime(now) .setMainDeptLevel(mainDeptLevel) + .setFirstDeptName(deptVo.getShortName()) .setFirstDeptId(mainDeptId) .setLocalProcessingFlag(data.getBoolean("localProcessingFlag")) .setDistributeFiles(data.getString("files")) 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 22b8d31..19978a2 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 @@ -1,5 +1,6 @@ package com.biutag.lan.flow.node; +import cn.hutool.core.util.NumberUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -114,8 +115,11 @@ public class FirstApprovalFlow extends Flow { mailReturnService.save(mailReturn); // 更新二级机构专班的待办 workService.updateTodo(mailId, RoleEnum.SECOND_DEPT_CLASSES.getRoleId(), mail.getSecondDeptId(), FlowNameEnum.RETURN_RECTIFICATION.getName()); + + Integer extensionDays = data.getInteger("extensionDays"); // 更新信件 mail.setUpdateTime(now) + .setExtensionDays(NumberUtil.nullToZero(mail.getExtensionDays()) + NumberUtil.nullToZero(extensionDays)) .setFlowKey(FlowNodeEnum.SECOND_APPROVAL.getKey()) .setCurrentOperator(String.format("%s专班", mail.getSecondDeptName())) .setReturnOperate(returnOperate); 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 04dd9eb..39ba3d6 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 @@ -143,12 +143,7 @@ public class FirstSignFlow extends Flow { .set(Mail::getFlowKey, FlowNodeEnum.SIGN.getKey()) .set(Mail::getFlowName, FlowNameEnum.MAIL_RETURN.getName()) .set(Mail::getFirstDeptId, null) - .set(Mail::getSecondDeptId, null) - .set(Mail::getSecondDeptName, null) - .set(Mail::getThreeDeptId, null) - .set(Mail::getThreeDeptName, null) - .set(Mail::getFirstDistributeInfo, null) - .set(Mail::getSecondDistributeInfo, null) + .set(Mail::getFirstDeptName, null) .set(Mail::getSimpleFlowFlag, false) .set(Mail::getCurrentOperator, "省厅专班") ); 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 d45c3fb..96a7459 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 @@ -84,6 +84,7 @@ public class SecondSignFlow extends Flow { .set(Mail::getFlowName, FlowNameEnum.MAIL_RETURN.getName()) .set(Mail::getSecondDeptId, null) .set(Mail::getSecondDeptName, null) + .set(Mail::getFirstDistributeInfo, null) .set(Mail::getThreeDeptId, null) .set(Mail::getThreeDeptName, null) .set(Mail::getCurrentOperator, String.format("%s专班", deptService.detail(mail.getFirstDeptId()).getShortName())) diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SignFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SignFlow.java index 75bbf98..bbf602c 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SignFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/SignFlow.java @@ -8,7 +8,6 @@ import com.biutag.enums.RoleEnum; import com.biutag.exception.BusinessException; import com.biutag.lan.config.AdminThreadLocal; import com.biutag.lan.domain.Mail; -import com.biutag.lan.domain.MailMark; import com.biutag.lan.domain.MailSource; import com.biutag.lan.domain.Work; import com.biutag.lan.enums.MailCategoryEnums; @@ -46,10 +45,6 @@ public class SignFlow extends Flow { // 将首次签收标识 改为是 mailSource.setSignFlag(true); mailSourceService.updateById(mailSource); - // 不纳入信件 -// if (ActionEnum.mail110RejectSubmit.getValue().equals(nextActionKey)) { -// return addIntoBadMailByMailId(mailId, data); -// } String mailFirstCategory = data.getString("mailFirstCategory"); Mail mail = mailSource.toMail(); @@ -90,11 +85,11 @@ public class SignFlow extends Flow { } Flow nextNode = next.get(nextActionKey); - validMailExists(mailId); + mail.setMailState(MailState.processing.getValue()) .setFlowKey(nextNode.getFlowNode().getKey()) .setFlowName(nextNode.getFlowNode().getBeforeName()); - mailService.save(mail); + mailService.saveOrUpdate(mail); noticeService.sendNoticeDoneByRole(); return nextNode; } @@ -108,7 +103,7 @@ public class SignFlow extends Flow { Assert.notNull(threeDeptId, "相关所队单位不能为空"); LocalDateTime now = LocalDateTime.now(); MailSource mailSource = mailSourceService.getById(mailId); - validMailExists(mailId); + String mailFirstCategory = data.getString("mailFirstCategory"); Mail mail = mailSource.toMail() .setMailFirstCategory(mailFirstCategory) @@ -121,7 +116,7 @@ public class SignFlow extends Flow { .setFlowName(FlowNodeEnum.COMPLETION.getFullName()) .setUpdateTime(now) .setLocalProcessingFlag(false); - mailService.save(mail); + mailService.saveOrUpdate(mail); // 更新为已办 workService.updateDoneByRole(mailId, null); noticeService.sendNoticeDoneByRole(); @@ -142,7 +137,7 @@ public class SignFlow extends Flow { String invalidationAttachments = data.getString("invalidationAttachments"); LocalDateTime now = LocalDateTime.now(); MailSource mailSource = mailSourceService.getById(mailId); - validMailExists(mailId); + Mail mail = mailSource.toMail() .setMailFirstCategory(mailFirstCategory) .setMailSecondCategory(mailSecondCategory) @@ -156,7 +151,7 @@ public class SignFlow extends Flow { .setInvalidationContactFlag(invalidationContactFlag) .setRepeat(data.getBoolean("repeat")) .setInvalidationAttachments(invalidationAttachments); - mailService.save(mail); + mailService.saveOrUpdate(mail); mailMarkService.removeById(mailId); // 更新为已办 workService.updateDoneByRole(mailId, null); @@ -164,11 +159,4 @@ public class SignFlow extends Flow { return null; } - private void validMailExists(String mailId) { - if (mailService.exists(mailId)) { - // 如果存在则删除相关数据 - mailService.removeById(mailId); - } - } - } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeSignFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeSignFlow.java index 5fd52fe..1ede23e 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeSignFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeSignFlow.java @@ -89,6 +89,8 @@ public class ThreeSignFlow extends Flow { .set(Mail::getFlowKey, FlowNodeEnum.SECOND_DISTRIBUTE.getKey()) .set(Mail::getFlowName, FlowNameEnum.MAIL_RETURN.getName()) .set(Mail::getExtensionDays, 0) + .set(Mail::getThreeDeptId, null) + .set(Mail::getThreeDeptName, null) .set(Mail::getSecondDistributeInfo, null) .set(Mail::getThreeSignTime, null) .set(Mail::getSecondDistributeTime, now); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java b/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java index 04d9d77..0e4fad2 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java @@ -16,6 +16,8 @@ import java.util.Map; public interface MailMapper extends BaseMapper { + Page selectQueryPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper, @Param("countMails") String countMails); + @Select("SELECT nextval('mail_id_seq') ") Integer getMailIdSeqVal(); 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 c57ed88..ed6207b 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 @@ -17,7 +17,7 @@ public interface WorkMapper extends BaseMapper { Page selectPageBy(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); - Page selectQueryPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper, @Param("countMails") String countMails); + Page selectDissatisfiedPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailQueryService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailQueryService.java index f296a8e..ce8bcd6 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailQueryService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailQueryService.java @@ -1,25 +1,36 @@ package com.biutag.lan.service; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.biutag.constants.AppConstants; import com.biutag.entity.setting.DictData; import com.biutag.entity.system.Dept; -import com.biutag.lan.domain.Mail; -import com.biutag.lan.domain.MailCategory; -import com.biutag.lan.domain.MailLabel; -import com.biutag.lan.domain.vo.MailQueryParam; -import com.biutag.lan.domain.vo.QueryItem; -import com.biutag.lan.domain.vo.QueryMail; -import com.biutag.lan.domain.vo.QueryMailVo; +import com.biutag.enums.MailState; +import com.biutag.lan.domain.*; +import com.biutag.lan.domain.bo.MailQuery; +import com.biutag.lan.domain.vo.*; +import com.biutag.lan.enums.AppealState; +import com.biutag.lan.enums.SatisfactionEnum; +import com.biutag.lan.flow.Flow; +import com.biutag.lan.flow.FlowNodeEnum; +import com.biutag.lan.flow.node.FirstSignFlow; import com.biutag.lan.mapper.MailMapper; +import com.biutag.util.StringUtils; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import java.io.IOException; +import java.io.OutputStream; import java.util.*; import java.util.stream.Collectors; @@ -29,11 +40,19 @@ import java.util.stream.Collectors; public class MailQueryService { private final MailMapper mailMapper; + + private final MailReturnService mailReturnService; + private final MailBlameService mailBlameService; + private final MailMarkService mailMarkService; + private final MailAppealService mailAppealService; + + private final WorkService workService; + private final IDictDataService dictDataService; private final MailCategoryService mailCategoryService; - private final IDeptService deptService; private final IMailLabelService mailLabelService; - private final WorkService workService; + private final IDeptService deptService; + private final IHolidayService holidayService; public JSONObject query(Page page, MailQueryParam queryParam) { long l = System.currentTimeMillis(); @@ -224,7 +243,269 @@ public class MailQueryService { BeanUtils.copyProperties(item, vo); return vo; }).toList(); - workService.export(response, data); + export(response, data); + } + + public Page page(Page page, MailQuery mailQuery) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (CollectionUtil.isNotEmpty(mailQuery.getReturnRole())) { + List list = mailReturnService.list(new LambdaQueryWrapper().eq(MailReturn::getSignFlag, false).in(MailReturn::getHandlerRoleId, mailQuery.getReturnRole())); + if (list.isEmpty()) { + return new Page().setRecords(new ArrayList<>()).setTotal(0); + } + queryWrapper.in("m.id", list.stream().map(MailReturn::getMailId).collect(Collectors.toSet())); + } + queryWrapper.ge(StrUtil.isNotBlank(mailQuery.getMailTimeStart()), "m.mail_time", mailQuery.getMailTimeStart()) + .le(StrUtil.isNotBlank(mailQuery.getMailTimeEnd()), "m.mail_time", mailQuery.getMailTimeEnd()) + .eq(StrUtil.isNotBlank(mailQuery.getSource()), "m.source", mailQuery.getSource()) + .eq(StrUtil.isNotBlank(mailQuery.getMailLevel()), "m.mail_level", mailQuery.getMailLevel()) + .eq(StrUtil.isNotBlank(mailQuery.getMailState()), "m.mail_state", mailQuery.getMailState()) + .like(StrUtil.isNotBlank(mailQuery.getQueryById()), "m.id", mailQuery.getQueryById()) + .eq(Objects.nonNull(mailQuery.getSignRoleId()), "w.sign_role_id", mailQuery.getSignRoleId()) + .eq(Objects.nonNull(mailQuery.getSignDeptId()), "w.sign_dept_id", mailQuery.getSignDeptId()) + .eq(StrUtil.isNotBlank(mailQuery.getVerifyIsTrue()), "m.verify_is_true", mailQuery.getVerifyIsTrue()) + .eq(Objects.nonNull(mailQuery.getVerifyNeedAccountability()), "m.verify_need_accountability", mailQuery.getVerifyNeedAccountability()) + .eq(Objects.nonNull(mailQuery.getSimpleFlowFlag()), "m.simple_flow_flag", mailQuery.getSimpleFlowFlag()) + .in(CollectionUtil.isNotEmpty(mailQuery.getSatisfactionStatus()), "m.satisfaction_status", mailQuery.getSatisfactionStatus()) + .in(CollectionUtil.isNotEmpty(mailQuery.getPoliceType()), "m.police_type", mailQuery.getPoliceType()); + // 责任追究 + if (StrUtil.isNotBlank(mailQuery.getVerifyPunish())) { + List mailBlames = mailBlameService.list(new LambdaQueryWrapper().like(MailBlame::getVerifyPunish, mailQuery.getVerifyPunish())); + if (mailBlames.isEmpty()) { + return new Page().setRecords(new ArrayList<>()).setTotal(0); + } + } + if (Objects.nonNull(mailQuery.getExtensionFlag())) { + if (mailQuery.getExtensionFlag()) { + queryWrapper.gt("m.extension_days", 0); + } else { + queryWrapper.and(q -> { + q.eq("m.extension_days", 0).or().isNull("m.extension_days"); + }); + } + } + if (StrUtil.isNotBlank(mailQuery.getQueryByContent())) { + queryWrapper.and(query -> { + query.like("m.content", mailQuery.getQueryByContent()) + .or() + .like("m.interview_details", mailQuery.getQueryByContent()) + .or() + .like("m.verify_details", mailQuery.getQueryByContent()) + .or() + .like("m.completion_comment", mailQuery.getQueryByContent()); + }); + } + if (StrUtil.isNotBlank(mailQuery.getCountMails())) { + switch (mailQuery.getCountMails()) { + case "1": + queryWrapper.and(i -> i.notIn("m.flow_key", Arrays.asList(FlowNodeEnum.FIRST_SIGN.getKey(), FlowNodeEnum.FIRST_DISTRIBUTE.getKey()))//防止二级专班退回市局专班的信件未被签收,但是仍然存在于mail表中 + .ne("m.mail_state", MailState.terminated.getValue())); + break; + case "2": + queryWrapper.nested(i -> i.eq("mm.completed", "1")); + break; + case "3": + queryWrapper.nested(i -> i.eq("mm.satisfied", "1")); + break; + case "4": + queryWrapper.nested(i -> i.eq("mm.resolved", "1")); + break; + } + } + if (StrUtil.isNotBlank(mailQuery.getFlowKey())) { + List flowKeyList = StrUtil.split(mailQuery.getFlowKey(), ',', true, true); + + //判断是否需要查询mail_source表内容 + boolean nullFlag = false; + for (String flowKey : flowKeyList) { + if (flowKey.equals("first_sign")) { + nullFlag = true; + } + } + if (nullFlag) + queryWrapper.nested(i -> i.isNull("m.flow_key").or().in("m.flow_key", flowKeyList)); + else + queryWrapper.in("m.flow_key", flowKeyList); + } + workService.mailCategorySearch(mailQuery, queryWrapper); + workService.deptSearch(mailQuery, queryWrapper); + if (StrUtil.isNotBlank(mailQuery.getMailLabels())) { + List labelIds = mailQuery.handleMailLabels(); + for (String labelId : labelIds) { + queryWrapper.like("m.mail_labels", labelId); + } + } + workService.roleCheck(queryWrapper); + if (StrUtil.isNotBlank(mailQuery.getContactField()) && StrUtil.isNotBlank(mailQuery.getContactFieldValue())) { + switch (mailQuery.getContactField()) { + case "name": + queryWrapper.like("m.contact_name", mailQuery.getContactFieldValue()); + break; + case "idCard": + queryWrapper.like("m.contact_id_card", mailQuery.getContactFieldValue()); + break; + case "phone": + queryWrapper.like("m.contact_phone", mailQuery.getContactFieldValue()); + break; + } + } + if (StrUtil.isNotBlank(mailQuery.getTimeout())) { + // 超时查询 + switch (mailQuery.getTimeout()) { + // 签收超时 + case "1": + queryWrapper.eq("mm.sign_timeout", true); + break; + // 联系群众超时 + case "2": + queryWrapper.eq("mm.contact_writer_timeout", true); + break; + // 办理超时 + case "3": + queryWrapper.eq("mm.process_timeout", true); + break; + } + } + + // 办结时间 + if (!mailQuery.getCompletionTime().isEmpty()) { + queryWrapper.ge("mm.completion_time", mailQuery.getCompletionTime().get(0)) + .le("mm.completion_time", mailQuery.getCompletionTime().get(1)); + } + // 申诉状态 + if (AppealState.UN_APPEAL.getValue().equals(mailQuery.getAppealState())) { + queryWrapper.eq("mm.satisfied", AppConstants.FALSE).eq("mm.completed", AppConstants.TRUE).isNull("ma.appeal_state"); + } else { + queryWrapper.eq(StrUtil.isNotBlank(mailQuery.getAppealState()), "ma.appeal_state", mailQuery.getAppealState()); + } + if (StrUtil.isNotBlank(mailQuery.getReturnReason())) { + List list = mailReturnService.list(new LambdaQueryWrapper().like(MailReturn::getReason, mailQuery.getReturnReason())); + queryWrapper.in(!list.isEmpty(), "m.id", list.stream().map(MailReturn::getMailId).toList()); + } + + // 排序 + queryWrapper.orderByDesc("m.mail_time"); + Page result = mailMapper.selectQueryPage(page, queryWrapper, mailQuery.getCountMails()); + for (QueryMailVo workVo : result.getRecords()) { + List labelNames = mailLabelService.list(); + if (StrUtil.isNotBlank(workVo.getMailLabels())) { + String[] labelIds = workVo.getMailLabels().split(","); + String labelNamesStr = ""; + for (String labelId : labelIds) { + for (MailLabel label : labelNames) { + if (label.getId().equals(Integer.parseInt(labelId))) { + labelNamesStr += label.getLabelName() + ","; + } + } + } + workVo.setMailLabels(labelNamesStr.substring(0, labelNamesStr.length() - 1)); + } + if (Objects.nonNull(workVo.getLimitedTime())) { + workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTimeByNow(workVo.getLimitedTime(), workVo.getFlowLimitedLastHandlerTime(), workVo.getExtensionDays())); + } else { + Flow flow = SpringUtil.getBean(FirstSignFlow.class); + workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTimeByNow(flow.getFlowNode().getLimitedTime(), workVo.getCreateTime(), workVo.getExtensionDays())); + } + } + return result; + } + + public void exportLedger(HttpServletResponse response, MailQuery mailQuery) { + List data = page(new Page<>(1, 10000), mailQuery).getRecords(); + export(response, data); + } + + public void export(HttpServletResponse response, List data) { + List mailIds = data.stream().map(QueryMailVo::getId).collect(Collectors.toList()); + List mailList = mailMapper.selectBatchIds(mailIds); + List mailMarks = mailMarkService.listByIds(mailIds); + List appealList = mailAppealService.list(new LambdaQueryWrapper().in(MailAppeal::getMailId, mailIds)); + List mailBlames = mailBlameService.list(mailIds); + List dictData = dictDataService.listByDateTypeAndValue(AppConstants.MAIL_SOURCE); + List list = new ArrayList<>(); + int i = 1; + for (QueryMailVo q : data) { + Mail m = mailList.stream().filter(item -> item.getId().equals(q.getId())).findFirst().orElse(new Mail()); + LedgerExcel ledgerExcel = new LedgerExcel(); + ledgerExcel.setSerialNumber(i++); + ledgerExcel.setId(StringUtils.nullToEmpty(q.getId())); + ledgerExcel.setSource((dictData.stream() + .filter(r -> r.getValue().equals(StringUtils.nullToEmpty(q.getSource()))) + .toList().get(0).getName())); + ledgerExcel.setMailTime(m.getMailTime()); + ledgerExcel.setCreateTime(m.getCreateTime()); + // 办结时间 + MailMark mailMark = mailMarks.stream().filter(item -> item.getMailId().equals(q.getId())).findFirst().orElse(null); + ledgerExcel.setCompletionTime(Optional.ofNullable(mailMark).map(MailMark::getCompletionTime).orElse(null)); + ledgerExcel.setContactName(StringUtils.nullToEmpty(q.getContactName())); + ledgerExcel.setContactPhone(StringUtils.nullToEmpty(q.getContactPhone())); + ledgerExcel.setInvolvedDeptName(m.getInvolvedDeptName()); + ledgerExcel.setSecondDeptName(StringUtils.nullToEmpty(m.getSecondDeptName())); + ledgerExcel.setThreeDeptName(m.getThreeDeptName()); + ledgerExcel.setContent(StringUtils.nullToEmpty(q.getContent())); + + // 超时时长 + long signTimeoutDuration = Optional.ofNullable(mailMark).map(MailMark::getSignTimeoutDuration).orElse(0L); + String secondSignFlag = signTimeoutDuration <= 0 ? AppConstants.YES : AppConstants.NO; + ledgerExcel.setSignTimoutFlag(secondSignFlag); + ledgerExcel.setSignTimeoutDuration(StringUtils.parseTimeStr(signTimeoutDuration)); + + Long contactWriterTimeoutDuration = Optional.ofNullable(mailMark).map(MailMark::getContactWriterTimeoutDuration).orElse(0L); + ledgerExcel.setContactWriterTimeoutDuration(StringUtils.parseTimeStr(contactWriterTimeoutDuration)); + + // 逾期办结 + String processTimeout = Optional.ofNullable(mailMark) + .map(item -> Objects.nonNull(item.getProcessTimeout()) && item.getProcessTimeout() ? AppConstants.YES : AppConstants.NO) + .orElse(""); + ledgerExcel.setProcessTimeout(processTimeout); + + ledgerExcel.setIsTrue(StringUtils.nullToEmpty(m.getVerifyIsTrue())); + ledgerExcel.setVerifyFeedback(m.getVerifyFeedback()); + ledgerExcel.setCategory(StringUtils.nullToEmpty(m.getMailFirstCategory()) + Optional.ofNullable(m.getMailSecondCategory()).map(item -> " -> " + item).orElse("") + Optional.ofNullable(m.getMailThreeCategory()).map(item -> " -> " + item).orElse("")); + ledgerExcel.setTellDate(m.getContactTime()); + ledgerExcel.setTellTime(m.getContactTime()); + + ledgerExcel.setResolved(Optional.ofNullable(m.getProblemSolvingStatus()).map(item -> item ? "已解决": "未解决").orElse("")); + ledgerExcel.setSatisfied(Optional.ofNullable(m.getSatisfaction()).map(SatisfactionEnum::getLabel).orElse(m.getSatisfactionStatus())); + ledgerExcel.setCompletionComment(m.getCompletionComment()); + boolean isAppeal = appealList.stream().anyMatch(item -> item.getMailId().equals(q.getId())); + ledgerExcel.setIsAppeal(isAppeal ? AppConstants.YES : AppConstants.NO); + if (isAppeal) { + String appealResult = appealList.stream().anyMatch(item -> item.getMailId().equals(q.getId()) && item.getAppealState().equals(AppealState.SUCCESS.getValue())) ? "成功" : "失败"; + ledgerExcel.setAppealResult(appealResult); + } + ledgerExcel.setIsQualify(StringUtils.nullToEmpty(m.getQualifiedProcessingStatus())); + // 被举报人 + if (Objects.nonNull(m.getVerifyNeedAccountability())) { + ledgerExcel.setVerifyNeedAccountability(m.getVerifyNeedAccountability() ? "是" : "否"); + } + List blames = mailBlames.stream().filter(item -> item.getMailId().equals(q.getId())).toList(); + ledgerExcel.setVerifyBlameNumber(blames.size()); + ledgerExcel.setVerifyBlames(blames.stream().map(item -> item.getBlameName() + "-" + item.getBlameEmpNo()).collect(Collectors.joining("、"))); + ledgerExcel.setVerifyProblem(blames.stream().filter(item -> StrUtil.isNotBlank(item.getVerifyProblem())).map(item -> String.join("/", JSON.parseArray(item.getVerifyProblem(), String.class))).collect(Collectors.joining("、"))); + ledgerExcel.setVerifyPunish(blames.stream().filter(item -> StrUtil.isNotBlank(item.getVerifyPunish())).map(item -> String.join("/", JSON.parseArray(item.getVerifyPunish(), String.class))).collect(Collectors.joining("、"))); + // ------------------- + list.add(ledgerExcel); + } + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("UTF-8"); + try (OutputStream out = response.getOutputStream()) { + // 使用EasyExcel写入数据到输出流 + EasyExcel.write(out, LedgerExcel.class).inMemory(Boolean.TRUE).sheet("“厅(局)长信箱即接即办工作汇总台账").doWrite(list); + } catch (Exception e) { + log.error("Exception occurred while exporting mail data" + e.getMessage(), e); + + // 如果response还没有被提交,返回一个错误信息 + if (!response.isCommitted()) { + response.reset(); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + try { + response.getWriter().write("Failed to export data due to an internal error."); + } catch (IOException ex) { + log.error(e.getMessage(), e); + } + } + } } private String getContactColumnField(String contactField) { 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 2e049f1..e57c0aa 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,5 @@ package com.biutag.lan.service; -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.alibaba.excel.EasyExcel; @@ -14,26 +13,27 @@ import com.biutag.constants.AppConstants; import com.biutag.core.AjaxResult; import com.biutag.entity.setting.DictData; import com.biutag.entity.system.Dept; -import com.biutag.enums.MailState; import com.biutag.enums.RoleEnum; import com.biutag.exception.BusinessException; import com.biutag.lan.config.AdminThreadLocal; -import com.biutag.lan.domain.*; +import com.biutag.lan.domain.Mail; +import com.biutag.lan.domain.MailCategory; +import com.biutag.lan.domain.Work; import com.biutag.lan.domain.bo.MailOuter; import com.biutag.lan.domain.bo.MailQuery; -import com.biutag.lan.domain.vo.LedgerExcel; 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.AppealState; import com.biutag.lan.enums.MailCategoryEnums; -import com.biutag.lan.enums.SatisfactionEnum; 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.*; +import com.biutag.lan.mapper.MailCategoryMapper; +import com.biutag.lan.mapper.MailMapper; +import com.biutag.lan.mapper.WorkMapper; import com.biutag.mapper.system.DeptMapper; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; @@ -47,17 +47,11 @@ import java.io.OutputStream; import java.net.URLEncoder; import java.time.LocalDateTime; import java.util.*; -import java.util.stream.Collectors; @RequiredArgsConstructor @Service public class WorkService extends ServiceImpl { - - private final MailLabelMapper mailLabelMapper; - - private final MailAppealMapper mailAppealMapper; - private final MailCategoryMapper mailCategoryMapper; private final MailMapper mailMapper; @@ -68,14 +62,9 @@ public class WorkService extends ServiceImpl { private final NoticeService noticeService; - private final MailMarkService mailMarkService; private final IDictDataService dictDataService; - private final MailReturnService mailReturnService; - - private final MailBlameService mailBlameService; - public boolean save(MailOuter mail) { LocalDateTime now = LocalDateTime.now(); Work work = new Work(); @@ -386,171 +375,7 @@ public class WorkService extends ServiceImpl { return list(new LambdaQueryWrapper().eq(Work::getMailId, mailId).eq(Work::getSignRoleId, roleId).eq(Work::getWorkType, workType)); } - public Page queryPage(Page page, MailQuery mailQuery) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (CollectionUtil.isNotEmpty(mailQuery.getReturnRole())) { - List list = mailReturnService.list(new LambdaQueryWrapper().eq(MailReturn::getSignFlag, false).in(MailReturn::getHandlerRoleId, mailQuery.getReturnRole())); - if (list.isEmpty()) { - return new Page().setRecords(new ArrayList<>()).setTotal(0); - } - queryWrapper.in("m.id", list.stream().map(MailReturn::getMailId).collect(Collectors.toSet())); - } - queryWrapper.ge(StrUtil.isNotBlank(mailQuery.getMailTimeStart()), "m.mail_time", mailQuery.getMailTimeStart()) - .le(StrUtil.isNotBlank(mailQuery.getMailTimeEnd()), "m.mail_time", mailQuery.getMailTimeEnd()) - .eq(StrUtil.isNotBlank(mailQuery.getSource()), "m.source", mailQuery.getSource()) - .eq(StrUtil.isNotBlank(mailQuery.getMailLevel()), "m.mail_level", mailQuery.getMailLevel()) - .eq(StrUtil.isNotBlank(mailQuery.getMailState()), "m.mail_state", mailQuery.getMailState()) - .like(StrUtil.isNotBlank(mailQuery.getQueryById()), "m.id", mailQuery.getQueryById()) - .eq(Objects.nonNull(mailQuery.getSignRoleId()), "w.sign_role_id", mailQuery.getSignRoleId()) - .eq(Objects.nonNull(mailQuery.getSignDeptId()), "w.sign_dept_id", mailQuery.getSignDeptId()) - .eq(StrUtil.isNotBlank(mailQuery.getVerifyIsTrue()), "m.verify_is_true", mailQuery.getVerifyIsTrue()) - .eq(Objects.nonNull(mailQuery.getVerifyNeedAccountability()), "m.verify_need_accountability", mailQuery.getVerifyNeedAccountability()) - .eq(Objects.nonNull(mailQuery.getSimpleFlowFlag()), "m.simple_flow_flag", mailQuery.getSimpleFlowFlag()) - .in(CollectionUtil.isNotEmpty(mailQuery.getSatisfactionStatus()), "m.satisfaction_status", mailQuery.getSatisfactionStatus()) - .in(CollectionUtil.isNotEmpty(mailQuery.getPoliceType()), "m.police_type", mailQuery.getPoliceType()); - // 责任追究 - if (StrUtil.isNotBlank(mailQuery.getVerifyPunish())) { - List mailBlames = mailBlameService.list(new LambdaQueryWrapper().like(MailBlame::getVerifyPunish, mailQuery.getVerifyPunish())); - if (mailBlames.isEmpty()) { - return new Page().setRecords(new ArrayList<>()).setTotal(0); - } - } - if (Objects.nonNull(mailQuery.getExtensionFlag())) { - if (mailQuery.getExtensionFlag()) { - queryWrapper.gt("m.extension_days", 0); - } else { - queryWrapper.and(q -> { - q.eq("m.extension_days", 0).or().isNull("m.extension_days"); - }); - } - } - if (StrUtil.isNotBlank(mailQuery.getQueryByContent())) { - queryWrapper.and(query -> { - query.like("m.content", mailQuery.getQueryByContent()) - .or() - .like("m.interview_details", mailQuery.getQueryByContent()) - .or() - .like("m.verify_details", mailQuery.getQueryByContent()) - .or() - .like("m.completion_comment", mailQuery.getQueryByContent()); - }); - } - if (StrUtil.isNotBlank(mailQuery.getCountMails())) { - switch (mailQuery.getCountMails()) { - case "1": - queryWrapper.and(i -> i.notIn("m.flow_key", Arrays.asList(FlowNodeEnum.FIRST_SIGN.getKey(), FlowNodeEnum.FIRST_DISTRIBUTE.getKey()))//防止二级专班退回市局专班的信件未被签收,但是仍然存在于mail表中 - .ne("m.mail_state", MailState.terminated.getValue())); - break; - case "2": - queryWrapper.nested(i -> i.eq("mm.completed", "1")); - break; - case "3": - queryWrapper.nested(i -> i.eq("mm.satisfied", "1")); - break; - case "4": - queryWrapper.nested(i -> i.eq("mm.resolved", "1")); - break; - } - } - if (StrUtil.isNotBlank(mailQuery.getFlowKey())) { - List flowKeyList = StrUtil.split(mailQuery.getFlowKey(), ',', true, true); - - //判断是否需要查询mail_source表内容 - boolean nullFlag = false; - for (String flowKey : flowKeyList) { - if (flowKey.equals("first_sign")) { - nullFlag = true; - } - } - if (nullFlag) - queryWrapper.nested(i -> i.isNull("m.flow_key").or().in("m.flow_key", flowKeyList)); - else - queryWrapper.in("m.flow_key", flowKeyList); - } - mailCategorySearch(mailQuery, queryWrapper); - deptSearch(mailQuery, queryWrapper); - if (StrUtil.isNotBlank(mailQuery.getMailLabels())) { - List labelIds = mailQuery.handleMailLabels(); - for (String labelId : labelIds) { - queryWrapper.like("m.mail_labels", labelId); - } - } - roleCheck(queryWrapper); - if (StrUtil.isNotBlank(mailQuery.getContactField()) && StrUtil.isNotBlank(mailQuery.getContactFieldValue())) { - switch (mailQuery.getContactField()) { - case "name": - queryWrapper.like("m.contact_name", mailQuery.getContactFieldValue()); - break; - case "idCard": - queryWrapper.like("m.contact_id_card", mailQuery.getContactFieldValue()); - break; - case "phone": - queryWrapper.like("m.contact_phone", mailQuery.getContactFieldValue()); - break; - } - } - if (StrUtil.isNotBlank(mailQuery.getTimeout())) { - // 超时查询 - switch (mailQuery.getTimeout()) { - // 签收超时 - case "1": - queryWrapper.eq("mm.sign_timeout", true); - break; - // 联系群众超时 - case "2": - queryWrapper.eq("mm.contact_writer_timeout", true); - break; - // 办理超时 - case "3": - queryWrapper.eq("mm.process_timeout", true); - break; - } - } - - // 办结时间 - if (!mailQuery.getCompletionTime().isEmpty()) { - queryWrapper.ge("mm.completion_time", mailQuery.getCompletionTime().get(0)) - .le("mm.completion_time", mailQuery.getCompletionTime().get(1)); - } - // 申诉状态 - if (AppealState.UN_APPEAL.getValue().equals(mailQuery.getAppealState())) { - queryWrapper.eq("mm.satisfied", AppConstants.FALSE).eq("mm.completed", AppConstants.TRUE).isNull("ma.appeal_state"); - } else { - queryWrapper.eq(StrUtil.isNotBlank(mailQuery.getAppealState()), "ma.appeal_state", mailQuery.getAppealState()); - } - if (StrUtil.isNotBlank(mailQuery.getReturnReason())) { - List list = mailReturnService.list(new LambdaQueryWrapper().like(MailReturn::getReason, mailQuery.getReturnReason())); - queryWrapper.in(!list.isEmpty(), "m.id", list.stream().map(MailReturn::getMailId).toList()); - } - - // 排序 - queryWrapper.orderByDesc("m.mail_time"); - Page result = baseMapper.selectQueryPage(page, queryWrapper, mailQuery.getCountMails()); - for (QueryMailVo workVo : result.getRecords()) { - List labelNames = mailLabelMapper.selectList(null); - if (StrUtil.isNotBlank(workVo.getMailLabels())) { - String[] labelIds = workVo.getMailLabels().split(","); - String labelNamesStr = ""; - for (String labelId : labelIds) { - for (MailLabel label : labelNames) { - if (label.getId().equals(Integer.parseInt(labelId))) { - labelNamesStr += label.getLabelName() + ","; - } - } - } - workVo.setMailLabels(labelNamesStr.substring(0, labelNamesStr.length() - 1)); - } - if (Objects.nonNull(workVo.getLimitedTime())) { - workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTimeByNow(workVo.getLimitedTime(), workVo.getFlowLimitedLastHandlerTime(), workVo.getExtensionDays())); - } else { - Flow flow = SpringUtil.getBean(FirstSignFlow.class); - workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTimeByNow(flow.getFlowNode().getLimitedTime(), workVo.getCreateTime(), workVo.getExtensionDays())); - } - } - return result; - } - - private void mailCategorySearch(MailQuery mailQuery, QueryWrapper queryWrapper) { + public void mailCategorySearch(MailQuery mailQuery, QueryWrapper queryWrapper) { if (StrUtil.isNotBlank(mailQuery.getMailCategory())) { MailCategory mailCategory = mailCategoryMapper.selectById(mailQuery.getMailCategory()); switch (mailCategory.getLevel()) { @@ -567,7 +392,7 @@ public class WorkService extends ServiceImpl { } } - private void deptSearch(MailQuery mailQuery, QueryWrapper queryWrapper) { + public void deptSearch(MailQuery mailQuery, QueryWrapper queryWrapper) { if (StrUtil.isNotBlank(mailQuery.getDeptId())) { Dept dept = deptMapper.selectById(mailQuery.getDeptId()); switch (dept.getLevel()) { @@ -778,137 +603,6 @@ public class WorkService extends ServiceImpl { return AjaxResult.success(excelService.getResult()); } - public String nullToEmpty(Object value) { - return value == null ? "" : value.toString(); - } - - public void exportLedger(HttpServletResponse response, MailQuery mailQuery) { - List data = queryPage(new Page<>(1, 10000), mailQuery).getRecords(); - export(response, data); - } - - public void export(HttpServletResponse response, List data) { - List mailIds = data.stream().map(QueryMailVo::getId).collect(Collectors.toList()); - List mailList = mailMapper.selectBatchIds(mailIds); - List mailMarks = mailMarkService.listByIds(mailIds); - List appealList = mailAppealMapper.selectList(new LambdaQueryWrapper().in(MailAppeal::getMailId, mailIds)); - List mailBlames = mailBlameService.list(mailIds); - List dictData = dictDataService.listByDateTypeAndValue(AppConstants.MAIL_SOURCE); - List list = new ArrayList<>(); - int i = 1; - for (QueryMailVo q : data) { - Mail m = mailList.stream().filter(item -> item.getId().equals(q.getId())).findFirst().orElse(new Mail()); - LedgerExcel ledgerExcel = new LedgerExcel(); - ledgerExcel.setSerialNumber(i++); - ledgerExcel.setId(nullToEmpty(q.getId())); - ledgerExcel.setSource((dictData.stream() - .filter(r -> r.getValue().equals(nullToEmpty(q.getSource()))) - .toList().get(0).getName())); - ledgerExcel.setMailTime(m.getMailTime()); - ledgerExcel.setCreateTime(m.getCreateTime()); - // 办结时间 - MailMark mailMark = mailMarks.stream().filter(item -> item.getMailId().equals(q.getId())).findFirst().orElse(null); - ledgerExcel.setCompletionTime(Optional.ofNullable(mailMark).map(MailMark::getCompletionTime).orElse(null)); - ledgerExcel.setContactName(nullToEmpty(q.getContactName())); - ledgerExcel.setContactPhone(nullToEmpty(q.getContactPhone())); - ledgerExcel.setInvolvedDeptName(m.getInvolvedDeptName()); - ledgerExcel.setSecondDeptName(nullToEmpty(m.getSecondDeptName())); - ledgerExcel.setThreeDeptName(m.getThreeDeptName()); - ledgerExcel.setContent(nullToEmpty(q.getContent())); - - // 超时时长 - long signTimeoutDuration = Optional.ofNullable(mailMark).map(MailMark::getSignTimeoutDuration).orElse(0L); - String secondSignFlag = signTimeoutDuration <= 0 ? AppConstants.YES : AppConstants.NO; - ledgerExcel.setSignTimoutFlag(secondSignFlag); - ledgerExcel.setSignTimeoutDuration(parseTimeStr(signTimeoutDuration)); - - Long contactWriterTimeoutDuration = Optional.ofNullable(mailMark).map(MailMark::getContactWriterTimeoutDuration).orElse(0L); - ledgerExcel.setContactWriterTimeoutDuration(parseTimeStr(contactWriterTimeoutDuration)); - - // 逾期办结 - String processTimeout = Optional.ofNullable(mailMark) - .map(item -> Objects.nonNull(item.getProcessTimeout()) && item.getProcessTimeout() ? AppConstants.YES : AppConstants.NO) - .orElse(""); - ledgerExcel.setProcessTimeout(processTimeout); - - ledgerExcel.setIsTrue(nullToEmpty(m.getVerifyIsTrue())); - ledgerExcel.setVerifyFeedback(m.getVerifyFeedback()); - ledgerExcel.setCategory(nullToEmpty(m.getMailFirstCategory()) + Optional.ofNullable(m.getMailSecondCategory()).map(item -> " -> " + item).orElse("") + Optional.ofNullable(m.getMailThreeCategory()).map(item -> " -> " + item).orElse("")); - ledgerExcel.setTellDate(m.getContactTime()); - ledgerExcel.setTellTime(m.getContactTime()); - - ledgerExcel.setResolved(Optional.ofNullable(m.getProblemSolvingStatus()).map(item -> item ? "已解决": "未解决").orElse("")); - ledgerExcel.setSatisfied(Optional.ofNullable(m.getSatisfaction()).map(SatisfactionEnum::getLabel).orElse(m.getSatisfactionStatus())); - ledgerExcel.setCompletionComment(m.getCompletionComment()); - boolean isAppeal = appealList.stream().anyMatch(item -> item.getMailId().equals(q.getId())); - ledgerExcel.setIsAppeal(isAppeal ? AppConstants.YES : AppConstants.NO); - if (isAppeal) { - String appealResult = appealList.stream().anyMatch(item -> item.getMailId().equals(q.getId()) && item.getAppealState().equals(AppealState.SUCCESS.getValue())) ? "成功" : "失败"; - ledgerExcel.setAppealResult(appealResult); - } - ledgerExcel.setIsQualify(nullToEmpty(m.getQualifiedProcessingStatus())); - // 被举报人 - if (Objects.nonNull(m.getVerifyNeedAccountability())) { - ledgerExcel.setVerifyNeedAccountability(m.getVerifyNeedAccountability() ? "是" : "否"); - } - List blames = mailBlames.stream().filter(item -> item.getMailId().equals(q.getId())).toList(); - ledgerExcel.setVerifyBlameNumber(blames.size()); - ledgerExcel.setVerifyBlames(blames.stream().map(item -> item.getBlameName() + "-" + item.getBlameEmpNo()).collect(Collectors.joining("、"))); - ledgerExcel.setVerifyProblem(blames.stream().filter(item -> StrUtil.isNotBlank(item.getVerifyProblem())).map(item -> String.join("/", JSON.parseArray(item.getVerifyProblem(), String.class))).collect(Collectors.joining("、"))); - ledgerExcel.setVerifyPunish(blames.stream().filter(item -> StrUtil.isNotBlank(item.getVerifyPunish())).map(item -> String.join("/", JSON.parseArray(item.getVerifyPunish(), String.class))).collect(Collectors.joining("、"))); - // ------------------- - list.add(ledgerExcel); - } - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setCharacterEncoding("UTF-8"); - try (OutputStream out = response.getOutputStream()) { - // 使用EasyExcel写入数据到输出流 - EasyExcel.write(out, LedgerExcel.class).inMemory(Boolean.TRUE).sheet("“厅(局)长信箱即接即办工作汇总台账").doWrite(list); - } catch (Exception e) { - log.error("Exception occurred while exporting mail data" + e.getMessage(), e); - - // 如果response还没有被提交,返回一个错误信息 - if (!response.isCommitted()) { - response.reset(); - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - try { - response.getWriter().write("Failed to export data due to an internal error."); - } catch (IOException ex) { - log.error(e.getMessage(), e); - } - } - } - } - - private String parseTimeStr(long time) { - if (time <= 0) { - return "未超时"; - } - if (time < 60) { - return String.format("超时%s秒", time); - } - if (time < 3600) { - long m = time % 60; - if (m == 0) { - return String.format("超时%s分", time / 60); - } - return String.format("超时%s分%s秒", time / 60, m); - } - if (time < 86400) { - long m = time % 3600; - if (m == 0) { - return String.format("超时%s时", time / 3600); - } - return String.format("超时%s时%s分", time / 3600, m / 60); - } - long m = time % 86400; - if (m == 0) { - return String.format("超时%s天", time / 86400); - } - return String.format("超时%s天%s时", time / 86400, m / 3600); - } - - // 新增省厅专班待办(待审批) public void addApprovalByProvincialClasses(Mail mail) { LocalDateTime now = LocalDateTime.now(); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DictDataServiceImpl.java b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DictDataServiceImpl.java index b55f910..9d9847d 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DictDataServiceImpl.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DictDataServiceImpl.java @@ -172,6 +172,7 @@ public class DictDataServiceImpl implements IDictDataService { public void add(DictDataCreateValidate createValidate) { Assert.isNull(dictDataMapper.selectOne(new QueryWrapper() .select("id") + .eq("type_id", createValidate.getTypeId()) .eq("name", createValidate.getName()) .eq("is_delete", 0) .last("limit 1")), "字典数据已存在!"); @@ -206,6 +207,7 @@ public class DictDataServiceImpl implements IDictDataService { Assert.isNull(dictDataMapper.selectOne(new QueryWrapper() .select("id") .ne("id", updateValidate.getId()) + .eq("type_id", updateValidate.getTypeId()) .eq("name", updateValidate.getName()) .eq("is_delete", 0) .last("limit 1")), "字典数据已存在!"); diff --git a/mailbox-lan/src/main/resources/mapper/DeptMappingMapper.xml b/mailbox-lan/src/main/resources/mapper/DeptMappingMapper.xml index 1affcc3..e93e234 100644 --- a/mailbox-lan/src/main/resources/mapper/DeptMappingMapper.xml +++ b/mailbox-lan/src/main/resources/mapper/DeptMappingMapper.xml @@ -43,97 +43,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and w.sign_dept_id = #{deptId} - - + +