Junjie
1 天以前 a4f07b2a0ddb6c210e05afbbb491feeb466203e7
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,6 +1,6 @@
package com.zy.asrs.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
@@ -36,6 +36,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@@ -150,13 +151,13 @@
        return R.error("任务取消失败");
    }
    @RequestMapping("/deviceStatus")
    @PostMapping("/deviceStatus")
    // @OpenApiLog(memo = "获取设备状态")
    public R getDeviceStatus() {
        HashMap<String, Object> map = new HashMap<>();
        // 获取堆垛机数据
        ArrayList<CrnProtocol> crnProtocols = new ArrayList<>();
        List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
        List<DeviceConfig> crnList = deviceConfigService.list(new QueryWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Crn)));
        for (DeviceConfig device : crnList) {
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, device.getDeviceNo());
@@ -173,7 +174,7 @@
        // 获取RGV数据
        ArrayList<RgvProtocol> rgvProtocols = new ArrayList<>();
        List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
        List<DeviceConfig> rgvList = deviceConfigService.list(new QueryWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Rgv)));
        for (DeviceConfig device : rgvList) {
            RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, device.getDeviceNo());
@@ -190,7 +191,7 @@
        // 获取双工位堆垛机数据
        ArrayList<DualCrnProtocol> dualCrnProtocols = new ArrayList<>();
        List<DeviceConfig> dualCrnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
        List<DeviceConfig> dualCrnList = deviceConfigService.list(new QueryWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.DualCrn)));
        for (DeviceConfig device : dualCrnList) {
            DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, device.getDeviceNo());
@@ -207,7 +208,7 @@
        // 获取输送站点数据
        ArrayList<StationProtocol> stationProtocols = new ArrayList<>();
        List<DeviceConfig> stationList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
        List<DeviceConfig> stationList = deviceConfigService.list(new QueryWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Devp)));
        for (DeviceConfig device : stationList) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, device.getDeviceNo());
@@ -227,6 +228,38 @@
        map.put("dualCrnList", dualCrnProtocols);
        map.put("stationList", stationProtocols);
        return R.ok().add(map);
    }
    @PostMapping("/stationStatus")
    public R getStationStatus(@RequestBody GetStationStatusParam param) {
        // 获取输送站点数据
        List<StationProtocol> stationProtocols = new ArrayList<>();
        List<DeviceConfig> devpList = deviceConfigService.list(new QueryWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Devp))
        );
        for (DeviceConfig device : devpList) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, device.getDeviceNo());
            if (stationThread == null) {
                continue;
            }
            List<StationProtocol> tmp = new ArrayList<>();
            if(param.getStationIds() == null || param.getStationIds().isEmpty()) {
                tmp.addAll(stationThread.getStatus());
            }else {
                Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
                for (Integer stationId : param.getStationIds()) {
                    StationProtocol stationProtocol = statusMap.get(stationId);
                    if (stationProtocol == null) {
                        continue;
                    }
                    tmp.add(stationProtocol);
                }
            }
            stationProtocols.addAll(tmp);
        }
        return R.ok().add(stationProtocols);
    }
    @PostMapping("/getLocInformation")
@@ -251,7 +284,7 @@
    @OpenApiLog(memo = "获取全部库位信息")
    public R getAllLocInformation(@RequestBody GetAllLocInformationParam param) {
        List<HashMap<String, Object>> list = new ArrayList<>();
        EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
        QueryWrapper<LocMast> wrapper = new QueryWrapper<>();
        if (!Cools.isEmpty(param.getRow())) {
            wrapper.eq("row1", param.getRow());
@@ -261,7 +294,7 @@
            wrapper.eq("lev1", param.getLev());
        }
        List<LocMast> locMasts = locMastService.selectList(wrapper);
        List<LocMast> locMasts = locMastService.list(wrapper);
        if (locMasts.isEmpty()) {
            return R.ok().add(list);
        }
@@ -283,7 +316,7 @@
    @PostMapping("/queryTask")
    @OpenApiLog(memo = "查询任务")
    public R queryTask(@RequestBody QueryTaskParam param) {
        EntityWrapper<WrkMast> wrapper = new EntityWrapper<>();
        QueryWrapper<WrkMast> wrapper = new QueryWrapper<>();
        if (param.getTaskNo() != null) {
            wrapper.eq("wms_wrk_no", param.getTaskNo());
        }
@@ -295,7 +328,7 @@
            }
            wrapper.eq("io_type", ioType.id);
        }
        List<WrkMast> wrkMasts = wrkMastService.selectList(wrapper);
        List<WrkMast> wrkMasts = wrkMastService.list(wrapper);
        return R.ok().add(wrkMasts);
    }
@@ -318,7 +351,7 @@
        if (mainProcessPlugin.contains("Fake")) {
            map.put("running", false);
            map.put("isFake", true);
            Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
            Config config = configService.getOne(new QueryWrapper<Config>().eq("code", "enableFake"));
            if (config != null) {
                if (config.getValue().equals("Y")) {
                    map.put("running", true);
@@ -333,7 +366,7 @@
    @PostMapping("/startFakeSystem")
    @OpenApiLog(memo = "启动仿真模拟")
    public R startFakeSystem() {
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
        Config config = configService.getOne(new QueryWrapper<Config>().eq("code", "enableFake"));
        if (config != null) {
            config.setValue("Y");
            configService.updateById(config);
@@ -344,7 +377,7 @@
    @PostMapping("/stopFakeSystem")
    @OpenApiLog(memo = "停止仿真模拟")
    public R stopFakeSystem() {
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
        Config config = configService.getOne(new QueryWrapper<Config>().eq("code", "enableFake"));
        if (config != null) {
            config.setValue("N");
            configService.updateById(config);