Commit 078d7b81 authored by 刘林's avatar 刘林

fix(jg):超设计使用年限功能开发

parent a5905186
...@@ -25,4 +25,6 @@ public interface JgOverDesignServiceLifeMapper extends BaseMapper<JgOverDesignSe ...@@ -25,4 +25,6 @@ public interface JgOverDesignServiceLifeMapper extends BaseMapper<JgOverDesignSe
@Param("sort") SortVo sortMap, @Param("sort") SortVo sortMap,
@Param("dto") JgOverDesignServiceLifeDto dto , @Param("dto") JgOverDesignServiceLifeDto dto ,
@Param("type") String type); @Param("type") String type);
List<Map<String, Object>> selectEquipList(@Param("records") List<String> records);
} }
...@@ -97,4 +97,28 @@ ...@@ -97,4 +97,28 @@
</if> </if>
ovds.create_date DESC, ovds.apply_no DESC ovds.create_date DESC, ovds.apply_no DESC
</select> </select>
<select id="selectEquipList" resultType="java.util.Map">
select jui.RECORD as SEQUENCE_NBR,
jfi.PRODUCE_UNIT_NAME,
jui.USE_INNER_CODE,
jfi.FACTORY_NUM,
jui.ADDRESS as ADDRESS,
jui.RECORD record,
(SELECT name from tz_equipment_category where code = jri.EQU_DEFINE) as EQU_DEFINE,
jri.PRODUCT_NAME,
jri.EQU_CODE,
jri.USE_ORG_CODE,
(SELECT name from tz_equipment_category where code = jri.EQU_LIST) as EQU_LIST,
(SELECT name from tz_equipment_category where code = jri.EQU_CATEGORY) as EQU_CATEGORY,
(select other.SUPERVISORY_CODE from idx_biz_jg_other_info other where other.RECORD = jui.RECORD) as SUPERVISORY_CODE,
to_char((select NEXT_INSPECT_DATE from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC limit 1), 'YYYY-MM-DD') as NEXT_INSPECT_DATE
FROM idx_biz_jg_use_info jui
LEFT JOIN idx_biz_jg_factory_info jfi on jui.RECORD = jfi.RECORD
LEFT JOIN idx_biz_jg_register_info jri on jui.RECORD = jri.RECORD
WHERE jui.record in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
</foreach>
</select>
</mapper> </mapper>
...@@ -60,6 +60,12 @@ ...@@ -60,6 +60,12 @@
<artifactId>seata-spring-boot-starter</artifactId> <artifactId>seata-spring-boot-starter</artifactId>
<version>1.8.0</version> <version>1.8.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.12</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
...@@ -17,4 +17,6 @@ public interface IIdxBizJgInspectionDetectionInfoService { ...@@ -17,4 +17,6 @@ public interface IIdxBizJgInspectionDetectionInfoService {
List<IdxBizJgInspectionDetectionInfo> checkInspectionInfo(List<String> records); List<IdxBizJgInspectionDetectionInfo> checkInspectionInfo(List<String> records);
boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList); boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList);
List<IdxBizJgInspectionDetectionInfo> queryInspectionListByRecord(String record);
} }
...@@ -72,6 +72,7 @@ import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO; ...@@ -72,6 +72,7 @@ import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.pdfbox.multipdf.PDFMergerUtility;
import org.redisson.api.RBucket; import org.redisson.api.RBucket;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
...@@ -804,7 +805,7 @@ public class CommonServiceImpl implements ICommonService { ...@@ -804,7 +805,7 @@ public class CommonServiceImpl implements ICommonService {
while (it.hasNext()) { while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next(); LinkedHashMap e = (LinkedHashMap) it.next();
// 删除非指定的单位类型 // 删除非指定的单位类型
if (!e.get("companyType").toString().contains(companyType)) { if (e.get("companyType") != null && !e.get("companyType").toString().contains(companyType)) {
it.remove(); it.remove();
} }
if (!ObjectUtils.isEmpty(e.get("children"))) { if (!ObjectUtils.isEmpty(e.get("children"))) {
...@@ -2451,47 +2452,54 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2451,47 +2452,54 @@ public class CommonServiceImpl implements ICommonService {
return formData; return formData;
} }
//多个证进行批量生成
public List<JSONObject> buildFileForOverDesign(JSONObject jsonObject) { public List<JSONObject> buildFileForOverDesign(JSONObject jsonObject) {
List<JSONObject> formDataList = new ArrayList<>(); List<JSONObject> formDataList = new ArrayList<>();
if (jsonObject.containsKey("equipmentLists")) {
JSONArray equipmentLists = jsonObject.getJSONArray("equipmentLists");
List<Map<String, Object>> equips = equipmentLists.stream()
.filter(obj -> obj instanceof Map)
.map(obj -> (Map<String, Object>) obj)
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(equips)) {
Map<String, Object> firstEquip = equips.get(0);
String equDefine = (String) firstEquip.get("EQU_DEFINE");
String equCategory = (String) firstEquip.get("EQU_CATEGORY");
formDataList = equips.stream().map(v -> {
JSONObject formData = new JSONObject(); JSONObject formData = new JSONObject();
formData.putAll(jsonObject); formData.put("equDefine", equDefine);
formData.put("equCategory", equCategory);
formData.entrySet().removeIf(entry -> entry.getValue() == null); formData.entrySet().removeIf(entry -> entry.getValue() == null);
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
if (formData.containsKey("type")) { Optional.ofNullable(Objects.toString(jsonObject.get("type"), ""))
formData.put("registrationType", RegistrationTypeEnum.getNameByType(formData.getString("type"))); .ifPresent(type -> formData.put("registrationType", RegistrationTypeEnum.getNameByType(type)));
} Optional.ofNullable(Objects.toString(jsonObject.get("equListCode"), ""))
if (formData.containsKey("equListCode")) { .ifPresent(code -> formData.put("equList", EquipmentClassifityEnum.getNameByCode(code)));
formData.put("equList", EquipmentClassifityEnum.getNameByCode(formData.getString("equListCode"))); String useRegistrationCode = Objects.toString(v.get("USE_ORG_CODE"), "");
}
//多个证进行批量生成
if (formData.containsKey("equipmentLists")) {
JSONArray equipmentLists = formData.getJSONArray("equipmentLists");
List<Map<String, Object>> equips = equipmentLists.stream()
.filter(obj -> obj instanceof Map)
.map(obj -> (Map<String, Object>) obj).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(equips)) {
formData.put("equDefine", equips.get(0).get("EQU_DEFINE"));
formData.put("equCategory", equips.get(0).get("EQU_CATEGORY"));
equips.forEach(v -> {
String useRegistrationCode = Objects.toString(v.get("USE_ORG_CODE"),"");
JgUseRegistrationManage manage = jgUseRegistrationManageService.lambdaQuery() JgUseRegistrationManage manage = jgUseRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCode) .eq(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCode)
.eq(JgUseRegistrationManage::getIsDelete, 0) .eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus,CertificateStatusEnum.YIDENGJI.getName()).one(); .eq(JgUseRegistrationManage::getCertificateStatus, CertificateStatusEnum.YIDENGJI.getName())
.one();
formData.put("equCode", v.get("EQU_CODE")); formData.put("equCode", v.get("EQU_CODE"));
formData.put("useRegistrationCode", v.get("USE_ORG_CODE")); formData.put("useRegistrationCode", v.get("USE_ORG_CODE"));
formData.put("produceUnitName", v.get("PRODUCE_UNIT_NAME")); formData.put("produceUnitName", v.get("PRODUCE_UNIT_NAME"));
formData.put("produceDate", LocalDateTime.parse(Objects.toString(v.get("PRODUCE_DATE")), inputFormatter).format(outputFormatter)); formData.put("produceDate", LocalDateTime.parse(Objects.toString(v.get("PRODUCE_DATE")), inputFormatter)
.format(outputFormatter));
formData.put("factoryNum", v.get("FACTORY_NUM")); formData.put("factoryNum", v.get("FACTORY_NUM"));
formData.put("productName", v.get("PRODUCT_NAME")); formData.put("productName", v.get("PRODUCT_NAME"));
formData.put("useUnitName", v.get("USE_UNIT_NAME")); formData.put("useUnitName", v.get("USE_UNIT_NAME"));
formData.put("auditPassDate", new SimpleDateFormat("yyyy-MM-dd").format( manage.getAuditPassDate()));
formData.put("receiveCompanyOrgName", manage.getReceiveOrgName()); if (manage != null && manage.getAuditPassDate() != null) {
formData.put("applyNo", manage.getApplyNo()); formData.put("auditPassDate", new SimpleDateFormat("yyyy-MM-dd").format(manage.getAuditPassDate()));
}
formData.put("receiveCompanyOrgName", manage != null ? manage.getReceiveOrgName() : null);
formData.put("applyNo", manage != null ? manage.getApplyNo() : null);
formData.put("cruDate", DateUtils.convertDateToString(new Date(), DateUtils.CHN_DATE_PATTERN)); formData.put("cruDate", DateUtils.convertDateToString(new Date(), DateUtils.CHN_DATE_PATTERN));
formDataList.add(formData); return formData;
}); }).collect(Collectors.toList());
} }
} }
return formDataList; return formDataList;
...@@ -2575,16 +2583,19 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2575,16 +2583,19 @@ public class CommonServiceImpl implements ICommonService {
List<JSONObject> formDataList = buildFileForOverDesign(jsonObject); List<JSONObject> formDataList = buildFileForOverDesign(jsonObject);
String wordPath = "use-registration-change-certificate.ftl"; String wordPath = "use-registration-change-certificate.ftl";
String fileName = "特种设备使用登记变更证明_"; String fileName = "特种设备使用登记变更证明_";
List<String> uploadedUrls = new ArrayList<>();
List<File> generatedFiles = new ArrayList<>(); List<File> generatedFiles = new ArrayList<>();
File mergedPdfFile = null;
try { try {
List<File> pdfFiles = new ArrayList<>();
for (JSONObject formData : formDataList) { for (JSONObject formData : formDataList) {
File pdfFile = wordToPdf(fileName, wordPath, formData); File pdfFile = wordToPdf(fileName, wordPath, formData);
pdfFiles.add(pdfFile);
generatedFiles.add(pdfFile); generatedFiles.add(pdfFile);
uploadedUrls.add(uploadFile(pdfFile, "useRegistrationFormFiles"));
} }
return MapBuilder.<String, Object>create().put("useRegistrationFormUrl", uploadedUrls).build(); mergedPdfFile = mergePdfFiles(pdfFiles, fileName + "合并.pdf");
String uploadedUrl = uploadFile(mergedPdfFile, "useRegistrationFormFiles");
return MapBuilder.<String, Object>create().put("useRegistrationFormUrl", uploadedUrl).build();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
...@@ -2595,7 +2606,25 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2595,7 +2606,25 @@ public class CommonServiceImpl implements ICommonService {
log.error("文件找不到,删除失败:{}", e); log.error("文件找不到,删除失败:{}", e);
} }
} }
if (mergedPdfFile != null) {
try {
Files.deleteIfExists(mergedPdfFile.toPath());
} catch (Exception e) {
log.error("合并 PDF 文件删除失败:{}", e);
}
}
}
}
private File mergePdfFiles(List<File> pdfFiles, String outputFileName) throws IOException {
PDFMergerUtility merger = new PDFMergerUtility();
File outputFile = new File(System.getProperty("java.io.tmpdir"), outputFileName);
merger.setDestinationFileName(outputFile.getAbsolutePath());
for (File pdf : pdfFiles) {
merger.addSource(pdf);
} }
merger.mergeDocuments(null);
return outputFile;
} }
@Override @Override
......
...@@ -12,6 +12,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -12,6 +12,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 安全追溯-检验检测信息表服务实现类 * 安全追溯-检验检测信息表服务实现类
...@@ -57,4 +58,19 @@ public class IdxBizJgInspectionDetectionInfoServiceImpl extends BaseService<IdxB ...@@ -57,4 +58,19 @@ public class IdxBizJgInspectionDetectionInfoServiceImpl extends BaseService<IdxB
public boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList) { public boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList) {
return super.saveOrUpdateBatch(inspectionDetectionInfoList); return super.saveOrUpdateBatch(inspectionDetectionInfoList);
} }
@Override
public List<IdxBizJgInspectionDetectionInfo> queryInspectionListByRecord(String record) {
return list(new QueryWrapper<IdxBizJgInspectionDetectionInfo>()
.lambda()
.eq(IdxBizJgInspectionDetectionInfo::getRecord, record)
.orderByDesc(IdxBizJgInspectionDetectionInfo::getInspectDate))
.stream()
.map(info -> {
IdxBizJgInspectionDetectionInfo result = new IdxBizJgInspectionDetectionInfo();
BeanUtils.copyProperties(info, result);
return result;
})
.collect(Collectors.toList());
}
} }
\ No newline at end of file
...@@ -321,7 +321,7 @@ ...@@ -321,7 +321,7 @@
"type": "120", "type": "120",
"pageType": "look", "pageType": "look",
"name": "超设计使用年限变更", "name": "超设计使用年限变更",
"url": "/mixuap?appId=1742358052905971713&id=1897575052807794690&roleIds={roleIds}&userId={userId}&pageType=look" "url": "/mixuap?appId=1742358052905971713&id=1897575343384981506&roleIds={roleIds}&userId={userId}&pageType=look"
}, },
{ {
"type": "121", "type": "121",
......
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