解决单据提交时库存未根据仓库去判断的bug

This commit is contained in:
季圣华
2019-06-10 23:14:40 +08:00
parent 4cf39d4d5f
commit 7b795718be
3 changed files with 38 additions and 5 deletions

View File

@@ -307,6 +307,14 @@ public class DepotItemService {
return result;
}
public int findByTypeAndMaterialIdAndDepotId(String type, Long mId, Long depotId) {
if(type.equals(TYPE)) {
return depotItemMapperEx.findByTypeAndDepotIdAndMaterialIdIn(depotId, mId);
} else {
return depotItemMapperEx.findByTypeAndDepotIdAndMaterialIdOut(depotId, mId);
}
}
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
@@ -588,7 +596,7 @@ public class DepotItemService {
if(material==null){
continue;
}
if(getCurrentInStock(depotItem.getMaterialid())<(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()){
if(getCurrentInStock(depotItem.getMaterialid(),depotItem.getDepotid())<(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()){
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE,
String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName()));
}
@@ -711,7 +719,7 @@ public class DepotItemService {
}
/**出库时处理序列号*/
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
if(getCurrentInStock(depotItem.getMaterialid())<(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()){
if(getCurrentInStock(depotItem.getMaterialid(),depotItem.getDepotid())<(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()){
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE,
String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName()));
}
@@ -754,11 +762,11 @@ public class DepotItemService {
* 查询商品当前库存数量是否充足,
*
* */
public int getCurrentInStock(Long materialId)throws Exception{
public int getCurrentInStock(Long materialId, Long depotId){
//入库数量
int inSum = findByTypeAndMaterialId(BusinessConstants.DEPOTHEAD_TYPE_STORAGE, materialId);
int inSum = findByTypeAndMaterialIdAndDepotId(BusinessConstants.DEPOTHEAD_TYPE_STORAGE, materialId, depotId);
//出库数量
int outSum = findByTypeAndMaterialId(BusinessConstants.DEPOTHEAD_TYPE_OUT, materialId);
int outSum = findByTypeAndMaterialIdAndDepotId(BusinessConstants.DEPOTHEAD_TYPE_OUT, materialId ,depotId);
return (inSum-outSum);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)