|
@@ -58,6 +58,8 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
IExcelService excelService;
|
|
IExcelService excelService;
|
|
@Autowired
|
|
@Autowired
|
|
IOrderService orderService;
|
|
IOrderService orderService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICameraTypeService cameraTypeService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<Camera> getListByCameraIdList(List<Long> cameraIdList) {
|
|
public List<Camera> getListByCameraIdList(List<Long> cameraIdList) {
|
|
@@ -107,19 +109,36 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
if(StringUtils.isEmpty(wifiName) ){
|
|
if(StringUtils.isEmpty(wifiName) ){
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
}
|
|
}
|
|
- if( !wifiName.contains("_") || !wifiName.contains("4D")){
|
|
|
|
|
|
+ List<CameraType> list = cameraTypeService.list();
|
|
|
|
+ Set<String> wifiNamePrefixList = list.stream().map(CameraType::getWifiNamePrefix).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ if(!wifiName.contains("_")){
|
|
|
|
+ throw new BusinessException(ResultCode.WIFI_NAME_ERROR);
|
|
|
|
+ }
|
|
|
|
+ String[] split = wifiName.split("_");
|
|
|
|
+ String cameraPrefix = split[0] +"_";
|
|
|
|
+ String snCode = split[1];
|
|
|
|
+
|
|
|
|
+ if(!wifiNamePrefixList.contains(cameraPrefix)){
|
|
throw new BusinessException(ResultCode.WIFI_NAME_ERROR);
|
|
throw new BusinessException(ResultCode.WIFI_NAME_ERROR);
|
|
}
|
|
}
|
|
|
|
+ HashMap<String,CameraType> cameraTypeMap = new HashMap<>();
|
|
|
|
+ list.forEach(entity->cameraTypeMap.put(entity.getWifiNamePrefix(),entity));
|
|
|
|
+
|
|
|
|
+ if(cameraTypeMap.get(cameraPrefix) == null){
|
|
|
|
+ throw new BusinessException(ResultCode.WIFI_NAME_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
LambdaQueryWrapper<Camera> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Camera> wrapper = new LambdaQueryWrapper<>();
|
|
- wrapper.eq(Camera::getSnCode,wifiName.split("_")[1]);
|
|
|
|
|
|
+ wrapper.eq(Camera::getSnCode,snCode);
|
|
long count = this.count(wrapper);
|
|
long count = this.count(wrapper);
|
|
if(count > 0){
|
|
if(count > 0){
|
|
throw new BusinessException(ResultCode.WIFI_NAME_REPEAT);
|
|
throw new BusinessException(ResultCode.WIFI_NAME_REPEAT);
|
|
}
|
|
}
|
|
- saveBatchCamera(Collections.singletonList(wifiName));
|
|
|
|
|
|
+ saveBatchCamera(Collections.singletonList(wifiName),cameraTypeMap);
|
|
}
|
|
}
|
|
|
|
|
|
- private Integer saveBatchCamera(List<String> wifiNameList){
|
|
|
|
|
|
+ private Integer saveBatchCamera(List<String> wifiNameList,HashMap<String,CameraType> cameraTypeMap){
|
|
HashSet<String> wifiNameSet = new HashSet<>(wifiNameList);
|
|
HashSet<String> wifiNameSet = new HashSet<>(wifiNameList);
|
|
List<Camera> cameraList = new ArrayList<>();
|
|
List<Camera> cameraList = new ArrayList<>();
|
|
for (String wifiName : wifiNameSet) {
|
|
for (String wifiName : wifiNameSet) {
|
|
@@ -127,6 +146,9 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
if(res.length !=2 || StringUtils.isBlank(res[1])){
|
|
if(res.length !=2 || StringUtils.isBlank(res[1])){
|
|
throw new BusinessException(ResultCode.WIFI_NAME_ERROR);
|
|
throw new BusinessException(ResultCode.WIFI_NAME_ERROR);
|
|
}
|
|
}
|
|
|
|
+ if(cameraTypeMap.get(res[0] +"_") == null){
|
|
|
|
+ throw new BusinessException(ResultCode.WIFI_NAME_ERROR);
|
|
|
|
+ }
|
|
Camera camera = new Camera();
|
|
Camera camera = new Camera();
|
|
camera.setWifiName(wifiName);
|
|
camera.setWifiName(wifiName);
|
|
camera.setSnCode(res[1]);
|
|
camera.setSnCode(res[1]);
|
|
@@ -141,25 +163,23 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
|
|
|
List<CameraDetail> cameraDetailList = new ArrayList<>();
|
|
List<CameraDetail> cameraDetailList = new ArrayList<>();
|
|
for (Camera camera : cameraList) {
|
|
for (Camera camera : cameraList) {
|
|
- String wifiName = camera.getWifiName();
|
|
|
|
- Integer type = CameraTypeEnum.getTypeByWifiNamePrefix(wifiName.substring(0,wifiName.lastIndexOf("_") +1));
|
|
|
|
-
|
|
|
|
CameraDetail cameraDetail = new CameraDetail();
|
|
CameraDetail cameraDetail = new CameraDetail();
|
|
cameraDetail.setAgency(CameraConstant.DEFAULT_AGENT);
|
|
cameraDetail.setAgency(CameraConstant.DEFAULT_AGENT);
|
|
cameraDetail.setCameraId(camera.getId());
|
|
cameraDetail.setCameraId(camera.getId());
|
|
cameraDetail.setCountry(0);//默认中国
|
|
cameraDetail.setCountry(0);//默认中国
|
|
- cameraDetail.setType(type);
|
|
|
|
- if (1 == cameraDetail.getType() || 9 == cameraDetail.getType() || 10 == cameraDetail.getType()){
|
|
|
|
|
|
+ String wifiNamePrix = camera.getWifiName().split("_")[0]+"_";
|
|
|
|
+ CameraType cameraType = cameraTypeMap.get(wifiNamePrix);
|
|
|
|
+ cameraDetail.setType(cameraType.getCameraType());
|
|
|
|
+
|
|
|
|
+ if (1 == cameraDetail.getType() || 9 == cameraDetail.getType() || 10 == cameraDetail.getType() || 11 == cameraDetail.getType()){
|
|
cameraDetail.setTotalSpace(Long.valueOf(Constant.CAMERA_BASE_SPACE_VALUE));
|
|
cameraDetail.setTotalSpace(Long.valueOf(Constant.CAMERA_BASE_SPACE_VALUE));
|
|
cameraDetail.setUsedSpace(0L);
|
|
cameraDetail.setUsedSpace(0L);
|
|
}
|
|
}
|
|
- if(type != 9 && type != 10){
|
|
|
|
- type = type == 0 ? 1: 4;
|
|
|
|
- }
|
|
|
|
if("aws".equals(CacheUtil.uploadType)){
|
|
if("aws".equals(CacheUtil.uploadType)){
|
|
cameraDetail.setCountry(1);//1-国外
|
|
cameraDetail.setCountry(1);//1-国外
|
|
}
|
|
}
|
|
- cameraDetail.setGoodsId(Long.valueOf(type));
|
|
|
|
|
|
+ cameraDetail.setGoodsId(null);
|
|
|
|
+
|
|
if("local".equals(CacheUtil.uploadType)) { //本地版本 ,入库即出库,并且添加无限期会员权限
|
|
if("local".equals(CacheUtil.uploadType)) { //本地版本 ,入库即出库,并且添加无限期会员权限
|
|
cameraDetail.setCountry(2);
|
|
cameraDetail.setCountry(2);
|
|
cameraDetail.setOwn(2);
|
|
cameraDetail.setOwn(2);
|
|
@@ -172,7 +192,12 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
public Integer ins(List<String> wifiNameList){
|
|
public Integer ins(List<String> wifiNameList){
|
|
- List<Integer> errorRow = getErrorRow(wifiNameList);
|
|
|
|
|
|
+ List<CameraType> cameraTypeList = cameraTypeService.list();
|
|
|
|
+ Set<String> wifiNamePrefixList = cameraTypeList.stream().map(CameraType::getWifiNamePrefix).collect(Collectors.toSet());
|
|
|
|
+ List<Integer> errorRow = getErrorRow(wifiNameList,wifiNamePrefixList);
|
|
|
|
+ HashMap<String,CameraType> cameraTypeMap = new HashMap<>();
|
|
|
|
+ cameraTypeList.forEach(entity->cameraTypeMap.put(entity.getWifiNamePrefix(),entity));
|
|
|
|
+
|
|
excelService.toExcelError(errorRow);
|
|
excelService.toExcelError(errorRow);
|
|
List<String> snCodeList = new ArrayList<>();
|
|
List<String> snCodeList = new ArrayList<>();
|
|
for (String wifiName : wifiNameList) {
|
|
for (String wifiName : wifiNameList) {
|
|
@@ -186,12 +211,12 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
List<Integer> errorRow2 = getErrorRow(snCodeList, newList);
|
|
List<Integer> errorRow2 = getErrorRow(snCodeList, newList);
|
|
excelService.toExcelError(errorRow2);
|
|
excelService.toExcelError(errorRow2);
|
|
}
|
|
}
|
|
- return saveBatchCamera(wifiNameList);
|
|
|
|
|
|
+ return saveBatchCamera(wifiNameList,cameraTypeMap);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private List<Integer> getErrorRow(List<String> wifiNameList){
|
|
|
|
|
|
+ private List<Integer> getErrorRow(List<String> wifiNameList,Set<String> wifiNamePrefixList){
|
|
List<Integer> errorIndexList = new ArrayList<>();
|
|
List<Integer> errorIndexList = new ArrayList<>();
|
|
Set<String> wifiNameSet = new HashSet<>();
|
|
Set<String> wifiNameSet = new HashSet<>();
|
|
Integer index = 0;
|
|
Integer index = 0;
|
|
@@ -205,9 +230,16 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
errorIndexList.add(index);
|
|
errorIndexList.add(index);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if( !wifiName.contains("_") || !wifiName.contains("4D")
|
|
|
|
- || !CameraTypeEnum.typePrefixMap.containsKey(wifiName.split("_")[0]+"_")){
|
|
|
|
|
|
+ if(!wifiName.contains("_")){
|
|
errorIndexList.add(index);
|
|
errorIndexList.add(index);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String[] split = wifiName.split("_");
|
|
|
|
+ String cameraPrefix = split[0] +"_";
|
|
|
|
+
|
|
|
|
+ if(!wifiNamePrefixList.contains(cameraPrefix)){
|
|
|
|
+ errorIndexList.add(index);
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
wifiNameSet.add(wifiName);
|
|
wifiNameSet.add(wifiName);
|
|
}
|
|
}
|