|
|
|
@ -22,6 +22,7 @@ import org.dromara.wms.mapper.WmsInventoryDetailsMapper;
|
|
|
|
import org.dromara.wms.mapper.WmsInventoryLedgerMapper;
|
|
|
|
import org.dromara.wms.mapper.WmsInventoryLedgerMapper;
|
|
|
|
import org.dromara.wms.mapper.WmsOutStockBillMapper;
|
|
|
|
import org.dromara.wms.mapper.WmsOutStockBillMapper;
|
|
|
|
import org.dromara.wms.mapper.WmsOutStockDetailsMapper;
|
|
|
|
import org.dromara.wms.mapper.WmsOutStockDetailsMapper;
|
|
|
|
|
|
|
|
import org.dromara.wms.service.IWmsInventoryDetailsService;
|
|
|
|
import org.dromara.wms.service.IWmsOutStockBillService;
|
|
|
|
import org.dromara.wms.service.IWmsOutStockBillService;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -44,8 +45,7 @@ public class WmsOutStockBillServiceImpl implements IWmsOutStockBillService {
|
|
|
|
|
|
|
|
|
|
|
|
private final WmsOutStockBillMapper baseMapper;
|
|
|
|
private final WmsOutStockBillMapper baseMapper;
|
|
|
|
private final WmsOutStockDetailsMapper wmsOutStockDetailsMapper;
|
|
|
|
private final WmsOutStockDetailsMapper wmsOutStockDetailsMapper;
|
|
|
|
private final WmsInventoryDetailsMapper wmsInventoryDetailsMapper;
|
|
|
|
private final IWmsInventoryDetailsService inventoryDetailsService;
|
|
|
|
private final WmsInventoryLedgerMapper wmsInventoryLedgerMapper;
|
|
|
|
|
|
|
|
@DubboReference
|
|
|
|
@DubboReference
|
|
|
|
private RemoteCodeRuleService remoteCodeRuleService;
|
|
|
|
private RemoteCodeRuleService remoteCodeRuleService;
|
|
|
|
|
|
|
|
|
|
|
|
@ -123,35 +123,12 @@ public class WmsOutStockBillServiceImpl implements IWmsOutStockBillService {
|
|
|
|
item.setOutStockBillId(outStockBillId);
|
|
|
|
item.setOutStockBillId(outStockBillId);
|
|
|
|
// 从出库明细中获取库存ID
|
|
|
|
// 从出库明细中获取库存ID
|
|
|
|
Long inventoryId = item.getInventoryDetailsId();
|
|
|
|
Long inventoryId = item.getInventoryDetailsId();
|
|
|
|
WmsInventoryDetails inventory = wmsInventoryDetailsMapper.selectById(inventoryId);
|
|
|
|
inventoryDetailsService.outStoreLossInventoryAmount(inventoryId,
|
|
|
|
Double inventoryAmount = inventory.getInventoryAmount();
|
|
|
|
item.getOutStockAmount(),item.getWarehouseId(),item.getBatchNumber(),item.getMaterielId(),"3");
|
|
|
|
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);
|
|
|
|
wmsOutStockDetailsMapper.insert(outStockDetailsList);
|
|
|
|
//插入库存变动
|
|
|
|
|
|
|
|
wmsInventoryLedgerMapper.insert(wmsInventoryLedgers);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return flag;
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|