|
|
@@ -36,6 +36,9 @@ import cn.start.tz.module.pressure2.controller.admin.boilertaskorderitemreportve
|
|
|
import cn.start.tz.module.pressure2.controller.admin.boilertaskordersignfile.vo.BoilerTaskOrderSignFilePageReqVO;
|
|
|
import cn.start.tz.module.pressure2.controller.admin.boilertaskordersignfile.vo.BoilerTaskOrderSignFileRespVO;
|
|
|
import cn.start.tz.module.pressure2.controller.admin.bpmtaskinfo.vo.BpmTaskRespVO;
|
|
|
+import cn.start.tz.module.pressure2.controller.admin.dynamictbins.vo.CreateInstantiateWithRuleVO;
|
|
|
+import cn.start.tz.module.pressure2.controller.admin.pipetaskorderinput.vo.PipeTaskOrderInputPrintReqVO;
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.boilerconnecttbservice.BoilerConnectTbServiceDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilerelectronicreportauditrecord.BoilerElectronicReportAuditRecordDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilertaskorder.BoilerTaskOrderDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilertaskorderfollowrecord.BoilerTaskOrderFollowRecordDO;
|
|
|
@@ -46,8 +49,11 @@ import cn.start.tz.module.pressure2.dal.dataobject.boilertaskorderitemreportuser
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilertaskorderitemuser.BoilerTaskOrderItemUserDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilertaskorderuser.BoilerTaskOrderUserDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.dynamictb.DynamicTbDO;
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.dynamictbins.DynamicTbInsDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.equipboiler.EquipBoilerDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.reporttemplate.ReportTemplateDO;
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.usesignreport.UseSignReportDO;
|
|
|
+import cn.start.tz.module.pressure2.dal.mysql.boilerconnecttbservice.BoilerConnectTbServiceMapper;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.boilerelectronicreportauditrecord.BoilerElectronicReportAuditRecordMapper;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.boilertaskorder.BoilerTaskOrderMapper;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.boilertaskorderfollowrecord.BoilerTaskOrderFollowRecordMapper;
|
|
|
@@ -61,11 +67,13 @@ import cn.start.tz.module.pressure2.dal.mysql.boilertaskorderuser.BoilerTaskOrde
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.dynamictb.DynamicTbMapper;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.equipboiler.EquipBoilerMapper;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.reporttemplate.ReportTemplateMapper;
|
|
|
+import cn.start.tz.module.pressure2.dal.mysql.usesignreport.UseSignReportMapper;
|
|
|
import cn.start.tz.module.pressure2.framework.thread.CommonThread;
|
|
|
import cn.start.tz.module.pressure2.service.boilertaskorder.BoilerTaskOrderService;
|
|
|
import cn.start.tz.module.pressure2.service.boilertaskorderitemreportrecord.BoilerTaskOrderItemReportRecordService;
|
|
|
import cn.start.tz.module.pressure2.service.boilertaskorderitemreportversion.BoilerTaskOrderItemReportVersionService;
|
|
|
import cn.start.tz.module.pressure2.service.boilertaskordersignfile.BoilerTaskOrderSignFileService;
|
|
|
+import cn.start.tz.module.pressure2.service.dynamictbins.DynamicTbInsService;
|
|
|
import cn.start.tz.module.pressure2.service.pdf.PdfService;
|
|
|
import cn.start.tz.module.pressure2.util.JwApiClient;
|
|
|
import cn.start.tz.module.pressure2.util.vo.ApiResponse;
|
|
|
@@ -87,9 +95,11 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.grapecity.documents.excel.cn;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
import jakarta.validation.Valid;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.pdfbox.multipdf.PDFMergerUtility;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import jakarta.annotation.Resource;
|
|
|
@@ -100,6 +110,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@@ -175,6 +187,15 @@ public class BoilerTaskOrderIssueReportServiceImpl extends ServiceImpl<BoilerTas
|
|
|
@Resource
|
|
|
private BoilerTaskOrderMapper taskOrderMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UseSignReportMapper useSignReportMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BoilerConnectTbServiceMapper boilerConnectTbServiceMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DynamicTbInsService dynamicTbInsService;
|
|
|
+
|
|
|
@Resource
|
|
|
private DynamicTbMapper dynamicTbMapper;
|
|
|
|
|
|
@@ -769,17 +790,20 @@ public class BoilerTaskOrderIssueReportServiceImpl extends ServiceImpl<BoilerTas
|
|
|
}
|
|
|
|
|
|
EquipBoilerDO equipBoilerDO = equipBoilerMapper.selectOne(new LambdaQueryWrapperX<EquipBoilerDO>().
|
|
|
- eq(EquipBoilerDO::getEquipCode, taskOrderItemDO.getEquipCode()), false);
|
|
|
+ eq(EquipBoilerDO::getId, taskOrderItemDO.getEquipId()), false);
|
|
|
+ if(equipBoilerDO == null){
|
|
|
+ throw exception0(502,"设备不存在");
|
|
|
+ }
|
|
|
|
|
|
- ReportTemplateDO reportTemplateDO = reportTemplateMapper.selectOne(new LambdaQueryWrapperX<ReportTemplateDO>().
|
|
|
- eq(ReportTemplateDO::getName, "压力容器使用标志"), false);
|
|
|
- if (reportTemplateDO == null){
|
|
|
- throw exception0(502,"模版不存在");
|
|
|
+ DynamicTbDO dynamicTbDO = dynamicTbMapper.selectOne(new LambdaQueryWrapperX<DynamicTbDO>().
|
|
|
+ eq(DynamicTbDO::getTbName, "设备使用标志"), false);
|
|
|
+ if (dynamicTbDO == null){
|
|
|
+ throw exception0(503,"模版不存在");
|
|
|
}
|
|
|
|
|
|
String useRegisterNo = equipBoilerDO.getUseRegisterNo();
|
|
|
if(useRegisterNo.equals("-") || useRegisterNo.equals("未领证") || useRegisterNo.equals("未办证") || StringUtils.isBlank(useRegisterNo)){
|
|
|
- throw exception0(503,"使用登记证为空,不能生成使用标志");
|
|
|
+ throw exception0(504,"使用登记证为空,不能生成使用标志");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(taskOrderItemDO.getUseLogo()) && fileType == 100){
|
|
|
@@ -790,98 +814,72 @@ public class BoilerTaskOrderIssueReportServiceImpl extends ServiceImpl<BoilerTas
|
|
|
return byteArrayOutputStream;
|
|
|
}
|
|
|
|
|
|
- //实体
|
|
|
- Map<String,String> dataMap = new HashMap<>();
|
|
|
-
|
|
|
- String equipCategory = "";
|
|
|
- DictDataRespDTO boilerTypeDTO = dictDataApi.getDictData("system_equip_boiler_type",equipBoilerDO.getType().toString()).getData();
|
|
|
- if (boilerTypeDTO != null){
|
|
|
- equipCategory = boilerTypeDTO.getLabel();
|
|
|
- }
|
|
|
- //String equipType = loadByDict("system_equip_container_equip_type", equipContainerDO.getEquipType());
|
|
|
- dataMap.put("equipmentType","锅炉");
|
|
|
- dataMap.put("equipCategory",equipCategory);
|
|
|
- dataMap.put("unitName",equipBoilerDO.getUnitName());
|
|
|
-// dataMap.put("unitInnerNo",equipBoilerDO.getUnitInnerNo());
|
|
|
- dataMap.put("equipCode",equipBoilerDO.getEquipCode());
|
|
|
- dataMap.put("useRegisterNo",useRegisterNo);
|
|
|
- // 查询主报告
|
|
|
-
|
|
|
- BoilerTaskOrderItemReportDO mainReport = taskOrderItemReportMapper.selectOne(new LambdaQueryWrapperX<BoilerTaskOrderItemReportDO>().
|
|
|
- eq(BoilerTaskOrderItemReportDO::getOrderItemId,id).
|
|
|
- eq(BoilerTaskOrderItemReportDO::getReportType, 100).
|
|
|
- eq(BoilerTaskOrderItemReportDO::getTaskStatus, TaskOrderStatusEnum.REPORT_FINISH.getStatus())
|
|
|
- , false);
|
|
|
- if(mainReport == null){
|
|
|
- throw exception0(501,"");
|
|
|
- }
|
|
|
- String nextCheckDate = JsonUtils.getHandleDateValue(mainReport.getPrepareJson(), "nextCheckDate");
|
|
|
- if(StringUtils.isNotBlank(nextCheckDate)){
|
|
|
- // 2026年1月1日 -> 2026年1月 (只保留年月部分)
|
|
|
- try{
|
|
|
- DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy年M月d日");
|
|
|
- DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy年M月");
|
|
|
-
|
|
|
- LocalDate date = LocalDate.parse(nextCheckDate, inputFormatter);
|
|
|
- String yearMonth = date.format(outputFormatter);
|
|
|
- dataMap.put("nextCheckDate", yearMonth);
|
|
|
- } catch (Exception e) {
|
|
|
- dataMap.put("nextCheckDate", nextCheckDate);
|
|
|
- }
|
|
|
- }
|
|
|
+ UseSignReportDO signReportDO = new UseSignReportDO();
|
|
|
+ signReportDO.setTemplateId(dynamicTbDO.getId());
|
|
|
+ signReportDO.setReportName(dynamicTbDO.getTbName());
|
|
|
+ signReportDO.setTaskOrderId(taskOrderItemDO.getOrderId());
|
|
|
+ signReportDO.setOrderItemId(taskOrderItemDO.getId());
|
|
|
+ signReportDO.setEquipId(equipBoilerDO.getId());
|
|
|
+ signReportDO.setEquipMainType(200);
|
|
|
+ useSignReportMapper.insert(signReportDO);
|
|
|
|
|
|
- String dataJson = objectMapper.writeValueAsString(dataMap);
|
|
|
+ //生成报表
|
|
|
+ CreateInstantiateWithRuleVO ruleVO = new CreateInstantiateWithRuleVO();
|
|
|
+ ruleVO.setTemplateId(dynamicTbDO.getId());
|
|
|
+ ruleVO.setRefId(signReportDO.getId());
|
|
|
+ ruleVO.setReportType(1);
|
|
|
+ //获取tbCode的服务方法名
|
|
|
+ BoilerConnectTbServiceDO tbServiceDO = boilerConnectTbServiceMapper.selectOne(BoilerConnectTbServiceDO::getTbId,dynamicTbDO.getId());
|
|
|
+ String instanceId = "";
|
|
|
+ if (tbServiceDO != null){
|
|
|
+ ruleVO.setServiceName(tbServiceDO.getInitServiceName());
|
|
|
+ DynamicTbInsDO instantiateWithRule = dynamicTbInsService.createInstantiateWithRule(ruleVO);
|
|
|
+ instanceId = instantiateWithRule.getId();
|
|
|
+ }else{
|
|
|
+ ruleVO.setServiceName("");
|
|
|
+ DynamicTbInsDO instantiateWithRule = dynamicTbInsService.createInstantiateWithRule(ruleVO);
|
|
|
+ instanceId = instantiateWithRule.getId();
|
|
|
+ }
|
|
|
|
|
|
- byte[] bytes = fileApi.getFileByPath(reportTemplateDO.getRecordTemplateUrl()).getCheckedData();
|
|
|
- GrapeCityReqDTO grapeCityReqDTO = new GrapeCityReqDTO();
|
|
|
- grapeCityReqDTO.setCode(TEMPLATE_NON_TAX);
|
|
|
+ if (instanceId == null || instanceId.isEmpty()){
|
|
|
+ throw exception0(504,"生成使用标志表单失败");
|
|
|
+ }
|
|
|
|
|
|
- grapeCityReqDTO.setTemplateBytes(bytes);
|
|
|
- grapeCityReqDTO.setDataJson(dataJson);
|
|
|
- // 根据 fileType 设置是否生成 PDF (100=PDF, 200=图片)
|
|
|
- grapeCityReqDTO.setIsPdf(fileType == 100);
|
|
|
- grapeCityReqDTO.setIsImage(fileType == 200);
|
|
|
+ byte[] pdf = pdfService.pdf(dynamicTbDO.getId(), instanceId);
|
|
|
|
|
|
String qrcode = String.format("https://yudao-h5.hofo.co/mp/pagesSub/reportInfoList/index?id=%s&type=0",id);
|
|
|
if(env.equals("uat")){
|
|
|
qrcode = String.format("https://tjt.gzsei.cn/mp/pagesSub/reportInfoList/index?id=%s&type=0",id);
|
|
|
}
|
|
|
-// if(StringUtils.isNotBlank(qrcode)){
|
|
|
-// ByteArrayOutputStream byteArrayOutputStream = ImageUtils.generateQRCode(qrcode, 80, 80);
|
|
|
-// grapeCityReqDTO.setImageData(byteArrayOutputStream.toByteArray());
|
|
|
-// }
|
|
|
-// grapeCityReqDTO.setImageWidth(53);
|
|
|
-// grapeCityReqDTO.setImageHeight(50);
|
|
|
- grapeCityReqDTO.setIsShrinkToFit(false);
|
|
|
- bytes = grapeCityApi.getByteArrayOutputStream(grapeCityReqDTO).getData();
|
|
|
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
- byteArrayOutputStream.write(bytes);
|
|
|
|
|
|
- byte[] resultByte = bytes;
|
|
|
- try {
|
|
|
- List<SignValuesDTO> valuesDTOList = Lists.newArrayList();
|
|
|
- SignValuesDTO valuesDTO1 = new SignValuesDTO();
|
|
|
- valuesDTO1.setSealType("JYZ");
|
|
|
- valuesDTO1.setTextonce(0);
|
|
|
- valuesDTO1.setText("机构公章或");
|
|
|
- valuesDTOList.add(valuesDTO1);
|
|
|
-
|
|
|
- QrCodeValuesDTO qrCodeValuesDTO = new QrCodeValuesDTO();
|
|
|
- qrCodeValuesDTO.setMetaname("特检院相关二维码");
|
|
|
- qrCodeValuesDTO.setTextval(qrcode);
|
|
|
- qrCodeValuesDTO.setPageno("1");
|
|
|
- qrCodeValuesDTO.setWidth(71);
|
|
|
- qrCodeValuesDTO.setHeight(71);
|
|
|
- qrCodeValuesDTO.setX("441");
|
|
|
- qrCodeValuesDTO.setY("568");
|
|
|
-
|
|
|
- resultByte = this.sign(bytes, valuesDTOList, qrCodeValuesDTO);
|
|
|
- log.info("签章成功");
|
|
|
- byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
- byteArrayOutputStream.write(resultByte);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("签章异常, 记录ID: {}, 错误信息: {}", id, e.getMessage(), e);
|
|
|
- }
|
|
|
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
+ byteArrayOutputStream.write(pdf);
|
|
|
+
|
|
|
+ byte[] resultByte = pdf;
|
|
|
+// try {
|
|
|
+// List<SignValuesDTO> valuesDTOList = Lists.newArrayList();
|
|
|
+// SignValuesDTO valuesDTO1 = new SignValuesDTO();
|
|
|
+// valuesDTO1.setSealType("JYZ");
|
|
|
+// valuesDTO1.setTextonce(0);
|
|
|
+// valuesDTO1.setText("机构公章或");
|
|
|
+// valuesDTOList.add(valuesDTO1);
|
|
|
+//
|
|
|
+// QrCodeValuesDTO qrCodeValuesDTO = new QrCodeValuesDTO();
|
|
|
+// qrCodeValuesDTO.setMetaname("特检院相关二维码");
|
|
|
+// qrCodeValuesDTO.setTextval(qrcode);
|
|
|
+// qrCodeValuesDTO.setPageno("1");
|
|
|
+// qrCodeValuesDTO.setWidth(71);
|
|
|
+// qrCodeValuesDTO.setHeight(71);
|
|
|
+// qrCodeValuesDTO.setX("441");
|
|
|
+// qrCodeValuesDTO.setY("568");
|
|
|
+//
|
|
|
+// resultByte = this.sign(pdf, valuesDTOList, qrCodeValuesDTO);
|
|
|
+// log.info("签章成功");
|
|
|
+// byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
+// byteArrayOutputStream.write(resultByte);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("签章异常, 记录ID: {}, 错误信息: {}", id, e.getMessage(), e);
|
|
|
+// }
|
|
|
|
|
|
if(fileType == 100){
|
|
|
String filePath = fileApi.createFile(resultByte);
|