自动化立体仓库 - WCS系统
#
zwl
2023-01-29 6ed70263efe02a6b302d938f5c1502c2fc4a9e28
#
5个文件已修改
239 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/SiteController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 133 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/pipeline.html 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/SiteController.java
@@ -45,12 +45,24 @@
        for (DevpSlave devp : slaveProperties.getDevp()) {
            SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            if (devp.getId() == 1) {
                Map<String, Object> map1 = new HashMap<>();
                map1.put("floor", 1);
                map1.put("modeVal", devpThread.ioModeOf1F.id);
                map1.put("modeDesc", devpThread.ioModeOf1F.desc);
                res.add(map1);
                Map<String, Object> map2 = new HashMap<>();
                map2.put("floor", 2);
                map2.put("modeVal", devpThread.ioModeOf2F.id);
                map2.put("modeDesc", devpThread.ioModeOf2F.desc);
                res.add(map2);
            } else {
                Map<String, Object> map3 = new HashMap<>();
                map3.put("floor", 3);
                map3.put("modeVal", devpThread.ioModeOf3F.id);
                map3.put("modeDesc", devpThread.ioModeOf3F.desc);
                res.add(map3);
                Map<String, Object> map4 = new HashMap<>();
                map4.put("floor", 4);
                map4.put("modeVal", devpThread.ioModeOf4F.id);
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -125,8 +125,10 @@
                // 入出库模式判断
//                if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; }
                if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { continue; }
                if ( inSta.getStaNo()==402 && devpThread.ioModeOf4F == IoModeType.PAKOUT_MODE) { continue; }
                if ( inSta.getStaNo()==101 && devpThread.ioModeOf1F == IoModeType.PAKOUT_MODE) { continue; }
                if ( inSta.getStaNo()==103 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { continue; }
                if ( inSta.getStaNo()==105 && devpThread.ioModeOf3F == IoModeType.PAKOUT_MODE) { continue; }
                if ( inSta.getStaNo()==107 && devpThread.ioModeOf4F == IoModeType.PAKOUT_MODE) { continue; }
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading()
@@ -191,7 +193,7 @@
                            }
                        } else {
                            staProtocol.setWorkNo((short) 9999);
                            staProtocol.setStaNo((short)(inSta.getStaNo()+1));
                            staProtocol.setStaNo((short)(inSta.getStaNo()-1));
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -794,8 +796,10 @@
            // 入出库模式判断
            //if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; }
                if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {continue;}
                if (wrkMast.getStaNo() == 402 && devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) {continue;}
                if (wrkMast.getStaNo() == 101 && devpThread.ioModeOf1F != IoModeType.PAKOUT_MODE) {continue;}
                if (wrkMast.getStaNo() == 103 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {continue;}
                if (wrkMast.getStaNo() == 105 && devpThread.ioModeOf3F != IoModeType.PAKOUT_MODE) {continue;}
                if (wrkMast.getStaNo() == 107 && devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) {continue;}
                // 查询站点详细信息
                BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
@@ -1905,15 +1909,33 @@
                    }
                    WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo());
                    switch (inSta.getStaNo()) {
                        case 203://1F
                        case 101://1F
                            if (pakout != null) {
                                if (devpThread.ioModeOf1F != IoModeType.PAKOUT_MODE) {
                                    // 出库切换中
                                    devpThread.ioModeOf1F = IoModeType.PAKOUT_BOOTING;
                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
                                    if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading()
                                            && !devpThread.getStation().get(inSta.getStaNo()-1).isLoading()
                                            && devpThread.getStation().get(inSta.getStaNo()-1).getWorkNo()==0) {
                                        // 出库模式
                                        devpThread.ioModeOf1F = IoModeType.PAKOUT_MODE;
                                    }
                                }
                            } else {
                                // 入库模式
                                devpThread.ioModeOf1F = IoModeType.PAKIN_MODE;
                            }
                            break;
                        case 103://1F
                            if (pakout != null) {
                                if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {
                                    // 出库切换中
                                    devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING;
                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
                                    if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading()
                                            && !devpThread.getStation().get(inSta.getStaNo()+1).isLoading()
                                            && devpThread.getStation().get(inSta.getStaNo()+1).getWorkNo()==0) {
                                            && !devpThread.getStation().get(inSta.getStaNo()-1).isLoading()
                                            && devpThread.getStation().get(inSta.getStaNo()-1).getWorkNo()==0) {
                                        // 出库模式
                                        devpThread.ioModeOf2F = IoModeType.PAKOUT_MODE;
                                    }
@@ -1923,13 +1945,27 @@
                                devpThread.ioModeOf2F = IoModeType.PAKIN_MODE;
                            }
                            break;
                        case 402://1F
                        case 105://1F
                            if (pakout != null) {
                                if ((pakout.getIoType()==103 || pakout.getIoType()==107)&& pakout.getWrkSts()==14 && devpThread.getStation().get(inSta.getStaNo()-1).getWorkNo()==0){
                                }else if ((pakout.getIoType()==103 || pakout.getIoType()==107)&& pakout.getWrkSts()==14 && devpThread.getStation().get(inSta.getStaNo()-1).getWorkNo()!=0) {
                                    // 入库模式
                                    devpThread.ioModeOf4F = IoModeType.PAKIN_MODE;
                                }else if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) {
                                if (devpThread.ioModeOf3F != IoModeType.PAKOUT_MODE) {
                                    // 出库切换中
                                    devpThread.ioModeOf3F = IoModeType.PAKOUT_BOOTING;
                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
                                    if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading()
                                            && !devpThread.getStation().get(inSta.getStaNo()-1).isLoading()
                                            && devpThread.getStation().get(inSta.getStaNo()-1).getWorkNo()==0) {
                                        // 出库模式
                                        devpThread.ioModeOf3F = IoModeType.PAKOUT_MODE;
                                    }
                                }
                            } else {
                                // 入库模式
                                devpThread.ioModeOf3F = IoModeType.PAKIN_MODE;
                            }
                            break;
                        case 107://1F
                            if (pakout != null) {
                                if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) {
                                    // 出库切换中
                                    devpThread.ioModeOf4F = IoModeType.PAKOUT_BOOTING;
                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
@@ -1941,12 +1977,8 @@
                                    }
                                }
                            } else {
                                List<WrkMast> wrkMasts = wrkMastMapper.selectWorkings();
                                if (wrkMasts.size()==0){
                                    // 入库模式
                                    devpThread.ioModeOf4F = IoModeType.PAKIN_MODE;
                                }else {
                                }
                                // 入库模式
                                devpThread.ioModeOf4F = IoModeType.PAKIN_MODE;
                            }
                            break;
                    }
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -44,13 +44,12 @@
    private short heartBeatVal = 1;
    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(100);add(101);add(102);add(103);add(104);
        add(201);add(202);add(203);
    }};
    public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
        add(401);add(402);
