#
Junjie
2026-01-22 afc1bebb2eafc87ba81fb9fe39ef0386d1fb3d17
#
6个文件已添加
2个文件已修改
331 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/OpenController.java 61 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/dto/TvDataDto.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/dto/TvWrkDetlDto.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/dto/WcsStationDto.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/BasStationTvMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/timer/WcsStationTimer.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/timer/WmsDataTimer.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/StationUtils.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -3,10 +3,14 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.entity.BasStation;
import com.zy.asrs.entity.BasStationTv;
import com.zy.asrs.entity.TvDevice;
import com.zy.asrs.entity.dto.TvDataDto;
import com.zy.asrs.entity.dto.WcsStationDto;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@@ -16,7 +20,6 @@
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@RestController
@@ -26,11 +29,11 @@
    private static final String[] WEEK = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
    @Autowired
    private com.zy.asrs.service.TvDeviceService tvDeviceService;
    private TvDeviceService tvDeviceService;
    @Autowired
    private com.zy.asrs.service.BasStationTvService basStationTvService;
    private BasStationTvService basStationTvService;
    @Autowired
    private com.zy.asrs.service.BasStationService basStationService;
    private StationUtils stationUtils;
    @Value("${app.version:1.0.0}")
    private String appVersion;
@@ -53,14 +56,12 @@
    @GetMapping("/getLedInfos")
    public R getLedInfos(HttpServletRequest request) {
        String remoteAddr = request.getRemoteAddr();
        // 1. 根据IP查询电视机
        TvDevice tvDevice = tvDeviceService.selectOne(
                new EntityWrapper<TvDevice>().eq("ip", remoteAddr));
        if (tvDevice == null) {
            return R.error("未找到IP对应的电视机设备: " + remoteAddr);
        }
        // 2. 查询绑定的站台ID
        List<BasStationTv> relations = basStationTvService
                .selectList(new EntityWrapper<BasStationTv>().eq("tv_id", tvDevice.getId()));
        if (relations == null || relations.isEmpty()) {
@@ -69,14 +70,46 @@
            return r;
        }
        // 3. 获取站台详情
        List<Integer> stationIds = relations.stream().map(BasStationTv::getStationId)
                .collect(Collectors.toList());
        List<BasStation> stations = basStationService.selectBatchIds(stationIds);
        R r = R.ok();
        r.put("data", stations);
        return r;
        List<TvDataDto> list = new ArrayList<>();
        for (BasStationTv relation : relations) {
            WcsStationDto wcsStationDto = stationUtils.stationMap.get(relation.getStationId());
            if (wcsStationDto == null) {
                continue;
            }
            if (wcsStationDto.getLoading() != 1) {
                continue;
            }
            String errorMsg = "";
            if (!Cools.isEmpty(wcsStationDto.getErrorMsg())) {
                errorMsg +=  wcsStationDto.getErrorMsg();
            }
            if (!Cools.isEmpty(wcsStationDto.getSystemWarning())) {
                errorMsg +=  wcsStationDto.getSystemWarning();
            }
            TvDataDto tvDataDto = new TvDataDto();
            tvDataDto.setStationId(wcsStationDto.getStationId());
            tvDataDto.setTaskNo(wcsStationDto.getTaskNo());
            tvDataDto.setBarcode(wcsStationDto.getBarcode());
            tvDataDto.setErrorMsg(errorMsg);
            tvDataDto.setIoType(wcsStationDto.getIoType());
            tvDataDto.setWrkDetls(wcsStationDto.getWrkDetls());
            if (Cools.isEmpty(errorMsg)) {
                tvDataDto.setErrorCode(0);
            }else {
                tvDataDto.setErrorCode(1);
            }
            list.add(tvDataDto);
        }
        return R.ok().add(list);
    }
    /**
src/main/java/com/zy/asrs/entity/dto/TvDataDto.java
New file
@@ -0,0 +1,22 @@
package com.zy.asrs.entity.dto;
import lombok.Data;
@Data
public class TvDataDto {
    private Integer stationId;
    private String taskNo;
    private String barcode;
    private Integer errorCode;
    private String errorMsg;
    private Integer ioType;
    private Object wrkDetls;
}
src/main/java/com/zy/asrs/entity/dto/TvWrkDetlDto.java
New file
@@ -0,0 +1,18 @@
package com.zy.asrs.entity.dto;
import lombok.Data;
@Data
public class TvWrkDetlDto {
    private String matnr;
    private String maktx;
    private String specs;
    private String batch;
    private Double anfme;
}
src/main/java/com/zy/asrs/entity/dto/WcsStationDto.java
New file
@@ -0,0 +1,26 @@
package com.zy.asrs.entity.dto;
import lombok.Data;
@Data
public class WcsStationDto {
    private Integer stationId;
    private String taskNo;
    private Integer auto;
    private Integer loading;
    private String barcode;
    private String errorMsg;
    private String systemWarning;
    private Integer ioType;
    private Object wrkDetls;
}
src/main/java/com/zy/asrs/mapper/BasStationTvMapper.java
@@ -3,11 +3,13 @@
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.zy.asrs.entity.BasStationTv;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
 * 站台与电视机绑定关联 Mapper
 */
@Mapper
@Repository
public interface BasStationTvMapper extends BaseMapper<BasStationTv> {
}
src/main/java/com/zy/asrs/timer/WcsStationTimer.java
New file
@@ -0,0 +1,90 @@
package com.zy.asrs.timer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.BasStation;
import com.zy.asrs.entity.dto.WcsStationDto;
import com.zy.asrs.service.BasStationService;
import com.zy.asrs.utils.StationUtils;
import com.zy.common.utils.HttpHandler;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class WcsStationTimer {
    @Autowired
    private ConfigService configService;
    @Autowired
    private BasStationService basStationService;
    @Autowired
    private StationUtils stationUtils;
    @Scheduled(cron = "0/3 * * * * ? ")
    public synchronized void execute() {
        Config wcsStationUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wcsStationUrl"));
        if (wcsStationUrlConfig == null) {
            return;
        }
        String wcsStationUrl = wcsStationUrlConfig.getValue();
        String response = null;
        try {
            HashMap<String, Object> requestParam = new HashMap<>();
            List<Integer> list = new ArrayList<>();
            List<BasStation> basStations = basStationService.selectList(new EntityWrapper<>());
            for (BasStation basStation : basStations) {
                list.add(basStation.getStationId());
            }
            requestParam.put("stationIds", list);
            response = new HttpHandler.Builder()
                    .setUri(wcsStationUrl)
                    .setJson(JSON.toJSONString(requestParam))
                    .setTimeout(30, TimeUnit.SECONDS)
                    .build()
                    .doPost();
            if (response != null) {
                JSONObject jsonObject = JSON.parseObject(response);
                JSONArray data = jsonObject.getJSONArray("data");
                for (Object o : data) {
                    JSONObject object = (JSONObject) o;
                    Integer stationId = object.getInteger("stationId");
                    WcsStationDto wcsStationDto = stationUtils.stationMap.get(stationId);
                    if (wcsStationDto == null) {
                        wcsStationDto = new WcsStationDto();
                    }
                    wcsStationDto.setStationId(stationId);
                    wcsStationDto.setTaskNo(object.getString("superTaskNo"));
                    wcsStationDto.setAuto(object.getBoolean("autoing") ? 1 : 0);
                    wcsStationDto.setLoading(object.getBoolean("loading") ? 1 : 0);
                    wcsStationDto.setBarcode(object.getString("barcode"));
                    wcsStationDto.setErrorMsg(object.getString("errorMsg"));
                    wcsStationDto.setSystemWarning(object.getString("systemWarning"));
                    stationUtils.stationMap.put(stationId, wcsStationDto);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
src/main/java/com/zy/asrs/timer/WmsDataTimer.java
New file
@@ -0,0 +1,98 @@
package com.zy.asrs.timer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
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.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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Component
public class WmsDataTimer {
    @Autowired
    private ConfigService configService;
    @Autowired
    private BasStationService basStationService;
    @Autowired
    private StationUtils stationUtils;
    @Autowired
    private RedisUtil redisUtil;
    @Scheduled(cron = "0/3 * * * * ? ")
    public synchronized void execute() {
        Config wmsTaskQueryUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsTaskQueryUrl"));
        if (wmsTaskQueryUrlConfig == null) {
            return;
        }
        String wmsTaskQueryUrl = wmsTaskQueryUrlConfig.getValue();
        String response = null;
        try {
            HashMap<String, Object> requestParam = new HashMap<>();
            List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("out_enable", "Y"));
            for (BasStation basStation : basStations) {
                WcsStationDto wcsStationDto = stationUtils.stationMap.get(basStation.getStationId());
                if (wcsStationDto == null) {
                    continue;
                }
                if (wcsStationDto.getAuto() != 1
                        || wcsStationDto.getLoading() != 1
                        || wcsStationDto.getTaskNo().equals("0")
                ) {
                    continue;
                }
                requestParam.put("taskNo", wcsStationDto.getTaskNo());
                response = new HttpHandler.Builder()
                        .setUri(wmsTaskQueryUrl)
                        .setJson(JSON.toJSONString(requestParam))
                        .setTimeout(30, TimeUnit.SECONDS)
                        .build()
                        .doPost();
                if (response != null) {
                    JSONObject jsonObject = JSON.parseObject(response);
                    JSONObject data = jsonObject.getJSONObject("data");
                    List<TvWrkDetlDto> list = new ArrayList<>();
                    for (Object o : data.getJSONArray("wrkDetls")) {
                        JSONObject wrkDetl = (JSONObject) o;
                        TvWrkDetlDto tvWrkDetlDto = new TvWrkDetlDto();
                        list.add(tvWrkDetlDto);
                        tvWrkDetlDto.setMatnr(wrkDetl.getString("matnr"));
                        tvWrkDetlDto.setMaktx(wrkDetl.getString("maktx"));
                        tvWrkDetlDto.setSpecs(wrkDetl.getString("specs"));
                        tvWrkDetlDto.setBatch(wrkDetl.getString("batch"));
                        tvWrkDetlDto.setAnfme(wrkDetl.getDouble("anfme"));
                    }
                    wcsStationDto.setIoType(data.getInteger("ioType"));
                    wcsStationDto.setWrkDetls(list);
                    stationUtils.stationMap.put(wcsStationDto.getStationId(), wcsStationDto);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
src/main/java/com/zy/asrs/utils/StationUtils.java
New file
@@ -0,0 +1,14 @@
package com.zy.asrs.utils;
import com.zy.asrs.entity.dto.WcsStationDto;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class StationUtils {
    public Map<Integer, WcsStationDto> stationMap = new HashMap<>();
}