diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/system/MailLabelController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/system/MailLabelController.java index 93281ed..cf3e1c9 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/system/MailLabelController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/system/MailLabelController.java @@ -34,8 +34,7 @@ public class MailLabelController { @PostMapping("/add") @ApiOperation(value="信件标签新增") public AjaxResult add(@Validated @RequestBody MailLabelValidate createValidate) { - iMailLabelService.addLabel(createValidate); - return AjaxResult.success(); + return iMailLabelService.addLabel(createValidate); } @PostMapping("/insert") 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 4ab4d0c..4556147 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 @@ -1,7 +1,5 @@ package com.biutag.lan.controller.work; -import com.alibaba.excel.EasyExcel; -import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.biutag.aop.NotPower; import com.biutag.core.AjaxResult; @@ -12,10 +10,9 @@ import com.biutag.lan.service.WorkService; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.net.URLEncoder; -import java.util.List; @RequestMapping("api/work") @RequiredArgsConstructor @@ -39,12 +36,19 @@ public class WorkController { @NotPower @PostMapping("export") public void detail(HttpServletResponse response, @RequestBody String dataWorkVo) throws IOException { - List data = JSON.parseArray(dataWorkVo, WorkVo.class); - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setCharacterEncoding("utf-8"); - // 这里URLEncoder.encode可以防止中文乱码 - String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20"); - response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream(), WorkVo.class).sheet("模板").doWrite(data); + workService.export(response, dataWorkVo); + } + + @NotPower + @PostMapping("import") + public AjaxResult importExcel(MultipartFile file) throws IOException { + workService.importExcel(file); + return AjaxResult.success(); + } + + @NotPower + @GetMapping("dissatisfied") + public AjaxResult> dissatisfied(Page page, TodoQuery todoQuery) { + return AjaxResult.success(workService.dissatisfied(page, todoQuery)); } } 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 1b12be1..6e84acc 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 @@ -293,4 +293,8 @@ public class Mail { */ private String mailLabels; + private String currentOperator; + private String extensionReason; + private String extensionState; + private Integer extensionDays; } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/TodoQuery.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/TodoQuery.java index 2cf91d3..938cb03 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/TodoQuery.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/TodoQuery.java @@ -39,6 +39,11 @@ public class TodoQuery { */ private String mailLabels; + /** + * 申诉状态 + */ + private String AppealState; + public List handleMailLabels() { if (mailLabels == null) { return null; diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java new file mode 100644 index 0000000..763e5c3 --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java @@ -0,0 +1,35 @@ +package com.biutag.lan.service; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; +import com.biutag.lan.domain.vo.WorkVo; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.util.ArrayList; +import java.util.List; + +@Slf4j +public class ExcelService implements ReadListener { + // 定义一个批量插入的大小 + private static final int BATCH_SIZE = 100; + // 定义一个缓存的列表,用于存储读取到的数据 + private List dataList = new ArrayList<>(BATCH_SIZE); + // 定义一个数据库连接对象 + private Connection connection; + // 定义一个预编译的SQL语句对象 + private PreparedStatement preparedStatement; + public ExcelService(WorkService workService) { + } + + @Override + public void invoke(WorkVo workVo, AnalysisContext analysisContext) { + + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + + } +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/IMailLabelService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/IMailLabelService.java index d010de3..31508a0 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/IMailLabelService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/IMailLabelService.java @@ -1,5 +1,6 @@ package com.biutag.lan.service; +import com.biutag.core.AjaxResult; import com.biutag.lan.validate.system.MailLabelInsertValidate; import com.biutag.lan.validate.system.MailLabelValidate; import com.biutag.lan.vo.system.MailLabelVO; @@ -9,7 +10,7 @@ import java.util.List; public interface IMailLabelService { List allLabels(); - void addLabel(MailLabelValidate mailLabel); + AjaxResult addLabel(MailLabelValidate mailLabel); void insertLabel(MailLabelInsertValidate mailLabel); } 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 4264f06..57d0559 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,8 @@ package com.biutag.lan.service; import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -17,10 +19,14 @@ import com.biutag.lan.enums.WorkType; import com.biutag.lan.mapper.MailLabelMapper; import com.biutag.lan.mapper.WorkMapper; import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import java.net.URLEncoder; import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @@ -279,7 +285,61 @@ public class WorkService extends ServiceImpl { return result; } - public WorkVo exportWork(Long id) { - return new WorkVo(); + public void export(HttpServletResponse response, String dataWorkVo) throws IOException { + List data = JSON.parseArray(dataWorkVo, WorkVo.class); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 + String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), WorkVo.class).sheet("模板").doWrite(data); + } + + public void importExcel(MultipartFile file) throws IOException { + EasyExcel.read(file.getInputStream(), WorkVo.class, new ExcelService(this)).sheet().doRead(); + } + + public Page dissatisfied(Page page, TodoQuery todoQuery) { + QueryWrapper queryWrapper = new QueryWrapper() + .ge(StrUtil.isNotBlank(todoQuery.getMailTimeStart()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", todoQuery.getMailTimeStart()) + .le(StrUtil.isNotBlank(todoQuery.getMailTimeStartEnd()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", todoQuery.getMailTimeStartEnd()) + .eq(StrUtil.isNotBlank(todoQuery.getSource()), "m.source", todoQuery.getSource()) + .eq(StrUtil.isNotBlank(todoQuery.getMailLevel()), "m.mail_level", todoQuery.getMailLevel()) + .eq(StrUtil.isNotBlank(todoQuery.getMailCategory()), "m.mail_category", todoQuery.getMailCategory()) + .like(StrUtil.isNotBlank(todoQuery.getThreeDeptName()), "m.three_dept_name", todoQuery.getThreeDeptName()) +// .eq(StrUtil.isNotBlank(todoQuery.getAppealState()), "m.appeal_state", todoQuery.getAppealState()) + .eq("m.satisfaction_status","不满意") + .or() + .eq("m.verify_feedback","不满意"); + Integer roleId = AdminThreadLocal.getRoleId(); + // 与角色相关的件 + if (roleId.equals(RoleEnum.MUNICIPAL_DEPT_CLASSES.getRoleId()) || + roleId.equals(RoleEnum.SECOND_DEPT_CLASSES.getRoleId()) || + roleId.equals(RoleEnum.THREE_DEPT_CLASSES.getRoleId())) { + Integer deptId = AdminThreadLocal.getDeptId(); + queryWrapper.eq("w.sign_role_id", roleId) + // 如果不是市局专班,则需要查询签收部门ID + .eq(!RoleEnum.MUNICIPAL_DEPT_CLASSES.getRoleId().equals(roleId), "w.sign_dept_id", deptId); + } else { + String empNo = AdminThreadLocal.getEmpNo(); + queryWrapper.eq("w.police_emp_no", empNo); + } + if (StrUtil.isNotBlank(todoQuery.getContactField()) && StrUtil.isNotBlank(todoQuery.getContactFieldValue())) { + switch (todoQuery.getContactField()) { + case "name": + queryWrapper.like("w.contact_name", todoQuery.getContactFieldValue()); + break; + case "idCard": + queryWrapper.like("w.contactIdCard", todoQuery.getContactFieldValue()); + break; + case "phone": + queryWrapper.like("w.contactPhone", todoQuery.getContactFieldValue()); + break; + } + + } + // 排序 + queryWrapper.orderByDesc("w.update_time"); + return baseMapper.selectPageTodo(page, queryWrapper); } } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/MailLabelServiceImpl.java b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/MailLabelServiceImpl.java index 76f9980..a0cc75b 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/MailLabelServiceImpl.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/MailLabelServiceImpl.java @@ -1,6 +1,7 @@ package com.biutag.lan.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.biutag.core.AjaxResult; import com.biutag.lan.domain.Mail; import com.biutag.lan.domain.MailLabel; import com.biutag.lan.mapper.MailLabelMapper; @@ -47,10 +48,16 @@ public class MailLabelServiceImpl implements IMailLabelService { * @param mailLabel */ @Override - public void addLabel(MailLabelValidate mailLabel) { + public AjaxResult addLabel(MailLabelValidate mailLabel) { MailLabel label = new MailLabel(); - label.setLabelName(mailLabel.getLabelName()); - mailLabelMapper.insert(label); + MailLabel existLabel = mailLabelMapper.selectOne(new QueryWrapper().eq("label_name", mailLabel.getLabelName())); + if (existLabel == null) { + label.setLabelName(mailLabel.getLabelName()); + mailLabelMapper.insert(label); + return AjaxResult.success(); + } else { + return AjaxResult.failed("标签已存在"); + } } @Override