|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.start.tz.module.pressure2.service.dynamicOFData.comm;
|
|
|
|
|
|
+import cn.start.tz.framework.common.pojo.CommonResult;
|
|
|
import cn.start.tz.framework.ip.core.utils.AreaUtils;
|
|
|
import cn.start.tz.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
import cn.start.tz.module.pressure2.controller.admin.dynamictbins.vo.CreateInstantiateWithRuleVO;
|
|
|
@@ -23,6 +24,7 @@ import cn.start.tz.module.pressure2.service.boilertaskorder.BoilerTaskOrderServi
|
|
|
import cn.start.tz.module.pressure2.service.boilertaskordersignfile.BoilerTaskOrderSignFileService;
|
|
|
import cn.start.tz.module.pressure2.service.dynamicOFData.IDynamicOFData;
|
|
|
import cn.start.tz.module.pressure2.service.pipetaskorder.PipeTaskOrderService;
|
|
|
+import cn.start.tz.module.system.api.calendar.CalendarApi;
|
|
|
import cn.start.tz.module.system.api.clientunit.ClientUnitApi;
|
|
|
import cn.start.tz.module.system.api.clientunit.dto.ClientUnitDTO;
|
|
|
import cn.start.tz.module.system.api.dict.DictDataApi;
|
|
|
@@ -32,6 +34,7 @@ import cn.start.tz.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import jakarta.annotation.Resource;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.DayOfWeek;
|
|
|
@@ -42,6 +45,7 @@ import java.util.List;
|
|
|
/**
|
|
|
* 特种设备检验意见通知书(1)
|
|
|
* */
|
|
|
+@Slf4j
|
|
|
@Service("QC01006_202400OFData")
|
|
|
public class QC01006_202400OFData implements IDynamicOFData {
|
|
|
|
|
|
@@ -84,6 +88,9 @@ public class QC01006_202400OFData implements IDynamicOFData {
|
|
|
@Resource
|
|
|
private DictDataApi dictDataApi;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CalendarApi calendarApi;
|
|
|
+
|
|
|
@Override
|
|
|
public JSONObject getOFData(JSONObject params) {
|
|
|
return null;
|
|
|
@@ -209,7 +216,7 @@ public class QC01006_202400OFData implements IDynamicOFData {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 计算指定日期后N个工作日的日期
|
|
|
+ * 计算指定日期后N个工作日的日期(排除周末和节假日)
|
|
|
* @param startDate 起始日期
|
|
|
* @param workingDays 工作日天数
|
|
|
* @return N个工作日后的日期
|
|
|
@@ -218,19 +225,25 @@ public class QC01006_202400OFData implements IDynamicOFData {
|
|
|
if (workingDays <= 0) {
|
|
|
return startDate;
|
|
|
}
|
|
|
-
|
|
|
+ try {
|
|
|
+ // 从起始日期的下一天开始计算,与原有逻辑保持一致
|
|
|
+ CommonResult<LocalDate> result = calendarApi.getCalendarDateByParam(startDate.plusDays(1), workingDays);
|
|
|
+ if (result != null && result.getData() != null) {
|
|
|
+ return result.getData();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("调用日历API计算工作日失败,降级为仅排除周末: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ // 降级逻辑:仅排除周末
|
|
|
LocalDate resultDate = startDate;
|
|
|
int daysToAdd = workingDays;
|
|
|
-
|
|
|
while (daysToAdd > 0) {
|
|
|
resultDate = resultDate.plusDays(1);
|
|
|
- // 跳过周末(周六和周日)
|
|
|
- if (resultDate.getDayOfWeek() != DayOfWeek.SATURDAY &&
|
|
|
- resultDate.getDayOfWeek() != DayOfWeek.SUNDAY) {
|
|
|
+ if (resultDate.getDayOfWeek() != DayOfWeek.SATURDAY &&
|
|
|
+ resultDate.getDayOfWeek() != DayOfWeek.SUNDAY) {
|
|
|
daysToAdd--;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return resultDate;
|
|
|
}
|
|
|
}
|