Răsfoiți Sursa

运行记录1211-运行记录工单查询保存优化

yuanchao 1 săptămână în urmă
părinte
comite
2822e8398f

+ 709 - 78
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/IotOpeationFillController.java

@@ -6,9 +6,7 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmodel.vo.IotModelPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.IotModelTemplateAttrsRespVO;
-import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO;
-import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO;
-import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.*;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
@@ -39,6 +37,7 @@ import cn.iocoder.yudao.module.pms.service.yanfan.YfDeviceService;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import com.aliyun.tea.utils.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import lombok.Data;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -103,6 +102,7 @@ public class IotOpeationFillController {
         return success(iotOpeationFillService.createIotOpeationFill(createReqVO));
     }
 
+
     @Transactional(rollbackFor = Exception.class)
     @PostMapping("/insertLog")
     @Operation(summary = "创建运行记录填写信息")
@@ -307,6 +307,358 @@ public class IotOpeationFillController {
 
     }
 
+    //*********APP全部保存接口************
+    @Transactional(rollbackFor = Exception.class)
+    @PostMapping("/insertDataList")
+    @Operation(summary = "创建运行记录工单设备集填写信息")
+    public CommonResult<Integer> insertDataList(@Valid @RequestBody List<IotOperationSaveInfoVO> createReqVO) {
+        try {
+            // 1. 数据预处理:提取所有设备数据并扁平化
+            List<IotOpeationFillSaveReqVO> allFillData = createReqVO.stream()
+                    .flatMap(vo -> vo.getDeviceInfoList().stream())
+                    .collect(Collectors.toList());
+
+            // 验证数据不为空
+            if (CollectionUtils.isEmpty(allFillData)) {
+                return error(1, "设备数据不能为空");
+            }
+
+            // 2. 批量处理累计逻辑(优化循环,使用Map减少时间复杂度)
+            processSummationLogic(allFillData);
+
+            // 3. 批量转换为DO对象
+            List<IotDeviceRunLogDO> logDOList = convertToLogDOList(allFillData);
+
+            // 4. 获取工单ID用于后续操作
+            Long orderId = allFillData.get(0).getId();
+            LocalDate createDate = allFillData.get(0).getCreateTime();
+            Integer userId = allFillData.get(0).getUserId();
+
+            // 5. 更新填写状态
+            updateFillOrderStatus(orderId, userId, createDate);
+
+            // 6. 批量保存日志(有则更新,无则插入)
+            batchSaveLogs(logDOList);
+
+            // 7. 获取部门ID集合
+            Map<String, Set<Long>> deptMap = getDeptIdSets();
+
+            // 8. 生成日报
+            generateDailyReports(logDOList, deptMap, createDate);
+
+            // 9. 更新工单填写状态
+            iotOpeationFillService.updateFill(allFillData.get(0));
+
+            return success(1);
+
+        } catch (Exception e) {
+            //log.error("插入device_run_log失败", e);
+            return error(1, "插入device_run_log失败:" + e.getMessage());
+        }
+    }
+
+    /**
+     * 处理累计逻辑
+     */
+    private void processSummationLogic(List<IotOpeationFillSaveReqVO> allFillData) {
+        // 按modelId分组,便于查找
+        Map<Long, List<IotOpeationFillSaveReqVO>> modelIdMap = allFillData.stream()
+                .filter(fill -> fill.getModelId() != null)
+                .collect(Collectors.groupingBy(IotOpeationFillSaveReqVO::getModelId));
+
+        // 找出需要累计的数据
+        List<IotOpeationFillSaveReqVO> sumDataList = allFillData.stream()
+                .filter(fill -> {
+                    if (fill.getIsSum() != 1) {
+                        return false;
+                    }
+
+                    String defaultValue = fill.getDefaultValue();
+                    // 同时检查null和空字符串
+                    if (defaultValue == null || defaultValue.isEmpty()) {
+                        return false;
+                    }
+
+                    // 如果还需要排除纯空格的情况
+                    if (defaultValue.trim().isEmpty()) {
+                        return false;
+                    }
+
+                    return true;
+                })
+                .collect(Collectors.toList());
+
+
+        for (IotOpeationFillSaveReqVO fill : sumDataList) {
+            try {
+                Long refModelId = Long.parseLong(fill.getDefaultValue());
+                List<IotOpeationFillSaveReqVO> targetFills = modelIdMap.get(refModelId);
+
+                if (CollectionUtils.isEmpty(targetFills)) {
+                    continue;
+                }
+
+                for (IotOpeationFillSaveReqVO targetFill : targetFills) {
+                    if (fill.getSumId() == 1) {
+                        // 需要累加的情况
+                        processAccumulation(fill, targetFill);
+                    } else if (fill.getSumId() == 0) {
+                        // 直接赋值的情况
+                        fill.setTotalRunTime(new BigDecimal(targetFill.getFillContent()));
+                    }
+                }
+            } catch (NumberFormatException e) {
+                //log.warn("DefaultValue转换失败: {}", fill.getDefaultValue());
+            }
+        }
+    }
+
+    /**
+     * 处理数据累加
+     */
+    private void processAccumulation(IotOpeationFillSaveReqVO fill, IotOpeationFillSaveReqVO targetFill) {
+        // 查询历史最大数据
+        LocalTime localTime = LocalTime.MIDNIGHT;
+        IotDeviceRunLogDO queryLog = new IotDeviceRunLogDO();
+        queryLog.setDeviceId(fill.getDeviceId());
+        queryLog.setPointName(fill.getPointName());
+        queryLog.setCreateTime(LocalDateTime.of(fill.getCreateTime(), localTime));
+
+        IotDeviceRunLogDO maxFillData = iotOpeationFillService.maxReportData(queryLog);
+
+        BigDecimal currentValue = new BigDecimal(targetFill.getFillContent());
+        if (maxFillData != null && maxFillData.getTotalRunTime() != null) {
+            fill.setTotalRunTime(maxFillData.getTotalRunTime().add(currentValue));
+        } else {
+            fill.setTotalRunTime(fill.getTotalRunTime() != null ?
+                    fill.getTotalRunTime().add(currentValue) : currentValue);
+        }
+    }
+
+    /**
+     * 批量转换为DO对象
+     */
+    private List<IotDeviceRunLogDO> convertToLogDOList(List<IotOpeationFillSaveReqVO> allFillData) {
+        LocalTime localTime = LocalTime.MIDNIGHT;
+
+        return allFillData.stream()
+                .map(fill -> {
+                    IotDeviceRunLogDO deviceRunLogDO = new IotDeviceRunLogDO();
+                    deviceRunLogDO.setDeviceId(fill.getDeviceId());
+                    deviceRunLogDO.setDeviceCode(fill.getDeviceCode());
+                    deviceRunLogDO.setFillContent(fill.getFillContent());
+                    deviceRunLogDO.setPointCode(fill.getModelAttr());
+                    deviceRunLogDO.setDeptId(fill.getDeptId());
+                    deviceRunLogDO.setCreateTime(LocalDateTime.of(fill.getCreateTime(), localTime));
+                    deviceRunLogDO.setPointName(fill.getPointName());
+                    deviceRunLogDO.setTotalRunTime(fill.getTotalRunTime());
+                    deviceRunLogDO.setIsSum(fill.getIsSum() != null ? fill.getIsSum() : 0);
+                    return deviceRunLogDO;
+                })
+                .collect(Collectors.toList());
+    }
+
+    /**
+     * 更新填写工单状态
+     */
+    private void updateFillOrderStatus(Long orderId, Integer userId, LocalDate createDate) {
+        IotOpeationFillRespVO queryVO = new IotOpeationFillRespVO();
+        queryVO.setUserId(userId);
+        queryVO.setCreateTime(createDate);
+        queryVO.setOrderId(orderId);
+
+        List<IotOpeationFillRespVO> fillList = iotOpeationFillService.getFillList(queryVO);
+
+        if (CollectionUtils.isEmpty(fillList)) {
+            return;
+        }
+
+        boolean allFilled = fillList.stream().allMatch(e -> e.getIsFill() == 1);
+        boolean allUnfilled = fillList.stream().allMatch(e -> e.getIsFill() == 0);
+
+        IotDeviceRunLogDO updateParam = new IotDeviceRunLogDO();
+        updateParam.setId(orderId);
+
+        if (allFilled) {
+            iotOpeationFillService.updateFillOrder(updateParam);
+            handleDuplicateOrders(orderId, createDate);
+        } else if (allUnfilled) {
+            iotOpeationFillService.updateFillOrder1(updateParam);
+        } else {
+            iotOpeationFillService.updateFillOrder2(updateParam);
+        }
+    }
+
+    /**
+     * 处理重复订单
+     */
+    private void handleDuplicateOrders(Long orderId, LocalDate createDate) {
+        IotOpeationFillDO queryDO = new IotOpeationFillDO();
+        queryDO.setOrderId(orderId);
+
+        List<IotOpeationFillDO> devList = iotOpeationFillService.devList(queryDO);
+
+        if (devList.size() == 1) {
+            queryDO.setDeviceId(devList.get(0).getDeviceId());
+            queryDO.setCreDate(createDate);
+
+            List<IotOpeationFillDO> orderList = iotOpeationFillService.orderList(queryDO);
+
+            if (!CollectionUtils.isEmpty(orderList)) {
+                for (IotOpeationFillDO order : orderList) {
+                    List<IotOpeationFillDO> delList = iotOpeationFillService.delList(order);
+                    if (delList.size() == 1) {
+                        iotOpeationFillService.delRepeat(delList.get(0));
+                        iotOpeationFillService.delRepeatOrder(order);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 批量保存日志
+     */
+    private void batchSaveLogs(List<IotDeviceRunLogDO> logDOList) {
+        for (IotDeviceRunLogDO log : logDOList) {
+            IotDeviceRunLogDO existingData = iotOpeationFillService.reportData(log);
+            if (existingData == null) {
+                iotOpeationFillService.insertLog1(log);
+            } else {
+                if (log.getIsSum() == 0) {
+                    iotOpeationFillService.updateLog(log);
+                } else {
+                    iotOpeationFillService.updateSumLog(log);
+                }
+            }
+        }
+    }
+
+    /**
+     * 获取部门ID集合
+     */
+    private Map<String, Set<Long>> getDeptIdSets() {
+        Map<String, Set<Long>> deptMap = new HashMap<>();
+
+        Set<Long> rhIdList = deptService.getChildDeptIdListFromCache(157L);
+        rhIdList.add(157L);
+        deptMap.put("RH", rhIdList);
+
+        Set<Long> ryIdList = deptService.getChildDeptIdListFromCache(158L);
+        ryIdList.add(158L);
+        deptMap.put("RY", ryIdList);
+
+        return deptMap;
+    }
+
+    /**
+     * 生成日报
+     */
+    private void generateDailyReports(List<IotDeviceRunLogDO> logDOList,
+                                      Map<String, Set<Long>> deptMap,
+                                      LocalDate createDate) {
+        // 按设备分组处理
+        Map<Long, List<IotDeviceRunLogDO>> deviceLogsMap = logDOList.stream()
+                .collect(Collectors.groupingBy(IotDeviceRunLogDO::getDeviceId));
+
+        for (Map.Entry<Long, List<IotDeviceRunLogDO>> entry : deviceLogsMap.entrySet()) {
+            List<IotDeviceRunLogDO> deviceLogs = entry.getValue();
+            if (CollectionUtils.isEmpty(deviceLogs)) {
+                continue;
+            }
+
+            IotDeviceRunLogDO sampleLog = deviceLogs.get(0);
+            IotOpeationFillDO reportQuery = new IotOpeationFillDO();
+            reportQuery.setDeviceId(sampleLog.getDeviceId());
+            reportQuery.setCreateTime(sampleLog.getCreateTime());
+
+            IotOpeationFillDO fillStatus = iotOpeationFillService.isReport(reportQuery);
+
+            if (fillStatus != null && fillStatus.getIsReport() != null &&
+                    fillStatus.getIsReport() == 1) {
+
+                processDepartmentReport(deviceLogs, fillStatus, deptMap, createDate);
+            }
+        }
+    }
+
+    /**
+     * 处理部门日报生成
+     */
+    private void processDepartmentReport(List<IotDeviceRunLogDO> deviceLogs,
+                                         IotOpeationFillDO fillStatus,
+                                         Map<String, Set<Long>> deptMap,
+                                         LocalDate createDate) {
+        Set<Long> rhIdList = deptMap.get("RH");
+        Set<Long> ryIdList = deptMap.get("RY");
+
+        if (rhIdList.contains(fillStatus.getDeptId())) {
+            generateRhDailyReport(deviceLogs, fillStatus, createDate);
+        } else if (ryIdList.contains(fillStatus.getDeptId())) {
+            generateRyDailyReport(deviceLogs, fillStatus, createDate);
+        }
+    }
+
+    /**
+     * 生成RH日报
+     */
+    private void generateRhDailyReport(List<IotDeviceRunLogDO> deviceLogs,
+                                       IotOpeationFillDO fillStatus,
+                                       LocalDate createDate) {
+        IotRhDailyReportSaveReqVO saveReqVO = new IotRhDailyReportSaveReqVO();
+        Map<String, Object> reportData = BeanUtil.beanToMap(saveReqVO);
+
+        for (IotDeviceRunLogDO log : deviceLogs) {
+            IotDeviceRunLogDO descDO = iotOpeationFillService.getDesc(log);
+            if (descDO != null && descDO.getPointName() != null) {
+                String pointName = descDO.getPointName();
+                if (reportData.containsKey(pointName)) {
+                    reportData.put(pointName, log.getFillContent());
+                }
+            }
+        }
+
+        IotRhDailyReportSaveReqVO finalReport = BeanUtil.mapToBean(reportData,
+                IotRhDailyReportSaveReqVO.class, false);
+        finalReport.setDeptId(fillStatus.getDeptId());
+        finalReport.setFillOrderCreateTime(createDate.atStartOfDay());
+
+        iotRhDailyReportService.createIotRhDailyReport(finalReport);
+    }
+
+    /**
+     * 生成RY日报
+     */
+    private void generateRyDailyReport(List<IotDeviceRunLogDO> deviceLogs,
+                                       IotOpeationFillDO fillStatus,
+                                       LocalDate createDate) {
+        IotRyDailyReportSaveReqVO saveReqVO = new IotRyDailyReportSaveReqVO();
+        Map<String, Object> reportData = BeanUtil.beanToMap(saveReqVO);
+
+        for (IotDeviceRunLogDO log : deviceLogs) {
+            IotDeviceRunLogDO descDO = iotOpeationFillService.getDesc(log);
+            if (descDO != null && descDO.getPointName() != null) {
+                String pointName = descDO.getPointName();
+                if (reportData.containsKey(pointName)) {
+                    reportData.put(pointName, log.getFillContent());
+                }
+            }
+        }
+
+        IotRyDailyReportSaveReqVO finalReport = BeanUtil.mapToBean(reportData,
+                IotRyDailyReportSaveReqVO.class, false);
+        finalReport.setDeptId(fillStatus.getDeptId());
+        finalReport.setFillOrderCreateTime(createDate.atStartOfDay());
+
+        if (fillStatus.getDeviceCategoryId() != null &&
+                fillStatus.getDeviceCategoryId() == 228) {
+            finalReport.setProjectClassification("2");
+        }
+
+        iotRyDailyReportService.createIotRyDailyReport(finalReport);
+    }
+    //************************************************8
+
     @PostMapping("/upOperationOrder")
     @Operation(summary = "创建运行记录填写信息")
     public CommonResult<Integer> upOperationOrder(@Valid @RequestBody IotOpeationFillRespVO respVO) {
@@ -364,30 +716,6 @@ public class IotOpeationFillController {
         return success(BeanUtils.toBean(iotOpeationFill, IotOpeationFillDO.class));
     }
 
-    @GetMapping("/page")
-    @Operation(summary = "获得运行记录填报分页")
-    @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
-    public CommonResult<List<IotOpeationFillDO>> getIotOpeationFillPage(@Valid IotOpeationFillRespVO pageReqVO) {
-        List<IotOpeationFillDO> fillList = iotOpeationFillService.fillListByUserId(pageReqVO);
-        return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
-    }
-
-    @GetMapping("/orderPage")
-    @Operation(summary = "获得运行记录填报分页")
-    @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
-    public CommonResult<List<IotOpeationFillDO>> getOrderPage(@Valid IotOpeationFillRespVO pageReqVO) {
-        List<IotOpeationFillDO> fillList = new ArrayList<>();
-        /* if(pageReqVO.getDeviceId()!=null){
-         *//**
-         * 根据设备ID和OrderId返回
-         *//*
-
-        }else{*/
-        fillList = iotOpeationFillService.fillListByDeptId(pageReqVO);
-
-
-        return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
-    }
 
 
     @GetMapping("/page1")
@@ -414,9 +742,9 @@ public class IotOpeationFillController {
             }
         }
 
-       /* IotOpeationFillRespVO fill = new IotOpeationFillRespVO();
+        /* IotOpeationFillRespVO fill = new IotOpeationFillRespVO();
 
-        *//**
+         *//**
          * 遍历主表数据,拿到id,根据id查询子表获取子表设备名称+设备编码
          *//*
         for (IotOpeationFillOrderDO orderDO : fillList.getList()) {
@@ -493,6 +821,309 @@ public class IotOpeationFillController {
         return success(BeanUtils.toBean(fillList, IotOpeationFillOrderDO.class));
     }
 
+
+    @GetMapping("/page")
+    @Operation(summary = "获得运行记录填报分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
+    public CommonResult<List<IotOpeationFillDO>> getIotOpeationFillPage(@Valid IotOpeationFillRespVO pageReqVO) {
+        List<IotOpeationFillDO> fillList = iotOpeationFillService.fillListByUserId(pageReqVO);
+        return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
+    }
+
+    @GetMapping("/orderFillpage")
+    @Operation(summary = "获得运行记录填报分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
+    public CommonResult<PageResult<IotOpeationFillDO>> getIotOpeationFillWithAttrsPage(@Valid IotOpeationFillPageVO pageReqVO) {
+        PageResult<IotOpeationFillDO> fillList = iotOpeationFillService.fillListPage(pageReqVO);
+        return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
+    }
+
+
+    //**************
+
+    // 新VO类,用于返回包含属性详情的分页结果
+    @Data
+    public class IotOpeationFillWithAttrsVO extends IotOpeationFillDO {
+        // 保留IotOpeationFillDO的所有属性
+        // 新增属性详情字段
+        private List<IotModelTemplateAttrsDO1> attrsDetail;
+    }
+
+    @GetMapping("/orderFillpage1")
+    @Operation(summary = "获得运行记录填报分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
+    public CommonResult<PageResult<IotOpeationFillWithAttrsVO>> getIotOpeationFillWithAttrsPage1(@Valid IotOpeationFillPageVO pageReqVO) throws SQLException {
+        // 1. 获取分页数据
+        PageResult<IotOpeationFillDO> fillList = iotOpeationFillService.fillListPage(pageReqVO);
+
+        // 2. 转换为新的VO类型(包含属性详情)
+        List<IotOpeationFillWithAttrsVO> resultList = new ArrayList<>();
+
+        for (IotOpeationFillDO fillDO : fillList.getList()) {
+            IotOpeationFillWithAttrsVO vo = BeanUtils.toBean(fillDO, IotOpeationFillWithAttrsVO.class);
+
+            // 3. 为每个分页项获取属性详情
+            IotModelTemplateAttrsRespVO attrsReqVO = new IotModelTemplateAttrsRespVO();
+            attrsReqVO.setDeviceId(fillDO.getDeviceId());
+            attrsReqVO.setDeviceCode(fillDO.getDeviceCode()); // 假设分页接口返回了deviceCode
+            attrsReqVO.setCreateTime(fillDO.getCreateTime().toLocalDate());
+            attrsReqVO.setDeviceCategoryId(fillDO.getDeviceCategoryId());
+
+
+            // 4. 调用原属性详情逻辑
+            List<IotModelTemplateAttrsDO1> attrsDetail = getAttrsDetail(attrsReqVO);
+            vo.setAttrsDetail(attrsDetail);
+
+            resultList.add(vo);
+        }
+
+        // 5. 创建新的分页结果
+        PageResult<IotOpeationFillWithAttrsVO> pageResult = new PageResult<>(
+                resultList,
+                fillList.getTotal()
+        );
+
+        return success(pageResult);
+    }
+
+    // 提取属性详情逻辑为私有方法
+    private List<IotModelTemplateAttrsDO1> getAttrsDetail(IotModelTemplateAttrsRespVO vo) throws SQLException {
+        // 以下是您原getAttrs接口的核心逻辑,保持不变
+        //判断是否为虚拟设备
+        //如果是走原来逻辑
+        //不是走虚拟设备逻辑
+        IotOpeationFillDO fillDO = new IotOpeationFillDO();
+        fillDO.setDeviceId(vo.getDeviceId());
+        fillDO.setCreateTime(vo.getCreateTime().atStartOfDay());
+        IotOpeationFillDO fillDO1 = iotOpeationFillService.isReport(fillDO);
+
+        List<IotModelTemplateAttrsDO1> result = new ArrayList<>();
+        List<IotModelTemplateAttrsDO> list = iotOpeationFillService.getAttrsById(vo);
+
+        if (fillDO1.getIsReport() != null && fillDO1.getIsReport() == 1) {
+            IotOpeationFillDO fillDO2 = iotOpeationFillService.orderDO(fillDO);
+
+            List<IotOpeationFillDO> reportList = new ArrayList<>();
+            List<IotOpeationFillDO> reportList1 = new ArrayList<>();
+
+            if (fillDO2 != null) {
+                reportList = iotOpeationFillService.reportList(fillDO2);
+                reportList1 = iotOpeationFillService.reportList1(fillDO2);
+            }
+
+            for (IotModelTemplateAttrsDO attrsDO : list) {
+                List<IotOpeationFillDO> cxLixt = reportList.stream().filter(e -> e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
+                //虚拟设备取值
+                List<IotOpeationFillDO> cxLixt1 = reportList1.stream().filter(e -> e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
+
+                if (cxLixt.size() > 0) {
+                    // 使用Map按orgName分组存储累加结果
+                    Map<String, String> orgNameToFillContent = new HashMap<>();
+
+                    for (IotOpeationFillDO reportData : cxLixt) {
+                        IotDeviceRunLogDO report = new IotDeviceRunLogDO();
+                        report.setDeviceId(reportData.getDeviceId());
+                        report.setPointName(reportData.getOrgName());
+                        report.setCreateTime(reportData.getCreateTime());
+
+                        IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
+
+                        String currentContent = "";
+                        if (reportCx == null) {
+                            attrsDO.setFillContent("");
+                        } else {
+                            currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
+                        }
+
+                        // 获取当前orgName
+                        String orgName = reportData.getOrgName();
+
+                        // 累加相同orgName的内容
+                        if (orgNameToFillContent.containsKey(orgName)) {
+                            String existingContent = orgNameToFillContent.get(orgName);
+
+                            double existingValue = safeParseInt(existingContent);
+                            double currentValue = safeParseInt(currentContent);
+
+                            if ((existingValue + currentValue) == 0) {
+                                orgNameToFillContent.put(orgName, "");
+                            } else {
+                                orgNameToFillContent.put(orgName, String.valueOf(existingValue + currentValue));
+                            }
+
+                        } else {
+                            orgNameToFillContent.put(orgName, currentContent);
+                        }
+                        attrsDO.setFillContent(orgNameToFillContent.get(reportData.getOrgName()));
+                    }
+                }
+
+                if (cxLixt1.size() > 0) {
+                    for (IotOpeationFillDO reportData : cxLixt1) {
+                        IotDeviceRunLogDO report = new IotDeviceRunLogDO();
+                        report.setDeviceId(reportData.getDeviceId());
+                        report.setPointName(reportData.getOrgName());
+                        report.setCreateTime(reportData.getCreateTime());
+                        IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
+
+                        String currentContent = "";
+                        if (reportCx != null) {
+                            currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
+                            attrsDO.setFillContent(currentContent);
+                        }
+                    }
+                }
+
+                attrsDO.setIsCollection(0);
+                attrsDO.setIsSum(0);
+            }
+
+        } else {
+            List<YfDeviceDO> allDevice = yfDeviceService.getAllDevice();
+
+            LocalTime localTime = LocalTime.of(0, 0, 0);
+            LocalTime localTime1 = LocalTime.of(23, 59, 59);
+
+            LocalDateTime start = LocalDateTime.of(vo.getCreateTime(), localTime);
+            LocalDateTime end = LocalDateTime.of(vo.getCreateTime(), localTime1);
+
+            Timestamp startTime = Timestamp.valueOf(start);
+            Timestamp endTime = Timestamp.valueOf(end);
+
+            List<YfDeviceDO> existList = allDevice.stream().filter(e -> e.getStatus() == 3).collect(Collectors.toList());
+            boolean exists1 = existList.stream().anyMatch(yfDeviceDO -> yfDeviceDO.getSerialNumber().equals(vo.getDeviceCode()));
+
+            IotDeviceRunLogDO logDO1 = new IotDeviceRunLogDO();
+            logDO1.setDeviceId(vo.getDeviceId());
+            LocalTime local = LocalTime.of(12, 0);
+            logDO1.setCreateTime(LocalDateTime.of(vo.getCreateTime(), local));
+
+            if (exists1) {
+                for (IotModelTemplateAttrsDO attrsDO : list) {
+                    DeviceVO dv = new DeviceVO();
+                    dv.setDeviceName(vo.getDeviceCode().toLowerCase());
+                    dv.setColName(attrsDO.getModelAttr());
+                    dv.setTs(startTime);
+                    dv.setTs1(endTime);
+
+                    DeviceVO deviceVO = iDeviceService.getYesInfo(dv);
+
+                    if (!StringUtils.isEmpty(deviceVO) && !deviceVO.getEarliestData().equals("0.0")) {
+                        attrsDO.setFillContent(
+                                String.valueOf(Double.parseDouble(deviceVO.getLatestData()) - Double.parseDouble(deviceVO.getEarliestData())));
+                        attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
+                        /**
+                         * 设置为数采
+                         */
+                        attrsDO.setIsCollection(1);
+                    } else {
+                        logDO1.setPointName(attrsDO.getName());
+                        IotDeviceRunLogDO logInfo = iotOpeationFillService.getLogInfo(logDO1);
+                        IotDeviceRunLogDO maxLog = iotOpeationFillService.getMaxFillInfo(logDO1);
+                        if (!StringUtils.isEmpty(logInfo)) {
+
+                            attrsDO.setFillContent(logInfo.getFillContent());
+
+                            if (StringUtils.isEmpty(maxLog)) {
+                                attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
+                            } else {
+                                attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
+                            }
+                            /**
+                             * 设置为非数采
+                             */
+                            attrsDO.setIsCollection(0);
+
+                        } else {
+                            attrsDO.setFillContent("");
+                            if (StringUtils.isEmpty(maxLog)) {
+                                attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
+                            } else {
+                                attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
+                            }
+                            /**
+                             * 设置为非数采
+                             */
+                            attrsDO.setIsCollection(0);
+                        }
+                    }
+                }
+            } else {
+                for (IotModelTemplateAttrsDO attrsDO : list) {
+                    logDO1.setPointName(attrsDO.getName());
+                    IotDeviceRunLogDO logInfo = iotOpeationFillService.getLogInfo(logDO1);
+                    IotDeviceRunLogDO maxLog = iotOpeationFillService.getMaxFillInfo(logDO1);
+                    if (!StringUtils.isEmpty(logInfo)) {
+
+                        attrsDO.setFillContent(logInfo.getFillContent());
+                        attrsDO.setTotalRunTime(logInfo.getTotalRunTime());
+
+                        /**
+                         * 设置为非数采
+                         */
+                        attrsDO.setIsCollection(0);
+
+                    } else {
+                        attrsDO.setFillContent("");
+                        if (StringUtils.isEmpty(maxLog)) {
+                            attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
+                        } else {
+                            attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
+                        }
+
+                        /**
+                         * 设置为非数采
+                         */
+                        attrsDO.setIsCollection(0);
+
+                    }
+
+                }
+
+            }
+
+        }
+        List<IotModelTemplateAttrsDO> sumList = list.stream().filter(e -> e.getIsSum() == 1).collect(Collectors.toList());
+        List<IotModelTemplateAttrsDO> nonSumList = list.stream().filter(e -> e.getIsSum() == 0).collect(Collectors.toList());
+
+        IotModelTemplateAttrsDO1 sum = new IotModelTemplateAttrsDO1();
+        sum.setSumList(sumList);
+        sum.setNonSumList(nonSumList);
+
+        result.add(sum);
+
+        return result;
+    }
+
+
+
+    //**************
+
+
+
+
+
+
+    @GetMapping("/orderPage")
+    @Operation(summary = "获得运行记录填报分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
+    public CommonResult<List<IotOpeationFillDO>> getOrderPage(@Valid IotOpeationFillRespVO pageReqVO) {
+        List<IotOpeationFillDO> fillList = new ArrayList<>();
+        /* if(pageReqVO.getDeviceId()!=null){
+         *//**
+         * 根据设备ID和OrderId返回
+         *//*
+
+        }else{*/
+        fillList = iotOpeationFillService.fillListByDeptId(pageReqVO);
+
+
+        return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
+    }
+
+
+
+
     @GetMapping("/fillRecordPage")
     @Operation(summary = "获得运行记录填报分页")
     public CommonResult<PageResult<IotOpeationFillOrderDO>> getFillRecords(@Valid IotOpeationFillPageReqVO pageReqVO) {
@@ -579,69 +1210,69 @@ public class IotOpeationFillController {
 
 
 
-                    List<IotOpeationFillDO> cxLixt = reportList.stream().filter(e->e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
-                    //虚拟设备取值
-                    List<IotOpeationFillDO> cxLixt1 = reportList1.stream().filter(e->e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
-
-                    if(cxLixt.size()>0){
-                        // 使用Map按orgName分组存储累加结果
-                        Map<String, String> orgNameToFillContent = new HashMap<>();
+                List<IotOpeationFillDO> cxLixt = reportList.stream().filter(e->e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
+                //虚拟设备取值
+                List<IotOpeationFillDO> cxLixt1 = reportList1.stream().filter(e->e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
 
-                        for (IotOpeationFillDO reportData : cxLixt) {
-                            IotDeviceRunLogDO report = new IotDeviceRunLogDO();
-                            report.setDeviceId(reportData.getDeviceId());
-                            report.setPointName(reportData.getOrgName());
-                            report.setCreateTime(reportData.getCreateTime());
+                if(cxLixt.size()>0){
+                    // 使用Map按orgName分组存储累加结果
+                    Map<String, String> orgNameToFillContent = new HashMap<>();
 
-                            IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
+                    for (IotOpeationFillDO reportData : cxLixt) {
+                        IotDeviceRunLogDO report = new IotDeviceRunLogDO();
+                        report.setDeviceId(reportData.getDeviceId());
+                        report.setPointName(reportData.getOrgName());
+                        report.setCreateTime(reportData.getCreateTime());
 
-                            String currentContent = "";
-                            if(reportCx==null){
-                                attrsDO.setFillContent("");
-                            }else{
-                                currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
-                            }
+                        IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
 
+                        String currentContent = "";
+                        if(reportCx==null){
+                            attrsDO.setFillContent("");
+                        }else{
+                            currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
+                        }
 
-                            // 获取当前orgName
-                            String orgName = reportData.getOrgName();
 
-                            // 累加相同orgName的内容
-                            if (orgNameToFillContent.containsKey(orgName)) {
-                                String existingContent = orgNameToFillContent.get(orgName);
+                        // 获取当前orgName
+                        String orgName = reportData.getOrgName();
 
-                                double existingValue = safeParseInt(existingContent);
-                                double currentValue = safeParseInt(currentContent);
+                        // 累加相同orgName的内容
+                        if (orgNameToFillContent.containsKey(orgName)) {
+                            String existingContent = orgNameToFillContent.get(orgName);
 
-                                if((existingValue + currentValue)==0){
-                                    orgNameToFillContent.put(orgName, "");
-                                }else{
-                                    orgNameToFillContent.put(orgName, String.valueOf(existingValue + currentValue));
-                                }
+                            double existingValue = safeParseInt(existingContent);
+                            double currentValue = safeParseInt(currentContent);
 
-                            } else {
-                                orgNameToFillContent.put(orgName, currentContent);
+                            if((existingValue + currentValue)==0){
+                                orgNameToFillContent.put(orgName, "");
+                            }else{
+                                orgNameToFillContent.put(orgName, String.valueOf(existingValue + currentValue));
                             }
-                            attrsDO.setFillContent(orgNameToFillContent.get(reportData.getOrgName()));
 
+                        } else {
+                            orgNameToFillContent.put(orgName, currentContent);
                         }
+                        attrsDO.setFillContent(orgNameToFillContent.get(reportData.getOrgName()));
+
                     }
+                }
 
-                    if(cxLixt1.size()>0){
-                        for (IotOpeationFillDO reportData : cxLixt1) {
-                            IotDeviceRunLogDO report = new IotDeviceRunLogDO();
-                            report.setDeviceId(reportData.getDeviceId());
-                            report.setPointName(reportData.getOrgName());
-                            report.setCreateTime(reportData.getCreateTime());
-                            IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
-
-                            String currentContent = "";
-                            if(reportCx!=null){
-                                currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
-                                attrsDO.setFillContent(currentContent);
-                            }
+                if(cxLixt1.size()>0){
+                    for (IotOpeationFillDO reportData : cxLixt1) {
+                        IotDeviceRunLogDO report = new IotDeviceRunLogDO();
+                        report.setDeviceId(reportData.getDeviceId());
+                        report.setPointName(reportData.getOrgName());
+                        report.setCreateTime(reportData.getCreateTime());
+                        IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
+
+                        String currentContent = "";
+                        if(reportCx!=null){
+                            currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
+                            attrsDO.setFillContent(currentContent);
                         }
                     }
+                }
 
 
                 attrsDO.setIsCollection(0);
@@ -810,12 +1441,12 @@ public class IotOpeationFillController {
     @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:export')")
     @ApiAccessLog(operateType = EXPORT)
     public void exportIotOpeationFillExcel(@Valid IotOpeationFillPageReqVO pageReqVO,
-              HttpServletResponse response) throws IOException {
+                                           HttpServletResponse response) throws IOException {
         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
         List<IotOpeationFillDO> list = iotOpeationFillService.getIotOpeationFillPage(pageReqVO).getList();
         // 导出 Excel
         ExcelUtils.write(response, "运行记录填报.xls", "数据", IotOpeationFillRespVO.class,
-                        BeanUtils.toBean(list, IotOpeationFillRespVO.class));
+                BeanUtils.toBean(list, IotOpeationFillRespVO.class));
     }
 
 

+ 86 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillPageVO.java

@@ -0,0 +1,86 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 运行记录填报分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotOpeationFillPageVO extends PageParam {
+
+    @Schema(description = "资产编号")
+    private String deviceCode;
+
+    private Long deviceCategoryId;
+
+    @Schema(description = "设备名称", example = "赵六")
+    private String deviceName;
+
+    @Schema(description = "填写内容")
+    private String fillContent;
+
+    @Schema(description = "设备类别", example = "1")
+    private String deviceType;
+
+    @Schema(description = "设备部件")
+    private String deviceComponent;
+
+    @Schema(description = "公司id", example = "17048")
+    private Long deptId;
+
+    @Schema(description = "设备id", example = "17048")
+    private Long deviceId;
+
+    @Schema(description = "所属组织", example = "李四")
+    private String orgName;
+
+    @Schema(description = "项目部id", example = "2565")
+    private Long proId;
+
+    @Schema(description = "所属项目部", example = "李四")
+    private String proName;
+
+    @Schema(description = "小队id", example = "26084")
+    private Long teamId;
+
+    @Schema(description = "所属小队", example = "张三")
+    private String teamName;
+
+    @Schema(description = "设备负责人", example = "李四")
+    private String dutyName;
+
+    @Schema(description = "填写日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
+    private LocalDate creDate;
+
+    private Date startDate;
+    private Date endDate;
+
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    private Integer isFill;
+    private String orderName;
+    private String orderType;
+    private Integer orderStatus;
+    private Integer userId;
+    private String userName;
+    private int isReport;
+    private List<Long> deptIds;
+    private Long orderId;
+}

+ 21 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOperationSaveInfoVO.java

@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo;
+
+import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskSaveReqVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author yc
+ * @version 1.0
+ * @className IotOperationSaveInfoVO
+ * @date 2025/12/11 10:37
+ * @description
+ */
+@Schema(description = "工单设备集数据集合")
+@Data
+public class IotOperationSaveInfoVO {
+    @Schema(description = "单设备数据集")
+    private List<IotOpeationFillSaveReqVO> deviceInfoList;
+}

+ 7 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillMapper.java

@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.IotModelTemplateAttrsRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
@@ -122,6 +123,10 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
 
     @TenantIgnore
     List<IotOpeationFillDO> fillListByUserId(IotOpeationFillRespVO vo);
+
+    @TenantIgnore
+    IPage<IotOpeationFillDO> fillListPage(IPage<IotOpeationFillPageVO> page,@Param("orderId") Long orderId);
+
     @TenantIgnore
     List<IotOpeationFillDO> getOrderIds(IotOpeationFillRespVO vo);
     @TenantIgnore
@@ -222,6 +227,8 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
     @TenantIgnore
     IPage<IotDeviceCountData> deviceCountList(IPage<IotOpeationFillPageReqVO> page, @Param("deptId") Long deptId,
                                               @Param("createTime")LocalDateTime[] createTime,@Param("isFill") Integer isFill,@Param("orderName") String orderName);
+
+
     @TenantIgnore
     List<IotOpeationFillOrderDO> childList(IotOpeationFillOrderDO fillDO);
 

+ 4 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillService.java

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.pms.service.iotopeationfill;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.IotModelTemplateAttrsRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
@@ -77,6 +78,9 @@ public interface IotOpeationFillService {
 
     List<IotOpeationFillDO> fillListByUserId(IotOpeationFillRespVO vo);
 
+
+    PageResult<IotOpeationFillDO> fillListPage(IotOpeationFillPageVO vo);
+
     void syncWordOrderData(List<Long> deviceIds, List<Long> oldDeptIds, Long deptId);
 
     List<IotOpeationFillDO> fillListByDeptId(IotOpeationFillRespVO vo);

+ 17 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillServiceImpl.java

@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pms.service.iotopeationfill;
 
 import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.IotModelTemplateAttrsRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
@@ -151,6 +152,21 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         return iotOpeationFillMapper.fillListByUserId(vo);
     }
 
+
+    @Override
+    public PageResult<IotOpeationFillOrderDO> fillRecords(IotOpeationFillPageReqVO vo) {
+        IPage<IotOpeationFillOrderDO> fillOrderDOIPage = iotOpeationFillMapper.fillRecords(Page.of(vo.getPageNo(), vo.getPageSize()),vo.getDeviceId(),vo.getOrderName(),vo.getOrderStatus());
+        return new PageResult<>(fillOrderDOIPage.getRecords(),fillOrderDOIPage.getTotal());
+    }
+
+    @Override
+    public PageResult<IotOpeationFillDO> fillListPage(IotOpeationFillPageVO vo) {
+
+        IPage<IotOpeationFillDO> fillPage = iotOpeationFillMapper.fillListPage(Page.of(vo.getPageNo(), vo.getPageSize()),vo.getOrderId());
+
+        return new PageResult<>(fillPage.getRecords(),fillPage.getTotal());
+    }
+
     @Override
     public void syncWordOrderData(List<Long> deviceIds, List<Long> oldDeptIds, Long deptId) {
         /**
@@ -291,11 +307,7 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         return iotOpeationFillMapper.delRepeatOrder(fillDO);
     }
 
-    @Override
-    public PageResult<IotOpeationFillOrderDO> fillRecords(IotOpeationFillPageReqVO vo) {
-        IPage<IotOpeationFillOrderDO> fillOrderDOIPage = iotOpeationFillMapper.fillRecords(Page.of(vo.getPageNo(), vo.getPageSize()),vo.getDeviceId(),vo.getOrderName(),vo.getOrderStatus());
-        return new PageResult<>(fillOrderDOIPage.getRecords(),fillOrderDOIPage.getTotal());
-    }
+
 
     @Override
     public PageResult<IotDeviceRespVO> getFillDevices1(IotOpeationFillPageReqVO vo) {

+ 50 - 27
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -192,8 +192,8 @@
         insert into rq_iot_device_run_log
         (dept_id, device_id, device_code, point_code, fill_content, create_time, point_name, total_run_time,is_sum)
         values
-            (#{deptId}, #{deviceId}, #{deviceCode},
-             #{pointCode}, #{fillContent}, #{createTime}, #{pointName}, #{totalRunTime},#{isSum})
+        (#{deptId}, #{deviceId}, #{deviceCode},
+         #{pointCode}, #{fillContent}, #{createTime}, #{pointName}, #{totalRunTime},#{isSum})
     </insert>
 
     <update id="updateLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
@@ -319,6 +319,29 @@
     </select>
 
 
+    <select id="fillListPage" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        SELECT DISTINCT
+        a.*,
+        b.name org_name
+        FROM
+        rq_iot_opeation_fill a
+        JOIN system_dept b ON a.dept_id = b.id
+        JOIN rq_iot_model_template_attrs c ON a.device_category_id = c.device_category_id
+        JOIN rq_iot_opeation_fill_order d ON a.order_id = d.id
+        WHERE
+        (
+        1=1
+        <if test="orderId != null and orderId != ''">
+            and  a.order_id = #{orderId}
+        </if>
+        )
+        ORDER BY
+        CASE WHEN device_code IS NULL OR device_code = '' THEN 1 ELSE 0 END ASC,
+        CAST(SUBSTRING(device_code, 3) AS UNSIGNED) ASC
+    </select>
+
+
     <select id="getOrderIds" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select
@@ -382,7 +405,7 @@
         WHERE
             order_id = #{orderId}
           and
-            dept_id IN (
+                dept_id IN (
                 SELECT id FROM (
                                    SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
                                    UNION ALL
@@ -1089,24 +1112,24 @@
             a.order_id = #{orderId}
           AND (
             -- 第一个查询的条件
-            (a.is_report = 1 AND b.daily_report = 0
-                AND b.name NOT IN (
-                    SELECT
-                        DISTINCT
-                        b2.name
-                    FROM
-                        rq_iot_opeation_fill a2
-                            INNER JOIN
-                        rq_iot_model_template_attrs b2
-                        ON
-                            a2.device_category_id = b2.device_category_id
-                    WHERE
-                        a2.order_id =  #{orderId}
-                      AND
-                        a2.is_report = 0
-                      AND
-                        b2.daily_report = 1
-                ))
+                (a.is_report = 1 AND b.daily_report = 0
+                    AND b.name NOT IN (
+                        SELECT
+                            DISTINCT
+                            b2.name
+                        FROM
+                            rq_iot_opeation_fill a2
+                                INNER JOIN
+                            rq_iot_model_template_attrs b2
+                            ON
+                                a2.device_category_id = b2.device_category_id
+                        WHERE
+                            a2.order_id =  #{orderId}
+                          AND
+                            a2.is_report = 0
+                          AND
+                            b2.daily_report = 1
+                    ))
                 -- 第二个查询的条件(通过OR代替UNION)
                 OR (a.is_report is null AND b.daily_report = 1)
             )
@@ -1149,11 +1172,11 @@
         SELECT
             MAX(total_Run_Time) AS total_run_time
         FROM
-        rq_iot_device_run_log
+            rq_iot_device_run_log
         WHERE
-        device_id = #{deviceId}
-        AND point_name = #{pointName}
-        AND create_time &lt; #{createTime}
+            device_id = #{deviceId}
+          AND point_name = #{pointName}
+          AND create_time &lt; #{createTime}
     </select>
 
     <select id="reportData1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
@@ -1176,8 +1199,8 @@
         where
             name = #{pointName}
           and
-            device_category_id =
-            (select device_category_id  from rq_iot_opeation_fill where device_id = #{deviceId} and DATE(create_time) = #{createTime})
+                device_category_id =
+                (select device_category_id  from rq_iot_opeation_fill where device_id = #{deviceId} and DATE(create_time) = #{createTime})
     </select>