|
@@ -1,4 +1,5 @@
|
|
|
package com.fdkankan.manage.service.impl;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -8,11 +9,9 @@ import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.entity.*;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.mapper.IAuthorizeCameraMapper;
|
|
|
-import com.fdkankan.manage.service.IAuthorizeCameraDetailService;
|
|
|
-import com.fdkankan.manage.service.IAuthorizeCameraLogService;
|
|
|
-import com.fdkankan.manage.service.IAuthorizeCameraService;
|
|
|
+import com.fdkankan.manage.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fdkankan.manage.service.ISysUserService;
|
|
|
+import com.fdkankan.manage.util.CameraUtils;
|
|
|
import com.fdkankan.manage.vo.request.AuthorizeParam;
|
|
|
import com.fdkankan.reg.RegCodeUtil;
|
|
|
import com.fdkankan.reg.dto.CamRegDto;
|
|
@@ -44,6 +43,10 @@ public class AuthorizeCameraServiceImpl extends ServiceImpl<IAuthorizeCameraMapp
|
|
|
IAuthorizeCameraLogService authorizeCameraLogService;
|
|
|
@Autowired
|
|
|
ISysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ ICameraService cameraService;
|
|
|
+ @Autowired
|
|
|
+ ICameraDetailService cameraDetailService;
|
|
|
|
|
|
@Override
|
|
|
public Object pageList(AuthorizeParam param) {
|
|
@@ -78,6 +81,7 @@ public class AuthorizeCameraServiceImpl extends ServiceImpl<IAuthorizeCameraMapp
|
|
|
@Override
|
|
|
public AuthorizeCamera addOrUpdate(AuthorizeCamera param) {
|
|
|
param.setSysUserId(Long.valueOf((String) StpUtil.getLoginId()));
|
|
|
+ HashMap<String,AuthorizeCameraDetail> detailHashMap = new HashMap<>();
|
|
|
if(param.getId() == null){
|
|
|
//获取机器UUID,机器名称
|
|
|
MachineRegDto machineRegDto = RegCodeUtil.ParseMachineCode(param.getMachineCode());
|
|
@@ -96,6 +100,20 @@ public class AuthorizeCameraServiceImpl extends ServiceImpl<IAuthorizeCameraMapp
|
|
|
CamRegDto camRegDto = new CamRegDto();
|
|
|
camRegDto.setSn(snCode);
|
|
|
camRegs.add(camRegDto);
|
|
|
+ Camera camera = cameraService.getBySnCode(snCode);
|
|
|
+ if(camera == null){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_SN_NOT_EXIST);
|
|
|
+ }
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.getByCameraId(camera.getId());
|
|
|
+ if(cameraDetail == null){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_SN_NOT_EXIST);
|
|
|
+ }
|
|
|
+
|
|
|
+ AuthorizeCameraDetail detail = new AuthorizeCameraDetail();
|
|
|
+ detail.setSnCode(snCode);
|
|
|
+ detail.setCameraId(camera.getId());
|
|
|
+ detail.setCameraType(CameraUtils.getCameraType(cameraDetail.getType()));
|
|
|
+ detailHashMap.put(snCode,detail);
|
|
|
}
|
|
|
dtos.setCamRegs(camRegs);
|
|
|
String authorizeKey = RegCodeUtil.batchGenRegeditCamCode(dtos);
|
|
@@ -108,6 +126,16 @@ public class AuthorizeCameraServiceImpl extends ServiceImpl<IAuthorizeCameraMapp
|
|
|
}
|
|
|
}
|
|
|
this.saveOrUpdate(param);
|
|
|
+ if(StringUtils.isNotBlank(param.getSnCodes())){
|
|
|
+ String[] split = param.getSnCodes().split(",");
|
|
|
+ for (String snCode : split) {
|
|
|
+ AuthorizeCameraDetail detail = detailHashMap.get(snCode);
|
|
|
+ if(detail!= null){
|
|
|
+ detail.setAuthorizeCameraId(param.getId());
|
|
|
+ authorizeCameraDetailService.save(detail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return param;
|
|
|
}
|
|
|
|