Browse Source

同步信件核对以及不满意信件列表,修改部门列表获取权限

dev_ycq
21819 2 years ago
parent
commit
1c11c28bbb
  1. 1
      mailbox-lan/src/main/java/com/biutag/lan/controller/system/DeptController.java
  2. 3
      mailbox-lan/src/main/java/com/biutag/lan/controller/system/MailLabelController.java
  3. 34
      mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java
  4. 14
      mailbox-lan/src/main/java/com/biutag/lan/domain/vo/WorkVo.java
  5. 2
      mailbox-lan/src/main/java/com/biutag/lan/mapper/WorkMapper.java
  6. 54
      mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java
  7. 3
      mailbox-lan/src/main/java/com/biutag/lan/service/IMailLabelService.java
  8. 23
      mailbox-lan/src/main/java/com/biutag/lan/service/MailSourceService.java
  9. 81
      mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java
  10. 9
      mailbox-lan/src/main/java/com/biutag/lan/service/impl/MailLabelServiceImpl.java

1
mailbox-lan/src/main/java/com/biutag/lan/controller/system/DeptController.java

@ -35,6 +35,7 @@ public class DeptController {
return AjaxResult.success(list); return AjaxResult.success(list);
} }
@NotPower
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value="部门列表") @ApiOperation(value="部门列表")
public AjaxResult<JSONArray> list(@Validated DeptSearchValidate searchValidate) { public AjaxResult<JSONArray> list(@Validated DeptSearchValidate searchValidate) {

3
mailbox-lan/src/main/java/com/biutag/lan/controller/system/MailLabelController.java

@ -33,8 +33,7 @@ public class MailLabelController {
@PostMapping("/add") @PostMapping("/add")
@ApiOperation(value="信件标签新增") @ApiOperation(value="信件标签新增")
public AjaxResult<Void> add(@Validated @RequestBody MailLabelValidate createValidate) { public AjaxResult<Void> add(@Validated @RequestBody MailLabelValidate createValidate) {
iMailLabelService.addLabel(createValidate); return iMailLabelService.addLabel(createValidate);
return AjaxResult.success();
} }
@PostMapping("/insert") @PostMapping("/insert")

34
mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java

@ -1,6 +1,5 @@
package com.biutag.lan.controller.work; package com.biutag.lan.controller.work;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.aop.NotPower; import com.biutag.aop.NotPower;
@ -8,13 +7,15 @@ import com.biutag.core.AjaxResult;
import com.biutag.lan.domain.Work; import com.biutag.lan.domain.Work;
import com.biutag.lan.domain.bo.MailQuery; import com.biutag.lan.domain.bo.MailQuery;
import com.biutag.lan.domain.vo.WorkVo; import com.biutag.lan.domain.vo.WorkVo;
import com.biutag.lan.service.MailSourceService;
import com.biutag.lan.service.WorkService; import com.biutag.lan.service.WorkService;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder;
import java.util.List; import java.util.List;
@RequestMapping("api/work") @RequestMapping("api/work")
@ -23,6 +24,7 @@ import java.util.List;
public class WorkController { public class WorkController {
private final WorkService workService; private final WorkService workService;
private final MailSourceService mailSourceService;
@NotPower @NotPower
@GetMapping("{workState}") @GetMapping("{workState}")
@ -39,12 +41,26 @@ public class WorkController {
@NotPower @NotPower
@PostMapping("export") @PostMapping("export")
public void detail(HttpServletResponse response, @RequestBody String dataWorkVo) throws IOException { public void detail(HttpServletResponse response, @RequestBody String dataWorkVo) throws IOException {
List<WorkVo> data = JSON.parseArray(dataWorkVo, WorkVo.class); workService.export(response, dataWorkVo);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); }
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 @NotPower
String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20"); @PostMapping("import")
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); @Transactional(rollbackFor = Exception.class)
EasyExcel.write(response.getOutputStream(), WorkVo.class).sheet("模板").doWrite(data); public AjaxResult<Void> importExcel(@RequestBody String workVoList) {
List<WorkVo> data = JSON.parseArray(workVoList, WorkVo.class);
return workService.saveExcelBatch(data) && mailSourceService.saveExcelBatch(data) ? AjaxResult.success() : AjaxResult.failed("导入失败");
}
@NotPower
@PostMapping("check")
public AjaxResult<List<WorkVo>> check(MultipartFile file, MailQuery mailQuery) throws IOException {
return workService.checkExcel(file, mailQuery);
}
@NotPower
@GetMapping("dissatisfied")
public AjaxResult<Page<WorkVo>> dissatisfied(Page<Work> page, MailQuery todoQuery) {
return AjaxResult.success(workService.dissatisfied(page, todoQuery));
} }
} }

14
mailbox-lan/src/main/java/com/biutag/lan/domain/vo/WorkVo.java

@ -12,7 +12,7 @@ import java.time.LocalDateTime;
@Getter @Getter
public class WorkVo { public class WorkVo {
@ExcelIgnore @ExcelProperty("工作流ID")
private Integer id; private Integer id;
/** /**
@ -27,7 +27,7 @@ public class WorkVo {
@ExcelProperty("联系电话") @ExcelProperty("联系电话")
private String contactPhone; private String contactPhone;
@ExcelIgnore @ExcelProperty("联系人身份证号")
private String contactIdCard; private String contactIdCard;
/** /**
@ -52,13 +52,13 @@ public class WorkVo {
/** /**
* 信件ID * 信件ID
*/ */
@ExcelProperty("信件ID")
private String mailId; private String mailId;
/** /**
* 信件等级 * 信件等级
*/ */
@ExcelIgnore @ExcelProperty("信件等级")
private String mailLevel; private String mailLevel;
/** /**
@ -76,7 +76,7 @@ public class WorkVo {
/** /**
* 信件流程节点 * 信件流程节点
*/ */
@ExcelIgnore @ExcelProperty("流程节点ID")
private String flowKey; private String flowKey;
/** /**
@ -94,7 +94,7 @@ public class WorkVo {
/** /**
* 办理单位ID三级单位 * 办理单位ID三级单位
*/ */
@ExcelIgnore @ExcelProperty("办理单位ID-三级")
private Integer threeDeptId; private Integer threeDeptId;
@ExcelProperty("办理单位") @ExcelProperty("办理单位")
@ -103,7 +103,7 @@ public class WorkVo {
/** /**
* 工作类型 * 工作类型
*/ */
@ExcelIgnore @ExcelProperty("工作类型")
private String workType; private String workType;
/** /**

2
mailbox-lan/src/main/java/com/biutag/lan/mapper/WorkMapper.java

@ -16,4 +16,6 @@ public interface WorkMapper extends BaseMapper<Work> {
@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}") @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 selectCount(String flowKey, Integer deptId);
@Select("select count(w.mail_id) from work w where w.mail_id = #{mailId}")
Integer countByFilter(String mailId);
} }

54
mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java

@ -0,0 +1,54 @@
package com.biutag.lan.service;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.biutag.lan.domain.Work;
import com.biutag.lan.domain.bo.MailQuery;
import com.biutag.lan.domain.vo.WorkVo;
import com.biutag.lan.mapper.WorkMapper;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@Getter
public class ExcelService implements ReadListener<WorkVo> {
private List<Work> dbDatalist;
private List<WorkVo> excelDatalist = new ArrayList<>();
private List<WorkVo> result;
private final WorkMapper workMapper;
private final MailQuery mailQuery;
public ExcelService(WorkMapper workMapper, MailQuery mailQuery) {
this.workMapper = workMapper;
this.mailQuery = mailQuery;
}
@Override
public void invoke(WorkVo workVo, AnalysisContext analysisContext) {
excelDatalist.add(workVo);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
QueryWrapper<Work> queryWrapper = new QueryWrapper<Work>()
.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());
dbDatalist = workMapper.selectList(queryWrapper);
for (int i = 0; i < excelDatalist.size(); i++) {
WorkVo workVo = excelDatalist.get(i);
for (Work work : dbDatalist) {
if (work.getMailId().equals(workVo.getMailId())) {
excelDatalist.remove(workVo);
i--; // 减去索引以补偿移除的元素
break; // 一旦找到匹配并移除,跳出内循环
}
}
}
result = excelDatalist;
}
}

3
mailbox-lan/src/main/java/com/biutag/lan/service/IMailLabelService.java

@ -1,5 +1,6 @@
package com.biutag.lan.service; package com.biutag.lan.service;
import com.biutag.core.AjaxResult;
import com.biutag.lan.validate.system.MailLabelInsertValidate; import com.biutag.lan.validate.system.MailLabelInsertValidate;
import com.biutag.lan.validate.system.MailLabelValidate; import com.biutag.lan.validate.system.MailLabelValidate;
import com.biutag.lan.vo.system.MailLabelVO; import com.biutag.lan.vo.system.MailLabelVO;
@ -9,7 +10,7 @@ import java.util.List;
public interface IMailLabelService { public interface IMailLabelService {
List<MailLabelVO> allLabels(); List<MailLabelVO> allLabels();
void addLabel(MailLabelValidate mailLabel); AjaxResult<Void> addLabel(MailLabelValidate mailLabel);
void insertLabel(MailLabelInsertValidate mailLabel); void insertLabel(MailLabelInsertValidate mailLabel);
} }

23
mailbox-lan/src/main/java/com/biutag/lan/service/MailSourceService.java

@ -5,11 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.lan.domain.MailSource; import com.biutag.lan.domain.MailSource;
import com.biutag.lan.domain.bo.MailOuter; import com.biutag.lan.domain.bo.MailOuter;
import com.biutag.lan.domain.vo.WorkVo;
import com.biutag.lan.mapper.MailSourceMapper; import com.biutag.lan.mapper.MailSourceMapper;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -18,6 +22,8 @@ import java.util.stream.Collectors;
public class MailSourceService extends ServiceImpl<MailSourceMapper, MailSource> { public class MailSourceService extends ServiceImpl<MailSourceMapper, MailSource> {
private final WorkService workService; private final WorkService workService;
@Resource
private MailSourceMapper mailSourceMapper;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean saveBatch(List<MailOuter> mailOuterList) { public boolean saveBatch(List<MailOuter> mailOuterList) {
@ -37,4 +43,21 @@ public class MailSourceService extends ServiceImpl<MailSourceMapper, MailSource>
return count(queryWrapper); return count(queryWrapper);
} }
public boolean saveExcelBatch(List<WorkVo> mailSources) {
LocalDateTime now = LocalDateTime.now();
List<MailSource> list = mailSources.stream().map(mail -> {
MailSource mail1 = new MailSource();
BeanUtils.copyProperties(mail, mail1);
mail1.setId(mail.getMailId())
.setState(mail.getMailState());
return mail1;
}).filter(mail -> {
QueryWrapper<MailSource> queryWrapper = new QueryWrapper<MailSource>()
.eq("id", mail.getId());
return !(mailSourceMapper.selectCount(queryWrapper) > 0);
}).collect(Collectors.toList());
return saveBatch(list);
}
} }

81
mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java

@ -1,10 +1,13 @@
package com.biutag.lan.service; package com.biutag.lan.service;
import cn.hutool.core.util.StrUtil; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.core.AjaxResult;
import com.biutag.enums.RoleEnum; import com.biutag.enums.RoleEnum;
import com.biutag.lan.AdminThreadLocal; import com.biutag.lan.AdminThreadLocal;
import com.biutag.lan.domain.Mail; import com.biutag.lan.domain.Mail;
@ -17,10 +20,14 @@ import com.biutag.lan.enums.WorkType;
import com.biutag.lan.mapper.MailLabelMapper; import com.biutag.lan.mapper.MailLabelMapper;
import com.biutag.lan.mapper.WorkMapper; import com.biutag.lan.mapper.WorkMapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; 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.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -33,6 +40,9 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
@Resource @Resource
private MailLabelMapper mailLabelMapper; private MailLabelMapper mailLabelMapper;
@Resource
private WorkMapper workMapper;
public boolean saveBatch(List<MailSource> mailSources) { public boolean saveBatch(List<MailSource> mailSources) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
List<Work> list = mailSources.stream().map(mail -> { List<Work> list = mailSources.stream().map(mail -> {
@ -51,6 +61,17 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
return saveBatch(list); return saveBatch(list);
} }
public boolean saveExcelBatch(List<WorkVo> mailSources) {
LocalDateTime now = LocalDateTime.now();
List<Work> list = mailSources.stream().map(mail -> {
Work work = new Work();
BeanUtils.copyProperties(mail, work);
return work;
}).filter(mail -> !(workMapper.countByFilter(mail.getMailId()) > 0)).collect(Collectors.toList());
return saveBatch(list);
}
public boolean save(Mail mail, String empNo, LocalDateTime time) { public boolean save(Mail mail, String empNo, LocalDateTime time) {
Work work = new Work(); Work work = new Work();
BeanUtils.copyProperties(mail, work); BeanUtils.copyProperties(mail, work);
@ -308,7 +329,63 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
return result; return result;
} }
public WorkVo exportWork(Long id) { public void export(HttpServletResponse response, String dataWorkVo) throws IOException {
return new WorkVo(); 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 Page<WorkVo> dissatisfied(Page<Work> page, MailQuery 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);
}
public AjaxResult<List<WorkVo>> checkExcel(MultipartFile file, MailQuery mailQuery) throws IOException {
ExcelService excelService = new ExcelService(workMapper, mailQuery);
EasyExcel.read(file.getInputStream(), WorkVo.class, excelService).sheet().doRead();
return AjaxResult.success(excelService.getResult());
} }
} }

9
mailbox-lan/src/main/java/com/biutag/lan/service/impl/MailLabelServiceImpl.java

@ -1,6 +1,7 @@
package com.biutag.lan.service.impl; package com.biutag.lan.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.biutag.core.AjaxResult;
import com.biutag.lan.domain.Mail; import com.biutag.lan.domain.Mail;
import com.biutag.lan.domain.MailLabel; import com.biutag.lan.domain.MailLabel;
import com.biutag.lan.mapper.MailLabelMapper; import com.biutag.lan.mapper.MailLabelMapper;
@ -47,10 +48,16 @@ public class MailLabelServiceImpl implements IMailLabelService {
* @param mailLabel * @param mailLabel
*/ */
@Override @Override
public void addLabel(MailLabelValidate mailLabel) { public AjaxResult<Void> addLabel(MailLabelValidate mailLabel) {
MailLabel label = new MailLabel(); MailLabel label = new MailLabel();
MailLabel existLabel = mailLabelMapper.selectOne(new QueryWrapper<MailLabel>().eq("label_name", mailLabel.getLabelName()));
if (existLabel == null) {
label.setLabelName(mailLabel.getLabelName()); label.setLabelName(mailLabel.getLabelName());
mailLabelMapper.insert(label); mailLabelMapper.insert(label);
return AjaxResult.success();
} else {
return AjaxResult.failed("标签已存在");
}
} }
@Override @Override

Loading…
Cancel
Save