Просмотр исходного кода

运行记录1210-运行记录工单查询优化

yuanchao 1 неделя назад
Родитель
Сommit
bb3f57530e

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

@@ -368,18 +368,7 @@ public class IotOpeationFillController {
     @Operation(summary = "获得运行记录填报分页")
     @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
     public CommonResult<List<IotOpeationFillDO>> getIotOpeationFillPage(@Valid IotOpeationFillRespVO pageReqVO) {
-        List<IotOpeationFillDO> fillList = new ArrayList<>();
-       /* if(pageReqVO.getDeviceId()!=null){
-            *//**
-             * 根据设备ID和OrderId返回
-             *//*
-            fillList = iotOpeationFillService.fillListByDeptId(pageReqVO);
-        }else{*/
-            /**
-             * 根据OrderId返回
-             */
-            fillList = iotOpeationFillService.fillListByUserId(pageReqVO);
-
+        List<IotOpeationFillDO> fillList = iotOpeationFillService.fillListByUserId(pageReqVO);
         return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
     }
 
@@ -454,11 +443,12 @@ public class IotOpeationFillController {
                 .collect(Collectors.toMap(IotOpeationFillOrderDO::getId, IotOpeationFillOrderDO::getDeptId));
 
         // 准备查询参数
-        IotOpeationFillRespVO fill = new IotOpeationFillRespVO();
+
 
         // 2. 批量查询所有fill数据
         List<IotOpeationFillDO> allFillList = new ArrayList<>();
         for (Map.Entry<Long, Long> entry : orderDeptMap.entrySet()) {
+            IotOpeationFillRespVO fill = new IotOpeationFillRespVO();
             fill.setOrderId(entry.getKey());
             fill.setDeptId(entry.getValue());
             allFillList.addAll(iotOpeationFillService.fillListByDeptId(fill));
@@ -466,9 +456,11 @@ public class IotOpeationFillController {
 
         // 3. 批量查询所有dev数据
         Map<Long, IotOpeationFillDO> devMap = new HashMap<>();
-        for (Long orderId : orderDeptMap.keySet()) {
-            fill.setOrderId(orderId);
-            devMap.put(orderId, iotOpeationFillService.devListByOrderId(fill));
+        for (Map.Entry<Long, Long> entry : orderDeptMap.entrySet()) {
+            IotOpeationFillRespVO fill1 = new IotOpeationFillRespVO();
+            fill1.setOrderId(entry.getKey());
+            fill1.setDeptId(entry.getValue());
+            devMap.put(entry.getKey(), iotOpeationFillService.devListByOrderId(fill1));
         }
 
         // 4. 将fill数据按订单ID分组

+ 1 - 22
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -307,32 +307,11 @@
         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
-        <!--a.dept_id IN (
-        SELECT id FROM (
-        SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
-        UNION ALL
-        SELECT d2.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id WHERE d1.id = #{deptId}
-        UNION ALL
-        SELECT d3.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id WHERE d1.id = #{deptId}
-        UNION ALL
-        SELECT d4.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id JOIN system_dept d4 ON d4.parent_id = d3.id WHERE d1.id = #{deptId}
-        ) AS dept_hierarchy
-        )
-        AND -->(
+        (
         1=1
         <if test="orderId != null and orderId != ''">
             and  a.order_id = #{orderId}
         </if>
-        <!--<if test="orgName != null and orgName != ''">
-            (
-            a.device_name LIKE CONCAT('%', #{orgName}, '%')
-            OR a.device_code LIKE CONCAT('%', #{orgName}, '%')
-            OR d.user_name LIKE CONCAT('%', #{orgName}, '%')
-            )
-        </if>
-        <if test="orgName == null or orgName == ''">
-            1=1
-        </if>-->
         )
         ORDER BY
         CASE WHEN device_code IS NULL OR device_code = '' THEN 1 ELSE 0 END ASC,