|
|
@@ -14,6 +14,7 @@ import com.fdkankan.common.util.DateUtil;
|
|
|
import com.fdkankan.manage.mapper.IUserIncrementMapper;
|
|
|
import com.fdkankan.manage.service.*;
|
|
|
import com.fdkankan.manage.util.DateUtils;
|
|
|
+import com.fdkankan.manage.vo.request.IncrementBindCameraParam;
|
|
|
import com.fdkankan.manage.vo.request.UserIncrementParam;
|
|
|
import com.fdkankan.manage.vo.response.GroupByCount;
|
|
|
import com.fdkankan.manage.vo.response.UserIncrementVo;
|
|
|
@@ -252,13 +253,11 @@ public class UserIncrementServiceImpl extends ServiceImpl<IUserIncrementMapper,
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
- IUserIncrementService userIncrementService;
|
|
|
|
|
|
public DateTime getDateTime(IncrementType incrementType, Long userIncrementId,Integer count) {
|
|
|
Date userTime = new Date();
|
|
|
if(userIncrementId != null){
|
|
|
- UserIncrement userIncrement = userIncrementService.getById(userIncrementId);
|
|
|
+ UserIncrement userIncrement = this.getById(userIncrementId);
|
|
|
userTime = DateUtils.getDate(userIncrement.getIncrementEndTime());
|
|
|
}
|
|
|
return DateUtils.getDateTime(userTime, incrementType,count);
|
|
|
@@ -311,4 +310,62 @@ public class UserIncrementServiceImpl extends ServiceImpl<IUserIncrementMapper,
|
|
|
wrapper.like(UserIncrement::getOrderSn,orderSn);
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void incrementBindCamera(IncrementBindCameraParam userParam) {
|
|
|
+ Long cameraId = checkIncrementCamera(userParam);
|
|
|
+ UserIncrement userIncrementByCam = this.getByCameraId(cameraId);
|
|
|
+ if(userIncrementByCam != null ){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_BIND_CAMERA_ERROR);
|
|
|
+ }
|
|
|
+ UserIncrement userIncrement = this.getById(userParam.getIncrementId());
|
|
|
+ if(userIncrement == null || userIncrement.getIsExpired() !=0 || StringUtils.isEmpty(userIncrement.getIncrementEndTime())){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_BIND_ERROR);
|
|
|
+ }
|
|
|
+ Date date = DateUtil.string2Date(userIncrement.getIncrementEndTime(), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ if(date.getTime() <= new Date().getTime()){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_BIND_ERROR);
|
|
|
+ }
|
|
|
+ if(userIncrement.getCameraId() != null){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_BIND_ERROR2);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<UserIncrement> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(UserIncrement::getId,userParam.getIncrementId());
|
|
|
+ wrapper.set(UserIncrement::getCameraId,cameraId);
|
|
|
+ this.update(wrapper);
|
|
|
+ sceneProService.lockOrUnLockBySpace(cameraId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void incrementUnBindCamera(IncrementBindCameraParam userParam) {
|
|
|
+ Long cameraId = checkIncrementCamera(userParam);
|
|
|
+ UserIncrement userIncrementByCam = this.getByCameraId(cameraId);
|
|
|
+ if(userIncrementByCam == null ){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_UNBIND_CAMERA_ERROR);
|
|
|
+ }
|
|
|
+ UserIncrement userIncrement = this.getById(userParam.getIncrementId());
|
|
|
+ if(userIncrement == null ){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_BIND_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<UserIncrement> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(UserIncrement::getId,userParam.getIncrementId());
|
|
|
+ wrapper.set(UserIncrement::getCameraId,null);
|
|
|
+ this.update(wrapper);
|
|
|
+ sceneProService.lockOrUnLockBySpace(cameraId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long checkIncrementCamera(IncrementBindCameraParam userParam){
|
|
|
+ if(StringUtils.isEmpty(userParam.getSnCode()) || userParam.getIncrementId() == null ){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ Camera camera = cameraService.getBySnCode(userParam.getSnCode());
|
|
|
+ if(camera == null){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
+ }
|
|
|
+
|
|
|
+ return camera.getId();
|
|
|
+ }
|
|
|
}
|