From d3f22f29b52d7b49e78ce905b6700c92a6096933 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期二, 07 一月 2025 19:30:27 +0800 Subject: [PATCH] #平仓出库功能 --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 156 insertions(+), 18 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java index 1cfb59d..b110fa7 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java @@ -1,54 +1,192 @@ package com.zy.asrs.wms.asrs.service.impl; -import com.zy.asrs.wms.asrs.entity.WaitPakin; -import com.zy.asrs.wms.asrs.entity.enums.LocTypeHeightType; -import com.zy.asrs.wms.asrs.entity.enums.TaskStsType; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zy.asrs.framework.exception.CoolException; +import com.zy.asrs.wms.asrs.entity.*; +import com.zy.asrs.wms.asrs.entity.enums.*; +import com.zy.asrs.wms.asrs.entity.enums.OrderType; import com.zy.asrs.wms.asrs.entity.param.BatchMergeOrdersParam; import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam; -import com.zy.asrs.wms.asrs.service.MobileService; -import com.zy.asrs.wms.asrs.service.WaitPakinService; -import com.zy.asrs.wms.asrs.service.WorkService; +import com.zy.asrs.wms.asrs.entity.param.PakinOnShelvesParams; +import com.zy.asrs.wms.asrs.service.*; +import com.zy.asrs.wms.system.entity.Host; +import com.zy.asrs.wms.system.service.HostService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; @Service public class MobileServiceImpl implements MobileService { @Autowired private WaitPakinService waitPakinService; - + @Autowired + private WaitPakinLogService waitPakinLogService; @Autowired private WorkService workService; + @Autowired + private HostService hostService; + @Autowired + private OrderService orderService; + @Autowired + private OrderLogService orderLogService; + @Autowired + private LocService locService; + @Autowired + private LocDetlService locDetlService; + @Autowired + private LocAreaService locAreaService; + @Autowired + private LocAreaTypeService locAreaTypeService; + @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public boolean batchMergeOrders(BatchMergeOrdersParam ordersParam) { + Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, ordersParam.getOrderNo())); + if (Objects.isNull(order)) { + throw new CoolException("璁㈠崟涓嶅瓨鍦紒锛�"); + } ArrayList<WaitPakin> waitPakins = new ArrayList<>(); ordersParam.getOrderDetls().forEach(orderdetl -> { WaitPakin waitPakin = new WaitPakin(); - waitPakin.setBatch(orderdetl.getBatch()).setAnfme(orderdetl.getMergeNum()).setBarcode(ordersParam.getMergeNo()).setMatnr(orderdetl.getMatnr()).setDetlId(orderdetl.getDetlId()).setIoStatus(0).setOrderNo(orderdetl.getOrderNo()).setOrderId(orderdetl.getOrderId()).setStatus(1); + waitPakin.setBatch(orderdetl.getBatch()) + .setAnfme(orderdetl.getMergeNum()) + .setBarcode(ordersParam.getMergeNo()) + .setMatnr(orderdetl.getMatnr()) + .setDetlId(orderdetl.getDetlId()) + .setIoStatus(0) + .setOrderNo(orderdetl.getOrderNo()).setOrderId(orderdetl.getOrderId()).setStatus(1); waitPakins.add(waitPakin); }); - /*** 椤圭洰涓嬪彂娴佺▼ * 1. PDA缁勬嫋閫氱煡妗�* 2. 鐢熸垚浠诲姟妗�* 3. 閫氳繃瀹氭椂浠诲姟涓嬪彂鑷矱SS** */ //缁勬嫋閫氱煡妗� waitPakins.forEach(pakin -> { waitPakinService.comb(pakin); }); - //鐢熸垚浠诲姟妗� - GeneratePakInParam generatePakInParam = new GeneratePakInParam(); - //褰撳墠娌℃湁璧峰绔欑偣锛岄粯璁�101锛� 楂樹綆浣嶉粯璁や紶浣庡簱浣� - generatePakInParam.setBarcode(ordersParam.getMergeNo()) - .setOriginSite("101") - .setTaskType(TaskStsType.GENERATE_IN.id).setLocTypeHeight(LocTypeHeightType.LOW.id); - if (workService.generatePakIn(generatePakInParam)) { - return true; + // UTC鍏ュ簱鍗曟嵁(闈炲钩搴撳叆搴撳崟鎹�) + if (order.getOrderType() != OrderType.PK_IN_ORDER.id) { + /*** 椤圭洰涓嬪彂娴佺▼ * 1. PDA缁勬嫋閫氱煡妗�* 2. 鐢熸垚浠诲姟妗�* 3. 閫氳繃瀹氭椂浠诲姟涓嬪彂鑷矱SS** */ + //鐢熸垚浠诲姟妗� + GeneratePakInParam generatePakInParam = new GeneratePakInParam(); + //褰撳墠娌℃湁璧峰绔欑偣锛岄粯璁�101锛� 楂樹綆浣嶉粯璁や紶浣庡簱浣� + generatePakInParam.setBarcode(ordersParam.getMergeNo()) + .setOriginSite("101") + .setTaskType(TaskStsType.GENERATE_IN.id).setLocTypeHeight(LocTypeHeightType.LOW.id); + if (workService.generatePakIn(generatePakInParam)) { + return true; + } + } else { + //fixme 骞冲簱鏄惁闇�瑕侀绾﹀叆搴� } return false; } + + @Override + public List<Host> getHosts() { + return hostService.list(); + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean pakinToStock(PakinOnShelvesParams shelvesParams) { + Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, shelvesParams.getLoc())); + if (Objects.isNull(loc)) { + throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�"); + } + if (loc.getLocStsId() != LocStsType.O.val()) { + throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉鏄┖搴撶姸鎬�." + LocStsType.O.val()); + } + + //鍒ゆ柇褰撳墠浠撳簱鏄惁涓哄钩搴撲綅 + List<LocArea> locAreas = locAreaService.list(new LambdaQueryWrapper<LocArea>().eq(LocArea::getLocId, loc.getId())); + if (locAreas.isEmpty()) { + throw new CoolException("搴撲綅娌℃湁鍒嗛厤鎵�灞炰粨搴撳尯鍩燂紒锛�"); + } + locAreas.forEach(locArea -> { + LocAreaType typeServiceOne = locAreaTypeService.getOne(new LambdaQueryWrapper<LocAreaType>().eq(LocAreaType::getId, locArea.getTypeId()), false); + if (typeServiceOne.getParentId() != LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id && typeServiceOne.getId() != LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id) { + throw new CoolException("璇烽�夋嫨骞冲簱鍖哄簱浣嶏紝鍐嶆搷浣滐紒锛�"); + } + }); + + loc.setBarcode(shelvesParams.getBarcode()); + loc.setUpdateTime(new Date()); + //搴撳瓨鐘舵�佷慨鏀逛负鍦ㄥ簱鐘舵�� + loc.setLocStsId(LocStsType.F.val()); + if (!locService.updateById(loc)) { + throw new CoolException("搴撲綅鏇存柊澶辫触锛侊紒"); + } + + List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, shelvesParams.getBarcode())); + waitPakins.forEach(pakin -> { + LocDetl locDetl = new LocDetl(); + locDetl.setAnfme(pakin.getAnfme()); + locDetl.setBatch(pakin.getBatch()); + locDetl.setMatId(pakin.getMatnrId$());; + locDetl.setCreateTime(new Date()); + locDetl.setOrderNo(pakin.getOrderNo()); + locDetl.setLocNo(loc.getLocNo()); + locDetl.setLocId(loc.getId()); + locDetl.setMatnr(pakin.getMatnr()); + locDetl.setMemo(pakin.getMemo()); + locDetl.setUpdateTime(new Date()); + if (!locDetlService.saveOrUpdate(locDetl)) { + throw new CoolException("搴撳瓨鏄庣粏鏇存柊澶辫触锛侊紒"); + } + //淇敼鐘舵�佷负鍏ュ簱涓� + pakin.setIoStatus(1); + }); + + //鍒犻櫎缁勬嫋妗o紝鍔犲叆鍘嗗彶缁勬嫋妗� + waitPakins.forEach(waitPakin -> { + WaitPakinLog pakinLog = new WaitPakinLog(); + BeanUtils.copyProperties(waitPakin, pakinLog); + if (!waitPakinLogService.saveOrUpdate(pakinLog)) { + throw new CoolException("缁勬嫋鍘嗗彶妗f洿鏂板け璐�"); + } + }); + + if (!waitPakinService.removeBatchByIds(waitPakins)) { + throw new CoolException("缁勬嫋妗e垹闄ゅけ璐ワ紒锛�"); + } + //閫氳繃缁勬嫋璁㈠崟ID鑾峰彇璁㈠崟锛屽苟鍒犻櫎鍘熷崟鎹紝鍔犲叆鍗曟嵁鍘嗗彶妗� + List<Long> list = waitPakins.stream().map(WaitPakin::getOrderId).collect(Collectors.toList()); + List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getId, list)); + orders.forEach(order -> { + OrderLog orderLog = new OrderLog(); + BeanUtils.copyProperties(order, orderLog); + if (!orderLogService.save(orderLog)) { + throw new CoolException("鍘嗗彶鍗曟嵁鏇存柊澶辫触锛侊紒"); + } + }); + + if (!orderService.removeBatchByIds(orders)) { + throw new CoolException("璁㈠崟鍒犻櫎澶辫触锛侊紒"); + } + + return true; + } + +// /** +// * 鑾峰彇褰撳墠搴撲綅鏄惁瀛樺湪 +// * @param shelvesParams +// * @return +// */ +// @Override +// public Loc selectPakinLocs(PakinOnShelvesParams shelvesParams) { +// return locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, shelvesParams.getLoc())); +// } + + } -- Gitblit v1.9.1