Compare commits

..

4 Commits

Author SHA1 Message Date
FCL
71bb44e053 Merge remote-tracking branch 'origin/test' into test 2025-12-25 11:10:01 +08:00
FCL
363185faed fix:报告数据组装 2025-12-25 11:04:59 +08:00
FCL
d0aff7840d Merge remote-tracking branch 'origin/test' into test 2025-12-25 10:30:19 +08:00
FCL
575e40773d fix:报告数据组装 2025-12-25 10:28:32 +08:00
6 changed files with 57 additions and 96 deletions

View File

@@ -150,8 +150,8 @@ public interface ErrorCodeConstants {
/*=================================resource 资源管理 1_032_150_000 ~ 1_032_199_999 ==================================*/ /*=================================resource 资源管理 1_032_150_000 ~ 1_032_199_999 ==================================*/
// ----------设备管理---------- // ----------设备管理----------
ErrorCode DEVICE_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备_设备信息不存在"); ErrorCode DEVICE_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备信息不存在");
ErrorCode DEVICE_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备_设备大类不存在"); ErrorCode DEVICE_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备大类不存在");
ErrorCode DEVICE_MAINTAIN_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备维护数据不存在"); ErrorCode DEVICE_MAINTAIN_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备维护数据不存在");
ErrorCode DEVICE_MAINTAIN_ITEM_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备维护项不存在"); ErrorCode DEVICE_MAINTAIN_ITEM_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备维护项不存在");
ErrorCode DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备业务配置不存在"); ErrorCode DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备业务配置不存在");

View File

@@ -61,7 +61,7 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
@Resource private ReportDocumentMainService reportDocumentMainService; @Resource private ReportDocumentMainService reportDocumentMainService;
@Resource private ReportDocumentDataService reportDocumentDataService; @Resource private ReportDocumentDataService reportDocumentDataService;
@Resource private ReportDocumentTypeService reportDocumentTypeService; @Resource private ReportDocumentTypeService reportDocumentTypeService;
@Resource private ConfigUserSignatureService configUserSignatureService;
@Resource private DataTemplateService dataTemplateService; @Resource private DataTemplateService dataTemplateService;
@RequestMapping("/testAsyncTask") @RequestMapping("/testAsyncTask")
@@ -181,58 +181,9 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
//处理签名 //处理签名
String docSig = vo.getDocumentSignature(); String docSig = vo.getDocumentSignature();
if(!ObjectUtils.isEmpty(docSig)){ String docSigJsonStr = reportDocumentDataService.assembleSignature(docSig);
JSONObject docSigJson = JSONObject.parseObject(docSig); if(!ObjectUtils.isEmpty(docSigJsonStr))
List<Long> sigIds = new ArrayList<>(); vo.setDocumentSignature(docSigJsonStr);
docSigJson.forEach((key, value) -> {
JSONObject obj = docSigJson.getJSONObject( key);
String signatureId = obj.getString("signatureId");
if(!ObjectUtils.isEmpty(signatureId))
sigIds.add(Long.parseLong(signatureId));
});
if(!sigIds.isEmpty()){
List<ConfigUserSignatureDO> sigList = configUserSignatureService.getByIdList(sigIds);
docSigJson.forEach((key, value) -> {
JSONObject obj = docSigJson.getJSONObject( key);
String signatureId = obj.getString("signatureId");
if(!ObjectUtils.isEmpty(signatureId)){
ConfigUserSignatureDO sig = sigList.stream().filter(item -> item.getId().equals(Long.parseLong(signatureId))).findFirst().orElse(null);
if(sig != null){
String base64 = sig.getSignatureContent();
obj.put("signatureIdBase64", base64);
}
}
});
}
vo.setDocumentSignature(docSigJson.toJSONString());
}
//处理抬头数据
// if("true".equals(editFlag)){
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String formData = vo.getFormData();
// JSONObject formDataJson = new JSONObject();
// if(!ObjectUtils.isEmpty(formData))
// formDataJson = JSONObject.parseObject(formData);
// List<ReportDocumentDataDO> dataList = reportDocumentDataService.listByMainDataId(id).getData();
// ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(reportDocumentMain.getReportDocumentTypeId());
// String customConfig = typeDO.getCustomConfig();
// String defaultConclusion = "";
// if(!ObjectUtils.isEmpty(customConfig)){
// JSONObject config = JSONObject.parseObject(customConfig);
// defaultConclusion = config.getString("defaultConclusion");
// }
// formDataJson.put("conclusion", defaultConclusion);
// if(!dataList.isEmpty())
// formDataJson.put("sampleName", dataList.get(0).getSampleName());
// //处理检测标准
// String standard = assembleStandard(dataList);
// formDataJson.put("standard", standard);
// formDataJson.put("reportTime", sdf.format(new Date()));
// vo.setFormData(formDataJson.toJSONString());
// }
return success(vo); return success(vo);
} }

