#
tqs
2022-12-06 50063730a3a8e3559a5ea5f3564ec80a2887369e
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -41,7 +41,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -97,7 +96,7 @@
     * 组托
     * 入库站,根据条码扫描生成入库工作档,工作状态 2
     */
    public void generateStoreWrkFile() {
    public synchronized void generateStoreWrkFile() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
@@ -276,7 +275,7 @@
     * wms入库
     * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2
     */
    public void generateStoreWrkFile0() {
    public synchronized void generateStoreWrkFile0() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
@@ -394,7 +393,8 @@
                    // 获取目标站
                    Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                            .eq("type_no", wrkMast.getIoType() - 50)
                            .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站
                            //速腾特有捡料, 11站是出库站, 然后手动走到15站进行再入库
                            .eq("stn_no", 15) // 作业站点 = 拣料出库的目标站
                            .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号
                    StaDesc staDesc = staDescService.selectOne(wrapper);
                    if (Cools.isEmpty(staDesc)) {
@@ -419,7 +419,7 @@
                        wrkMast.setIoTime(now);
                        wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57
                        wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走
                        wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站
                        wrkMast.setSourceStaNo(staDesc.getStnNo()); // 源站
                        wrkMast.setStaNo(staNo); // 目标站
                        wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位
                        wrkMast.setSourceLocNo(""); // 源库位清空
@@ -461,7 +461,6 @@
    /**
     * 堆垛机站出库到出库站
     */
    @Async
    public synchronized void crnStnToOutStn() {
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            // 遍历堆垛机出库站
@@ -770,7 +769,7 @@
     * 出库  ===>>  库位到堆垛机站
     * 2022-06-09 TQS修改,查询工作档LIST,遍历下发,防止第一个任务堵塞出库
     */
    public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) {
    public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) {
        for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
            // 获取工作状态为11(生成出库ID)的出库工作档
//            WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo());
@@ -861,7 +860,7 @@
                            log.error("{}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo);
                            continue;
                        } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) {
                            WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
                            WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo);
                            if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) {
                                continue;
                            }
@@ -907,7 +906,7 @@
//    /**
//     * 出库  ===>>  库位到堆垛机站
//     */
//    public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
//    public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
//        for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
//            // 获取工作状态为11(生成出库ID)的出库工作档
//            WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo());
@@ -1024,7 +1023,7 @@
    /**
     * 库位移转
     */
    public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) {
    public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) {
        // 获取工作档信息
        WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId());
        if (null == wrkMast) {
@@ -1092,8 +1091,7 @@
    /**
     * 执行对工作档的完成操作
     */
    @Async
    public void storeFinished() {
    public synchronized void storeFinished() {
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
@@ -1136,8 +1134,7 @@
    /**
     * 堆垛机异常信息记录
     */
    @Async
    public void recCrnErr() {
    public synchronized void recCrnErr() {
        Date now = new Date();
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
@@ -1258,8 +1255,7 @@
    /**
     * 空栈板初始化入库,叉车入库站放货
     */
    @Async
    public void storeEmptyPlt() {
    public synchronized void storeEmptyPlt() {
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历空板入库口
            for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) {
@@ -1373,8 +1369,7 @@
    /**
     * 出库  ===>> 工作档信息写入led显示器
     */
    @Async
    public void ledExecute() {
    public synchronized void ledExecute() {
        for (LedSlave led : slaveProperties.getLed()) {
            // 获取输送线plc线程
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
@@ -1490,8 +1485,7 @@
    /**
     * 其他  ===>> LED显示器复位,显示默认信息
     */
    @Async
    public void ledReset() {
    public synchronized void ledReset() {
//        for (LedSlave led : slaveProperties.getLed()) {
//            // 获取输送线plc线程
//            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
@@ -1535,26 +1529,26 @@
                    break;
                }
            }
            // 获取led线程
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
            // led显示默认内容
            if (reset && !ledThread.isLedMk()) {
                if (led.getId() == 7) {
                    ledThread.setLedMk(true);
                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
                        log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    } else {
                    }
                } else {
                    ledThread.setLedMk(true);
                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
                        log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    } else {
                    }
                }
            }
//            // 获取led线程
//            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
//            // led显示默认内容
//            if (reset && !ledThread.isLedMk()) {
//                if (led.getId() == 7) {
//                    ledThread.setLedMk(true);
//                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
//                        log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
//                    } else {
//
//                    }
//                } else {
//                    ledThread.setLedMk(true);
//                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
//                        log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
//                    } else {
//
//                    }
//                }
//            }
        }
    }
@@ -1906,7 +1900,7 @@
    /**
     * 入出库模式切换函数
     */
    public void ioConvert() {
    public synchronized void ioConvert() {
        try {
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -1966,7 +1960,7 @@
    }
    public void outOfDevp() {
    public synchronized void outOfDevp() {
        List<WrkMast> wrkMasts = wrkMastMapper.selectPick();
        for (WrkMast wrkMast : wrkMasts) {
            if (basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo())) == 0) {
@@ -1980,7 +1974,7 @@
    }
    public void autoEmptyOut() {
    public synchronized void autoEmptyOut() {
        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
        Integer autoOutSite = 12;
        //如果站点可出禁用,则不生成空盘出库任务
@@ -2019,7 +2013,7 @@
        }
    }
    public void autoEmptyIn() {
    public synchronized void autoEmptyIn() {
        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
        Integer autoInSite = 12;
        StaProtocol staProtocol = devpThread.getStation().get(autoInSite);