Browse Source

修改优化excel功能

dev_ycq
21819 2 years ago
parent
commit
48761479fb
  1. 13
      mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java
  2. 75
      mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java
  3. 422
      mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailExcel.java
  4. 29
      mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java
  5. 7
      mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java

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

@ -7,9 +7,10 @@ import com.biutag.core.AjaxResult;
import com.biutag.lan.domain.Mail;
import com.biutag.lan.domain.Work;
import com.biutag.lan.domain.bo.MailQuery;
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.service.MailSourceService;
import com.biutag.lan.service.MailService;
import com.biutag.lan.service.WorkService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
@ -25,7 +26,7 @@ import java.util.List;
public class WorkController {
private final WorkService workService;
private final MailSourceService mailSourceService;
private final MailService mailService;
@NotPower
@GetMapping("{workState}")
@ -47,14 +48,14 @@ public class WorkController {
@NotPower
@PostMapping("import")
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("导入失败");
public AjaxResult<Void> importExcel(@RequestBody String mailList) {
List<Mail> data = JSON.parseArray(mailList, Mail.class);
return mailService.saveBatch(data) ? AjaxResult.success() : AjaxResult.failed("导入失败");
}
@NotPower
@PostMapping("check")
public AjaxResult<List<QueryMailVo>> check(MultipartFile file, MailQuery mailQuery) throws IOException {
public AjaxResult<List<MailExcel>> check(MultipartFile file, MailQuery mailQuery) throws IOException {
return workService.checkExcel(file, mailQuery);
}

75
mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java

@ -1,6 +1,5 @@
package com.biutag.lan.domain;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
@ -14,69 +13,56 @@ import java.time.LocalDateTime;
public class Mail {
@TableId
@ExcelProperty("信件id")
private String id;
/**
* 联系人姓名
*/
@ExcelProperty("联系人姓名")
private String contactName;
/**
* 联系人性别 M / F
*/
@ExcelProperty("联系人性别")
private String contactSex;
/**
* 联系人身份证号码
*/
@ExcelProperty("联系人身份证号码")
private String contactIdCard;
/**
* 联系人手机号
*/
@ExcelProperty("联系人手机号")
private String contactPhone;
/**
* 案件编号
*/
@ExcelProperty("案件编号")
private String caseNumber;
/**
* 内容
*/
@ExcelProperty("内容")
private String content;
/**
* 附件
*/
@ExcelProperty("附件")
private String attachments;
/**
* 创建时间
*/
@ExcelProperty("创建时间")
private LocalDateTime createTime;
/**
* 更新时间
*/
@ExcelProperty("更新时间")
private LocalDateTime updateTime;
/**
* 来信时间
*/
@ExcelProperty("来信时间")
private LocalDateTime mailTime;
/**
* 来源
*/
@ExcelProperty("来源")
private String source;
/**
* 满意读(群众)
*/
@ExcelProperty("满意度(群众)")
private String satisfaction;
/*-------------------------------*/
@ -84,343 +70,282 @@ public class Mail {
/**
* 信件状态
*/
@ExcelProperty("信件状态")
private String mailState;
/**
* 信件当前流程
*/
@ExcelProperty("信件当前流程")
private String flowKey;
/**
* 信件当前流程节点
*/
@ExcelProperty("信件当前流程节点")
private String flowBeforeName;
/**
* 流程限时最后操作时间
*/
@ExcelProperty("流程限时最后操作时间")
private LocalDateTime flowLimitedLastHandlerTime;
/**
* 信件源数据ID 多个
*/
@ExcelProperty("信件源数据ID")
private String mailSourceId;
/**
* 信件类名
*/
@ExcelProperty("信件类名")
private String mailCategory;
/**
* 信件一级类目
*/
@ExcelProperty("信件一级类目")
private String mailFirstCategory;
/**
* 信件二级类目
*/
@ExcelProperty("信件二级类目")
private String mailSecondCategory;
/**
* 信件三级类目
*/
@ExcelProperty("信件三级类目")
private String mailThreeCategory;
/**
* 信件等级
*/
@ExcelProperty("信件等级")
private String mailLevel;
/**
* 二级单位ID(主责)
*/
@ExcelProperty("二级单位ID(主责)")
private Integer secondDeptId;
@ExcelProperty("二级单位名称(主责)")
private String secondDeptName;
/**
* 三级单位ID(主责)
*/
@ExcelProperty("三级单位ID(主责)")
private Integer threeDeptId;
@ExcelProperty("三级单位名称(主责)")
private String threeDeptName;
/**
* 协办核查民警String
*/
@ExcelProperty("协办核查民警")
private String coHandlingPolices;
/**
* 联系民警名称
*/
@ExcelProperty("联系民警姓名")
private String contactPoliceName;
/**
* 联系民警
*/
@ExcelProperty("联系民警")
private String contactPoliceEmpNo;
/**
* 联系民警职位
*/
@ExcelProperty("联系民警职位")
private String contactPolicePost;
/**
* 联系群众时间
*/
@ExcelProperty("联系群众时间")
private LocalDateTime contactTime;
/**
* 联系时长
*/
@ExcelProperty("联系时长")
private Long contactDuration;
/**
* 是否联系群众
*/
@ExcelProperty("是否联系群众")
private Boolean contactFlag;
/**
* 接访形式
*/
@ExcelProperty("接访形式")
private String interviewType;
/**
* 是否领导接访
*/
@ExcelProperty("是否领导接访")
private Boolean interviewIsLeader;
/**
* 接访人员警号
*/
@ExcelProperty("接访人员警号")
private String interviewPoliceEmpNo;
/**
* 接访人员姓名
*/
@ExcelProperty("接访人员姓名")
private String interviewPoliceName;
/**
* 接访情况
*/
@ExcelProperty("接访情况")
private String interviewDetails;
/**
* 接访附件佐证材料
*/
@ExcelProperty("接访附件")
private String interviewAttachments;
/**
* 核办情况
*/
@ExcelProperty("核办情况")
private String verifyDetails;
/**
* 核办-是否属实
*/
@ExcelProperty("核办-是否属实")
private String verifyIsTrue;
/**
* 核办-被举报对象json
*/
@ExcelProperty("核办-被举报对象")
private String verifyReportedPolices;
/**
* 核办-查证属实问题json
*/
@ExcelProperty("核办-查证属实问题")
private String verifyProblem;
/**
* 核办-是否需要问责
*/
@ExcelProperty("核办-是否需要问责")
private Boolean verifyNeedAccountability;
/**
* 核办-责任追究json
*/
@ExcelProperty("核办-责任追究")
private String verifyPunish;
/**
* 核办-群众反映事项解决情况(是否已解决)
*/
@ExcelProperty("核办-群众反映事项解决情况")
private Boolean verifyIsResolved;
/**
* 核办-办理反馈情况
*/
@ExcelProperty("核办-办理反馈情况")
private String verifyFeedback;
/**
* 核办-回访人信息(String)
*/
@ExcelProperty("核办-回访人信息")
private String verifyFollowupPolice;
/**
* 核办-附件上传佐证
*/
@ExcelProperty("核办-附件")
private String verifyAttachments;
/**
* 办结方式
*/
@ExcelProperty("办结方式")
private String completeMethod;
/**
* 办理合格情况
*/
@ExcelProperty("办理合格情况")
private String qualifiedProcessingStatus;
/**
* 问题解决情况
*/
@ExcelProperty("问题解决情况")
private Boolean problemSolvingStatus;
/**
* 群众回复情况
*/
@ExcelProperty("群众回复情况")
private String satisfactionStatus;
/**
* 认定办结意见
*/
@ExcelProperty("认定办结意见")
private String completionComment;
/**
* 是否是简易流程
*/
@ExcelProperty("是否是简易流程")
private Boolean simpleFlowFlag;
/**
* 涉及单位ID
*/
@ExcelProperty("涉及单位ID")
private Integer involvedDeptId;
/**
* 涉及单位名称
*/
@ExcelProperty("涉及单位名称")
private String involvedDeptName;
/**
* 会签部门总数
*/
@ExcelProperty("会签部门总数")
private Integer countersignTotal;
/**
* 会签完成部门数量
*/
@ExcelProperty("会签完成部门数量")
private Integer countersignCompleted;
/**
* 会签发起人
*/
@ExcelProperty("会签发起人")
private String countersignPromoterEmpNo;
/**
* 会签发起姓名
*/
@ExcelProperty("会签发起姓名")
private String countersignPromoterName;
/**
* 会签发起部门ID
*/
@ExcelProperty("会签发起部门ID")
private Integer countersignPromoterDeptId;
/**
* 会签发起部门名称
*/
@ExcelProperty("会签发起部门名称")
private String countersignPromoterDeptName;
/**
* 会签具体要求
*/
@ExcelProperty("会签具体要求")
private String countersignRequirement;
/**
* 信件标签
*/
@ExcelProperty("信件标签")
private String mailLabels;
/**
* 当前操作人
*/
@ExcelProperty("当前操作人")
private String currentOperator;
/**
* 是否申请延期
*/
@ExcelProperty("是否申请延期")
private Boolean extensionFlag;
/**
* 延期天数
*/
@ExcelProperty("延期天数")
private Integer extensionDays;
/**
* 延期理由
*/
@ExcelProperty("延期理由")
private String extensionReason;
/**
* 延期状态
*/
@ExcelProperty("延期状态")
private String extensionState;
/**
* 无效判定理由
*/
@ExcelProperty("无效判定理由")
private String invalidationReason;
/**
* 市局下发信息
*/
@ExcelProperty("市局下发信息")
private String firstDistributeInfo;
/**
* 二级单位下发信息
*/
@ExcelProperty("二级单位下发信息")
private String secondDistributeInfo;
}

422
mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailExcel.java

@ -0,0 +1,422 @@
package com.biutag.lan.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class MailExcel {
@TableId
@ExcelProperty("信件id")
private String id;
/**
* 联系人姓名
*/
@ExcelProperty("联系人姓名")
private String contactName;
/**
* 联系人性别 M / F
*/
@ExcelProperty("联系人性别")
private String contactSex;
/**
* 联系人身份证号码
*/
@ExcelProperty("联系人身份证号码")
private String contactIdCard;
/**
* 联系人手机号
*/
@ExcelProperty("联系人手机号")
private String contactPhone;
/**
* 案件编号
*/
@ExcelProperty("案件编号")
private String caseNumber;
/**
* 内容
*/
@ExcelProperty("内容")
private String content;
/**
* 附件
*/
@ExcelProperty("附件")
private String attachments;
/**
* 创建时间
*/
@ExcelProperty("创建时间")
private LocalDateTime createTime;
/**
* 更新时间
*/
@ExcelProperty("更新时间")
private LocalDateTime updateTime;
/**
* 来信时间
*/
@ExcelProperty("来信时间")
private LocalDateTime mailTime;
/**
* 来源
*/
@ExcelProperty("来源")
private String source;
/**
* 满意读(群众)
*/
@ExcelProperty("满意度(群众)")
private String satisfaction;
/*-------------------------------*/
/**
* 信件状态
*/
@ExcelProperty("信件状态")
private String mailState;
/**
* 信件当前流程
*/
@ExcelProperty("信件当前流程")
private String flowKey;
/**
* 信件当前流程节点
*/
@ExcelProperty("信件当前流程节点")
private String flowBeforeName;
/**
* 流程限时最后操作时间
*/
@ExcelProperty("流程限时最后操作时间")
private LocalDateTime flowLimitedLastHandlerTime;
/**
* 信件源数据ID 多个
*/
@ExcelProperty("信件源数据ID")
private String mailSourceId;
/**
* 信件类名
*/
@ExcelProperty("信件类名")
private String mailCategory;
/**
* 信件一级类目
*/
@ExcelProperty("信件一级类目")
private String mailFirstCategory;
/**
* 信件二级类目
*/
@ExcelProperty("信件二级类目")
private String mailSecondCategory;
/**
* 信件三级类目
*/
@ExcelProperty("信件三级类目")
private String mailThreeCategory;
/**
* 信件等级
*/
@ExcelProperty("信件等级")
private String mailLevel;
/**
* 二级单位ID(主责)
*/
@ExcelProperty("二级单位ID(主责)")
private Integer secondDeptId;
@ExcelProperty("二级单位名称(主责)")
private String secondDeptName;
/**
* 三级单位ID(主责)
*/
@ExcelProperty("三级单位ID(主责)")
private Integer threeDeptId;
@ExcelProperty("三级单位名称(主责)")
private String threeDeptName;
/**
* 协办核查民警String
*/
@ExcelProperty("协办核查民警")
private String coHandlingPolices;
/**
* 联系民警名称
*/
@ExcelProperty("联系民警姓名")
private String contactPoliceName;
/**
* 联系民警
*/
@ExcelProperty("联系民警")
private String contactPoliceEmpNo;
/**
* 联系民警职位
*/
@ExcelProperty("联系民警职位")
private String contactPolicePost;
/**
* 联系群众时间
*/
@ExcelProperty("联系群众时间")
private LocalDateTime contactTime;
/**
* 联系时长
*/
@ExcelProperty("联系时长")
private Long contactDuration;
/**
* 是否联系群众
*/
@ExcelProperty("是否联系群众")
private Boolean contactFlag;
/**
* 接访形式
*/
@ExcelProperty("接访形式")
private String interviewType;
/**
* 是否领导接访
*/
@ExcelProperty("是否领导接访")
private Boolean interviewIsLeader;
/**
* 接访人员警号
*/
@ExcelProperty("接访人员警号")
private String interviewPoliceEmpNo;
/**
* 接访人员姓名
*/
@ExcelProperty("接访人员姓名")
private String interviewPoliceName;
/**
* 接访情况
*/
@ExcelProperty("接访情况")
private String interviewDetails;
/**
* 接访附件佐证材料
*/
@ExcelProperty("接访附件")
private String interviewAttachments;
/**
* 核办情况
*/
@ExcelProperty("核办情况")
private String verifyDetails;
/**
* 核办-是否属实
*/
@ExcelProperty("核办-是否属实")
private String verifyIsTrue;
/**
* 核办-被举报对象json
*/
@ExcelProperty("核办-被举报对象")
private String verifyReportedPolices;
/**
* 核办-查证属实问题json
*/
@ExcelProperty("核办-查证属实问题")
private String verifyProblem;
/**
* 核办-是否需要问责
*/
@ExcelProperty("核办-是否需要问责")
private Boolean verifyNeedAccountability;
/**
* 核办-责任追究json
*/
@ExcelProperty("核办-责任追究")
private String verifyPunish;
/**
* 核办-群众反映事项解决情况(是否已解决)
*/
@ExcelProperty("核办-群众反映事项解决情况")
private Boolean verifyIsResolved;
/**
* 核办-办理反馈情况
*/
@ExcelProperty("核办-办理反馈情况")
private String verifyFeedback;
/**
* 核办-回访人信息(String)
*/
@ExcelProperty("核办-回访人信息")
private String verifyFollowupPolice;
/**
* 核办-附件上传佐证
*/
@ExcelProperty("核办-附件")
private String verifyAttachments;
/**
* 办结方式
*/
@ExcelProperty("办结方式")
private String completeMethod;
/**
* 办理合格情况
*/
@ExcelProperty("办理合格情况")
private String qualifiedProcessingStatus;
/**
* 问题解决情况
*/
@ExcelProperty("问题解决情况")
private Boolean problemSolvingStatus;
/**
* 群众回复情况
*/
@ExcelProperty("群众回复情况")
private String satisfactionStatus;
/**
* 认定办结意见
*/
@ExcelProperty("认定办结意见")
private String completionComment;
/**
* 是否是简易流程
*/
@ExcelProperty("是否是简易流程")
private Boolean simpleFlowFlag;
/**
* 涉及单位ID
*/
@ExcelProperty("涉及单位ID")
private Integer involvedDeptId;
/**
* 涉及单位名称
*/
@ExcelProperty("涉及单位名称")
private String involvedDeptName;
/**
* 会签部门总数
*/
@ExcelProperty("会签部门总数")
private Integer countersignTotal;
/**
* 会签完成部门数量
*/
@ExcelProperty("会签完成部门数量")
private Integer countersignCompleted;
/**
* 会签发起人
*/
@ExcelProperty("会签发起人")
private String countersignPromoterEmpNo;
/**
* 会签发起姓名
*/
@ExcelProperty("会签发起姓名")
private String countersignPromoterName;
/**
* 会签发起部门ID
*/
@ExcelProperty("会签发起部门ID")
private Integer countersignPromoterDeptId;
/**
* 会签发起部门名称
*/
@ExcelProperty("会签发起部门名称")
private String countersignPromoterDeptName;
/**
* 会签具体要求
*/
@ExcelProperty("会签具体要求")
private String countersignRequirement;
/**
* 信件标签
*/
@ExcelProperty("信件标签")
private String mailLabels;
/**
* 当前操作人
*/
@ExcelProperty("当前操作人")
private String currentOperator;
/**
* 是否申请延期
*/
@ExcelProperty("是否申请延期")
private Boolean extensionFlag;
/**
* 延期天数
*/
@ExcelProperty("延期天数")
private Integer extensionDays;
/**
* 延期理由
*/
@ExcelProperty("延期理由")
private String extensionReason;
/**
* 延期状态
*/
@ExcelProperty("延期状态")
private String extensionState;
/**
* 无效判定理由
*/
@ExcelProperty("无效判定理由")
private String invalidationReason;
/**
* 市局下发信息
*/
@ExcelProperty("市局下发信息")
private String firstDistributeInfo;
/**
* 二级单位下发信息
*/
@ExcelProperty("二级单位下发信息")
private String secondDistributeInfo;
}

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

@ -6,21 +6,20 @@ import com.alibaba.excel.read.listener.ReadListener;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.biutag.lan.domain.Mail;
import com.biutag.lan.domain.bo.MailQuery;
import com.biutag.lan.domain.vo.QueryMailVo;
import com.biutag.lan.domain.vo.MailExcel;
import com.biutag.lan.mapper.MailMapper;
import lombok.Getter;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
@Getter
public class ExcelService implements ReadListener<Mail> {
public class ExcelService implements ReadListener<MailExcel> {
private List<Mail> dbDatalist;
private List<Mail> excelDatalist = new ArrayList<>();
private List<MailExcel> excelDatalist = new ArrayList<>();
private List<QueryMailVo> result;
private List<MailExcel> result;
private final MailMapper mailMapper;
@ -33,8 +32,8 @@ public class ExcelService implements ReadListener<Mail> {
@Override
public void invoke(Mail mail, AnalysisContext analysisContext) {
excelDatalist.add(mail);
public void invoke(MailExcel mail, AnalysisContext analysisContext) {
excelDatalist.add(mail);//Accessors注解报错
}
@Override
@ -43,20 +42,16 @@ public class ExcelService implements ReadListener<Mail> {
.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 = mailMapper.selectList(queryWrapper);
for (int i = 0; i < excelDatalist.size(); i++) {
Mail excelMail = excelDatalist.get(i);
Iterator<MailExcel> iterator = excelDatalist.iterator();
while (iterator.hasNext()) {
MailExcel excelMail = iterator.next();
for (Mail mail : dbDatalist) {
if (excelMail.getId().equals(mail.getId())) {
excelDatalist.remove(excelMail);
i--; // 减去索引以补偿移除的元素
iterator.remove(); // 使用迭代器的remove方法安全删除元素
break; // 一旦找到匹配并移除,跳出内循环
}
}
}
result = excelDatalist.stream().map(mail -> {
QueryMailVo queryMailVo = new QueryMailVo();
BeanUtils.copyProperties(mail, queryMailVo);
return queryMailVo;
}).collect(Collectors.toList());
result = excelDatalist;
}
}

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

@ -15,6 +15,7 @@ import com.biutag.lan.domain.MailLabel;
import com.biutag.lan.domain.MailSource;
import com.biutag.lan.domain.Work;
import com.biutag.lan.domain.bo.MailQuery;
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.WorkType;
@ -333,7 +334,7 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
// 这里URLEncoder.encode可以防止中文乱码
String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), Mail.class).sheet("模板").doWrite(mailList);
EasyExcel.write(response.getOutputStream(), MailExcel.class).sheet("模板").doWrite(mailList);
}
public Page<QueryMailVo> dissatisfied(Page<Mail> page, MailQuery mailQuery) {
@ -398,9 +399,9 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
}
}
public AjaxResult<List<QueryMailVo>> checkExcel(MultipartFile file, MailQuery mailQuery) throws IOException {
public AjaxResult<List<MailExcel>> checkExcel(MultipartFile file, MailQuery mailQuery) throws IOException {
ExcelService excelService = new ExcelService(mailMapper, mailQuery);
EasyExcel.read(file.getInputStream(), Mail.class, excelService).sheet().doRead();
EasyExcel.read(file.getInputStream(), MailExcel.class, excelService).sheet().doRead();
return AjaxResult.success(excelService.getResult());
}
}
Loading…
Cancel
Save