Parcourir la source

pms 瑞鹰 钻井日报 进尺逻辑调整

zhangcl il y a 12 heures
Parent
commit
6f488afe2b

+ 6 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrydailyreport/IotRyDailyReportMapper.java

@@ -258,8 +258,10 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
         }
         // 获取 reportDate 的前一天日期
         LocalDateTime previousDay = reportDate.minusDays(1);
-        int year = previousDay.getYear();
-        int month = previousDay.getMonthValue();
+        // int year = previousDay.getYear();
+        // int month = previousDay.getMonthValue();
+        int year = reportDate.getYear();
+        int month = reportDate.getMonthValue();
 
         List<IotRyDailyReportDO> list = selectList(new LambdaQueryWrapperX<IotRyDailyReportDO>()
                 .eq(ObjUtil.isNotNull(deptId), IotRyDailyReportDO::getDeptId, deptId)
@@ -310,7 +312,8 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
         }
         // 获取 reportDate 的前一天日期
         LocalDateTime previousDay = reportDate.minusDays(1);
-        int year = previousDay.getYear();
+        // int year = previousDay.getYear();
+        int year = reportDate.getYear();
 
         List<IotRyDailyReportDO> list = selectList(new LambdaQueryWrapperX<IotRyDailyReportDO>()
                 .eq(ObjUtil.isNotNull(deptId), IotRyDailyReportDO::getDeptId, deptId)

+ 13 - 19
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportServiceImpl.java

@@ -119,7 +119,6 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
 
     @Override
     public Long createIotRyDailyReport(IotRyDailyReportSaveReqVO createReqVO) {
-        System.out.println("新增日报方法开始:");
         // 插入
         IotRyDailyReportDO iotRyDailyReport = BeanUtils.toBean(createReqVO, IotRyDailyReportDO.class);
         LocalDateTime reportDate = createReqVO.getFillOrderCreateTime();
@@ -186,12 +185,11 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
         } else {
             wellName = StrUtil.EMPTY;
             // 当前队伍没有关联任务 不生成日报
-            // throw exception(IOT_PROJECT_TASK_NOT_RELATED);
         }
 
         if (StrUtil.isBlank(createReqVO.getProjectClassification()) || "1".equals(createReqVO.getProjectClassification())) {
             // 钻井类型日报 需要根据当前井深 计算 日进尺 月进尺 年累计进尺
-
+            // 切换新井号时 当前井深=日进尺 根据施工队伍计算月累进尺、年累进尺
             // 计算月进尺 年累计进尺 reportDate对应的前一天的 年-月份 对应的日报记录日进尺的累加值
             // 查询指定部门、指定时间段 填写的日报记录的 ’月进尺数据‘(逻辑细则:reportDate 所在的月份与数据表的字段 construction_start_date
             // 所在的月份相匹配 且 create_time < reportDate 的记录的 ’daily_footage‘ 字段值累加计算得出
@@ -208,26 +206,22 @@ public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
             // 将 reportDate 减去1天 得到日期 date(yyyy-MM-dd) 查询date对应的日报记录
             IotRyDailyReportDO lastReport = iotRyDailyReportMapper.selectLatestReportBeforeDate(
                     createReqVO.getDeptId(), taskId, reportDate);
+            BigDecimal dailyFootage = BigDecimal.ZERO;
             if (ObjUtil.isNotEmpty(lastReport) && ObjUtil.isNotEmpty(lastReport.getCurrentDepth())) {
-                // 当前井深-前一天日报的当前井深 = 日进尺
-                BigDecimal dailyFootage = createReqVO.getCurrentDepth().subtract(lastReport.getCurrentDepth());
+                // 井号已经产生过日报 当前井深-前一天日报的当前井深 = 日进尺
+                dailyFootage = createReqVO.getCurrentDepth().subtract(lastReport.getCurrentDepth());
                 iotRyDailyReport.setDailyFootage(dailyFootage);
-                // 月进尺 = 当前井深 - 当前月份的最早记录天的井深
-                /* BigDecimal monthlyFootage = (monthStartFootage.compareTo(BigDecimal.ZERO) == 0)
-                        ? BigDecimal.ZERO : createReqVO.getCurrentDepth().subtract(monthStartFootage); */
-                iotRyDailyReport.setMonthlyFootage(dailyFootage.add(historyMonthlyFootage));
-                // 年累计进尺 = 当前井深 - 当前年最早记录的井深
-                /* BigDecimal annualFootage = (yearStartFootage.compareTo(BigDecimal.ZERO) == 0)
-                        ? BigDecimal.ZERO : createReqVO.getCurrentDepth().subtract(yearStartFootage); */
-                iotRyDailyReport.setAnnualFootage(dailyFootage.add(historyAnnualFootage));
             } else {
-                // 如果没有查询到数据 则设置 日进尺 为0 后期可修复数据
-                iotRyDailyReport.setDailyFootage(BigDecimal.ZERO);
-                // 月进尺 = 当前井深 - 当前月份的最早记录天的井深
-                iotRyDailyReport.setMonthlyFootage(BigDecimal.ZERO);
-                // 年累计进尺 = 当前井深 - 当前年最早记录的井深
-                iotRyDailyReport.setAnnualFootage(BigDecimal.ZERO);
+                // 新井号 如果没有查询到数据 则设置 日进尺 为 当前井深 后期可修复数据
+                dailyFootage = createReqVO.getCurrentDepth();
+                // 月进尺 = 当前队伍 施工日期所在月份的日进尺加和
+                // iotRyDailyReport.setMonthlyFootage(BigDecimal.ZERO);
+                // 年累计进尺 = 当前队伍 施工日期所在年份的日进尺加和
+                // iotRyDailyReport.setAnnualFootage(BigDecimal.ZERO);
             }
+            iotRyDailyReport.setDailyFootage(dailyFootage);
+            iotRyDailyReport.setMonthlyFootage(dailyFootage.add(historyMonthlyFootage));
+            iotRyDailyReport.setAnnualFootage(dailyFootage.add(historyAnnualFootage));
         }
 
         // 设置瑞鹰日报类型 钻井 修井