|
|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
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;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
|
|
|
@@ -12,6 +13,7 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.pms.constant.PmsConstants;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotattachment.vo.IotAttachmentSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdailyreportfuel.vo.IotDailyReportFuelSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotdeviceassociate.vo.IotDeviceAssociatePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.*;
|
|
|
@@ -22,6 +24,7 @@ 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.iotdeviceassociate.IotDeviceAssociateDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttaskattrs.IotTaskAttrModelProperty;
|
|
|
@@ -31,6 +34,7 @@ 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.iotdeviceassociate.IotDeviceAssociateMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotprojectinfo.IotProjectInfoMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotrddailyreport.IotRdDailyReportMapper;
|
|
|
@@ -122,6 +126,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
private IotProductClassifyMapper iotProductClassifyMapper;
|
|
|
@Resource
|
|
|
private IotRdDailyReportDetailMapper iotRdDailyReportDetailMapper;
|
|
|
+ @Resource
|
|
|
+ private IotDeviceAssociateMapper iotDeviceAssociateMapper;
|
|
|
|
|
|
@Override
|
|
|
public Long createIotRdDailyReport(IotRdDailyReportSaveReqVO createReqVO) {
|
|
|
@@ -1469,6 +1475,25 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// key项目部id value A+B类设备id集合
|
|
|
Map<Long, Set<Long>> projectABDeviceIdPair = new HashMap<>();
|
|
|
|
|
|
+ // 设备利用率逻辑调整 只筛选 压裂 连油 主设备 rq_iot_device_associate
|
|
|
+ // 队伍日报中关联的主设备数量 /(队伍下所有主设备数量-封存设备数量)
|
|
|
+ Set<Long> mainDeviceIds = new HashSet<>();
|
|
|
+ Set<Long> fcMainDeviceIds = new HashSet<>();
|
|
|
+ // key设备id value设备所属部门id
|
|
|
+ Map<Long, Long> mainDeviceIdPair = new HashMap<>();
|
|
|
+ IotDeviceAssociatePageReqVO deviceAssocReqVO = new IotDeviceAssociatePageReqVO();
|
|
|
+ deviceAssocReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ deviceAssocReqVO.setDeptIds(allRhChildDeptIds);
|
|
|
+ PageResult<IotDeviceAssociateDO> pageResult = iotDeviceAssociateMapper.selectPage(deviceAssocReqVO);
|
|
|
+ if (ObjUtil.isNotEmpty(pageResult)) {
|
|
|
+ List<IotDeviceAssociateDO> deviceAssociates = pageResult.getList();
|
|
|
+ // 查询出所有瑞都压裂 连油主设备
|
|
|
+ deviceAssociates.forEach(assoc -> {
|
|
|
+ mainDeviceIds.add(assoc.getDeviceId());
|
|
|
+ mainDeviceIdPair.put(assoc.getDeviceId(), assoc.getDeptId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
// 以项目部为维度统计 设备利用率 日报中用到AB类设备/
|
|
|
// 瑞都 A B 类设备id 集合
|
|
|
Set<Long> abDeviceCategoryIds = new HashSet<>();
|
|
|
@@ -1493,28 +1518,39 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- // 查询瑞都所有设备
|
|
|
+ // 查询瑞都 压裂 连油 主设备详情信息
|
|
|
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());
|
|
|
+ deviceReqVO.setDeviceIds(new ArrayList<>(mainDeviceIds));
|
|
|
+ List<IotDeviceDO> mainDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
+ // 筛选出 封存 的主设备
|
|
|
+ if (CollUtil.isNotEmpty(mainDevices)) {
|
|
|
+ mainDevices.forEach(device -> {
|
|
|
+ if ("fc".equals(device.getDeviceStatus())) {
|
|
|
+ fcMainDeviceIds.add(device.getId());
|
|
|
}
|
|
|
- if (projectDeptIds.contains(device.getDeptId())) {
|
|
|
- projectId = device.getDeptId();
|
|
|
- }
|
|
|
- if (abDeviceCategoryIds.contains(device.getAssetClass())) {
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置各项目部 压裂 连油 主设备集合
|
|
|
+ if (CollUtil.isNotEmpty(mainDeviceIdPair)) {
|
|
|
+ // key主设备id value主设备所属部门id
|
|
|
+ mainDeviceIdPair.forEach((deviceId, deptId) -> {
|
|
|
+ // 过滤掉封存的压裂 连油主设备
|
|
|
+ if (!fcMainDeviceIds.contains(deviceId)) {
|
|
|
+ Long projectId = 0l;
|
|
|
+ if (teamProjectIdPair.containsKey(deptId)) {
|
|
|
+ projectId = teamProjectIdPair.get(deptId);
|
|
|
+ }
|
|
|
+ if (projectDeptIds.contains(deptId)) {
|
|
|
+ projectId = deptId;
|
|
|
+ }
|
|
|
if (projectABDeviceIdPair.containsKey(projectId)) {
|
|
|
Set<Long> tempDeviceIds = projectABDeviceIdPair.get(projectId);
|
|
|
- tempDeviceIds.add(device.getId());
|
|
|
+ tempDeviceIds.add(deviceId);
|
|
|
projectABDeviceIdPair.put(projectId, tempDeviceIds);
|
|
|
} else {
|
|
|
Set<Long> tempDeviceIds = new HashSet<>();
|
|
|
- tempDeviceIds.add(device.getId());
|
|
|
+ tempDeviceIds.add(deviceId);
|
|
|
projectABDeviceIdPair.put(projectId, tempDeviceIds);
|
|
|
}
|
|
|
}
|
|
|
@@ -1525,32 +1561,34 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
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);
|
|
|
- }
|
|
|
+ // 利用率暂时不考虑日报状态
|
|
|
+ // 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中存在的元素
|
|
|
+ .filter(deviceId -> !fcMainDeviceIds.contains(deviceId)) // 过滤掉 封存的主设备
|
|
|
+ .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;
|
|
|
@@ -1716,11 +1754,12 @@ 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);
|
|
|
@@ -1867,25 +1906,55 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// key队伍id value A+B类设备id集合
|
|
|
Map<Long, Set<Long>> teamABDeviceIdPair = new HashMap<>();
|
|
|
|
|
|
- // 查询瑞都所有设备
|
|
|
+ // 设备利用率逻辑调整 只筛选 压裂 连油 主设备 rq_iot_device_associate
|
|
|
+ // 队伍日报中关联的主设备数量 /(队伍下所有主设备数量-封存设备数量)
|
|
|
+ Set<Long> mainDeviceIds = new HashSet<>();
|
|
|
+ Set<Long> fcMainDeviceIds = new HashSet<>();
|
|
|
+ // key设备id value设备所属部门id
|
|
|
+ Map<Long, Long> mainDeviceIdPair = new HashMap<>();
|
|
|
+ IotDeviceAssociatePageReqVO deviceAssocReqVO = new IotDeviceAssociatePageReqVO();
|
|
|
+ deviceAssocReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ deviceAssocReqVO.setDeptIds(allRhChildDeptIds);
|
|
|
+ PageResult<IotDeviceAssociateDO> pageResult = iotDeviceAssociateMapper.selectPage(deviceAssocReqVO);
|
|
|
+ if (ObjUtil.isNotEmpty(pageResult)) {
|
|
|
+ List<IotDeviceAssociateDO> deviceAssociates = pageResult.getList();
|
|
|
+ // 查询出所有瑞都压裂 连油主设备
|
|
|
+ deviceAssociates.forEach(assoc -> {
|
|
|
+ // 过滤掉封存的设备
|
|
|
+ mainDeviceIds.add(assoc.getDeviceId());
|
|
|
+ mainDeviceIdPair.put(assoc.getDeviceId(), assoc.getDeptId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询瑞都 压裂 连油 主设备详情信息
|
|
|
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();
|
|
|
+ deviceReqVO.setDeviceIds(new ArrayList<>(mainDeviceIds));
|
|
|
+ List<IotDeviceDO> mainDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
+ // 筛选出 封存 的主设备
|
|
|
+ if (CollUtil.isNotEmpty(mainDevices)) {
|
|
|
+ mainDevices.forEach(device -> {
|
|
|
+ if ("fc".equals(device.getDeviceStatus())) {
|
|
|
+ fcMainDeviceIds.add(device.getId());
|
|
|
}
|
|
|
- if (abDeviceCategoryIds.contains(device.getAssetClass())) {
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 筛选每个项目部 压裂 连油 主设备id集合
|
|
|
+ if (CollUtil.isNotEmpty(mainDeviceIdPair)) {
|
|
|
+ mainDeviceIdPair.forEach((deviceId, departmentId) -> {
|
|
|
+ // 过滤掉封存的压裂 连油主设备
|
|
|
+ if (!fcMainDeviceIds.contains(deviceId)) {
|
|
|
+ Long teamId = 0l;
|
|
|
+ if (teamDeptIds.contains(departmentId)) {
|
|
|
+ teamId = departmentId;
|
|
|
+ }
|
|
|
if (teamABDeviceIdPair.containsKey(teamId)) {
|
|
|
Set<Long> tempDeviceIds = teamABDeviceIdPair.get(teamId);
|
|
|
- tempDeviceIds.add(device.getId());
|
|
|
+ tempDeviceIds.add(deviceId);
|
|
|
teamABDeviceIdPair.put(teamId, tempDeviceIds);
|
|
|
} else {
|
|
|
Set<Long> tempDeviceIds = new HashSet<>();
|
|
|
- tempDeviceIds.add(device.getId());
|
|
|
+ tempDeviceIds.add(deviceId);
|
|
|
teamABDeviceIdPair.put(teamId, tempDeviceIds);
|
|
|
}
|
|
|
}
|
|
|
@@ -1896,29 +1965,27 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
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);
|
|
|
- }
|
|
|
+ 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中存在的元素
|
|
|
+ .filter(deviceId -> !fcMainDeviceIds.contains(deviceId)) // 过滤掉 封存的主设备
|
|
|
+ .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);
|
|
|
}
|
|
|
}
|
|
|
}
|