该资源已发起下架,重复发起下架时 抛出异常

This commit is contained in:
wangliwen 2022-05-20 18:11:14 +08:00
parent 8cdefe07de
commit e994527810
1 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,9 @@ import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysUserService; import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -54,6 +57,9 @@ public class ResourceMountController {
@Autowired @Autowired
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired
protected TaskService taskService;
private static String apply_key = "resourcemountapply"; // 资源上架 private static String apply_key = "resourcemountapply"; // 资源上架
private static String undercarriage_key = "resourcundercarriageapply"; // 资源下架 private static String undercarriage_key = "resourcundercarriageapply"; // 资源下架
@ -99,6 +105,11 @@ public class ResourceMountController {
} catch (Exception e) { } catch (Exception e) {
logger.error("", e); logger.error("", e);
} }
TaskQuery taskQuery = taskService.createTaskQuery();
Task task = taskQuery.active().processInstanceBusinessKey(tResourceMountApplyDTO.getId().toString()).singleResult();
if (task != null) {
throw new RuntimeException("该资源已发起下架");
}
ValidatorUtils.validateEntity(tResourceMountApplyDTO, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(tResourceMountApplyDTO, AddGroup.class, DefaultGroup.class);
tResourceMountApplyService.save(tResourceMountApplyDTO); // 保存单条资源申请记录 tResourceMountApplyService.save(tResourceMountApplyDTO); // 保存单条资源申请记录
@ -128,6 +139,7 @@ public class ResourceMountController {
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList())); }).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
} }
// TODO
@PostMapping(value = "/undercarriage") @PostMapping(value = "/undercarriage")
@ApiOperation("批量进行能力下架申请") @ApiOperation("批量进行能力下架申请")
public Result<List<ProcessInstanceDTO>> undercarriage(@RequestBody TResourceUndercarriageApplyDTO tResourceUndercarriageApplyDTO) { public Result<List<ProcessInstanceDTO>> undercarriage(@RequestBody TResourceUndercarriageApplyDTO tResourceUndercarriageApplyDTO) {