自动化立体仓库 - WMS系统
whycq
2024-05-24 d17a7346759fbb432cea1c83de63d29c6a3d330d
src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java
@@ -17,6 +17,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -70,7 +71,11 @@
        // 空板入库 设置库位状态为D.空桶/空栈板
        String locSts = agvWrkMast.getIoType() == 10 ? "D" : "F";
        if (agvWrkMast.getIoType() == 10 || agvWrkMast.getIoType() == 109) {
            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
            if (agvWrkMast.getIoType() == 109 && agvWrkMast.getLocNo().substring(0,2).equals("DB")) {
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"R",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
            } else {
                agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
            }
        } else {
            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"F",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
        }
@@ -107,9 +112,20 @@
        }
        if(agvWrkMast.getIoType() == 109){
            //修改源库位状态为O
            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue(),"",(short)0);
            if (agvWrkMast.getSourceLocNo().substring(0,2).equals("DB")) {
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(),"O","",(short)0);
            } else {
                //修改源库位状态为O
                agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue(),"",(short)0);
                // 新建工作档
                Date now = new Date();
                createWrkMast(109, 201L, agvWrkMast.getLocNo(), "", agvWrkMast.getBarcode(), now, 9527L, agvWrkMast.getWhsType(), 0);
            }
        }
        if (agvWrkMast.getIoType() == 58) {
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue());
        }
        //删除AGV工作档
@@ -236,6 +252,19 @@
    }
    @Transactional
    @Synchronized
    public ReturnT<String> startAllcationIn(AgvWrkMast agvWrkMast) throws IOException {
        //下发任务
        int startWrkCode = agvWrkMastService.startAllcationIn(agvWrkMast);
        if(startWrkCode != 0){
            throw new CoolException("任务下发失败");
        }
        return SUCCESS;
    }
//    @Transactional
//    public ReturnT<String> startCarryWrk(AgvWrkMast agvWrkMast) throws IOException {
//        //log.info(agvWrkMastList.toString());
@@ -323,4 +352,41 @@
            return num <= maxWrokNum;
        }).collect(Collectors.toList());
    }
    /*
  生成工作档
   */
    private AgvWrkMast createWrkMast(int ioType, long wrkSts, String sourceLocNo, String locNo, String barcode, Date now, Long userId, int containerType, int floor){
        AgvWrkMast wrkMast = new AgvWrkMast();
        //工作状态
        wrkMast.setWrkSts(wrkSts);
        //入出库类型
        wrkMast.setIoType(ioType);
        wrkMast.setIoTime(now);
        //优先级
        wrkMast.setIoPri(300.0);
        //源站点
        wrkMast.setSourceLocNo(sourceLocNo);
        //目标站点
        wrkMast.setLocNo(locNo);
        //货架编码
        wrkMast.setBarcode(barcode);
        //货架类型
        wrkMast.setWhsType(containerType);
        // 目标楼层
        wrkMast.setCrnNo(floor);
        wrkMast.setAppeUser(userId);
        wrkMast.setAppeTime(now);
        wrkMast.setModiUser(userId);
        wrkMast.setModiTime(now);
        if (!agvWrkMastService.insertByIncrease(wrkMast)) {
            throw new CoolException("保存工作档失败");
        }
        wrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", locNo).eq("source_loc_no",sourceLocNo).eq("barcode",barcode).orderBy("modi_time",false));
        return wrkMast;
    }
}