自动化立体仓库 - WCS系统
whycq
2022-03-16 e1ab7f1517041275be4b2e30210b2b65736b9d4a
Merge remote-tracking branch 'origin/xgmwcs' into xgmwcs
1个文件已添加
7个文件已修改
168 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/mapper/WrkMastMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/IoModeType.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/MelsecCrnThread.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/WrkMastMapper.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/WrkMastMapper.java
@@ -70,4 +70,8 @@
    @Update("update cust_wait_pakin set io_status='F' where zpallet = #{barcode}")
    int updateWaitPakInStep2(String barcode);
    WrkMast selectWorkingPakin();
    WrkMast selectWorkingPakout();
}
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -37,6 +37,7 @@
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
import com.zy.core.thread.LedThread;
import com.zy.core.thread.SiemensDevpThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -114,13 +115,17 @@
//                }
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 入出库模式判断
                if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; }
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading()
                        && staProtocol.isInEnable()
@@ -265,13 +270,17 @@
            // 遍历入库口
            for (DevpSlave.Sta inSta : devp.getInSta()) {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 入出库模式判断
                if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; }
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999)
@@ -329,13 +338,17 @@
//                }
                // 获取拣料入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 入出库模式判断
                if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){
                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
@@ -690,13 +703,18 @@
                continue;
            }
            // 获取堆垛机出库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
            SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
            StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
            if (staProtocol == null) {
                continue;
            } else {
                staProtocol = staProtocol.clone();
            }
            // 入出库模式判断
            if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; }
            // 查询站点详细信息
            BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
            if (staDetl == null) {
@@ -1016,13 +1034,17 @@
            // 遍历空板入库口
            for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) {
                // 获取空板入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 入出库模式判断
                if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; }
                // 站点条件判断
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
                        && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9990 || staProtocol.getWorkNo() == 9997) && staProtocol.isPakMk()) {
@@ -1588,5 +1610,39 @@
        }
    }
    /**
     * 入出库模式切换函数
     */
    public void ioConvert() {
        try {
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                WrkMast pakout = wrkMastMapper.selectWorkingPakout();
                if (pakout != null) {
                    if (devpThread.ioMode != IoModeType.PAKOUT_MODE) {
                        // 出库切换中
                        devpThread.ioMode = IoModeType.PAKOUT_BOOTING;
                        WrkMast pakin = wrkMastMapper.selectWorkingPakin();
                        if (pakin == null && !devpThread.getStation().get(201).isLoading() && !devpThread.getStation().get(202).isLoading()) {
                            // 出库模式
                            devpThread.ioMode = IoModeType.PAKOUT_MODE;
                        }
                    }
                } else {
                    // 入库模式
                    devpThread.ioMode = IoModeType.PAKIN_MODE;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
src/main/java/com/zy/core/MainProcess.java
@@ -41,7 +41,8 @@
                    // 演示
                    mainService.crnDemoOfLocMove1();
                    // 入出库模式切换函数
                    mainService.ioConvert();
                    // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                    mainService.generateStoreWrkFile(); // 组托
                    mainService.generateStoreWrkFile0(); // WMS入库
@@ -58,7 +59,7 @@
                    // 堆垛机异常信息记录
                    mainService.recCrnErr();
                    // 入库  ===>> 空栈板初始化入库,叉车入库站放货
                    mainService.storeEmptyPlt();
//                    mainService.storeEmptyPlt();
                    // 出库  ===>> 工作档信息写入led显示器
                    mainService.ledExecute();
                    // 其他  ===>> LED显示器复位,显示默认信息
src/main/java/com/zy/core/enums/IoModeType.java
New file
@@ -0,0 +1,32 @@
package com.zy.core.enums;
/**
 * 入出库模式枚举
 */
public enum IoModeType {
    NONE((short) 0, "未知"),
    PAKIN_BOOTING((short) 1, "入库启动中"),
    PAKIN_MODE((short) 2, "入库模式"),
    PAKOUT_BOOTING((short) 3, "出库启动中"),
    PAKOUT_MODE((short) 4, "出库模式"),
    ;
    public Short id;
    public String desc;
    IoModeType(Short id, String desc) {
        this.id = id;
        this.desc = desc;
    }
    public static IoModeType get(Short id) {
        for (IoModeType type : IoModeType.values()) {
            if (id.equals(type.id)) {
                return type;
            }
        }
        return IoModeType.NONE;
    }
}
src/main/java/com/zy/core/thread/MelsecCrnThread.java
@@ -198,7 +198,6 @@
                    }
                }
                // 根据实时信息更新数据库
                BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class);
                BasCrnp basCrnp = new BasCrnp();
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -12,6 +12,7 @@
import com.zy.core.DevpThread;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.enums.IoModeType;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.Task;
@@ -47,8 +48,11 @@
        add(150);add(151);add(152);add(153);add(154);add(155);add(156);add(157);add(158);add(159);
        add(160);add(161);add(162);add(163);add(164);add(165);add(166);add(167);add(168);add(169);
        add(170);add(171);add(172);add(173);add(174);add(175);add(176);add(177);add(178);add(179);
        add(180);add(181);add(182);
        add(180);add(181);add(182);add(183);add(184);add(185);add(186);add(187);add(188);add(189);
        add(190);add(191);add(192);
    }};
    public IoModeType ioMode = IoModeType.NONE;
    public SiemensDevpThread(DevpSlave slave) {
        this.slave = slave;
@@ -110,7 +114,9 @@
     * 读取状态 ====> 整块plc
     */
    private void read() throws InterruptedException {
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 166);
        // 更新入出库模式
        updateIoMode();
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 186);
        if (result.IsSuccess) {
            for (int i = 0; i < 83; i++) {
                Integer siteId = staNos.get(i); // 站点编号
@@ -124,7 +130,7 @@
            }
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 166);
        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
        if (result0.IsSuccess) {
            for (int i = 0; i < 83; i++) {
                Integer siteId = staNos.get(i); // 站点编号
@@ -138,7 +144,7 @@
            }
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) 166);
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) 186);
        if (result1.IsSuccess) {
            for (int i = 0; i < 83; i++) {
                Integer siteId = staNos.get(i); // 站点编号
@@ -157,6 +163,11 @@
                    staProtocol.setPakMk(true);
                }
            }
        }
        OperateResultExOne<Short> result2 = siemensS7Net.ReadInt16("DB200.0");
        if (result2.IsSuccess) {
            this.ioMode = IoModeType.get(result2.Content);
        }
        if (result.IsSuccess && result0.IsSuccess && result1.IsSuccess) {
@@ -210,6 +221,16 @@
        }
    }
    // 更新入出库模式
    private void updateIoMode() throws InterruptedException {
        if (this.ioMode != IoModeType.NONE) {
            if (!siemensS7Net.Write("DB200", this.ioMode.id).IsSuccess) {
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线1F入出库模式失败。输送线plc编号={1}", slave.getId()));
                log.error("写入输送线1F入出库模式失败。输送线plc编号={}", slave.getId());
            }
        }
    }
    /**
     * 心跳
     */
