Commit 49ea1c13 authored by 韩桐桐's avatar 韩桐桐

feat(jg):压力管道基本信息汇总表导出zip接口

parent 3246ce83
......@@ -77,6 +77,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
......@@ -109,6 +110,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired
IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
@Autowired
TzsUserInfoMapper userInfoMapper;
@Autowired
ICommonService commonService;
@Autowired
CommonServiceImpl commonServiceImpl;
......@@ -1569,8 +1572,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
total = equipmentLists.size();
JgUseRegistration jgUseRegistration = jgUseRegistrationMapper.selectOne(new QueryWrapper<JgUseRegistration>().lambda()
.eq(JgUseRegistration::getSequenceNbr, sequenceNbr));
if ("0".equals(category)) {
// 压力管道基本信息汇总表
TzsUserInfo tzsUserInfo = new TzsUserInfo();
if (!ValidationUtil.isEmpty(jgUseRegistration.getCreateUserId())) {
tzsUserInfo = userInfoMapper.selectOne(new QueryWrapper<TzsUserInfo>().lambda()
.eq(TzsUserInfo::getIsDelete, false)
.eq(TzsUserInfo::getAmosUserId, jgUseRegistration.getCreateUserId()));
}
if ("8300".equals(category)) {// 压力管道基本信息汇总表
// 模板
String wordPath = "PressurePipeBasicInformationSummary.ftl";
// 文件名前缀
......@@ -1579,23 +1587,22 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
String customFileName = filePrefix + jgUseRegistration.getApplyNo() + ".zip";
// 总页数
int page = (int) Math.ceil(total / size);
List<CompletableFuture<byte[]>> futures = pressurePipeDataPreparation(page, jsonObject, size, total, equipmentLists, wordPath, filePrefix);
// 异步获取数据
List<CompletableFuture<byte[]>> futures = pressurePipeDataPreparation(page, jsonObject, size, total, equipmentLists, wordPath, filePrefix, tzsUserInfo);
// byte[]压缩zip
toZipFile(response, futures, filePrefix, customFileName);
} else if ("1".equals(category)) {
// 气瓶基本信息汇总表
} else if ("2300".equals(category)) {// 气瓶基本信息汇总表
// 模板
String wordPath = "SummaryOfBasicCylinderInformation.ftl";
String wordPath = "CylinderBasicInformationSummary.ftl";
// 文件名前缀
String filePrefix = "气瓶基本信息汇总表_";
// 压力包名称
String customFileName = filePrefix + jgUseRegistration.getApplyNo() + ".zip";
// 总页数
int page = (int) Math.ceil(total / size);
List<CompletableFuture<byte[]>> futures = cylinderDataPreparation(page, jsonObject, size, total, equipmentLists, wordPath, filePrefix);
// 异步获取数据
List<CompletableFuture<byte[]>> futures = cylinderDataPreparation(page, jsonObject, size, total, equipmentLists, wordPath, filePrefix, tzsUserInfo);
// byte[]压缩zip
toZipFile(response, futures, filePrefix, customFileName);
}
}
......@@ -1605,24 +1612,28 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
*
* @return
*/
private List<CompletableFuture<byte[]>> cylinderDataPreparation(int page, JSONObject jsonObject, int size, double total, JSONArray equipmentLists, String wordPath, String filePrefix) {
private List<CompletableFuture<byte[]>> cylinderDataPreparation(int page, JSONObject jsonObject, int size, double total, JSONArray equipmentLists, String wordPath, String filePrefix, TzsUserInfo tzsUserInfo) {
List<CompletableFuture<byte[]>> futures = IntStream.rangeClosed(1, page)
.mapToObj(current -> CompletableFuture.supplyAsync(() -> {
Map<String, Object> exportParamsMap = new HashMap<>();
exportParamsMap.put("current", current);
exportParamsMap.put("page", page);
exportParamsMap.put("printDate", new Date());
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter);
exportParamsMap.put("printDate", formattedDate);
// 使用单位
exportParamsMap.put("useUnitName", jsonObject.get("useUnitName"));
// 联系电话
exportParamsMap.put("phone", "");
exportParamsMap.put("phone", ValidationUtil.isEmpty(tzsUserInfo.getPhone()) ? "" : tzsUserInfo.getPhone());
// 经办人
exportParamsMap.put("agent", "");
exportParamsMap.put("agent", ValidationUtil.isEmpty(tzsUserInfo.getName()) ? "" : tzsUserInfo.getName());
// 电子邮箱
exportParamsMap.put("email", "");
exportParamsMap.put("email", ValidationUtil.isEmpty(tzsUserInfo.getEmail()) ? "" : tzsUserInfo.getEmail());
// 数据分页
int start = (current - 1) * size;
int end = ((current - 1) * size + size) < total ? (current - 1) * size + size : (int) total;
// 数据截取
List<Object> equData = equipmentLists.subList(start, end);
// 设备数据填充
this.fillInCylinderEquData(exportParamsMap, equData, size);
......@@ -1637,29 +1648,36 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
*
* @return
*/
private List<CompletableFuture<byte[]>> pressurePipeDataPreparation(int page, JSONObject jsonObject, int size, double total, JSONArray equipmentLists, String wordPath, String filePrefix) {
private List<CompletableFuture<byte[]>> pressurePipeDataPreparation(int page, JSONObject jsonObject, int size, double total, JSONArray equipmentLists, String wordPath, String filePrefix, TzsUserInfo tzsUserInfo) {
List<CompletableFuture<byte[]>> futures = IntStream.rangeClosed(1, page)
.mapToObj(current -> CompletableFuture.supplyAsync(() -> {
Map<String, Object> exportParamsMap = new HashMap<>();
exportParamsMap.put("current", current);
exportParamsMap.put("page", page);
exportParamsMap.put("printDate", new Date());
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter);
exportParamsMap.put("printDate", formattedDate);
// 使用单位
exportParamsMap.put("useUnitName", jsonObject.get("useUnitName"));
// 使用单位地址
exportParamsMap.put("", jsonObject.get(""));
exportParamsMap.put("address", jsonObject.get("address"));
// 工程(装置)名称
exportParamsMap.put("nameOfProjectDevice", "");
// 安全管理部门
exportParamsMap.put("orgBranchName", String.valueOf(jsonObject.get("orgBranchCode")).split("_")[1]);
// 安全管理员
exportParamsMap.put("safetyManager", String.valueOf(jsonObject.get("safetyManager")).split("_")[1]);
// 联系电话
exportParamsMap.put("phone", "13209090909");
exportParamsMap.put("phone", ValidationUtil.isEmpty(tzsUserInfo.getPhone()) ? "" : tzsUserInfo.getPhone());
// 经办人
exportParamsMap.put("agent", "张三");
exportParamsMap.put("agent", ValidationUtil.isEmpty(tzsUserInfo.getName()) ? "" : tzsUserInfo.getName());
// 电子邮箱
exportParamsMap.put("email", "htt@yeah.net");
exportParamsMap.put("email", ValidationUtil.isEmpty(tzsUserInfo.getEmail()) ? "" : tzsUserInfo.getEmail());
// 数据分页
int start = (current - 1) * size;
int end = ((current - 1) * size + size) < total ? (current - 1) * size + size : (int) total;
// 数据截取
List<Object> equData = equipmentLists.subList(start, end);
// 设备数据填充
this.pressurePipeEquData(exportParamsMap, equData, size);
......@@ -1682,7 +1700,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
JSONObject obj = (JSONObject) equData.get(curr);
int serialNum = curr + 1;
for (String fieldName : fieldNames) {
exportParamsMap.put(fieldName + serialNum, obj.get(fieldName));
exportParamsMap.put(fieldName + serialNum, ValidationUtil.isEmpty(obj.get(fieldName)) ? "" : obj.get(fieldName));
}
}
......@@ -1708,7 +1726,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
JSONObject obj = (JSONObject) equData.get(curr);
int serialNum = curr + 1;
for (String fieldName : fieldNames) {
exportParamsMap.put(fieldName + serialNum, obj.get(fieldName));
exportParamsMap.put(fieldName + serialNum, ValidationUtil.isEmpty(obj.get(fieldName)) ? "" : obj.get(fieldName));
}
}
......
......@@ -3567,7 +3567,7 @@
<w:sz w:val="15"/>
<w:szCs w:val="15"/>
</w:rPr>
<w:t>${printDate?string('yyyy-MM-dd')}</w:t>
<w:t>${printDate}</w:t>
</w:r>
<w:r w:rsidRPr="00635746">
<w:rPr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment