whycq
2022-10-18 97fb61157e1f007c00c10c01a7307b0cc374a745
Merge remote-tracking branch 'origin/hylywcs' into hylywcs
4个文件已修改
191 ■■■■ 已修改文件
src/main/java/com/zy/core/thread/SiemensDevpThread.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/console.js 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/console.map.js 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -8,6 +8,7 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.service.BasDevpService;
import com.zy.core.DevpThread;
@@ -41,10 +42,15 @@
    private SiemensS7Net siemensS7Net;
    private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
    private short heartBeatVal = 1;
    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
    public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
        add(101);add(102);add(103);add(104);
        add(201);add(202);add(203);add(204);
        add(301);add(302);add(303);add(304);add(305);add(306);add(401);add(402);
        add(301);add(302);add(303);add(304);add(305);add(306);
    }};
    public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
        add(401);add(402);
    }};
    /**
@@ -67,6 +73,17 @@
    public SiemensDevpThread(DevpSlave slave) {
        this.slave = slave;
    }
    private ArrayList<Integer> getStaNo() {
        switch (slave.getId()) {
            case 1:
                return staNos1;
            case 2:
                return staNos2;
            default:
                throw new CoolException("服务器异常");
        }
    }
    @Override
@@ -102,6 +119,33 @@
        }
    }
    /**
     * 初始化站点状态
     */
    private void initSite() {
        ArrayList<Integer> staNos = getStaNo();
        // 站点编号
        for (Integer siteId : staNos) {
            StaProtocol staProtocol = station.get(siteId);
            if (null == staProtocol) {
                staProtocol = new StaProtocol();
                staProtocol.setSiteId(siteId);
                station.put(siteId, staProtocol);
            }
            staProtocol.setWorkNo((short) 0);    // ID
            staProtocol.setAutoing(false);      // 自动
            staProtocol.setLoading(false);      // 有物
            staProtocol.setInEnable(false);     // 可入
            staProtocol.setOutEnable(false);    // 可出
            staProtocol.setEmptyMk(false);      // 空板信号
            staProtocol.setStaNo((short) 0);     // 目标站
            if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
                staProtocol.setPakMk(true);
            }
        }
    }
    @Override
    public boolean connect() {
        boolean result = false;
@@ -116,6 +160,7 @@
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format( "【{0}】输送线plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.error("输送线plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            initSite();
        }
        siemensS7Net.ConnectClose();
        return result;
@@ -127,6 +172,7 @@
    private void read() throws InterruptedException {
//        // 更新入出库模式
        updateIoMode();
        ArrayList<Integer> staNos = getStaNo();
        int staNoSize = staNos.size();
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*4));
        if (result.IsSuccess) {
@@ -220,6 +266,7 @@
            }
        } else {
            initSite();
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】读取输送线plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
//            log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
        }
@@ -232,6 +279,7 @@
        if (null == staProtocol) {
            return;
        }
        ArrayList<Integer> staNos = getStaNo();
        int index = staNos.indexOf(staProtocol.getSiteId());
        short[] array = new short[2];
        array[0] = staProtocol.getWorkNo();
@@ -297,14 +345,14 @@
    }
    public static void main(String[] args) {
        System.out.println(staNos.indexOf(129));
        System.out.println(staNos.size());
        for (int i = 0; i<staNos.size(); i++) {
        System.out.println(staNos1.indexOf(129));
        System.out.println(staNos1.size());
        for (int i = 0; i< staNos1.size(); i++) {
//            System.out.println(i*2);
//            System.out.println(i*2 + 200);
//            System.out.println(i);
        }
        int index = staNos.indexOf(128);
        int index = staNos1.indexOf(128);
        System.out.println(index*2);
        System.out.println(index*2 + 200);
    }
src/main/resources/application.yml
@@ -237,6 +237,28 @@
    pickSta[3]:
      staNo: 402
      barcode: ${wcs-slave.barcode[3].id}
  devp[1]:
    id: 1
    ip: 10.10.10.60
    port: 102
    rack: 0
    slot: 0
    # 入库口1
    inSta[0]:
      staNo: 401
      barcode: ${wcs-slave.barcode[3].id}
    # 空板入库口1
    emptyInSta[0]:
      staNo: 401
    # 出库口1
    outSta[0]:
      staNo: 402
    # 拣料入库口1
    pickSta[0]:
      staNo: 402
      barcode: ${wcs-slave.barcode[3].id}
  # 条码扫描仪
  barcode[0]:
    id: 1
src/main/webapp/static/js/console.js
@@ -25,36 +25,59 @@
    for (let i = 0;i < rackss.length;i++) {
        let bay ='' // 单个库位
        let bays = '' // 库位集合
        let bayWidth = rackss[i].width / (rackss[i].maxBayNo / rackss[i].minBayNo)
        let maxBayNo = rackss[i].maxBayNo // 最大库位号
        let minBayNo = rackss[i].minBayNo // 最小库位号
        let bLen = maxBayNo / minBayNo // 库位个数
        let bLen
        let interval // 间隔数
        if (maxBayNo<35) {
            interval = 1
            bLen = maxBayNo / interval // 库位个数
        } else {
            interval = 2
            bLen = maxBayNo / interval // 库位个数
        }
        let bayWidth // 单个库位宽度
        let bNum // 库位号码
        // hpPosition 0 表示货架序号 左->右 1 表示货架序号 右->左
        if (minBayNo % 2 == 0) { // 从2开始
            if(interval == 1) {
                bLen = bLen - 1
            } else if (interval == 2) {
                if (maxBayNo % 2 == 0) { // 偶数
                    bLen = bLen
                } else { // 奇数
                    maxBayNo = maxBayNo + 1
                    bLen = maxBayNo / interval // 库位个数
                }
            }
        } else { // 从1开始
            if(interval == 1) {
                bLen = bLen
            } else if (interval == 2) {
                if (maxBayNo % 2 == 0) { // 偶数
                    bLen = bLen
                } else { // 奇数
                    bLen = bLen + 1
                }
            }
        }
        bayWidth = rackss[i].width / bLen
        // hpPosition 0 表示货架序号 左->右 1 表示货架序号 左<-右
        if (mapInfo.hpPosition == 1) {
            bNum = maxBayNo
            for (let j = bLen; j > 0; j--) {
                bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                bays = bays + bay
                bNum = bNum - minBayNo;
                bNum = bNum - interval;
            }
        }else {
            if (minBayNo % 2 == 0) {
                bNum = minBayNo
                for (let j = 0; j < bLen; j++) {
                    bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                    bays = bays + bay
                    bNum = bNum + minBayNo;
                }
            } else {
                bNum = minBayNo + 1
                for (let j = 0; j < bLen; j++) {
                    bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                    bays = bays + bay
                    bNum = bNum + minBayNo;
                }
            bNum = minBayNo
            for (let j = 0; j < bLen; j++) {
                bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                bays = bays + bay
                bNum = bNum + interval;
            }
        }
        rack = "<div class='rack' id='" + rackss[i].id +
src/main/webapp/static/js/console.map.js
@@ -14,8 +14,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 30
            "minBayNo": 2,
            "maxBayNo": 31
        },
        {
            "type": "rack",
@@ -24,8 +24,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 30
            "minBayNo": 2,
            "maxBayNo": 31
        },
        {
            "type": "rack",
@@ -34,8 +34,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 30
            "minBayNo": 2,
            "maxBayNo": 31
        },
        {
            "type": "rack",
@@ -44,8 +44,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 30
            "minBayNo": 2,
            "maxBayNo": 31
        },
        {
            "type": "rack",
@@ -54,8 +54,8 @@
            "left": 430,
            "width": 1088,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 16
            "minBayNo": 2,
            "maxBayNo": 17
        },
        {
            "type": "rack",
@@ -64,8 +64,8 @@
            "left": 430,
            "width": 1088,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 16
            "minBayNo": 2,
            "maxBayNo": 17
        },
        {
            "type": "rack",
@@ -74,8 +74,8 @@
            "left": 430,
            "width": 1088,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 16
            "minBayNo": 2,
            "maxBayNo": 17
        },
        {
            "type": "rack",
@@ -84,8 +84,8 @@
            "left": 430,
            "width": 1088,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 16
            "minBayNo": 2,
            "maxBayNo": 17
        },
        {
            "type": "rack",
@@ -134,8 +134,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 23
            "minBayNo": 2,
            "maxBayNo": 24
        },
        {
            "type": "rack",
@@ -144,8 +144,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 23
            "minBayNo": 2,
            "maxBayNo": 24
        },
        {
            "type": "rack",
@@ -154,8 +154,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 23
            "minBayNo": 2,
            "maxBayNo": 24
        },
        {
            "type": "rack",
@@ -164,8 +164,8 @@
            "left": 430,
            "width": 1020,
            "height": 24,
            "minBayNo": 1,
            "maxBayNo": 23
            "minBayNo": 2,
            "maxBayNo": 24
        },
    ],
    "rackDescs": [