资源重复下线错误提示
This commit is contained in:
parent
27d692f575
commit
1c7e2dcdc1
|
@ -103,13 +103,7 @@ public class ResourceMountController {
|
|||
try {
|
||||
tResourceMountApplyDTO.setResourceId(tResourceMountApplyDTO.getResourceDTO().getId());
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
Task task = taskQuery.active().processInstanceBusinessKey(tResourceMountApplyDTO.getId().toString()).singleResult();
|
||||
if (task != null) {
|
||||
logger.error("该资源已发起下架");
|
||||
throw new RuntimeException("该资源已发起下架");
|
||||
logger.error("资源上架异常", e);
|
||||
}
|
||||
|
||||
ValidatorUtils.validateEntity(tResourceMountApplyDTO, AddGroup.class, DefaultGroup.class);
|
||||
|
@ -117,6 +111,13 @@ public class ResourceMountController {
|
|||
if (tResourceMountApplyDTO.getId() == null) {
|
||||
return null;
|
||||
}
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
Task task = taskQuery.active().processInstanceBusinessKey(tResourceMountApplyDTO.getId().toString()).singleResult();
|
||||
if (task != null) {
|
||||
logger.error("该资源已发起上架");
|
||||
throw new RuntimeException("该资源已发起上架");
|
||||
}
|
||||
|
||||
tResourceMountApplyDTO.setCompleteEntry(Boolean.TRUE);
|
||||
logger.info("-------------------1.保存申请表单成功--------------------------");
|
||||
// 仿照请求接口 /act/running/startOfBusinessKey
|
||||
|
@ -140,7 +141,6 @@ public class ResourceMountController {
|
|||
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping(value = "/undercarriage")
|
||||
@ApiOperation("批量进行能力下架申请")
|
||||
public Result<List<ProcessInstanceDTO>> undercarriage(@RequestBody TResourceUndercarriageApplyDTO tResourceUndercarriageApplyDTO) {
|
||||
|
@ -152,14 +152,29 @@ public class ResourceMountController {
|
|||
logger.info("---------------------------------------------------");
|
||||
logger.info(JSONObject.toJSONString(tResourceUndercarriageApplyDTO));
|
||||
logger.info("####################################################");
|
||||
Optional<Boolean> undercarriage =
|
||||
tResourceUndercarriageApplyDTO.getResource().stream().map(index -> {
|
||||
Long resourceId = Long.valueOf(index.get("resourceId"));
|
||||
Optional<ResourceDTO> resourceDTO = Optional.ofNullable(resourceService.get(resourceId));
|
||||
if (resourceDTO.isPresent()) {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
Task task = taskQuery.active().processDefinitionKey(undercarriage_key).processInstanceBusinessKey(resourceId.toString()).singleResult();
|
||||
return task != null;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}).filter(index -> index).findAny();
|
||||
if (undercarriage.isPresent()){
|
||||
return new Result<List<ProcessInstanceDTO>>().error("该资源已发起下架");
|
||||
}
|
||||
return new Result().ok(tResourceUndercarriageApplyDTO.getResource().stream().map(index -> {
|
||||
List<ProcessInstanceDTO> dtoList = new ArrayList<>();
|
||||
Long resourceId = Long.valueOf(index.get("resourceId"));
|
||||
String resourceName = index.get("resourceName");
|
||||
// String resourceName = index.get("resourceName");
|
||||
Optional<ResourceDTO> resourceDTO = Optional.ofNullable(resourceService.get(resourceId));
|
||||
resourceDTO.ifPresent(dto -> {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
Task task = taskQuery.active().processInstanceBusinessKey(resourceId.toString()).singleResult();
|
||||
Task task = taskQuery.active().processDefinitionKey(undercarriage_key).processInstanceBusinessKey(resourceId.toString()).singleResult();
|
||||
if (task != null) {
|
||||
logger.error("该资源已发起下架");
|
||||
throw new RuntimeException("该资源已发起下架");
|
||||
|
|
Loading…
Reference in New Issue