|
|
@@ -14,7 +14,9 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProject
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotProductClassifyListReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotProductClassifyDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotattachment.IotAttachmentDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotdailyreportfuel.IotDailyReportFuelDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoDO;
|
|
|
@@ -22,6 +24,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskD
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttaskattrs.IotTaskAttrModelProperty;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotrddailyreport.IotRdDailyReportDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.IotProductClassifyMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotattachment.IotAttachmentMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotdailyreportfuel.IotDailyReportFuelMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotprojectinfo.IotProjectInfoMapper;
|
|
|
@@ -108,6 +111,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
private IotDeviceMapper iotDeviceMapper;
|
|
|
@Resource
|
|
|
private IotDailyReportFuelMapper iotDailyReportFuelMapper;
|
|
|
+ @Resource
|
|
|
+ private IotProductClassifyMapper iotProductClassifyMapper;
|
|
|
|
|
|
@Override
|
|
|
public Long createIotRdDailyReport(IotRdDailyReportSaveReqVO createReqVO) {
|
|
|
@@ -956,10 +961,52 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// key工作量标识 value累计 台次 当日泵车台次
|
|
|
Map<String, BigDecimal> cumulativePumpTripsPair = new HashMap<>();
|
|
|
|
|
|
+ // 查询 瑞都 施工状态 字典数据 筛选出施工设备为 LY 的记录
|
|
|
+ Set<String> lyStatuses = new HashSet<>();
|
|
|
+ List<DictDataDO> rdStatuses = dictDataService.getDictDataListByDictType("rdStatus");
|
|
|
+ if (CollUtil.isNotEmpty(rdStatuses)) {
|
|
|
+ rdStatuses.forEach(tech -> {
|
|
|
+ if ("LY".equals(tech.getRemark())) {
|
|
|
+ lyStatuses.add(tech.getValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询瑞都所有 A B 类设备 计算总的设备利用率
|
|
|
+ Set<Long> abDeviceCategoryIds = new HashSet<>();
|
|
|
+ // 查询所有瑞都产品类别包含 A B 类
|
|
|
+ IotProductClassifyListReqVO deviceCategoryReqVO = new IotProductClassifyListReqVO();
|
|
|
+ List<IotProductClassifyDO> allDeviceCategories = iotProductClassifyMapper.selectList(deviceCategoryReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(allDeviceCategories)) {
|
|
|
+ allDeviceCategories.forEach(category -> {
|
|
|
+ if ("A".equals(category.getRemark()) || "B".equals(category.getRemark())) {
|
|
|
+ abDeviceCategoryIds.add(category.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 查询瑞都所有查询到的设备
|
|
|
+ Set<Long> abDeviceIds = new HashSet<>();
|
|
|
+ IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
|
+ deviceReqVO.setDeptIds(new ArrayList<>(ids));
|
|
|
+ List<IotDeviceDO> rdDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(rdDevices)) {
|
|
|
+ rdDevices.forEach(device -> {
|
|
|
+ if (abDeviceCategoryIds.contains(device.getAssetClass())) {
|
|
|
+ abDeviceIds.add(device.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 日报涉及到的施工设备id集合
|
|
|
+ Set<Long> reportDeviceIds = new HashSet<>();
|
|
|
+
|
|
|
List<IotRdDailyReportDO> dailyReports = iotRdDailyReportMapper.dailyReports(pageReqVO);
|
|
|
// 累加所有日报的 工作量 数据 油耗 桥塞 趟数 井数...
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
dailyReports.forEach(report -> {
|
|
|
+ // 筛选出日报中施工的 设备id集合
|
|
|
+ if (CollUtil.isNotEmpty(report.getDeviceIds())) {
|
|
|
+ reportDeviceIds.addAll(report.getDeviceIds());
|
|
|
+ }
|
|
|
BigDecimal dailyFuel = report.getDailyFuel();
|
|
|
dailyFuel = ObjUtil.isEmpty(dailyFuel) ? BigDecimal.ZERO : dailyFuel;
|
|
|
if (cumulativeFuelsPair.containsKey("cumulativeFuels")) {
|
|
|
@@ -1083,6 +1130,23 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ // 指定时间范围内 日报中所有施工的设备数量/总设备数量 (A B类)
|
|
|
+ // abDeviceIds所有AB类设备 reportDeviceIds日报中用到的所有设备 交集求出日报中使用到的AB类设备
|
|
|
+ if (CollUtil.isNotEmpty(abDeviceIds) && CollUtil.isNotEmpty(reportDeviceIds)) {
|
|
|
+ // 1. 求交集:实际使用的A B类设备
|
|
|
+ Set<Long> utilizedDeviceIds = reportDeviceIds.stream()
|
|
|
+ .filter(abDeviceIds::contains)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ // 2. 计算设备利用率(实际使用设备数 / 总设备数)
|
|
|
+ BigDecimal deviceUtilization = BigDecimal.ZERO;
|
|
|
+ // 转换为BigDecimal进行计算,保留4位小数
|
|
|
+ deviceUtilization = BigDecimal.valueOf(utilizedDeviceIds.size())
|
|
|
+ .divide(BigDecimal.valueOf(abDeviceIds.size()), 4, RoundingMode.HALF_UP);
|
|
|
+ IotRdDailyReportStatisticsRespVO utilizationResp = new IotRdDailyReportStatisticsRespVO();
|
|
|
+ utilizationResp.setUtilizationRate(deviceUtilization);
|
|
|
+ utilizationResp.setDeptName("utilizationRate");
|
|
|
+ result.add(utilizationResp);
|
|
|
+ }
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(cumulativeBridgePlugPair)) {
|
|
|
Collection<BigDecimal> cumulativeBridgePlugs = cumulativeBridgePlugPair.values();
|
|
|
@@ -1186,6 +1250,9 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// key队伍id value队伍部门
|
|
|
Map<Long, DeptDO> teamDeptPair = new HashMap<>();
|
|
|
|
|
|
+ // key队伍id/项目部id value设备利用率
|
|
|
+ Map<Long, BigDecimal> utilizationRatePair = new HashMap<>();
|
|
|
+
|
|
|
// key队伍id/项目部id value累计 桥塞(个数)
|
|
|
Map<Long, BigDecimal> cumulativeBridgePlugPair = new HashMap<>();
|
|
|
// key队伍id/项目部id value累计 趟数
|
|
|
@@ -1245,10 +1312,94 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
ylTeamIds.add(dept.getId());
|
|
|
}
|
|
|
});
|
|
|
+ // key项目部id value 日报中A+B类设备id集合
|
|
|
+ Map<Long, Set<Long>> projectReportABDeviceIdPair = new HashMap<>();
|
|
|
+ // key项目部id value A+B类设备id集合
|
|
|
+ Map<Long, Set<Long>> projectABDeviceIdPair = new HashMap<>();
|
|
|
+
|
|
|
+ // 以项目部为维度统计 设备利用率 日报中用到AB类设备/
|
|
|
+ // 瑞都 A B 类设备id 集合
|
|
|
+ Set<Long> abDeviceCategoryIds = new HashSet<>();
|
|
|
+ // 查询所有瑞都产品类别包含 A B 类
|
|
|
+ IotProductClassifyListReqVO deviceCategoryReqVO = new IotProductClassifyListReqVO();
|
|
|
+ List<IotProductClassifyDO> allDeviceCategories = iotProductClassifyMapper.selectList(deviceCategoryReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(allDeviceCategories)) {
|
|
|
+ allDeviceCategories.forEach(category -> {
|
|
|
+ if ("A".equals(category.getRemark()) || "B".equals(category.getRemark())) {
|
|
|
+ abDeviceCategoryIds.add(category.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 查询 瑞都 施工状态 字典数据 筛选出施工设备为 LY 的记录
|
|
|
+ Set<String> lyStatuses = new HashSet<>();
|
|
|
+ List<DictDataDO> rdStatuses = dictDataService.getDictDataListByDictType("rdStatus");
|
|
|
+ if (CollUtil.isNotEmpty(rdStatuses)) {
|
|
|
+ rdStatuses.forEach(tech -> {
|
|
|
+ if ("LY".equals(tech.getRemark())) {
|
|
|
+ lyStatuses.add(tech.getValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询瑞都所有设备
|
|
|
+ IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
|
+ deviceReqVO.setDeptIds(new ArrayList<>(allRhChildDeptIds));
|
|
|
+ List<IotDeviceDO> rdDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
+ // 筛选每个项目部 A B 类设备id集合
|
|
|
+ if (CollUtil.isNotEmpty(rdDevices)) {
|
|
|
+ rdDevices.forEach(device -> {
|
|
|
+ Long projectId = 0l;
|
|
|
+ if (teamProjectIdPair.containsKey(device.getDeptId())) {
|
|
|
+ projectId = teamProjectIdPair.get(device.getDeptId());
|
|
|
+ }
|
|
|
+ if (projectDeptIds.contains(device.getDeptId())) {
|
|
|
+ projectId = device.getDeptId();
|
|
|
+ }
|
|
|
+ if (abDeviceCategoryIds.contains(device.getAssetClass())) {
|
|
|
+ if (projectABDeviceIdPair.containsKey(projectId)) {
|
|
|
+ Set<Long> tempDeviceIds = projectABDeviceIdPair.get(projectId);
|
|
|
+ tempDeviceIds.add(device.getId());
|
|
|
+ projectABDeviceIdPair.put(projectId, tempDeviceIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempDeviceIds = new HashSet<>();
|
|
|
+ tempDeviceIds.add(device.getId());
|
|
|
+ projectABDeviceIdPair.put(projectId, tempDeviceIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// 累计计算各项 工作量
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
dailyReports.forEach(report -> {
|
|
|
+ // 统计日报包含施工AB类设备的利用率
|
|
|
+ if (lyStatuses.contains(report.getRdStatus())) {
|
|
|
+ Set<Long> reportDeviceIds = report.getDeviceIds();
|
|
|
+ // 获得当前日报施工队伍的上级项目部
|
|
|
+ if (teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
|
+ Long projectId = teamProjectIdPair.get(report.getDeptId());
|
|
|
+ if (projectABDeviceIdPair.containsKey(projectId)) {
|
|
|
+ // 项目部下所有的AB类设备id集合
|
|
|
+ Set<Long> tempReportDeviceIds = projectABDeviceIdPair.get(projectId);
|
|
|
+ Set<Long> crossDeviceIds = CollUtil.isNotEmpty(reportDeviceIds)
|
|
|
+ && CollUtil.isNotEmpty(tempReportDeviceIds)
|
|
|
+ ? reportDeviceIds.stream() // 流式处理reportDeviceIds
|
|
|
+ .filter(tempReportDeviceIds::contains) // 筛选出在tempReportDeviceIds中存在的元素
|
|
|
+ .collect(Collectors.toSet()) // 收集为新的Set集合
|
|
|
+ : Collections.emptySet(); // 任意集合为空则返回空Set(避免返回null)
|
|
|
+ if (projectReportABDeviceIdPair.containsKey(projectId)) {
|
|
|
+ Set<Long> tempDeviceIds = projectReportABDeviceIdPair.get(projectId);
|
|
|
+ tempDeviceIds.addAll(crossDeviceIds);
|
|
|
+ projectReportABDeviceIdPair.put(projectId, tempDeviceIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempDeviceIds = new HashSet<>();
|
|
|
+ tempDeviceIds.addAll(crossDeviceIds);
|
|
|
+ projectReportABDeviceIdPair.put(projectId, tempDeviceIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
BigDecimal dailyFuel = report.getDailyFuel();
|
|
|
dailyFuel = ObjUtil.isEmpty(dailyFuel) ? BigDecimal.ZERO : dailyFuel;
|
|
|
|
|
|
@@ -1412,6 +1563,29 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ // 计算每个项目部的设备利用率 施工的设备数量/设备总数量
|
|
|
+ if (CollUtil.isNotEmpty(projectABDeviceIdPair)) {
|
|
|
+ projectABDeviceIdPair.forEach((projectDeptId, deviceIds) -> {
|
|
|
+ // 项目部下所有AB类设备
|
|
|
+ Integer projectDeviceCount = deviceIds.size();
|
|
|
+ // 项目部日报中施工的AB类设备
|
|
|
+ Integer reportDeviceCount = 0;
|
|
|
+ if (projectReportABDeviceIdPair.containsKey(projectDeptId)) {
|
|
|
+ Set<Long> reportDeviceIds = projectReportABDeviceIdPair.get(projectDeptId);
|
|
|
+ reportDeviceCount = reportDeviceIds.size();
|
|
|
+ }
|
|
|
+ double rate = 0.0;
|
|
|
+ // 计算设备利用率(处理除数为0的情况)
|
|
|
+ if (projectDeviceCount > 0 && reportDeviceCount > 0) {
|
|
|
+ rate = new BigDecimal((double) reportDeviceCount / (projectDeviceCount))
|
|
|
+ .setScale(4, RoundingMode.HALF_UP) // 保留4位小数,四舍五入
|
|
|
+ .doubleValue();;
|
|
|
+ } else {
|
|
|
+ rate = 0;
|
|
|
+ }
|
|
|
+ utilizationRatePair.put(projectDeptId, BigDecimal.valueOf(rate));
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 生成返回的数据列表集合
|
|
|
@@ -1421,6 +1595,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
statistics.setProjectDeptName(dept.getName());
|
|
|
statistics.setSort(dept.getSort());
|
|
|
statistics.setType("2");
|
|
|
+ statistics.setUtilizationRate(utilizationRatePair.get(deptId));
|
|
|
statistics.setCumulativeBridgePlug(cumulativeBridgePlugPair.get(deptId));
|
|
|
statistics.setCumulativeRunCount(cumulativeRunCountPair.get(deptId));
|
|
|
statistics.setCumulativeWorkingWell(cumulativeWorkingWellPair.get(deptId));
|
|
|
@@ -1457,7 +1632,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
private List<IotRdDailyReportStatisticsRespVO> statisticsByProjectDepartment(List<IotRdDailyReportDO> dailyReports, Long deptId) {
|
|
|
List<IotRdDailyReportStatisticsRespVO> result = new ArrayList<>();
|
|
|
|
|
|
- Set<Long> projectDeptIds = new HashSet<>();
|
|
|
+ Set<Long> teamDeptIds = new HashSet<>();
|
|
|
// key项目部id value项目部名称
|
|
|
Map<Long, DeptDO> projectDeptPair = new HashMap<>();
|
|
|
// key队伍id value队伍名称
|
|
|
@@ -1465,6 +1640,9 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// key部门id value部门parentId
|
|
|
Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
|
|
|
+ // key队伍id/项目部id value设备利用率
|
|
|
+ Map<Long, BigDecimal> utilizationRatePair = new HashMap<>();
|
|
|
+
|
|
|
// key队伍id/项目部id value累计 桥塞(个数)
|
|
|
Map<Long, BigDecimal> cumulativeBridgePlugPair = new HashMap<>();
|
|
|
// key队伍id/项目部id value累计 趟数
|
|
|
@@ -1498,7 +1676,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
depts.forEach(dept -> {
|
|
|
if ("3".equals(dept.getType())) {
|
|
|
// 队伍
|
|
|
- projectDeptIds.add(dept.getId());
|
|
|
+ teamDeptIds.add(dept.getId());
|
|
|
teamDeptPair.put(dept.getId(), dept);
|
|
|
}
|
|
|
if ("2".equals(dept.getType())) {
|
|
|
@@ -1508,11 +1686,91 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
});
|
|
|
|
|
|
- // 因为有的日报是挂在项目部下 所以 点击某个项目部最好是同时展示 项目部和队伍的数据
|
|
|
+ // 统计各队伍的设备利用率
|
|
|
+ // 查询 瑞都 施工状态 字典数据 筛选出施工设备为 LY 的记录
|
|
|
+ Set<String> lyStatuses = new HashSet<>();
|
|
|
+ List<DictDataDO> rdStatuses = dictDataService.getDictDataListByDictType("rdStatus");
|
|
|
+ if (CollUtil.isNotEmpty(rdStatuses)) {
|
|
|
+ rdStatuses.forEach(tech -> {
|
|
|
+ if ("LY".equals(tech.getRemark())) {
|
|
|
+ lyStatuses.add(tech.getValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 查询瑞都所有 A B 类设备 计算总的设备利用率
|
|
|
+ Set<Long> abDeviceCategoryIds = new HashSet<>();
|
|
|
+ // 查询所有瑞都产品类别包含 A B 类
|
|
|
+ IotProductClassifyListReqVO deviceCategoryReqVO = new IotProductClassifyListReqVO();
|
|
|
+ List<IotProductClassifyDO> allDeviceCategories = iotProductClassifyMapper.selectList(deviceCategoryReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(allDeviceCategories)) {
|
|
|
+ allDeviceCategories.forEach(category -> {
|
|
|
+ if ("A".equals(category.getRemark()) || "B".equals(category.getRemark())) {
|
|
|
+ abDeviceCategoryIds.add(category.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // key队伍id value 日报中A+B类设备id集合
|
|
|
+ Map<Long, Set<Long>> teamReportABDeviceIdPair = new HashMap<>();
|
|
|
+ // key队伍id value A+B类设备id集合
|
|
|
+ Map<Long, Set<Long>> teamABDeviceIdPair = new HashMap<>();
|
|
|
+
|
|
|
+ // 查询瑞都所有设备
|
|
|
+ IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
|
+ deviceReqVO.setDeptIds(new ArrayList<>(allRhChildDeptIds));
|
|
|
+ List<IotDeviceDO> rdDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
+ // 筛选每个项目部 A B 类设备id集合
|
|
|
+ if (CollUtil.isNotEmpty(rdDevices)) {
|
|
|
+ rdDevices.forEach(device -> {
|
|
|
+ Long teamId = 0l;
|
|
|
+ if (teamDeptIds.contains(device.getDeptId())) {
|
|
|
+ teamId = device.getDeptId();
|
|
|
+ }
|
|
|
+ if (abDeviceCategoryIds.contains(device.getAssetClass())) {
|
|
|
+ if (teamABDeviceIdPair.containsKey(teamId)) {
|
|
|
+ Set<Long> tempDeviceIds = teamABDeviceIdPair.get(teamId);
|
|
|
+ tempDeviceIds.add(device.getId());
|
|
|
+ teamABDeviceIdPair.put(teamId, tempDeviceIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempDeviceIds = new HashSet<>();
|
|
|
+ tempDeviceIds.add(device.getId());
|
|
|
+ teamABDeviceIdPair.put(teamId, tempDeviceIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// 累计计算 工作量
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
dailyReports.forEach(report -> {
|
|
|
+ // 统计日报关联施工AB类设备的利用率
|
|
|
+ // 统计日报包含施工AB类设备的利用率
|
|
|
+ if (lyStatuses.contains(report.getRdStatus())) {
|
|
|
+ Set<Long> reportDeviceIds = report.getDeviceIds();
|
|
|
+ // 获得当前日报施工队伍的上级项目部
|
|
|
+ if (teamDeptIds.contains(report.getDeptId())) {
|
|
|
+ if (teamABDeviceIdPair.containsKey(report.getDeptId())) {
|
|
|
+ // 下所有的AB类设备id集合
|
|
|
+ Set<Long> tempReportDeviceIds = teamABDeviceIdPair.get(report.getDeptId());
|
|
|
+ Set<Long> crossDeviceIds = CollUtil.isNotEmpty(reportDeviceIds)
|
|
|
+ && CollUtil.isNotEmpty(tempReportDeviceIds)
|
|
|
+ ? reportDeviceIds.stream() // 流式处理reportDeviceIds
|
|
|
+ .filter(tempReportDeviceIds::contains) // 筛选出在tempReportDeviceIds中存在的元素
|
|
|
+ .collect(Collectors.toSet()) // 收集为新的Set集合
|
|
|
+ : Collections.emptySet(); // 任意集合为空则返回空Set(避免返回null)
|
|
|
+ if (teamReportABDeviceIdPair.containsKey(report.getDeptId())) {
|
|
|
+ Set<Long> tempDeviceIds = teamReportABDeviceIdPair.get(report.getDeptId());
|
|
|
+ tempDeviceIds.addAll(crossDeviceIds);
|
|
|
+ teamReportABDeviceIdPair.put(report.getDeptId(), tempDeviceIds);
|
|
|
+ } else {
|
|
|
+ Set<Long> tempDeviceIds = new HashSet<>();
|
|
|
+ tempDeviceIds.addAll(crossDeviceIds);
|
|
|
+ teamReportABDeviceIdPair.put(report.getDeptId(), tempDeviceIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
BigDecimal dailyFuel = report.getDailyFuel();
|
|
|
dailyFuel = ObjUtil.isEmpty(dailyFuel) ? BigDecimal.ZERO : dailyFuel;
|
|
|
if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
|
@@ -1652,29 +1910,30 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
-
|
|
|
- // 项目部数据
|
|
|
- /* projectDeptPair.forEach((projectDeptId, dept) -> {
|
|
|
- IotRdDailyReportStatisticsRespVO statistics = new IotRdDailyReportStatisticsRespVO();
|
|
|
- statistics.setTeamId(projectDeptId);
|
|
|
- statistics.setProjectDeptName(dept.getName());
|
|
|
- statistics.setSort(dept.getSort());
|
|
|
- if (projectDeptPair.containsKey(projectDeptId)) {
|
|
|
- statistics.setSort(0);
|
|
|
- statistics.setType("2");
|
|
|
+ // 计算每个队伍的设备利用率 施工的设备数量/设备总数量
|
|
|
+ if (CollUtil.isNotEmpty(teamABDeviceIdPair)) {
|
|
|
+ teamABDeviceIdPair.forEach((teamDeptId, deviceIds) -> {
|
|
|
+ // 队伍下所有AB类设备
|
|
|
+ Integer projectDeviceCount = deviceIds.size();
|
|
|
+ // 队伍日报中施工的AB类设备
|
|
|
+ Integer reportDeviceCount = 0;
|
|
|
+ if (teamReportABDeviceIdPair.containsKey(teamDeptId)) {
|
|
|
+ Set<Long> reportDeviceIds = teamReportABDeviceIdPair.get(teamDeptId);
|
|
|
+ reportDeviceCount = reportDeviceIds.size();
|
|
|
+ }
|
|
|
+ double rate = 0.0;
|
|
|
+ // 计算设备利用率(处理除数为0的情况)
|
|
|
+ if (projectDeviceCount > 0 && reportDeviceCount > 0) {
|
|
|
+ rate = new BigDecimal((double) reportDeviceCount / (projectDeviceCount))
|
|
|
+ .setScale(4, RoundingMode.HALF_UP) // 保留4位小数,四舍五入
|
|
|
+ .doubleValue();;
|
|
|
+ } else {
|
|
|
+ rate = 0;
|
|
|
+ }
|
|
|
+ utilizationRatePair.put(teamDeptId, BigDecimal.valueOf(rate));
|
|
|
+ });
|
|
|
}
|
|
|
- statistics.setCumulativeBridgePlug(cumulativeBridgePlugPair.get(projectDeptId));
|
|
|
- statistics.setCumulativeRunCount(cumulativeRunCountPair.get(projectDeptId));
|
|
|
- statistics.setCumulativeWorkingWell(cumulativeWorkingWellPair.get(projectDeptId));
|
|
|
- statistics.setCumulativeHourCount(cumulativeHourCountPair.get(projectDeptId));
|
|
|
- statistics.setCumulativeWaterVolume(cumulativeWaterVolumePair.get(projectDeptId));
|
|
|
- statistics.setCumulativeWorkingLayers(cumulativeWorkingLayersPair.get(projectDeptId));
|
|
|
- statistics.setCumulativeMixSand(cumulativeMixSandPair.get(projectDeptId));
|
|
|
- statistics.setCumulativePumpTrips(cumulativePumpTripsPair.get(projectDeptId));
|
|
|
- statistics.setTotalDailyFuel(cumulativeFuelsPair.get(projectDeptId));
|
|
|
- result.add(statistics);
|
|
|
- }); */
|
|
|
+ }
|
|
|
|
|
|
// 队伍数据 生成返回的数据列表集合
|
|
|
teamDeptPair.forEach((teamDeptId, dept) -> {
|
|
|
@@ -1685,6 +1944,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
if (teamDeptPair.containsKey(teamDeptId)) {
|
|
|
statistics.setType("3"); // 最好是 项目部小队同时展示 因为有的瑞都日报挂在了项目部下
|
|
|
}
|
|
|
+ statistics.setUtilizationRate(utilizationRatePair.get(teamDeptId));
|
|
|
statistics.setCumulativeBridgePlug(cumulativeBridgePlugPair.get(teamDeptId));
|
|
|
statistics.setCumulativeRunCount(cumulativeRunCountPair.get(teamDeptId));
|
|
|
statistics.setCumulativeWorkingWell(cumulativeWorkingWellPair.get(teamDeptId));
|