添加物品单位和基础单位副单位不一致的判断

This commit is contained in:
qiankunpingtai
2019-06-14 14:25:06 +08:00
parent 5a93cd472f
commit 0d6c24d522
2 changed files with 54 additions and 49 deletions

View File

@@ -278,6 +278,9 @@ public class ExceptionConstants {
//商品库存不足 //商品库存不足
public static final int MATERIAL_STOCK_NOT_ENOUGH_CODE = 8000004; public static final int MATERIAL_STOCK_NOT_ENOUGH_CODE = 8000004;
public static final String MATERIAL_STOCK_NOT_ENOUGH_MSG = "商品:%s库存不足"; public static final String MATERIAL_STOCK_NOT_ENOUGH_MSG = "商品:%s库存不足";
//商品单位不正确
public static final int MATERIAL_UNIT_NOT_RIGHT_CODE = 8000005;
public static final String MATERIAL_UNIT_NOT_RIGHT_MSG = "商品:%s单位不正确使用单位:%s基础单位%s副单位%s";
/** /**
* 单据信息 * 单据信息
* type = 85 * type = 85

View File

@@ -513,9 +513,9 @@ public class DepotItemService {
depotItem.setHeaderid(headerId); depotItem.setHeaderid(headerId);
depotItem.setMaterialid(tempInsertedJson.getLong("MaterialId")); depotItem.setMaterialid(tempInsertedJson.getLong("MaterialId"));
depotItem.setMunit(tempInsertedJson.getString("Unit")); depotItem.setMunit(tempInsertedJson.getString("Unit"));
Material material= materialService.getMaterial(depotItem.getMaterialid());
if (!StringUtil.isEmpty(tempInsertedJson.get("OperNumber").toString())) { if (!StringUtil.isEmpty(tempInsertedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempInsertedJson.getBigDecimal("OperNumber")); depotItem.setOpernumber(tempInsertedJson.getBigDecimal("OperNumber"));
try {
String Unit = tempInsertedJson.get("Unit").toString(); String Unit = tempInsertedJson.get("Unit").toString();
BigDecimal oNumber = tempInsertedJson.getBigDecimal("OperNumber"); BigDecimal oNumber = tempInsertedJson.getBigDecimal("OperNumber");
Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString()); Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString());
@@ -535,13 +535,14 @@ public class DepotItemService {
depotItem.setBasicnumber(oNumber); //数量一致 depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位 } else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio)) ); //数量乘以比例 depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio)) ); //数量乘以比例
}else{
//不等于基础单位也不等于副单位,单位存在问题
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_CODE,
String.format(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_MSG,material==null?"":material.getName(),Unit,basicUnit,otherUnit));
} }
} else { } else {
depotItem.setBasicnumber(oNumber); //其他情况 depotItem.setBasicnumber(oNumber); //其他情况
} }
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
} }
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) { if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempInsertedJson.getBigDecimal("UnitPrice")); depotItem.setUnitprice(tempInsertedJson.getBigDecimal("UnitPrice"));
@@ -593,7 +594,6 @@ public class DepotItemService {
if(depotItem==null){ if(depotItem==null){
continue; continue;
} }
Material material= materialService.getMaterial(depotItem.getMaterialid());
if(material==null){ if(material==null){
continue; continue;
} }
@@ -648,9 +648,11 @@ public class DepotItemService {
depotItem.setId(tempUpdatedJson.getLong("Id")); depotItem.setId(tempUpdatedJson.getLong("Id"));
depotItem.setMaterialid(tempUpdatedJson.getLong("MaterialId")); depotItem.setMaterialid(tempUpdatedJson.getLong("MaterialId"));
depotItem.setMunit(tempUpdatedJson.getString("Unit")); depotItem.setMunit(tempUpdatedJson.getString("Unit"));
if(!material.getId().equals(depotItem.getMaterialid())){
material= materialService.getMaterial(depotItem.getMaterialid());
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("OperNumber").toString())) { if (!StringUtil.isEmpty(tempUpdatedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempUpdatedJson.getBigDecimal("OperNumber")); depotItem.setOpernumber(tempUpdatedJson.getBigDecimal("OperNumber"));
try {
String Unit = tempUpdatedJson.get("Unit").toString(); String Unit = tempUpdatedJson.get("Unit").toString();
BigDecimal oNumber = tempUpdatedJson.getBigDecimal("OperNumber"); BigDecimal oNumber = tempUpdatedJson.getBigDecimal("OperNumber");
Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString()); Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString());
@@ -667,13 +669,14 @@ public class DepotItemService {
depotItem.setBasicnumber(oNumber); //数量一致 depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位 } else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio))); //数量乘以比例 depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio))); //数量乘以比例
}else{
//不等于基础单位也不等于副单位,单位存在问题
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_CODE,
String.format(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_MSG,material==null?"":material.getName(),Unit,basicUnit,otherUnit));
} }
} else { } else {
depotItem.setBasicnumber(oNumber); //其他情况 depotItem.setBasicnumber(oNumber); //其他情况
} }
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
} }
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) { if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempUpdatedJson.getBigDecimal("UnitPrice")); depotItem.setUnitprice(tempUpdatedJson.getBigDecimal("UnitPrice"));
@@ -715,7 +718,6 @@ public class DepotItemService {
* 这里需要重新获取页面传递的商品信息 * 这里需要重新获取页面传递的商品信息
*/ */
if(!material.getId().equals(depotItem.getMaterialid())){ if(!material.getId().equals(depotItem.getMaterialid())){
material= materialService.getMaterial(depotItem.getMaterialid());
if(material==null){ if(material==null){
continue; continue;
} }