自动化立体仓库 - WCS系统
Junjie
2023-11-27 95a8a2bd5b418980860fcaac6a6f5293e9cd65f2
src/main/java/com/zy/asrs/controller/SiteController.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.domain.vo.PlcErrorTableVo;
import com.zy.asrs.domain.vo.SiteTableVo;
@@ -20,10 +21,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 输送设备接口
@@ -56,6 +54,38 @@
    @PostMapping("/table/site")
    @ManagerAuth(memo = "站点信息表")
    public R siteTable(){
        List<SiteTableVo> list = new ArrayList<>();
        // 内存数据
        Map<Integer, StaProtocol> station = new HashMap<>();
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            station.putAll(devpThread.getStation());
        }
        // 持久数据
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>().orderBy("dev_no"));
        for (BasDevp devp : basDevps) {
            SiteTableVo vo = new SiteTableVo();
            vo.setDevNo(devp.getDevNo());    // 站点编号
            list.add(vo);
            StaProtocol staProtocol = station.get(devp.getDevNo());
            if (null == staProtocol) { continue; }
            vo.setWorkNo(staProtocol.getWorkNo());   //  工作号
            vo.setAutoing(staProtocol.isAutoing()?"Y":"N");     //  自动
            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() ? "低" : "高");     //高低库位
            vo.setLocType1(devp.getDevNo()==102 ? "高" : "低");
        }
        return R.ok().add(list);
    }
    @GetMapping("/list/auth")
    @ManagerAuth(memo = "站点信息表")
    public R crnList(){
        List<SiteTableVo> list = new ArrayList<>();
        // 内存数据
        Map<Integer, StaProtocol> station = new HashMap<>();
@@ -165,15 +195,22 @@
    @PostMapping("/detl/update")
    @ManagerAuth(memo = "修改站点数据")
    public R siteDetlUpdate(@RequestParam Integer siteId,
    public R siteDetlUpdate(@RequestParam Integer devNo,
                            @RequestParam Short workNo,
                            @RequestParam Short staNo,
                            @RequestParam String pakMk){
                            @RequestParam(required = false) String pakMk,
                            @RequestParam(required = false) Boolean inEnable,
                            @RequestParam(required = false) Boolean outEnable
    ) {
        BasDevp basDevp = basDevpService.selectById(devNo);
        if (basDevp == null) {
            return R.error("站点不存在");
        }
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            Map<Integer, StaProtocol> station = devpThread.getStation();
            for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
                if (siteId.equals(entry.getKey())) {
                if (devNo.equals(entry.getKey())) {
                    StaProtocol staProtocol = entry.getValue();
                    if (staProtocol == null) {
                        continue;
@@ -189,6 +226,15 @@
                    if (pakMk != null) {
                        staProtocol.setPakMk(pakMk.equals("Y"));
                    }
                    if (inEnable != null) {
                        staProtocol.setInEnable(inEnable);
                        basDevp.setInEnable(inEnable ? "Y" : "N");
                    }
                    if (outEnable != null) {
                        staProtocol.setOutEnable(outEnable);
                        basDevp.setOutEnable(outEnable ? "Y" : "N");
                    }
                    basDevpService.updateById(basDevp);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (result) {
                        return R.ok();
@@ -198,7 +244,7 @@
                }
            }
        }
        return R.error("plc已掉线");
        return R.error("更新失败");
    }