解决单据提交时库存未根据仓库去判断的bug
This commit is contained in:
@@ -51,6 +51,14 @@ public interface DepotItemMapperEx {
|
|||||||
int findByTypeAndMaterialIdOut(
|
int findByTypeAndMaterialIdOut(
|
||||||
@Param("mId") Long mId);
|
@Param("mId") Long mId);
|
||||||
|
|
||||||
|
int findByTypeAndDepotIdAndMaterialIdIn(
|
||||||
|
@Param("depotId") Long depotId,
|
||||||
|
@Param("mId") Long mId);
|
||||||
|
|
||||||
|
int findByTypeAndDepotIdAndMaterialIdOut(
|
||||||
|
@Param("depotId") Long depotId,
|
||||||
|
@Param("mId") Long mId);
|
||||||
|
|
||||||
List<DepotItemVo4WithInfoEx> getDetailList(
|
List<DepotItemVo4WithInfoEx> getDetailList(
|
||||||
@Param("headerId") Long headerId);
|
@Param("headerId") Long headerId);
|
||||||
|
|
||||||
|
|||||||
@@ -307,6 +307,14 @@ public class DepotItemService {
|
|||||||
return result;
|
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 {
|
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId)throws Exception {
|
||||||
List<DepotItemVo4WithInfoEx> list =null;
|
List<DepotItemVo4WithInfoEx> list =null;
|
||||||
try{
|
try{
|
||||||
@@ -588,7 +596,7 @@ public class DepotItemService {
|
|||||||
if(material==null){
|
if(material==null){
|
||||||
continue;
|
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,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE,
|
||||||
String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName()));
|
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(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,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE,
|
||||||
String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName()));
|
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);
|
return (inSum-outSum);
|
||||||
}
|
}
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
|||||||
@@ -148,6 +148,23 @@
|
|||||||
and ifnull(dh.delete_Flag,'0') !='1'
|
and ifnull(dh.delete_Flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="findByTypeAndDepotIdAndMaterialIdIn" resultType="java.lang.Integer">
|
||||||
|
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
|
||||||
|
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
|
||||||
|
where dh.type='入库'
|
||||||
|
and di.MaterialId = ${mId} and di.DepotId = ${depotId}
|
||||||
|
and ifnull(dh.delete_Flag,'0') !='1'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="findByTypeAndDepotIdAndMaterialIdOut" resultType="java.lang.Integer">
|
||||||
|
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
|
||||||
|
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
|
||||||
|
where dh.type='出库'
|
||||||
|
and dh.SubType!='调拨'
|
||||||
|
and di.MaterialId = ${mId} and di.DepotId = ${depotId}
|
||||||
|
and ifnull(dh.delete_Flag,'0') !='1'
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
|
<select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
|
||||||
select di.*,m.Name MName,m.Model MModel,m.Unit MaterialUnit,m.Color MColor,m.Standard MStandard,m.Mfrs MMfrs,
|
select di.*,m.Name MName,m.Model MModel,m.Unit MaterialUnit,m.Color MColor,m.Standard MStandard,m.Mfrs MMfrs,
|
||||||
m.OtherField1 MOtherField1,m.OtherField2 MOtherField2,m.OtherField3 MOtherField3,
|
m.OtherField1 MOtherField1,m.OtherField2 MOtherField2,m.OtherField3 MOtherField3,
|
||||||
|
|||||||
Reference in New Issue
Block a user