自动化立体仓库 - WMS系统
lsh
2024-05-31 af7735421399789ec5a47a352906acc3abe306ca
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;
@@ -69,16 +70,25 @@
        agvWrkMastService.updateById(agvWrkMast);
        // 空板入库 设置库位状态为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() == 10 || agvWrkMast.getIoType() == 109 || agvWrkMast.getIoType() == 111 ) {
            // 库位 -- 接驳位 / 库位
            if ((agvWrkMast.getIoType() == 109 || agvWrkMast.getIoType() == 111) && agvWrkMast.getLocNo().substring(0,2).equals("DB")) {
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"F",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());
        }
        //生成AGV工作历史档
        agvWrkMastLogService.save(agvWrkMast);
        //生成AGV工作明细历史档
        agvWrkDetlLogService.save(wrkNo);
        if (agvWrkMast.getIoType() != 111) {
            //生成AGV工作历史档
            agvWrkMastLogService.save(agvWrkMast);
            //生成AGV工作明细历史档
            agvWrkDetlLogService.save(wrkNo);
        }
        //类型为入库时
        if(agvWrkMast.getIoType() == 1){
            //更新目标库位明细
@@ -106,16 +116,36 @@
            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue(),"",(short)0);
        }
        if(agvWrkMast.getIoType() == 109 || agvWrkMast.getIoType() == 58){
            //修改源库位状态为O
            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue(),"",(short)0);
        if(agvWrkMast.getIoType() == 109 || agvWrkMast.getIoType() == 111 || agvWrkMast.getIoType() == 112){
            // 接驳位 -- 库位
            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);
            }
        }
        if(agvWrkMast.getIoType() == 113){
            // 接驳位 -- 库位
            if (agvWrkMast.getSourceLocNo().substring(0,2).equals("DB")) {
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(),"O","",(short)0);
            }
        }
        if (agvWrkMast.getIoType() == 58) {
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue());
        }
        //删除AGV工作档
        agvWrkMastService.deleteById(wrkNo);
        //删除AGV工作明细档
        agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",wrkNo));
        if (agvWrkMast.getIoType() != 111) {
            //删除AGV工作档
            agvWrkMastService.deleteById(wrkNo);
            //删除AGV工作明细档
            agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",wrkNo));
        }
        if(!isJSON(orderNo)){
            //检查订单是否已完成
@@ -220,20 +250,24 @@
    @Synchronized
    public ReturnT<String> startPutWayWrk(AgvWrkMast agvWrkMast) throws IOException {
        //下发任务
        int startWrkCode = agvWrkMastService.startWrk(agvWrkMast);
        if(startWrkCode != 0){
            throw new CoolException("任务下发失败");
        }
        try{
            //下发任务
            int startWrkCode = agvWrkMastService.startWrk(agvWrkMast);
            if(startWrkCode != 0){
                throw new CoolException("任务下发失败");
            }
        agvWrkMast.setWrkSts(202L);
        agvWrkMastService.updateById(agvWrkMast);
        if(agvWrkMast.getIoType() == 1){
            //修改AGV入库通知档状态入出状态为Y
            agvWaitPakinService.updateIoStatus(agvWrkMast.getWrkNo(),"Y");
            agvWrkMast.setWrkSts(202L);
            agvWrkMastService.updateById(agvWrkMast);
            if(agvWrkMast.getIoType() == 1){
                //修改AGV入库通知档状态入出状态为Y
                agvWaitPakinService.updateIoStatus(agvWrkMast.getWrkNo(),"Y");
            }
            return SUCCESS;
        }catch (Exception e){
            log.error(e.getMessage());
        }
        return SUCCESS;
        return FAIL;
    }
    @Transactional
@@ -336,4 +370,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;
    }
}