|
|
@@ -1,15 +1,26 @@
|
|
|
package com.yunfeiyun.agmp.iotm.web.service.impl;
|
|
|
|
|
|
+import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.SecurityUtils;
|
|
|
+import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
+import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.TmnBlock;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.TmnLand;
|
|
|
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindStatisticVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindVo;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceBindAddReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceBindListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.mapper.IotDeviceBindMapper;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceBindService;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.ITmnBlockService;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.ITmnLandService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
@@ -19,11 +30,12 @@ public class IotDeviceBindServiceImpl implements IIotDeviceBindService {
|
|
|
@Autowired
|
|
|
private IotDeviceBindMapper iotDeviceBindMapper;
|
|
|
|
|
|
-// @Autowired
|
|
|
-// private ITmnLandService iTmnLandService;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// private ITmnBlockService iTmnBlockService;
|
|
|
+ @Autowired
|
|
|
+ private ITmnLandService iTmnLandService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITmnBlockService iTmnBlockService;
|
|
|
+
|
|
|
// @Autowired
|
|
|
// private FmsBlockMapper fmsBlockMapper;
|
|
|
/**
|
|
|
@@ -57,67 +69,69 @@ public class IotDeviceBindServiceImpl implements IIotDeviceBindService {
|
|
|
String tid = SecurityUtils.getTid();
|
|
|
return iotDeviceBindMapper.selectDeviceBindStatistic(tid);
|
|
|
}
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 绑定设备到基地或地块
|
|
|
-// *
|
|
|
-// * @param iotDeviceBindAddReqVo
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @Override
|
|
|
-// public int iotDeviceBindAdd(IotDeviceBindAddReqVo iotDeviceBindAddReqVo) {
|
|
|
-// List<String> devBidList = iotDeviceBindAddReqVo.getDevBidList();
|
|
|
-// String landId = iotDeviceBindAddReqVo.getLandId();
|
|
|
-// String blockId = iotDeviceBindAddReqVo.getBlockId();
|
|
|
-// HashSet<String> tmnIdLandSet = new HashSet<>();
|
|
|
-// List<TmnLand> tmnLandResultList = iTmnLandService.selectTmnLandByLandId(landId);
|
|
|
-// if(tmnLandResultList != null){
|
|
|
-// for(TmnLand tmn: tmnLandResultList){
|
|
|
-// tmnIdLandSet.add(tmn.getTmnId());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// HashSet<String> tmnIdBlockSet = new HashSet<>();
|
|
|
-// List<TmnBlock> tmnBlockResultList = iTmnBlockService.selectTmnBlockByBlockId(blockId);
|
|
|
-// if(tmnBlockResultList != null){
|
|
|
-// for(TmnBlock tmnB: tmnBlockResultList){
|
|
|
-// tmnIdBlockSet.add(tmnB.getTmnId());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<TmnLand> tmnLandList = new ArrayList<>();
|
|
|
-// List<TmnBlock> tmnBlockList = new ArrayList<>();
|
|
|
-// for(String devBid: devBidList){
|
|
|
-// if(!tmnIdLandSet.contains(devBid)){
|
|
|
-// TmnLand tmnLand = new TmnLand();
|
|
|
-// tmnLand.setTmnlandId(tmnLand.getId());
|
|
|
-// tmnLand.setTmnId(devBid);
|
|
|
-// tmnLand.setLandId(landId);
|
|
|
-// tmnLand.setTmnlandAssigndate(DateUtils.dateTimeNow());
|
|
|
-// tmnLandList.add(tmnLand);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(StringUtils.isNotEmpty(blockId) && !tmnIdBlockSet.contains(devBid)){
|
|
|
-// TmnBlock tmnBlock = new TmnBlock();
|
|
|
-// tmnBlock.setTmnblockId(tmnBlock.getId());
|
|
|
-// tmnBlock.setTmnId(devBid);
|
|
|
-// tmnBlock.setBlockId(blockId);
|
|
|
-// tmnBlock.setTmnblockAssigndate(DateUtils.dateTimeNow());
|
|
|
-// tmnBlockList.add(tmnBlock);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// int status = 0;
|
|
|
-// if(tmnLandList.size() > 0){
|
|
|
-// status = iTmnLandService.insertTmnLandBatch(tmnLandList);
|
|
|
-// }
|
|
|
-// if(tmnBlockList.size() > 0){
|
|
|
-// status = iTmnBlockService.insertTmnBlockBatch(tmnBlockList);
|
|
|
-// }
|
|
|
-// if(status == 0){
|
|
|
-// throw new IotBizException(IotErrorCode.BIND_DEVICE_EXIST);
|
|
|
-// }
|
|
|
-// return status;
|
|
|
-// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绑定设备到基地或地块
|
|
|
+ *
|
|
|
+ * @param iotDeviceBindAddReqVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int iotDeviceBindAdd(IotDeviceBindAddReqVo iotDeviceBindAddReqVo) {
|
|
|
+ List<String> devBidList = iotDeviceBindAddReqVo.getDevBidList();
|
|
|
+ String landId = iotDeviceBindAddReqVo.getLandId();
|
|
|
+ String blockId = iotDeviceBindAddReqVo.getBlockId();
|
|
|
+ HashSet<String> tmnIdLandSet = new HashSet<>();
|
|
|
+ List<TmnLand> tmnLandResultList = iTmnLandService.selectTmnLandByLandId(landId);
|
|
|
+ if(tmnLandResultList != null){
|
|
|
+ for(TmnLand tmn: tmnLandResultList){
|
|
|
+ tmnIdLandSet.add(tmn.getTmnId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ HashSet<String> tmnIdBlockSet = new HashSet<>();
|
|
|
+ List<TmnBlock> tmnBlockResultList = iTmnBlockService.selectTmnBlockByBlockId(blockId);
|
|
|
+ if(tmnBlockResultList != null){
|
|
|
+ for(TmnBlock tmnB: tmnBlockResultList){
|
|
|
+ tmnIdBlockSet.add(tmnB.getTmnId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TmnLand> tmnLandList = new ArrayList<>();
|
|
|
+ List<TmnBlock> tmnBlockList = new ArrayList<>();
|
|
|
+
|
|
|
+ for(String devBid: devBidList){
|
|
|
+ if(!tmnIdLandSet.contains(devBid)){
|
|
|
+ TmnLand tmnLand = new TmnLand();
|
|
|
+ tmnLand.setTmnlandId(tmnLand.getUUId());
|
|
|
+ tmnLand.setTmnId(devBid);
|
|
|
+ tmnLand.setLandId(landId);
|
|
|
+ tmnLand.setTmnlandAssigndate(DateUtils.dateTimeNow());
|
|
|
+ tmnLandList.add(tmnLand);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(blockId) && !tmnIdBlockSet.contains(devBid)){
|
|
|
+ TmnBlock tmnBlock = new TmnBlock();
|
|
|
+ tmnBlock.setTmnblockId(tmnBlock.getUUId());
|
|
|
+ tmnBlock.setTmnId(devBid);
|
|
|
+ tmnBlock.setBlockId(blockId);
|
|
|
+ tmnBlock.setTmnblockAssigndate(DateUtils.dateTimeNow());
|
|
|
+ tmnBlockList.add(tmnBlock);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int status = 0;
|
|
|
+ if(!tmnLandList.isEmpty()){
|
|
|
+ status = iTmnLandService.insertTmnLandBatch(tmnLandList);
|
|
|
+ }
|
|
|
+ if(!tmnBlockList.isEmpty()){
|
|
|
+ status = iTmnBlockService.insertTmnBlockBatch(tmnBlockList);
|
|
|
+ }
|
|
|
+ if(status == 0){
|
|
|
+ throw new IotBizException(IotErrorCode.BIND_DEVICE_EXIST.getCode(), "设备已绑定");
|
|
|
+ }
|
|
|
+ return status;
|
|
|
+ }
|
|
|
+
|
|
|
//
|
|
|
// /**
|
|
|
// * @param iotDeviceBindDelReqVo
|