Jelajahi Sumber

设备调拨

yuanchao 2 bulan lalu
induk
melakukan
1db33d29ff

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

@@ -53,16 +53,16 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
     @TenantIgnore
     List<IotOpeationFillDO> getFillDevices();
     @TenantIgnore
-    List<IotOpeationFillDO> getFillDevices1(Long[] deviceIds);
+    List<IotOpeationFillDO> getFillDevices1(@Param("deviceIds") List<Long> deviceIds);
     List<IotModelTemplateAttrsDO> getAttrsById(IotModelTemplateAttrsRespVO vo);
     int insertFill(List<IotOpeationFillDO> vo);
     int insertFillOrder(List<IotOpeationFillDO> vo);
     @TenantIgnore
     List<IotOpeationFillDO> fillList(IotOpeationFillPageReqVO vo);
     @TenantIgnore
-    List<IotOpeationFillDO> fills(Long[] deviceIds);
+    List<IotOpeationFillDO> fills(@Param("deviceIds")List<Long> deviceIds);
     @TenantIgnore
-    int upFill(Long[] deviceIds);
+    int upFill(@Param("deptId")Long deptId,@Param("deviceIds")List<Long> deviceIds);
     @TenantIgnore
     List<IotOpeationFillDO> fillListByUserId(IotOpeationFillRespVO vo);
     @TenantIgnore

+ 3 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/failure/IotFailureReportServiceImpl.java

@@ -234,7 +234,9 @@ public class IotFailureReportServiceImpl implements IotFailureReportService {
         failureReportDOS.forEach(failureReport -> {
             failureReport.setDeptId(deptId);
         });
-        iotFailureReportMapper.updateBatch(failureReportDOS);
+        if(failureReportDOS.size()>0){
+            iotFailureReportMapper.updateBatch(failureReportDOS);
+        }
     }
 
 }

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

@@ -127,72 +127,10 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         /**
          * 1、判断设备
          */
-        Long[] deviceId = (Long[]) deviceIds.toArray();
 
-        List<IotOpeationFillDO> fills = iotOpeationFillMapper.fills(deviceId);
+        List<IotOpeationFillDO> fills = iotOpeationFillMapper.fills(deviceIds);
         if(fills.size()>0){
-            iotOpeationFillMapper.upFill(deviceId);
-        }
-
-        List<IotOpeationFillDO> fillDOS = iotOpeationFillMapper.getFillDevices1(deviceId);
-        List<IotOpeationFillDO> rhList = iotOpeationFillMapper.rhList();
-        List<IotOpeationFillDO> rdList = iotOpeationFillMapper.rdList();
-        List<IotOpeationFillDO> ryList = iotOpeationFillMapper.ryList();
-        List<IotOpeationFillOrderDO> orderList = new ArrayList<>();
-
-        if(fillDOS.size()>0){
-
-            for (IotOpeationFillDO fillDO:fillDOS) {
-
-                IotOpeationFillOrderDO fill = new IotOpeationFillOrderDO();
-
-                boolean exists = rhList.stream()
-                        .anyMatch(rh -> rh.getId().equals(fillDO.getDeptId()));
-                if(exists){
-                    fillDO.setOrderName("瑞恒兴域"+ LocalDate.now()+"运行记录填报");
-                    fillDO.setDeptId(fillDO.getDeptId());
-                    fillDO.setOrderStatus(0);
-                    fillDO.setCreateTime(LocalDateTime.now());
-                    fillDO.setUserName(fillDO.getUserName());
-                    fillDO.setUserId(fillDO.getUserId());
-                    orderList.add(fill);
-                }
-
-                boolean exists1 = rdList.stream()
-                        .anyMatch(rd -> rd.getId().equals(fillDO.getDeptId()));
-
-                if(exists1){
-                    fillDO.setOrderName("瑞都石油"+LocalDate.now()+"运行记录填报");
-                    fillDO.setDeptId(fillDO.getDeptId());
-                    fillDO.setOrderStatus(0);
-                    fillDO.setCreateTime(LocalDateTime.now());
-                    fillDO.setUserName(fillDO.getUserName());
-                    fillDO.setUserId(fillDO.getUserId());
-                    orderList.add(fill);
-                }
-
-                boolean exists2 = ryList.stream()
-                        .anyMatch(ry -> ry.getId().equals(fillDO.getDeptId()));
-
-                if(exists2){
-                    fillDO.setOrderName("瑞鹰国际"+LocalDate.now()+"运行记录填报");
-                    fillDO.setDeptId(fillDO.getDeptId());
-                    fillDO.setOrderStatus(0);
-                    fillDO.setCreateTime(LocalDateTime.now());
-                    fillDO.setUserName(fillDO.getUserName());
-                    fillDO.setUserId(fillDO.getUserId());
-                    orderList.add(fill);
-                }
-            }
-
-            iotOpeationFillOrderMapper.insertBatch(orderList);
-
-            for (IotOpeationFillDO device:fillDOS) {
-                for (IotOpeationFillOrderDO order:orderList) {
-                    device.setOrderId(order.getId());
-                }
-            }
-            iotOpeationFillMapper.insertFill(fillDOS);
+            iotOpeationFillMapper.upFill(deptId,deviceIds);
         }
     }
 

