From 17efddc6a667670dca682bf36b51a43e99615e6d Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 16 十月 2024 15:59:38 +0800
Subject: [PATCH] 代码初始化

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPlatformsServiceImpl.java |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPlatformsServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPlatformsServiceImpl.java
index 6fc54ed..ec7fc9d 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPlatformsServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPlatformsServiceImpl.java
@@ -1,6 +1,7 @@
 package com.doumee.service.business.impl.hksync;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
@@ -12,19 +13,19 @@
 import com.doumee.core.haikang.service.HKService;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.DateUtil;
-import com.doumee.dao.business.DeviceMapper;
 import com.doumee.dao.business.PlatformDeviceMapper;
+import com.doumee.dao.business.PlatformJobMapper;
 import com.doumee.dao.business.PlatformMapper;
 import com.doumee.dao.business.model.Device;
 import com.doumee.dao.business.model.Platform;
 import com.doumee.dao.business.model.PlatformDevice;
+import com.doumee.dao.business.model.PlatformJob;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
@@ -35,9 +36,10 @@
  */
 @Service
 public class HkSyncPlatformsServiceImpl extends HkSyncBaseServiceImpl {
-
     @Autowired
     private PlatformMapper platformMapper;
+    @Autowired
+    private PlatformJobMapper platformJobMapper;
     @Autowired
     private PlatformDeviceMapper platformDeviceMapper;
 
@@ -60,7 +62,7 @@
             List<PlatformDevice> deviceList = new ArrayList<>();
             Date date = new Date();
             //鏌ヨ鍏ㄩ儴闂ㄧ璁惧鏁版嵁
-            List<Platform> allList = platformMapper.selectList(null);
+            List<Platform> allList = platformMapper.selectList(new QueryWrapper<Platform>().lambda().eq(Platform::getIsdeleted,Constants.ZERO));
             List<PlatformListInfoResponse> allHkList = getAllHkList(param);
             /**
              * 鑾峰彇澧炲垹鏀规暟鎹泦鍚�
@@ -68,9 +70,24 @@
             getDataChangeList(allList,allHkList,addList,deviceList,editList,deleteList,date);
             if(deleteList.size()>0){
                 //閫昏緫鍒犻櫎
+                List<Integer> platIds = new ArrayList<>();
                 for(Platform d : deleteList){
                     platformMapper.updateById(d);
+                    platIds.add(d.getId());
                 }
+                //鏇存柊鍒犻櫎鐨勬湀鍙颁俊鎭垹姝e湪鎵ц鐨勪綔涓氱姸鎬佷负銆愬緟绛惧埌銆戠姸鎬�
+                platformJobMapper.update(null,  new UpdateWrapper<PlatformJob>().lambda()
+                        .eq(PlatformJob::getIsdeleted,Constants.ZERO)
+                        .notIn(PlatformJob::getStatus,Constants.PlatformJobStatus.WART_SIGN_IN.getKey()
+                                ,Constants.PlatformJobStatus.WAIT_CONFIRM.getKey()
+                                ,Constants.PlatformJobStatus.DONE.getKey()
+                                ,Constants.PlatformJobStatus.LEAVED.getKey()
+                                ,Constants.PlatformJobStatus.CANCEL.getKey() )
+                        .in(PlatformJob::getPlatformId,platIds)
+                        .set(PlatformJob::getPlatformId,null)
+                        .set(PlatformJob::getPlatforms,null)
+                        .set(PlatformJob::getStatus,Constants.PlatformJobStatus.WART_SIGN_IN.getKey())
+                );
             }
             if(deviceList.size()>0){
                 platformDeviceMapper.insert(deviceList);
@@ -165,7 +182,9 @@
                     editList.add(model);
                     //娓呯┖鐩戞帶鐐规暟鎹�
                     platformDeviceMapper.delete(new UpdateWrapper<PlatformDevice>().lambda()
-                            .eq(PlatformDevice::getPlatformId,model.getId()));
+                            .eq(PlatformDevice::getPlatformId,model.getId())
+                            .eq(PlatformDevice::getType,Constants.ONE)
+                    );
                     deviceList.addAll(getCameraList(device.getCameras(),model));
                 }else{
                     //濡傛灉涓嶅瓨鍦紝鍒欐柊澧炴暟鎹�
@@ -183,13 +202,13 @@
 
     private List<PlatformDevice> getCameraList(List<PlatformCameraInfoResponse> cameras, Platform model) {
         List<PlatformDevice> list = new ArrayList<>();
-        if(cameras!=null || cameras.size()>0){
+        if(cameras!=null && cameras.size()>0){
             for(PlatformCameraInfoResponse param :cameras){
                 PlatformDevice d = new PlatformDevice();
                 d.setCreateDate(model.getCreateDate());
                 d.setPlatformId(model.getId());
                 d.setIsdeleted(Constants.ZERO);
-                d.setDeviceId(param.getCameraIdompan());
+                d.setDeviceId(param.getCameraId());
                 d.setName(param.getCameraName());
                 d.setType(Constants.ONE);
                 list.add(d);
@@ -255,7 +274,6 @@
             }
         }
         return  true;
-
     }
 
 }

--
Gitblit v1.9.3