|
|
@@ -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
|