+ 5 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/maintain/IotMaintainServiceImpl.java

@@ -376,8 +376,11 @@ public class IotMaintainServiceImpl implements IotMaintainService {
     @Override
     public void syncWordOrderData(List<Long> deviceIds, Long deptId) {
         List<IotMaintainDO> maintainDOS = iotMaintainMapper.selectByStatusAndAuditStatusAndDeviceId("finished", 20, deviceIds);
-        maintainDOS.forEach(maintainDO -> maintainDO.setDeptId(deptId));
-        iotMaintainMapper.updateBatch(maintainDOS);
+        if(maintainDOS.size()>0){
+            maintainDOS.forEach(maintainDO -> maintainDO.setDeptId(deptId));
+            iotMaintainMapper.updateBatch(maintainDOS);
+        }
+
     }
 
 

+ 29 - 18
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -59,10 +59,12 @@
             c.id = d.device_id
           and
             c.device_status in ('sg','dm')
-          and c.device_id in
-        <foreach item="deviceId" collection="array" open="(" separator="," close=")">
-            #{deviceId}
-        </foreach>
+        <if test="deviceIds != null and !deviceIds.isEmpty()">
+            and c.id in
+            <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
     </select>
 
 
@@ -130,17 +132,22 @@
         SELECT * FROM
         rqiot.rq_iot_opeation_fill
         WHERE 1=1
-        and c.device_id in
-        <foreach item="deviceId" collection="array" open="(" separator="," close=")">
-            #{deviceId}
-        </foreach>
+        <if test="deviceIds != null and !deviceIds.isEmpty()">
+            and device_id  in
+            <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
     </select>
 
     <update id="upFill" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
-        update rqiot.rq_iot_opeation_fill set dept_id = #{deptId} where device_id in
-        <foreach item="id" collection="array" open="(" separator="," close=")">
-            #{deviceId}
-        </foreach>
+        update rqiot.rq_iot_opeation_fill set dept_id = #{deptId} where 1=1
+        <if test="deviceIds != null and !deviceIds.isEmpty()">
+            and device_id  in
+            <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
     </update>
 
 
@@ -152,19 +159,23 @@
 
     <select id="fillListByUserId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
-        select
+            select
             distinct
             a.*,
             b.name org_name
-        from
+            from
             rq_iot_opeation_fill a,
             system_dept b,
-            rqiot.rq_iot_model_template_attrs c
-        where
+            rqiot.rq_iot_model_template_attrs c,
+            rq_iot_opeation_fill_order d
+            where
             a.dept_id = b.id
-          and
+            and
             a.device_category_id = c.device_category_id
-
+            and
+            a.order_id = d.id
+            and
+            a.dept_id = d.dept_id
             <if test="orderId != null  and orderId != ''">
                 and a.order_id = #{orderId}
             </if>