//        add(401);add(402);
    }};
    private Integer count=0;
@@ -68,8 +67,10 @@
     * 3.出库启动中 (不能生成入库工作档)
     * 4.出库模式
     */
    public IoModeType ioModeOf1F = IoModeType.NONE;
    public IoModeType ioModeOf2F = IoModeType.NONE;
//    public IoModeType ioMode = IoModeType.NONE;
    public IoModeType ioModeOf3F = IoModeType.NONE;
    public IoModeType ioModeOf4F = IoModeType.NONE;
//    public IoModeType ioMode = IoModeType.NONE;
@@ -180,7 +181,7 @@
        updateIoMode();
        ArrayList<Integer> staNos = getStaNo();
        int staNoSize = staNos.size();
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*4));
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*2));
        if (result.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                Integer siteId = staNos.get(i); // 站点编号
@@ -190,29 +191,29 @@
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4));     // 工作号
                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*2));     // 工作号
                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4 + 2));   // 目标站
//                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4 + 2));   // 目标站
            }
        }
//        Thread.sleep(200);
//        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
//        if (result0.IsSuccess) {
//            for (int i = 0; i < 93; i++) {
//                Integer siteId = staNos.get(i); // 站点编号
//                StaProtocol staProtocol = station.get(siteId);
//                if (null == staProtocol) {
//                    staProtocol = new StaProtocol();
//                    staProtocol.setSiteId(siteId);
//                    station.put(siteId, staProtocol);
//                }
//                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2));   // 目标站
//            }
//        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) (staNoSize*2));
        if (result0.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2));   // 目标站
            }
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result1 = null;
        if(slave.getId()==1) {
            result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize));
            result1 = siemensS7Net.Read("DB102.100", (short) (staNoSize));
            if (result1.IsSuccess) {
                for (int i = 0; i < staNoSize; i++) {
                    Integer siteId = staNos.get(i); // 站点编号
@@ -234,48 +235,36 @@
                }
            }
        } else if(slave.getId()==2) {
            result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize * 2));
            if (result1.IsSuccess) {
                for (int i = 0; i < staNoSize; i++) {
                    Integer siteId = staNos.get(i); // 站点编号
                    boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i * 2, 1);
                    StaProtocol staProtocol = station.get(siteId);
                    staProtocol.setAutoing(status[0]);  // 自动
                    staProtocol.setLoading(status[1]);  // 有物
                    staProtocol.setInEnable(status[2]); // 可入
                    staProtocol.setOutEnable(status[3]);// 可出
                    staProtocol.setEmptyMk(status[4]);  // 空板信号
                    staProtocol.setFullPlt(status[5]);  // 满托盘
                    staProtocol.setHigh(status[6]);     // 高库位
                    staProtocol.setLow(status[7]);      // 低库位
                    if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
                        staProtocol.setPakMk(true);
                    }
                }
                count = 0;
            }
