自动化立体仓库 - WMS系统
pjb
1 天以前 2ded9514aa9a93ee440af0b1437d788fb052028b
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -14,6 +14,7 @@
import com.zy.asrs.entity.param.StockOutParam;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.entity.result.FindLocNoAttributeVo;
import com.zy.asrs.mapper.OrderDetlPakoutMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.OrderInAndOutUtil;
import com.zy.asrs.utils.Utils;
@@ -23,6 +24,8 @@
import com.zy.common.properties.SlaveProperties;
import com.zy.common.service.CommonService;
import com.zy.common.web.WcsController;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -93,6 +96,12 @@
    @Resource
    private OrderPakoutService orderPakOutService;
    @Resource
    private OrderDetlPakoutMapper orderDetlPakoutMapper;
    @Resource
    private ConfigService configService;
    @Override
    @Transactional
@@ -180,6 +189,16 @@
    public void startupFullTakeStore(StockOutParam param, Long userId) {
        // 目标站点状态检测
        BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite());
        // 判断任务目标站点是否是出库模式
        if (param.getOutSite() == 1016 || param.getOutSite() == 1043) {
            Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "inOrOutBoundMode").eq("status", 1));
            if (config != null && !Cools.isEmpty(config.getValue())) {
                int value = Integer.parseInt(config.getValue());
                if (value != 2) {
                    throw new CoolException("目标站点" + param.getOutSite() + "不是出库模式,当前模式为:" + value);
                }
            }
        }
        // 获取库位明细
        List<LocDetlDto> locDetlDtos = new ArrayList<>();
        for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) {
@@ -336,7 +355,7 @@
            wrkMast.setIoTime(now);
            wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID
            wrkMast.setIoType(ioType); // 入出库状态
            wrkMast.setIoPri(13D); // 优先级:13
            wrkMast.setIoPri(staDesc.getStnNo() == 1064 || staDesc.getStnNo() == 1031 ? 14D: 13D); // 空桶出库到二号罐装线,去打包,优先级提高
            wrkMast.setCrnNo(locMast.getCrnNo());
            wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站
            wrkMast.setStaNo(staDesc.getStnNo()); // 目标站
@@ -566,6 +585,9 @@
            if (Cools.isEmpty(locMast)) {
                throw new CoolException(locNo+"库位不存在");
            }
            if (!locMast.getLocSts().equals("M") && !locMast.getLocSts().equals("Z")) {
                throw new CoolException("库位状态有误:" + locMast.getLocSts());
            }
            // 获取源站
            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                    .eq("type_no", 110)
@@ -734,7 +756,7 @@
            throw new CoolException(locDetl.getLocNo() + "," + locDetl.getMatnr() + "," + locDetl.getBatch() + "库存明细已被冻结!");
        }
        if (!loc.getLocSts().equals("O") || (!sourceLoc.getLocSts().equals("F") && !sourceLoc.getLocSts().equals("D"))){
        if (!loc.getLocSts().equals("O") || (!sourceLoc.getLocSts().equals("F") && !sourceLoc.getLocSts().equals("M") && !sourceLoc.getLocSts().equals("Z"))){
            throw new CoolException("库位状态已改变");
        }
        if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) {
@@ -756,7 +778,7 @@
        wrkMast.setFullPlt(Cools.isEmpty(locDetls)?"N":"Y"); // 满板:Y
        wrkMast.setPicking("N"); // 拣料
        wrkMast.setExitMk("N"); // 退出
        wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板
        wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("M") ? "M" : sourceLoc.getLocSts().equals("Z") ? "Z" : "N"); // 空板
        wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码
        wrkMast.setLinkMis("N");
        wrkMast.setAppeUser(userId);
