自动化立体仓库 - WMS系统
#
whycq
2024-06-13 84cfd49774d4aa0e475b319a70a411c4cc078694
src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
@@ -9,6 +9,7 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.CodeDetectionUtil;
import com.zy.common.model.DetlDto;
import com.zy.common.service.AgvCommonService;
import lombok.Synchronized;
@@ -67,6 +68,9 @@
    public String comb(CombParam param, Long userId) {
        if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
            throw new CoolException(BaseRes.PARAM);
        }
        if (!CodeDetectionUtil.barcodeDetection(param.getBarcode())){
            throw new CoolException(param.getBarcode() + "货架码有误,请正确扫码!!!");
        }
        param.setContainerType(Short.valueOf(param.getBarcode().substring(0,2)));
@@ -233,7 +237,7 @@
                checkOrderQty(order,combMat);
            }
            DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode(),param.getLocType());
            DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode(),param.getLocType(),combMat.getProcessSts());
            //同一货架下相同物料信息和批号转为一个入库通知档
            if (DetlDto.has(detlDtos, detlDto)) {
                DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(),detlDto.getContainerCode());
@@ -289,6 +293,8 @@
        waitPakin.setDeadTime(detlDto.getIsoseq());
        waitPakin.setLocType(detlDto.getLocType());
        waitPakin.setProcessSts(detlDto.getProcessSts());
        waitPakin.setAppeUser(userId);
@@ -419,7 +425,7 @@
            throw new CoolException("当前"+agvLocMast.getBarcode()+"货架码已在工作档中");
        }
        //检索库位,选择合适的库位
        AgvLocMast locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(),floor);
        AgvLocMast locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(),floor,false,false);
        if (Cools.isEmpty(locMast)) {
            throw new CoolException("当前楼层没有空库位");
        }
