自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-01-06 006ca71bd84497f2ff53630a3f9257f7a6e29391
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -395,7 +395,7 @@
                    }
                    //  判断堆垛机状态等待确认
                    if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue())
                            && crnProtocol.getTaskFinish() == 1  // todo:luxiaotao 等待确认
                            && crnProtocol.statusType == CrnStatusType.WAITING
                            && crnProtocol.forkPosType == CrnForkPosType.HOME) {
                        // 命令下发区 --------------------------------------------------------------------------
@@ -427,8 +427,7 @@
    /**
     * 入出库  ===>>  堆垛机入出库作业下发
     */
    @Async
    public void crnIoExecute(){
    public synchronized void crnIoExecute(){
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
@@ -470,7 +469,7 @@
    /**
     * 入库  ===>>  堆垛机站到库位
     */
    public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){
    public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){
        for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) {
            boolean flag = false;
            // 获取堆垛机入库站信息
@@ -564,7 +563,7 @@
    /**
     * 出库  ===>>  库位到堆垛机站
     */
    public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
    public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
        for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
            // 获取工作状态为11(生成出库ID)的出库工作档
            WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo());
@@ -671,7 +670,7 @@
    /**
     * 库位移转
     */
    public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol){
    public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol){
        // 获取工作档信息
        WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId());
        if (null == wrkMast) {
@@ -747,8 +746,7 @@
            CrnProtocol crnProtocol = crnThread.getCrnProtocol();
            if (crnProtocol == null) { continue; }
            //  状态:等待确认 并且  任务完成位 = 1
            if (crnProtocol.getTaskFinish() == 1    // todo:luxiaotao 等待确认
                    && crnProtocol.getTaskNo() != 0) {
            if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) {
                // 获取入库待确认工作档
                WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue());
                if (wrkMast == null) {
@@ -794,13 +792,13 @@
                    BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue());
                    // 有异常
                    if (latest == null) {
                        if (crnProtocol.getAlarm1() != null && crnProtocol.getAlarm1() > 0) {
                        if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
                            WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo());
                            if (wrkMast == null) {
                                continue;
                            }
                            BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
                            String errName = crnError==null? String.valueOf(crnProtocol.getAlarm1()):crnError.getErrName();
                            BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
                            String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName();
                            BasErrLog basErrLog = new BasErrLog(
                                    null,    // 编号
                                    wrkMast.getWrkNo(),    // 工作号
@@ -815,7 +813,7 @@
                                    wrkMast.getSourceStaNo(),    // 源站
                                    wrkMast.getSourceLocNo(),    // 源库位
                                    wrkMast.getBarcode(),    // 条码
                                    crnProtocol.getAlarm1(),    // 异常码
                                    (int) crnProtocol.getAlarm(),    // 异常码
                                    errName,    // 异常
                                    1,    // 异常情况
                                    now,    // 添加时间
@@ -830,7 +828,7 @@
                        }
                    } else {
                        // 异常修复
                        if (crnProtocol.getAlarm1() == null || crnProtocol.getAlarm1() == 0) {
                        if (crnProtocol.getAlarm() == null || crnProtocol.getAlarm() == 0) {
                            latest.setEndTime(now);
                            latest.setUpdateTime(now);
                            latest.setStatus(2);
@@ -843,11 +841,11 @@
                } else {
                    BasErrLog latest = basErrLogService.findLatest(crn.getId());
                    // 有异常
                    if (crnProtocol.getAlarm1() != null && crnProtocol.getAlarm1() > 0) {
                    if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
                        // 记录新异常
                        if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm1().intValue())) {
                            BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
                            String errName = crnError==null? String.valueOf(crnProtocol.getAlarm1()):crnError.getErrName();
                        if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) {
                            BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
                            String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName();
                            BasErrLog basErrLog = new BasErrLog(
                                    null,    // 编号
                                    null,    // 工作号
@@ -862,7 +860,7 @@
                                    null,    // 源站
                                    null,    // 源库位
                                    null,    // 条码
                                    crnProtocol.getAlarm1(),    // 异常码
                                    (int)crnProtocol.getAlarm(),    // 异常码
                                    errName,    // 异常
                                    1,    // 异常情况
                                    now,    // 添加时间
@@ -914,7 +912,7 @@
                }
                // 站点条件判断
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
                        && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9990) && staProtocol.isPakMk()) {
                        && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9990 || staProtocol.getWorkNo() == 9997) && staProtocol.isPakMk()) {
                    // 检索库位
                    LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
                    StartupDto startupDto = commonService.getLocNo(1, 10, emptyInSta.getStaNo(), null, locTypeDto, 0);
@@ -1188,82 +1186,6 @@
            throw new CoolException("移转失败");
        }
    }
    /**
     * 堆垛机演示  ===>> 库位移转
     */
    @Async
    public void crnDemoOfLocMove(Integer crn){
        for (int i = 0; i < 5; i++) {
            LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn);
            LocMast loc = locMastService.queryDemoLoc(crn);
            if (null == sourceLoc || null == loc) {
                break;
            }
            String sourceLocNo = sourceLoc.getLocNo();
            String locNo = loc.getLocNo();
            // 获取工作号
            int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
            // 保存工作档
            WrkMast wrkMast = new WrkMast();
            wrkMast.setWrkNo(workNo);
            wrkMast.setIoTime(new Date());
            wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID
            wrkMast.setIoType(11); // 入出库状态: 11.库格移载
            wrkMast.setIoPri(13D);
            wrkMast.setCrnNo(crn);
            wrkMast.setSourceLocNo(sourceLocNo); // 源库位
            wrkMast.setLocNo(locNo); // 目标库位
            wrkMast.setFullPlt("N"); // 满板:Y
            wrkMast.setPicking("N"); // 拣料
            wrkMast.setExitMk("N"); // 退出
            wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板
            wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码
            wrkMast.setLinkMis("N");
            wrkMast.setAppeTime(new Date());
            wrkMast.setModiTime(new Date());
            int res = wrkMastMapper.insert(wrkMast);
            if (res == 0) {
                throw new CoolException("保存工作档失败");
            }
            // 工作档明细保存
            List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo));
            for (LocDetl locDetl : locDetls) {
                WrkDetl wrkDetl = new WrkDetl();
                wrkDetl.setWrkNo(workNo);
                wrkDetl.setIoTime(new Date());
                wrkDetl.setAnfme(locDetl.getAnfme());
                VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制
                wrkDetl.setAppeTime(new Date());
                wrkDetl.setModiTime(new Date());
                if (!wrkDetlService.insert(wrkDetl)) {
                    throw new CoolException("保存工作档明细失败");
                }
            }
            // 修改源库位状态
            if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) {
                sourceLoc.setLocSts("R"); // R.出库预约
                sourceLoc.setModiTime(new Date());
                if (!locMastService.updateById(sourceLoc)){
                    throw new CoolException("更新源库位状态失败");
                }
            } else {
                throw new CoolException("源库位出库失败");
            }
            // 修改目标库位状态
            if (loc.getLocSts().equals("O")) {
                loc.setLocSts("S"); // S.入库预约
                loc.setModiTime(new Date());
                if (!locMastService.updateById(loc)) {
                    throw new CoolException("更新目标库位状态失败");
                }
            } else {
                throw new CoolException("移转失败");
            }
        }
    }
    /**