|
|
@@ -15,6 +15,8 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
|
|
import cn.iocoder.yudao.module.pms.constant.PmsConstants;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotcarzhbd.vo.IotCarZhbdPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplateattrs.vo.IotDeviceProperty;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.*;
|
|
|
@@ -22,6 +24,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotcarzhbd.IotCarZhbdDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotdailyreportfuel.IotDailyReportFuelDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
|
|
|
@@ -254,18 +257,84 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
// throw exception(IOT_PROJECT_TASK_NOT_RELATED);
|
|
|
}
|
|
|
|
|
|
- // 查询当前任务下关联的所有设备 查询这些设备的当日注气量 进而计算累计注气量
|
|
|
- IotDevicePageReqVO deptDeviceReqVO = new IotDevicePageReqVO();
|
|
|
- deptDeviceReqVO.setDeptId(createReqVO.getDeptId());
|
|
|
- List<IotDeviceDO> deptDevices = iotDeviceMapper.selectList(deptDeviceReqVO);
|
|
|
- Set<String> deviceCodes = new HashSet<>();
|
|
|
- if (CollUtil.isNotEmpty(deptDevices)) {
|
|
|
+ // 查询当前队伍的运行记录 找到注水量 注水时间 赋值到日报的 注水时间
|
|
|
+ Set<Long> deviceTypeIds = new HashSet<>();
|
|
|
+ List<DictDataDO> deviceTypeDictData = dictDataService.getDictDataListByDictType("rq_iot_rh_water_injection_device_type");
|
|
|
+ if (CollUtil.isNotEmpty(deviceTypeDictData)) {
|
|
|
+ deviceTypeDictData.forEach(data -> {
|
|
|
+ String value = data.getValue();
|
|
|
+ if (NumberUtil.isNumber(value)) {
|
|
|
+ Long longValue = Long.valueOf(value);
|
|
|
+ deviceTypeIds.add(longValue);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 查询 注水泵 类别 下包含的设备
|
|
|
+ if (CollUtil.isNotEmpty(deviceTypeIds)) {
|
|
|
+ // 查询当前任务下关联的 注水泵 设备 查询这些设备在运行记录中填写的 注水时间
|
|
|
+ IotDevicePageReqVO deptDeviceReqVO = new IotDevicePageReqVO();
|
|
|
+ deptDeviceReqVO.setDeptId(createReqVO.getDeptId());
|
|
|
+ deptDeviceReqVO.setAssetClasses(new ArrayList<>(deviceTypeIds));
|
|
|
+ List<IotDeviceDO> deptDevices = iotDeviceMapper.selectList(deptDeviceReqVO);
|
|
|
+ Set<Long> pumpDeviceIds = new HashSet<>();
|
|
|
+ if (CollUtil.isNotEmpty(deptDevices)) {
|
|
|
+ deptDevices.forEach(device -> {
|
|
|
+ pumpDeviceIds.add(device.getId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ DataPermissionUtils.executeIgnore(() -> {
|
|
|
+ BigDecimal maxWaterInjectionTime = BigDecimal.ZERO;
|
|
|
+ // 过滤数据权限 查询 运行记录 日志
|
|
|
+ // 根据 当前日期 deptId pumpDeviceIds 查询运行记录工单关联的 deviceId
|
|
|
+ String reportDateStr = LocalDateTimeUtil.format(reportDate, DatePattern.NORM_DATE_PATTERN);
|
|
|
+ IotOpeationFillPageReqVO fillReqVO = new IotOpeationFillPageReqVO();
|
|
|
+ fillReqVO.setCreateTimeStr(reportDateStr);
|
|
|
+ fillReqVO.setDeptId(deptId);
|
|
|
+ fillReqVO.setDeviceIds(pumpDeviceIds);
|
|
|
+ List<IotOpeationFillDO> fills = iotOpeationFillMapper.selectList(fillReqVO);
|
|
|
+ Set<Long> fillPumpDeviceIds = new HashSet<>();
|
|
|
+ if (CollUtil.isNotEmpty(fills)) {
|
|
|
+ fills.forEach(fill -> {
|
|
|
+ fillPumpDeviceIds.add(fill.getDeviceId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 根据 device_id createTime is_sum=0 在表 rq_iot_device_run_log 中查询 "当日运转时间H" 的值 fill_content
|
|
|
+ // 如果有多个注水泵的 运转时间 取 较大值
|
|
|
+ if (CollUtil.isNotEmpty(fillPumpDeviceIds)) {
|
|
|
+ IotDeviceRunLogPageReqVO runLogReqVO = new IotDeviceRunLogPageReqVO();
|
|
|
+ runLogReqVO.setCreateTimeStr(reportDateStr);
|
|
|
+ runLogReqVO.setDeviceIds(new ArrayList<>(fillPumpDeviceIds));
|
|
|
+ runLogReqVO.setIsSum(0);
|
|
|
+ List<IotDeviceRunLogDO> runLogs = iotDeviceRunLogMapper.selectList(runLogReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(runLogs)) {
|
|
|
+ // 查询 注水泵 当日注水时间 参数名称
|
|
|
+ DictTypeDO pointNameDict = dictTypeService.getDictType("rq_iot_rh_water_point_name");
|
|
|
+ if (ObjUtil.isNotEmpty(pointNameDict) && StrUtil.isNotBlank(pointNameDict.getRemark())) {
|
|
|
+ String pointName = pointNameDict.getRemark();
|
|
|
+ // 当日填报的 注水泵 的运行时间 即 注水时间
|
|
|
+ maxWaterInjectionTime = runLogs.stream()
|
|
|
+ .filter(log -> pointName.equals(log.getPointName()))
|
|
|
+ .map(IotDeviceRunLogDO::getFillContent)
|
|
|
+ .filter(StrUtil::isNotBlank)
|
|
|
+ .filter(NumberUtil::isNumber)
|
|
|
+ .map(BigDecimal::new)
|
|
|
+ .max(BigDecimal::compareTo)
|
|
|
+ .orElse(BigDecimal.ZERO);
|
|
|
+ iotRhDailyReport.setDailyInjectWaterTime(maxWaterInjectionTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /* if (CollUtil.isNotEmpty(deptDevices)) {
|
|
|
deptDevices.forEach(device -> {
|
|
|
deviceCodes.add(device.getDeviceCode());
|
|
|
});
|
|
|
// 查询当前小队在运行记录填报结果表中 生产日报虚拟设备id 查询当年的日报
|
|
|
// 然后根据 虚拟设备id 在 rq_iot_device_run_log 表中查询 日报中填写的 当日注气量
|
|
|
- List<IotOpeationFillDO> reports = iotOpeationFillMapper.selectReportsByYear(createReqVO.getDeptId(), LocalDateTime.now().getYear());
|
|
|
+ List<IotOpeationFillDO> reports = iotOpeationFillMapper.selectReportsByYear(createReqVO.getDeptId(), LocalDateTime.now().getYear());
|
|
|
Set<Long> reportDeviceIds = new HashSet<>();
|
|
|
if (CollUtil.isNotEmpty(reports)) {
|
|
|
reports.forEach(report -> {
|
|
|
@@ -275,7 +344,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
BigDecimal currentYearFillContentSum = iotDeviceRunLogMapper.selectCurrentYearFillContentSum(createReqVO.getDeptId(), reportDeviceIds);
|
|
|
iotRhDailyReport.setTotalGasInjection(currentYearFillContentSum);
|
|
|
}
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
BigDecimal capacity = queryCapacity(createReqVO.getDeptId());
|
|
|
// 计算运行时效 当日注气量/产能
|