lsh
9 天以前 246c867095e2029379492b82914a4ff327344b6e
自动补空板
2个文件已修改
144 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 140 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -7,6 +7,7 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.exception.CoolException;
import com.zy.asrs.domain.enums.WorkNoType;
import com.zy.asrs.entity.*;
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.TestMastMapper;
@@ -157,7 +158,7 @@
                    // 退回
                    if (back ||(!Cools.isEmpty(barcode) && barcode.equals("00000000"))) {
                    if (back || (!Cools.isEmpty(barcode) && barcode.equals("00000000"))) {
                        staProtocol.setWorkNo((short) 9999);
                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
@@ -1012,7 +1013,7 @@
        WrkMast wrkMast = null;
        if (Cools.isEmpty(wrkMasts)) {
            return;
        }else {
        } else {
            wrkMast = wrkMasts.get(0);
        }
//        //后查等待库位转测试库位
@@ -1406,7 +1407,7 @@
                if (null == wrkMast) {
                    continue;
                }
                log.info(""+mark+" - 0"+" - 开始执行:出库  ===>> 工作档信息写入led显示器");
                log.info("" + mark + " - 0" + " - 开始执行:出库  ===>> 工作档信息写入led显示器");
                wrkMasts.add(wrkMast);
                // 组装命令
                LedCommand ledCommand = new LedCommand();
@@ -1437,7 +1438,7 @@
                        ledCommand.setEmptyMk(true);
                        break;
                    default:
                        News.error(""+mark+" - 1"+" - 任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
                        News.error("" + mark + " - 1" + " - 任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
                        break;
                }
                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
@@ -1446,7 +1447,7 @@
//                ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
                if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) {
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs())));
                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getSpecs())));
                }
                commands.add(ledCommand);
            }
@@ -1481,7 +1482,7 @@
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
                    News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    continue;
                }else {
                } else {
                    ledThread.setLedMk(false);
                }
            }
@@ -1492,7 +1493,7 @@
                    wrkMast.setOveMk("Y");
                    wrkMast.setModiTime(new Date());
                    if (wrkMastMapper.updateById(wrkMast) == 0) {
                        log.error(""+mark+" - 4"+" - 更新工作档失败");
                        log.error("" + mark + " - 4" + " - 更新工作档失败");
                        throw new CoolException("更新工作档失败");
                    }
                }