//            result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize * 2));
//            if (result1.IsSuccess) {
//                for (int i = 0; i < staNoSize; i++) {
//                    Integer siteId = staNos.get(i); // 站点编号
//                    boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i * 2, 1);
//                    StaProtocol staProtocol = station.get(siteId);
//                    staProtocol.setAutoing(status[0]);  // 自动
//                    staProtocol.setLoading(status[1]);  // 有物
//                    staProtocol.setInEnable(status[2]); // 可入
//                    staProtocol.setOutEnable(status[3]);// 可出
//                    staProtocol.setEmptyMk(status[4]);  // 空板信号
//                    staProtocol.setFullPlt(status[5]);  // 满托盘
//                    staProtocol.setHigh(status[6]);     // 高库位
//                    staProtocol.setLow(status[7]);      // 低库位
//
//                    if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
//                        staProtocol.setPakMk(true);
//                    }
//                }
//                count = 0;
//            }
        }
        Thread.sleep(200);
        if(slave.getId()==1) {
            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.150", (short) (barcodeSize * 8));
            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.200", (short) (barcodeSize * 8));
            if (result2.IsSuccess) {
                for (int i = 0; i < barcodeSize; i++) {
                    String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8");
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
                    if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                        barcodeThread.setBarcode(barcode);
                    }
                }
            }
        } else if(slave.getId()==2) {
            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.150", (short) (1 * 8));
            if (result2.IsSuccess) {
                for (int i = 0; i < 1; i++) {
                    String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8");
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 4);
                    if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                        barcodeThread.setBarcode(barcode);
                    }
@@ -330,11 +319,11 @@
        short[] array = new short[2];
        array[0] = staProtocol.getWorkNo();
        array[1] = staProtocol.getStaNo();
        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);
