|
|
@@ -1,6 +1,7 @@
|
|
|
package cn.iocoder.yudao.module.pms.service.iotfivedailyreport;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
@@ -10,6 +11,8 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiv
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotfivedailyreport.vo.IotFiveDailyReportStatisticsRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotfivedailyreport.IotFiveDailyReportDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotfivedailyreport.IotFiveDailyReportMapper;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -17,6 +20,8 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
@@ -181,4 +186,434 @@ public class IotFiveDailyReportServiceImpl implements IotFiveDailyReportService
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IotFiveDailyReportStatisticsRespVO> summaryStatistics(IotFiveDailyReportPageReqVO pageReqVO) {
|
|
|
+ List<IotFiveDailyReportStatisticsRespVO> result = new ArrayList<>();
|
|
|
+ // 不分页统计所有数据
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
|
|
|
+ pageReqVO.setDeptId(388l);
|
|
|
+ }
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ // 找到所有子部门对象集合
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ pageReqVO.setDeptIds(ids);
|
|
|
+ // 检查contractName不为空但projectIds为空的情况
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getProjectName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ // 检查taskName不为空但taskIds为空的情况
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getWellName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ PageResult<IotFiveDailyReportDO> pageReports = iotFiveDailyReportMapper.selectPage(pageReqVO);
|
|
|
+ List<IotFiveDailyReportDO> dailyReports = pageReports.getList();
|
|
|
+
|
|
|
+ // 默认显示所有项目部的汇总数据(新疆分公司也展示 下属各项目部的数据)
|
|
|
+ // 点击项目部 显示 下属队伍的数据
|
|
|
+ // 首先判断点击的部门是属于 公司 还是 队伍 如果没有点击任何部门 默认查询所有项目部数据
|
|
|
+ if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
|
|
|
+ result = statisticsByProjectDept(dailyReports, 388L, pageReqVO);
|
|
|
+ } else {
|
|
|
+ // 判断点击的组织树中的部门类型 类型(公司级1 项目部2 队伍3)
|
|
|
+ DeptDO selectedDept = deptService.getDept(pageReqVO.getDeptId());
|
|
|
+ if ("1".equals(selectedDept.getType())) {
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
+ result = statisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO);
|
|
|
+ } else if ("2".equals(selectedDept.getType())) {
|
|
|
+ // 以队伍为维度汇总数据
|
|
|
+ result = statisticsByProjectDepartment(dailyReports, pageReqVO);
|
|
|
+ } else if ("3".equals(selectedDept.getType())) {
|
|
|
+ // 显示单个队伍的汇总数据
|
|
|
+ result = statisticsByProjectDepartment(dailyReports, pageReqVO);
|
|
|
+ } else {
|
|
|
+ // 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
+ result = statisticsByProjectDept(dailyReports, pageReqVO.getDeptId(), pageReqVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 根据result集合内对象的 sort 属性正序排列 sort 类型为 integer 类型
|
|
|
+ if (CollUtil.isNotEmpty(result)) {
|
|
|
+ result.sort(Comparator.comparing(
|
|
|
+ IotFiveDailyReportStatisticsRespVO::getSort,
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder())
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按项目部维度 汇总 统计数据
|
|
|
+ * @param dailyReports 日报数据列表
|
|
|
+ * @param rootDeptId 根部门ID(如 388L为 5#国 根部门,或其他公司级部门ID)
|
|
|
+ * @return 项目部维度统计结果列表
|
|
|
+ */
|
|
|
+ private List<IotFiveDailyReportStatisticsRespVO> statisticsByProjectDept(List<IotFiveDailyReportDO> dailyReports,
|
|
|
+ Long rootDeptId, IotFiveDailyReportPageReqVO pageReqVO) {
|
|
|
+ List<IotFiveDailyReportStatisticsRespVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ Set<Long> projectDeptIds = new HashSet<>();
|
|
|
+ // key项目部id value项目部名称
|
|
|
+ Map<Long, DeptDO> projectDeptPair = new HashMap<>();
|
|
|
+ // key部门id value部门parentId
|
|
|
+ Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
+ // key队伍id value队伍部门
|
|
|
+ Map<Long, DeptDO> teamDeptPair = new HashMap<>();
|
|
|
+
|
|
|
+ // key队伍id/项目部id value累计 桥塞(个数)
|
|
|
+ Map<Long, BigDecimal> cumulativeBridgePlugPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 注液
|
|
|
+ Map<Long, BigDecimal> cumulativeLiquidPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 作业泵车数量
|
|
|
+ Map<Long, BigDecimal> cumulativeWorkDevicePair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 油耗
|
|
|
+ Map<Long, BigDecimal> cumulativeFuelsPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 累计主设备泵车数量
|
|
|
+ Map<Long, BigDecimal> cumulativeMainDevicePair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 段数 累计施工-层
|
|
|
+ Map<Long, BigDecimal> cumulativeWorkingLayersPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 台次 当日仪表/混砂
|
|
|
+ Map<Long, BigDecimal> cumulativeMixSandPair = new HashMap<>();
|
|
|
+
|
|
|
+ // 队伍id 集合
|
|
|
+ Set<Long> teamIds = new HashSet<>();
|
|
|
+
|
|
|
+ // 以项目部为维度统计数据
|
|
|
+ // 找到所有项目部与队伍的对应关系
|
|
|
+ // 查询指定根部门下的所有子部门
|
|
|
+ Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(rootDeptId);
|
|
|
+ DeptListReqVO reqVO = new DeptListReqVO();
|
|
|
+ reqVO.setDeptIds(allRhChildDeptIds);
|
|
|
+ List<DeptDO> depts = deptService.getDeptList(reqVO);
|
|
|
+
|
|
|
+ depts.forEach(dept -> {
|
|
|
+ if ("2".equals(dept.getType())) {
|
|
|
+ // 项目部
|
|
|
+ projectDeptIds.add(dept.getId());
|
|
|
+ projectDeptPair.put(dept.getId(), dept);
|
|
|
+ }
|
|
|
+ if ("3".equals(dept.getType())) {
|
|
|
+ // 队伍
|
|
|
+ teamIds.add(dept.getId());
|
|
|
+ teamDeptPair.put(dept.getId(), dept);
|
|
|
+ }
|
|
|
+ // 可能是项目部 也可能是队伍
|
|
|
+ teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 计算指定时间区间内包含的天数
|
|
|
+ long daysCount;
|
|
|
+ if (ObjUtil.isNotEmpty(pageReqVO.getCreateTime()) && pageReqVO.getCreateTime().length >= 2) {
|
|
|
+ LocalDateTime start = pageReqVO.getCreateTime()[0];
|
|
|
+ LocalDateTime end = pageReqVO.getCreateTime()[1];
|
|
|
+
|
|
|
+ if (ObjUtil.isNotEmpty(start) && ObjUtil.isNotEmpty(end) && !end.isBefore(start)) {
|
|
|
+ // 使用ChronoUnit.DAYS.between计算天数差,并+1包含首尾两天
|
|
|
+ daysCount = ChronoUnit.DAYS.between(
|
|
|
+ start.toLocalDate(),
|
|
|
+ end.toLocalDate()
|
|
|
+ ) + 1;
|
|
|
+ } else {
|
|
|
+ daysCount = 0L;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ daysCount = 0L;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 累计计算各项 工作量
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ // 油耗
|
|
|
+ BigDecimal dailyFuel = report.getDailyFuel();
|
|
|
+ // 当日主压层数(层)
|
|
|
+ BigDecimal dailyLayers = report.getDailyWorkingLayers();
|
|
|
+ // 当日加砂
|
|
|
+ BigDecimal dailySand = report.getDailySandVolume();
|
|
|
+ // 当日注液
|
|
|
+ BigDecimal dailyLiquid = report.getDailyLiquidVolume();
|
|
|
+ // 设备利用率 作业泵车数量/主设备泵车数量
|
|
|
+ BigDecimal wokDeviceNum = report.getWokDeviceNum();
|
|
|
+ BigDecimal mainDeviceNum = report.getMainDeviceNum();
|
|
|
+
|
|
|
+ if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
|
+ // projectDeptId可能是项目部 也可能是项目的上级
|
|
|
+ Long projectDeptId = 0l;
|
|
|
+ if (teamDeptPair.containsKey(report.getDeptId())) {
|
|
|
+ // 日报deptId如果是队伍 获取队伍的上级项目部
|
|
|
+ projectDeptId = teamProjectIdPair.get(report.getDeptId());
|
|
|
+ }
|
|
|
+ if (projectDeptPair.containsKey(report.getDeptId())) {
|
|
|
+ // 日报deptId如果是项目部 使用当前项目部
|
|
|
+ projectDeptId = report.getDeptId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjUtil.isNotEmpty(projectDeptId) && (projectDeptId > 0)) {
|
|
|
+ // 累计油耗
|
|
|
+ if (cumulativeFuelsPair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal existTotalFuel = cumulativeFuelsPair.get(projectDeptId);
|
|
|
+ BigDecimal tempTotalFuel = existTotalFuel.add(dailyFuel);
|
|
|
+ cumulativeFuelsPair.put(projectDeptId, tempTotalFuel);
|
|
|
+ } else {
|
|
|
+ cumulativeFuelsPair.put(projectDeptId, dailyFuel);
|
|
|
+ }
|
|
|
+ // 累计主压层数(层)
|
|
|
+ if (cumulativeWorkingLayersPair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal existTotalLayers = cumulativeWorkingLayersPair.get(projectDeptId);
|
|
|
+ BigDecimal tempTotalLayers = existTotalLayers.add(dailyFuel);
|
|
|
+ cumulativeWorkingLayersPair.put(projectDeptId, tempTotalLayers);
|
|
|
+ } else {
|
|
|
+ cumulativeWorkingLayersPair.put(projectDeptId, dailyLayers);
|
|
|
+ }
|
|
|
+ // 累计加砂
|
|
|
+ if (cumulativeMixSandPair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal existTotalSand = cumulativeMixSandPair.get(projectDeptId);
|
|
|
+ BigDecimal tempTotalSand = existTotalSand.add(dailyFuel);
|
|
|
+ cumulativeMixSandPair.put(projectDeptId, tempTotalSand);
|
|
|
+ } else {
|
|
|
+ cumulativeMixSandPair.put(projectDeptId, dailySand);
|
|
|
+ }
|
|
|
+ // 累计注液
|
|
|
+ if (cumulativeLiquidPair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal existTotalLiquid = cumulativeLiquidPair.get(projectDeptId);
|
|
|
+ BigDecimal tempTotalLiquid = existTotalLiquid.add(dailyFuel);
|
|
|
+ cumulativeLiquidPair.put(projectDeptId, tempTotalLiquid);
|
|
|
+ } else {
|
|
|
+ cumulativeLiquidPair.put(projectDeptId, dailyLiquid);
|
|
|
+ }
|
|
|
+ // 累计作业泵车数量
|
|
|
+ if (cumulativeWorkDevicePair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal existTotalWorkNum = cumulativeWorkDevicePair.get(projectDeptId);
|
|
|
+ BigDecimal tempWorkDeviceNum = existTotalWorkNum.add(wokDeviceNum);
|
|
|
+ cumulativeWorkDevicePair.put(projectDeptId, tempWorkDeviceNum);
|
|
|
+ } else {
|
|
|
+ cumulativeWorkDevicePair.put(projectDeptId, wokDeviceNum);
|
|
|
+ }
|
|
|
+ // 累计主设备数量
|
|
|
+ if (cumulativeMainDevicePair.containsKey(projectDeptId)) {
|
|
|
+ BigDecimal existMainDeviceNum = cumulativeMainDevicePair.get(projectDeptId);
|
|
|
+ BigDecimal tempMainDeviceNum = existMainDeviceNum.add(mainDeviceNum);
|
|
|
+ cumulativeMainDevicePair.put(projectDeptId, tempMainDeviceNum);
|
|
|
+ } else {
|
|
|
+ cumulativeMainDevicePair.put(projectDeptId, mainDeviceNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成返回的数据列表集合
|
|
|
+ projectDeptPair.forEach((deptId, dept) -> {
|
|
|
+ IotFiveDailyReportStatisticsRespVO statistics = new IotFiveDailyReportStatisticsRespVO();
|
|
|
+ statistics.setProjectDeptId(deptId);
|
|
|
+ statistics.setProjectDeptName(dept.getName());
|
|
|
+ statistics.setSort(dept.getSort());
|
|
|
+ statistics.setType("2");
|
|
|
+ // 计算项目部下设备利用率
|
|
|
+ if (CollUtil.isNotEmpty(cumulativeWorkDevicePair) && CollUtil.isNotEmpty(cumulativeMainDevicePair)) {
|
|
|
+ BigDecimal workDeviceNum = cumulativeWorkDevicePair.get(deptId);
|
|
|
+ BigDecimal mainDeviceNum = cumulativeMainDevicePair.get(deptId);
|
|
|
+ if (ObjUtil.isNotEmpty(mainDeviceNum) && mainDeviceNum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ BigDecimal utilizationRate = workDeviceNum.divide(mainDeviceNum, 4, RoundingMode.HALF_UP);
|
|
|
+ statistics.setUtilizationRate(utilizationRate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ statistics.setCumulativeWorkingLayers(cumulativeWorkingLayersPair.get(deptId));
|
|
|
+ statistics.setCumulativeMixSand(cumulativeMixSandPair.get(deptId));
|
|
|
+ statistics.setCumulativeLiquidVolume(cumulativeLiquidPair.get(deptId));
|
|
|
+ BigDecimal cumulativeFuel = cumulativeFuelsPair.get(deptId);
|
|
|
+ if (ObjUtil.isNotEmpty(cumulativeFuel)) {
|
|
|
+ // 油耗单位转换成 万升
|
|
|
+ BigDecimal FuelWan = cumulativeFuel
|
|
|
+ .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
|
|
|
+ statistics.setTotalDailyFuel(FuelWan);
|
|
|
+ }
|
|
|
+
|
|
|
+ statistics.setCumulativeBridgePlug(cumulativeBridgePlugPair.get(deptId));
|
|
|
+
|
|
|
+ result.add(statistics);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按 队伍 维度统计 汇总 数据
|
|
|
+ * @param dailyReports 日报数据列表
|
|
|
+ * @param pageReqVO (deptId)项目部ID 或 队伍id
|
|
|
+ * @return 队伍 维度统计结果列表
|
|
|
+ */
|
|
|
+ private List<IotFiveDailyReportStatisticsRespVO> statisticsByProjectDepartment(List<IotFiveDailyReportDO> dailyReports, IotFiveDailyReportPageReqVO pageReqVO) {
|
|
|
+ List<IotFiveDailyReportStatisticsRespVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ Set<Long> teamDeptIds = new HashSet<>();
|
|
|
+ // key项目部id value项目部名称
|
|
|
+ Map<Long, DeptDO> projectDeptPair = new HashMap<>();
|
|
|
+ // key队伍id value队伍名称
|
|
|
+ Map<Long, DeptDO> teamDeptPair = new HashMap<>();
|
|
|
+ // key部门id value部门parentId
|
|
|
+ Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
+
|
|
|
+ // key队伍id/项目部id value累计 作业泵车数量
|
|
|
+ Map<Long, BigDecimal> cumulativeWorkDevicePair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 趟数
|
|
|
+ Map<Long, BigDecimal> cumulativeLiquidPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 油耗
|
|
|
+ Map<Long, BigDecimal> cumulativeFuelsPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 段数 累计施工-层
|
|
|
+ Map<Long, BigDecimal> cumulativeWorkingLayersPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 台次 当日仪表/混砂
|
|
|
+ Map<Long, BigDecimal> cumulativeMixSandPair = new HashMap<>();
|
|
|
+ // key队伍id/项目部id value累计 主设备泵车数量
|
|
|
+ Map<Long, BigDecimal> cumulativeMainDevicePair = new HashMap<>();
|
|
|
+
|
|
|
+ // 以 队伍 为维度统计数据
|
|
|
+ // 找到所有项目部与队伍的对应关系
|
|
|
+ // 查询指定根部门下的所有子部门
|
|
|
+ Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ DeptListReqVO reqVO = new DeptListReqVO();
|
|
|
+ // 查询某支队伍 或 所属项目部的信息
|
|
|
+ allRhChildDeptIds.add(pageReqVO.getDeptId());
|
|
|
+ reqVO.setDeptIds(allRhChildDeptIds);
|
|
|
+ List<DeptDO> depts = deptService.getDeptList(reqVO);
|
|
|
+
|
|
|
+ // 构建项目部映射和父子部门关系
|
|
|
+ depts.forEach(dept -> {
|
|
|
+ if ("3".equals(dept.getType())) {
|
|
|
+ // 队伍
|
|
|
+ teamDeptIds.add(dept.getId());
|
|
|
+ teamDeptPair.put(dept.getId(), dept);
|
|
|
+ }
|
|
|
+ if ("2".equals(dept.getType())) {
|
|
|
+ // 项目部
|
|
|
+ projectDeptPair.put(dept.getId(), dept);
|
|
|
+ }
|
|
|
+ teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
+ });
|
|
|
+
|
|
|
+ LocalDateTime[] createTime = pageReqVO.getCreateTime();
|
|
|
+ List<Long> daysCounts = new ArrayList<>();
|
|
|
+ // 如果 createTime 包含的时间是 1天则查询 这1天时间内的 队伍总数 施工队伍数量 施工准备队伍数量 驻地待命队伍数量
|
|
|
+ if (ObjUtil.isNotEmpty(createTime)) {
|
|
|
+ LocalDateTime startTime = createTime[0];
|
|
|
+ LocalDateTime endTime = createTime[1];
|
|
|
+ if (ObjUtil.isNotEmpty(startTime) && ObjUtil.isNotEmpty(endTime) && !endTime.isBefore(startTime)) {
|
|
|
+ // 查询时间区间包含的天数
|
|
|
+ // 使用ChronoUnit.DAYS.between计算天数差,并+1包含首尾两天
|
|
|
+ long daysCount = ChronoUnit.DAYS.between(
|
|
|
+ startTime.toLocalDate(),
|
|
|
+ endTime.toLocalDate()
|
|
|
+ ) + 1;
|
|
|
+ daysCounts.add(daysCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 累计计算 工作量
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ // 油耗
|
|
|
+ BigDecimal dailyFuel = report.getDailyFuel();
|
|
|
+ // 当日主压层数(层)
|
|
|
+ BigDecimal dailyLayers = report.getDailyWorkingLayers();
|
|
|
+ // 当日加砂
|
|
|
+ BigDecimal dailySand = report.getDailySandVolume();
|
|
|
+ // 当日注液
|
|
|
+ BigDecimal dailyLiquid = report.getDailyLiquidVolume();
|
|
|
+ // 设备利用率 作业泵车数量/主设备泵车数量
|
|
|
+ BigDecimal wokDeviceNum = report.getWokDeviceNum();
|
|
|
+ BigDecimal mainDeviceNum = report.getMainDeviceNum();
|
|
|
+
|
|
|
+ if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
|
+ // projectDeptId 可能是项目部 也可能是项目的上级
|
|
|
+ Long detailDeptId = 0l;
|
|
|
+ detailDeptId = report.getDeptId();
|
|
|
+ if (ObjUtil.isNotEmpty(detailDeptId) && (detailDeptId > 0)) {
|
|
|
+ // 累计油耗
|
|
|
+ if (cumulativeFuelsPair.containsKey(detailDeptId)) {
|
|
|
+ BigDecimal existTotalFuel = cumulativeFuelsPair.get(detailDeptId);
|
|
|
+ BigDecimal tempTotalFuel = existTotalFuel.add(dailyFuel);
|
|
|
+ cumulativeFuelsPair.put(detailDeptId, tempTotalFuel);
|
|
|
+ } else {
|
|
|
+ cumulativeFuelsPair.put(detailDeptId, dailyFuel);
|
|
|
+ }
|
|
|
+ // 累计主压层数(层)
|
|
|
+ if (cumulativeWorkingLayersPair.containsKey(detailDeptId)) {
|
|
|
+ BigDecimal existTotalLayers = cumulativeWorkingLayersPair.get(detailDeptId);
|
|
|
+ BigDecimal tempTotalLayers = existTotalLayers.add(dailyFuel);
|
|
|
+ cumulativeWorkingLayersPair.put(detailDeptId, tempTotalLayers);
|
|
|
+ } else {
|
|
|
+ cumulativeWorkingLayersPair.put(detailDeptId, dailyLayers);
|
|
|
+ }
|
|
|
+ // 累计加砂
|
|
|
+ if (cumulativeMixSandPair.containsKey(detailDeptId)) {
|
|
|
+ BigDecimal existTotalSand = cumulativeMixSandPair.get(detailDeptId);
|
|
|
+ BigDecimal tempTotalSand = existTotalSand.add(dailyFuel);
|
|
|
+ cumulativeMixSandPair.put(detailDeptId, tempTotalSand);
|
|
|
+ } else {
|
|
|
+ cumulativeMixSandPair.put(detailDeptId, dailySand);
|
|
|
+ }
|
|
|
+ // 累计注液
|
|
|
+ if (cumulativeLiquidPair.containsKey(detailDeptId)) {
|
|
|
+ BigDecimal existTotalLiquid = cumulativeLiquidPair.get(detailDeptId);
|
|
|
+ BigDecimal tempTotalLiquid = existTotalLiquid.add(dailyFuel);
|
|
|
+ cumulativeLiquidPair.put(detailDeptId, tempTotalLiquid);
|
|
|
+ } else {
|
|
|
+ cumulativeLiquidPair.put(detailDeptId, dailyLiquid);
|
|
|
+ }
|
|
|
+ // 累计作业泵车数量
|
|
|
+ if (cumulativeWorkDevicePair.containsKey(detailDeptId)) {
|
|
|
+ BigDecimal existTotalWorkNum = cumulativeWorkDevicePair.get(detailDeptId);
|
|
|
+ BigDecimal tempWorkDeviceNum = existTotalWorkNum.add(wokDeviceNum);
|
|
|
+ cumulativeWorkDevicePair.put(detailDeptId, tempWorkDeviceNum);
|
|
|
+ } else {
|
|
|
+ cumulativeWorkDevicePair.put(detailDeptId, wokDeviceNum);
|
|
|
+ }
|
|
|
+ // 累计主设备数量
|
|
|
+ if (cumulativeMainDevicePair.containsKey(detailDeptId)) {
|
|
|
+ BigDecimal existMainDeviceNum = cumulativeMainDevicePair.get(detailDeptId);
|
|
|
+ BigDecimal tempMainDeviceNum = existMainDeviceNum.add(mainDeviceNum);
|
|
|
+ cumulativeMainDevicePair.put(detailDeptId, tempMainDeviceNum);
|
|
|
+ } else {
|
|
|
+ cumulativeMainDevicePair.put(detailDeptId, mainDeviceNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 计算每个队伍的设备利用率 (作业泵车数量) / (主设备泵车数量)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 队伍数据 生成返回的数据列表集合
|
|
|
+ teamDeptPair.forEach((teamDeptId, dept) -> {
|
|
|
+ IotFiveDailyReportStatisticsRespVO statistics = new IotFiveDailyReportStatisticsRespVO();
|
|
|
+ statistics.setTeamId(teamDeptId);
|
|
|
+ statistics.setTeamName(dept.getName());
|
|
|
+ statistics.setSort(dept.getSort());
|
|
|
+ if (teamDeptPair.containsKey(teamDeptId)) {
|
|
|
+ statistics.setType("3");
|
|
|
+ }
|
|
|
+ // 计算队伍设备利用率
|
|
|
+ if (CollUtil.isNotEmpty(cumulativeWorkDevicePair) && CollUtil.isNotEmpty(cumulativeMainDevicePair)) {
|
|
|
+ BigDecimal workDeviceNum = cumulativeWorkDevicePair.get(teamDeptId);
|
|
|
+ BigDecimal mainDeviceNum = cumulativeMainDevicePair.get(teamDeptId);
|
|
|
+ if (ObjUtil.isNotEmpty(mainDeviceNum) && mainDeviceNum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ BigDecimal utilizationRate = workDeviceNum.divide(mainDeviceNum, 4, RoundingMode.HALF_UP);
|
|
|
+ statistics.setUtilizationRate(utilizationRate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ statistics.setCumulativeWorkingLayers(cumulativeWorkingLayersPair.get(teamDeptId));
|
|
|
+ statistics.setCumulativeMixSand(cumulativeMixSandPair.get(teamDeptId));
|
|
|
+ statistics.setCumulativeLiquidVolume(cumulativeLiquidPair.get(teamDeptId));
|
|
|
+ BigDecimal cumulativeFuel = cumulativeFuelsPair.get(teamDeptId);
|
|
|
+ if (ObjUtil.isNotEmpty(cumulativeFuel)) {
|
|
|
+ // 油耗单位转换成 万升
|
|
|
+ BigDecimal FuelWan = cumulativeFuel
|
|
|
+ .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
|
|
|
+ statistics.setTotalDailyFuel(FuelWan);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.add(statistics);
|
|
|
+ });
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|