@@ -1506,7 +1507,7 @@
            }
        }
        log.info(""+mark+" - 0"+" - 出库  ===>> 工作档信息写入led显示器执行完成");
        log.info("" + mark + " - 0" + " - 出库  ===>> 工作档信息写入led显示器执行完成");
    }
    /**
@@ -2028,7 +2029,7 @@
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                if(null != devpThread){
                if (null != devpThread) {
                    //devpThread.startSignal[i][0]
                    //0:空闲,1:待测,2:测试中;3.测试完成;4.测试失败;
@@ -2037,48 +2038,48 @@
                    //testMast.setStatus
                    //"状态 0: 无货  1: 等待测试 2:测试中 3.测试完成;4.测试失败; "
                    for (int i = 0; i < 24; i++){
                    for (int i = 0; i < 24; i++) {
                        //查询在库和预约出库
                        LocMast locMast=locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",i+1));
                        if(!Cools.isEmpty(locMast)){
                            if (locMast.getLocSts().equals("F")){
                                TestMast testMast=testMastService.selectOne(new EntityWrapper<TestMast>()
                                        .eq("loc_no",locMast.getLocNo())
                                        .eq("user_id",locMast.getBarcode()));
                                if(Cools.isEmpty(testMast)){
                        LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel", i + 1));
                        if (!Cools.isEmpty(locMast)) {
                            if (locMast.getLocSts().equals("F")) {
                                TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
                                        .eq("loc_no", locMast.getLocNo())
                                        .eq("user_id", locMast.getBarcode()));
                                if (Cools.isEmpty(testMast)) {
//                                log.info("2377行程序开始运行,测试档为空,跳过");
                                    continue;
                                }
                                HashMap<String,Short> hashMap=new HashMap<>();
                                if(devpThread.startSignal[i][0]!=locMast.getPackStatus()){
                                    hashMap.put("locSts",locMast.getPackStatus().shortValue());
                                    hashMap.put("channel",(short)(i*2));
                                    MessageQueue.offer(SlaveType.Devp, 1, new Task(6,hashMap));
                                HashMap<String, Short> hashMap = new HashMap<>();
                                if (devpThread.startSignal[i][0] != locMast.getPackStatus()) {
                                    hashMap.put("locSts", locMast.getPackStatus().shortValue());
                                    hashMap.put("channel", (short) (i * 2));
                                    MessageQueue.offer(SlaveType.Devp, 1, new Task(6, hashMap));
                                }
                                //同步设备状态
                                if(locMast.getPackStatus()!=testMast.getStatus()){
                                if (locMast.getPackStatus() != testMast.getStatus()) {
                                    testMast.setStatus(locMast.getPackStatus());
                                    testMastService.updateById(testMast);
                                }
                                if(devpThread.startSignal[i][1]!=locMast.getCtnKind()){
                                if (devpThread.startSignal[i][1] != locMast.getCtnKind()) {
                                    locMast.setCtnKind(devpThread.startSignal[i][1]);
                                    locMastService.updateById(locMast);
                                }
                            }else if(locMast.getLocSts().equals("O")){
                            } else if (locMast.getLocSts().equals("O")) {
                                //当充放电库位为O空库位时
                                //库位状态改为0空闲
                                locMast=locMastService.selectztgx("O",i);
                                if(!Cools.isEmpty(locMast)){
                                    HashMap<String,Short> hashMap=new HashMap<>();
                                    if(devpThread.startSignal[i][0]!=locMast.getPackStatus()){
                                        hashMap.put("locSts",(short)0);
                                        hashMap.put("channel",(short)(i*2));
                                        MessageQueue.offer(SlaveType.Devp, 1, new Task(6,hashMap));
                                locMast = locMastService.selectztgx("O", i);
                                if (!Cools.isEmpty(locMast)) {
                                    HashMap<String, Short> hashMap = new HashMap<>();
                                    if (devpThread.startSignal[i][0] != locMast.getPackStatus()) {
                                        hashMap.put("locSts", (short) 0);
                                        hashMap.put("channel", (short) (i * 2));
                                        MessageQueue.offer(SlaveType.Devp, 1, new Task(6, hashMap));
                                        locMast.setPackStatus(0);
                                        locMastService.updateById(locMast);
                                    }
                                    if(devpThread.startSignal[i][1]!=locMast.getChannel()){
                                    if (devpThread.startSignal[i][1] != locMast.getChannel()) {
                                        locMast.setCtnKind(devpThread.startSignal[i][1]);
                                        locMastService.updateById(locMast);
                                    }
@@ -2094,4 +2095,77 @@
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }
    /**
     * 出库站点无货时自动补空板到出库口
     */
    public void automaticEmptyBoardOutbound() {
        // 获取入库站信息
        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
        StaProtocol staProtocol = devpThread.getStation().get(101);
        if (staProtocol == null) {
            return;
        } else {
            staProtocol = staProtocol.clone();
        }
        if (staProtocol.isAutoing() && !staProtocol.isLoading()
                && staProtocol.isOutEnable() && staProtocol.getWorkNo() == 0
        ) {
            WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("io_type", 110));
            if (!Cools.isEmpty(wrkMast1)) {
                return;
            }
            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "D").orderBy("row1"));
            if (Cools.isEmpty(locMast)) {
                return;
            }
            //生成空板出库任务
            // 获取工作号
            int workNo = commonService.getWorkNo(WorkNoType.PAKOUT.type);
            // 获取源站
            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                    .eq("type_no", 110)
                    .eq("stn_no", 101)
                    .eq("crn_no", locMast.getCrnNo());
            StaDesc staDesc = staDescService.selectOne(wrapper);
            Integer sourceStaNo = staDesc.getCrnStn();
            if (Cools.isEmpty(sourceStaNo)) {
                throw new CoolException("检索源站失败");
            }
            Date now = new Date();
            // 保存工作档
            WrkMast wrkMast = new WrkMast();
            wrkMast.setWrkNo(workNo);
            wrkMast.setIoTime(now);
            wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID
            wrkMast.setIoType(110); // 入出库状态: 110.空板出库
            wrkMast.setIoPri(10D);
            wrkMast.setSourceStaNo(sourceStaNo); // 源站
            wrkMast.setStaNo(staDesc.getStnNo()); // 目标站
            wrkMast.setCrnNo(locMast.getCrnNo());
            wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位
            wrkMast.setFullPlt("N"); // 满板:Y
            wrkMast.setPicking("N"); // 拣料
            wrkMast.setExitMk("N"); // 退出
            wrkMast.setEmptyMk("Y"); // 空板
            wrkMast.setLinkMis("N");
            wrkMast.setAppeUser(9995L);
            wrkMast.setAppeTime(now);
            wrkMast.setModiUser(9995L);
            wrkMast.setModiTime(now);
            boolean res = wrkMastService.insert(wrkMast);
            if (!res) {
                throw new CoolException("保存工作档失败");
            }
            // 更新库位状态 D.空板 -> R.出库预约
            if (locMast.getLocSts().equals("D")){
                locMast.setLocSts("R");
                locMast.setModiUser(9995L);
                locMast.setModiTime(now);
                if (!locMastService.updateById(locMast)) {
                    throw new CoolException("更新库位状态失败");
                }
            }
        }
    }
}
src/main/java/com/zy/core/MainProcess.java
@@ -71,8 +71,8 @@
//                    //火警,给堆垛机发送火警警报
//                    mainService.fierCrn();
                    //103站点有物下发pack码
//                    mainService.packDevp();
                    //自动出空板
                    mainService.automaticEmptyBoardOutbound();
                } catch (Exception e) {
                    e.printStackTrace();