添加库存校验
This commit is contained in:
@@ -179,4 +179,6 @@ public interface DepotItemMapperEx {
|
|||||||
@Param("rows") Integer rows, @Param("pid") Integer pid);
|
@Param("rows") Integer rows, @Param("pid") Integer pid);
|
||||||
|
|
||||||
int findStockWarningCountTotal( @Param("pid") Integer pid);
|
int findStockWarningCountTotal( @Param("pid") Integer pid);
|
||||||
|
|
||||||
|
BigDecimal getCurrentRepByMaterialIdAndDepotId(@Param("materialId")Long materialId,@Param("depotId") Long depotId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ public class DepotItemService {
|
|||||||
String mIdStr = map.get("mId");
|
String mIdStr = map.get("mId");
|
||||||
Long mId = null;
|
Long mId = null;
|
||||||
if(!StringUtil.isEmpty(mIdStr)) {
|
if(!StringUtil.isEmpty(mIdStr)) {
|
||||||
mId = Long.parseLong(mIdStr);
|
mId = Long.valueOf(mIdStr);
|
||||||
}
|
}
|
||||||
String monthTime = map.get("monthTime");
|
String monthTime = map.get("monthTime");
|
||||||
List<DepotItemVo4Material> list =null;
|
List<DepotItemVo4Material> list =null;
|
||||||
@@ -601,7 +601,7 @@ public class DepotItemService {
|
|||||||
if(material==null){
|
if(material==null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(getCurrentInStock(depotItem.getMaterialid())<(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()){
|
if(getCurrentRepByMaterialIdAndDepotId(material.getId(),depotItem.getDepotid()).compareTo(depotItem.getBasicnumber()==null?BigDecimal.ZERO:depotItem.getBasicnumber())==-1){
|
||||||
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()));
|
||||||
}
|
}
|
||||||
@@ -633,19 +633,21 @@ public class DepotItemService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//首先回收序列号
|
//首先回收序列号
|
||||||
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
|
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())) {
|
||||||
&&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())) {
|
|
||||||
/**
|
if(!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())) {
|
||||||
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
|
/**
|
||||||
* */
|
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
|
||||||
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())) {
|
* */
|
||||||
serialNumberService.cancelSerialNumber(depotItem.getMaterialid(), depotItem.getHeaderid(), (depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),
|
if (BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())) {
|
||||||
userInfo);
|
serialNumberService.cancelSerialNumber(depotItem.getMaterialid(), depotItem.getHeaderid(), (depotItem.getBasicnumber() == null ? 0 : depotItem.getBasicnumber()).intValue(),
|
||||||
|
userInfo);
|
||||||
|
}
|
||||||
|
/**收回序列号的时候释放库存*/
|
||||||
|
depotItem.setOpernumber(BigDecimal.ZERO);
|
||||||
|
depotItem.setBasicnumber(BigDecimal.ZERO);
|
||||||
|
this.updateDepotItemWithObj(depotItem);
|
||||||
}
|
}
|
||||||
/**收回序列号的时候释放库存*/
|
|
||||||
depotItem.setOpernumber(BigDecimal.ZERO);
|
|
||||||
depotItem.setBasicnumber(BigDecimal.ZERO);
|
|
||||||
this.updateDepotItemWithObj(depotItem);
|
|
||||||
}
|
}
|
||||||
depotItem.setId(tempUpdatedJson.getLong("Id"));
|
depotItem.setId(tempUpdatedJson.getLong("Id"));
|
||||||
depotItem.setMaterialid(tempUpdatedJson.getLong("MaterialId"));
|
depotItem.setMaterialid(tempUpdatedJson.getLong("MaterialId"));
|
||||||
@@ -724,7 +726,8 @@ 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(getCurrentRepByMaterialIdAndDepotId(material.getId(),depotItem.getDepotid())
|
||||||
|
.compareTo(depotItem.getBasicnumber()==null?BigDecimal.ZERO:depotItem.getBasicnumber())==-1){
|
||||||
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()));
|
||||||
}
|
}
|
||||||
@@ -820,4 +823,23 @@ public class DepotItemService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* create by: qiankunpingtai
|
||||||
|
* create time: 2019/5/16 18:15
|
||||||
|
* website:https://qiankunpingtai.cn
|
||||||
|
* description:
|
||||||
|
* 查询指定仓库指定材料的当前库存
|
||||||
|
*/
|
||||||
|
public BigDecimal getCurrentRepByMaterialIdAndDepotId(Long materialId,Long depotId) {
|
||||||
|
BigDecimal result = BigDecimal.ZERO;
|
||||||
|
try{
|
||||||
|
result =depotItemMapperEx.getCurrentRepByMaterialIdAndDepotId(materialId,depotId);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -610,5 +610,25 @@
|
|||||||
AND ifnull(m.delete_Flag, '0') != '1'
|
AND ifnull(m.delete_Flag, '0') != '1'
|
||||||
AND intype.BasicInNumber > 0
|
AND intype.BasicInNumber > 0
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getCurrentRepByMaterialIdAndDepotId" resultType="java.math.BigDecimal">
|
||||||
|
select ((curep.inTotal+curep.transfInTotal+curep.assemInTotal+curep.disAssemInTotal)
|
||||||
|
-(curep.transfOutTotal+curep.outTotal+curep.assemOutTotal+curep.disAssemOutTotal)) as currentRepo
|
||||||
|
from
|
||||||
|
(select sum(dh.type='入库' and di.DepotId=#{depotId}) as inTotal,
|
||||||
|
sum(dh.SubType='调拨' and di.AnotherDepotId=#{depotId}) as transfInTotal,
|
||||||
|
sum(dh.SubType='调拨' and di.DepotId=#{depotId}) as transfOutTotal,
|
||||||
|
sum(dh.type='出库' and dh.SubType!='调拨' and di.DepotId=#{depotId}) as outTotal,
|
||||||
|
sum(dh.SubType='组装单' and di.MType='组合件' and di.DepotId=#{depotId}) as assemInTotal,
|
||||||
|
sum(dh.SubType='组装单' and di.MType='普通子件' and di.DepotId=#{depotId}) as assemOutTotal,
|
||||||
|
sum(dh.SubType='拆卸单' and di.MType='普通子件' and di.DepotId=#{depotId}) as disAssemInTotal,
|
||||||
|
sum(dh.SubType='拆卸单' and di.MType='组合件' and di.DepotId=#{depotId}) as disAssemOutTotal
|
||||||
|
from
|
||||||
|
jsh_depothead dh,jsh_depotitem di
|
||||||
|
where 1=1
|
||||||
|
and dh.id=di.HeaderId
|
||||||
|
and di.MaterialId=#{materialId}
|
||||||
|
and ifnull(dh.delete_Flag,'0') !='1'
|
||||||
|
and ifnull(di.delete_Flag,'0') !='1') curep
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user