|
|
@@ -1,14 +1,18 @@
|
|
|
package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.entity.AgentAudit;
|
|
|
+import com.fdkankan.manage.entity.Camera;
|
|
|
import com.fdkankan.manage.entity.RtkInfo;
|
|
|
import com.fdkankan.manage.entity.SysUser;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.mapper.IRtkInfoMapper;
|
|
|
+import com.fdkankan.manage.service.ICameraService;
|
|
|
import com.fdkankan.manage.service.IRtkInfoService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.manage.service.ISysUserService;
|
|
|
@@ -17,10 +21,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -37,7 +38,8 @@ public class RtkInfoServiceImpl extends ServiceImpl<IRtkInfoMapper, RtkInfo> imp
|
|
|
|
|
|
@Autowired
|
|
|
ISysUserService sysUserService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ ICameraService cameraService;
|
|
|
@Override
|
|
|
public RtkInfo getByRtkSnCode(String rtkSnCode) {
|
|
|
LambdaQueryWrapper<RtkInfo> wrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -104,4 +106,73 @@ public class RtkInfoServiceImpl extends ServiceImpl<IRtkInfoMapper, RtkInfo> imp
|
|
|
wrapper.eq(RtkInfo::getCameraSnCode,cameraSnCode);
|
|
|
return this.getOne(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void activation(RtkInfo rtkInfo) {
|
|
|
+ if(rtkInfo.getId() == null || rtkInfo.getStatus() == null){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ RtkInfo rtkInfo1 = this.getById(rtkInfo.getId());
|
|
|
+ if(rtkInfo1 == null){
|
|
|
+ throw new BusinessException(ResultCode.RECOED_NO_EXITS);
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<RtkInfo> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(RtkInfo::getId,rtkInfo.getId());
|
|
|
+ wrapper.set(RtkInfo::getStatus,rtkInfo.getStatus());
|
|
|
+ this.update(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveOrEditEntity(RtkInfo rtkInfo) {
|
|
|
+ RtkInfo dbRtkInfo = null;
|
|
|
+ RtkInfo dbRtkInfo2 = null;
|
|
|
+ Camera camera = null;
|
|
|
+ if(StringUtils.isNotBlank(rtkInfo.getRtkSnCode())){
|
|
|
+ dbRtkInfo = this.getByRtkSnCode(rtkInfo.getRtkSnCode());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(rtkInfo.getCameraSnCode())){
|
|
|
+ camera = cameraService.getBySnCode(rtkInfo.getCameraSnCode());
|
|
|
+ if(camera == null){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(rtkInfo.getSgRtkSn())){
|
|
|
+ dbRtkInfo2 = this.getSgRtkSn(rtkInfo.getSgRtkSn());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(rtkInfo.getId() == null){
|
|
|
+ if(dbRtkInfo != null){
|
|
|
+ throw new BusinessException(ResultCode.RTK_SN_EXIST);
|
|
|
+ }
|
|
|
+ if(dbRtkInfo2 != null){
|
|
|
+ throw new BusinessException(ResultCode.SGRTK_SN_EXIST);
|
|
|
+ }
|
|
|
+ rtkInfo.setCreateUserId(Long.valueOf((String) StpUtil.getLoginId()));
|
|
|
+ }else {
|
|
|
+ if( dbRtkInfo != null && !Objects.equals(dbRtkInfo.getId(), rtkInfo.getId()) ){
|
|
|
+ throw new BusinessException(ResultCode.RTK_SN_EXIST);
|
|
|
+ }
|
|
|
+ if( dbRtkInfo2 != null && !Objects.equals(dbRtkInfo2.getId(), rtkInfo.getId()) ){
|
|
|
+ throw new BusinessException(ResultCode.SGRTK_SN_EXIST);
|
|
|
+ }
|
|
|
+ rtkInfo.setUpdateUserId(Long.valueOf((String)StpUtil.getLoginId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(rtkInfo.getRtkType() != null && rtkInfo.getRtkType() == 0){
|
|
|
+ rtkInfo.setIpAddr(null);
|
|
|
+ rtkInfo.setMountPoint(null);
|
|
|
+ rtkInfo.setPort(null);
|
|
|
+ rtkInfo.setUserName(null);
|
|
|
+ rtkInfo.setPassword(null);
|
|
|
+ rtkInfo.setOperator(null);
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(rtkInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private RtkInfo getSgRtkSn(String sgRtkSn) {
|
|
|
+ LambdaQueryWrapper<RtkInfo> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(RtkInfo::getSgRtkSn,sgRtkSn);
|
|
|
+ return this.getOne(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
}
|