@@ -783,7 +805,7 @@
            }
        }
        // 修改源库位状态
        if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) {
        if (sourceLoc.getLocSts().equals("F") || sourceLoc.getLocSts().equals("M") || sourceLoc.getLocSts().equals("Z")) {
            sourceLoc.setLocSts("R"); // R.出库预约
            sourceLoc.setModiUser(userId);
            sourceLoc.setModiTime(now);
@@ -816,7 +838,7 @@
        if (wrkMast.getStaNo() == 1090 && wrkMast.getLocNo() == null) {
            throw new CoolException(workNo+"工作档无法完成,库位号为空!");
        }
        if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) {
        if (wrkMast.getWrkSts() == 4L || wrkMast.getWrkSts() == 14L || wrkMast.getWrkSts() == 54L) {
            throw new CoolException("当前工作档已完成");
        }
        // 完成空桶库入出库任务另一个任务
@@ -834,6 +856,12 @@
                wrkMast.setWrkSts(14L);
            }
            workNoOther = wrkMast.getWorkNoOther();
        } else if(wrkMast.getIoType() == 1 && wrkMast.getWrkSts() == 10) {
            wrkMast.setWrkSts(2L);
            wrkMast.setRgvFinishTime(new Date());
        } else if(wrkMast.getIoType() == 120) {
            wrkMast.setWrkSts(54L);
            wrkMast.setRgvFinishTime(new Date());
        }
        Date now = new Date();
        wrkMast.setCrnStrTime(DateUtils.calculate(now, 1L, TimeUnit.SECONDS, true));
@@ -847,13 +875,15 @@
        }
        if(workNoOther != 0) {
            WrkMast wrkMast1 = wrkMastService.selectById(workNoOther);
            wrkMast1.setWrkSts(wrkMast.getWrkSts());
            wrkMast1.setCrnStrTime(wrkMast.getCrnStrTime());
            wrkMast1.setCrnEndTime(now);
            wrkMast1.setModiTime(now);
            wrkMast1.setModiUser(userId);
            wrkMast1.setManuType("手动完成");
            wrkMastService.updateById(wrkMast1);
            if (wrkMast1 != null) {
                wrkMast1.setWrkSts(wrkMast.getWrkSts());
                wrkMast1.setCrnStrTime(wrkMast.getCrnStrTime());
                wrkMast1.setCrnEndTime(now);
                wrkMast1.setModiTime(now);
                wrkMast1.setModiUser(userId);
                wrkMast1.setManuType("手动完成");
                wrkMastService.updateById(wrkMast1);
            }
        }
    }
@@ -882,7 +912,7 @@
        wrkMast.setCrnNo(locMast.getCrnNo());
        wrkMast.setSourceLocNo(locMast.getLocNo());
        wrkMast.setLocNo(locMast.getLocNo());
        wrkMast.setBarcode(locMast.getBarcode()); // 托盘码
        wrkMast.setBarcode(list.get(0).getZpallet()); // 托盘码
        wrkMast.setFullPlt("Y"); // 满板:Y
        wrkMast.setPicking("N"); // 拣料
        wrkMast.setExitMk("N"); // 退出
