Browse Source

信件核对、不满意信件、信件标签去重添加

dev_ycq
21819 2 years ago
parent
commit
2b927667af
  1. 3
      mailbox-lan/src/main/java/com/biutag/lan/controller/system/MailLabelController.java
  2. 26
      mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java
  3. 4
      mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java
  4. 5
      mailbox-lan/src/main/java/com/biutag/lan/domain/bo/TodoQuery.java
  5. 35
      mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java
  6. 3
      mailbox-lan/src/main/java/com/biutag/lan/service/IMailLabelService.java
  7. 64
      mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java
  8. 13
      mailbox-lan/src/main/java/com/biutag/lan/service/impl/MailLabelServiceImpl.java

3
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<Void> add(@Validated @RequestBody MailLabelValidate createValidate) {
iMailLabelService.addLabel(createValidate);
return AjaxResult.success();
return iMailLabelService.addLabel(createValidate);
}
@PostMapping("/insert")

26
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<WorkVo> 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<Void> importExcel(MultipartFile file) throws IOException {
workService.importExcel(file);
return AjaxResult.success();
}
@NotPower
@GetMapping("dissatisfied")
public AjaxResult<Page<WorkVo>> dissatisfied(Page<Work> page, TodoQuery todoQuery) {
return AjaxResult.success(workService.dissatisfied(page, todoQuery));
}
}

4
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;
}

5
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<String> handleMailLabels() {
if (mailLabels == null) {
return null;

35
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<WorkVo> {
// 定义一个批量插入的大小
private static final int BATCH_SIZE = 100;
// 定义一个缓存的列表,用于存储读取到的数据
private List<WorkVo> 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) {
}
}

3
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<MailLabelVO> allLabels();
void addLabel(MailLabelValidate mailLabel);
AjaxResult<Void> addLabel(MailLabelValidate mailLabel);
void insertLabel(MailLabelInsertValidate mailLabel);
}

64
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<WorkMapper, Work> {
return result;
}
public WorkVo exportWork(Long id) {
return new WorkVo();
public void export(HttpServletResponse response, String dataWorkVo) throws IOException {
List<WorkVo> 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<WorkVo> dissatisfied(Page<Work> page, TodoQuery todoQuery) {
QueryWrapper<Work> queryWrapper = new QueryWrapper<Work>()
.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);
}
}

13
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<Void> addLabel(MailLabelValidate mailLabel) {
MailLabel label = new MailLabel();
label.setLabelName(mailLabel.getLabelName());
mailLabelMapper.insert(label);
MailLabel existLabel = mailLabelMapper.selectOne(new QueryWrapper<MailLabel>().eq("label_name", mailLabel.getLabelName()));
if (existLabel == null) {
label.setLabelName(mailLabel.getLabelName());
mailLabelMapper.insert(label);
return AjaxResult.success();
} else {
return AjaxResult.failed("标签已存在");
}
}
@Override

Loading…
Cancel
Save