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 cf84c59..f038c29 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 @@ -86,6 +86,12 @@ public class QueryMailVo { @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/service/WorkService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java index ec519d0..4531aac 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 @@ -37,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.io.OutputStream; import java.net.URLEncoder; import java.time.LocalDateTime; import java.util.Collection; @@ -382,8 +383,8 @@ public class WorkService extends ServiceImpl { public Page queryPage(Page page, MailQuery mailQuery) { QueryWrapper queryWrapper = new QueryWrapper() - .ge(StrUtil.isNotBlank(mailQuery.getMailTimeStart()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", mailQuery.getMailTimeStart()) - .le(StrUtil.isNotBlank(mailQuery.getMailTimeStartEnd()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", mailQuery.getMailTimeStartEnd()) + .ge(StrUtil.isNotBlank(mailQuery.getMailTimeStart()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD HH24:MI:SS')", mailQuery.getMailTimeStart()) + .le(StrUtil.isNotBlank(mailQuery.getMailTimeStartEnd()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD HH24:MI:SS')", mailQuery.getMailTimeStartEnd()) .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()) @@ -393,19 +394,19 @@ public class WorkService extends ServiceImpl { if (StrUtil.isNotBlank(mailQuery.getCountMails())) { switch (mailQuery.getCountMails()) { case "1": - queryWrapper.and(i -> i.ne("m.flow_key","first_sign")//防止二级专班退回市局专班的信件未被签收,但是仍然存在于mail表中 - .ne("m.mail_first_category","无效类") - .ne("m.mail_first_category","终止类") - .ne("m.mail_first_category","感谢信类")); + queryWrapper.and(i -> i.ne("m.flow_key", "first_sign")//防止二级专班退回市局专班的信件未被签收,但是仍然存在于mail表中 + .ne("m.mail_first_category", "无效类") + .ne("m.mail_first_category", "终止类") + .ne("m.mail_first_category", "感谢信类")); break; case "2": - queryWrapper.nested(i->i.eq("mm.completed", "1")); + queryWrapper.nested(i -> i.eq("mm.completed", "1")); break; case "3": - queryWrapper.nested(i->i.eq("mm.satisfied", "1")); + queryWrapper.nested(i -> i.eq("mm.satisfied", "1")); break; case "4": - queryWrapper.nested(i->i.eq("mm.resolved", "1")); + queryWrapper.nested(i -> i.eq("mm.resolved", "1")); break; } } @@ -464,6 +465,13 @@ public class WorkService extends ServiceImpl { } workVo.setMailLabels(labelNamesStr.substring(0, labelNamesStr.length() - 1)); } + + if (Objects.nonNull(workVo.getLimitedTime())) { + workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTime(workVo.getLimitedTime(), workVo.getFlowLimitedLastHandlerTime())); + } else { + Flow flow = SpringUtil.getBean(FirstSignFlow.class); + workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTime(flow.getFlowNode().getLimitedTime(), workVo.getCreateTime())); + } } return result; } @@ -526,13 +534,25 @@ public class WorkService extends ServiceImpl { // 这里URLEncoder.encode可以防止中文乱码 String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream(), MailExcel.class).sheet("模板").doWrite(mailList); + try (OutputStream out = response.getOutputStream()) { + // 使用EasyExcel写入数据到输出流 + EasyExcel.write(out, MailExcel.class).sheet("模板").doWrite(mailList); + } 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); + response.getWriter().write("Failed to export data due to an internal error."); + } + } } public Page dissatisfied(Page page, MailQuery mailQuery) { QueryWrapper queryWrapper = new QueryWrapper() - .ge(StrUtil.isNotBlank(mailQuery.getMailTimeStart()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", mailQuery.getMailTimeStart()) - .le(StrUtil.isNotBlank(mailQuery.getMailTimeStartEnd()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", mailQuery.getMailTimeStartEnd()) + .ge(StrUtil.isNotBlank(mailQuery.getMailTimeStart()), "m.mail_time", mailQuery.getMailTimeStart()) + .le(StrUtil.isNotBlank(mailQuery.getMailTimeStartEnd()), "m.mail_time", mailQuery.getMailTimeStartEnd()) .eq(StrUtil.isNotBlank(mailQuery.getSource()), "m.source", mailQuery.getSource()) .eq(StrUtil.isNotBlank(mailQuery.getMailLevel()), "m.mail_level", mailQuery.getMailLevel()) .nested(i -> @@ -587,6 +607,12 @@ public class WorkService extends ServiceImpl { } break; } + if (Objects.nonNull(workVo.getLimitedTime())) { + workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTime(workVo.getLimitedTime(), workVo.getFlowLimitedLastHandlerTime())); + } else { + Flow flow = SpringUtil.getBean(FirstSignFlow.class); + workVo.setFlowLimitedRemainingTime(holidayService.getFlowRemainingTime(flow.getFlowNode().getLimitedTime(), workVo.getCreateTime())); + } } return result; } diff --git a/mailbox-lan/src/main/resources/mapper/WorkMapper.xml b/mailbox-lan/src/main/resources/mapper/WorkMapper.xml index 554cee9..2d40c2f 100644 --- a/mailbox-lan/src/main/resources/mapper/WorkMapper.xml +++ b/mailbox-lan/src/main/resources/mapper/WorkMapper.xml @@ -28,7 +28,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.current_operator, f.limited_time, m.flow_limited_last_handler_time, - w.create_time + w.create_time, + m.extension_flag, + m.extension_days, from work w left join mail m on w.mail_id = m.id left join flow_node f on m.flow_key = f.key @@ -51,11 +53,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.contact_name,m.contact_phone,m.contact_id_card,m.contact_sex,m.content,m.source,m.mail_time,m.id,m.mail_state, m.mail_category ,m.mail_level,m.three_dept_id,m.three_dept_name,m.flow_key,m.flow_before_name,m.mail_labels,m.flow_name,m.current_operator, m.flow_limited_last_handler_time,m.second_dept_id,m.mail_first_category,m.mail_second_category,m.mail_three_category, - f.limited_time - ROUND(EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - m.flow_limited_last_handler_time))) flow_limited_remaining_time + f.limited_time,m.flow_limited_last_handler_time,m.extension_flag, + m.extension_days, from mail m - m.*,f.limited_time - ROUND(extract(EPOCH FROM (CURRENT_TIMESTAMP - m.flow_limited_last_handler_time))) AS flow_limited_remaining_time + m.*,f.limited_time FROM (SELECT COALESCE(a.contact_name, ms.contact_name) AS contact_name,COALESCE(a.contact_phone, ms.contact_phone) AS contact_phone, @@ -64,7 +67,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" COALESCE(a.mail_time, ms.mail_time) AS mail_time,COALESCE(a.id, ms.id) AS id, a.mail_state,a.mail_category,a.mail_level,a.three_dept_id,a.three_dept_name,a.flow_key,a.flow_before_name, a.mail_labels,a.flow_name,a.current_operator,a.flow_limited_last_handler_time,a.second_dept_id,a.mail_first_category, - a.mail_second_category,a.mail_three_category + a.mail_second_category,a.mail_three_category,a.flow_limited_last_handler_time,a.extension_flag, + a.extension_days, FROM mail_source ms LEFT JOIN mail a ON ms.id = a.id @@ -82,7 +86,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.mail_category ,m.mail_level,m.three_dept_id,m.three_dept_name,m.flow_key,m.flow_before_name,m.mail_labels,m.flow_name, m.current_operator, ma.appeal_state,ma.handling_dept,ma.step, - f.limited_time - ROUND(EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - m.flow_limited_last_handler_time))) flow_limited_remaining_time + f.limited_time,m.flow_limited_last_handler_time, + m.extension_flag, + m.extension_days, from mail m left join mail_appeal ma on ma.mail_id = m.id left join mail_mark mm on mm.mail_id = m.id