添加物品单位和基础单位副单位不一致的判断
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -513,34 +513,35 @@ 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());
|
/***
|
||||||
/***
|
* 为什么调用的方法要先把基础单位去掉,去掉之后后续还能获取到?
|
||||||
* 为什么调用的方法要先把基础单位去掉,去掉之后后续还能获取到?
|
* */
|
||||||
* */
|
//以下进行单位换算
|
||||||
//以下进行单位换算
|
// String UnitName = findUnitName(mId); //查询计量单位名称
|
||||||
// String UnitName = findUnitName(mId); //查询计量单位名称
|
String unitName = materialService.findUnitName(mId);
|
||||||
String unitName = materialService.findUnitName(mId);
|
if (!StringUtil.isEmpty(unitName)) {
|
||||||
if (!StringUtil.isEmpty(unitName)) {
|
String unitList = unitName.substring(0, unitName.indexOf("("));
|
||||||
String unitList = unitName.substring(0, unitName.indexOf("("));
|
String ratioList = unitName.substring(unitName.indexOf("("));
|
||||||
String ratioList = unitName.substring(unitName.indexOf("("));
|
String basicUnit = unitList.substring(0, unitList.indexOf(",")); //基本单位
|
||||||
String basicUnit = unitList.substring(0, unitList.indexOf(",")); //基本单位
|
String otherUnit = unitList.substring(unitList.indexOf(",") + 1); //副单位
|
||||||
String otherUnit = unitList.substring(unitList.indexOf(",") + 1); //副单位
|
Integer ratio = Integer.parseInt(ratioList.substring(ratioList.indexOf(":") + 1).replace(")", "")); //比例
|
||||||
Integer ratio = Integer.parseInt(ratioList.substring(ratioList.indexOf(":") + 1).replace(")", "")); //比例
|
if (Unit.equals(basicUnit)) { //如果等于基础单位
|
||||||
if (Unit.equals(basicUnit)) { //如果等于基础单位
|
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{
|
||||||
}
|
//不等于基础单位也不等于副单位,单位存在问题
|
||||||
} else {
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_CODE,
|
||||||
depotItem.setBasicnumber(oNumber); //其他情况
|
String.format(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_MSG,material==null?"":material.getName(),Unit,basicUnit,otherUnit));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
|
depotItem.setBasicnumber(oNumber); //其他情况
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
|
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
|
||||||
@@ -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,31 +648,34 @@ 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());
|
//以下进行单位换算
|
||||||
//以下进行单位换算
|
// String UnitName = findUnitName(mId); //查询计量单位名称
|
||||||
// String UnitName = findUnitName(mId); //查询计量单位名称
|
String unitName = materialService.findUnitName(mId);
|
||||||
String unitName = materialService.findUnitName(mId);
|
if (!StringUtil.isEmpty(unitName)) {
|
||||||
if (!StringUtil.isEmpty(unitName)) {
|
String unitList = unitName.substring(0, unitName.indexOf("("));
|
||||||
String unitList = unitName.substring(0, unitName.indexOf("("));
|
String ratioList = unitName.substring(unitName.indexOf("("));
|
||||||
String ratioList = unitName.substring(unitName.indexOf("("));
|
String basicUnit = unitList.substring(0, unitList.indexOf(",")); //基本单位
|
||||||
String basicUnit = unitList.substring(0, unitList.indexOf(",")); //基本单位
|
String otherUnit = unitList.substring(unitList.indexOf(",") + 1); //副单位
|
||||||
String otherUnit = unitList.substring(unitList.indexOf(",") + 1); //副单位
|
Integer ratio = Integer.parseInt(ratioList.substring(ratioList.indexOf(":") + 1).replace(")", "")); //比例
|
||||||
Integer ratio = Integer.parseInt(ratioList.substring(ratioList.indexOf(":") + 1).replace(")", "")); //比例
|
if (Unit.equals(basicUnit)) { //如果等于基础单位
|
||||||
if (Unit.equals(basicUnit)) { //如果等于基础单位
|
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{
|
||||||
}
|
//不等于基础单位也不等于副单位,单位存在问题
|
||||||
} else {
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_CODE,
|
||||||
depotItem.setBasicnumber(oNumber); //其他情况
|
String.format(ExceptionConstants.MATERIAL_UNIT_NOT_RIGHT_MSG,material==null?"":material.getName(),Unit,basicUnit,otherUnit));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
|
depotItem.setBasicnumber(oNumber); //其他情况
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
|
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user