|
@@ -55,16 +55,12 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
|
private SparePickDetailMapper sparePickDetailMapper;
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void spareOutStore(OutStoreFormDTO model) {
|
|
|
SpareStore spareStore = new SpareStore();
|
|
|
spareStore.setSpareId(model.getSpareId());
|
|
|
- List<SpareStore> spareStores = spareStoreMapper.select(spareStore);
|
|
|
- Integer currentStock=0;
|
|
|
- for (SpareStore store:spareStores){
|
|
|
- Integer num = (store.getNum()==null?0:store.getNum().intValue());
|
|
|
- currentStock+=num;
|
|
|
- }
|
|
|
- if (currentStock<model.getOutNum()){
|
|
|
+ spareStore = spareStoreMapper.selectOne(spareStore);
|
|
|
+ if (spareStore.getNum().intValue()<model.getOutNum()){
|
|
|
throw new BusinessException("库存不足,请修改出库数量!");
|
|
|
}
|
|
|
UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
@@ -74,8 +70,13 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
|
model.setOutNo(IdGeneratorUtils.getOutStoreNo(++count));
|
|
|
model.setDelFlag(false);
|
|
|
model.setUserInfo(userInfo);
|
|
|
+
|
|
|
model.setStatus(OutStoreStatusEnum.EXECUTING.getValue());
|
|
|
OutStoreForm outStoreForm = super.saveModelByDTO(model);
|
|
|
+ //修改库存
|
|
|
+ spareStore.setNum(new BigDecimal(spareStore.getNum().intValue()-model.getOutNum()));
|
|
|
+ spareStoreMapper.updateByPrimaryKeySelective(spareStore);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|