Browse Source

同步巡检记录时,同步计划任务

459242451@qq.com 3 years ago
parent
commit
452e081d7d

+ 2 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/PlanTask.java

@@ -14,6 +14,7 @@ import org.springframework.stereotype.Component;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @Description: 巡检计划任务
@@ -79,7 +80,7 @@ public class PlanTask {
             }
             if (planRecords.size() > 0) {
                 planRecordService.batchInsert(planRecords);
-                redisCache.setCacheObject("tl:planrecord:" + queryDate, true);
+                redisCache.setCacheObject("tl:planrecord:" + queryDate, true, 2, TimeUnit.DAYS);
             }
         }
 

+ 15 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/XunTask.java

@@ -12,12 +12,14 @@ import com.ruoyi.qdtl.domain.TlInspectionDeviceTrail;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
 import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
 import com.ruoyi.qdtl.domain.TlPatrolman;
+import com.ruoyi.qdtl.domain.TlPlanRecord;
 import com.ruoyi.qdtl.service.IQdCommonService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceTrailService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import com.ruoyi.qdtl.service.ITlPatrolmanService;
+import com.ruoyi.qdtl.service.ITlPlanRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -44,6 +46,8 @@ public class XunTask {
     private ITlInspectionDeviceTrailService tlInspectionDeviceTrailService;
     @Autowired
     private ITlPatrolmanService tlPatrolmanService;
+    @Autowired
+    private ITlPlanRecordService planRecordService;
 
     /**
      * 同步设备列表
@@ -142,6 +146,17 @@ public class XunTask {
                     deviceTrail.setFence(tlInspectionLocation.getLnglat());
                     tlInspectionDeviceTrailService.insertTlInspectionDeviceTrail(deviceTrail);
                 }
+                // 更新到计划中
+                if (StrUtil.isNotBlank(convert.getPatrolmanCard())) {
+                    TlPlanRecord tlPlanRecord = new TlPlanRecord();
+                    tlPlanRecord.setPlanDate(DateUtil.formatDate(convert.getCreateTime()));
+                    tlPlanRecord.setCard(convert.getPatrolmanCard());
+                    tlPlanRecord.setCheckpointCard(convert.getCheckpointCard());
+                    tlPlanRecord.setDeviceCode(convert.getDeviceCode());
+                    tlPlanRecord.setFence(tlInspectionLocation.getLnglat());
+                    tlPlanRecord.setCreateTime(convert.getCreateTime());
+                    planRecordService.updateRecordByDateAndCard(tlPlanRecord);
+                }
             }
         }
     }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlPlanRecordMapper.java

@@ -61,4 +61,6 @@ public interface TlPlanRecordMapper {
     public int deleteTlPlanRecordByIds(Long[] ids);
 
     void batchInsert(@Param("list") List<TlPlanRecord> planRecords);
+
+    void updateRecordByDateAndCard(TlPlanRecord tlPlanRecord);
 }

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlPlanRecordService.java

@@ -60,5 +60,6 @@ public interface ITlPlanRecordService {
     public int deleteTlPlanRecordById(Long id);
 
     void batchInsert(List<TlPlanRecord> planRecords);
-    
+
+    void updateRecordByDateAndCard(TlPlanRecord tlPlanRecord);
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlPlanRecordServiceImpl.java

@@ -91,4 +91,9 @@ public class TlPlanRecordServiceImpl implements ITlPlanRecordService {
     public void batchInsert(List<TlPlanRecord> planRecords) {
         tlPlanRecordMapper.batchInsert(planRecords);
     }
+
+    @Override
+    public void updateRecordByDateAndCard(TlPlanRecord tlPlanRecord) {
+        tlPlanRecordMapper.updateRecordByDateAndCard(tlPlanRecord);
+    }
 }

+ 11 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlPlanRecordMapper.xml

@@ -121,6 +121,17 @@
         where id = #{id}
     </update>
 
+    <update id="updateRecordByDateAndCard">
+        update tl_plan_record
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="checkpointCard != null">checkpoint_card = #{checkpointCard},</if>
+            <if test="deviceCode != null">device_code = #{deviceCode},</if>
+            <if test="fence != null">fence = #{fence},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+        </trim>
+        where plan_date = #{planDate} and card = #{card}
+    </update>
+
     <delete id="deleteTlPlanRecordById" parameterType="Long">
         delete
         from tl_plan_record