|
|
@@ -13,7 +13,6 @@ import cn.start.tz.module.pressure2.controller.admin.boilertaskordersignfile.vo.
|
|
|
import cn.start.tz.module.pressure2.controller.admin.dynamictbins.vo.CreateInstantiateWithRuleVO;
|
|
|
import cn.start.tz.module.pressure2.controller.app.taskorder.vo.ServeOrderSignRespVo;
|
|
|
import cn.start.tz.module.pressure2.controller.appapi.boilertaskorder.vo.OrderFromPdfReqVO;
|
|
|
-import cn.start.tz.module.pressure2.controller.appapi.boilertaskorder.vo.TaskOrderAppPushReqVO;
|
|
|
import cn.start.tz.module.pressure2.controller.appapi.boilertaskorder.vo.TaskOrderPushReqVO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilerconnecttbservice.BoilerConnectTbServiceDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilertaskorder.BoilerTaskOrderDO;
|
|
|
@@ -216,7 +215,12 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
saveOrUpdateSignFile(taskOrderSignFileDO, taskOrderDO, reqVO);
|
|
|
|
|
|
// 根据业务类型生成对应的报告
|
|
|
- handleReportGeneration(taskOrderDO, reqVO);
|
|
|
+ String url = handleReportGeneration(taskOrderDO, reqVO);
|
|
|
+
|
|
|
+ taskOrderSignFileDO.setSignFilePdf(url);
|
|
|
+
|
|
|
+ // 生成pdf
|
|
|
+ boilerTaskOrderSignFileService.updateById(taskOrderSignFileDO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -470,64 +474,6 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * app端签名提交
|
|
|
- * <p>
|
|
|
- * 处理从app端提交的签名,更新对应的报告记录并生成动态报表。
|
|
|
- * 支持受理单(100)和检验情况告知(200)两种业务类型。
|
|
|
- *
|
|
|
- * @param reqVO app签名提交请求
|
|
|
- * @throws Exception 处理过程中可能抛出的异常
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public void orderAppSignSubmit(TaskOrderAppPushReqVO reqVO) throws Exception {
|
|
|
- if (reqVO == null || reqVO.getId() == null) {
|
|
|
- throw new ServiceException(400, "请求参数不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- // 查询任务单,不存在则抛出异常
|
|
|
- BoilerTaskOrderDO taskOrderDO = boilerTaskOrderMapper.selectById(reqVO.getId());
|
|
|
- if (taskOrderDO == null) {
|
|
|
- throw new ServiceException(404, "任务单不存在");
|
|
|
- }
|
|
|
-
|
|
|
- if (reqVO.getBusinessType().equals(BUSINESS_TYPE_ACCEPT_REPORT)) {
|
|
|
- // 受理单:更新报告签名信息并重新生成报告
|
|
|
- OrderReportDO orderReport = orderReportService.getById(reqVO.getOrderReportId());
|
|
|
- if (orderReport == null) {
|
|
|
- throw new ServiceException(404, "报告记录不存在");
|
|
|
- }
|
|
|
- orderReport.setSignDate(now());
|
|
|
- orderReport.setSignUrl(reqVO.getSignUrl());
|
|
|
-
|
|
|
- if (taskOrderDO.getEquipMainType().equals(EQUIP_TYPE_BOILER)) {
|
|
|
- orderReportService.generateBoilerOrderReport(taskOrderDO.getAcceptOrderId());
|
|
|
- } else {
|
|
|
- orderReportService.generatePipeOrderReport(taskOrderDO.getAcceptOrderId());
|
|
|
- }
|
|
|
- orderReportService.save(orderReport);
|
|
|
-
|
|
|
- } else if (reqVO.getBusinessType().equals(BUSINESS_TYPE_NOTIFICATIONFORM_REPORT)) {
|
|
|
- // 检验情况告知:更新第一个通知表单的签名信息,并批量创建动态报表
|
|
|
- List<NotificationformReportDO> notificationReportDOs = notificationformReportMapper
|
|
|
- .selectList(NotificationformReportDO::getTaskOrderId, taskOrderDO.getId());
|
|
|
-
|
|
|
- if (notificationReportDOs.isEmpty()) {
|
|
|
- throw new ServiceException(404, "通知表单报告不存在");
|
|
|
- }
|
|
|
-
|
|
|
- // 更新第一个通知表单报告的签名信息
|
|
|
- NotificationformReportDO notificationReportDO = notificationReportDOs.get(0);
|
|
|
- notificationReportDO.setSignUrl(reqVO.getSignUrl());
|
|
|
- notificationReportDO.setSignDate(now());
|
|
|
- notificationformReportMapper.updateById(notificationReportDO);
|
|
|
-
|
|
|
- // 批量创建动态报表实例
|
|
|
- processSubReportInstances(taskOrderDO, notificationReportDOs);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// ======================== 私有方法 ========================
|
|
|
|
|
|
/**
|
|
|
@@ -570,34 +516,55 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
/**
|
|
|
* 根据业务类型生成对应的报告
|
|
|
*/
|
|
|
- private void handleReportGeneration(BoilerTaskOrderDO taskOrderDO, TaskOrderPushReqVO reqVO) {
|
|
|
+ private String handleReportGeneration(BoilerTaskOrderDO taskOrderDO, TaskOrderPushReqVO reqVO) throws Exception {
|
|
|
if (reqVO.getBusinessType().equals(BUSINESS_TYPE_ACCEPT_REPORT)) {
|
|
|
- generateMainReport(taskOrderDO);
|
|
|
+ return generateAcceptReport(taskOrderDO);
|
|
|
|
|
|
} else if (reqVO.getBusinessType().equals(BUSINESS_TYPE_NOTIFICATIONFORM_REPORT)) {
|
|
|
List<NotificationformReportDO> notificationReportDOs = notificationformReportMapper
|
|
|
.selectList(NotificationformReportDO::getTaskOrderId, taskOrderDO.getId());
|
|
|
if (notificationReportDOs != null) {
|
|
|
- processSubReportInstances(taskOrderDO, notificationReportDOs);
|
|
|
+ return processNotificationformInstances(taskOrderDO, notificationReportDOs);
|
|
|
}
|
|
|
|
|
|
} else if (reqVO.getBusinessType().equals(BUSINESS_TYPE_SINGLE_REPORT)) {
|
|
|
- processSingleReportInstances(taskOrderDO, reqVO.getSecurityCheckId());
|
|
|
+ return processSingleReportInstances(taskOrderDO, reqVO.getSecurityCheckId());
|
|
|
|
|
|
} else if (reqVO.getBusinessType().equals(BUSINESS_TYPE_SUGGESTION)) {
|
|
|
- processSuggestionReportSync(taskOrderDO);
|
|
|
+ return processSuggestionReportSync(taskOrderDO);
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成受理单(业务类型 100)
|
|
|
*/
|
|
|
- private void generateMainReport(BoilerTaskOrderDO taskOrderDO) {
|
|
|
+ private String generateAcceptReport(BoilerTaskOrderDO taskOrderDO) throws Exception {
|
|
|
if (taskOrderDO.getEquipMainType().equals(EQUIP_TYPE_BOILER)) {
|
|
|
orderReportService.generateBoilerOrderReport(taskOrderDO.getAcceptOrderId());
|
|
|
} else {
|
|
|
orderReportService.generatePipeOrderReport(taskOrderDO.getAcceptOrderId());
|
|
|
}
|
|
|
+
|
|
|
+ String templateId = null; // Initialize templateId
|
|
|
+ String instanceId = null;
|
|
|
+ OrderReportDO orderReport = null;
|
|
|
+ BoilerTaskOrderDO taskOrder = boilerTaskOrderMapper.selectById(taskOrderDO.getId());
|
|
|
+ if (taskOrder != null && StringUtils.isNotBlank(taskOrder.getAcceptOrderId())) {
|
|
|
+ orderReport = orderReportMapper.selectOne(
|
|
|
+ new LambdaQueryWrapperX<OrderReportDO>()
|
|
|
+ .eq(OrderReportDO::getAcceptOrderId, taskOrder.getAcceptOrderId())
|
|
|
+ .orderByDesc(OrderReportDO::getCreateTime)
|
|
|
+ .last("limit 1"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (orderReport != null) {
|
|
|
+ StringUtils.isBlank(templateId);
|
|
|
+ templateId = orderReport.getTemplateId();
|
|
|
+ instanceId = orderReport.getInsId();
|
|
|
+ }
|
|
|
+ byte[] pdf = pdfService.pdf(templateId, instanceId);
|
|
|
+ return fileApi.createFile(pdf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -606,8 +573,9 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
* @param taskOrderDO 任务单
|
|
|
* @param notificationReportDOs 通知表单报告列表
|
|
|
*/
|
|
|
- private void processSubReportInstances(BoilerTaskOrderDO taskOrderDO, List<NotificationformReportDO> notificationReportDOs) {
|
|
|
+ private String processNotificationformInstances(BoilerTaskOrderDO taskOrderDO, List<NotificationformReportDO> notificationReportDOs) throws Exception {
|
|
|
String equipMainType = taskOrderDO.getEquipMainType().equals(EQUIP_TYPE_BOILER) ? "boiler" : "pipe";
|
|
|
+ String pdfUrl = null;
|
|
|
for (NotificationformReportDO reportDO : notificationReportDOs) {
|
|
|
DynamicTbDO dynamicTbDO = dynamicTbMapper.selectById(reportDO.getTemplateId());
|
|
|
if (dynamicTbDO == null) {
|
|
|
@@ -619,7 +587,15 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
String serviceName = tbServiceDO != null ? tbServiceDO.getInitServiceName() : "";
|
|
|
buildAndCreateDynamicReport(equipMainType, reportDO.getId(), reportDO.getTemplateId(),
|
|
|
dynamicTbDO.getTbName(), serviceName);
|
|
|
+ // 生成并保存PDF,返回第一个报告的PDF URL
|
|
|
+ String instanceId = resolveDynamicRefId(reportDO.getId());
|
|
|
+ byte[] pdf = pdfService.pdf(reportDO.getTemplateId(), instanceId);
|
|
|
+ String url = fileApi.createFile(pdf);
|
|
|
+ if (pdfUrl == null) {
|
|
|
+ pdfUrl = url;
|
|
|
+ }
|
|
|
}
|
|
|
+ return pdfUrl;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -628,14 +604,21 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
*
|
|
|
* @param taskOrderDO 任务单
|
|
|
* @param securityCheckId 安全检查记录ID
|
|
|
+ * @return
|
|
|
*/
|
|
|
- private void processSingleReportInstances(BoilerTaskOrderDO taskOrderDO, String securityCheckId) {
|
|
|
+ private String processSingleReportInstances(BoilerTaskOrderDO taskOrderDO, String securityCheckId) throws Exception {
|
|
|
+ String pdfUrl = null;
|
|
|
if (taskOrderDO.getEquipMainType().equals(EQUIP_TYPE_BOILER)) {
|
|
|
List<BoilerTaskOrderSecurityCheckDO> boilerChecks = taskOrderSecurityCheckMapper
|
|
|
.selectList(BoilerTaskOrderSecurityCheckDO::getOrderId, taskOrderDO.getId());
|
|
|
for (BoilerTaskOrderSecurityCheckDO checkDO : boilerChecks) {
|
|
|
if (Objects.equals(checkDO.getId(), securityCheckId)) {
|
|
|
createSingleReportByTemplate(checkDO.getId(), "boiler");
|
|
|
+ // 生成并保存PDF
|
|
|
+ String templateId = safeGetDynamicTbById(TemplateIdConstants.A_Q_J_C_G_Z_D).getId();
|
|
|
+ String instanceId = resolveDynamicRefId(checkDO.getId());
|
|
|
+ byte[] pdf = pdfService.pdf(templateId, instanceId);
|
|
|
+ pdfUrl = fileApi.createFile(pdf);
|
|
|
}
|
|
|
}
|
|
|
} else if (taskOrderDO.getEquipMainType().equals(EQUIP_TYPE_PIPE)) {
|
|
|
@@ -644,9 +627,15 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
for (PipeTaskOrderSecurityCheckDO checkDO : pipeChecks) {
|
|
|
if (Objects.equals(checkDO.getId(), securityCheckId)) {
|
|
|
createSingleReportByTemplate(checkDO.getId(), "pipe");
|
|
|
+ // 生成并保存PDF
|
|
|
+ String templateId = safeGetDynamicTbById(TemplateIdConstants.A_Q_J_C_G_Z_D).getId();
|
|
|
+ String instanceId = resolveDynamicRefId(checkDO.getId());
|
|
|
+ byte[] pdf = pdfService.pdf(templateId, instanceId);
|
|
|
+ pdfUrl = fileApi.createFile(pdf);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return pdfUrl;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -666,8 +655,11 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
|
|
|
/**
|
|
|
* 处理检验意见通知书(业务类型 400)的报告数据同步
|
|
|
+ *
|
|
|
+ * @return
|
|
|
*/
|
|
|
- private void processSuggestionReportSync(BoilerTaskOrderDO taskOrderDO) {
|
|
|
+ private String processSuggestionReportSync(BoilerTaskOrderDO taskOrderDO) throws Exception {
|
|
|
+ String pdfUrl = null;
|
|
|
if (taskOrderDO.getEquipMainType().equals(EQUIP_TYPE_BOILER)) {
|
|
|
List<BoilerTaskOrderItemReportDO> boilerReports = boilerTaskOrderItemReportMapper
|
|
|
.selectList(new LambdaQueryWrapperX<BoilerTaskOrderItemReportDO>()
|
|
|
@@ -675,6 +667,13 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
.eq(BoilerTaskOrderItemReportDO::getReportType, REPORT_TYPE_RECORD));
|
|
|
for (BoilerTaskOrderItemReportDO reportDO : boilerReports) {
|
|
|
syncSingleReport(boilerTaskOrderService, reportDO.getId(), "boiler");
|
|
|
+ // 生成并保存PDF,返回第一个报告的PDF URL
|
|
|
+ String instanceId = resolveDynamicRefId(reportDO.getId());
|
|
|
+ byte[] pdf = pdfService.pdf(reportDO.getTemplateId(), instanceId);
|
|
|
+ String url = fileApi.createFile(pdf);
|
|
|
+ if (pdfUrl == null) {
|
|
|
+ pdfUrl = url;
|
|
|
+ }
|
|
|
}
|
|
|
} else if (taskOrderDO.getEquipMainType().equals(EQUIP_TYPE_PIPE)) {
|
|
|
List<PipeTaskOrderItemReportDO> pipeReports = pipeTaskOrderItemReportMapper
|
|
|
@@ -683,8 +682,16 @@ public class TaskSignServiceImpl implements TaskSignService {
|
|
|
.eq(PipeTaskOrderItemReportDO::getReportType, REPORT_TYPE_RECORD));
|
|
|
for (PipeTaskOrderItemReportDO reportDO : pipeReports) {
|
|
|
syncSingleReport(pipeTaskOrderService, reportDO.getId(), "pipe");
|
|
|
+ // 生成并保存PDF,返回第一个报告的PDF URL
|
|
|
+ String instanceId = resolveDynamicRefId(reportDO.getId());
|
|
|
+ byte[] pdf = pdfService.pdf(reportDO.getTemplateId(), instanceId);
|
|
|
+ String url = fileApi.createFile(pdf);
|
|
|
+ if (pdfUrl == null) {
|
|
|
+ pdfUrl = url;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ return pdfUrl;
|
|
|
}
|
|
|
|
|
|
/**
|