@@ -899,6 +929,10 @@
        boolean deleteFlag = true;
        boolean addFlag = true;
        // 库位状态是空,则添加
        // 库位状态在库,有提交数据,则修改
        // 库位状态在库,没有提交数据,则删除
        // 修改数量
        Iterator<LocDetl> iterator = locDetls.iterator();
        while (iterator.hasNext()) {
@@ -909,13 +943,20 @@
                LocDetlAdjustParam.LocDetlAdjust adjust = iterator1.next();
                if (adjust.getCount() == 0) { continue; }
                if (locDetl.getMatnr().equals(adjust.getMatnr()) && Cools.eq(locDetl.getBatch(), adjust.getBatch())) {
                    if (!locDetl.getAnfme().equals(adjust.getCount())) {
                        // todo 盘点记录
                        // 修改库存
                        if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBrand(),
                                locDetl.getStandby1(),locDetl.getStandby2(),locDetl.getStandby3(),locDetl.getBoxType1(),locDetl.getBoxType2(),locDetl.getBoxType3())) {
                            throw new CoolException(locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号修改数量失败");
                        }
//                        if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBrand(),
//                                locDetl.getStandby1(),locDetl.getStandby2(),locDetl.getStandby3(),locDetl.getBoxType1(),locDetl.getBoxType2(),locDetl.getBoxType3())) {
//                            throw new CoolException(locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号修改数量失败");
//                        }
                        locDetl.setAnfme(adjust.getCount());
                        locDetl.setZpallet(adjust.getZpallet());
                        locDetl.setModel(adjust.getModel());
                        locDetl.setManuDate(adjust.getManuDate());
                        locDetl.setWeight(adjust.getWeight());
                        locDetl.setManLength(adjust.getManLength());
                        locDetl.setVolume(adjust.getVolume());
                        locDetlService.update(locDetl,new EntityWrapper<LocDetl>().eq("loc_no",locDetl.getLocNo()).eq("matnr",locDetl.getMatnr()).eq("batch",locDetl.getBatch()));
                        // 保存调整记录
                        AdjDetl adjDetl = new AdjDetl();
                        adjDetl.setLocNo(locDetl.getLocNo());
@@ -945,6 +986,13 @@
                        wrkDetl.setWrkNo(wrkMast.getWrkNo());
                        wrkDetl.setIoTime(wrkMast.getIoTime());
                        wrkDetl.setAnfme(adjust.getCount());
                        wrkDetl.setAnfme(adjust.getCount());
                        wrkDetl.setZpallet(adjust.getZpallet());
                        wrkDetl.setModel(adjust.getModel());
                        wrkDetl.setManuDate(adjust.getManuDate());
                        wrkDetl.setWeight(adjust.getWeight());
                        wrkDetl.setManLength(adjust.getManLength());
                        wrkDetl.setVolume(adjust.getVolume());
                        wrkDetl.setAppeTime(now);
                        wrkDetl.setModiTime(now);
                        wrkMast.setAppeUser(userId);
@@ -952,7 +1000,6 @@
                        if (!wrkDetlLogService.insert(wrkDetl)) {
                            throw new CoolException("保存工作明细失败");
                        }
                    }
                    iterator.remove();
                    iterator1.remove();
                }
@@ -1012,8 +1059,13 @@
            locDetl.sync(mat);
            locDetl.setBatch(adjust.getBatch());
            locDetl.setLocNo(locMast.getLocNo());
            locDetl.setZpallet(locMast.getBarcode());
            locDetl.setZpallet(adjust.getZpallet());
            locDetl.setAnfme(adjust.getCount()); // 数量
            locDetl.setModel(adjust.getModel());
            locDetl.setManuDate(adjust.getManuDate());
            locDetl.setWeight(adjust.getWeight());
            locDetl.setManLength(adjust.getManLength());
            locDetl.setVolume(adjust.getVolume());
            locDetl.setModiUser(userId); // 操作人员信息
            locDetl.setModiTime(now);
            locDetl.setAppeUser(userId);
@@ -1062,12 +1114,15 @@
        int count = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
        if (locMast.getLocSts().equals("F")) {
            if (count == 0) {
                locMast.setLocSts("D");
                locMast.setLocSts("O");
            } else {
                locMast.setBarcode(wrkMast.getBarcode());
            }
        }
        if (locMast.getLocSts().equals("D") || locMast.getLocSts().equals("O")) {
            if (count > 0) {
                locMast.setLocSts("F");
                locMast.setBarcode(wrkMast.getBarcode());
            }
        }
        locMast.setModiUser(userId);
