|
|
@@ -22,10 +22,13 @@ import cn.start.tz.module.pressure2.dal.dataobject.equipboilerschedulingitem.Equ
|
|
|
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.acceptorder.AcceptOrderMapper;
|
|
|
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.dynamictb.DynamicTbMapper;
|
|
|
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.enums.RedisKeyEnums;
|
|
|
import cn.start.tz.module.pressure2.service.acceptorder.AcceptOrderService;
|
|
|
import cn.start.tz.module.pressure2.service.boilerconnectrecordreport.BoilerConnectRecordReportService;
|
|
|
import cn.start.tz.module.pressure2.service.boilertaskorderitem.BoilerTaskOrderItemService;
|
|
|
@@ -35,6 +38,8 @@ 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.dept.DeptApi;
|
|
|
+import cn.start.tz.module.system.api.dept.dto.DeptRespDTO;
|
|
|
import cn.start.tz.module.system.api.mail.MailSendApi;
|
|
|
import cn.start.tz.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
@@ -42,6 +47,7 @@ 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.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -49,7 +55,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.Duration;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.ZonedDateTime;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.start.tz.module.pressure2.controller.admin.orderreport.vo.*;
|
|
|
@@ -133,6 +144,18 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
@Resource
|
|
|
private ConfigApi configApi;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private DynamicTbMapper dynamicTbMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private StringRedisTemplate stringRedisTemplate;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AcceptOrderMapper acceptOrderMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+
|
|
|
|
|
|
private final String ACCEPT = "1";
|
|
|
private final String TASK = "2";
|
|
|
@@ -209,6 +232,8 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
orderReportDO.setAcceptOrderId(acceptOrderId);
|
|
|
orderReportDO.setOrderType(ACCEPT);
|
|
|
orderReportDO.setTemplateId(reportTemplateDO.getId());
|
|
|
+ String acceptOrderNo = this.generateAcceptOrderNo(acceptOrderId, 200, "SL");
|
|
|
+ orderReportDO.setAcceptOrderNo(acceptOrderNo);
|
|
|
|
|
|
// 生成报表数据
|
|
|
CreateInstantiateWithRuleVO ruleVO = new CreateInstantiateWithRuleVO();
|
|
|
@@ -229,6 +254,13 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
}
|
|
|
|
|
|
orderReportMapper.insertOrUpdate(orderReportDO);
|
|
|
+
|
|
|
+ //修改受理单编号
|
|
|
+ AcceptOrderDO updateAcceptOrder = new AcceptOrderDO();
|
|
|
+ updateAcceptOrder.setId(acceptOrderId);
|
|
|
+ updateAcceptOrder.setAcceptNo(acceptOrderNo);
|
|
|
+ acceptOrderMapper.updateById(updateAcceptOrder);
|
|
|
+
|
|
|
}
|
|
|
// 锅炉设备检验,定检存在委托收费项目时,需要生成一张受理单一张服务单
|
|
|
String code = configApi.getConfigValueByKey("boiler_legal_service_code").getCheckedData();
|
|
|
@@ -250,6 +282,8 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
orderReportDO.setAcceptOrderId(acceptOrderId);
|
|
|
orderReportDO.setOrderType(ACCEPT);
|
|
|
orderReportDO.setTemplateId(reportTemplateDO.getId());
|
|
|
+ String acceptOrderNo = this.generateAcceptOrderNo(acceptOrderId, 200, "WT");
|
|
|
+ orderReportDO.setAcceptOrderNo(acceptOrderNo);
|
|
|
|
|
|
// 生成报表数据
|
|
|
CreateInstantiateWithRuleVO ruleVO = new CreateInstantiateWithRuleVO();
|
|
|
@@ -280,6 +314,17 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
orderReportDO.setAcceptOrderId(acceptOrderId);
|
|
|
orderReportDO.setOrderType(ACCEPT);
|
|
|
|
|
|
+ String acceptOrderNo = "";
|
|
|
+ AcceptOrderDO acceptOrderDO = acceptOrderMapper.selectById(acceptOrderId);
|
|
|
+ if (acceptOrderDO != null){
|
|
|
+ if (acceptOrderDO.getCheckType() == 100){
|
|
|
+ acceptOrderNo = this.generateAcceptOrderNo(acceptOrderId, 300, "SL");
|
|
|
+ }else if (acceptOrderDO.getCheckType() == 200){
|
|
|
+ acceptOrderNo = this.generateAcceptOrderNo(acceptOrderId, 300, "WT");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderReportDO.setAcceptOrderNo(acceptOrderNo);
|
|
|
+
|
|
|
/*List<DynamicTbDO> list = dynamicTbService.list(new LambdaQueryWrapperX<DynamicTbDO>()
|
|
|
.eq(DynamicTbDO::getPjType, 4)
|
|
|
.eq(DynamicTbDO::getReportType, 300)
|
|
|
@@ -328,6 +373,13 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
}
|
|
|
|
|
|
orderReportMapper.insertOrUpdate(orderReportDO);
|
|
|
+
|
|
|
+ //修改受理单编号
|
|
|
+ AcceptOrderDO updateAcceptOrder = new AcceptOrderDO();
|
|
|
+ updateAcceptOrder.setId(acceptOrderId);
|
|
|
+ updateAcceptOrder.setAcceptNo(acceptOrderNo);
|
|
|
+ acceptOrderMapper.updateById(updateAcceptOrder);
|
|
|
+
|
|
|
}else {
|
|
|
throw new ServiceException(500, "生成报表数据失败,未找到主项目受理单配置");
|
|
|
}
|
|
|
@@ -640,4 +692,249 @@ public class OrderReportServiceImpl extends ServiceImpl<OrderReportMapper, Order
|
|
|
return orderReportMapper.selectList(lqw);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String generateAcceptOrderNo(String acceptOrderId,Integer EquipMainType,String prefix){
|
|
|
+
|
|
|
+ AcceptOrderDO acceptOrderDO = acceptOrderMapper.selectById(acceptOrderId);
|
|
|
+ if (acceptOrderDO == null) {
|
|
|
+ throw new ServiceException(500, "受理单号不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ String deptId = acceptOrderDO.getDeptId();
|
|
|
+ DeptRespDTO dept = deptApi.getDept(deptId).getCheckedData();
|
|
|
+ String deptCode = dept.getCode();
|
|
|
+
|
|
|
+ // 获取项目代码(2位)
|
|
|
+ String projectCode = "";
|
|
|
+ if (EquipMainType == 200){
|
|
|
+ projectCode = getProjectCodeBoiler(acceptOrderId);
|
|
|
+ }else if (EquipMainType == 300){
|
|
|
+ projectCode = getProjectCodePipe(acceptOrderId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据前缀类型选择不同的Redis key
|
|
|
+ String redisKeyBase = "WT".equals(prefix) ?
|
|
|
+ RedisKeyEnums.SERVICE_ACCEPTANCE_NO.getKey() :
|
|
|
+ RedisKeyEnums.BUSINESS_ACCEPTANCE_NO.getKey();
|
|
|
+
|
|
|
+ // 生成日期部分
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyMMdd"); // 6位年月日
|
|
|
+ String dateStr = simpleDateFormat.format(new Date());
|
|
|
+
|
|
|
+ // 生成Redis键:key类型 + 部门代码 + 项目代码 + 日期
|
|
|
+ String redisKey = redisKeyBase + deptCode + projectCode + dateStr;
|
|
|
+
|
|
|
+ // 获取当天的流水号
|
|
|
+ String value = stringRedisTemplate.opsForValue().get(redisKey);
|
|
|
+ long curEndTime = getCurEndTime();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(value)) {
|
|
|
+ //获取当前时间到今天24点的时间距离多少秒
|
|
|
+ stringRedisTemplate.opsForValue()
|
|
|
+ .set(redisKey, "01", curEndTime, TimeUnit.SECONDS);
|
|
|
+ return prefix + deptCode + projectCode + dateStr + "01";
|
|
|
+ } else {
|
|
|
+ Integer numberValue = Integer.parseInt(value) + 1;
|
|
|
+ String serialNum = String.format("%02d", numberValue); // 格式化为2位数字
|
|
|
+ stringRedisTemplate.opsForValue().set(redisKey, serialNum, curEndTime, TimeUnit.SECONDS);
|
|
|
+ return prefix + deptCode + projectCode + dateStr + serialNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取项目代码(2位)锅炉
|
|
|
+ *
|
|
|
+ * @param acceptOrderId 约检确认ID
|
|
|
+ * @return 项目代码(2位),如果获取不到则返回"00"
|
|
|
+ */
|
|
|
+ private String getProjectCodeBoiler(String acceptOrderId) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<EquipBoilerSchedulingCheckDO> checkDOList = equipBoilerSchedulingCheckService.lambdaQuery()
|
|
|
+ .eq(EquipBoilerSchedulingCheckDO::getAcceptOrderId, acceptOrderId)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!checkDOList.isEmpty()) {
|
|
|
+ List<String> checkIds = checkDOList.stream()
|
|
|
+ .map(EquipBoilerSchedulingCheckDO::getCheckId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .toList();
|
|
|
+
|
|
|
+ if (!checkIds.isEmpty()) {
|
|
|
+ List<BoilerConnectRecordReportDO> mainProjectList = boilerConnectRecordReportService.lambdaQuery()
|
|
|
+ .in(BoilerConnectRecordReportDO::getId, checkIds)
|
|
|
+ .eq(BoilerConnectRecordReportDO::getProjectType, "MAIN")
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!mainProjectList.isEmpty()) {
|
|
|
+ return mainProjectList.get(0).getProjectCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取项目代码失败,acceptOrderId: {}", acceptOrderId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "00"; // 默认值
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取项目代码(2位)管道
|
|
|
+ *
|
|
|
+ * @param acceptOrderId 约检确认ID
|
|
|
+ * @return 项目代码(2位),如果获取不到则返回"00"
|
|
|
+ */
|
|
|
+ private String getProjectCodePipe(String acceptOrderId) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<EquipPipeSchedulingCheckDO> checkDOList = equipPipeSchedulingCheckService.lambdaQuery()
|
|
|
+ .eq(EquipPipeSchedulingCheckDO::getAcceptOrderId, acceptOrderId)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!checkDOList.isEmpty()) {
|
|
|
+ List<String> checkIds = checkDOList.stream()
|
|
|
+ .map(EquipPipeSchedulingCheckDO::getCheckId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .toList();
|
|
|
+
|
|
|
+ if (!checkIds.isEmpty()) {
|
|
|
+ List<BoilerConnectRecordReportDO> mainProjectList = boilerConnectRecordReportService.lambdaQuery()
|
|
|
+ .in(BoilerConnectRecordReportDO::getId, checkIds)
|
|
|
+ .eq(BoilerConnectRecordReportDO::getProjectType, "MAIN")
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!mainProjectList.isEmpty()) {
|
|
|
+ return mainProjectList.get(0).getProjectCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取项目代码失败,acceptOrderId: {}", acceptOrderId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "00"; // 默认值
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据模版类型获取受理单编号前缀 管道
|
|
|
+ *
|
|
|
+ * @param acceptOrderId 受理单模版ID
|
|
|
+ * @return 前缀:SL(受理单)或 WT(服务单)
|
|
|
+ */
|
|
|
+ private String getAcceptanceNoPrefixPipe(String acceptOrderId) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ String templateId = "";
|
|
|
+ List<EquipPipeSchedulingCheckDO> checkDOList = equipPipeSchedulingCheckService.lambdaQuery()
|
|
|
+ .eq(EquipPipeSchedulingCheckDO::getAcceptOrderId, acceptOrderId)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!checkDOList.isEmpty()) {
|
|
|
+ List<String> checkIds = checkDOList.stream()
|
|
|
+ .map(EquipPipeSchedulingCheckDO::getCheckId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .toList();
|
|
|
+
|
|
|
+ if (!checkIds.isEmpty()) {
|
|
|
+ List<BoilerConnectRecordReportDO> mainProjectList = boilerConnectRecordReportService.lambdaQuery()
|
|
|
+ .in(BoilerConnectRecordReportDO::getId, checkIds)
|
|
|
+ .eq(BoilerConnectRecordReportDO::getProjectType, "MAIN")
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!mainProjectList.isEmpty()) {
|
|
|
+ templateId = mainProjectList.get(0).getAcceptOrderTemplateId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicTbDO dynamicTbDO = dynamicTbMapper.selectById(templateId);
|
|
|
+ if (dynamicTbDO != null) {
|
|
|
+ String tbName = dynamicTbDO.getTbName();
|
|
|
+ // 如果是服务单模版,使用WTD前缀;否则使用SLD前缀
|
|
|
+ if (tbName.contains("受理")) {
|
|
|
+ return "SL";
|
|
|
+ }else if (tbName.contains("服务")){
|
|
|
+ return "WT";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取模版类型失败,acceptOrderId: {}", acceptOrderId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "WT"; // 默认为服务单
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据模版类型获取受理单编号前缀 锅炉
|
|
|
+ *
|
|
|
+ * @param acceptOrderId 受理单模版ID
|
|
|
+ * @return 前缀:SL(受理单)或 WT(服务单)
|
|
|
+ */
|
|
|
+ private String getAcceptanceNoPrefixBoiler(String acceptOrderId) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ String templateId = "";
|
|
|
+ List<EquipBoilerSchedulingCheckDO> checkDOList = equipBoilerSchedulingCheckService.lambdaQuery()
|
|
|
+ .eq(EquipBoilerSchedulingCheckDO::getAcceptOrderId, acceptOrderId)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!checkDOList.isEmpty()) {
|
|
|
+ List<String> checkIds = checkDOList.stream()
|
|
|
+ .map(EquipBoilerSchedulingCheckDO::getCheckId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .toList();
|
|
|
+
|
|
|
+ if (!checkIds.isEmpty()) {
|
|
|
+ List<BoilerConnectRecordReportDO> mainProjectList = boilerConnectRecordReportService.lambdaQuery()
|
|
|
+ .in(BoilerConnectRecordReportDO::getId, checkIds)
|
|
|
+ .eq(BoilerConnectRecordReportDO::getProjectType, "MAIN")
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!mainProjectList.isEmpty()) {
|
|
|
+ if (mainProjectList.size() > 1){
|
|
|
+ return "SL";
|
|
|
+ }else{
|
|
|
+ templateId = mainProjectList.get(0).getAcceptOrderTemplateId();
|
|
|
+
|
|
|
+ DynamicTbDO dynamicTbDO = dynamicTbMapper.selectById(templateId);
|
|
|
+ if (dynamicTbDO != null) {
|
|
|
+ String tbName = dynamicTbDO.getTbName();
|
|
|
+ // 如果是服务单模版,使用WTD前缀;否则使用SLD前缀
|
|
|
+ if (tbName.contains("受理")) {
|
|
|
+ return "SL";
|
|
|
+ }else if (tbName.contains("服务")){
|
|
|
+ return "WT";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取模版类型失败,acceptOrderId: {}", acceptOrderId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "WT"; // 默认为服务单
|
|
|
+ }
|
|
|
+
|
|
|
+ private long getCurEndTime() {
|
|
|
+ // 获取带时区的当前时间(使用系统默认时区)
|
|
|
+ ZonedDateTime now = ZonedDateTime.now(ZoneId.systemDefault());
|
|
|
+
|
|
|
+ // 计算当天结束时间(次日00:00:00)
|
|
|
+ ZonedDateTime midnight = now.toLocalDate()
|
|
|
+ .plusDays(1)
|
|
|
+ .atStartOfDay(ZoneId.systemDefault());
|
|
|
+
|
|
|
+ // 计算时间差并获取秒数
|
|
|
+ long secondsRemaining = Duration.between(now, midnight).getSeconds();
|
|
|
+
|
|
|
+ System.out.println("距离今日24点还剩:" + secondsRemaining + "秒");
|
|
|
+ return secondsRemaining;
|
|
|
+ }
|
|
|
+
|
|
|
}
|