Merge remote-tracking branch 'origin/master'

This commit is contained in:
dinggang 2022-05-11 09:49:48 +08:00
commit 8822dbac56
12 changed files with 380 additions and 93 deletions

View File

@ -31,7 +31,7 @@ import java.util.Map;
@RestController
@RequestMapping("/demand_v2/center")
public class DemandDataController {
private static Logger logger = LoggerFactory.getLogger(ResourceMountController.class);
private static Logger logger = LoggerFactory.getLogger(DemandDataController.class);
@Autowired
private ActProcessService actProcessService;

View File

@ -13,9 +13,16 @@ import io.renren.modules.activiti.dto.ProcessInstanceDTO;
import io.renren.modules.activiti.dto.ProcessStartDTO;
import io.renren.modules.activiti.service.ActProcessService;
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.resourceMountApply.dto.TResourceBatchMountApplyDTO;
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.security.user.SecurityUser;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.codehaus.jackson.map.ObjectMapper;
@ -30,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@Api(tags = "资源上架")
@ -44,12 +52,26 @@ public class ResourceMountController {
private ActRunningService actRunningService;
@Autowired
private TResourceMountApplyService tResourceMountApplyService;
private static String key = "resourcemountapply";
@Autowired
private ResourceService resourceService;
@Autowired
private SysUserService sysUserService;
private static Map<String, Object> params = new HashMap<String, Object>() {
private static String apply_key = "resourcemountapply"; // 资源上架
private static String undercarriage_key = "resourcundercarriageapply"; // 资源下架
private static Map<String, Object> apply_params = new HashMap<String, Object>() {
{
put("isLatestVersion", true); // 取最新版本
put("key", key); // 限定 能力资源上架
put("key", apply_key); // 限定 能力资源上架
}
};
private static Map<String, Object> undercarriage_params = new HashMap<String, Object>() {
{
put("isLatestVersion", true); // 取最新版本
put("key", undercarriage_key); // 限定 资源下架
}
};
@ -58,7 +80,7 @@ public class ResourceMountController {
@ApiOperation("批量进行能力上架申请")
public Result<List<ProcessInstanceDTO>> apply(@RequestBody TResourceBatchMountApplyDTO tResourceBatchMountApplyDTO) {
// 仿照请求接口 /act/process/lastestPage
PageData<Map<String, Object>> page = actProcessService.page(params);
PageData<Map<String, Object>> page = actProcessService.page(apply_params);
if (page.getTotal() <= 0) { //
return new Result().error("联系管理员添加流程");
}
@ -85,7 +107,7 @@ public class ResourceMountController {
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(tResourceMountApplyDTO.getId().toString());
processStartDTO.setProcessDefinitionKey(key); // 限定资源上架
processStartDTO.setProcessDefinitionKey(apply_key); // 限定资源上架
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(tResourceMountApplyDTO, Map.class);
processStartDTO.setVariables(variables);
@ -103,4 +125,47 @@ public class ResourceMountController {
return dto;
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
}
@PostMapping(value = "/undercarriage")
@ApiOperation("批量进行能力下架申请")
public Result<List<ProcessInstanceDTO>> 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("####################################################");
return new Result().ok(tResourceUndercarriageApplyDTO.getResource().stream().map(index -> {
Long resourceId = Long.valueOf(index.get("resourceId"));
String resourceName = index.get("resourceName");
Optional<ResourceDTO> resourceDTO = Optional.ofNullable(resourceService.get(resourceId));
resourceDTO.ifPresent(dto -> {
dto.setUndercarriageReason(tResourceUndercarriageApplyDTO.getReason());
dto.setDelFlag(ResourceEntityDelFlag.UNDERCARRIAGE_REVIEW.getFlag()); // 设置为下架审核中
String userId = SecurityUser.getUserId().toString();
Optional<SysUserDTO> userDTO = Optional.ofNullable(sysUserService.get(Long.valueOf(userId)));
userDTO.ifPresent(user -> {
dto.setUndercarriageUserName(user.getRealName());
});
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
resourceService.update(dto);
});
logger.info("-------------------1.保存申请表单成功--------------------------");
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(resourceId.toString());
processStartDTO.setProcessDefinitionKey(undercarriage_key); // 限定资源下架
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(resourceDTO, Map.class);
processStartDTO.setVariables(variables);
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
logger.info("-------------------2.启动流程成功--------------------------");
logger.info("ProcessInstanceDTO.getBusinessKey:" + dto.getBusinessKey());
return dto;
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
}
}

View File

@ -14,7 +14,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@ -24,11 +23,12 @@ import java.util.Map;
/**
* 任务管理
*
* @author Jone
*/
@RestController
@RequestMapping("/act/task")
@Api(tags="任务管理")
@Api(tags = "任务管理")
public class ActTaskController {
@Autowired
private ActTaskService actTaskService;
@ -38,40 +38,42 @@ public class ActTaskController {
/**
* 获取用户任务列表
* 根据用户ID或角色组获取任务信息
*
* @return
*/
@GetMapping("page")
@ApiOperation("待办任务默认查询所有待办任务。根据用户ID或角色ID查询个人或组的任务")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = "roleIds", value = "roleIds", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "userId", value = "userId", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "isRoleGroup", value = "是否查询分组", paramType = "query", dataType="String")
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "roleIds", value = "roleIds", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "userId", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "isRoleGroup", value = "是否查询分组", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result<PageData<TaskDTO>> queryUserTaskPage(@ApiIgnore @RequestParam Map<String, Object> params){
public Result<PageData<TaskDTO>> queryUserTaskPage(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<TaskDTO> page = actTaskService.page(params);
return new Result<PageData<TaskDTO>>().ok(page);
}
/**
* 我的待办列表
*
* @return
*/
@GetMapping("myToDoTaskPage")
@ApiOperation("我的待办列表")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int"),
@ApiImplicitParam(name = "taskName", value = "任务名称", paramType = "query", dataType="String")
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "taskName", value = "任务名称", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result<PageData<TaskDTO>> myToDoTaskPage(@ApiIgnore @RequestParam Map<String, Object> params){
public Result<PageData<TaskDTO>> myToDoTaskPage(@ApiIgnore @RequestParam Map<String, Object> params) {
params.put("userId", SecurityUser.getUserId().toString());
PageData<TaskDTO> page = actTaskService.page(params);
for(TaskDTO taskDTO : page.getList()){
if(!StringUtils.isEmpty(taskDTO.getAssignee())){
for (TaskDTO taskDTO : page.getList()) {
if (!StringUtils.isEmpty(taskDTO.getAssignee())) {
SysUserDTO userDTO = sysUserService.get(Long.valueOf(taskDTO.getAssignee()));
taskDTO.setAssigneeName(userDTO.getRealName());
}
@ -86,7 +88,7 @@ public class ActTaskController {
@ApiOperation("获取任务详情")
@LogOperation("获取任务详情")
// @RequiresPermissions("sys:task:all")
public Result getTaskById(@PathVariable("id") String id){
public Result getTaskById(@PathVariable("id") String id) {
TaskDTO task = actTaskService.taskDetail(id);
return new Result().ok(task);
}
@ -96,10 +98,10 @@ public class ActTaskController {
*/
@PostMapping("claim")
@ApiOperation("认领任务")
@ApiImplicitParam(name = "taskId", value = "taskId", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "taskId", paramType = "query", dataType = "String")
// @RequiresPermissions("sys:task:all")
public Result claimTask(String taskId){
if(StringUtils.isEmpty(taskId)){
public Result claimTask(String taskId) {
if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.claimTask(taskId);
@ -111,10 +113,10 @@ public class ActTaskController {
*/
@PostMapping("unclaim")
@ApiOperation("释放任务")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String")
// @RequiresPermissions("sys:task:all")
public Result unclaimTask(String taskId){
if(StringUtils.isEmpty(taskId)){
public Result unclaimTask(String taskId) {
if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.unclaimTask(taskId);
@ -127,25 +129,26 @@ public class ActTaskController {
@PostMapping("complete")
@ApiOperation("任务处理(完成任务)")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "comment", value = "审批意见", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "审批意见", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result completeTask(String taskId, String comment){
if(StringUtils.isEmpty(taskId)){
public Result completeTask(String taskId, String comment) {
if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.completeTask(taskId, comment);
return new Result();
}
/**
* 带参数的任务处理
*/
@PostMapping("completeByVariables")
@ApiOperation("带参数的任务处理(完成任务)")
// @RequiresPermissions("sys:task:all")
public Result completeTaskByVariables(@RequestBody TaskDTO taskDTO){
if(StringUtils.isEmpty(taskDTO.getTaskId())){
public Result completeTaskByVariables(@RequestBody TaskDTO taskDTO) {
if (StringUtils.isEmpty(taskDTO.getTaskId())) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.completeTaskByVariables(taskDTO);
@ -158,12 +161,12 @@ public class ActTaskController {
@PostMapping("entrust")
@ApiOperation("任务委托")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "assignee", value = "受理人", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "assignee", value = "受理人", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result taskEntrust(String taskId, String assignee){
if(StringUtils.isEmpty(taskId) || StringUtils.isEmpty(assignee)){
public Result taskEntrust(String taskId, String assignee) {
if (StringUtils.isEmpty(taskId) || StringUtils.isEmpty(assignee)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
String depositorId = SecurityUser.getUserId().toString();
@ -177,12 +180,12 @@ public class ActTaskController {
@GetMapping("getTaskVariables")
@ApiOperation("获取流程变量")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "variableName", value = "参数的键", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "variableName", value = "参数的键", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result getTaskVariables(String taskId, String variableName){
if(StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)){
public Result getTaskVariables(String taskId, String variableName) {
if (StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
return new Result().ok(actTaskService.getTaskVariables(taskId, variableName));
@ -194,8 +197,8 @@ public class ActTaskController {
@PostMapping("updateTaskVariable")
@ApiOperation("更新任务变量")
// @RequiresPermissions("sys:task:all")
public Result updateTaskVariable(@RequestBody TaskDTO taskDTO){
if(StringUtils.isEmpty(taskDTO.getTaskId())){
public Result updateTaskVariable(@RequestBody TaskDTO taskDTO) {
if (StringUtils.isEmpty(taskDTO.getTaskId())) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.updateTaskVariable(taskDTO);
@ -207,10 +210,10 @@ public class ActTaskController {
*/
@DeleteMapping("deleteTaskVariables")
@ApiOperation("删除任务的所有变量")
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType = "String")
// @RequiresPermissions("sys:task:all")
public Result deleteTaskVariables(String taskId){
if(StringUtils.isEmpty(taskId)){
public Result deleteTaskVariables(String taskId) {
if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.deleteTaskVariables(taskId);
@ -223,13 +226,13 @@ public class ActTaskController {
@DeleteMapping("deleteVariable")
@ApiOperation("删除指定变量,默认删除本地变量")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "variableName", value = "变量名", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "scope", value = "变量的范围local本地global,全局)", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "variableName", value = "变量名", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "scope", value = "变量的范围local本地global,全局)", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result deleteVariable(String taskId, String variableName, String scope){
if(StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)){
public Result deleteVariable(String taskId, String variableName, String scope) {
if (StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.deleteTaskVariable(taskId, variableName, scope);
@ -242,12 +245,12 @@ public class ActTaskController {
@PostMapping("backPreviousTask")
@ApiOperation("回退任务到上一节点")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "comment", value = "回退审核意见", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "回退审核意见", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result backPreviousTask(String taskId, String comment){
if(StringUtils.isEmpty(taskId)){
public Result backPreviousTask(String taskId, String comment) {
if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.doBackPreviousTask(taskId, comment);
@ -260,11 +263,11 @@ public class ActTaskController {
@PostMapping("endProcess")
@ApiOperation("终止流程")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "comment", value = "终止审核意见", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "终止审核意见", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result endProcess(String taskId, String comment){
public Result endProcess(String taskId, String comment) {
actTaskService.endProcess(taskId, comment);
return new Result();
}
@ -275,12 +278,12 @@ public class ActTaskController {
@PostMapping("backToFirst")
@ApiOperation("驳回,回退至第一个用户任务")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "comment", value = "驳回审核意见", paramType = "query", dataType="String")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "驳回审核意见", paramType = "query", dataType = "String")
})
// @RequiresPermissions("sys:task:all")
public Result backToFirst(String taskId, String comment){
if(StringUtils.isEmpty(taskId)){
public Result backToFirst(String taskId, String comment) {
if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR);
}
actTaskService.backToFirst(taskId, comment);

View File

@ -12,6 +12,8 @@ import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.service.TDemandDataService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
import io.renren.modules.security.user.SecurityUser;
@ -72,6 +74,8 @@ public class ActTaskService extends BaseServiceImpl {
@Autowired
private TDemandDataService tDemandDataService;
@Autowired
private ResourceService resourceService;
/**
* 根据参数获取当前运行的任务信息
@ -115,25 +119,37 @@ public class ActTaskService extends BaseServiceImpl {
for (Task task : list) {
TaskDTO dto = new TaskDTO();
this.convertTaskInfo(task, dto);
ObjectMapper oMapper = new ObjectMapper();
TAbilityApplicationDTO abilityApplicationDTO =
tAbilityApplicationService.get(Long.valueOf(dto.getBusinessKey()));
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(dto.getBusinessKey()));
TDemandDataDTO tDemandDataDTO = tDemandDataService.get(Long.valueOf(dto.getBusinessKey()));
if (abilityApplicationDTO != null) {
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(abilityApplicationDTO, Map.class);
dto.setParams(variables);
} else if (resourceMountApplyDTO != null) {
ObjectMapper oMapper = new ObjectMapper();
listDto.add(dto);
continue;
}
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceMountApplyDTO != null) {
Map<String, Object> variables = oMapper.convertValue(resourceMountApplyDTO, Map.class);
dto.setParams(variables);
} else if (tDemandDataDTO != null) {
ObjectMapper oMapper = new ObjectMapper();
listDto.add(dto);
continue;
}
TDemandDataDTO tDemandDataDTO = tDemandDataService.get(Long.valueOf(dto.getBusinessKey()));
if (tDemandDataDTO != null) {
Map<String, Object> variables = oMapper.convertValue(tDemandDataDTO, Map.class);
dto.setParams(variables);
listDto.add(dto);
continue;
}
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceDTO != null) {
Map<String, Object> variables = oMapper.convertValue(resourceDTO, Map.class);
dto.setParams(variables);
listDto.add(dto);
continue;
}
listDto.add(dto);
}
return new PageData<>(listDto, (int) taskQuery.count());
}

View File

@ -119,7 +119,7 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
JsonElement jsonElement = gson.toJsonTree(kv);
TDemandDataDTO demandDataDTO = gson.fromJson(jsonElement, TDemandDataDTO.class);
if (demandDataDTO != null) {
if (demandDataDTO != null && demandDataDTO.getApplyUserDeptId() != null) {
logger.error(JSONObject.toJSONString(demandDataDTO));
SysDeptDTO deptDTO =
sysDeptService.get(Long.valueOf(demandDataDTO.getApplyUserDeptId()));

View File

@ -65,11 +65,18 @@ public class ResourceController {
return new Result<>().ok(resourceService.pageWithAttrs(jsonObject));
}
@GetMapping("/{id}")
@ApiOperation("信息")
public Result<ResourceDTO> get(@PathVariable("id") Long id) {
ResourceDTO data = resourceService.get(id);
return new Result<ResourceDTO>().ok(data);
}
@GetMapping("/select/{id}")
@ApiOperation("查询资源详细信息")
@LogOperation("查询资源详细信息")
//@RequiresPermissions("resource:resource:info")
public Result<ResourceDTO> get(@PathVariable("id") Long id) {
public Result<ResourceDTO> select(@PathVariable("id") Long id) {
ResourceDTO data = resourceService.selectWithAttrs(id);
return new Result<ResourceDTO>().ok(data);
}

View File

@ -96,6 +96,10 @@ public class ResourceDTO implements Serializable {
@ApiModelProperty(value = "附件")
private String enclosure;
@ApiModelProperty(value = "下架理由")
private String undercarriageReason;
@ApiModelProperty(value = "提起下架人员姓名")
private String undercarriageUserName;
public String getDelFlagTip() {
if (this.delFlag != null) {

View File

@ -19,11 +19,6 @@ import java.util.Date;
public class ResourceEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
// /**
// * 主键
// */
// @TableId(type = IdType.INPUT)
// private Long id;
/**
* 类型基础设施数据资源等
*/
@ -88,16 +83,7 @@ public class ResourceEntity extends BaseEntity {
* 删除标志0:正常1:已删除9其他
*/
private Integer delFlag;
// /**
// * 创建人
// */
// @TableField(fill = FieldFill.INSERT)
// private Long creator;
// /**
// * 创建时间
// */
// @TableField(fill = FieldFill.INSERT)
// private Date createDate;
/**
* 修改人
*/
@ -134,4 +120,15 @@ public class ResourceEntity extends BaseEntity {
* 附件
*/
private String enclosure;
/**
* 下架理由
*/
private String undercarriageReason;
/**
* 提起下架人员
*/
private String undercarriageUserName;
}

View File

@ -8,13 +8,38 @@ import java.util.Arrays;
*/
public enum ResourceEntityDelFlag {
/**
* 正常
*/
NORMAL(0, "正常"),
/**
* 已删除
*/
DELETED(1, "已删除"),
/**
* 上架待审核
*/
PENDING_REVIEW(2, "上架待审核"),
/**
* 上架审核中
*/
UNDER_REVIEW(3, "上架审核中"),
/**
* 下架审核中
*/
UNDERCARRIAGE_REVIEW(4, "下架审核中"),
/**
* 已下架
*/
UNDERCARRIAGE(5, "已下架"),
OTHER(9, "其他");
/**
* 其他
*/
OTHER(9, "其他"),
/**
* 未知
*/
UNKNOWN(10, "未知");
private int flag;
private String tip;
@ -26,7 +51,7 @@ public enum ResourceEntityDelFlag {
public static ResourceEntityDelFlag getByFlag(int flag) {
ResourceEntityDelFlag[] index = ResourceEntityDelFlag.values();
return Arrays.asList(index).stream().filter(index_ -> index_.flag == flag).findAny().orElse(null);
return Arrays.asList(index).stream().filter(index_ -> index_.flag == flag).findAny().orElse(ResourceEntityDelFlag.UNKNOWN);
}

View File

@ -0,0 +1,146 @@
package io.renren.modules.resource.listener;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
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.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* 资源下线审核
*/
@Component
public class ResourceUndercarriageListener implements TaskListener, ExecutionListener {
private static Logger logger = LoggerFactory.getLogger(ResourceUndercarriageListener.class);
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@Autowired
private SysRoleService sysRoleService;
@Autowired
private TaskService taskService;
@Autowired
private SysUserService sysUserService;
@Autowired
private SysDeptService sysDeptService;
@Autowired
private ResourceService resourceService;
@Override
public void notify(DelegateTask delegateTask) {
logger.error("----------------------进入资源所有者节点---------------------------");
logger.error("事件类型:" + delegateTask.getEventName());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
final String eventName = delegateTask.getEventName();
switch (eventName) {
case EVENTNAME_CREATE: // 创建当前审批节点事件
create(delegateTask, roleDTO);
break;
default:
logger.error("未处理该事件:" + eventName);
}
logger.error("-----------------------结束资源所有者节点---------------------------");
}
@Override
public void notify(DelegateExecution execution) throws Exception {
logger.error("----------------------进入审批通过节点---------------------------");
logger.error("事件类型:" + execution.getEventName());
final String eventName = execution.getEventName();
switch (eventName) {
case EVENTNAME_END: {
endTake(execution.getVariables());
}
break;
}
}
private void endTake(Map<String, Object> kv) { // 进入最后结束节点
Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv);
ResourceDTO re = gson.fromJson(jsonElement, ResourceDTO.class);
if (re != null) {
re.setDelFlag(ResourceEntityDelFlag.UNDERCARRIAGE.getFlag());
resourceService.update(re);
logger.error("审批通过资源id:" + re.getId());
}
}
/**
* 节点创建时动态分配资源部门审核人
*
* @param delegateTask
* @param roleDTO
*/
private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) {
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv);
ResourceDTO re = gson.fromJson(jsonElement, ResourceDTO.class);
if (re.getDeptId() != null) {
SysDeptDTO deptDTO =
sysDeptService.get(re.getDeptId());
SysUserDTO userDTO = null;
if (deptDTO.getId() != null) {
userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); // 搜出审批人
}
if (userDTO != null) {
logger.error("审批人id:" + userDTO.getId() + "姓名:" + userDTO.getRealName());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
} else {
logger.error("未查到该部门对应的 " + roleName + " 将使用大数据部门审核人");
defaultUser(delegateTask.getId(), roleDTO);
}
} else {
defaultUser(delegateTask.getId(), roleDTO);
}
}
/**
* 未找到部门对应的审核人
*
* @param taskId
*/
private void defaultUser(String taskId, final SysRoleDTO roleDTO) {
logger.error("大数据局名称:" + bigDateDeptName);
SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName);
logger.error("roleDTOId:" + roleDTO.getId());
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
if (userDTO != null) {
logger.error("大数据审批人id:" + userDTO.getId() + "姓名:" + userDTO.getRealName());
taskService.setAssignee(taskId, userDTO.getId().toString());
} else {
logger.error("未查到大数据部门对应 " + roleName);
taskService.setAssignee(taskId, "1516728698224427010");
}
}
}

View File

@ -0,0 +1,27 @@
package io.renren.modules.resourceMountApply.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@Data
@ApiModel(value = "资源下架申请表单")
public class TResourceUndercarriageApplyDTO implements Serializable {
@ApiModelProperty(value = "下架申请人id")
private String userId;
@ApiModelProperty(value = "下架申请人名字")
private String userName;
@ApiModelProperty(value = "下架申请人电话")
private String phone;
@ApiModelProperty(value = "下架申请人部门")
private String deptId;
@ApiModelProperty(value = "待下架的资源 id、资源名称 键值对")
private List<Map<String, String>> resource;
@ApiModelProperty(value = "下架原因")
private String reason;
}

View File

@ -80,9 +80,6 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
case EVENTNAME_CREATE: // 创建当前审批节点事件
create(delegateTask, roleDTO);
break;
// case EVENTNAME_COMPLETE:
// complete(delegateTask);
// break;
default:
logger.error("未处理该事件:" + eventName);
}