Commit 4dedcba2 authored by litengwei's avatar litengwei

使用单位变更

parent eaca49d7
......@@ -58,7 +58,8 @@
</if>
</where>
ORDER BY
isn.create_date,isn.apply_no DESC
isn.create_date DESC, isn.apply_no DESC
</select>
<select id="queryEquipInformation" resultType="java.util.Map">
......@@ -67,7 +68,7 @@
isn.apply_no AS applyNo,
isn.change_certificate AS changeCertificate,
isn.remark AS remark,
isn.use_regist_code AS equRegisterCode,
isn.equ_code_b AS equRegisterCode,
ri.equ_list AS equList,
ri.equ_category AS equCategory,
ri.EQU_DEFINE AS equDefine,
......
......@@ -297,112 +297,6 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
return this.updateBatchById(JgChangeRegistrationUnits);
}
/**
* 打印单位变更单
*
* @param sequenceNbr 主键
* @return pdf文件路径
*/
@Override
public String generateInstallationNoticeReport(Long sequenceNbr) {
if (Objects.isNull(sequenceNbr)) {
throw new IllegalArgumentException("参数不能为空");
}
JgChangeRegistrationUnit JgChangeRegistrationUnit = this.getById(sequenceNbr);
List<Map<String, Object>> informationList = JgChangeRegistrationUnitMapper.queryEquipInformation(sequenceNbr);
if (Objects.isNull(JgChangeRegistrationUnit) || CollectionUtils.isEmpty(informationList)) {
throw new IllegalArgumentException("单位变更单不存在");
}
Map<String, Object> installation = informationList.get(0);
Function<String, String> getValue = key -> installation.getOrDefault(key, "").toString();
// 组装模板变量
Map<String, Object> placeholders = new HashMap<>();
placeholders.put("sequenceNbr", getValue.apply("sequenceNbr"));
placeholders.put("installUnitName", getValue.apply("installUnitName"));
placeholders.put("applyNo", getValue.apply("applyNo"));
placeholders.put("productName", getValue.apply("productName"));
placeholders.put("equipType", getValue.apply("equType"));
placeholders.put("equipCode", getValue.apply("equRegisterCode"));
placeholders.put("produceCode", getValue.apply("factoryNum")); // TODO: 出厂编号
placeholders.put("produceUnitName", getValue.apply("produceUnitName"));
placeholders.put("produceLicenseNum", getValue.apply("produceLicenseNum"));
placeholders.put("installUnitAddress", getValue.apply("provinceName") + getValue.apply("cityName") + getValue.apply("countyName") + getValue.apply("streetName") + getValue.apply("address"));
placeholders.put("installStartDate", getValue.apply("installStartDate"));
placeholders.put("installType", "单位变更"); // TODO: 施工类别
placeholders.put("installLicenseNo", getValue.apply("installLicenseNo"));
placeholders.put("installLicenseExpirationDate", getValue.apply("installLicenseExpirationDate"));
placeholders.put("installLeaderName", getValue.apply("installLeaderName"));
placeholders.put("installLeaderPhone", getValue.apply("installLeaderPhone"));
placeholders.put("fullAddress", getValue.apply("provinceName") + getValue.apply("cityName") + getValue.apply("countyName") + getValue.apply("streetName") + getValue.apply("address"));
placeholders.put("useUnitName", getValue.apply("useUnitName"));
placeholders.put("useUnitLeaderName", getValue.apply("safetyManager"));
placeholders.put("useUnitLeaderPhone", getValue.apply("safetyManagerPhone"));
placeholders.put("useUnitLeaderAddress", getValue.apply("address"));
// 生成二维码
String qrCode = ImageUtils.generateQRCode(getValue.apply("applyNo"), 300, 300);
placeholders.put("qrCode", qrCode);
// word转pdf
File pdfFile;
try {
pdfFile = this.wordToPdf("installation-notification-report.ftl", placeholders);
} catch (Exception e) {
throw new RuntimeException(e);
}
// 上传pdf至文件服务器
String url = this.uploadFile(pdfFile);
// 删除临时文件
try {
Files.deleteIfExists(pdfFile.toPath());
} catch (IOException e) {
log.error("删除临时文件失败:{}", e);
}
// 更新到数据库
// JgChangeRegistrationUnit.setNoticeReportUrl(url);
this.updateById(JgChangeRegistrationUnit);
return url;
}
/**
* word 转 pdf
*
* @param wordPath word文件路径
*/
private File wordToPdf(String wordPath, Map<String, Object> placeholders) throws Exception {
Assert.hasText(wordPath, "word文件路径不能为空");
String tempFileName = "单位变更单_" + System.currentTimeMillis() + "_temp.pdf";
WordTemplateUtils instance = WordTemplateUtils.getInstance();
return instance.fillAndConvertDocFile(wordPath, tempFileName, placeholders, SaveFormat.PDF);
}
/**
* 上传文件至文件服务器
*
* @param file 文件
*/
private String uploadFile(File file) {
Assert.notNull(file, "文件不能为空");
MultipartFile multipartFile = new ByteArrayMultipartFile("file", "file.pdf", "application/pdf", file2byte(file));
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile);
String urlString = "";
if (result != null) {
for (String s : result.getResult().keySet()) {
urlString = s;
}
}
return urlString;
}
@Override
@SuppressWarnings({"Duplicates", "rawtypes"})
......@@ -509,7 +403,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
dto.setEquType((String.valueOf(obj.get("EQU_CATEGORY"))));
dto.setProductNameB((String.valueOf(obj.get("PRODUCT_NAME"))));
dto.setEquCodeB((String.valueOf(obj.get("EQU_CODE"))));
dto.setUseInnerCode((String.valueOf(obj.get("USE_INNER_CODE"))));
dto.setUseInnerCode(ValidationUtil.isEmpty(obj.get("USE_INNER_CODE")) ? "" : String.valueOf(obj.get("USE_INNER_CODE")));
dto.setEquAddress((String.valueOf(obj.get("ADDRESS"))));
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
......@@ -573,6 +467,15 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
}
}
String newUseUnitId = model.getNewUseUnitCreditCode();
if (!ObjectUtils.isEmpty(newUseUnitId)) {
String[] newUseUnitList = newUseUnitId.split("_");
if (newUseUnitList.length > 1) {
model.setNewUseUnitCreditCode(newUseUnitList[0]);
model.setNewUseUnitName(newUseUnitList[1]);
}
}
String receiveOrgCode = model.getReceiveOrgCode();
if (!ObjectUtils.isEmpty(receiveOrgCode)) {
String[] receiveOrgCodeList = receiveOrgCode.split("_");
......
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