chen.lin
5 小时以前 c69781e2b78ed7a5ffe9b59c0c555f07deabe735
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
@@ -43,6 +43,7 @@
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.Date;
@Service
public class PdaOutStockServiceImpl implements PdaOutStockService {
@@ -356,6 +357,34 @@
                if (!taskItemService.updateById(item)) {
                    throw new CoolException("状态完成失败!!");
                }
                // 扣减库位明细库存(与出库完成逻辑保持一致)
                if (StringUtils.isNotBlank(task.getOrgLoc())) {
                    LocItem locItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>()
                            .eq(LocItem::getLocCode, task.getOrgLoc())
                            .eq(LocItem::getMatnrId, item.getMatnrId())
                            .eq(StringUtils.isNotBlank(item.getBatch()), LocItem::getBatch, item.getBatch())
                            .eq(StringUtils.isNotBlank(item.getFieldsIndex()), LocItem::getFieldsIndex, item.getFieldsIndex()));
                    if (Objects.nonNull(locItem)) {
                        // 使用实际拣货数量(taskItem.getAnfme())扣减库位明细
                        Double newAnfme = Math.round((locItem.getAnfme() - taskItem.getAnfme()) * 1000000) / 1000000.0;
                        if (newAnfme.compareTo(0.0) <= 0) {
                            // 数量小于等于0,删除库位明细
                            locItemService.removeById(locItem.getId());
                        } else {
                            // 更新库位明细数量
                            locItem.setAnfme(newAnfme)
                                    .setUpdateBy(SystemAuthUtils.getLoginUserId())
                                    .setUpdateTime(new Date());
                            if (!locItemService.updateById(locItem)) {
                                throw new CoolException("库位明细数量扣减失败!!");
                            }
                        }
                    }
                }
                StockItem stockItem = new StockItem();
                BeanUtils.copyProperties(item, stockItem);
                //taskItem为上报数据