From 2e7ba2bc0fbefa6ee0b44eaf1990a493795efe4a Mon Sep 17 00:00:00 2001
From: lishuai <260038442@qq.com>
Date: 星期二, 26 十二月 2023 16:33:36 +0800
Subject: [PATCH] 导出字段对接调整提交

---
 server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDoorsServiceImpl.java |  108 +++++++++++++++++++++++++++++------------------------
 1 files changed, 59 insertions(+), 49 deletions(-)

diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDoorsServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDoorsServiceImpl.java
index 5ff883d..cd1be6c 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDoorsServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDoorsServiceImpl.java
@@ -7,10 +7,8 @@
 import com.doumee.core.haikang.model.param.BaseResponse;
 import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest;
 import com.doumee.core.haikang.model.param.request.DoorsListRequest;
+import com.doumee.core.haikang.model.param.respose.*;
 import com.doumee.core.haikang.model.param.respose.DoorsInfoResponse;
-import com.doumee.core.haikang.model.param.respose.AcsDeviceListResponse;
-import com.doumee.core.haikang.model.param.respose.DoorsInfoResponse;
-import com.doumee.core.haikang.model.param.respose.DoorsListResponse;
 import com.doumee.core.haikang.service.HKService;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.DateUtil;
@@ -43,56 +41,68 @@
     @Override
 //    @Async
     public String syncDoors(DoorsListRequest param){
-        List<Device> deleteList = new ArrayList<>();
-        List<Device> addList = new ArrayList<>();
-        List<Device> editList = new ArrayList<>();
-        List<DoorsInfoResponse> allHkList = new ArrayList<>();
-        Date date = new Date();
-        //鏌ヨ鍏ㄩ儴闂ㄧ璁惧鏁版嵁
-        List<Device> allList = deviceMapper.selectList(null);
-        boolean hasNext = true;
-        int curTotal = 0;
-        int curPage = 1;
-        while (hasNext){
-            //鍒嗛〉閬嶅巻寰幆鏌ヨ鎵�鏈夐棬绂佽澶囨暟鎹�
-            param = new DoorsListRequest();
-            param.setPageNo(curPage);
-            param.setPageSize(100);
-            BaseResponse<DoorsListResponse> response = HKService.doorSearch(param);
-            if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
-                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝娴峰悍鍚屾鏁版嵁澶辫触~");
-            }
-            DoorsListResponse r = response.getData();
-            curTotal += 100;
-            if(curTotal >= r.getTotal()){
-                hasNext = false;
-            }
-            if(r.getList() == null || r.getList().size()==0){
-                hasNext =false;
-            }else{
-                allHkList.addAll(r.getList());
-            }
-            curPage++;
+        if(Constants.DEALING_HK_SYNCDEVICE){
+            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鍚屾浠诲姟姝e湪鎵ц鍝︼紝璇风◢鍚庢煡鐪嬬粨鏋滐紒") ;
         }
-        /**
-         * 鑾峰彇澧炲垹鏀规暟鎹泦鍚�
-         */
-        getDataChangeList(allList,allHkList,addList,editList,deleteList,date);
-        if(deleteList.size()>0){
-            //閫昏緫鍒犻櫎
-            for(Device d : deleteList){
-                deviceMapper.updateById(d);
+        Constants.DEALING_HK_SYNCDEVICE =true;
+        try {
+            List<Device> deleteList = new ArrayList<>();
+            List<Device> addList = new ArrayList<>();
+            List<Device> editList = new ArrayList<>();
+            List<DoorsInfoResponse> allHkList = new ArrayList<>();
+            Date date = new Date();
+            //鏌ヨ鍏ㄩ儴闂ㄧ璁惧鏁版嵁
+            List<Device> allList = deviceMapper.selectList(null);
+            boolean hasNext = true;
+            int curTotal = 0;
+            int curPage = 1;
+            while (hasNext){
+                //鍒嗛〉閬嶅巻寰幆鏌ヨ鎵�鏈夐棬绂佽澶囨暟鎹�
+                param = new DoorsListRequest();
+                param.setPageNo(curPage);
+                param.setPageSize(100);
+                BaseResponse<DoorsListResponse> response = HKService.doorSearch(param);
+                if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
+                    throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝娴峰悍鍚屾鏁版嵁澶辫触~");
+                }
+                DoorsListResponse r = response.getData();
+                curTotal += 100;
+                if(curTotal >= r.getTotal()){
+                    hasNext = false;
+                }
+                if(r.getList() == null || r.getList().size()==0){
+                    hasNext =false;
+                }else{
+                    allHkList.addAll(r.getList());
+                }
+                curPage++;
             }
-        }
-        if(addList.size()>0){
-            deviceMapper.insertBatchSomeColumn(addList);
-        }
-        if(editList.size()>0){
-            for(Device d : editList){
-                deviceMapper.updateById(d);
+            /**
+             * 鑾峰彇澧炲垹鏀规暟鎹泦鍚�
+             */
+            getDataChangeList(allList,allHkList,addList,editList,deleteList,date);
+            if(deleteList.size()>0){
+                //閫昏緫鍒犻櫎
+                for(Device d : deleteList){
+                    deviceMapper.updateById(d);
+                }
             }
+            if(addList.size()>0){
+                deviceMapper.insertBatchSomeColumn(addList);
+            }
+            if(editList.size()>0){
+                for(Device d : editList){
+                    deviceMapper.updateById(d);
+                }
+            }
+            return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+editList.size()+"銆戞潯锛屽垹闄ゃ��"+deleteList.size()+"銆戞潯";
+        }catch (Exception e){
+            e.printStackTrace();
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "鍚屾澶辫触锛�");
+        }finally {
+            Constants.DEALING_HK_SYNCDEVICE =false;
         }
-        return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+editList.size()+"銆戞潯锛屽垹闄ゃ��"+deleteList.size()+"銆戞潯";
+
     }
 
     private void getDataChangeList(List<Device> allList, List<DoorsInfoResponse> allHkList, List<Device> addList, List<Device> editList,List<Device> deleteList, Date date) {

--
Gitblit v1.9.3