lipenghui 1 сар өмнө
parent
commit
549485b91e

+ 4 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/inspect/order/IotInspectOrderController.java

@@ -101,6 +101,9 @@ public class IotInspectOrderController {
             IotDeviceDO iotDevice = iotDeviceService.getIotDevice(k);
             OrderDetail orderDetail = new OrderDetail();
             orderDetail.setDeviceId(k);
+            if (CollUtil.isNotEmpty(v)) {
+                orderDetail.setRouteIndex(v.get(0).getRouteIndex());
+            }
             if (Objects.nonNull(iotDevice)) {
                 orderDetail.setDeviceName(iotDevice.getDeviceCode() + iotDevice.getDeviceName());
                 orderDetail.setDeviceCode(iotDevice.getDeviceCode());
@@ -112,7 +115,7 @@ public class IotInspectOrderController {
         if (CollUtil.isEmpty(orderDetails)) {
             throw new ServiceException(ErrorCodeConstant.INSPECT_DEVICE_CHANGE);
         }
-        bean.setDetails(orderDetails);
+        bean.setDetails(orderDetails.stream().sorted(Comparator.comparing(OrderDetail::getRouteIndex)).collect(Collectors.toList()));
         return success(bean);
     }
 

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/inspect/IotInspectOrderServiceImpl.java

@@ -94,6 +94,7 @@ public class IotInspectOrderServiceImpl implements IotInspectOrderService {
         detailDO.setIfNormal("true".equals(ifNormal));
         detailDO.setDescription(description);
         detailDO.setPicUrl(picUrl);
+        detailDO.setUpdateTime(LocalDateTime.now());
         iotInspectOrderDetailMapper.updateById(detailDO);
 
         Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();

+ 23 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotInspectRouteMapper.xml

@@ -10,9 +10,29 @@
      -->
     <select id="getRoute"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectRouteDO">
-        select* from (select * from (select route.route_name, device.device_name, device.id device_id,route.id, route.item_json,route.create_time,device.dept_id, device.device_code from
-        (select * from rqiot.rq_iot_inspect_route where device_id is null and deleted=0) route
-        left join (select * from rqiot.rq_iot_device where deleted=0) device on route.device_classify = device.asset_class)a where a.device_id not in (select device_id from rqiot.rq_iot_inspect_route where device_id is not null)
+        select * from (SELECT
+        r.route_name,
+        r.device_name,
+        d.id as device_id,
+        r.id,
+        r.item_json,
+        r.create_time,
+        d.dept_id,d.device_code
+        FROM
+        rq_iot_inspect_route r
+        LEFT JOIN rq_iot_device d
+        ON d.asset_class IN (
+        SELECT id FROM rq_iot_product_classify
+        WHERE id = r.device_classify OR parent_id = r.device_classify
+        )
+        LEFT JOIN rq_iot_product_classify p
+        ON d.asset_class = p.id
+        WHERE
+        NOT EXISTS (
+        SELECT 1 FROM rq_iot_inspect_route i
+        WHERE i.device_id = d.id
+        )
+        AND d.id IS NOT NULL and r.deleted=0 and d.deleted=0 and p.deleted=0
         union all
         select route_name, device_name, device_id,id,item_json,create_time,dept_id,device_code from rqiot.rq_iot_inspect_route where device_id is not null
         and deleted=0)fin