自动化立体仓库 - WCS系统
whycq
2022-03-18 afe777a76ae3448a53986aac22b3a667a21c64c7
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;
@@ -93,7 +94,6 @@
     * 组托
     * 入库站,根据条码扫描生成入库工作档,工作状态 2
     */
    @Async
    public void generateStoreWrkFile() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -115,18 +115,35 @@
                }
                // 获取入库站信息
                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 ( inSta.getStaNo()==180 && devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; }
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999)
                        && staProtocol.isPakMk() && !Cools.isEmpty(barcode)) {
                        && staProtocol.isPakMk()){// && !Cools.isEmpty(barcode)) {
//                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
//                        //条码为空或者不符合,退库到172站点
//                        staProtocol.setWorkNo((short)9999);
//                        staProtocol.setStaNo((short)172);
//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
//                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                        if (!result) {
//                            throw new CoolException("更新plc站点信息失败");
//                        }
//                        continue;
//                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
@@ -247,20 +264,23 @@
     * wms入库
     * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2
     */
    @Async
    public void generateStoreWrkFile0() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
            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)
@@ -318,14 +338,32 @@
                }
                // 获取拣料入库站信息
                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)) {
//                        log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
//                        //条码为空或者不符合,退库到172站点
//                        staProtocol.setWorkNo((short)9999);
//                        staProtocol.setStaNo((short)172);
//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
//                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                        if (!result) {
//                            throw new CoolException("更新plc站点信息失败");
//                        }
//                        continue;
//                    }
                    WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
                    if (wrkMast == null) {
                        // 无拣料数据
@@ -665,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) {
@@ -792,7 +835,7 @@
        }
        // 已经存在吊车执行任务时,则过滤
        if (wrkMastMapper.selectLocMoving(slave.getId()) != null) {
        if (wrkMastMapper.selectWorking(slave.getId()) != null) {
            return;
        }
@@ -991,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()) {
@@ -1340,6 +1387,15 @@
        for (Integer row : rows) {
            if (Utils.isDeepLoc(slaveProperties, row)) {
                loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1());
                if (Utils.isDeepLoc(slaveProperties, loc.getLocNo())){
                    String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo());
                    LocMast shallowLoc1 = locMastService.selectById(shallowLocNo);
                    if(!shallowLoc1.getLocSts().equals("O")){
                        loc = null;
                    }
                }
                if (null != loc) { break; }
            }
        }
@@ -1554,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();
        }
    }
}