|
|
|
@ -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()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|