src/main/resources/application.yml
@@ -11,7 +11,8 @@
    #    url: jdbc:sqlserver://47.97.1.152:51433;databasename=xgmasrs
    #    username: sa
    #    password: Zoneyung@zy56$
    url: jdbc:sqlserver://10.10.10.238:1433;databasename=xgmasrs
#    url: jdbc:sqlserver://10.10.10.238:1433;databasename=xgmasrs
    url: jdbc:sqlserver://localhost:1433;databasename=xgmasrs
    username: sa
    password: sa@123
  mvc:
@@ -169,6 +170,9 @@
    inSta[0]:
      staNo: 176
      barcode: ${wcs-slave.barcode[0].id}
    inSta[1]:
      staNo: 180
      barcode: ${wcs-slave.barcode[1].id}
    # 空板入库口1
    emptyInSta[0]:
      staNo: 176
@@ -187,6 +191,10 @@
    id: 1
    ip: 10.10.10.52
    port: 51236
  barcode[1]:
    id: 2
    ip: 10.10.10.53
    port: 51236
   # LED1
  led[0]:
    id: 1
src/main/resources/mapper/WrkMastMapper.xml
@@ -119,4 +119,25 @@
        select top 1 * from dbo.asr_wrk_mast where 1=1 and (wrk_sts=3 or wrk_sts=12) and crn_no=#{crnNo} order by io_time,wrk_no
    </select>
    <!-- 入库任务 -->
    <select id="selectWorkingPakin" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where wrk_sts in (2,3,4) and io_type != 11 order by io_time,wrk_no
    </select>
    <!-- 出库任务 -->
    <select id="selectWorkingPakout" resultMap="BaseResultMap">
        select top 1 *
        from dbo.asr_wrk_mast
        where (wrk_sts in (11,12)
        or (wrk_sts in (14,15) and wrk_no in
        (
        select wrk_no
        from asr_bas_devp
        where wrk_no > 0)
        ))
        and io_type != 11
        order by io_time,wrk_no
    </select>
</mapper>