Browse Source

“航征数据处理;货架列表查询”

yangjunfeng 2 years ago
parent
commit
de89c81294

+ 2 - 0
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/config/MqttConfig.java

@@ -64,6 +64,8 @@ public class MqttConfig {
         // Paho客户端消息驱动通道适配器,主要用来订阅主题
         MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter("consumerClient-hz",
                 mqttClientFactory(), "boat", "collector", "battery", "+/sensor", "demo","my-topic");
+//        MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter("consumerClient-bd",
+//                mqttClientFactory(), "boat", "collector", "battery", "+/sensor", "demo");
         adapter.setCompletionTimeout(5000);
 
         // Paho消息转换器

+ 15 - 0
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/controller/TfStocksShelvesController.java

@@ -21,6 +21,8 @@ import io.swagger.annotations.ApiImplicitParams;
 import org.springframework.web.bind.annotation.ModelAttribute;
 
 import java.util.Arrays;
+import java.util.List;
+
 /**
  * 库存货架表
  *
@@ -50,6 +52,19 @@ public class TfStocksShelvesController {
       return ResultRespone.success(shelvesPage);
     }
 
+    /**
+     * 列表查询
+     * @param tfStocksShelves 库存货架表
+     * @return
+     */
+    @GetMapping("/list" )
+    @ApiOperation(value = "列表查询")
+    public ResultRespone getTfStocksShelvesPage(@ModelAttribute TfStocksShelves tfStocksShelves) {
+        List<TfStocksShelves> shelvesList = tfStocksShelvesService.list(Wrappers.query(tfStocksShelves));
+        shelvesList.forEach(e -> e.setStocksStore(tfStocksStoreService.getById(e.getStoreId())));
+        return ResultRespone.success(shelvesList);
+    }
+
 
     /**
      * 通过id查询库存货架表

+ 60 - 57
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/mqtt/HangZhengTopicHandler.java

@@ -65,16 +65,16 @@ public class HangZhengTopicHandler implements TopicHandler {
 
         //雷达水位计一体机1
         if (payloads!=null&&payloads.get("device_model")!=null&&payloads.get("device_model").equals("HZ-RLS-60L-50Pi")) {
-            IndexVal indexVal = new IndexVal();
+            IndexVal swIndex = new IndexVal();
             Long id = SnowFlake.nextId();
-            indexVal.setId(id);
-            indexVal.setDeviceCode("ldswytj1");
-            indexVal.setItCd("sw");
-            indexVal.setItVal(String.valueOf(payloads.get("water_levels")));
+            swIndex.setId(id);
+            swIndex.setDeviceCode("ldswytj1");
+            swIndex.setItCd("sw");
+            swIndex.setItVal(String.valueOf(payloads.get("water_levels")));
             Date collectTime;
             try {
                 collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
-                indexVal.setScadaTime(collectTime);
+                swIndex.setScadaTime(collectTime);
             } catch (ParseException e) {
                 e.printStackTrace();
             }
@@ -85,46 +85,47 @@ public class HangZhengTopicHandler implements TopicHandler {
             List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
             if (indexVal1 == null || indexVal1.size() == 0) {
                 List<IndexVal> indexValNewList = new ArrayList<>();
-                indexValNewList.add(indexVal);
+                indexValNewList.add(swIndex);
                 customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
             }else {
-                indexVal.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
-                customDisplayMapper.updateTemp(indexVal);
+                swIndex.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
+                customDisplayMapper.updateTemp(swIndex);
             }
-            indexVal.setId(id);
-            indexValList.add(indexVal);
+            swIndex.setId(id);
+            indexValList.add(swIndex);
 
+            IndexVal kgIndex = new IndexVal();
             id = SnowFlake.nextId();
-            indexVal.setId(id);
-            indexVal.setItCd("kg");
-            indexVal.setItVal(String.valueOf(payloads.get("ullage")));
+            kgIndex.setId(id);
+            kgIndex.setItCd("kg");
+            kgIndex.setItVal(String.valueOf(payloads.get("ullage")));
             wis.setIndexCode("kg");
             wis.setTableName("tf_ywpn_monitor_reatime_copy");
             List<Map<String,Object>> indexVal2 = customDisplayMapper.viewCopyIndex(wis);
             if (indexVal2 == null || indexVal2.size() == 0) {
                 List<IndexVal> indexValNewList = new ArrayList<>();
-                indexValNewList.add(indexVal);
+                indexValNewList.add(kgIndex);
                 customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
             }else {
-                indexVal.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
-                customDisplayMapper.updateTemp(indexVal);
+                kgIndex.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
+                customDisplayMapper.updateTemp(kgIndex);
             }
-            indexVal.setId(id);
-            indexValList.add(indexVal);
+            kgIndex.setId(id);
+            indexValList.add(kgIndex);
         }
 
         //雷达水位计一体机2
         if (payloads!=null&&payloads.get("device_model")!=null&&payloads.get("device_model").equals("HZ-RLS-60L-50")) {
-            IndexVal indexVal = new IndexVal();
+            IndexVal swIndex = new IndexVal();
             Long id = SnowFlake.nextId();
-            indexVal.setId(id);
-            indexVal.setDeviceCode("ldswytj2");
-            indexVal.setItCd("sw");
-            indexVal.setItVal(String.valueOf(payloads.get("water_levels")));
+            swIndex.setId(id);
+            swIndex.setDeviceCode("ldswytj2");
+            swIndex.setItCd("sw");
+            swIndex.setItVal(String.valueOf(payloads.get("water_levels")));
             Date collectTime;
             try {
                 collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
-                indexVal.setScadaTime(collectTime);
+                swIndex.setScadaTime(collectTime);
             } catch (ParseException e) {
                 e.printStackTrace();
             }
@@ -135,46 +136,47 @@ public class HangZhengTopicHandler implements TopicHandler {
             List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
             if (indexVal1 == null || indexVal1.size() == 0) {
                 List<IndexVal> indexValNewList = new ArrayList<>();
-                indexValNewList.add(indexVal);
+                indexValNewList.add(swIndex);
                 customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
             }else {
-                indexVal.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
-                customDisplayMapper.updateTemp(indexVal);
+                swIndex.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
+                customDisplayMapper.updateTemp(swIndex);
             }
-            indexVal.setId(id);
-            indexValList.add(indexVal);
+            swIndex.setId(id);
+            indexValList.add(swIndex);
 
+            IndexVal kgIndex = new IndexVal();
             id = SnowFlake.nextId();
-            indexVal.setId(id);
-            indexVal.setItCd("kg");
-            indexVal.setItVal(String.valueOf(payloads.get("ullage")));
+            kgIndex.setId(id);
+            kgIndex.setItCd("kg");
+            kgIndex.setItVal(String.valueOf(payloads.get("ullage")));
             wis.setIndexCode("kg");
             wis.setTableName("tf_ywpn_monitor_reatime_copy");
             List<Map<String,Object>> indexVal2 = customDisplayMapper.viewCopyIndex(wis);
             if (indexVal2 == null || indexVal2.size() == 0) {
                 List<IndexVal> indexValNewList = new ArrayList<>();
-                indexValNewList.add(indexVal);
+                indexValNewList.add(kgIndex);
                 customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
             }else {
-                indexVal.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
-                customDisplayMapper.updateTemp(indexVal);
+                kgIndex.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
+                customDisplayMapper.updateTemp(kgIndex);
             }
-            indexVal.setId(id);
-            indexValList.add(indexVal);
+            kgIndex.setId(id);
+            indexValList.add(kgIndex);
         }
 
         //雷达流量计
         if (payloads!=null&&payloads.get("device_model")!=null&&payloads.get("device_model").equals("HZ-SVR-122QP")) {
-            IndexVal indexVal = new IndexVal();
+            IndexVal ssIndex = new IndexVal();
             Long id = SnowFlake.nextId();
-            indexVal.setId(id);
-            indexVal.setDeviceCode("ldllj");
-            indexVal.setItCd("ss");
-            indexVal.setItVal(String.valueOf(payloads.get("water_levels")));
+            ssIndex.setId(id);
+            ssIndex.setDeviceCode("ldllj");
+            ssIndex.setItCd("ss");
+            ssIndex.setItVal(String.valueOf(payloads.get("water_levels")));
             Date collectTime;
             try {
                 collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
-                indexVal.setScadaTime(collectTime);
+                ssIndex.setScadaTime(collectTime);
             } catch (ParseException e) {
                 e.printStackTrace();
             }
@@ -185,32 +187,33 @@ public class HangZhengTopicHandler implements TopicHandler {
             List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
             if (indexVal1 == null || indexVal1.size() == 0) {
                 List<IndexVal> indexValNewList = new ArrayList<>();
-                indexValNewList.add(indexVal);
+                indexValNewList.add(ssIndex);
                 customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
             }else {
-                indexVal.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
-                customDisplayMapper.updateTemp(indexVal);
+                ssIndex.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
+                customDisplayMapper.updateTemp(ssIndex);
             }
-            indexVal.setId(id);
-            indexValList.add(indexVal);
+            ssIndex.setId(id);
+            indexValList.add(ssIndex);
 
+            IndexVal ssllIndex = new IndexVal();
             id = SnowFlake.nextId();
-            indexVal.setId(id);
-            indexVal.setItCd("ssll");
-            indexVal.setItVal(String.valueOf(payloads.get("instantaneous_flow")));
+            ssllIndex.setId(id);
+            ssllIndex.setItCd("ssll");
+            ssllIndex.setItVal(String.valueOf(payloads.get("instantaneous_flow")));
             wis.setIndexCode("ssll");
             wis.setTableName("tf_ywpn_monitor_reatime_copy");
             List<Map<String,Object>> indexVal2 = customDisplayMapper.viewCopyIndex(wis);
             if (indexVal2 == null || indexVal2.size() == 0) {
                 List<IndexVal> indexValNewList = new ArrayList<>();
-                indexValNewList.add(indexVal);
+                indexValNewList.add(ssllIndex);
                 customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
             }else {
-                indexVal.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
-                customDisplayMapper.updateTemp(indexVal);
+                ssllIndex.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
+                customDisplayMapper.updateTemp(ssllIndex);
             }
-            indexVal.setId(id);
-            indexValList.add(indexVal);
+            ssllIndex.setId(id);
+            indexValList.add(ssllIndex);
         }
 
         //雷达流速仪