//        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);
//        OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 工作号
//        Thread.sleep(500);
//        OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo());    // 目标站
        OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 工作号
        Thread.sleep(500);
        OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo());    // 目标站
        if (!write.IsSuccess) {
            staProtocol = station.get(staProtocol.getSiteId());
@@ -351,15 +340,27 @@
    // 更新入出库模式
    private void updateIoMode() throws InterruptedException {
        if (slave.getId()==1 && this.ioModeOf2F != IoModeType.NONE) {
            if (!siemensS7Net.Write("DB100.180", this.ioModeOf2F.id).IsSuccess) {
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线2F入出库模式失败。输送线plc编号={1}", slave.getId()));
        if (this.ioModeOf1F != IoModeType.NONE) {
            if (!siemensS7Net.Write("DB100.180", this.ioModeOf1F.id).IsSuccess) {
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F1入出库模式失败。输送线plc编号={1}", slave.getId()));
                log.error("写入输送线1F入出库模式失败。输送线plc编号={}", slave.getId());
            }
        }
        if (this.ioModeOf2F != IoModeType.NONE) {
            if (!siemensS7Net.Write("DB100.182", this.ioModeOf2F.id).IsSuccess) {
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F2入出库模式失败。输送线plc编号={1}", slave.getId()));
                log.error("写入输送线2F入出库模式失败。输送线plc编号={}", slave.getId());
            }
        }
        if (slave.getId()==2 && this.ioModeOf4F != IoModeType.NONE) {
            if (!siemensS7Net.Write("DB100.170", this.ioModeOf4F.id).IsSuccess) {
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线4F入出库模式失败。输送线plc编号={1}", slave.getId()));
        if (this.ioModeOf3F != IoModeType.NONE) {
            if (!siemensS7Net.Write("DB100.184", this.ioModeOf3F.id).IsSuccess) {
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F3入出库模式失败。输送线plc编号={1}", slave.getId()));
                log.error("写入输送线3F入出库模式失败。输送线plc编号={}", slave.getId());
            }
        }
        if (this.ioModeOf4F != IoModeType.NONE) {
            if (!siemensS7Net.Write("DB100.186", this.ioModeOf4F.id).IsSuccess) {
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F4入出库模式失败。输送线plc编号={1}", slave.getId()));
                log.error("写入输送线4F入出库模式失败。输送线plc编号={}", slave.getId());
            }
        }
src/main/resources/application.yml
@@ -41,7 +41,7 @@
  # 双深
  doubleDeep: true
  # 双深库位排号
  doubleLocs: 1,4,5,8,9,12,13,16
  doubleLocs: 1,4,5,8
  # 一个堆垛机负责的货架排数
  groupCount: 4
  # 堆垛机1
@@ -71,7 +71,7 @@
    # 堆垛机出库站点1
    crnOutStn[0]:
      devpPlcId: ${wcs-slave.devp[0].id}
      staNo: 100
      staNo: 101
      row: 2
      bay: 1
      lev: 1
@@ -79,7 +79,7 @@
    # 堆垛机出库站点1
    crnOutStn[1]:
      devpPlcId: ${wcs-slave.devp[0].id}
      staNo: 102
      staNo: 103
      row: 3
      bay: 1
      lev: 1
@@ -110,13 +110,13 @@
    # 堆垛机出库站点
    crnOutStn[0]:
      devpPlcId: ${wcs-slave.devp[0].id}
      staNo: 104
      staNo: 105
      row: 6
      bay: 1
      lev: 1
    crnOutStn[1]:
      devpPlcId: ${wcs-slave.devp[0].id}
      staNo: 106
      staNo: 107
      row: 7
      bay: 1
      lev: 1
src/main/webapp/views/pipeline.html
@@ -59,8 +59,16 @@
                        <fieldset>
                            <legend>入出库模式(IO-Mode)</legend>
                            <div class="io-mode-box">
                                <label>F1</label>
                                <button id="io-mode-1" class="ioModeBtn" onclick="ioModeSwitch(this.id)"> - </button>
                            </div>
                            <div class="io-mode-box">
                                <label>F2</label>
                                <button id="io-mode-2" class="ioModeBtn" onclick="ioModeSwitch(this.id)"> - </button>
                            </div>
                            <div class="io-mode-box">
                                <label>F3</label>
                                <button id="io-mode-3" class="ioModeBtn" onclick="ioModeSwitch(this.id)"> - </button>
                            </div>
                            <div class="io-mode-box">
                                <label>F4</label>
@@ -229,7 +237,7 @@
                    if (e.modeVal === 3 || e.modeVal === 4) {
                        layer.confirm('确定切换为入库模式吗?',function () {
                            $.ajax({
                                url: baseUrl+ "/site/io/mode/action/site",
                                url: baseUrl+ "/site/io/mode/info/site",
                                headers: {'token': localStorage.getItem('token')},
                                data: {floor: e.floor},
                                method: 'POST',