skyouc
7 天以前 b9d414bc2d61b4824ce6a019b1c10f526f71ced1
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
@@ -2,7 +2,6 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.manager.controller.params.PakinItem;
import com.vincent.rsf.server.manager.controller.params.WaitPakinParam;
@@ -16,7 +15,6 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -41,16 +39,17 @@
    private LocService locService;
    /**
     * @param
     * @param userId
     * @return
     * @author Ryan
     * @description 组拖
     * @param
     * @return
     * @time 2025/3/29 14:42
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public WaitPakin mergeItems(WaitPakinParam waitPakin) {
        if (waitPakin.getItems().isEmpty()) {
    public WaitPakin mergeItems(WaitPakinParam waitPakin, Long userId) {
        if (Objects.isNull(waitPakin.getItems()) || waitPakin.getItems().isEmpty()) {
            throw new CoolException("参数错误:物料跟踪码为空!");
        }
        if (StringUtils.isBlank(waitPakin.getBarcode())) {
@@ -84,6 +83,8 @@
                    //状态修改为入库中
                    .setIoStatus(Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val))
                    .setAnfme(sum)
                    .setUpdateBy(userId)
                    .setCreateBy(userId)
                    .setBarcode(waitPakin.getBarcode());
            if (!this.save(waitPakin1)) {
                throw new CoolException("主单保存失败!!");
@@ -125,10 +126,17 @@
                        .setFieldsIndex(item.getFieldsIndex())
                        .setMatnrId(item.getMatnrId())
                        .setMaktx(item.getMaktx())
                        .setUpdateBy(userId)
                        .setCreateBy(userId)
                        .setMatnrCode(item.getMatnrCode());
                AsnOrder order = asnOrderService.getById(item.getAsnId());
                if (!Objects.isNull(order)) {
                    pakinItem.setType(null == order.getType() ?  null :order.getType())
                            .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()) );
                }
                for (PakinItem waitPakinItem : waitPakin.getItems()) {
                    if (waitPakinItem.getTrackCode().equals(item.getTrackCode())) {
                        if (waitPakinItem.getReceiptQty() > item.getAnfme()) {
                        if (waitPakinItem.getReceiptQty() > item.getAnfme() || waitPakinItem.getReceiptQty().compareTo(0.0) >= 0) {
                            throw new CoolException("组拖数量不能大于收货数量!!");
                        }
                        pakinItem.setAnfme(waitPakinItem.getReceiptQty()).setTrackCode(waitPakinItem.getTrackCode());
@@ -159,11 +167,19 @@
                        .setFieldsIndex(item.getFieldsIndex())
                        .setMatnrId(item.getMatnrId())
                        .setMaktx(item.getMaktx())
                        .setUpdateBy(userId)
                        .setCreateBy(userId)
                        .setMatnrCode(item.getMatnrCode());
                AsnOrder order = asnOrderService.getById(item.getAsnId());
                if (!Objects.isNull(order)) {
                    pakinItem.setType(null == order.getType() ?  null :order.getType())
                            .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()) );
                }
                for (PakinItem waitPakinItem : waitPakin.getItems()) {
                    if (waitPakinItem.getTrackCode().equals(item.getTrackCode())) {
                        if (waitPakinItem.getReceiptQty() > item.getAnfme()) {
                            throw new CoolException("组拖数量不能大于收货数量!!");
                        if (waitPakinItem.getReceiptQty() > item.getAnfme() || waitPakinItem.getReceiptQty().compareTo(0.0) <= 0) {
                            throw new CoolException("组拖数量不能大于收货数量且不能小于零!!");
                        }
                        pakinItem.setAnfme(waitPakinItem.getReceiptQty()).setTrackCode(waitPakinItem.getTrackCode());
                    }
@@ -179,6 +195,9 @@
        if (!this.updateById(waitPakin1)) {
            throw new CoolException("组拖数量修改失败!!");
        }
        //TODO 组拖完成后,扣减收货区库存
        return pakin;
    }