From 2d34613f07deabbbe7e5065c13eec61cfe2a4dcf Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期一, 22 四月 2024 11:32:11 +0800
Subject: [PATCH] 最新版本
---
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDeviceServiceImpl.java | 64 ++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDeviceServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDeviceServiceImpl.java
index 6cc4b9c..0268516 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDeviceServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDeviceServiceImpl.java
@@ -2,11 +2,14 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.haikang.model.HKConstants;
+import com.doumee.core.haikang.model.param.BaseListPageResponse;
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.AcsDeviceStatusListRequest;
import com.doumee.core.haikang.model.param.request.DoorsListRequest;
import com.doumee.core.haikang.model.param.request.ParkListRequest;
import com.doumee.core.haikang.model.param.respose.*;
@@ -83,6 +86,37 @@
Constants.DEALING_HK_SYNCDEVICE =false;
}
}
+ @Override
+// @Async
+ public void getAscDeviceStatus(){
+ if(Constants.DEALING_HK_SYNCDEVICE_STATUS){
+ return;
+ }
+ Constants.DEALING_HK_SYNCDEVICE_STATUS =true;
+ try {
+ List<Device> editList = new ArrayList<>();
+ Date date = new Date();
+ //鏌ヨ鍏ㄩ儴闂ㄧ璁惧鏁版嵁
+ List<AscDeviceStatusInfoResponse> allHkList = getAllDeviceStatusList();
+
+ if(allHkList.size()>0){
+ //閫昏緫鍒犻櫎
+ for(AscDeviceStatusInfoResponse d : allHkList){
+ deviceMapper.update(null,new UpdateWrapper<Device>().lambda()
+ .set(Device::getOnline,d.getOnline())
+ .set(Device::getIp,d.getIp())
+ .set(Device::getPort,d.getPort())
+ .set(Device::getManufature,d.getManufacturer())
+ .set(Device::getEditDate,date)
+ .eq(Device::getHkId,d.getIndexCode()));
+ }
+ }
+ }catch (Exception e){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "鍚屾璁惧鐘舵�佸け璐ワ紒");
+ }finally {
+ Constants.DEALING_HK_SYNCDEVICE_STATUS =false;
+ }
+ }
private List<AcsDeviceInfoResponse> getAllDeViceList() {
AcsDeviceListRequest param = new AcsDeviceListRequest();
@@ -143,6 +177,35 @@
}
return allDoorList;
}
+ public List<AscDeviceStatusInfoResponse> getAllDeviceStatusList(){
+ List<AscDeviceStatusInfoResponse> allDoorList = new ArrayList<>();
+ Date date = new Date();
+ boolean hasNext = true;
+ int curTotal = 0;
+ int curPage = 1;
+ while (hasNext){
+ //鍒嗛〉閬嶅巻寰幆鏌ヨ鎵�鏈夐棬绂佽澶囨暟鎹�
+ AcsDeviceStatusListRequest param = new AcsDeviceStatusListRequest();
+ param.setPageNo(curPage);
+ param.setPageSize(100);
+ BaseResponse<BaseListPageResponse<AscDeviceStatusInfoResponse>> response = HKService.acsDeviceStatus(param);
+ if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝娴峰悍鍚屾鏁版嵁澶辫触~");
+ }
+ BaseListPageResponse r = response.getData();
+ curTotal += 100;
+ if(curTotal >= r.getTotal()){
+ hasNext = false;
+ }
+ if(r.getList() == null || r.getList().size()==0){
+ hasNext =false;
+ }else{
+ allDoorList.addAll(r.getList());
+ }
+ curPage++;
+ }
+ return allDoorList;
+ }
private void getDataChangeList(List<Device> allList, List<DoorsInfoResponse> hkDoorList , List<AcsDeviceInfoResponse> allHkList, List<Device> addList, List<Device> editList,List<Device> deleteList, Date date) {
if(hkDoorList!=null && hkDoorList.size()>0){
@@ -157,6 +220,7 @@
//濡傛灉涓嶅瓨鍦紝鍒欐柊澧炴暟鎹�
model = new Device();
model = initDoorDataByHkData(model,device,date,allHkList);
+ model.setIsEntrance(Constants.ZERO);
addList.add(model);
}
}
--
Gitblit v1.9.3