|
|
|
|
@ -5,15 +5,19 @@ import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.io.IoUtil; |
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.core.util.ZipUtil; |
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.biutag.supervision.constants.enums.ComfortStatus; |
|
|
|
|
import com.biutag.supervision.constants.enums.PersonTypeEnum; |
|
|
|
|
import com.biutag.supervision.mapper.RpcComfortPacksMapper; |
|
|
|
|
import com.biutag.supervision.pojo.dto.ComfortPacksDto; |
|
|
|
|
import com.biutag.supervision.pojo.entity.RpcComfortPacks; |
|
|
|
|
import com.biutag.supervision.pojo.entity.RpcRightPerson; |
|
|
|
|
import com.biutag.supervision.pojo.entity.SupPolice; |
|
|
|
|
import com.biutag.supervision.pojo.vo.RpcApplyVo; |
|
|
|
|
import com.biutag.supervision.pojo.vo.RpcComfortPacksVo; |
|
|
|
|
import com.biutag.supervision.util.Arrays; |
|
|
|
|
@ -24,10 +28,13 @@ import freemarker.template.Version;
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
@ -40,9 +47,10 @@ public class RpcComfortPacksService extends ServiceImpl<RpcComfortPacksMapper, R
|
|
|
|
|
private final RpcPacksComfortService rpcPacksComfortService; |
|
|
|
|
|
|
|
|
|
private final RpcRightPersonService rpcRightPersonService; |
|
|
|
|
|
|
|
|
|
private final FileService fileService; |
|
|
|
|
|
|
|
|
|
private final SupPoliceService policeService; |
|
|
|
|
|
|
|
|
|
private final Template template1; |
|
|
|
|
|
|
|
|
|
private final Template template2; |
|
|
|
|
@ -53,11 +61,12 @@ public class RpcComfortPacksService extends ServiceImpl<RpcComfortPacksMapper, R
|
|
|
|
|
|
|
|
|
|
private final Template template5; |
|
|
|
|
|
|
|
|
|
public RpcComfortPacksService(RpcApplyService rpcApplyService, RpcPacksComfortService rpcPacksComfortService, RpcRightPersonService rpcRightPersonService, FileService fileService) throws IOException { |
|
|
|
|
public RpcComfortPacksService(RpcApplyService rpcApplyService, RpcPacksComfortService rpcPacksComfortService, RpcRightPersonService rpcRightPersonService, FileService fileService, SupPoliceService policeService) throws IOException { |
|
|
|
|
this.rpcApplyService = rpcApplyService; |
|
|
|
|
this.rpcPacksComfortService = rpcPacksComfortService; |
|
|
|
|
this.rpcRightPersonService = rpcRightPersonService; |
|
|
|
|
this.fileService = fileService; |
|
|
|
|
this.policeService = policeService; |
|
|
|
|
//
|
|
|
|
|
Configuration configuration = new Configuration(new Version("2.3.28")); |
|
|
|
|
configuration.setDefaultEncoding("UTF-8"); |
|
|
|
|
@ -65,10 +74,10 @@ public class RpcComfortPacksService extends ServiceImpl<RpcComfortPacksMapper, R
|
|
|
|
|
// 设置FreeMarker生成Word文档所需要的模板的路径
|
|
|
|
|
configuration.setClassLoaderForTemplateLoading(RpcComfortPacksService.class.getClassLoader(), ""); |
|
|
|
|
this.template1 = configuration.getTemplate("static/templates/ftl/1、抚慰金审批签呈.xml", "UTF-8"); |
|
|
|
|
this.template2 = configuration.getTemplate("static/templates/ftl/2、维权抚慰登记表.xml", "UTF-8"); |
|
|
|
|
this.template3 = configuration.getTemplate("static/templates/ftl/3、抚慰金申报批处理表.xml", "UTF-8"); |
|
|
|
|
this.template4 = configuration.getTemplate("static/templates/ftl/4、抚慰金申请发放明细表.xml", "UTF-8"); |
|
|
|
|
this.template5 = configuration.getTemplate("static/templates/ftl/5、民警维权抚慰申请表.xml", "UTF-8"); |
|
|
|
|
this.template2 = configuration.getTemplate("static/templates/ftl/2、抚慰金申报批处理表.xml", "UTF-8"); |
|
|
|
|
this.template3 = configuration.getTemplate("static/templates/ftl/3、维权抚慰登记表.xml", "UTF-8"); |
|
|
|
|
this.template4 = configuration.getTemplate("static/templates/ftl/4、抚慰金申请发放明细表.xml", "UTF-8"); |
|
|
|
|
this.template5 = configuration.getTemplate("static/templates/ftl/5、民警维权抚慰申请表.xml", "UTF-8"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -95,6 +104,13 @@ public class RpcComfortPacksService extends ServiceImpl<RpcComfortPacksMapper, R
|
|
|
|
|
}); |
|
|
|
|
save(rpcComfortPacks); |
|
|
|
|
rpcPacksComfortService.saveBatch(rpcComfortPacks.getId(), rpcIds); |
|
|
|
|
|
|
|
|
|
List<SupPolice> polices = policeService.list(new LambdaQueryWrapper<SupPolice>().in(SupPolice::getEmpNo, comfortPacksDto.getComforts().stream().map(RpcApplyVo::getApplicantEmpNo).toList())); |
|
|
|
|
comfortPacksDto.getComforts().forEach(item -> { |
|
|
|
|
String personType = polices.stream().filter(p -> p.getEmpNo().equals(item.getApplicantEmpNo())).findFirst().map(SupPolice::getPersonType).orElse(""); |
|
|
|
|
item.setPersonType(StrUtil.isNotBlank(personType) ? PersonTypeEnum.getLabel(personType) : ""); |
|
|
|
|
item.setHappenTimeStr(item.getHappenTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); |
|
|
|
|
}); |
|
|
|
|
// 生成呈报文件
|
|
|
|
|
genReports(rpcComfortPacks, comfortPacksDto.getComforts()); |
|
|
|
|
return true; |
|
|
|
|
@ -105,36 +121,65 @@ public class RpcComfortPacksService extends ServiceImpl<RpcComfortPacksMapper, R
|
|
|
|
|
comforts.forEach(item -> { |
|
|
|
|
item.setSexName(item.getSex() == 0 ? "男" : item.getSex() == 1 ?"女" : ""); |
|
|
|
|
}); |
|
|
|
|
String rightsPersons = rpcRightPersonService.listByCouncil().stream().map(RpcRightPerson::getEmpName).collect(Collectors.joining(" ")); |
|
|
|
|
//String rightsPersons = rpcRightPersonService.listByCouncil().stream().map(RpcRightPerson::getEmpName).collect(Collectors.joining(" "));
|
|
|
|
|
List<LocalDate> applyDates = comforts.stream().map(RpcApplyVo::getApplyDate).sorted().toList(); |
|
|
|
|
String applyMonth; |
|
|
|
|
String applyDate; |
|
|
|
|
List<String> distinctDates = applyDates.stream().map(item -> item.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))).distinct().toList(); |
|
|
|
|
LocalDate beginDate = applyDates.get(0); |
|
|
|
|
LocalDate endDate = applyDates.get(applyDates.size() - 1); |
|
|
|
|
// 同一日
|
|
|
|
|
if (distinctDates.size() == 1) { |
|
|
|
|
applyMonth = beginDate.format(DateTimeFormatter.ofPattern("yyyy年MM月")); |
|
|
|
|
applyDate = distinctDates.get(0); |
|
|
|
|
} else { |
|
|
|
|
// 同一年
|
|
|
|
|
if (beginDate.getYear() == endDate.getYear()) { |
|
|
|
|
// 同一月
|
|
|
|
|
if (beginDate.getMonth() == endDate.getMonth()) { |
|
|
|
|
applyMonth = beginDate.format(DateTimeFormatter.ofPattern("yyyy年MM月")); |
|
|
|
|
applyDate = distinctDates.get(0) + "至" + endDate.format(DateTimeFormatter.ofPattern("dd日")); |
|
|
|
|
} else { |
|
|
|
|
applyMonth = beginDate.format(DateTimeFormatter.ofPattern("yyyy年MM月")) + "至" + endDate.format(DateTimeFormatter.ofPattern("MM月")); |
|
|
|
|
applyDate = distinctDates.get(0) + "至" + endDate.format(DateTimeFormatter.ofPattern("MM月dd日")); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
applyMonth = beginDate.format(DateTimeFormatter.ofPattern("yyyy年MM月")) + "至" + endDate.format(DateTimeFormatter.ofPattern("yyyy年MM月")); |
|
|
|
|
applyDate = distinctDates.get(0) + "至" + endDate.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 1、抚慰金审批签呈
|
|
|
|
|
String reportMoneyChinese = NumberChineseFormatter.format(rpcComfortPacks.getReportMoney(), true) + "元整"; |
|
|
|
|
JSONObject data1 = new JSONObject() |
|
|
|
|
.fluentPut("monthDate", DateUtil.format(new Date(), "yyyy年MM月")) |
|
|
|
|
.fluentPut("applyMonth", applyMonth) |
|
|
|
|
.fluentPut("applyDate", applyDate) |
|
|
|
|
.fluentPut("policeName", comforts.get(0).getApplicantEmpName()) |
|
|
|
|
.fluentPut("reportNum", rpcComfortPacks.getReportNum()) |
|
|
|
|
.fluentPut("reportMoney", rpcComfortPacks.getReportMoney()) |
|
|
|
|
.fluentPut("reportMoneyChinese", NumberChineseFormatter.format(rpcComfortPacks.getReportMoney(), true)) |
|
|
|
|
.fluentPut("rightsPersons", rightsPersons) |
|
|
|
|
.fluentPut("reportMoneyChinese", reportMoneyChinese) |
|
|
|
|
.fluentPut("date", DateUtil.format(new Date(), "yyyy年MM月dd日")); |
|
|
|
|
ByteArrayOutputStream os1 = new ByteArrayOutputStream(); |
|
|
|
|
template1.process(data1, new BufferedWriter(new OutputStreamWriter(os1, StandardCharsets.UTF_8))); |
|
|
|
|
|
|
|
|
|
// 2、维权抚慰登记表
|
|
|
|
|
// 2、抚慰金申报批处理表
|
|
|
|
|
JSONObject data2 = new JSONObject() |
|
|
|
|
.fluentPut("rpcApplys", comforts); |
|
|
|
|
.fluentPut("rpcApplys", comforts) |
|
|
|
|
.fluentPut("reportMoney", rpcComfortPacks.getReportMoney()) |
|
|
|
|
.fluentPut("reportMoneyChinese", reportMoneyChinese); |
|
|
|
|
ByteArrayOutputStream os2 = new ByteArrayOutputStream(); |
|
|
|
|
template2.process(data2, new BufferedWriter(new OutputStreamWriter(os2, StandardCharsets.UTF_8))); |
|
|
|
|
|
|
|
|
|
// 3、抚慰金申报批处理表
|
|
|
|
|
// 3、维权抚慰登记表.xml
|
|
|
|
|
JSONObject data3 = new JSONObject() |
|
|
|
|
.fluentPut("rpcApplys", comforts) |
|
|
|
|
.fluentPut("reportMoney", rpcComfortPacks.getReportMoney()) |
|
|
|
|
.fluentPut("reportMoneyChinese", NumberChineseFormatter.format(rpcComfortPacks.getReportMoney(), true)); |
|
|
|
|
.fluentPut("applyMonth", applyMonth); |
|
|
|
|
ByteArrayOutputStream os3 = new ByteArrayOutputStream(); |
|
|
|
|
template3.process(data3, new BufferedWriter(new OutputStreamWriter(os3, StandardCharsets.UTF_8))); |
|
|
|
|
|
|
|
|
|
// 4、抚慰金申请发放明细表.xml
|
|
|
|
|
// 4、抚慰金申请发放明细表.xml
|
|
|
|
|
JSONObject data4 = new JSONObject() |
|
|
|
|
.fluentPut("rpcApplys", comforts) |
|
|
|
|
.fluentPut("applyMonth", applyMonth) |
|
|
|
|
.fluentPut("reportMoney", rpcComfortPacks.getReportMoney()); |
|
|
|
|
ByteArrayOutputStream os4 = new ByteArrayOutputStream(); |
|
|
|
|
template4.process(data4, new BufferedWriter(new OutputStreamWriter(os4, StandardCharsets.UTF_8))); |
|
|
|
|
@ -146,7 +191,7 @@ public class RpcComfortPacksService extends ServiceImpl<RpcComfortPacksMapper, R
|
|
|
|
|
template5.process(data5, new BufferedWriter(new OutputStreamWriter(os5, StandardCharsets.UTF_8))); |
|
|
|
|
|
|
|
|
|
ByteArrayOutputStream zipOs = new ByteArrayOutputStream(); |
|
|
|
|
ZipUtil.zip(zipOs, Arrays.array("1、抚慰金审批签呈.doc", "2、维权抚慰登记表.doc", "3、抚慰金申报批处理表.doc", "4、抚慰金申请发放明细表.doc", "5、民警维权抚慰申请表.doc"), |
|
|
|
|
ZipUtil.zip(zipOs, Arrays.array("1、抚慰金审批签呈.doc", "2、抚慰金申报批处理表.doc", "3、维权抚慰登记表.doc", "4、抚慰金申请发放明细表.doc", "5、民警维权抚慰申请表.doc"), |
|
|
|
|
Arrays.array(IoUtil.toStream(os1), IoUtil.toStream(os2), IoUtil.toStream(os3), IoUtil.toStream(os4), IoUtil.toStream(os5))); |
|
|
|
|
// 上传
|
|
|
|
|
ByteArrayInputStream zipIs = IoUtil.toStream(zipOs); |
|
|
|
|
|