Browse Source

Merge remote-tracking branch 'origin/master'

Zimo 9 hours ago
parent
commit
4b2fee2177

+ 31 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -56,6 +56,7 @@ import java.text.DecimalFormat;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Stream;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -777,6 +778,10 @@ public class IotRhDailyReportController {
                 }
             }
 
+            // 计算每个日报的 非生产时效
+            BigDecimal sumNpt = calculateNonProductTime(reportVO);
+            reportVO.setNonProductionRate(sumNpt.divide(BigDecimal.valueOf(24), 4, RoundingMode.HALF_UP ));
+
             // 导出列表时 格式化时间为 yyyy-MM-dd
             if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
                 reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
@@ -842,6 +847,32 @@ public class IotRhDailyReportController {
         });
     }
 
+    /**
+     *  计算非生产时间累加值 计算非生产时效
+     * @param dailyReport
+     * @return
+     */
+    private BigDecimal calculateNonProductTime(IotRhDailyReportRespVO dailyReport){
+        return Stream.of(
+                        dailyReport.getAccidentTime(),
+                        dailyReport.getRepairTime(),
+                        dailyReport.getSelfStopTime(),
+                        dailyReport.getComplexityTime(),
+                        dailyReport.getRelocationTime(),
+                        dailyReport.getRectificationTime(),
+                        dailyReport.getWaitingStopTime(),
+                        dailyReport.getWinterBreakTime(),
+                        dailyReport.getPartyaDesign(),    // 注:字段名虽无Time但属于非生产时间,保留
+                        dailyReport.getPartyaPrepare(),
+                        dailyReport.getPartyaResource(),
+                        dailyReport.getOtherNptTime()
+                )
+                // 处理null值,避免调用add()时抛出NullPointerException
+                .map(bd -> Objects.isNull(bd) ? BigDecimal.ZERO : bd)
+                // Stream.reduce:从初始值0开始,依次累加所有元素
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+    }
+
     /**
      * 以井为维度 统计 瑞恒日报 分页数据 以队伍分组小计工作量
      * @param reports

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportRespVO.java

@@ -243,4 +243,7 @@ public class IotRhDailyReportRespVO {
 
     @Schema(description = "气电比 塔里木、吐哈-气/电   其它-气/电/1.07")
     private BigDecimal gasElectricityRatio;
+
+    @Schema(description = "非生产时效")
+    private BigDecimal nonProductionRate;
 }

+ 32 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/IotRyDailyReportController.java

@@ -46,6 +46,7 @@ import java.time.LocalDateTime;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Stream;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -452,6 +453,11 @@ public class IotRyDailyReportController {
                         .divide(BigDecimal.valueOf(1), 2, RoundingMode.HALF_UP);
                 reportVO.setDailyFuel(fuel);
             }
+
+            // 计算非生产时效
+            BigDecimal sumNpt = calculateNonProductTime(reportVO);
+            reportVO.setNonProductionRate(sumNpt.divide(BigDecimal.valueOf(24), 4, RoundingMode.HALF_UP ));
+
             // 日报生成日期 格式化时间为 yyyy-MM-dd
             if (ObjUtil.isNotEmpty(reportVO.getCreateTime())) {
                 reportVO.setCreateTimeStr(LocalDateTimeUtil.format(reportVO.getCreateTime(), DatePattern.NORM_DATE_PATTERN));
@@ -504,6 +510,32 @@ public class IotRyDailyReportController {
         });
     }
 
+    /**
+     *  计算非生产时间累加值 计算非生产时效
+     * @param dailyReport
+     * @return
+     */
+    private BigDecimal calculateNonProductTime(IotRyDailyReportRespVO dailyReport){
+        return Stream.of(
+                        dailyReport.getAccidentTime(),
+                        dailyReport.getRepairTime(),
+                        dailyReport.getSelfStopTime(),
+                        dailyReport.getComplexityTime(),
+                        dailyReport.getRelocationTime(),
+                        dailyReport.getRectificationTime(),
+                        dailyReport.getWaitingStopTime(),
+                        dailyReport.getWinterBreakTime(),
+                        dailyReport.getPartyaDesign(),    // 注:字段名虽无Time但属于非生产时间,保留
+                        dailyReport.getPartyaPrepare(),
+                        dailyReport.getPartyaResource(),
+                        dailyReport.getOtherNptTime()
+                )
+                // 处理null值,避免调用add()时抛出NullPointerException
+                .map(bd -> Objects.isNull(bd) ? BigDecimal.ZERO : bd)
+                // Stream.reduce:从初始值0开始,依次累加所有元素
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+    }
+
     /**
      * 瑞鹰日报分页 设置关联查询信息
      * @param reports

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportRespVO.java

@@ -299,4 +299,7 @@ public class IotRyDailyReportRespVO {
 
     @Schema(description = "小组内最后1条记录标识 true false")
     private boolean lastGroupIdFlag = false;
+
+    @Schema(description = "非生产时效")
+    private BigDecimal nonProductionRate;
 }

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

@@ -172,6 +172,14 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
                         .gt(IotRyDailyReportDO::getWaitingStopTime, BigDecimal.ZERO)
                         .or()
                         .gt(IotRyDailyReportDO::getWinterBreakTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getPartyaDesign, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getPartyaPrepare, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getPartyaResource, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getOtherNptTime, BigDecimal.ZERO)
                 );
             }
         } else {

+ 14 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

@@ -31,6 +31,20 @@
         <result column="total_water_injection" property="totalWaterInjection" />
         <result column="personnel" property="personnel" />
         <result column="total_gas_injection" property="totalGasInjection" />
+        <!-- 非生产时间 -->
+        <result column="accident_time" property="accidentTime" />
+        <result column="repair_time" property="repairTime" />
+        <result column="self_stop_time" property="selfStopTime" />
+        <result column="complexity_time" property="complexityTime" />
+        <result column="relocation_time" property="relocationTime" />
+        <result column="rectification_time" property="rectificationTime" />
+        <result column="waiting_stop_time" property="waitingStopTime" />
+        <result column="winter_break_time" property="winterBreakTime" />
+        <result column="partya_design" property="partyaDesign" />
+        <result column="partya_prepare" property="partyaPrepare" />
+        <result column="partya_resource" property="partyaResource" />
+        <result column="other_npt_time" property="otherNptTime" />
+        <result column="other_npt_reason" property="otherNptReason" />
         <!-- 其他字段映射 -->
         <result column="cumulative_completion" property="cumulativeCompletion" />
         <result column="remark" property="remark" />