1
zhang
1 天以前 b78572fb09a2c63398e8d87bd19d5d3f92f5aa58
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/controller/SiteController.java
@@ -1,17 +1,14 @@
package com.zy.acs.conveyor.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.acs.common.utils.RedisSupport;
import com.zy.acs.conveyor.controller.vo.SiteTableVo;
import com.zy.acs.conveyor.core.DevpThread;
import com.zy.acs.conveyor.core.cache.MessageQueue;
import com.zy.acs.conveyor.core.cache.OutputQueue;
import com.zy.acs.conveyor.core.cache.SlaveConnection;
import com.zy.acs.conveyor.core.enums.SlaveType;
import com.zy.acs.conveyor.core.enums.TaskType;
import com.zy.acs.conveyor.core.model.Task;
import com.zy.acs.conveyor.core.model.protocol.StaProtocol;
import com.zy.acs.conveyor.core.constant.RedisConveyorConstant;
import com.zy.acs.conveyor.core.model.StaProtocol;
import com.zy.acs.conveyor.core.properties.DevpSlave;
import com.zy.acs.conveyor.core.properties.OutputQueue;
import com.zy.acs.conveyor.core.properties.SlaveProperties;
import com.zy.acs.conveyor.core.service.StationService;
import com.zy.acs.conveyor.entity.Devp;
import com.zy.acs.conveyor.service.DevpService;
import com.zy.acs.framework.annotations.ManagerAuth;
@@ -34,8 +31,16 @@
    @Autowired
    private SlaveProperties slaveProperties;
    @Autowired
    private DevpService devpService;
    @Autowired
    private StationService stationService;
    private final RedisSupport redis = RedisSupport.defaultRedisSupport;
    @PostMapping("/table/site")
@@ -45,8 +50,8 @@
        // 内存数据
        Map<Integer, StaProtocol> station = new HashMap<>();
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            station.putAll(devpThread.getStation());
            Map<Integer, StaProtocol> stationMap = stationService.getStationMap(devp.getId());
            station.putAll(stationMap);
        }
        // 持久数据
        List<Devp> devps = devpService.selectList(new EntityWrapper<Devp>().orderBy("dev_no"));
@@ -64,7 +69,6 @@
            vo.setLoading(staProtocol.isLoading() ? "Y" : "N");     // 有物
            vo.setInEnable(staProtocol.isInEnable() ? "Y" : "N");   // 可入
            vo.setOutEnable(staProtocol.isOutEnable() ? "Y" : "N"); // 可出
            vo.setPakMk(staProtocol.isPakMk() ? "Y" : "N");       // 入库标记
            vo.setEmptyMk(staProtocol.isEmptyMk() ? "Y" : "N");     // 空板信号
            vo.setStaNo(staProtocol.getStaNo());                // 目标站
//            vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高");     //高低库位
@@ -96,8 +100,7 @@
    public R siteDetl(@PathVariable("siteId") Integer siteId) {
        SiteTableVo vo = new SiteTableVo();
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            Map<Integer, StaProtocol> station = devpThread.getStation();
            Map<Integer, StaProtocol> station = stationService.getStationMap(devp.getId());
            for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
                if (siteId.equals(entry.getKey())) {
                    StaProtocol staProtocol = entry.getValue();
@@ -107,7 +110,6 @@
                    vo.setLoading(staProtocol.isLoading() ? "Y" : "N");     // 有物
                    vo.setInEnable(staProtocol.isInEnable() ? "Y" : "N");   // 可入
                    vo.setOutEnable(staProtocol.isOutEnable() ? "Y" : "N"); // 可出
                    vo.setPakMk(staProtocol.isPakMk() ? "Y" : "N");       // 需求1
                    vo.setEmptyMk(staProtocol.isEmptyMk() ? "Y" : "N");     // 空板信号
                    vo.setStaNo(staProtocol.getStaNo());                // 目标站
                    vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高");     //高低库位
@@ -125,8 +127,7 @@
                            @RequestParam Integer staNo,
                            @RequestParam String pakMk) {
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            Map<Integer, StaProtocol> station = devpThread.getStation();
            Map<Integer, StaProtocol> station = stationService.getStationMap(devp.getId());
            for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
                if (siteId.equals(entry.getKey())) {
                    StaProtocol staProtocol = entry.getValue();
@@ -141,15 +142,9 @@
                    if (staNo != null) {
                        staProtocol.setStaNo(staNo);
                    }
                    if (pakMk != null) {
                        staProtocol.setPakMk(pakMk.equals("Y"));
                    }
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(TaskType.WRITE, staProtocol));
                    if (result) {
                    redis.push(RedisConveyorConstant.CONVEYOR_TASK_FLAG, staProtocol);
                        return R.ok();
                    } else {
                        return R.error("下发命令失败");
                    }
                }
            }
        }