解决多单位商品,大单位时分批出库的时候的bug

This commit is contained in:
神话 2022-04-27 23:48:42 +08:00
parent b75076a5d4
commit 2df1e02080
2 changed files with 14 additions and 4 deletions

View File

@ -191,13 +191,13 @@ public class DepotItemController {
item.put("color", diEx.getMColor());
item.put("materialOther", getOtherInfo(mpArr, diEx));
BigDecimal stock;
Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询计量单位信息
String materialUnit = diEx.getMaterialUnit();
if(StringUtil.isNotEmpty(diEx.getSku())){
stock = depotItemService.getSkuStockByParam(diEx.getDepotId(),diEx.getMaterialExtendId(),null,null);
} else {
stock = depotItemService.getStockByParam(diEx.getDepotId(),diEx.getMaterialId(),null,null);
Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询计量单位信息
if (StringUtil.isNotEmpty(unitInfo.getName())) {
String materialUnit = diEx.getMaterialUnit();
stock = unitService.parseStockByUnit(stock, unitInfo, materialUnit);
}
}
@ -212,7 +212,7 @@ public class DepotItemController {
item.put("operNumber", diEx.getOperNumber());
item.put("basicNumber", diEx.getBasicNumber());
item.put("preNumber", diEx.getOperNumber()); //原数量
item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialId(), diEx.getHeaderId())); //已入库|已出库
item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialId(), diEx.getHeaderId(), unitInfo, materialUnit)); //已入库|已出库
item.put("unitPrice", diEx.getUnitPrice());
item.put("taxUnitPrice", diEx.getTaxUnitPrice());
item.put("allPrice", diEx.getAllPrice());

View File

@ -701,7 +701,7 @@ public class DepotItemService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BigDecimal getFinishNumber(Long mId, Long headerId) {
public BigDecimal getFinishNumber(Long mId, Long headerId, Unit unitInfo, String materialUnit) {
String goToType = "";
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
String linkNumber = depotHead.getNumber(); //订单号
@ -712,6 +712,16 @@ public class DepotItemService {
goToType = BusinessConstants.SUB_TYPE_SALES;
}
BigDecimal count = depotItemMapperEx.getFinishNumber(mId, linkNumber, goToType);
//根据多单位情况进行数量的转换
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatioTwo()),2,BigDecimal.ROUND_HALF_UP);
}
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != 0) {
count = count.divide(BigDecimal.valueOf(unitInfo.getRatioThree()),2,BigDecimal.ROUND_HALF_UP);
}
return count;
}