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 | 122 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 113 insertions(+), 9 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 d01778e..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 @@ -2,26 +2,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.exception.CoolException; -import com.zy.asrs.wms.asrs.entity.Order; -import com.zy.asrs.wms.asrs.entity.WaitPakin; -import com.zy.asrs.wms.asrs.entity.enums.LocTypeHeightType; +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.enums.TaskStsType; 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.OrderService; -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 { @@ -29,12 +28,23 @@ @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 @@ -85,4 +95,98 @@ 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