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

计算优先级配置接口,设置接口

lyhzzz 1 рік тому
батько
коміт
1be5a9f2c5

+ 17 - 0
src/main/java/com/fdkankan/manage/controller/OverallController.java

@@ -6,14 +6,17 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.manage.common.PageInfo;
 import com.fdkankan.manage.common.ResultData;
+import com.fdkankan.manage.entity.MqSendLog;
 import com.fdkankan.manage.entity.ScenePlus;
 import com.fdkankan.manage.entity.ScenePlusExt;
 import com.fdkankan.manage.httpClient.client.OverallClient;
 import com.fdkankan.manage.httpClient.vo.OverallParam;
 import com.fdkankan.manage.httpClient.vo.OverallVo;
 import com.fdkankan.manage.service.ICommonService;
+import com.fdkankan.manage.service.IMqSendLogService;
 import com.fdkankan.manage.service.IScenePlusExtService;
 import com.fdkankan.manage.service.IScenePlusService;
+import com.fdkankan.manage.vo.response.SceneVo;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -45,6 +48,8 @@ public class OverallController {
    IScenePlusExtService scenePlusExtService;
    @Autowired
     ICommonService commonService;
+    @Autowired
+    IMqSendLogService mqSendLogService;
 
     @PostMapping("/list")
     public ResultData list(@RequestBody OverallParam param){
@@ -88,6 +93,10 @@ public class OverallController {
         HashMap<Long, ScenePlusExt> extMap = scenePlusExtService.getByPlusIds(plusIds);
         HashMap<String, ScenePlus> plusMap = new HashMap<>();
         scenePluses.forEach( e -> plusMap.put(e.getNum(),e));
+        HashMap<String,MqSendLog> mqSendLogMap = null;
+        if(!numList.isEmpty()){
+            mqSendLogMap = mqSendLogService.getByNumList(numList);
+        }
 
         for (Object o : array) {
             JSONObject obj = (JSONObject) o;
@@ -110,6 +119,14 @@ public class OverallController {
                 }
 
             }
+
+            if(mqSendLogMap!=null){
+                MqSendLog mqSendLog = mqSendLogMap.get(num);
+                if(mqSendLog != null){
+                    obj.put("statusString","排队中");
+                    obj.put("status",-4);
+                }
+            }
         }
         List<Object> list = new ArrayList<>(array);
         long total = dataObj.getLongValue("total");

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

@@ -3,6 +3,9 @@ package com.fdkankan.manage.service;
 import com.fdkankan.manage.entity.MqSendLog;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IMqSendLogService extends IService<MqSendLog> {
 
+    HashMap<String, MqSendLog> getByNumList(List<String> modelingNumList);
 }

+ 18 - 0
src/main/java/com/fdkankan/manage/service/impl/MqSendLogServiceImpl.java

@@ -1,11 +1,15 @@
 package com.fdkankan.manage.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.manage.entity.MqSendLog;
 import com.fdkankan.manage.mapper.IMqSendLogMapper;
 import com.fdkankan.manage.service.IMqSendLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +21,18 @@ import org.springframework.stereotype.Service;
 @Service
 public class MqSendLogServiceImpl extends ServiceImpl<IMqSendLogMapper, MqSendLog> implements IMqSendLogService {
 
+    @Override
+    public HashMap<String, MqSendLog> getByNumList(List<String> modelingNumList) {
+        HashMap<String, MqSendLog> map = new HashMap<>();
+        if(modelingNumList.isEmpty()){
+            return map;
+        }
+        LambdaQueryWrapper<MqSendLog> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(MqSendLog::getNum,modelingNumList);
+        wrapper.eq(MqSendLog::getStatus,0);
+        wrapper.isNull(MqSendLog::getQueue);
+        List<MqSendLog> list = this.list(wrapper);
+        list.forEach(e -> map.put(e.getNum(),e));
+        return map;
+    }
 }

+ 24 - 13
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -98,6 +98,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     ICommonService commonService;
     @Autowired
     IUserService userService;
+    @Autowired
+    IMqSendLogService mqSendLogService;
 
 
     @Override
@@ -233,27 +235,28 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         HashMap<String,SceneColdStorage> coldStorageMap = null;
         HashMap<Long, User> userMap = null;
         HashMap<Long, Camera> cameraMap = null;
+        HashMap<String,JSONObject> ssSceneMap = null;
+        HashMap<String,MqSendLog> mqSendLogMap = null;
 
         List<String> sceneNumList = page.getRecords().stream().map(SceneVo::getNum).collect(Collectors.toList());
-        HashMap<String,JSONObject> ssSceneMap = new HashMap<>();
-        if(param.getType() == 2 ){
-            ssSceneMap = laserService.list(sceneNumList,4);
-        }
-        if(param.getType() == 6){
-            ssSceneMap = laserService.list(sceneNumList,5);
-        }
-
         if(!records.isEmpty()){
-            List<String> numList = records.parallelStream().map(SceneVo::getNum).collect(Collectors.toList());
-            map = copyLogService.getByNewNumList(numList);
-            coldStorageMap = sceneColdStorageService.getByNumList(numList);
-
+            map = copyLogService.getByNewNumList(sceneNumList);
+            coldStorageMap = sceneColdStorageService.getByNumList(sceneNumList);
             List<Long> userIds = records.parallelStream().map(SceneVo::getUserId).collect(Collectors.toList());
             userMap = userService.getByIds(userIds);
-
             List<Long> cameraIds = records.parallelStream().map(SceneVo::getCameraId).collect(Collectors.toList());
             cameraMap = cameraService.getByIds(cameraIds);
 
+            if(param.getType() == 2 ){
+                ssSceneMap = laserService.list(sceneNumList,4);
+            }
+            if(param.getType() == 6){
+                ssSceneMap = laserService.list(sceneNumList,5);
+            }
+            List<String> modelingNumList = page.getRecords().stream().filter(e -> e.getStatus() == 0).map(SceneVo::getNum).collect(Collectors.toList());
+            if(!modelingNumList.isEmpty()){
+                mqSendLogMap = mqSendLogService.getByNumList(modelingNumList);
+            }
         }
         for (SceneVo record : page.getRecords()) {
             if(param.getType() == 2 || param.getType() == 6){
@@ -306,6 +309,14 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             }
             //{"latitude":22.3672085,"longitude":113.595673,"altitude":9.275519,"horizontalAccuracy":65.0,"verticalAccuracy":10.0,"timestamp":1564381147.2775609}
             record.setAddressComponent(commonService.getAddressComponent(record.getGps()));
+
+            if(mqSendLogMap!=null){
+                MqSendLog mqSendLog = mqSendLogMap.get(record.getNum());
+                if(mqSendLog != null){
+                    record.setStatusString("排队中");
+                    record.setStatus(-4);
+                }
+            }
         }
         return PageInfo.PageInfo(page);
     }