|
|
|
|
@ -5,24 +5,29 @@ import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
import org.dromara.system.api.RemoteCodeRuleService;
|
|
|
|
|
import org.dromara.wms.domain.WmsInventoryDetails;
|
|
|
|
|
import org.dromara.wms.domain.WmsInventoryLedger;
|
|
|
|
|
import org.dromara.wms.domain.WmsOutStockBill;
|
|
|
|
|
import org.dromara.wms.domain.WmsOutStockDetails;
|
|
|
|
|
import org.dromara.wms.domain.bo.WmsOutStockBillBo;
|
|
|
|
|
import org.dromara.wms.domain.vo.WmsInventoryDetailsVo;
|
|
|
|
|
import org.dromara.wms.domain.vo.WmsOutStockBillVo;
|
|
|
|
|
import org.dromara.wms.mapper.WmsInventoryDetailsMapper;
|
|
|
|
|
import org.dromara.wms.mapper.WmsInventoryLedgerMapper;
|
|
|
|
|
import org.dromara.wms.mapper.WmsOutStockBillMapper;
|
|
|
|
|
import org.dromara.wms.mapper.WmsOutStockDetailsMapper;
|
|
|
|
|
import org.dromara.wms.service.IWmsOutStockBillService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
@ -39,9 +44,10 @@ public class WmsOutStockBillServiceImpl implements IWmsOutStockBillService {
|
|
|
|
|
|
|
|
|
|
private final WmsOutStockBillMapper baseMapper;
|
|
|
|
|
private final WmsOutStockDetailsMapper wmsOutStockDetailsMapper;
|
|
|
|
|
private final WmsInventoryDetailsMapper wmsInventoryDetailsMapper;
|
|
|
|
|
private final WmsInventoryLedgerMapper wmsInventoryLedgerMapper;
|
|
|
|
|
@DubboReference
|
|
|
|
|
private RemoteCodeRuleService remoteCodeRuleService;
|
|
|
|
|
private final WmsInventoryDetailsMapper wmsInventoryDetailsMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询出库单
|
|
|
|
|
@ -112,19 +118,40 @@ public class WmsOutStockBillServiceImpl implements IWmsOutStockBillService {
|
|
|
|
|
if (flag) {
|
|
|
|
|
Long outStockBillId = add.getOutStockBillId();
|
|
|
|
|
List<WmsOutStockDetails> outStockDetailsList = bo.getOutStockDetailsList();
|
|
|
|
|
List<WmsInventoryLedger> wmsInventoryLedgers = new ArrayList<>();
|
|
|
|
|
outStockDetailsList.forEach(item -> {
|
|
|
|
|
|
|
|
|
|
item.setOutStockBillId(outStockBillId);
|
|
|
|
|
// 从出库明细中获取库存ID
|
|
|
|
|
Long inventoryId = item.getInventoryDetailsId();
|
|
|
|
|
WmsInventoryDetails inventory = wmsInventoryDetailsMapper.selectById(inventoryId);
|
|
|
|
|
if (inventory.getInventoryAmount()<item.getOutStockAmount()) {
|
|
|
|
|
Double inventoryAmount = inventory.getInventoryAmount();
|
|
|
|
|
double lossQty = inventoryAmount - item.getOutStockAmount();
|
|
|
|
|
if (lossQty < 0) {
|
|
|
|
|
throw new IllegalArgumentException("库存数量不足");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inventory.setInventoryAmount(lossQty);
|
|
|
|
|
if (lossQty == 0.0){
|
|
|
|
|
inventory.setDelFlag("1");
|
|
|
|
|
}
|
|
|
|
|
inventory.setUpdateBy( LoginHelper.getUserId());
|
|
|
|
|
inventory.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
wmsInventoryDetailsMapper.updataDetailsByInventoryId(inventory);
|
|
|
|
|
//库存变动
|
|
|
|
|
WmsInventoryLedger wmsInventoryLedger = new WmsInventoryLedger();
|
|
|
|
|
wmsInventoryLedger.setWarehouseId(item.getWarehouseId());
|
|
|
|
|
wmsInventoryLedger.setBatchNumber(item.getBatchNumber());
|
|
|
|
|
wmsInventoryLedger.setMaterielId(item.getMaterielId());
|
|
|
|
|
wmsInventoryLedger.setChangeType("3");//变动类型
|
|
|
|
|
wmsInventoryLedger.setLedgerState("0");
|
|
|
|
|
wmsInventoryLedger.setChangeAmount(item.getOutStockAmount());
|
|
|
|
|
wmsInventoryLedger.setInventoryAmount(inventoryAmount);
|
|
|
|
|
wmsInventoryLedgers.add(wmsInventoryLedger);
|
|
|
|
|
});
|
|
|
|
|
//插入出库明细
|
|
|
|
|
wmsOutStockDetailsMapper.insert(outStockDetailsList);
|
|
|
|
|
//插入库存变动
|
|
|
|
|
wmsInventoryLedgerMapper.insert(wmsInventoryLedgers);
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|