From ca3a0224877225aee36b0d7a89deb8c624f15d97 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 22 一月 2026 11:08:21 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/timer/WmsDataTimer.java |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/asrs/timer/WmsDataTimer.java b/src/main/java/com/zy/asrs/timer/WmsDataTimer.java
index 7f85cce..4dc9bc0 100644
--- a/src/main/java/com/zy/asrs/timer/WmsDataTimer.java
+++ b/src/main/java/com/zy/asrs/timer/WmsDataTimer.java
@@ -5,14 +5,15 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.zy.asrs.entity.BasStation;
-import com.zy.asrs.entity.dto.TvWrkDetlDto;
-import com.zy.asrs.entity.dto.WcsStationDto;
+import com.zy.asrs.entity.dto.*;
+import com.zy.asrs.enums.RedisKeyType;
 import com.zy.asrs.service.BasStationService;
 import com.zy.asrs.utils.StationUtils;
 import com.zy.common.utils.HttpHandler;
 import com.zy.common.utils.RedisUtil;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
+import lombok.Synchronized;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -34,8 +35,9 @@
     @Autowired
     private RedisUtil redisUtil;
 
+    //WMS浠诲姟鏌ヨ鎺ュ彛
     @Scheduled(cron = "0/3 * * * * ? ")
-    public synchronized void execute() {
+    public synchronized void taskQuery() {
         Config wmsTaskQueryUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsTaskQueryUrl"));
         if (wmsTaskQueryUrlConfig == null) {
             return;
@@ -95,4 +97,115 @@
         }
     }
 
+    //WMS搴撳瓨鏁版嵁鏌ヨ
+    @Synchronized
+    @Scheduled(cron = "0/3 * * * * ? ")
+    public void locQuery() {
+        Config wmsUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsLocQueryUrl"));
+        if (wmsUrlConfig == null) {
+            return;
+        }
+
+        String wmsUrl = wmsUrlConfig.getValue();
+
+        String response = null;
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(wmsUrl)
+                    .setTimeout(30, TimeUnit.SECONDS)
+                    .build()
+                    .doGet();
+            if (response != null) {
+                JSONObject jsonObject = JSON.parseObject(response);
+                JSONObject data = jsonObject.getJSONObject("data");
+
+                TvLocDataDto tvLocDataDto = new TvLocDataDto();
+                tvLocDataDto.setEmptyCount(data.getInteger("emptyCount"));
+                tvLocDataDto.setDisableCount(data.getInteger("disableCount"));
+                tvLocDataDto.setTotal(data.getInteger("total"));
+                tvLocDataDto.setStockCount(data.getInteger("stockCount"));
+                tvLocDataDto.setUsedPr(data.getDouble("usedPr"));
+                tvLocDataDto.setUsed(data.getInteger("used"));
+
+                List<CommonNvDto> pieList = new ArrayList<>();
+                JSONArray list = data.getJSONArray("pie");
+                for (Object o : list) {
+                    CommonNvDto commonNvDto = JSON.parseObject(JSON.toJSONString(o), CommonNvDto.class);
+                    pieList.add(commonNvDto);
+                }
+
+                tvLocDataDto.setPie(pieList);
+
+                redisUtil.set(RedisKeyType.TV_LOC_DATA_DTO.key, JSON.toJSONString(tvLocDataDto));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    //WMS鍏ュ嚭搴撴姌绾垮浘
+    @Synchronized
+    @Scheduled(cron = "0/3 * * * * ? ")
+    public void inOutLineCharts() {
+        Config wmsUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsInOutLineChartsQueryUrl"));
+        if (wmsUrlConfig == null) {
+            return;
+        }
+
+        String wmsUrl = wmsUrlConfig.getValue();
+
+        String response = null;
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(wmsUrl)
+                    .setTimeout(30, TimeUnit.SECONDS)
+                    .build()
+                    .doGet();
+            if (response != null) {
+                JSONObject jsonObject = JSON.parseObject(response);
+                JSONObject data = jsonObject.getJSONObject("data");
+
+                redisUtil.set(RedisKeyType.TV_LINE_CHARTS.key, JSON.toJSONString(data));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    //WMS搴撳瓨鏁版嵁缁熻
+    @Synchronized
+    @Scheduled(cron = "0/3 * * * * ? ")
+    public void locDetlStatistics() {
+        Config wmsUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsLocDetlStatisticsQueryUrl"));
+        if (wmsUrlConfig == null) {
+            return;
+        }
+
+        String wmsUrl = wmsUrlConfig.getValue();
+
+        String response = null;
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(wmsUrl)
+                    .setTimeout(30, TimeUnit.SECONDS)
+                    .build()
+                    .doGet();
+            if (response != null) {
+                JSONObject jsonObject = JSON.parseObject(response);
+                JSONObject data = jsonObject.getJSONObject("data");
+
+                List<TvLocDetlStatisticsDto> list = new ArrayList<>();
+                JSONArray records = data.getJSONArray("records");
+                for (Object record : records) {
+                    TvLocDetlStatisticsDto tvLocDetlStatisticsDto = JSON.parseObject(JSON.toJSONString(record), TvLocDetlStatisticsDto.class);
+                    list.add(tvLocDetlStatisticsDto);
+                }
+
+                redisUtil.set(RedisKeyType.TV_LOC_DETL_STATISTICS.key, JSON.toJSONString(list));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
 }

--
Gitblit v1.9.1