自动化立体仓库 - WMS系统
LSH
2023-09-15 58d1a051b0d8f523901469947900dea5af8b97dd
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -7,10 +7,7 @@
import com.core.common.*;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.CombParam;
import com.zy.asrs.entity.param.MobileAdjustParam;
import com.zy.asrs.entity.param.OffSaleParam;
import com.zy.asrs.entity.param.OpenOrderPakinParam;
import com.zy.asrs.entity.param.*;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatUtils;
@@ -81,9 +78,110 @@
    @Override
    @Transactional
    public void trussComb(TrussCombParam param, Long userId) {
//        if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
//            throw new CoolException(BaseRes.PARAM);
//        }
    }
    @Override
    @Transactional
    public void trussComb2(PalletizingCompleteParam param, Long userId) {
        //判断param参数
        if (Cools.isEmpty(param.getBarcode())){
            throw new CoolException("参数:托盘码 barcode为空");
        }else if (Cools.isEmpty(param.getPalletizingNo())){
            throw new CoolException("参数:码垛位编号 palletizingNo为空");
        }else if (Cools.isEmpty(param.getBoxType())){
            throw new CoolException("参数:木箱类型 boxType为空");
        }else if (Cools.isEmpty(param.getMatLists()) || param.getMatLists().size()==0){
            throw new CoolException("参数:物料明细 matLists为空");
        }
        ArrayList<String> positions = new ArrayList<>();   //木箱位置查重      (orgin)
        ArrayList<String> boxNos = new ArrayList<>();   //木箱唯一编码查重  (batch)
        //判断matLists参数
        for (PalletizingCompleteParam.MatList matList:param.getMatLists()){
            if (Cools.isEmpty(matList.getMatnr())){
                throw new CoolException("参数:物料编码 matnr为空");
            }else if (Cools.isEmpty(matList.getPosition())){
                throw new CoolException("物料编码:"+matList.getMatnr()+"、参数:码垛位置 position为空");
            }else if (Cools.isEmpty(matList.getBoxNo())){
                throw new CoolException("物料编码:"+matList.getMatnr()+"、参数:木箱编号 boxNo为空");
            }else if (Cools.isEmpty(matList.getAnfme()) || matList.getAnfme().equals(0)){
                throw new CoolException("物料编码:"+matList.getMatnr()+"、参数:木箱中铜箔数量 anfme为空");
            }else if (Cools.isEmpty(matList.getWeight()) || matList.getWeight().equals(0D)){
                throw new CoolException("物料编码:"+matList.getMatnr()+"、参数:重量 weight为空");
            }
            if (!positions.contains(matList.getPosition())){
                positions.add(matList.getPosition());
            }else {
                throw new CoolException("参数:木箱编号 boxNo:"+matList.getBoxNo()+",木箱位置存在重复:"+matList.getPosition());
            }
            if (!boxNos.contains(matList.getBoxNo())){
                boxNos.add(matList.getBoxNo());
            }else {
                throw new CoolException("参数:木箱编号 boxNo:"+matList.getBoxNo()+",木箱编码存在重复");
            }
        }
//        BasDevp basDevp = basDevpService.selectById(Integer.parseInt(param.getDevNo$()));
//        if (Cools.isEmpty(basDevp)){
//            throw new CoolException("参数:码垛位编号 palletizingNo="+param.getPalletizingNo()+"不存在");
//        }
//        if (Cools.isEmpty(basDevp.getAutoing()) || !basDevp.getAutoing().equals("Y")){
//            throw new CoolException("码垛位编号 palletizingNo="+param.getPalletizingNo()+" 所处站点不是自动状态");
//        }
//        if (Cools.isEmpty(basDevp.getLoading()) || !basDevp.getLoading().equals("Y")){
//            throw new CoolException("码垛位编号 palletizingNo="+param.getPalletizingNo()+" 所处站点不是有物状态");
//        }
//        if (Cools.isEmpty(basDevp.getCanining()) || !basDevp.getCanining().equals("Y")){
//            throw new CoolException("码垛位编号 palletizingNo="+param.getPalletizingNo()+" 所处站点不是能入状态");
//        }
        if (locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()))!=0
                || wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()))!=0
                || waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()))!=0){
            throw new CoolException("托盘条码:"+param.getBarcode()+"已存在,请勿重复组托");
        }
        Date now = new Date();
        for (PalletizingCompleteParam.MatList matList:param.getMatLists()){
            Mat mat = matService.selectByMatnr(matList.getMatnr());
            if (Cools.isEmpty(mat)) {
                throw new CoolException(matList.getMatnr() + "商品档案不存在");
            }
            WaitPakin waitPakin = new WaitPakin();
            waitPakin.sync(mat);
            waitPakin.setModel(matList.getBatch());     //批次
            waitPakin.setSpecs(matList.getSpecs());     //规格
            waitPakin.setBatch(matList.getBoxNo());       //木箱编码
            waitPakin.setBrand(param.getBoxType());     //木箱类型
            waitPakin.setZpallet(param.getBarcode());   //托盘码
            waitPakin.setOrigin(matList.getPosition()); //木箱在托盘上的位置
            waitPakin.setIoStatus("N");     // 入出状态
            waitPakin.setAnfme(matList.getAnfme().doubleValue());  // 木箱中铜箔数量
            waitPakin.setStatus("Y");    // 状态
            waitPakin.setAppeUser(userId);
            waitPakin.setAppeTime(now);
            waitPakin.setModiUser(userId);
            waitPakin.setModiTime(now);
            if (!waitPakinService.insert(waitPakin)) {
                throw new CoolException("保存入库通知档失败");
            }
        }
    }
    @Override
    @Transactional
    public void comb(CombParam param, Long userId) {
        if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
            throw new CoolException(BaseRes.PARAM);
        }
        if(param.getCombMats().size()>1){
            throw new CoolException("请提取一个商品,或者刷新重新组托!");
        }
        // 判断是否有相同条码的数据
        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
