自动化立体仓库 - WMS系统
zhou zhou
2025-12-21 8fbb7182a426eac7e8112e60548b07d051b91a51
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -2,10 +2,7 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SnowflakeIdWorker;
import com.core.common.*;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.EmptyPlateOutParam;
@@ -29,6 +26,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -98,6 +96,9 @@
    @Autowired
    private OrderDetlPakoutService orderDetlPakoutService;
    @Autowired
    private InventoryReserveService inventoryReserveService;
    @Override
    @Transactional
@@ -189,6 +190,32 @@
        List<LocDetlDto> locDetlDtos = new ArrayList<>();
        for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) {
            if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) {
                List<InventoryReserve> inventoryReserves = inventoryReserveService.selectList(new EntityWrapper<InventoryReserve>()
                        .eq("matnr", paramLocDetl.getMatnr())
                        .eq("batch", paramLocDetl.getBatch())
                        .eq(!Cools.isEmpty(paramLocDetl.getBrand()), "brand", paramLocDetl.getBrand())
                        .eq(!Cools.isEmpty(paramLocDetl.getStandby1()), "standby1", paramLocDetl.getStandby1())
                        .eq(!Cools.isEmpty(paramLocDetl.getStandby2()), "standby2", paramLocDetl.getStandby2())
                        .eq(!Cools.isEmpty(paramLocDetl.getStandby3()), "standby3", paramLocDetl.getStandby3())
                        .eq(!Cools.isEmpty(paramLocDetl.getBoxType1()), "box_type1", paramLocDetl.getBoxType1())
                        .eq(!Cools.isEmpty(paramLocDetl.getBoxType2()), "box_type2", paramLocDetl.getBoxType2())
                        .eq(!Cools.isEmpty(paramLocDetl.getBoxType3()), "box_type3", paramLocDetl.getBoxType3())
                );
                List<LocDetl> locDetls = locDetlService.queryStockAll(null, null, paramLocDetl.getMatnr(), paramLocDetl.getBatch(),
                        paramLocDetl.getBrand(), paramLocDetl.getStandby1(), paramLocDetl.getStandby2(), paramLocDetl.getStandby3(), paramLocDetl.getBoxType1(), paramLocDetl.getBoxType2(), paramLocDetl.getBoxType3());
                if (!Cools.isEmpty(inventoryReserves)) {
                    BigDecimal inventoryReserveQuantity = inventoryReserves.stream().map(InventoryReserve::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal locDetlQuantity = locDetls.stream().map(LocDetl::getAnfme).map(BigDecimal::valueOf).reduce(BigDecimal.ZERO, BigDecimal::add);
                    if (locDetlQuantity.subtract(new BigDecimal(paramLocDetl.getCount().toString())).compareTo(inventoryReserveQuantity) < 0) {
                        throw new CoolException("库存预留数量大于库存数量");
                    }
                }
                LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch(), paramLocDetl.getBrand()
                        , paramLocDetl.getStandby1(), paramLocDetl.getStandby2(), paramLocDetl.getStandby3(), paramLocDetl.getBoxType1(), paramLocDetl.getBoxType2(), paramLocDetl.getBoxType3());
                if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount()));
@@ -1067,7 +1094,7 @@
    @Transactional
    public void cancelWrkMast(String workNo, Long userId) {
        Date now = new Date();
        WrkMast wrkMast = wrkMastService.selectById(workNo);
        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", workNo));
        if (Cools.isEmpty(wrkMast)) {
            throw new CoolException(workNo + "工作档不存在");
        }
@@ -1218,7 +1245,7 @@
    @Override
    @Transactional
    public void pickWrkMast(String workNo, Long userId) {
        WrkMast wrkMast = wrkMastService.selectById(workNo);
        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", workNo));
        if (Cools.isEmpty(wrkMast)) {
            throw new CoolException(workNo + "工作档不存在");
        }