@@ -497,10 +503,16 @@
    @Synchronized
    public String allocationOut(AgvMobileStartPakin param, Long userId) {
        Date now = new Date();
        if(Cools.isEmpty(param.getBarcode())) {
            throw new CoolException("请输入货架码");
        }
        AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", param.getDevNo()));
        Integer oldWrkNo = agvWrkMast.getWrkNo();
        if (Cools.isEmpty(agvWrkMast)) {
            throw new CoolException("工作档中没有此站点任务");
        }
        if (!agvWrkMast.getBarcode().equals(param.getBarcode())) {
            throw new CoolException("当前货架码与任务不匹配");
        }
        if (!agvWrkMast.getWrkSts().equals(207L)) {
            throw new CoolException("工作状态不符合离场条件");
@@ -542,8 +554,14 @@
    public String allocationIn(AgvMobileStartPakin param, Long userId) {
        Date now = new Date();
        AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode()));
        if (Cools.isEmpty(agvWrkMast)) {
            throw new CoolException("暂无当前货架码的任务");
        }
        if (agvWrkMast.getIoType() != 111) {
            throw new CoolException("非手动调拨任务,不支持次功能");
        }
        if (!Cools.isEmpty(agvWrkMast.getSourceLocNo())) {
            throw new CoolException("当前货架码任有源库位,请确认");
        }
        AgvBasDevp agvBasDevp = agvBasDevpService.selectByDevNo(param.getDevNo());
        if (Cools.isEmpty(agvWrkMast)) {
@@ -552,7 +570,7 @@
        if (agvWrkMast.getCrnNo() != agvBasDevp.getFloor()) {
            throw new CoolException("请移动到->" + agvWrkMast.getCrnNo() + "楼入库点入库");
        }
        AgvLocMast locNo = agvCommonService.getLocNo(3, 1);
        AgvLocMast locNo = agvCommonService.getLocNo(3, 1,false,true);
        //工作状态
        agvWrkMast.setWrkSts(211L);
        //入出库类型
@@ -578,10 +596,16 @@
    @Synchronized
    public String empOut(AgvMobileStartPakin param, Long userId) {
        Date now = new Date();
        if (Cools.isEmpty(param.getBarcode())) {
            throw new CoolException("请输入货架码");
        }
        AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("source_loc_no", param.getDevNo()));
        Integer oldWrkNo = agvWrkMast.getWrkNo();
        if (Cools.isEmpty(agvWrkMast)) {
            throw new CoolException("工作档中没有此站点任务");
        }
        if (!agvWrkMast.getBarcode().equals(param.getBarcode())) {
            throw new CoolException("当前货架码与任务不匹配");
        }
        agvWrkMast.setWrkSts(213L);
        agvWrkMast.setSourceLocNo("");
@@ -604,6 +628,12 @@
        if (Cools.isEmpty(agvWrkMast)) {
            throw new CoolException("工作档中没有此站点任务");
        }
        if (agvWrkMast.getIoType() != 113) {
            throw new CoolException("当前工作类型不能空架进场");
        }
        if (agvWrkMast.getWrkSts() != 213) {
            throw new CoolException("当前工作类型不能空架进场");
        }
        agvWrkMast.setWrkSts(214L);
        agvWrkMast.setSourceLocNo(param.getDevNo());
        if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
@@ -614,7 +644,7 @@
        return "ok";
    }
    /*
     * 站点回退
     * 转手动回流
    */
    @Override
    @Transactional
@@ -631,11 +661,73 @@
    }
    /*
     * 确认加工完成
     */
    @Override
    @Transactional
    public String processed(AgvMobileStartPakin param, Long userId) {
        Date now = new Date();
        AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode()).eq("loc_no", param.getDevNo()));
        if (Cools.isEmpty(agvWrkMast)) {
            throw new CoolException("暂无当前货架的工作档");
        }
        if (agvWrkMast.getWrkSts() != 205) {
            throw new CoolException("当前任务未完成,请确认");
        }
        //生成AGV工作历史档 + 生成AGV工作明细历史档
        agvWrkMastLogService.save(agvWrkMast);
        agvWrkDetlLogService.save(agvWrkMast.getWrkNo());
        String sourceLocNo = agvWrkMast.getSourceLocNo();
        AgvLocMast newLocMast = agvCommonService.getLocNo(3, 1,false,false);
        agvWrkMast.setSourceLocNo(agvWrkMast.getLocNo());
        agvWrkMast.setLocNo(newLocMast.getLocNo());
        agvWrkMast.setIoType(57);
        agvWrkMast.setWrkSts(201L);
        agvWrkMast.setModiUser(userId);
        agvWrkMast.setModiTime(now);
        if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
            throw new CoolException("更新工作档失败");
        }
        // 更新源站点 + 目标库位状态 + 历史源库位
        agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"R",param.getBarcode(),agvWrkMast.getWhsType().shortValue());
        agvLocMastService.updateLocStsByLocNo(newLocMast.getLocNo(),"S",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
        agvLocMastService.updateLocStsByLocNo(sourceLocNo,"O","",(short)30);
        agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",sourceLocNo));
        List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code",param.getBarcode()));
        agvWrkDetls.forEach(agvWrkDetl -> {
            agvWrkDetl.setProcessSts(2);
            agvWrkDetl.setOrderNo(agvWrkDetl.getOrderNo().substring(2));
            agvWrkDetl.setModiUser(userId);
            agvWrkDetl.setModiTime(now);
            if (!agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>()
                    .eq("matnr",agvWrkDetl.getMatnr())
                    .eq("three_code",agvWrkDetl.getThreeCode())
                    .eq("supp_code",param.getBarcode()))) {
                throw new CoolException("更新工作明细失败");
            }
        });
        return "ok";
    }
    /*
     * 站点回退
     */
    @Override
    @Transactional
    public String doBack(AgvMobileStartPakin param, Long userId) {
        if (Cools.isEmpty(param.getBarcode()) || !CodeDetectionUtil.barcodeDetection(param.getBarcode())){
            throw new CoolException(param.getBarcode() + "货架码有误,请正确扫码!!!");
        }
        if (Cools.isEmpty(param.getDevNo()) || !CodeDetectionUtil.carCodeDetection(param.getDevNo())){
            throw new CoolException(param.getDevNo() + "小车地码有误,请正确扫码!!!");
        }
        Date now = new Date();
        AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", param.getDevNo()));
        AgvWrkMast agvWrkMastSource = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("source_loc_no", param.getDevNo()));