View File

@@ -118,19 +118,9 @@ public class ReportDocumentAssistService {
CommonResult<JSONArray> result = reportDocumentDataService.assembleDynamicData(mainDO, typeDO, pageFlag); CommonResult<JSONArray> result = reportDocumentDataService.assembleDynamicData(mainDO, typeDO, pageFlag);
JSONArray data = result.getData(); JSONArray data = result.getData();
String templateContent = templateDO.getFormContent(); String templateContent = templateDO.getFormContent();
JSONObject templateData = new JSONObject();
JSONArray tableList = data.getJSONArray(0);
JSONObject headerData = new JSONObject();
if(tableList != null && !tableList.isEmpty())
headerData = tableList.getJSONObject(0).clone();
templateData.put("headerData", headerData);
templateData.put("tableList", tableList);
templateData.put("formData", mainDO.getFormData());
templateData.put("signatureData", mainDO.getDocumentSignature());
JSONObject bodyJson = new JSONObject(); JSONObject bodyJson = new JSONObject();
bodyJson.put("Template", templateContent); bodyJson.put("Template", templateContent);
bodyJson.put("Data", templateData.toJSONString()); bodyJson.put("Data", data.toJSONString());
String bodyStr = bodyJson.toJSONString(); String bodyStr = bodyJson.toJSONString();
log.info("html2pdf body: " + bodyStr); log.info("html2pdf body: " + bodyStr);
log.info("html2pdf--start at {}", LocalDateTime.now()); log.info("html2pdf--start at {}", LocalDateTime.now());
@@ -142,12 +132,9 @@ public class ReportDocumentAssistService {
InputStream inputStream = response.bodyStream(); // 关键:返回原始 InputStream InputStream inputStream = response.bodyStream(); // 关键:返回原始 InputStream
//尝试从响应头中提取文件名 //尝试从响应头中提取文件名
// String contentDisposition = response.header("Content-Disposition");
String documentCode = mainDO.getDocumentCode(); String documentCode = mainDO.getDocumentCode();
if(documentCode == null) documentCode = ""; if(documentCode == null) documentCode = "";
String filename = documentCode + "检测报告.pdf"; String filename = documentCode + "检测报告.pdf";
// String filename = extractFilename(contentDisposition).orElse(defaultName);
//inputStream转byte[]
byte[] fileBytes = IOUtils.toByteArray(inputStream); byte[] fileBytes = IOUtils.toByteArray(inputStream);
//上传到文件服务 //上传到文件服务
@@ -172,24 +159,4 @@ public class ReportDocumentAssistService {
reportDocumentFileService.createReportDocumentFile(fileSaveReqVO); reportDocumentFileService.createReportDocumentFile(fileSaveReqVO);
return BeanUtils.toBean(fileRespDTO, ReportDocumentFileDO.class); return BeanUtils.toBean(fileRespDTO, ReportDocumentFileDO.class);
} }
// private Optional<String> extractFilename(String contentDisposition) {
// if (contentDisposition != null && contentDisposition.contains("filename=")) {
// String filename = contentDisposition.substring(contentDisposition.indexOf("filename=") + 9);
// filename = filename.replaceAll("\"", "").trim();
// return Optional.of(filename);
// }
// return Optional.empty();
// }
// private String encodeFilename(String filename) {
// try {
// return URLEncoder.encode(filename, StandardCharsets.UTF_8.toString())
// .replaceAll("\\+", "%20");
// } catch (Exception e) {
// return "download.bin";
// }
// }
} }

View File

@@ -25,7 +25,7 @@ public interface ReportDocumentDataService {
CommonResult<Long> countMainDataId(Long mainDataId); CommonResult<Long> countMainDataId(Long mainDataId);
CommonResult<String> removeByMainIdAndDetailIds(Long mainDataId, List<Long> detailIds); CommonResult<String> removeByMainIdAndDetailIds(Long mainDataId, List<Long> detailIds);
String assembleSignature(String docSig);
/** /**
* 创建检测报告明细 * 创建检测报告明细

View File

@@ -39,6 +39,8 @@ public class ReportDocumentFileServiceImpl implements ReportDocumentFileService
LambdaQueryWrapper<ReportDocumentFileDO> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ReportDocumentFileDO> query = new LambdaQueryWrapper<>();
query.eq(ReportDocumentFileDO::getMainId, mainId); query.eq(ReportDocumentFileDO::getMainId, mainId);
query.eq(ReportDocumentFileDO::getVersion, version); query.eq(ReportDocumentFileDO::getVersion, version);
query.orderByDesc(ReportDocumentFileDO::getCreateTime);
query.last("LIMIT 1");
return reportDocumentFileMapper.selectOne(query); return reportDocumentFileMapper.selectOne(query);
} }