给多单位再增加两个副单位
This commit is contained in:
@@ -138,17 +138,10 @@ public class DepotItemController {
|
||||
stock = depotItemService.getSkuStockByParam(depotId,materialVo4Unit.getMeId(),null,null);
|
||||
} else {
|
||||
stock = depotItemService.getStockByParam(depotId,materialVo4Unit.getId(),null,null);
|
||||
String commodityUnit = materialVo4Unit.getCommodityUnit();
|
||||
Long unitId = materialVo4Unit.getUnitId();
|
||||
if(unitId!=null) {
|
||||
Integer ratio = 1;
|
||||
Unit unit = unitService.getUnit(unitId);
|
||||
if(commodityUnit.equals(unit.getOtherUnit())){
|
||||
ratio = unit.getRatio();
|
||||
if(ratio!=0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(ratio),2,BigDecimal.ROUND_HALF_UP); //两位小数
|
||||
}
|
||||
}
|
||||
if(materialVo4Unit.getUnitId()!=null) {
|
||||
Unit unit = unitService.getUnit(materialVo4Unit.getUnitId());
|
||||
String commodityUnit = materialVo4Unit.getCommodityUnit();
|
||||
stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,20 +190,15 @@ public class DepotItemController {
|
||||
item.put("model", diEx.getMModel());
|
||||
item.put("color", diEx.getMColor());
|
||||
item.put("materialOther", getOtherInfo(mpArr, diEx));
|
||||
Integer ratio = diEx.getRatio();
|
||||
BigDecimal stock;
|
||||
if(StringUtil.isNotEmpty(diEx.getSku())){
|
||||
stock = depotItemService.getSkuStockByParam(diEx.getDepotId(),diEx.getMaterialExtendId(),null,null);
|
||||
} else {
|
||||
stock = depotItemService.getStockByParam(diEx.getDepotId(),diEx.getMaterialId(),null,null);
|
||||
if(ratio!=null){
|
||||
BigDecimal ratioDecimal = new BigDecimal(ratio.toString());
|
||||
if(ratioDecimal.compareTo(BigDecimal.ZERO)!=0){
|
||||
String otherUnit = diEx.getOtherUnit();
|
||||
if(otherUnit.equals(diEx.getMaterialUnit())) {
|
||||
stock = stock.divide(ratioDecimal,2,BigDecimal.ROUND_HALF_UP); //两位小数
|
||||
}
|
||||
}
|
||||
Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询计量单位信息
|
||||
if (StringUtil.isNotEmpty(unitInfo.getName())) {
|
||||
String materialUnit = diEx.getMaterialUnit();
|
||||
stock = unitService.parseStockByUnit(stock, unitInfo, materialUnit);
|
||||
}
|
||||
}
|
||||
item.put("stock", stock);
|
||||
@@ -252,7 +240,6 @@ public class DepotItemController {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取扩展信息
|
||||
*
|
||||
|
||||
@@ -208,14 +208,11 @@ public class MaterialController {
|
||||
for (MaterialVo4Unit material : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", material.getMeId()); //商品扩展表的id
|
||||
String ratio; //比例
|
||||
String ratioStr; //比例
|
||||
if (material.getUnitId() == null || material.getUnitId().equals("")) {
|
||||
ratio = "";
|
||||
ratioStr = "";
|
||||
} else {
|
||||
ratio = material.getUnitName();
|
||||
if(ratio!=null) {
|
||||
ratio = ratio.substring(ratio.indexOf("("));
|
||||
}
|
||||
ratioStr = "[多单位]";
|
||||
}
|
||||
item.put("mBarCode", material.getmBarCode());
|
||||
item.put("name", material.getName());
|
||||
@@ -223,7 +220,7 @@ public class MaterialController {
|
||||
item.put("standard", material.getStandard());
|
||||
item.put("model", material.getModel());
|
||||
item.put("color", material.getColor());
|
||||
item.put("unit", material.getCommodityUnit() + ratio);
|
||||
item.put("unit", material.getCommodityUnit() + ratioStr);
|
||||
item.put("sku", material.getSku());
|
||||
item.put("enableSerialNumber", material.getEnableSerialNumber());
|
||||
item.put("enableBatchNumber", material.getEnableBatchNumber());
|
||||
@@ -234,11 +231,8 @@ public class MaterialController {
|
||||
stock = depotItemService.getStockByParam(depotId,material.getId(),null,null);
|
||||
if (material.getUnitId()!=null){
|
||||
Unit unit = unitService.getUnit(material.getUnitId());
|
||||
if(material.getCommodityUnit().equals(unit.getOtherUnit())) {
|
||||
if(unit.getRatio()!=0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(unit.getRatio()),2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
String commodityUnit = material.getCommodityUnit();
|
||||
stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
|
||||
}
|
||||
}
|
||||
item.put("stock", stock);
|
||||
@@ -578,11 +572,8 @@ public class MaterialController {
|
||||
stock = depotItemService.getStockByParam(mvo.getDepotId(), mvo.getId(), null, null);
|
||||
if (mvo.getUnitId() != null) {
|
||||
Unit unit = unitService.getUnit(mvo.getUnitId());
|
||||
if (mvo.getCommodityUnit().equals(unit.getOtherUnit())) {
|
||||
if (unit.getRatio() != 0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(unit.getRatio()), 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
String commodityUnit = mvo.getCommodityUnit();
|
||||
stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
|
||||
}
|
||||
}
|
||||
mvo.setStock(stock);
|
||||
|
||||
Reference in New Issue
Block a user