Parcourir la source

pms 日报 编辑日报

zhangcl il y a 3 semaines
Parent
commit
46ac4931bf

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/config/PmsDataPermissionConfiguration.java

@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectPlanDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectRouteDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotlockstock.IotLockStockDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorder.IotMainWorkOrderDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstock.IotSapStockDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.maintain.IotMaintainDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.maintenance.IotMaintenancePlanDO;
@@ -51,6 +52,7 @@ public class PmsDataPermissionConfiguration {
             rule.addDeptColumn(IotMainWorkOrderDO.class, "dept_id");
             rule.addDeptColumn(IotMaintenancePlanDO.class, "dept_id");
             rule.addDeptColumn(IotSapStockDO.class, "dept_id");
+            rule.addDeptColumn(IotRhDailyReportDO.class, "dept_id");
             // user
 //            rule.addUserColumn(SupplierDO.class);
             rule.addUserColumn(AdminUserDO.class, "id");

+ 19 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -34,6 +34,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -89,7 +90,11 @@ public class IotRhDailyReportController {
     @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:query')")
     public CommonResult<IotRhDailyReportRespVO> getIotRhDailyReport(@RequestParam("id") Long id) {
         IotRhDailyReportDO iotRhDailyReport = iotRhDailyReportService.getIotRhDailyReport(id);
-        return success(BeanUtils.toBean(iotRhDailyReport, IotRhDailyReportRespVO.class));
+        // 查询当前日报关联的 部门下 增压机 的产能
+        BigDecimal capacity = iotRhDailyReportService.queryCapacity(iotRhDailyReport.getDeptId());
+        IotRhDailyReportRespVO result = BeanUtils.toBean(iotRhDailyReport, IotRhDailyReportRespVO.class);
+        result.setCapacity(capacity);
+        return success(result);
     }
 
     @GetMapping("/page")
@@ -104,6 +109,18 @@ public class IotRhDailyReportController {
         // return success(new PageResult<>(rhDailyReports, pageResult.getTotal()));
     }
 
+    @GetMapping("/dailyReportSummary")
+    @Operation(summary = "瑞恒日报汇总")
+    @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:query')")
+    public CommonResult<PageResult<IotRhDailyReportRespVO>> dailyReportSummary(@Valid IotRhDailyReportPageReqVO pageReqVO) {
+        // 根据查询参数筛选出 符合条件 的记录id 再传入 颁布查询
+        PageResult<IotRhDailyReportDO> pageResult = iotRhDailyReportService.dailyReportSummary(pageReqVO);
+
+        // List<IotRhDailyReportRespVO> rhDailyReports = IotRhDailyReportConvert.INSTANCE.convertList(pageResult.getList(), deptMap);
+        return success(new PageResult<>(buildRhDailyReports(pageResult.getList()), pageResult.getTotal()));
+        // return success(new PageResult<>(rhDailyReports, pageResult.getTotal()));
+    }
+
     @GetMapping("/taskActualProgress")
     @Operation(summary = "查询日报所属任务的实际进度")
     @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:query')")
@@ -160,8 +177,7 @@ public class IotRhDailyReportController {
                     }
                 });
             }
-            // 查询任务中维护的 设计注气量
-
+            // 查询每个日报关联队伍中包含的 增压机 的产能
         });
         // 2. 拼接数据
         return BeanUtils.toBean(reports, IotRhDailyReportRespVO.class, (reportVO) -> {

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportRespVO.java

@@ -148,4 +148,7 @@ public class IotRhDailyReportRespVO {
     @Schema(description = "设计注气量")
     private String designInjection;
 
+    @Schema(description = "产能")
+    private BigDecimal capacity;
+
 }

+ 17 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportService.java

@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDai
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 
 import javax.validation.Valid;
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -60,4 +61,20 @@ public interface IotRhDailyReportService {
      * @return 从日报中提取任务的实际进度
      */
     List<IotRhDailyReportDO> taskActualProgress(IotRhDailyReportPageReqVO reqVO);
+
+    /**
+     * 查询指定队伍下包含的增压机的产能
+     *
+     * @param deptId
+     * @return 增压机 产能
+     */
+    BigDecimal queryCapacity(Long deptId);
+
+    /**
+     * 瑞恒日报汇总
+     *
+     * @param
+     * @return 增压机 产能
+     */
+    PageResult<IotRhDailyReportDO> dailyReportSummary(IotRhDailyReportPageReqVO pageReqVO);
 }

+ 78 - 43
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -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.iotprojecttask.IotProjectTaskMapper;
 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.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.DictTypeService;
 import com.google.gson.Gson;
@@ -34,10 +36,7 @@ import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 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 static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -67,7 +66,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
     private IotOpeationFillMapper iotOpeationFillMapper;
     @Resource
     private IotDeviceRunLogMapper iotDeviceRunLogMapper;
-
+    @Resource
+    private DeptService deptService;
 
     @Override
     @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)) {
                 // 查询当前任务下关联的所有设备
@@ -229,6 +197,73 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         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
     public void updateIotRhDailyReport(IotRhDailyReportSaveReqVO updateReqVO) {
         // 校验存在