@@ -1088,8 +1143,53 @@
        }
        String locNo = ""; // 待修改目标库位
        String locSts = ""; // 待修改目标库位状态
        Long wrkSts = wrkMast.getWrkSts();
        Integer ioType = wrkMast.getIoType();
        // 任务完成,无法取消
        if(wrkSts == 4 || wrkSts == 5 || wrkSts == 14 || wrkSts == 15 || wrkSts == 54) {
            throw new CoolException(workNo+"任务已完成,无法取消");
        }
        if(ioType == 101 || ioType == 110) {
            if(wrkSts == 11 || wrkSts == 12) {
            } else {
                throw new CoolException(workNo+"库存信息已更新,无法取消");
            }
        }
        // 入库取消(修改目标库位)
        if (wrkMast.getWrkSts() <= 10) {
//        if(ioType == 1 || ioType == 10) {
//            if(wrkSts == 1 || wrkSts == 2|| wrkSts == 3 || wrkSts == 9 || wrkSts == 10) {
//                locNo = wrkMast.getLocNo();
//                locSts = "O";
//            } else {
//                throw new CoolException(workNo+"取消失败,当前状态:" + wrkSts);
//            }
//        } else if(ioType == 11){
//            if(wrkSts <= 10) {
//                locNo = wrkMast.getLocNo();
//                locSts = "O";
//                // 库位转移:源库位
//                LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());
//                if (Cools.isEmpty(locMast)) {
//                    throw new CoolException("取消库位转移失败,源库位不存在:"+ wrkMast.getSourceLocNo());
//                }
//                locMast.setLocSts(wrkMast.getFullPlt().equalsIgnoreCase("N")?wrkMast.getEmptyMk():"F");
//                locMast.setModiTime(now);
//                locMast.setModiUser(userId);
//                locMastService.updateById(locMast);
//            } else {
//                throw new CoolException(workNo+"取消失败,当前状态:" + wrkSts);
//            }
//        } else if(ioType == 3) {
//
//        } else if(ioType == 101) {
//
//        } else if(ioType == 110) {
//
//        }
        if (wrkMast.getWrkSts() <= 10  && wrkMast.getIoType()!=120) {
            locNo = wrkMast.getLocNo();
            locSts = "O";
@@ -1100,13 +1200,13 @@
                if (Cools.isEmpty(locMast)) {
                    throw new CoolException("取消库位转移失败,源库位不存在:"+ wrkMast.getSourceLocNo());
                }
                locMast.setLocSts(wrkMast.getFullPlt().equalsIgnoreCase("N")?"D":"F");
                locMast.setLocSts(wrkMast.getFullPlt().equalsIgnoreCase("N")?wrkMast.getEmptyMk():"F");
                locMast.setModiTime(now);
                locMast.setModiUser(userId);
                locMastService.updateById(locMast);
            }
        // 出库取消(修改源库位)
        } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 14) {
        } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 14 && wrkMast.getIoType()!=120) {
            locNo = wrkMast.getSourceLocNo();
            if (wrkMast.getIoType() == 110) {
                if(wrkMast.getStaNo() == 1035) { // 子拆盘机站点
@@ -1120,7 +1220,7 @@
                locSts = "F";
                // 空板出库 ===>> D.空桶/空栈板
            } else if (wrkMast.getIoType() == 11) {
                locSts = wrkMast.getFullPlt().equalsIgnoreCase("N")?"D":"F";
                locSts = wrkMast.getFullPlt().equalsIgnoreCase("N")?wrkMast.getEmptyMk():"F";
                // 库位转移:目标库位
                LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
                if (Cools.isEmpty(locMast)) {
@@ -1131,6 +1231,16 @@
                locMast.setModiUser(userId);
                locMastService.updateById(locMast);
            }
        } else if (wrkMast.getIoType()==120){
            // 取消操作人员记录
            wrkMast.setWrkSts(54L);
            wrkMast.setManuType("手动取消");
            wrkMast.setModiUser(userId);
            wrkMast.setModiTime(now);
            if (!wrkMastService.updateById(wrkMast)) {
                throw new CoolException("取消工作档失败");
            }
            return;
        } else {
            throw new CoolException("当前工作状态无法取消");
        }
@@ -1147,9 +1257,11 @@
//                    if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) {
//                        throw new CoolException("订单数据回滚失败");
//                    }
                    OrderInAndOutUtil.decrease(Boolean.FALSE,wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(),wrkDetl.getBrand(),
                            wrkDetl.getStandby1(),wrkDetl.getStandby2(),wrkDetl.getStandby3(),
                            wrkDetl.getBoxType1(),wrkDetl.getBoxType2(),wrkDetl.getBoxType3(), wrkDetl.getAnfme());
//                    OrderInAndOutUtil.decrease(Boolean.FALSE,wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(),wrkDetl.getBrand(),
//                            wrkDetl.getStandby1(),wrkDetl.getStandby2(),wrkDetl.getStandby3(),
//                            wrkDetl.getBoxType1(),wrkDetl.getBoxType2(),wrkDetl.getBoxType3(), wrkDetl.getAnfme());
                    orderDetlPakoutMapper.increaseQtyByOrderNoNew(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
                            wrkDetl.getBatch(),wrkDetl.getModel(),wrkDetl.getVolume(),wrkDetl.getAnfme());
                    //修改订单主表状态,没有作业数量时才可以修改
                    boolean flag = true;