|
@@ -19,8 +19,10 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotdevicerunlog.IotDeviceRunLogMapp
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
|
|
import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
@@ -34,10 +36,7 @@ import java.lang.reflect.Type;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
@@ -67,7 +66,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
private IotOpeationFillMapper iotOpeationFillMapper;
|
|
private IotOpeationFillMapper iotOpeationFillMapper;
|
|
@Resource
|
|
@Resource
|
|
private IotDeviceRunLogMapper iotDeviceRunLogMapper;
|
|
private IotDeviceRunLogMapper iotDeviceRunLogMapper;
|
|
-
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private DeptService deptService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -122,46 +122,14 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 找到当前小队下的 电驱增压机 分类下设备的产能 计算 运行时效
|
|
|
|
- DictTypeDO dictType = dictTypeService.getDictType("rq_iot_charger_device_category");
|
|
|
|
- AtomicReference<BigDecimal> capacity = new AtomicReference<>(BigDecimal.ZERO);
|
|
|
|
- if (ObjUtil.isNotEmpty(dictType)) {
|
|
|
|
- if (StrUtil.isNotBlank(dictType.getRemark())) {
|
|
|
|
- IotDevicePageReqVO capacityReqVO = new IotDevicePageReqVO();
|
|
|
|
- capacityReqVO.setDeptId(createReqVO.getDeptId());
|
|
|
|
- capacityReqVO.setAssetClass(Long.valueOf(dictType.getRemark()));
|
|
|
|
- List<IotDeviceDO> capacityDevices = iotDeviceMapper.selectList(capacityReqVO);
|
|
|
|
- if (CollUtil.isNotEmpty(capacityDevices)) {
|
|
|
|
- // 解析每个设备的 扩展属性 找出 已经设置 了产能的设备并提取值
|
|
|
|
- capacityDevices.forEach(device -> {
|
|
|
|
- if (StrUtil.isNotBlank(device.getTemplateJson())) {
|
|
|
|
- Gson gson = new Gson();
|
|
|
|
- Type listType = new TypeToken<List<IotDeviceProperty>>(){}.getType();
|
|
|
|
- List<IotDeviceProperty> deviceProperties = gson.fromJson(device.getTemplateJson(), listType);
|
|
|
|
- if (CollUtil.isNotEmpty(deviceProperties)) {
|
|
|
|
- deviceProperties.forEach(property -> {
|
|
|
|
- if ("产能".equals(property.getName()) && StrUtil.isNotBlank(property.getValue())) {
|
|
|
|
- // 当前扩展属性已经维护了 产能 值
|
|
|
|
- capacity.set(new BigDecimal(property.getValue()));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- // 计算运行时效 当日注气量/产能
|
|
|
|
- if (ObjUtil.isNotEmpty(createReqVO.getDailyGasInjection()) && (capacity.get().compareTo(BigDecimal.ZERO)>0)) {
|
|
|
|
- // 将当日注气量单位 换算成 万方
|
|
|
|
- // 将当日注气量单位由"方"换算成"万方"
|
|
|
|
- /* BigDecimal dailyGasInjectionInTenThousand = createReqVO.getDailyGasInjection()
|
|
|
|
- .divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP); */
|
|
|
|
- iotRhDailyReport.setTransitTime(createReqVO.getDailyGasInjection().divide(capacity.get(), 4, RoundingMode.HALF_UP));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ BigDecimal capacity = queryCapacity(createReqVO.getDeptId());
|
|
|
|
+ // 计算运行时效 当日注气量/产能
|
|
|
|
+ if (ObjUtil.isNotEmpty(createReqVO.getDailyGasInjection()) && (capacity.compareTo(BigDecimal.ZERO)>0)) {
|
|
|
|
+ // 将当日注气量单位 换算成 万方
|
|
|
|
+ // 将当日注气量单位由"方"换算成"万方"
|
|
|
|
+ iotRhDailyReport.setTransitTime(createReqVO.getDailyGasInjection().divide(capacity, 4, RoundingMode.HALF_UP));
|
|
}
|
|
}
|
|
|
|
|
|
- // todo 根据当日注气量 计算累计注气量
|
|
|
|
-
|
|
|
|
// 查询当前日报所属任务关联的设备 更新设备状态
|
|
// 查询当前日报所属任务关联的设备 更新设备状态
|
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
|
// 查询当前任务下关联的所有设备
|
|
// 查询当前任务下关联的所有设备
|
|
@@ -229,6 +197,73 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
return iotRhDailyReport.getId();
|
|
return iotRhDailyReport.getId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /***
|
|
|
|
+ * 计算指定队伍下包含的 增压机设备的产能
|
|
|
|
+ */
|
|
|
|
+ public BigDecimal queryCapacity(Long deptId) {
|
|
|
|
+ // 找到当前小队下的 电驱增压机 分类下设备的产能 计算 运行时效
|
|
|
|
+ DictTypeDO dictType = dictTypeService.getDictType("rq_iot_charger_device_category");
|
|
|
|
+ AtomicReference<BigDecimal> capacity = new AtomicReference<>(BigDecimal.ZERO);
|
|
|
|
+ if (ObjUtil.isNotEmpty(dictType)) {
|
|
|
|
+ if (StrUtil.isNotBlank(dictType.getRemark())) {
|
|
|
|
+ IotDevicePageReqVO capacityReqVO = new IotDevicePageReqVO();
|
|
|
|
+ capacityReqVO.setDeptId(deptId);
|
|
|
|
+ capacityReqVO.setAssetClass(Long.valueOf(dictType.getRemark()));
|
|
|
|
+ List<IotDeviceDO> capacityDevices = iotDeviceMapper.selectList(capacityReqVO);
|
|
|
|
+ if (CollUtil.isNotEmpty(capacityDevices)) {
|
|
|
|
+ // 解析每个设备的 扩展属性 找出 已经设置 了产能的设备并提取值
|
|
|
|
+ capacityDevices.forEach(device -> {
|
|
|
|
+ if (StrUtil.isNotBlank(device.getTemplateJson())) {
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ Type listType = new TypeToken<List<IotDeviceProperty>>(){}.getType();
|
|
|
|
+ List<IotDeviceProperty> deviceProperties = gson.fromJson(device.getTemplateJson(), listType);
|
|
|
|
+ if (CollUtil.isNotEmpty(deviceProperties)) {
|
|
|
|
+ deviceProperties.forEach(property -> {
|
|
|
|
+ if ("产能".equals(property.getName()) && StrUtil.isNotBlank(property.getValue())) {
|
|
|
|
+ // 当前扩展属性已经维护了 产能 值
|
|
|
|
+ capacity.set(new BigDecimal(property.getValue()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return capacity.get();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public PageResult<IotRhDailyReportDO> dailyReportSummary(IotRhDailyReportPageReqVO pageReqVO) {
|
|
|
|
+ // 查询 瑞恒兴域 下所有项目部级别的部门
|
|
|
|
+ // 组装成 map key项目部id value项目部下包含的部门集合
|
|
|
|
+ Set<Long> projectDeptIds = new HashSet<>();
|
|
|
|
+ Map<Long, Set<Long>> projectSubDeptPair = new HashMap<>();
|
|
|
|
+ Map<Long, String> deptMap = new HashMap<>();
|
|
|
|
+ Set<Long> rhChildDeptIds = deptService.getChildDeptIdListFromCache(157l);
|
|
|
|
+ List<DeptDO> depts =deptService.getDeptList(rhChildDeptIds);
|
|
|
|
+ // 找出名称中包含 项目部 的部门
|
|
|
|
+ if (CollUtil.isNotEmpty(depts)) {
|
|
|
|
+ depts.forEach(dept -> {
|
|
|
|
+ if (dept.getName().contains("项目部")) {
|
|
|
|
+ projectDeptIds.add(dept.getId());
|
|
|
|
+ }
|
|
|
|
+ deptMap.put(dept.getId(), dept.getName());
|
|
|
|
+ });
|
|
|
|
+ // 查询每个项目部下所有子部门 小队
|
|
|
|
+ if (CollUtil.isNotEmpty(projectDeptIds)) {
|
|
|
|
+ projectDeptIds.forEach(deptId -> {
|
|
|
|
+ Set<Long> tempDeptIds = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
|
+ tempDeptIds.add(deptId);
|
|
|
|
+ projectSubDeptPair.put(deptId, tempDeptIds);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // 查询所有瑞恒日报数据
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void updateIotRhDailyReport(IotRhDailyReportSaveReqVO updateReqVO) {
|
|
public void updateIotRhDailyReport(IotRhDailyReportSaveReqVO updateReqVO) {
|
|
// 校验存在
|
|
// 校验存在
|