|
@@ -2,13 +2,18 @@ package com.fdkankan.agent.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.agent.entity.CameraDetail;
|
|
|
+import com.fdkankan.agent.entity.IncrementType;
|
|
|
import com.fdkankan.agent.entity.User;
|
|
|
+import com.fdkankan.agent.entity.UserIncrement;
|
|
|
import com.fdkankan.agent.mapper.ICameraDetailMapper;
|
|
|
import com.fdkankan.agent.mapper.IUserMapper;
|
|
|
import com.fdkankan.agent.service.ICameraDetailService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.agent.service.IIncrementTypeService;
|
|
|
+import com.fdkankan.agent.service.IUserIncrementService;
|
|
|
import com.fdkankan.agent.service.IUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
@@ -28,6 +33,10 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
|
|
|
|
|
|
@Autowired
|
|
|
IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ IIncrementTypeService incrementTypeService;
|
|
|
+ @Autowired
|
|
|
+ IUserIncrementService userIncrementService;
|
|
|
|
|
|
@Override
|
|
|
public List<CameraDetail> getByUserName(Integer agentId,String userName) {
|
|
@@ -63,4 +72,38 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
|
|
|
wrapper.eq(CameraDetail::getAgentId,agentId);
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
+ private String uploadType;
|
|
|
+ @Override
|
|
|
+ public Boolean checkSpace(CameraDetail detailEntity, Long space) {
|
|
|
+ if(!uploadType.contains("eur") && (detailEntity.getType() == 10 || detailEntity.getType() == 11)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ UserIncrement userIncrement = userIncrementService.getByCameraId(detailEntity.getCameraId());
|
|
|
+ if(userIncrement == null || userIncrement.getIsExpired() == 1){
|
|
|
+ return checkSpace(detailEntity,null,space);
|
|
|
+ }
|
|
|
+ IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
+ return checkSpace(detailEntity,incrementType,space);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean checkSpace(CameraDetail detailEntity, IncrementType incrementType, Long space) {
|
|
|
+ Long totalSpace = 0L;
|
|
|
+ if("SP".equals(detailEntity.getUnit())){
|
|
|
+ if(incrementType!=null && incrementType.getCameraSpace() == -1){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ totalSpace = incrementType != null ?incrementType.getCameraSpace() : detailEntity.getTotalSpace();
|
|
|
+ return detailEntity.getUsedSpace() + 1 <= totalSpace;
|
|
|
+ }
|
|
|
+ if("GB".equals(detailEntity.getUnit())){
|
|
|
+ if(incrementType!=null && incrementType.getCameraCapacity() == -1){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ totalSpace = incrementType != null ?incrementType.getCameraCapacity() * 1024 * 1024 * 1024L: detailEntity.getTotalSpace();
|
|
|
+ return detailEntity.getUsedSpace() + space <= totalSpace ;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|