zhou zhou
18 小时以前 cfe049492f81d2c650a2b17348593edbc5054498
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
@@ -8,6 +8,7 @@
import com.vincent.rsf.server.manager.controller.params.WaitPakinParam;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.enums.PakinIOStatus;
import com.vincent.rsf.server.manager.mapper.AsnOrderMapper;
import com.vincent.rsf.server.manager.mapper.WaitPakinMapper;
import com.vincent.rsf.server.manager.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,6 +16,7 @@
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -26,11 +28,9 @@
    @Autowired
    private AsnOrderService asnOrderService;
    private AsnOrderMapper asnOrderMapper;
    @Autowired
    private AsnOrderItemService asnOrderItemService;
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private WaitPakinItemService waitPakinItemService;
    @Autowired
@@ -38,10 +38,9 @@
    @Autowired
    private LocService locService;
    @Autowired
    private TaskService taskService;
    @Autowired
    private TaskItemService taskItemService;
    @Autowired
    @Lazy
    private AgvService  agvService;
@@ -63,7 +62,7 @@
            throw new CoolException("参数错误:托盘码为空!!");
        }
//        List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        WaitPakin pakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
        WaitPakin pakin = this.getOne(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
        if (!Objects.isNull(pakin)) {
            throw new CoolException("托盘码:" + waitPakin.getBarcode() + "已被组托单:" + pakin.getCode() + "使用!!");
@@ -129,7 +128,7 @@
                    .setUpdateBy(userId)
                    .setCreateBy(userId)
                    .setMatnrCode(warehouseAreasItems.getMatnrCode());
            WkOrder order = asnOrderService.getById(warehouseAreasItems.getAsnId());
            WkOrder order = asnOrderMapper.selectById(warehouseAreasItems.getAsnId());
            if (!Objects.isNull(order)) {
                pakinItem.setType(null == order.getType() ? null : order.getType())
                        .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()));
@@ -177,6 +176,38 @@
        return pakin;
    }
    /**
     * @author Munch D. Luffy
     * @date 2026/01/23
     * @description: PDA组拖前置检查
     * @version 1.0
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public synchronized boolean mergeItemsCheck(WaitPakinParam waitPakin, Long userId) {
        if (StringUtils.isBlank(waitPakin.getBarcode())) {
            throw new CoolException("参数错误:托盘码为空!!");
        }
        WaitPakin pakin = this.getOne(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
        if (!Objects.isNull(pakin)) {
            throw new CoolException("托盘码:" + waitPakin.getBarcode() + "已被组托单:" + pakin.getCode() + "使用!!");
        }
        List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
        if (!locs.isEmpty()) {
            List<String> locCodes = locs.stream().map(Loc::getCode).collect(Collectors.toList());
            String join = StringUtils.join(locCodes, ",");
            throw new CoolException("托盘码:" + waitPakin.getBarcode() + "已被库位:" + join + "使用!!");
        }
        String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_WAIT_PAKIN_CODE, null);
        if (StringUtils.isBlank(ruleCode)) {
            throw new CoolException("编码规则错误: 编码规则「SYS_WAIT_PAKIN_CODE」规则是不存在");
        }
        return agvService.AGVBindAndInTaskStart(waitPakin.getBarcode(),waitPakin.getStaNo());
    }
    /**
@@ -195,7 +226,7 @@
            throw new CoolException("参数错误:托盘码为空!!");
        }
//        List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        WaitPakin pakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
        WaitPakin pakin = this.getOne(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
        if (!Objects.isNull(pakin)) {
            throw new CoolException("托盘码:" + waitPakin.getBarcode() + "已被组托单:" + pakin.getCode() + "使用!!");
@@ -250,7 +281,7 @@
                    .setUpdateBy(userId)
                    .setCreateBy(userId)
                    .setMatnrCode(warehouseAreasItems.getMatnrCode());
            WkOrder order = asnOrderService.getById(warehouseAreasItems.getAsnId());
            WkOrder order = asnOrderMapper.selectById(warehouseAreasItems.getAsnId());
            if (!Objects.isNull(order)) {
                pakinItem.setType(null == order.getType() ? null : order.getType())
                        .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()));
@@ -316,7 +347,7 @@
    public synchronized WaitPakin unBind(WaitPakinParam param) {
        String barcode = param.getBarcode();
        if (StringUtils.isNotBlank(barcode)) {
            WaitPakin waitPakins = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, barcode));
            WaitPakin waitPakins = this.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, barcode));
            if (Objects.isNull(waitPakins)) {
                throw new CoolException("组托不存在!!");
            }
@@ -376,13 +407,13 @@
            double anfmes = paramItems.stream().mapToDouble(PakinItem::getReceiptQty).sum();
//            double anfmes = warehouseAreasItems.stream().mapToDouble(WarehouseAreasItem::getAnfme).sum();
            if (waitPakins.getAnfme().compareTo(anfmes) <= 0) {
                if (!waitPakinService.removeById(waitPakins.getId())) {
                if (!this.removeById(waitPakins.getId())) {
                    throw new CoolException("组托删除失败!!");
                }
            } else {
                Double anfme = Math.round((waitPakins.getAnfme() - anfmes) * 10000) / 10000.0;
                waitPakins.setAnfme(anfme);
                if (!waitPakinService.updateById(waitPakins)) {
                if (!this.updateById(waitPakins)) {
                    throw new CoolException("组托数据修改失败!!");
                }
            }
@@ -439,7 +470,7 @@
            }
        }
        if (!waitPakinService.removeByIds(pakinIds)) {
        if (!this.removeByIds(pakinIds)) {
            return R.error("Delete Fail");
        }