#
Junjie
2026-01-22 ca3a0224877225aee36b0d7a89deb8c624f15d97
#
4个文件已添加
2个文件已修改
243 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/OpenController.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/dto/CommonNvDto.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/dto/TvLocDataDto.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/dto/TvLocDetlStatisticsDto.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/enums/RedisKeyType.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/timer/WmsDataTimer.java 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,5 +1,6 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
@@ -7,12 +8,16 @@
import com.zy.asrs.entity.TvDevice;
import com.zy.asrs.entity.dto.TvDataDto;
import com.zy.asrs.entity.dto.TvLocDataDto;
import com.zy.asrs.entity.dto.WcsStationDto;
import com.zy.asrs.enums.RedisKeyType;
import com.zy.asrs.service.BasStationTvService;
import com.zy.asrs.service.TvDeviceService;
import com.zy.asrs.utils.StationUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.charts.LineChartData;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +39,8 @@
    private BasStationTvService basStationTvService;
    @Autowired
    private StationUtils stationUtils;
    @Autowired
    private RedisUtil redisUtil;
    @Value("${app.version:1.0.0}")
    private String appVersion;
@@ -131,4 +138,45 @@
        );
    }
    /**
     * 获取库位数据
     */
    @GetMapping("/queryLoc")
    public R queryLoc() {
        TvLocDataDto tvLocDataDto = new TvLocDataDto();
        Object o = redisUtil.get(RedisKeyType.TV_LOC_DATA_DTO.key);
        if(o == null){
            return R.ok().add(tvLocDataDto);
        }
        tvLocDataDto = JSON.parseObject(o.toString(), TvLocDataDto.class);
        return R.ok().add(tvLocDataDto);
    }
    /**
     * WMS入出库折线图
     */
    @GetMapping("/inOutLineCharts")
    public R inOutLineCharts() {
        Object o = redisUtil.get(RedisKeyType.TV_LINE_CHARTS.key);
        if(o == null){
            return R.error();
        }
        return R.ok().add(JSON.parseObject(o.toString()));
    }
    /**
     * WMS库存数据统计
     */
    @GetMapping("/locDetlStatistics")
    public R locDetlStatistics() {
        Object o = redisUtil.get(RedisKeyType.TV_LOC_DETL_STATISTICS.key);
        if(o == null){
            return R.error();
        }
        return R.ok().add(JSON.parseArray(o.toString()));
    }
}
src/main/java/com/zy/asrs/entity/dto/CommonNvDto.java
New file
@@ -0,0 +1,12 @@
package com.zy.asrs.entity.dto;
import lombok.Data;
@Data
public class CommonNvDto {
    private String name;
    private String value;
}
src/main/java/com/zy/asrs/entity/dto/TvLocDataDto.java
New file
@@ -0,0 +1,31 @@
package com.zy.asrs.entity.dto;
import lombok.Data;
import java.util.List;
@Data
public class TvLocDataDto {
    //空库位数量
    private Integer emptyCount;
    //禁用库位数量
    private Integer disableCount;
    //总库位数量
    private Integer total;
    //在库位数量
    private Integer stockCount;
    //库位使用率
    private Double usedPr;
    //库位使用数量
    private Integer used;
    //饼图数据
    private List<CommonNvDto> pie;
}
src/main/java/com/zy/asrs/entity/dto/TvLocDetlStatisticsDto.java
New file
@@ -0,0 +1,18 @@
package com.zy.asrs.entity.dto;
import lombok.Data;
@Data
public class TvLocDetlStatisticsDto {
    private String matnr;
    private String maktx;
    private String specs;
    private String batch;
    private Double anfme;
}
src/main/java/com/zy/asrs/enums/RedisKeyType.java
New file
@@ -0,0 +1,15 @@
package com.zy.asrs.enums;
public enum RedisKeyType {
    TV_LOC_DATA_DTO("tvLocDataDto"),
    TV_LINE_CHARTS("tvLineCharts"),
    TV_LOC_DETL_STATISTICS("tvLocDetlStatistics"),
    ;
    public String key;
    RedisKeyType(String key) {
        this.key = key;
    }
}
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();
        }
    }
}