Commit bda064b4 authored by suhuiguang's avatar suhuiguang

fix(jyjc): 报检规则4.0开发

1.报检申请表生成url功能初始版本提交
parent c0197da6
...@@ -37,9 +37,6 @@ public class InspectionApplicationPushData implements Serializable { ...@@ -37,9 +37,6 @@ public class InspectionApplicationPushData implements Serializable {
@ApiModelProperty(value = "申请联系人电话") @ApiModelProperty(value = "申请联系人电话")
private String applicationContactPhone; private String applicationContactPhone;
@ApiModelProperty(value = "内部人员代码")
private String innerPersonCode;
@ApiModelProperty(value = "检验检测类型") @ApiModelProperty(value = "检验检测类型")
private String inspectionType; private String inspectionType;
......
...@@ -356,4 +356,11 @@ public class JyjcInspectionApplicationController extends BaseController { ...@@ -356,4 +356,11 @@ public class JyjcInspectionApplicationController extends BaseController {
@RequestParam(value = "parentId", required = false) String parentId) { @RequestParam(value = "parentId", required = false) String parentId) {
return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.getRegion(level, parentId)); return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.getRegion(level, parentId));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/file/test")
@ApiOperation(httpMethod = "PUT", value = "报检申请表测试", notes = "报检申请表测试")
public ResponseModel<Object> fileTest(String appSeq) {
return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.fileTest(appSeq));
}
} }
...@@ -342,7 +342,7 @@ public class InspectionApplicationPushEventListener { ...@@ -342,7 +342,7 @@ public class InspectionApplicationPushEventListener {
} }
private String getAddressByRecord(IdxBizJgUseInfo idxBizJgUseInfo) { private String getAddressByRecord(IdxBizJgUseInfo idxBizJgUseInfo) {
return null2Blank(idxBizJgUseInfo.getProvinceName()) + null2Blank(idxBizJgUseInfo.getCityName()) + null2Blank(idxBizJgUseInfo.getCountyName()) + null2Blank(idxBizJgUseInfo.getAddress()); return null2Blank(idxBizJgUseInfo.getProvinceName()) + null2Blank(idxBizJgUseInfo.getCityName()) + null2Blank(idxBizJgUseInfo.getCountyName()) + null2Blank(idxBizJgUseInfo.getStreetName()) + null2Blank(idxBizJgUseInfo.getAddress());
} }
private void setRegisterInfo(InspectionEquipData equipData, String equipUnicode) { private void setRegisterInfo(InspectionEquipData equipData, String equipUnicode) {
...@@ -351,12 +351,16 @@ public class InspectionApplicationPushEventListener { ...@@ -351,12 +351,16 @@ public class InspectionApplicationPushEventListener {
wrapper.eq(IdxBizJgRegisterInfo::getRecord, equipUnicode); wrapper.eq(IdxBizJgRegisterInfo::getRecord, equipUnicode);
wrapper.select(IdxBizJgRegisterInfo::getRecord, wrapper.select(IdxBizJgRegisterInfo::getRecord,
IdxBizJgRegisterInfo::getEquType, IdxBizJgRegisterInfo::getEquType,
IdxBizJgRegisterInfo::getEquCode,
IdxBizJgRegisterInfo::getUseOrgCode, IdxBizJgRegisterInfo::getUseOrgCode,
IdxBizJgRegisterInfo::getProductName,
IdxBizJgRegisterInfo::getLastUseCertFilePath); IdxBizJgRegisterInfo::getLastUseCertFilePath);
// 使用证信息 // 使用证信息
IdxBizJgRegisterInfo jgRegisterInfo = idxBizJgRegisterInfoMapper.selectOne(wrapper); IdxBizJgRegisterInfo jgRegisterInfo = idxBizJgRegisterInfoMapper.selectOne(wrapper);
if (jgRegisterInfo != null) { if (jgRegisterInfo != null) {
equipData.setEquType(jgRegisterInfo.getEquType()); equipData.setEquType(jgRegisterInfo.getEquType());
equipData.setEquCode(jgRegisterInfo.getEquCode());
equipData.setEquName(jgRegisterInfo.getProductName());
equipData.setUseRegistrationCode(jgRegisterInfo.getUseOrgCode()); equipData.setUseRegistrationCode(jgRegisterInfo.getUseOrgCode());
equipData.setUseCertFilePath(jgRegisterInfo.getLastUseCertFilePath()); equipData.setUseCertFilePath(jgRegisterInfo.getLastUseCertFilePath());
} }
......
...@@ -34,6 +34,8 @@ public class GenericDocGeneratorStrategy implements SupportableDocGenerator { ...@@ -34,6 +34,8 @@ public class GenericDocGeneratorStrategy implements SupportableDocGenerator {
private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper; private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
private static final int pageSize = 15;
@Override @Override
public boolean support(String equList, String equCategory, String equDefine) { public boolean support(String equList, String equCategory, String equDefine) {
return !EquipmentClassifityEnum.YLGD.getCode().equals(equList); return !EquipmentClassifityEnum.YLGD.getCode().equals(equList);
...@@ -44,10 +46,15 @@ public class GenericDocGeneratorStrategy implements SupportableDocGenerator { ...@@ -44,10 +46,15 @@ public class GenericDocGeneratorStrategy implements SupportableDocGenerator {
Map<String, Object> params = appDocCmService.getBaseInFo(appId); Map<String, Object> params = appDocCmService.getBaseInFo(appId);
JyjcInspectionApplication inspectionApplication = jyjcInspectionApplicationService.getBaseMapper().selectById(appId); JyjcInspectionApplication inspectionApplication = jyjcInspectionApplicationService.getBaseMapper().selectById(appId);
params.put("numberOfEquip", inspectionApplication.getNumberOfEquip()); params.put("numberOfEquip", inspectionApplication.getNumberOfEquip());
params.put("equips", this.buildEquipsBatch(inspectionApplication.getSequenceNbr())); setEquipExcelData(inspectionApplication, params);
return this.generatePdfAndUpload(params); return this.generatePdfAndUpload(params);
} }
private void setEquipExcelData(JyjcInspectionApplication inspectionApplication, Map<String, Object> params) {
List<Map<String, Object>> equips = this.buildEquipsBatch(inspectionApplication.getSequenceNbr());
params.put("equips", equips);
}
private String generatePdfAndUpload(Map<String, Object> formData) { private String generatePdfAndUpload(Map<String, Object> formData) {
String wordPath = "inspect-app-generic.ftl"; String wordPath = "inspect-app-generic.ftl";
String fileName = "检验检测报检申请受理单"; String fileName = "检验检测报检申请受理单";
...@@ -56,7 +63,7 @@ public class GenericDocGeneratorStrategy implements SupportableDocGenerator { ...@@ -56,7 +63,7 @@ public class GenericDocGeneratorStrategy implements SupportableDocGenerator {
// 填充模板, word转pdf // 填充模板, word转pdf
pdfFile = WordTemplateUtils.wordToPdf(fileName, wordPath, formData); pdfFile = WordTemplateUtils.wordToPdf(fileName, wordPath, formData);
// 上传文档到文件服务器 // 上传文档到文件服务器
return WordTemplateUtils.uploadFile(pdfFile, "upload/tzs/pdf/inspectApp"); return WordTemplateUtils.uploadFile(pdfFile, "/tzs/jyjc/inspectApp");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
......
...@@ -29,6 +29,8 @@ public class PipelineDocGeneratorStrategy implements SupportableDocGenerator { ...@@ -29,6 +29,8 @@ public class PipelineDocGeneratorStrategy implements SupportableDocGenerator {
private final JyjcInspectionHistoryServiceImpl inspectionHistoryService; private final JyjcInspectionHistoryServiceImpl inspectionHistoryService;
private static final int pageSize = 12;
@Override @Override
public boolean support(String equList, String equCategory, String equDefine) { public boolean support(String equList, String equCategory, String equDefine) {
return EquipmentClassifityEnum.YLGD.getCode().equals(equList); return EquipmentClassifityEnum.YLGD.getCode().equals(equList);
...@@ -47,20 +49,24 @@ public class PipelineDocGeneratorStrategy implements SupportableDocGenerator { ...@@ -47,20 +49,24 @@ public class PipelineDocGeneratorStrategy implements SupportableDocGenerator {
JyjcInspectionHistory inspectionHistory = inspectionHistoryService.getBySSeq(inspectionApplication.getSequenceNbr()); JyjcInspectionHistory inspectionHistory = inspectionHistoryService.getBySSeq(inspectionApplication.getSequenceNbr());
if (inspectionHistory != null) { if (inspectionHistory != null) {
// 新报检单记录历史数据的逻辑 // 新报检单记录历史数据的逻辑
params.put("pipelines", inspectionHistory.getHistoryData().get("equip")); setPipelineExcelData((List<Map<String, Object>>) inspectionHistory.getHistoryData().get("equip"), params);
params.put("numberOfEquip", inspectionHistory.getHistoryData().get("pipelineLength")); params.put("numberOfEquip", inspectionHistory.getHistoryData().get("pipelineLength"));
} else { } else {
List<Map<String, Object>> pipelines = jyjcInspectionApplicationService.getPipelines(inspectionApplication); List<Map<String, Object>> pipelines = setPipelineExcelData(jyjcInspectionApplicationService.getPipelines(inspectionApplication), params);
params.put("pipelines", pipelines);
params.put("numberOfEquip", JyjcInspectionApplicationServiceImpl.calTotalLength(pipelines)); params.put("numberOfEquip", JyjcInspectionApplicationServiceImpl.calTotalLength(pipelines));
} }
} else { } else {
List<Map<String, Object>> pipelines = jyjcInspectionApplicationService.getPipelines(inspectionApplication); // 不会走到这,业务需求为已完成时才生成报检申请表
params.put("pipelines", pipelines); List<Map<String, Object>> pipelines = setPipelineExcelData(jyjcInspectionApplicationService.getPipelines(inspectionApplication), params);
params.put("numberOfEquip", JyjcInspectionApplicationServiceImpl.calTotalLength(pipelines)); params.put("numberOfEquip", JyjcInspectionApplicationServiceImpl.calTotalLength(pipelines));
} }
} }
private List<Map<String, Object>> setPipelineExcelData(List<Map<String, Object>> pipelines, Map<String, Object> params) {
params.put("pipelines", pipelines);
return pipelines;
}
private String generatePdfAndUpload(Map<String, Object> formData) { private String generatePdfAndUpload(Map<String, Object> formData) {
String wordPath = "inspect-app-pipeline.ftl"; String wordPath = "inspect-app-pipeline.ftl";
String fileName = "检验检测报检申请受理单"; String fileName = "检验检测报检申请受理单";
...@@ -69,7 +75,7 @@ public class PipelineDocGeneratorStrategy implements SupportableDocGenerator { ...@@ -69,7 +75,7 @@ public class PipelineDocGeneratorStrategy implements SupportableDocGenerator {
// 填充模板, word转pdf // 填充模板, word转pdf
pdfFile = WordTemplateUtils.wordToPdf(fileName, wordPath, formData); pdfFile = WordTemplateUtils.wordToPdf(fileName, wordPath, formData);
// 上传文档到文件服务器 // 上传文档到文件服务器
return WordTemplateUtils.uploadFile(pdfFile, "upload/tzs/pdf/inspectApp"); return WordTemplateUtils.uploadFile(pdfFile, "/tzs/jyjc/inspectApp");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
......
...@@ -6,7 +6,6 @@ import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; ...@@ -6,7 +6,6 @@ import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.module.common.api.enums.UserPostEnum; import com.yeejoin.amos.boot.module.common.api.enums.UserPostEnum;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplication; import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplication;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationModel; import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationModel;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
......
...@@ -37,6 +37,8 @@ import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionApplicationPushEven ...@@ -37,6 +37,8 @@ import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionApplicationPushEven
import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.EventPublisher; import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jyjc.biz.feign.JgFeignClient; import com.yeejoin.amos.boot.module.jyjc.biz.feign.JgFeignClient;
import com.yeejoin.amos.boot.module.jyjc.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jyjc.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jyjc.biz.file.inspectapp.factory.DocGeneratorFactory;
import com.yeejoin.amos.boot.module.jyjc.biz.file.inspectapp.factory.support.DocGenerator;
import com.yeejoin.amos.boot.module.jyjc.biz.service.TaskModelServiceImpl; import com.yeejoin.amos.boot.module.jyjc.biz.service.TaskModelServiceImpl;
import com.yeejoin.amos.boot.module.jyjc.biz.typeHandler.EquipCategoryTypeHandler; import com.yeejoin.amos.boot.module.jyjc.biz.typeHandler.EquipCategoryTypeHandler;
import com.yeejoin.amos.boot.module.jyjc.biz.util.CompareUtils; import com.yeejoin.amos.boot.module.jyjc.biz.util.CompareUtils;
...@@ -194,6 +196,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -194,6 +196,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
@Resource @Resource
private TzBaseEnterpriseInfoMapper baseEnterpriseInfoMapper; private TzBaseEnterpriseInfoMapper baseEnterpriseInfoMapper;
@Resource
private DocGeneratorFactory docGeneratorFactory;
@NotNull @NotNull
public static List<DictionarieModel> getDictionarieModels(String bizTypes) { public static List<DictionarieModel> getDictionarieModels(String bizTypes) {
...@@ -1908,4 +1913,10 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1908,4 +1913,10 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
} }
return regionModels; return regionModels;
} }
public String fileTest(String appSeq) {
JyjcInspectionApplication application = this.getBaseMapper().selectById(appSeq);
DocGenerator docGenerator = docGeneratorFactory.getGenerator(application.getEquipClassify(), application.getEquCategory(), application.getEquDefine());
return docGenerator.generate(appSeq);
}
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -14,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
/** /**
* 特种设备目录处理器 * 特种设备目录处理器
*/ */
@Component("equipCategoryTypeHandler") @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class EquipCategoryTypeHandler implements TypeHandler<String> { public class EquipCategoryTypeHandler implements TypeHandler<String> {
private final Map<String, String> CODE_NAME_MAP = new ConcurrentHashMap<>(); private final Map<String, String> CODE_NAME_MAP = new ConcurrentHashMap<>();
......
...@@ -13,8 +13,8 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -13,8 +13,8 @@ import java.util.concurrent.ConcurrentHashMap;
/** /**
* 特种设备目录处理器 * 特种设备目录处理器
*/ */
@Component("equipCategoryTypeHandler")
@RequiredArgsConstructor @RequiredArgsConstructor
@Component
public class InspectTypeHandler implements TypeHandler<String> { public class InspectTypeHandler implements TypeHandler<String> {
private final Map<String, String> CODE_NAME_MAP = new ConcurrentHashMap<>(); private final Map<String, String> CODE_NAME_MAP = new ConcurrentHashMap<>();
......
...@@ -15,7 +15,7 @@ import static com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant ...@@ -15,7 +15,7 @@ import static com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant
/** /**
* 行政区划处理器 * 行政区划处理器
*/ */
@Component("regionCodeTypeHandler") @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class RegionCodeTypeHandler implements TypeHandler<String> { public class RegionCodeTypeHandler implements TypeHandler<String> {
......
...@@ -13,7 +13,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -13,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
...@@ -24,6 +23,7 @@ import java.util.*; ...@@ -24,6 +23,7 @@ import java.util.*;
@Slf4j @Slf4j
public class WordTemplateUtils { public class WordTemplateUtils {
private static final String BUCKET_NAME = "upload";
public static final String BASE_PACKAGE_PATH = "/templates"; public static final String BASE_PACKAGE_PATH = "/templates";
private static WordTemplateUtils wordTemplateUtils; private static WordTemplateUtils wordTemplateUtils;
private final Configuration configuration; private final Configuration configuration;
...@@ -130,60 +130,12 @@ public class WordTemplateUtils { ...@@ -130,60 +130,12 @@ public class WordTemplateUtils {
return result; return result;
} }
public static String templateToPdf(String pdfName, String wordPath, Map<String, Object> placeholders) {
// word转pdf
File pdfFile;
try {
pdfFile = wordToPdf(pdfName, wordPath, placeholders);
} catch (Exception e) {
throw new RuntimeException(e);
}
// 上传pdf至文件服务器
String url = uploadFile(pdfFile);
// 删除临时文件
try {
Files.deleteIfExists(pdfFile.toPath());
} catch (IOException e) {
log.error("删除临时文件失败:{}", e);
}
return url;
}
public static byte[] getTemplateToPdfData(String pdfName, String wordPath, Map<String, Object> placeholders) {
// word转pdf
File pdfFile;
try {
pdfFile = wordToPdf(pdfName, wordPath, placeholders);
} catch (Exception e) {
log.error("模板转pdf失败:", e);
throw new BadRequest("模板转pdf失败");
}
try {
return file2byte(pdfFile);
} finally {
try {
Files.deleteIfExists(pdfFile.toPath());
} catch (Exception e) {
log.error("文件找不到,删除失败:", e);
}
}
}
private static byte[] file2byte(File file) { private static byte[] file2byte(File file) {
try { try {
FileInputStream in = new FileInputStream(file); return Files.readAllBytes(file.toPath());
//当文件没有结束时,每次读取一个字节显示
byte[] data = new byte[in.available()];
in.read(data);
in.close();
return data;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new RuntimeException(e);
return null;
} }
} }
...@@ -196,27 +148,7 @@ public class WordTemplateUtils { ...@@ -196,27 +148,7 @@ public class WordTemplateUtils {
public static String uploadFile(File file, String path) { public static String uploadFile(File file, String path) {
Assert.notNull(file, "文件不能为空"); Assert.notNull(file, "文件不能为空");
MultipartFile multipartFile = new ByteArrayMultipartFile("file", "file.pdf", "application/pdf", file2byte(file)); MultipartFile multipartFile = new ByteArrayMultipartFile("file", "file.pdf", "application/pdf", file2byte(file));
// 返回路径 : upload/common/${path}/xxx.xx FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateBucketFile(multipartFile, BUCKET_NAME, path);
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFileFree(multipartFile, path);
String urlString = "";
if (result != null) {
for (String s : result.getResult().keySet()) {
urlString = s;
}
}
return urlString;
}
/**
* 上传文件至文件服务器
*
* @param file 文件
*/
private static 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 = ""; String urlString = "";
if (result != null) { if (result != null) {
for (String s : result.getResult().keySet()) { for (String s : result.getResult().keySet()) {
......
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