|
@@ -268,42 +268,69 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
LambdaQueryWrapper<Camera> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.in(Camera::getSnCode,snCodeList);
|
|
|
List<Camera> cameraList = list(wrapper);
|
|
|
+
|
|
|
+ HashMap<String,Camera> dbCamera =new HashMap<>();
|
|
|
+ HashMap<String,CameraDetail> dbCameraDetail =new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
List<String> inSnCodeList = new ArrayList<>();
|
|
|
if(cameraList.size() >0){
|
|
|
- inSnCodeList = cameraList.parallelStream().map(Camera::getSnCode).collect(Collectors.toList());
|
|
|
+ List<Long> cameraIdList = cameraList.stream().map(Camera::getId).collect(Collectors.toList());
|
|
|
+ HashMap<Long,CameraDetail> detailHashMap = cameraDetailService.getByCameraIds(cameraIdList);
|
|
|
+ for (Camera camera: cameraList) {
|
|
|
+ if(detailHashMap.get(camera.getId())!=null && detailHashMap.get(camera.getId()).getUserId() == null){
|
|
|
+ dbCamera.put(camera.getSnCode(),camera);
|
|
|
+ dbCameraDetail.put(camera.getSnCode(),detailHashMap.get(camera.getId()));
|
|
|
+ }else {
|
|
|
+ inSnCodeList.add(camera.getSnCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
for (String snCode : snCodeList) {
|
|
|
if(inSnCodeList.contains(snCode)){
|
|
|
continue;
|
|
|
}
|
|
|
- Camera camera = new Camera();
|
|
|
- camera.setWifiName(CameraTypeEnum.DOUBLE_EYE_TURN.getWifiNamePrefix() + snCode);
|
|
|
- camera.setSnCode(snCode);
|
|
|
- camera.setChildName(snCode);
|
|
|
- camera.setWifiPassword(AgentConstant.WIFI_PASSWORD_VALUE);
|
|
|
- camera.setChildPassword(AgentConstant.CHILD_PASSWORD_VALUE);
|
|
|
- camera.setActivatedTime(DateUtil.date2String(new Date(),null));
|
|
|
- camera.setRecStatus("A");
|
|
|
- camera.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
- camera.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
- save(camera);
|
|
|
-
|
|
|
- CameraDetail detailEntity = new CameraDetail();
|
|
|
- detailEntity.setCameraId(camera.getId());
|
|
|
- detailEntity.setAgency(AgentConstant.DEFAULT_AGENT);
|
|
|
- detailEntity.setCountry(0);//默认中国
|
|
|
- detailEntity.setType(CameraTypeEnum.DOUBLE_EYE_TURN.getType());
|
|
|
- //商品类型,type:1为8目,type:2为双目 3:为转台
|
|
|
- detailEntity.setGoodsId((long) CameraTypeEnum.DOUBLE_EYE_TURN.getType());
|
|
|
- detailEntity.setTotalSpace(Long.parseLong(Constant.CAMERA_BASE_SPACE_VALUE) * 10);
|
|
|
- detailEntity.setUsedSpace(0L);
|
|
|
- detailEntity.setRecStatus("A");
|
|
|
- detailEntity.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
- detailEntity.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
- detailEntity.setLastRequestTime(new Date());
|
|
|
- detailEntity.setOrderSn("");
|
|
|
- detailEntity.setOwn(0);
|
|
|
- cameraDetailService.save(detailEntity);
|
|
|
+
|
|
|
+ Camera camera = dbCamera.get(snCode);
|
|
|
+ if(camera == null){
|
|
|
+ camera = new Camera();
|
|
|
+ camera.setWifiName(CameraTypeEnum.DOUBLE_EYE_TURN.getWifiNamePrefix() + snCode);
|
|
|
+ camera.setSnCode(snCode);
|
|
|
+ camera.setChildName(snCode);
|
|
|
+ camera.setWifiPassword(AgentConstant.WIFI_PASSWORD_VALUE);
|
|
|
+ camera.setChildPassword(AgentConstant.CHILD_PASSWORD_VALUE);
|
|
|
+ camera.setActivatedTime(DateUtil.date2String(new Date(),null));
|
|
|
+ camera.setRecStatus("A");
|
|
|
+ camera.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
+ camera.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
+ save(camera);
|
|
|
+ }
|
|
|
+
|
|
|
+ CameraDetail detailEntity = dbCameraDetail.get(snCode);
|
|
|
+ if(detailEntity == null){
|
|
|
+ detailEntity = new CameraDetail();
|
|
|
+ detailEntity.setCameraId(camera.getId());
|
|
|
+ detailEntity.setAgency(AgentConstant.DEFAULT_AGENT);
|
|
|
+ detailEntity.setCountry(0);//默认中国
|
|
|
+ detailEntity.setType(CameraTypeEnum.DOUBLE_EYE_TURN.getType());
|
|
|
+ //商品类型,type:1为8目,type:2为双目 3:为转台
|
|
|
+ detailEntity.setGoodsId((long) CameraTypeEnum.DOUBLE_EYE_TURN.getType());
|
|
|
+ detailEntity.setTotalSpace(Long.parseLong(Constant.CAMERA_BASE_SPACE_VALUE) * 10);
|
|
|
+ detailEntity.setUsedSpace(0L);
|
|
|
+ detailEntity.setRecStatus("A");
|
|
|
+ detailEntity.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
+ detailEntity.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
+ detailEntity.setLastRequestTime(new Date());
|
|
|
+ detailEntity.setOrderSn("");
|
|
|
+ detailEntity.setOwn(0);
|
|
|
+ cameraDetailService.save(detailEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
UserIncrement userIncrement = new UserIncrement();
|
|
|
userIncrement.setCameraId(camera.getId());
|
|
@@ -316,7 +343,7 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
userIncrement.setRecStatus("A");
|
|
|
userIncrement.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
userIncrement.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
- userIncrementService.save(userIncrement);
|
|
|
+
|
|
|
List<IncrementType> list = incrementTypeService.list();
|
|
|
if(list == null || list.size() <=0){
|
|
|
IncrementType incrementType = incrementTypeService.initIncrementType();
|
|
@@ -324,6 +351,8 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
}else {
|
|
|
userIncrement.setIncrementTypeId(list.get(0).getId());
|
|
|
}
|
|
|
+ userIncrementService.save(userIncrement);
|
|
|
+ sceneProService.lockOrUnLockBySpace(detailEntity,camera.getId(),1);
|
|
|
}
|
|
|
return inSnCodeList;
|
|
|
}
|