Browse Source

运行记录填报

yuanchao 2 months ago
parent
commit
8a013b5e08

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

@@ -107,7 +107,7 @@ public class IotOpeationFillController {
             }
         }
         for (IotOpeationFillSaveReqVO totalGas:fillList) {
-            if(totalGas.getPointName().equals("累计注气量")){
+            if(totalGas.getPointName().equals("累计注气量")&&totalGas.getIsCollection()==0){
                 double total = Double.parseDouble(fillContent);
                 totalGas.setTotalRunTime(BigDecimal.valueOf(total).add(totalGas.getTotalRunTime()));
                 break;

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

@@ -49,13 +49,20 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
                 .betweenIfPresent(IotOpeationFillDO::getCreateTime, reqVO.getCreateTime())
                 .orderByDesc(IotOpeationFillDO::getId));
     }
-
+    @TenantIgnore
     List<IotOpeationFillDO> getFillDevices();
+    @TenantIgnore
+    List<IotOpeationFillDO> getFillDevices1(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);
+    @TenantIgnore
+    int upFill(Long[] deviceIds);
+    @TenantIgnore
     List<IotOpeationFillDO> fillListByUserId(IotOpeationFillRespVO vo);
     @TenantIgnore
     List<IotOpeationFillDO> fillListByDeptId(IotOpeationFillRespVO vo);

+ 5 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/IotOperationFillJob.java

@@ -134,12 +134,12 @@ public class IotOperationFillJob implements JobHandler {
         System.out.println("*****************插入运行记录设备表***********************");
         IotOpeationFillPageReqVO vo = new IotOpeationFillPageReqVO();
         List<IotOpeationFillDO> fillList = iotOpeationFillMapper.fillList(vo);
-        if(fillList.size()==0){
-            for (IotOpeationFillDO re:deviceList) {
-                re.setDeviceId(re.getId());
-            }
-            iotOpeationFillMapper.insertFill(deviceList);
+
+        for (IotOpeationFillDO re:deviceList) {
+            re.setDeviceId(re.getId());
         }
+        iotOpeationFillMapper.insertFill(deviceList);
+
 
         System.out.println("*****************插入运行记录设备表完成***********************");
         return "创建成功";

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

@@ -67,6 +67,9 @@ public interface IotOpeationFillService {
     List<IotOpeationFillDO> fillList(IotOpeationFillPageReqVO vo);
 
     List<IotOpeationFillDO> fillListByUserId(IotOpeationFillRespVO vo);
+
+    void syncWordOrderData(List<Long> deviceIds, List<Long> oldDeptIds, Long deptId);
+
     List<IotOpeationFillDO> fillListByDeptId(IotOpeationFillRespVO vo);
     List<IotOpeationFillDO> deviceList(IotOpeationFillRespVO vo);
 

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

@@ -21,6 +21,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -114,6 +117,80 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         return iotOpeationFillMapper.fillListByUserId(vo);
     }
 
+    @Override
+    public void syncWordOrderData(List<Long> deviceIds, List<Long> oldDeptIds, Long deptId) {
+        /**
+         * 1、判断设备
+         */
+        Long[] deviceId = (Long[]) deviceIds.toArray();
+
+        List<IotOpeationFillDO> fills = iotOpeationFillMapper.fills(deviceId);
+        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);
+        }
+    }
+
     @Override
     public List<IotOpeationFillDO> fillListByDeptId(IotOpeationFillRespVO vo) {
         return iotOpeationFillMapper.fillListByDeptId(vo);

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

@@ -30,6 +30,38 @@
     </select>
 
 
+
+    <select id="getFillDevices1"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+
+        select
+            distinct
+            c.id,
+            c.dept_id,
+            c.device_code,
+            c.device_name,
+            b.device_category_id,
+            d.person_id user_id
+        from
+            rqiot.rq_iot_model_template a,
+            rqiot.rq_iot_model_template_attrs b,
+            rqiot.rq_iot_device c,
+            rqiot.rq_iot_device_person d
+        where
+            a.device_category_id = b.device_category_id
+          and
+            a.device_category_id = c.asset_class
+          and
+            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>
+    </select>
+
+
     <insert id="insertFill"
     parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
        insert into rqiot.rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id)
@@ -89,6 +121,24 @@
         </if>
     </select>
 
+    <select id="fills" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        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>
+    </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>
+
 
     <select id="deviceList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">