Compare commits

...

2 Commits

  1. 3
      mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java
  2. 94
      mailbox-lan/src/main/java/com/biutag/lan/domain/vo/LedgerExcel.java
  3. 2
      mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailExcel.java
  4. 102
      mailbox-lan/src/main/java/com/biutag/lan/service/WorkService.java

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

@ -51,7 +51,8 @@ public class WorkController {
@NotPower
@PostMapping("exportLedger")
public void exportLedger(HttpServletResponse response, MailQuery mailQuery) throws IOException {
public void exportLedger(HttpServletResponse response, @RequestBody String data) throws IOException {
MailQuery mailQuery = JSON.parseObject(data,MailQuery.class);
workService.exportLedger(response, mailQuery);
}

94
mailbox-lan/src/main/java/com/biutag/lan/domain/vo/LedgerExcel.java

@ -0,0 +1,94 @@
package com.biutag.lan.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
@ApiOperation("台账导出模板")
public class LedgerExcel {
@ExcelProperty({"局长信箱即接即办工作汇总台账", "序号"})
private String serialNumber;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "台账编号"})
private String ledgerNumber;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "原渠道编号"})
private String id;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "线索来源"})
private String source;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "受理时间"})
private String createTime;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "信访人姓名"})
private String contactName;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "电话"})
private String contactPhone;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "被投诉单位"})
private String involvedDeptName;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "被投诉所队"})
private String involvedTeamName;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "举报投诉事项"})
private String content;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "是否十分钟内签收"})
private String isTenMinutes;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "是否三十分钟内回访"})
private String isThirtyMinutes;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "是否接访"})
private String isVisit;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "是否四天内办结"})
private String isFourDays;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "逾期办结"})
private String isOverdue;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "处理结果"})
private String resolveResult;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "备注分析"})
private String remark;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "问题分类(可多选)"})
private String category;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "电访日期"})
private String tellDate;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "电访时间"})
private String tellTime;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "满意与否"})
private String isSatisfaction;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "不满意原因"})
private String unsatisfactoryReason;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "申诉结果"})
private String appealResult;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "典型件"})
private String typicalMail;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "是否属实"})
private String isTrue;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "是否合格"})
private String isQualify;
@ExcelProperty({"局长信箱即接即办工作汇总台账", "扣分项"})
private String demeritPoints;
}

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

