月报整合导出--发给联系人

This commit is contained in:
zhn
2022-08-17 11:51:35 +08:00
parent 329a31c4cf
commit 1a8f2475c7
2 changed files with 59 additions and 10 deletions
@@ -421,6 +421,9 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
wrapper.in(LawsMonthlyReportWriteEO::getCreateBy,currentUser.getUsername());
}
List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS = this.list(wrapper);
//法规联系人
List<LoginUser> loginUserList = getlawsContact(lawsMonthlyReportWriteEOS);
List<String> lawsMonthlyReportIdList = lawsMonthlyReportWriteEOS.stream().map(LawsMonthlyReportWriteEO::getId).collect(Collectors.toList());
//新征求意见清单模板
@@ -471,7 +474,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
fileTemp.mkdirs();
OutputStream os = null;
try {
createWord(path,lawsMonthlyReportWriteEOS,lawsMonthlyReportTitleTemplateEOS);
createWord(path,lawsMonthlyReportWriteEOS,lawsMonthlyReportTitleTemplateEOS,loginUserList);
ZipUtil.zip(path, path + ".zip");
//文件
os = response.getOutputStream();
@@ -513,6 +516,28 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
}
private List<LoginUser> getlawsContact(List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS) {
List<String> userIdList = lawsMonthlyReportWriteEOS.stream().map(LawsMonthlyReportWriteEO::getLawsContact).collect(Collectors.toList());
//法规联系人
List<String> userIds = new ArrayList<>();
for (String s : userIdList) {
if(StringUtils.isNotBlank(s)){
if(s.contains(",")){
userIds.addAll(Arrays.asList(s.split(",")));
}else{
userIds.add(s);
}
}
}
List<JSONObject> jsonObjects = sysBaseApi.queryUsersByIds(StringUtils.join(userIds, ","));
List<LoginUser> userList = new ArrayList<>();
for (JSONObject jsonObject : jsonObjects) {
LoginUser loginUser = JSONObject.parseObject(jsonObject.toJSONString(), LoginUser.class);
userList.add(loginUser);
}
return userList;
}
/**
*创建word文件
@@ -522,7 +547,8 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
*/
private void createWord(String path,
List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS,
List<LawsMonthlyReportTitleTemplateEO> lawsMonthlyReportTitleTemplateEOS){
List<LawsMonthlyReportTitleTemplateEO> lawsMonthlyReportTitleTemplateEOS,
List<LoginUser> loginUserList){
//一级菜单
List<String> parentIdList = lawsMonthlyReportTitleTemplateEOS.stream().map(LawsMonthlyReportTitleTemplateEO::getParentId).distinct().collect(Collectors.toList());
LambdaQueryWrapper<LawsMonthlyReportTitleTemplateEO> wrapper = new LambdaQueryWrapper<>();
@@ -591,13 +617,15 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
//内容中文版
XWPFDocument documentContentCn = new XWPFDocument();
FileOutputStream outContentCn = new FileOutputStream(wordFileContentCn);
wordContent(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleCN, documentContentCn,CutEnum.CN.getValue());
wordContent(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleCN,
documentContentCn,CutEnum.CN.getValue(),loginUserList);
documentContentCn.write(outContentCn);
//内容英文版
XWPFDocument documentContentEn = new XWPFDocument();
FileOutputStream outContentEn = new FileOutputStream(wordFileContentEn);
wordContent(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleEN, documentContentEn,CutEnum.EN.getValue());
wordContent(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleEN,
documentContentEn,CutEnum.EN.getValue(), loginUserList);
documentContentEn.write(outContentEn);
} catch (IOException e) {
@@ -683,7 +711,8 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
List<LawsMonthlyReportTitleTemplateEO> reportTitleOneList,
String titleCN,
XWPFDocument document,
String cut) {
String cut,
List<LoginUser> loginUserList) {
//数据字典
List<SysDictItem> sysDictItems = sysDictItemServiceImpl.selectItemsAll();
@@ -761,7 +790,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
String contentTemplate = lawsMonthlyReportWriteEO.getContentTemplate();
if(ContentTemplateEnum.DEFAULT_TEMPLATE.getValue().equals(contentTemplate)){
//写入模板
WordUtil.exportWordExcelDefault(document,lawsMonthlyReportWriteEO,sysDictItems,categoryList,cut);
WordUtil.exportWordExcelDefault(document,lawsMonthlyReportWriteEO,sysDictItems,categoryList,cut,loginUserList);
}
// else if(ContentTemplateEnum.NEW_REQUEST_LIST_TEMPLATE.getValue().equals(contentTemplate)){
@@ -2,7 +2,7 @@ package com.jero.modules.report.util;
import cn.hutool.core.util.ObjectUtil;
import com.jero.common.constant.enums.CutEnum;
import com.jero.modules.project.service.impl.ProjectLawsInventoryEOServiceImpl;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.report.entity.LawsMonthlyReportWriteEO;
import com.jero.modules.report.entity.NewOpinionTemplateEO;
import com.jero.modules.report.entity.NewStandardTemplateEO;
@@ -36,7 +36,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
import java.io.FileInputStream;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
@@ -44,6 +43,7 @@ import java.util.List;
import java.util.stream.Collectors;
public class WordUtil {
/**
* 导出工具示例
*
@@ -350,7 +350,8 @@ public class WordUtil {
LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO,
List<SysDictItem> sysDictItems,
List<SysCategory> categoryList,
String cut) {
String cut,
List<LoginUser> loginUserList) {
String technologyTerritory = lawsMonthlyReportWriteEO.getTechnologyTerritory();//技术领域
String applyCar = lawsMonthlyReportWriteEO.getApplyCar();//适用车型
String applyScope = lawsMonthlyReportWriteEO.getApplyScope();//适用范围
@@ -363,7 +364,8 @@ public class WordUtil {
String contentEn = lawsMonthlyReportWriteEO.getContentEn();//主要内容英文
String workProgressCn = lawsMonthlyReportWriteEO.getWorkProgressCn();//NIO工作进展中文
String workProgressEn = lawsMonthlyReportWriteEO.getWorkProgressEn();//NIO工作进展英文
String lawsContact = lawsMonthlyReportWriteEO.getLawsContact();//法规联系人
String lawsContactTemp = lawsMonthlyReportWriteEO.getLawsContact();//法规联系人
String lawsContact = getLawsContact(loginUserList, lawsContactTemp);
String link = lawsMonthlyReportWriteEO.getLink();//链接
String technologyTerritoryName = "";
if(org.apache.commons.lang3.StringUtils.isNotBlank(technologyTerritory)){
@@ -679,5 +681,23 @@ public class WordUtil {
tableRow.getCell(0).setText(fieldName);
tableRow.getCell(1).setText(technologyTerritory);
}
private static String getLawsContact(List<LoginUser> userList, String lawsContact) {
if(com.jero.modules.system.util.StringUtils.isNotBlank(lawsContact)){
List<LoginUser> collect = userList.stream().filter(e -> lawsContact.contains(e.getId())).collect(Collectors.toList());
StringBuilder sb = new StringBuilder();
for (String s : lawsContact.split(",")) {
List<LoginUser> loginUserList = collect.stream().filter(e -> e.getId().equals(s)).collect(Collectors.toList());
if(loginUserList.size() != 0){
sb.append(loginUserList.get(0).getUsername()+",");
}
}
if(com.jero.modules.system.util.StringUtils.isNotBlank(sb)){
String substring = sb.substring(0, sb.length() - 1);
return substring;
}
}
return null;
}
}