zjj
6 天以前 d8dd683271bffd641084193c6d8ef0b2cffa008d
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java
@@ -16,6 +16,7 @@
import com.vincent.rsf.server.manager.service.QlyInspectService;
import com.vincent.rsf.server.manager.service.QlyIsptItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -110,17 +111,22 @@
            if (Objects.isNull(orderItem)) {
                throw new CoolException("收货单据不存在!!");
            }
            Double sum = item.getDisQty() + item.getSafeQty();
            Double disQty = Objects.isNull(item.getDisQty()) ? 0 : item.getDisQty();
            Double safeQty = Objects.isNull(item.getSafeQty()) ? 0 : item.getSafeQty();
            Double sum = disQty + safeQty;
            orderItem.setIsptQty(sum);
            if (!warehouseAreasItemService.updateById(orderItem)) {
                throw new CoolException("收货区库存信息更新失败!!");
            }
            if (sum.compareTo(0.0) > 0) {
                if (!warehouseAreasItemService.updateById(orderItem)) {
                    throw new CoolException("收货区库存信息更新失败!!");
                }
            if (Objects.isNull(orderItem.getIsptResult())) {
                operateReceipt(item, orderItem);
            } else {
                //新建质检单,质检结果不会有质检结果
                if (Objects.isNull(orderItem.getIsptResult())) {
                    operateReceipt(item, orderItem);
                }
            }
        }
@@ -135,7 +141,6 @@
                    .eq(QlyInspect::getId, isptItem.stream().findFirst().get().getIspectId()));
        }
//        qlyIsptItemService.pageByIsptResult(null, new QueryWrapper<QlyIsptItem>())
        return true;
    }
@@ -146,41 +151,57 @@
     * @version 1.0
     */
    private void operateReceipt(QlyIsptItem item, WarehouseAreasItem orderItem) {
        Double sum = item.getDisQty() + item.getSafeQty();
        Double disQty = Objects.isNull(item.getDisQty()) ? 0 : item.getDisQty();
        Double safeQty = Objects.isNull(item.getSafeQty()) ? 0 : item.getSafeQty();
        Double sum = disQty + safeQty;
        if (sum.compareTo(orderItem.getAnfme()) >= 0) {
            //完成质检,做更新操作
            if (item.getSafeQty().compareTo(0.0) > 0) {
                orderItem.setIsptQty(item.getSafeQty());
            if (safeQty.compareTo(0.0) > 0) {
                orderItem.setIsptQty(safeQty).setAnfme(safeQty);
                orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val);
                if (!warehouseAreasItemService.updateById(orderItem)) {
                    throw new CoolException("收货区库存明细更新失败!!");
                }
            }
            if (item.getDisQty().compareTo(0.0) > 0) {
                orderItem.setIsptQty(item.getDisQty())
            WarehouseAreasItem areasItem = new WarehouseAreasItem();
            BeanUtils.copyProperties(orderItem, areasItem);
            if (disQty.compareTo(0.0) > 0) {
                areasItem.setIsptQty(disQty)
                        .setAnfme(disQty)
                        .setId(null)
                        .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val);
                if (!warehouseAreasItemService.saveOrUpdate(orderItem)) {
                if (!warehouseAreasItemService.saveOrUpdate(areasItem)) {
                    throw new CoolException("收货区库存明细更新失败!!");
                }
            }
        } else {
            orderItem.setAnfme(orderItem.getAnfme() - sum);
            if (!warehouseAreasItemService.updateById(orderItem)) {
                throw new CoolException("收货区库存明细更新失败!!");
            }
            WarehouseAreasItem areasItem = new WarehouseAreasItem();
            BeanUtils.copyProperties(orderItem, areasItem);
            //未完成做添加操作
            if (item.getSafeQty().compareTo(0.0) > 0) {
                orderItem.setIsptQty(item.getSafeQty())
            if (safeQty.compareTo(0.0) > 0) {
                areasItem.setIsptQty(safeQty)
                        .setAnfme(safeQty)
                        .setId(null)
                        .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val);
                if (!warehouseAreasItemService.saveOrUpdate(orderItem)) {
                if (!warehouseAreasItemService.saveOrUpdate(areasItem)) {
                    throw new CoolException("收货区库存明细更新失败!!");
                }
            }
            if (item.getDisQty().compareTo(0.0) > 0) {
                orderItem.setIsptQty(item.getDisQty())
            WarehouseAreasItem items = new WarehouseAreasItem();
            BeanUtils.copyProperties(orderItem, items);
            if (disQty.compareTo(0.0) > 0) {
                items.setIsptQty(disQty)
                        .setAnfme(disQty)
                        .setId(null)
                        .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val);
                if (!warehouseAreasItemService.saveOrUpdate(orderItem)) {
                if (!warehouseAreasItemService.saveOrUpdate(items)) {
                    throw new CoolException("收货区库存明细更新失败!!");
                }
            }