@ -1,6 +1,7 @@
package com.biutag.lan.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Getter;
import lombok.Setter;
@ -8,6 +9,7 @@ import java.time.LocalDateTime;
@Setter
@Getter
@ApiOperation("信件导出模板")
public class MailExcel {
@ExcelProperty("信件编号")
private String id;

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

@ -10,12 +10,14 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.core.AjaxResult;
import com.biutag.entity.setting.DictData;
import com.biutag.entity.system.Dept;
import com.biutag.enums.RoleEnum;
import com.biutag.exception.BusinessException;
import com.biutag.lan.config.AdminThreadLocal;
import com.biutag.lan.domain.*;
import com.biutag.lan.domain.bo.MailQuery;
import com.biutag.lan.domain.vo.LedgerExcel;
import com.biutag.lan.domain.vo.MailExcel;
import com.biutag.lan.domain.vo.QueryMailVo;
import com.biutag.lan.domain.vo.WorkVo;
@ -25,6 +27,7 @@ import com.biutag.lan.flow.FlowNameEnum;
import com.biutag.lan.flow.FlowNodeEnum;
import com.biutag.lan.flow.node.FirstSignFlow;
import com.biutag.lan.mapper.*;
import com.biutag.mapper.setting.DictDataMapper;
import com.biutag.mapper.system.DeptMapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
@ -38,9 +41,8 @@ import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@RequiredArgsConstructor
@ -50,9 +52,14 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
@Resource
private MailLabelMapper mailLabelMapper;
@Resource
private MailAppealMapper mailAppealMapper;
@Resource
private MailCategoryMapper mailCategoryMapper;
@Resource
private DictDataMapper dictDataMapper;
@Resource
private WorkMapper workMapper;
@ -652,7 +659,94 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
return AjaxResult.success(excelService.getResult());
}
public void exportLedger(HttpServletResponse response, MailQuery mailQuery) {
public String nullToEmpty(Object value) {
return value == null ? "" : value.toString();
}
public String turnSatisfaction(String en) {
if (en == null)
return "";
else {
switch (en) {
case "satisfied":
return "非常满意";
case "basically_satisfied":
return "基本满意";
case "not_satisfied":
return "不满意";
default:
return "";
}
}
}
public void exportLedger(HttpServletResponse response, MailQuery mailQuery) throws IOException {
List<QueryMailVo> data = queryPage(new Page<>(1, 10000), mailQuery).getRecords();
List<String> mailIds = data.stream().map(QueryMailVo::getId).collect(Collectors.toList());
List<Mail> mailList = mailMapper.selectBatchIds(mailIds);
List<MailAppeal> appealList = mailAppealMapper.selectList(null);
List<DictData> dictData = dictDataMapper.selectList(null);
List<LedgerExcel> list = new ArrayList<>();
for (int i = 0; i < data.size(); i++) {
QueryMailVo q = data.get(i);
Mail m = new Mail();
if (i < mailList.size())
m = mailList.get(i);
LedgerExcel ledgerExcel = new LedgerExcel();
ledgerExcel.setId(nullToEmpty(q.getId()));
ledgerExcel.setSource((dictData.stream()
.filter(r -> r.getValue().equals(nullToEmpty(q.getSource())))
.collect(Collectors.toList()).get(0).getName()));
ledgerExcel.setCreateTime(m.getCreateTime() == null ? "" : m.getCreateTime().toString());
ledgerExcel.setContactName(nullToEmpty(q.getContactName()));
ledgerExcel.setContactPhone(nullToEmpty(q.getContactPhone()));
ledgerExcel.setInvolvedDeptName(StrUtil.isNotBlank(m.getInvolvedDeptName()) ? m.getInvolvedDeptName() : "");
ledgerExcel.setContent(nullToEmpty(q.getContent()));
ledgerExcel.setIsThirtyMinutes(m.getContactDuration() != null && m.getContactDuration() > 30 * 60 ? "是" : "否");
ledgerExcel.setIsVisit(m.getInterviewIsLeader() != null && m.getInterviewIsLeader() ? "是" : "否");
ledgerExcel.setResolveResult(turnSatisfaction((m.getSatisfaction())));
ledgerExcel.setCategory(nullToEmpty(m.getMailFirstCategory()) + "->" + nullToEmpty(m.getMailSecondCategory()) + "->" + nullToEmpty(m.getMailThreeCategory()));
if (m.getContactTime() != null) {
ledgerExcel.setTellDate(m.getContactTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
ledgerExcel.setTellTime(m.getContactTime().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
} else {
ledgerExcel.setTellDate("");
ledgerExcel.setTellTime("");
}
ledgerExcel.setIsSatisfaction(nullToEmpty(m.getSatisfactionStatus()));
String appealResult = "";
for (MailAppeal map : appealList) {
if (map.getMailId().equals(q.getId())) {
appealResult = map.getAppealState().equals("2") ? "成功" : "失败";
break;
}
}
ledgerExcel.setAppealResult(appealResult);
ledgerExcel.setIsTrue(nullToEmpty(m.getVerifyIsTrue()));
ledgerExcel.setIsQualify(nullToEmpty(m.getQualifiedProcessingStatus()));
list.add(ledgerExcel);
}
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");
try (OutputStream out = response.getOutputStream()) {
// 使用EasyExcel写入数据到输出流
EasyExcel.write(out, LedgerExcel.class).inMemory(Boolean.TRUE).sheet("模板").doWrite(list);
} 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.");
}
}
}
}
Loading…
Cancel
Save