fix:需求单下推方法加锁避免并发问题
This commit is contained in:
@@ -311,9 +311,14 @@ public class PmDemandPlatingServiceImpl extends ServiceImpl<PmDemandPlatingMappe
|
||||
if (CollectionUtils.isEmpty(pmDemandDtos)){
|
||||
throw new BadRequestException("下推失败,请求数据不能为空");
|
||||
}
|
||||
if (pmDemandDtos.stream().anyMatch(i -> !Objects.equals(i.getStatus(), "01"))){
|
||||
throw new BadRequestException("单据不为已分配状态不能下推");
|
||||
}
|
||||
List<PmDemandPlating> disList = this.list(new LambdaQueryWrapper<PmDemandPlating>()
|
||||
.in(PmDemandPlating::getId, pmDemandDtos.stream().map(PmDemandDto::getId).collect(Collectors.toList()))
|
||||
.last("FOR UPDATE"));
|
||||
disList.forEach(item -> {
|
||||
if (!Objects.equals(item.getStatus(), DemandStatus.DIS.getValue())){
|
||||
throw new BadRequestException("下推失败,单据状态已更新请刷新重新推送");
|
||||
}
|
||||
});
|
||||
// 一次性分成两组
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -334,12 +335,14 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void pushDemand(List<PmDemandDto> pmDemandDtos) {
|
||||
if (CollectionUtils.isEmpty(pmDemandDtos)) {
|
||||
throw new BadRequestException("下推失败,请求数据不能为空");
|
||||
}
|
||||
List<PmDemand> disList = this.list(new LambdaQueryWrapper<PmDemand>()
|
||||
.in(PmDemand::getId, pmDemandDtos.stream().map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
.in(PmDemand::getId, pmDemandDtos.stream().map(PmDemandDto::getId).collect(Collectors.toList()))
|
||||
.last("FOR UPDATE"));
|
||||
disList.forEach(item -> {
|
||||
if (!Objects.equals(item.getStatus(), DemandStatus.DIS.getValue())){
|
||||
throw new BadRequestException("下推失败,单据状态已更新请刷新重新推送");
|
||||
|
||||
Reference in New Issue
Block a user