From 362ec4c6c00747fb869b97ad3f0f3ce12b3e47aa Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期四, 10 十月 2024 15:15:46 +0800 Subject: [PATCH] 代码初始化 --- server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPlatformsServiceImpl.java | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 40 insertions(+), 12 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 fdefd55..10e2a89 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 @@ -12,13 +12,15 @@ 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.PlatformMapper; import com.doumee.dao.business.model.Device; import com.doumee.dao.business.model.Platform; +import com.doumee.dao.business.model.PlatformDevice; 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.Date; @@ -31,9 +33,10 @@ */ @Service public class HkSyncPlatformsServiceImpl extends HkSyncBaseServiceImpl { - @Autowired private PlatformMapper platformMapper; + @Autowired + private PlatformDeviceMapper platformDeviceMapper; /** * 鍚屾娴峰悍鏈堝彴鏁版嵁 @@ -41,7 +44,7 @@ * @return */ @Override -// @Async + @Transactional public String syncPlatforms(PlatformsListRequest param){ if(Constants.DEALING_HK_SYNCPLATFORM){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鍚屾浠诲姟姝e湪鎵ц鍝︼紝璇风◢鍚庢煡鐪嬬粨鏋滐紒") ; @@ -51,6 +54,7 @@ List<Platform> deleteList = new ArrayList<>(); List<Platform> addList = new ArrayList<>(); List<Platform> editList = new ArrayList<>(); + List<PlatformDevice> deviceList = new ArrayList<>(); Date date = new Date(); //鏌ヨ鍏ㄩ儴闂ㄧ璁惧鏁版嵁 List<Platform> allList = platformMapper.selectList(null); @@ -58,15 +62,15 @@ /** * 鑾峰彇澧炲垹鏀规暟鎹泦鍚� */ - getDataChangeList(allList,allHkList,addList,editList,deleteList,date); + getDataChangeList(allList,allHkList,addList,deviceList,editList,deleteList,date); if(deleteList.size()>0){ //閫昏緫鍒犻櫎 for(Platform d : deleteList){ platformMapper.updateById(d); } } - if(addList.size()>0){ - platformMapper.insert(addList); + if(deviceList.size()>0){ + platformDeviceMapper.insert(deviceList); } if(editList.size()>0){ for(Platform d : editList){ @@ -98,9 +102,9 @@ //鏇存柊鐘舵�� (鏈堝彴鐘舵�� 0-鏃犺溅 1-鏈夎溅 2-瓒呮椂鍋滈潬 3-閿欒鍋滈潬) for(PlatformStatusInfoResponse d : allHkList){ platformMapper.update(null,new UpdateWrapper<Platform>().lambda() - .set(Platform::getStatus,d.getStatus()) + .set(Platform::getPlatformStatus,d.getStatus()) .set(Platform::getEditDate,date) - .eq(Platform::getHkId,d.getPlatformtId())); + .eq(Platform::getHkId,d.getPlatformId())); } } }catch (Exception e){ @@ -144,7 +148,8 @@ } private void getDataChangeList(List<Platform> allList, List<PlatformListInfoResponse> allHkList, - List<Platform> addList, + List<Platform> addList , + List<PlatformDevice> deviceList, List<Platform> editList, List<Platform> deleteList, Date date) { if(allHkList!=null && allHkList.size()>0){ @@ -155,16 +160,41 @@ //濡傛灉宸插瓨鍦紝鍒欐洿鏂版暟鎹� model = initDataByHkData(model,device,date); editList.add(model); + //娓呯┖鐩戞帶鐐规暟鎹� + platformDeviceMapper.delete(new UpdateWrapper<PlatformDevice>().lambda() + .eq(PlatformDevice::getPlatformId,model.getId()) + .eq(PlatformDevice::getType,Constants.ONE) + ); + deviceList.addAll(getCameraList(device.getCameras(),model)); }else{ //濡傛灉涓嶅瓨鍦紝鍒欐柊澧炴暟鎹� model = new Platform(); model = initDataByHkData(model,device,date); + platformMapper.insert(model); addList.add(model); + deviceList.addAll(getCameraList(device.getCameras(),model)); } } } //鍒ゆ柇鑾峰彇鍒犻櫎鐨勯棬绂佽澶囷紝閫昏緫鍒犻櫎 getDeleteList(allList,allHkList,deleteList,date); + } + + private List<PlatformDevice> getCameraList(List<PlatformCameraInfoResponse> cameras, Platform model) { + List<PlatformDevice> list = new ArrayList<>(); + 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.getCameraId()); + d.setName(param.getCameraName()); + d.setType(Constants.ONE); + list.add(d); + } + } + return list; } /** @@ -176,6 +206,7 @@ */ private Platform initDataByHkData(Platform model, PlatformListInfoResponse device,Date date ) { model.setIsdeleted(Constants.ZERO); + model.setCreateDate(date); model.setHkDate(date); model.setHkId(device.getPlatformId()); model.setCreateDate(DateUtil.getISO8601DateByStr(device.getCreateTime())); @@ -189,8 +220,6 @@ model.setRemark(JSONObject.toJSONString(device)); return model; } - - private Platform getExistedDevice(PlatformListInfoResponse device, List<Platform> allList) { if(allList.size()>0){ @@ -225,7 +254,6 @@ } } return true; - } } -- Gitblit v1.9.3