This commit is contained in:
wangliwen 2022-11-03 15:13:35 +08:00
parent f67410ddf3
commit 259ac18110
1 changed files with 0 additions and 77 deletions

View File

@ -15,14 +15,10 @@ import io.renren.modules.activiti.dto.ProcessInstanceDTO;
import io.renren.modules.activiti.dto.ProcessStartDTO; import io.renren.modules.activiti.dto.ProcessStartDTO;
import io.renren.modules.activiti.service.ActProcessService; import io.renren.modules.activiti.service.ActProcessService;
import io.renren.modules.activiti.service.ActRunningService; import io.renren.modules.activiti.service.ActRunningService;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceMountApply.dto.TResourceBatchMountApplyDTO; import io.renren.modules.resourceMountApply.dto.TResourceBatchMountApplyDTO;
import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO; import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
import io.renren.modules.resourceMountApply.dto.TResourceUndercarriageApplyDTO;
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService; import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysDeptService; import io.renren.modules.sys.service.SysDeptService;
@ -168,77 +164,4 @@ public class ResourceMountShowController {
return dto; return dto;
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList())); }).filter(ObjectUtil::isNotNull).collect(Collectors.toList()));
} }
@PostMapping(value = "/undercarriage")
@ApiOperation("批量进行能力下架申请")
@LogOperation("批量进行能力下架申请")
public Result<Object> undercarriage(@RequestBody TResourceUndercarriageApplyDTO tResourceUndercarriageApplyDTO) {
// 仿照请求接口 /act/process/lastestPage
PageData<Map<String, Object>> page = actProcessService.page(undercarriage_params);
if (page.getTotal() <= 0) { //
return new Result().error("联系管理员添加流程");
}
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();
long task = taskQuery.active().processDefinitionKey(UNDERCARRIAGE_KEY).processInstanceBusinessKey(resourceId.toString()).count();
return task > 0;
} else {
return true;
}
}).filter(index -> index).findAny();
if (undercarriage.isPresent()) {
return new Result<>().ok("该资源已发起下架");
}
return new Result().ok(tResourceUndercarriageApplyDTO.getResource().stream().map(index -> {
List<ProcessInstanceDTO> dtoList = new ArrayList<>();
Long resourceId = Long.valueOf(index.get("resourceId"));
Optional<ResourceDTO> resourceDTO = Optional.ofNullable(resourceService.get(resourceId));
resourceDTO.ifPresent(dto -> {
TaskQuery taskQuery = taskService.createTaskQuery();
long task = taskQuery.active().processDefinitionKey(UNDERCARRIAGE_KEY).processInstanceBusinessKey(resourceId.toString()).count();
if (task > 0) {
logger.error("该资源已发起下架");
throw new RuntimeException("该资源已发起下架");
}
dto.setUndercarriageReason(tResourceUndercarriageApplyDTO.getReason());
dto.setUndercarriageEnclosure(tResourceUndercarriageApplyDTO.getEnclosure());
dto.setUndercarriageEnclosureName(tResourceUndercarriageApplyDTO.getEnclosureName());
dto.setUndercarriageTitle(tResourceUndercarriageApplyDTO.getTitle());
dto.setUndercarriageUserPhone(tResourceUndercarriageApplyDTO.getPhone());
dto.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag()); // 设置为正常
dto.setFlowType("资源下架");
String userId = SecurityUser.getUserId().toString();
Optional<SysUserDTO> userDTO = Optional.ofNullable(sysUserService.get(Long.valueOf(userId)));
userDTO.ifPresent(user -> {
dto.setUndercarriageUserName(user.getRealName());
});
codeGenerationUtils.setApplyNumber("NLXJ", Arrays.asList(dto.getId()), jdbcTemplate);
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
resourceService.update(dto);
logger.error(resourceDTO.get().toString());
dto.setCompleteEntry(Boolean.TRUE);
logger.info("-------------------1.保存申请表单成功--------------------------");
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(resourceId.toString());
processStartDTO.setProcessDefinitionKey(UNDERCARRIAGE_KEY); // 限定资源下架
Map<String, Object> variables = oMapper.convertValue(dto, Map.class);
processStartDTO.setVariables(variables);
ProcessInstanceDTO index_ = actRunningService.startOfBusinessKey(processStartDTO);
logger.info("-------------------2.启动流程成功--------------------------");
logger.info("ProcessInstanceDTO.getBusinessKey:{}", index_.getBusinessKey());
dtoList.add(index_);
});
return dtoList.stream().findAny().orElse(null);
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList()));
}
} }