|
|
@@ -1,24 +1,38 @@
|
|
|
package cn.start.tz.module.pressure2.service.orderreport;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.start.tz.framework.common.exception.ErrorCode;
|
|
|
import cn.start.tz.framework.common.exception.ServiceException;
|
|
|
import cn.start.tz.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
+import cn.start.tz.module.infra.api.file.FileApi;
|
|
|
import cn.start.tz.module.pressure2.controller.admin.dynamictbins.vo.CreateInstantiateWithRuleVO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilerconnectrecordreport.BoilerConnectRecordReportDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.boilerconnecttbservice.BoilerConnectTbServiceDO;
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.boilertaskorder.BoilerTaskOrderDO;
|
|
|
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.equipboilerschedulingitem.EquipBoilerSchedulingCheckDO;
|
|
|
import cn.start.tz.module.pressure2.dal.dataobject.equippipeschedulingitem.EquipPipeSchedulingCheckDO;
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.notificationformreport.NotificationformReportDO;
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.pipetaskorder.PipeTaskOrderDO;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.boilerconnecttbservice.BoilerConnectTbServiceMapper;
|
|
|
+import cn.start.tz.module.pressure2.dal.mysql.boilertaskorder.BoilerTaskOrderMapper;
|
|
|
+import cn.start.tz.module.pressure2.dal.mysql.notificationformreport.NotificationformReportMapper;
|
|
|
+import cn.start.tz.module.pressure2.dal.mysql.pipetaskorder.PipeTaskOrderMapper;
|
|
|
import cn.start.tz.module.pressure2.service.boilerconnectrecordreport.BoilerConnectRecordReportService;
|
|
|
import cn.start.tz.module.pressure2.service.dynamictb.DynamicTbService;
|
|
|
import cn.start.tz.module.pressure2.service.dynamictbins.DynamicTbInsService;
|
|
|
import cn.start.tz.module.pressure2.service.equipboilerschedulingcheck.EquipBoilerSchedulingCheckService;
|
|
|
import cn.start.tz.module.pressure2.service.equippipeschedulingcheck.EquipPipeSchedulingCheckService;
|
|
|
+import cn.start.tz.module.pressure2.service.pdf.PdfService;
|
|
|
+import cn.start.tz.module.system.api.mail.MailSendApi;
|
|
|
+import cn.start.tz.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -36,6 +50,8 @@ import cn.start.tz.framework.common.util.object.BeanUtils;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.orderreport.OrderReportMapper;
|
|
|
|
|
|
import static cn.start.tz.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static cn.start.tz.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
+import static cn.start.tz.module.pressure.enums.ErrorCodeConstants.TASK_ORDER_SIGN_FILE_NOT_EXISTS;
|
|
|
import static cn.start.tz.module.pressure2.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
|
@@ -46,6 +62,7 @@ import static cn.start.tz.module.pressure2.enums.ErrorCodeConstants.*;
|
|
|
@Service
|
|
|
@Validated
|
|
|
@Transactional
|
|
|
+@Slf4j
|
|
|
public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, OrderReportDO> implements OrderReportService {
|
|
|
|
|
|
@Resource
|
|
|
@@ -66,9 +83,36 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
@Resource
|
|
|
private BoilerConnectRecordReportService boilerConnectRecordReportService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BoilerTaskOrderMapper boilerTaskOrderMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private NotificationformReportMapper notificationformReportMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PdfService pdfService;
|
|
|
+
|
|
|
+ @Value("${tz.minio.hostouter}")
|
|
|
+ private String minioHostouter;
|
|
|
+
|
|
|
+ @Value("${tz.minio.host}")
|
|
|
+ private String minioHost;
|
|
|
+
|
|
|
+ @Value("${tz.env.name}")
|
|
|
+ private String env;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private FileApi fileApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PipeTaskOrderMapper pipeTaskOrderMapper;
|
|
|
+
|
|
|
@Resource
|
|
|
private DynamicTbService dynamicTbService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MailSendApi mailSendApi;
|
|
|
+
|
|
|
private final String ACCEPT = "1";
|
|
|
private final String TASK = "2";
|
|
|
|
|
|
@@ -250,4 +294,96 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
updateById(one);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean serviceFromSendEmail(TaskOrderSignFilePageReqVO pageReqVO) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ String userId = getLoginUserId();
|
|
|
+ String reportUrl = "";
|
|
|
+ String fileUrl = "";
|
|
|
+ byte[] pdf = null;
|
|
|
+ //构建邮件发送参数
|
|
|
+ Map<String, Object> templateParams = new HashMap<>();
|
|
|
+ // 设置自定义附件名称
|
|
|
+ String attachmentName = "";
|
|
|
+ if (Integer.valueOf(100).equals(pageReqVO.getBusinessType())) {
|
|
|
+ BoilerTaskOrderDO taskOrderDO = boilerTaskOrderMapper.selectById(pageReqVO.getOrderId());
|
|
|
+ if (ObjectUtil.isEmpty(taskOrderDO)) {
|
|
|
+ throw exception(new ErrorCode(1001, "任务单不存在"));
|
|
|
+ }
|
|
|
+ //区分是受理单还是服务单
|
|
|
+ if (taskOrderDO.getEquipMainType() == 200){
|
|
|
+ if (Integer.valueOf(100).equals(taskOrderDO.getCheckType())) {
|
|
|
+ templateParams.put("projectName", "锅炉定期检验受理单");
|
|
|
+ attachmentName = "锅炉定期检验受理单.pdf";
|
|
|
+ } else if (Integer.valueOf(200).equals(taskOrderDO.getCheckType())) {
|
|
|
+ templateParams.put("projectName", "锅炉年度检查服务单");
|
|
|
+ attachmentName = "锅炉年度检查服务单.pdf";
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (Integer.valueOf(100).equals(taskOrderDO.getCheckType())) {
|
|
|
+ templateParams.put("projectName", "压力管道定期检验受理单");
|
|
|
+ attachmentName = "压力管道定期检验受理单.pdf";
|
|
|
+ } else if (Integer.valueOf(200).equals(taskOrderDO.getCheckType())) {
|
|
|
+ templateParams.put("projectName", "压力管道年度检查服务单");
|
|
|
+ attachmentName = "压力管道年度检查服务单.pdf";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pageReqVO.getReportId() != null){
|
|
|
+ OrderReportDO orderReportDO = orderReportMapper.selectById(pageReqVO.getReportId());
|
|
|
+ if (orderReportDO != null){
|
|
|
+ pdf = pdfService.pdf(orderReportDO.getTemplateId(), orderReportDO.getInsId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (Integer.valueOf(200).equals(pageReqVO.getBusinessType())) {
|
|
|
+ templateParams.put("projectName", "承压类特种设备检验情况告知单");
|
|
|
+ attachmentName = "承压类特种设备检验情况告知单.pdf";
|
|
|
+ if (pageReqVO.getReportId() != null){
|
|
|
+ NotificationformReportDO notificationformReportDO = notificationformReportMapper.selectById(pageReqVO.getReportId());
|
|
|
+ if (notificationformReportDO != null){
|
|
|
+ pdf = pdfService.pdf(notificationformReportDO.getTemplateId(), notificationformReportDO.getInsId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (Integer.valueOf(400).equals(pageReqVO.getBusinessType())) {
|
|
|
+ templateParams.put("projectName", "重大问题线索告知单");
|
|
|
+ attachmentName = "重大问题线索告知单.pdf";
|
|
|
+ if (pageReqVO.getReportId() != null){
|
|
|
+ DynamicTbInsDO dynamicTbIns = dynamicTbInsService.getDynamicRefId(pageReqVO.getReportId());
|
|
|
+ pdf = pdfService.pdf(dynamicTbIns.getTbId(), dynamicTbIns.getId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ attachmentName = "检验文件.pdf";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pdf == null) {
|
|
|
+ throw exception(new ErrorCode(1001, "生成报表失败"));
|
|
|
+ }else{
|
|
|
+ fileUrl = fileApi.createFile(pdf);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.equals(env, "uat")) {
|
|
|
+ reportUrl = minioHostouter + fileUrl;
|
|
|
+ } else {
|
|
|
+ reportUrl = minioHost + fileUrl;
|
|
|
+ }
|
|
|
+ log.info("报告url:{}", reportUrl);
|
|
|
+ // 发送邮件
|
|
|
+ MailSendSingleToUserReqDTO sendParam = new MailSendSingleToUserReqDTO();
|
|
|
+ sendParam.setMail(pageReqVO.getEmail());
|
|
|
+ sendParam.setTemplateCode("service-from-send-email");
|
|
|
+ sendParam.setUserId(userId);
|
|
|
+ sendParam.setTemplateParams(templateParams);
|
|
|
+
|
|
|
+ sendParam.setFilePath(List.of(reportUrl));
|
|
|
+ sendParam.setAttachmentNames(List.of(attachmentName));
|
|
|
+
|
|
|
+ mailSendApi.sendSingleMailToMember(sendParam);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("服务单/受理单/检验告知书邮箱发送失败:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|