@@ -91,10 +189,18 @@
            throw new CoolException(param.getBarcode() + "数据正在进行入库");
        }
        if(param.getBarcode().length()!=8){
            throw new CoolException("条码长度不是8位===>>" + param.getBarcode());
        }
        if (param.getCombMats().size()>1){
            throw new CoolException("不允许混料===>>" + param.getBarcode());
        }
        int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
        int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode()));
        if (countLoc > 0 || countWrk > 0) {
            throw new CoolException("工作档/库存条码数据已存在===>>" + param.getBarcode());
        int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode()));
        if (countLoc > 0 || countWrk > 0 || countwait > 0) {
            throw new CoolException("组托档/工作档/库存条码数据已存在===>>" + param.getBarcode());
        }
        Date now = new Date();
@@ -139,7 +245,7 @@
        // 关联组托
        } else {
            Order order = orderService.selectByNo(param.getOrderNo());
            if (order.getSettle() > 2) {
            if (Cools.isEmpty(order) || order.getSettle() > 2) {
                throw new CoolException("单据编号已过期");
            }
            // 生成入库通知档
@@ -191,6 +297,7 @@
    }
    // 商品上架
    @Override
    public void onSale(CombParam param) {
        Date now = new Date();
@@ -211,14 +318,14 @@
                throw new CoolException(combMat.getMatnr() + ":商品数量有误!");
            }
            if (Cools.isEmpty(combMat.getBatch())){
                throw new CoolException(combMat.getMatnr() + ":商品批号有误!");
//                throw new CoolException(combMat.getMatnr() + ":商品批号有误!");
            }
            ManLocDetl manLocDetl = new ManLocDetl();
            manLocDetl.setLocNo(locno);
            manLocDetl.setNodeId(node.getId());
            manLocDetl.setMaktx(mat.getMaktx());
            manLocDetl.setMatnr(mat.getMatnr());
            manLocDetl.setBatch(combMat.getBatch());
            manLocDetl.setBatch(Cools.isEmpty(combMat.getBatch()) ? "" : combMat.getBatch());
            manLocDetl.setAnfme(combMat.getAnfme());
            manLocDetl.setModiTime(now);
            if (!manLocDetlService.insert(manLocDetl)) {
@@ -227,15 +334,25 @@
        }
    }
    // 商品下架
    @Override
    public void offSale(OffSaleParam offSaleParam) {
        List<ManLocDetl> manLocDetls = manLocDetlMapper.selectLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr());
        if (Cools.isEmpty(manLocDetls)){
            throw new CoolException("商品下架失败!");
        ManLocDetl manLocDetl = manLocDetlMapper.selectLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr());
        if (Cools.isEmpty(manLocDetl)){
            throw new CoolException("无此商品!");
        }
        int i = manLocDetlMapper.deleteLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr());
        System.out.println(i);
        double anfme = manLocDetl.getAnfme() - offSaleParam.getAnfme();
        if (anfme < 0) {
            throw new CoolException("商品库存不足!");
        } else if (anfme == 0){
            manLocDetlMapper.deleteLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr());
        }
        manLocDetlMapper.updateAnfme0(anfme,manLocDetl.getNodeId());
    }
    // 查找商品
    @Override
    @Transactional
    public void adjust(MobileAdjustParam param, Long userId) {
@@ -573,6 +690,7 @@
        wrkMast.setEmptyMk("N"); // 空板
        wrkMast.setLinkMis("N");
        wrkMast.setAppeUser(userId); // 操作人员数据
        wrkMast.setSheetNo("0");  //徐工汉云拆垛标记:0: 未拆  1: 已拆  2:已处理可下一步(转历史档)
        wrkMast.setAppeTime(now);
        wrkMast.setModiUser(userId);
        wrkMast.setModiTime(now);