Переглянути джерело

Merge branch 'test-20240704-xwj' into projects/sd

# Conflicts:
#	src/main/java/com/fdkankan/manage/inner/controller/InnerController.java
lyhzzz 1 рік тому
батько
коміт
4b904268f7

+ 2 - 1
src/main/java/com/fdkankan/manage/common/ResultCode.java

@@ -95,7 +95,8 @@ public enum ResultCode  {
     RTK_SN_EXIST(50074, "板卡SN码已存在"),
     CAMERA_SN_EXIST(50075, "相机SN码已存在"),
     LASER_VIEW_ERROR(50076, "激光系统访问失败"),
-
+    RTK_SN_CODE_NOT_AC(50077, "板卡SN码未激活"),
+    SGRTK_SN_EXIST(50078, "深光插件sn已存在"),
 
     ;
 

+ 8 - 34
src/main/java/com/fdkankan/manage/controller/RtkInfoController.java

@@ -33,8 +33,7 @@ public class RtkInfoController {
 
     @Autowired
     IRtkInfoService rtkInfoService;
-    @Autowired
-    ICameraService cameraService;
+
 
     @PostMapping("/list")
     public ResultData list(@RequestBody RtkInfoParam param){
@@ -43,38 +42,7 @@ public class RtkInfoController {
 
     @PostMapping("/saveOrEdit")
     public ResultData saveOrEdit(@RequestBody RtkInfo rtkInfo){
-        if(StringUtils.isNotBlank(rtkInfo.getRtkSnCode())){
-            RtkInfo dbRtkInfo = rtkInfoService.getByRtkSnCode(rtkInfo.getRtkSnCode());
-            if(rtkInfo.getId() == null){
-                if(dbRtkInfo != null){
-                    throw new BusinessException(ResultCode.RTK_SN_EXIST);
-                }
-            }else {
-                if( dbRtkInfo != null && !Objects.equals(dbRtkInfo.getId(), rtkInfo.getId()) ){
-                    throw new BusinessException(ResultCode.RTK_SN_EXIST);
-                }
-            }
-        }
-        if(rtkInfo.getId() == null){
-            rtkInfo.setCreateUserId(Long.valueOf((String)StpUtil.getLoginId()));
-        }else {
-            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);
-        }
-        if(StringUtils.isNotBlank(rtkInfo.getCameraSnCode())){
-            Camera camera = cameraService.getBySnCode(rtkInfo.getCameraSnCode());
-            if(camera == null){
-                throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
-            }
-        }
-        rtkInfoService.saveOrEdit(rtkInfo);
+        rtkInfoService.saveOrEditEntity(rtkInfo);
         return ResultData.ok();
     }
 
@@ -83,5 +51,11 @@ public class RtkInfoController {
         rtkInfoService.del(rtkInfo);
         return ResultData.ok();
     }
+
+    @PostMapping("/activation")
+    public ResultData activation(@RequestBody RtkInfo rtkInfo){
+        rtkInfoService.activation(rtkInfo);
+        return ResultData.ok();
+    }
 }
 

+ 34 - 0
src/main/java/com/fdkankan/manage/inner/controller/InnerController.java

@@ -8,7 +8,11 @@ import com.fdkankan.manage.common.ResultCode;
 import com.fdkankan.manage.common.ResultData;
 import com.fdkankan.manage.controller.BaseController;
 import com.fdkankan.manage.entity.RtkInfo;
+import com.fdkankan.manage.entity.ScenePlus;
+import com.fdkankan.manage.entity.ScenePlusExt;
+import com.fdkankan.manage.entity.ScenePro;
 import com.fdkankan.manage.exception.BusinessException;
+import com.fdkankan.manage.service.*;
 import com.fdkankan.manage.httpClient.service.OverallService;
 import com.fdkankan.manage.httpClient.vo.OverallParam;
 import com.fdkankan.manage.service.ICommonService;
@@ -17,6 +21,7 @@ import com.fdkankan.manage.service.ISceneProService;
 import com.fdkankan.manage.service.IServiceUpTipService;
 import com.fdkankan.manage.util.RsaUtils;
 import com.fdkankan.manage.vo.request.SceneParam;
+import com.fdkankan.manage.vo.response.BuildSceneVO;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -40,6 +45,14 @@ public class InnerController extends BaseController {
     private ISceneProService sceneProService;
     @Autowired
     IServiceUpTipService serviceUpTipService;
+    @Autowired
+    IScenePlusService scenePlusService;
+    @Autowired
+    IScenePlusExtService scenePlusExtService;
+
+    @Autowired
+    IDataService dataService;
+
 
     @PostMapping("/move")
     public ResultData move(@RequestBody SceneParam param){
@@ -53,6 +66,17 @@ public class InnerController extends BaseController {
         sceneProService.move(param);
         return ResultData.ok();
     }
+    @GetMapping("/copyScene")
+    public ResultData copyScene(@RequestParam(required = false) String num){
+        if(!checkSign()){
+            return ResultData.error(-1,"签名错误");
+        }
+        if(StringUtils.isEmpty(num)){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        sceneProService.copy(num);
+        return ResultData.ok();
+    }
 
     @GetMapping("/getServiceUpTip")
     public ResultData getServiceUpTip(@RequestParam(required = false) Integer type){
@@ -96,6 +120,9 @@ public class InnerController extends BaseController {
         if(rtkInfo == null){
             throw new BusinessException(ResultCode.RTK_SN_CODE_NOT_EXIT);
         }
+//        if(rtkInfo.getStatus() == 0){
+//            throw new BusinessException(ResultCode.RTK_SN_CODE_NOT_AC);
+//        }
         return ResultData.ok(rtkInfo);
     }
 
@@ -110,4 +137,11 @@ public class InnerController extends BaseController {
         }
         return overallService.cameraSceneList(param);
     }
+
+
+    @GetMapping("/getSceneProgress")
+    public ResultData getSceneProgress(@RequestParam(required = false) String num){
+        BuildSceneVO progress=sceneProService.getSceneProgress(num);
+        return ResultData.ok(progress);
+    }
 }

+ 4 - 0
src/main/java/com/fdkankan/manage/service/IRtkInfoService.java

@@ -23,4 +23,8 @@ public interface IRtkInfoService extends IService<RtkInfo> {
     void del(RtkInfo rtkInfo);
 
     RtkInfo getByCameraSnCode(String cameraSnCode);
+
+    void activation(RtkInfo rtkInfo);
+
+    void saveOrEditEntity(RtkInfo rtkInfo);
 }

+ 4 - 1
src/main/java/com/fdkankan/manage/service/ISceneProService.java

@@ -6,6 +6,7 @@ import com.fdkankan.manage.entity.ScenePlus;
 import com.fdkankan.manage.entity.ScenePro;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.manage.vo.request.SceneParam;
+import com.fdkankan.manage.vo.response.BuildSceneVO;
 import com.fdkankan.manage.vo.response.GroupByCount;
 
 import java.util.HashMap;
@@ -37,7 +38,7 @@ public interface ISceneProService extends IService<ScenePro> {
 
     Integer move(SceneParam param);
 
-    void copy(String num) throws Exception;
+    void copy(String num) ;
 
     void deleteByNum(String num);
 
@@ -63,4 +64,6 @@ public interface ISceneProService extends IService<ScenePro> {
     Object getRestStoreProcess(String num);
 
     void restStoreSuccess(String num);
+
+    BuildSceneVO getSceneProgress(String num);
 }

+ 6 - 0
src/main/java/com/fdkankan/manage/service/impl/CameraServiceImpl.java

@@ -372,6 +372,12 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
             }
             cameraDetails.add(cameraDetail);
         }
+        List<Long> cameraIds = cameraDetails.stream().map(CameraDetail::getCameraId).collect(Collectors.toList());
+        if(!cameraIds.isEmpty()){
+            HashMap<String,Object> map = new HashMap<>();
+            map.put("cameraIds",cameraIds);
+            rabbitMqProducer.sendByWorkQueue("camera-update-agent",map);
+        }
         return cameraDetailService.saveOrUpdateBatch(cameraDetails) ? cameraDetails.size() : 0;
     }
 

+ 1 - 1
src/main/java/com/fdkankan/manage/service/impl/DownService.java

@@ -107,7 +107,7 @@ public class DownService implements IDownService {
             if(!redisUtil.hasKey(redisKey) || StringUtils.isBlank(redisUtil.get(redisKey))){
                 SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
                 if(sceneEditInfo == null){
-                    throw new com.fdkankan.common.exception.BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
+                    throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
                 }
                 version = sceneEditInfo.getVersion();
             }else {

+ 76 - 5
src/main/java/com/fdkankan/manage/service/impl/RtkInfoServiceImpl.java

@@ -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);
+    }
+
 }

+ 64 - 2
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -3,6 +3,9 @@ package com.fdkankan.manage.service.impl;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.file.FileReader;
+import cn.hutool.core.util.NumberUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -38,6 +41,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -105,7 +109,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     IMqSendLogService mqSendLogService;
     @Autowired
     OverallService overallService;
-
+    @Autowired
+    private ISceneProService sceneProService;
 
     @Override
     public ScenePro getByNum(String num) {
@@ -565,7 +570,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     }
 
     @Override
-    public void copy(String sceneNum) throws Exception {
+    public void copy(String sceneNum)  {
         ScenePro scenePro = this.getByNum(sceneNum);
         ScenePlus scenePlus = scenePlusService.getByNum(sceneNum);
         if((scenePro == null || scenePro.getCameraId() == null ) && (scenePlus== null || scenePlus.getCameraId() == null)){
@@ -925,4 +930,61 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         wrapper.in(ScenePro::getStatus,0,-2);
         return this.count(wrapper);
     }
+
+    @Override
+    public BuildSceneVO getSceneProgress(String num) {
+        //V3
+        ScenePro scenePro = sceneProService.getByNum(num);
+        //V4
+        ScenePlus plus = scenePlusService.getByNum(num);
+        if(scenePro == null && plus == null){
+            throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
+        }
+        String dataSource ="";
+        Integer sceneStatus =null;
+        if (ObjectUtil.isNotNull(plus)){
+            ScenePlus scenePlus = scenePlusService.getByNum(num);
+            sceneStatus = scenePlus.getSceneStatus();
+            //=-2 =0计算中 -1=失败
+            ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
+            if (ObjectUtil.isNotNull(scenePlus)){
+                dataSource=scenePlusExt.getDataSource();
+            }
+        }else {
+              dataSource = scenePro.getDataSource();
+            sceneStatus = scenePro.getStatus();
+        }
+        BuildSceneVO buildSceneVO = new BuildSceneVO();
+        //=-2 =0计算中 -1=失败
+        if (sceneStatus == 0){
+            //去目录检查project.json
+            File projectJson = FileUtil.file(dataSource + File.separator + "project.json");
+            if (FileUtil.exist(projectJson)) {
+                FileReader reader = new FileReader(projectJson);
+                String data = reader.readString();
+                JSONObject data_project = JSONObject.parseObject(data);
+                if (data_project.containsKey("progress")) {
+                    JSONObject state = data_project.getJSONObject("state");
+                    Double progress = state.getDouble("progress");
+                    if (ObjectUtil.isNotNull(progress)) {
+                        if (progress == 1){
+                            buildSceneVO.setProgress(90);
+                        }else {
+                            progress = NumberUtil.mul(progress, new Double(100.00));
+                            buildSceneVO.setProgress(progress.intValue());
+                        }
+                    }
+                }else {
+                    buildSceneVO.setProgress(0);
+                }
+            }
+        }else if (sceneStatus == -2){
+            buildSceneVO.setProgress(100);
+        }else if (sceneStatus == -1){
+            buildSceneVO.setProgress(0);
+        }
+        buildSceneVO.setProgress(sceneStatus);
+        buildSceneVO.setNum(num);
+        return buildSceneVO;
+    }
 }

+ 1 - 1
src/main/java/com/fdkankan/manage/service/impl/UserIncrementServiceImpl.java

@@ -224,7 +224,7 @@ public class UserIncrementServiceImpl extends ServiceImpl<IUserIncrementMapper,
             }
             LambdaUpdateWrapper<User> wrapper = new LambdaUpdateWrapper<>();
             wrapper.eq(User::getId,user.getId());
-            wrapper.setSql("download_num_total = download_num_total + " +  param.getCount() * incrementType.getDownloadNum());
+            wrapper.setSql("download_num_total = download_num_total + " +  (param.getMonthQy() == null? 1: param.getMonthQy())  *  param.getCount() * incrementType.getDownloadNum());
             userService.update(wrapper);
 
             Set<Long> ids = userIncrementList.stream().map(UserIncrement::getId).collect(Collectors.toSet());

+ 18 - 0
src/main/java/com/fdkankan/manage/vo/response/BuildSceneVO.java

@@ -0,0 +1,18 @@
+package com.fdkankan.manage.vo.response;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Created by Xiewj on 2021/11/24 0026 10:14
+ * 特殊点坐标
+ */
+@Data
+public class BuildSceneVO {
+
+    private int progress;
+    private String num;
+    private int status;
+
+}