给多单位再增加两个副单位
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);
|
||||
|
||||
@@ -9,8 +9,16 @@ public class Unit {
|
||||
|
||||
private String otherUnit;
|
||||
|
||||
private String otherUnitTwo;
|
||||
|
||||
private String otherUnitThree;
|
||||
|
||||
private Integer ratio;
|
||||
|
||||
private Integer ratioTwo;
|
||||
|
||||
private Integer ratioThree;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private String deleteFlag;
|
||||
@@ -47,6 +55,22 @@ public class Unit {
|
||||
this.otherUnit = otherUnit == null ? null : otherUnit.trim();
|
||||
}
|
||||
|
||||
public String getOtherUnitTwo() {
|
||||
return otherUnitTwo;
|
||||
}
|
||||
|
||||
public void setOtherUnitTwo(String otherUnitTwo) {
|
||||
this.otherUnitTwo = otherUnitTwo == null ? null : otherUnitTwo.trim();
|
||||
}
|
||||
|
||||
public String getOtherUnitThree() {
|
||||
return otherUnitThree;
|
||||
}
|
||||
|
||||
public void setOtherUnitThree(String otherUnitThree) {
|
||||
this.otherUnitThree = otherUnitThree == null ? null : otherUnitThree.trim();
|
||||
}
|
||||
|
||||
public Integer getRatio() {
|
||||
return ratio;
|
||||
}
|
||||
@@ -55,6 +79,22 @@ public class Unit {
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
public Integer getRatioTwo() {
|
||||
return ratioTwo;
|
||||
}
|
||||
|
||||
public void setRatioTwo(Integer ratioTwo) {
|
||||
this.ratioTwo = ratioTwo;
|
||||
}
|
||||
|
||||
public Integer getRatioThree() {
|
||||
return ratioThree;
|
||||
}
|
||||
|
||||
public void setRatioThree(Integer ratioThree) {
|
||||
this.ratioThree = ratioThree;
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
@@ -374,6 +374,146 @@ public class UnitExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoIsNull() {
|
||||
addCriterion("other_unit_two is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoIsNotNull() {
|
||||
addCriterion("other_unit_two is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoEqualTo(String value) {
|
||||
addCriterion("other_unit_two =", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoNotEqualTo(String value) {
|
||||
addCriterion("other_unit_two <>", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoGreaterThan(String value) {
|
||||
addCriterion("other_unit_two >", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("other_unit_two >=", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoLessThan(String value) {
|
||||
addCriterion("other_unit_two <", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoLessThanOrEqualTo(String value) {
|
||||
addCriterion("other_unit_two <=", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoLike(String value) {
|
||||
addCriterion("other_unit_two like", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoNotLike(String value) {
|
||||
addCriterion("other_unit_two not like", value, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoIn(List<String> values) {
|
||||
addCriterion("other_unit_two in", values, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoNotIn(List<String> values) {
|
||||
addCriterion("other_unit_two not in", values, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoBetween(String value1, String value2) {
|
||||
addCriterion("other_unit_two between", value1, value2, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitTwoNotBetween(String value1, String value2) {
|
||||
addCriterion("other_unit_two not between", value1, value2, "otherUnitTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeIsNull() {
|
||||
addCriterion("other_unit_three is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeIsNotNull() {
|
||||
addCriterion("other_unit_three is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeEqualTo(String value) {
|
||||
addCriterion("other_unit_three =", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeNotEqualTo(String value) {
|
||||
addCriterion("other_unit_three <>", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeGreaterThan(String value) {
|
||||
addCriterion("other_unit_three >", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("other_unit_three >=", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeLessThan(String value) {
|
||||
addCriterion("other_unit_three <", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeLessThanOrEqualTo(String value) {
|
||||
addCriterion("other_unit_three <=", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeLike(String value) {
|
||||
addCriterion("other_unit_three like", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeNotLike(String value) {
|
||||
addCriterion("other_unit_three not like", value, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeIn(List<String> values) {
|
||||
addCriterion("other_unit_three in", values, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeNotIn(List<String> values) {
|
||||
addCriterion("other_unit_three not in", values, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeBetween(String value1, String value2) {
|
||||
addCriterion("other_unit_three between", value1, value2, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOtherUnitThreeNotBetween(String value1, String value2) {
|
||||
addCriterion("other_unit_three not between", value1, value2, "otherUnitThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioIsNull() {
|
||||
addCriterion("ratio is null");
|
||||
return (Criteria) this;
|
||||
@@ -434,6 +574,126 @@ public class UnitExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoIsNull() {
|
||||
addCriterion("ratio_two is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoIsNotNull() {
|
||||
addCriterion("ratio_two is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoEqualTo(Integer value) {
|
||||
addCriterion("ratio_two =", value, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoNotEqualTo(Integer value) {
|
||||
addCriterion("ratio_two <>", value, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoGreaterThan(Integer value) {
|
||||
addCriterion("ratio_two >", value, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("ratio_two >=", value, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoLessThan(Integer value) {
|
||||
addCriterion("ratio_two <", value, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("ratio_two <=", value, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoIn(List<Integer> values) {
|
||||
addCriterion("ratio_two in", values, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoNotIn(List<Integer> values) {
|
||||
addCriterion("ratio_two not in", values, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoBetween(Integer value1, Integer value2) {
|
||||
addCriterion("ratio_two between", value1, value2, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioTwoNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("ratio_two not between", value1, value2, "ratioTwo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeIsNull() {
|
||||
addCriterion("ratio_three is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeIsNotNull() {
|
||||
addCriterion("ratio_three is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeEqualTo(Integer value) {
|
||||
addCriterion("ratio_three =", value, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeNotEqualTo(Integer value) {
|
||||
addCriterion("ratio_three <>", value, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeGreaterThan(Integer value) {
|
||||
addCriterion("ratio_three >", value, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("ratio_three >=", value, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeLessThan(Integer value) {
|
||||
addCriterion("ratio_three <", value, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("ratio_three <=", value, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeIn(List<Integer> values) {
|
||||
addCriterion("ratio_three in", values, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeNotIn(List<Integer> values) {
|
||||
addCriterion("ratio_three not in", values, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeBetween(Integer value1, Integer value2) {
|
||||
addCriterion("ratio_three between", value1, value2, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRatioThreeNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("ratio_three not between", value1, value2, "ratioThree");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIsNull() {
|
||||
addCriterion("tenant_id is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -382,12 +382,14 @@ public class DepotItemService {
|
||||
Unit unitInfo = materialService.findUnit(materialExtend.getMaterialId()); //查询计量单位信息
|
||||
if (StringUtil.isNotEmpty(unitInfo.getName())) {
|
||||
String basicUnit = unitInfo.getBasicUnit(); //基本单位
|
||||
String otherUnit = unitInfo.getOtherUnit(); //副单位
|
||||
Integer ratio = unitInfo.getRatio(); //比例
|
||||
if (unit.equals(basicUnit)) { //如果等于基础单位
|
||||
depotItem.setBasicNumber(oNumber); //数量一致
|
||||
} else if (unit.equals(otherUnit)) { //如果等于副单位
|
||||
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(ratio)) ); //数量乘以比例
|
||||
} else if (unit.equals(unitInfo.getOtherUnit())) { //如果等于副单位
|
||||
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatio())) ); //数量乘以比例
|
||||
} else if (unit.equals(unitInfo.getOtherUnitTwo())) { //如果等于副单位2
|
||||
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatioTwo())) ); //数量乘以比例
|
||||
} else if (unit.equals(unitInfo.getOtherUnitThree())) { //如果等于副单位3
|
||||
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatioThree())) ); //数量乘以比例
|
||||
}
|
||||
} else {
|
||||
depotItem.setBasicNumber(oNumber); //其他情况
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -102,7 +103,7 @@ public class UnitService {
|
||||
Unit unit = JSONObject.parseObject(obj.toJSONString(), Unit.class);
|
||||
int result=0;
|
||||
try{
|
||||
unit.setName(unit.getBasicUnit() + "," + unit.getOtherUnit() + "(1:" + unit.getRatio() + ")");
|
||||
parseNameByUnit(unit);
|
||||
result=unitMapper.insertSelective(unit);
|
||||
logService.insertLog("计量单位",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(unit.getName()).toString(), request);
|
||||
@@ -117,7 +118,7 @@ public class UnitService {
|
||||
Unit unit = JSONObject.parseObject(obj.toJSONString(), Unit.class);
|
||||
int result=0;
|
||||
try{
|
||||
unit.setName(unit.getBasicUnit() + "," + unit.getOtherUnit() + "(1:" + unit.getRatio() + ")");
|
||||
parseNameByUnit(unit);
|
||||
result=unitMapper.updateByPrimaryKeySelective(unit);
|
||||
logService.insertLog("计量单位",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(unit.getName()).toString(), request);
|
||||
@@ -127,6 +128,21 @@ public class UnitService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据单位信息生成名称的格式
|
||||
* @param unit
|
||||
*/
|
||||
private void parseNameByUnit(Unit unit) {
|
||||
String unitName = unit.getBasicUnit() + "/" + "(" + unit.getOtherUnit() + "=" + unit.getRatio().toString() + unit.getBasicUnit() + ")";
|
||||
if(StringUtil.isNotEmpty(unit.getOtherUnitTwo()) && unit.getRatioTwo()!=null) {
|
||||
unitName += "/" + "(" + unit.getOtherUnitTwo() + "=" + unit.getRatioTwo().toString() + unit.getBasicUnit() + ")";
|
||||
if(StringUtil.isNotEmpty(unit.getOtherUnitThree()) && unit.getRatioThree()!=null) {
|
||||
unitName += "/" + "(" + unit.getOtherUnitThree() + "=" + unit.getRatioThree().toString() + unit.getBasicUnit() + ")";
|
||||
}
|
||||
}
|
||||
unit.setName(unitName);
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int deleteUnit(Long id, HttpServletRequest request)throws Exception {
|
||||
return batchDeleteUnitByIds(id.toString());
|
||||
@@ -199,4 +215,24 @@ public class UnitService {
|
||||
}
|
||||
return unitId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据多单位的比例进行库存换算(保留两位小数)
|
||||
* @param stock
|
||||
* @param unitInfo
|
||||
* @param materialUnit
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal parseStockByUnit(BigDecimal stock, Unit unitInfo, String materialUnit) {
|
||||
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo() != 0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatioTwo()),2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != 0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatioThree()),2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
return stock;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user