Merge remote-tracking branch 'origin/master'

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java
#	renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java
This commit is contained in:
huangweixiong 2022-05-11 16:27:32 +08:00
commit 56cc7cfbf4
28 changed files with 790 additions and 287 deletions

View File

@ -0,0 +1,87 @@
package io.renren.common.controller;
import io.renren.common.utils.Result;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* 统计
*/
@Api(tags = "全局统计中心")
@RestController
@RequestMapping("/census/center")
public class CensusController {
private static Logger logger = LoggerFactory.getLogger(CensusController.class);
@Autowired
private ResourceService resourceService;
@Autowired
private SysUserService sysUserService;
@Value("${census.type}")
private String[] censusTypes; // 大数据局名称
/**
* 获取各类资源数目
*
* @return
*/
@GetMapping(value = "/resource_amount")
@ApiOperation("各类资源数目")
public Result<List<Map<String, Object>>> resourceAmount() {
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
List<String> temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList());
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
Map<String, Object> nullMap = new HashMap<String, Object>() {
{
put("amount", 0);
put("type", index);
}
};
dbAmount.add(nullMap);
});
Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum();
Map<String, Object> sumMap = new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "资源汇聚总量");
}
};
dbAmount.add(sumMap);
return new Result<List<Map<String, Object>>>().ok(dbAmount);
}
@GetMapping(value = "/whole_amount")
@ApiOperation("平台整体情况")
public Result<List<Map<String, Object>>> wholeAmount() {
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
CompletableFuture<Long> resourceAmount = CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum();
return sum;
});
CompletableFuture<Long> userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数
return sysUserService.countAllUser();
});
CompletableFuture<Void> all = CompletableFuture.allOf(resourceAmount, userAmount);
all.join();
return new Result<List<Map<String, Object>>>().ok(result);
}
}

View File

@ -31,7 +31,7 @@ import java.util.Map;
@RestController @RestController
@RequestMapping("/demand_v2/center") @RequestMapping("/demand_v2/center")
public class DemandDataController { public class DemandDataController {
private static Logger logger = LoggerFactory.getLogger(ResourceMountController.class); private static Logger logger = LoggerFactory.getLogger(DemandDataController.class);
@Autowired @Autowired
private ActProcessService actProcessService; 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.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.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.SysUserDTO;
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.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
@ -30,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Api(tags = "资源上架") @Api(tags = "资源上架")
@ -44,12 +52,26 @@ public class ResourceMountController {
private ActRunningService actRunningService; private ActRunningService actRunningService;
@Autowired @Autowired
private TResourceMountApplyService tResourceMountApplyService; 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("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("批量进行能力上架申请") @ApiOperation("批量进行能力上架申请")
public Result<List<ProcessInstanceDTO>> apply(@RequestBody TResourceBatchMountApplyDTO tResourceBatchMountApplyDTO) { public Result<List<ProcessInstanceDTO>> apply(@RequestBody TResourceBatchMountApplyDTO tResourceBatchMountApplyDTO) {
// 仿照请求接口 /act/process/lastestPage // 仿照请求接口 /act/process/lastestPage
PageData<Map<String, Object>> page = actProcessService.page(params); PageData<Map<String, Object>> page = actProcessService.page(apply_params);
if (page.getTotal() <= 0) { // if (page.getTotal() <= 0) { //
return new Result().error("联系管理员添加流程"); return new Result().error("联系管理员添加流程");
} }
@ -85,7 +107,7 @@ public class ResourceMountController {
// 仿照请求接口 /act/running/startOfBusinessKey // 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO(); ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(tResourceMountApplyDTO.getId().toString()); processStartDTO.setBusinessKey(tResourceMountApplyDTO.getId().toString());
processStartDTO.setProcessDefinitionKey(key); // 限定资源上架 processStartDTO.setProcessDefinitionKey(apply_key); // 限定资源上架
ObjectMapper oMapper = new ObjectMapper(); ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(tResourceMountApplyDTO, Map.class); Map<String, Object> variables = oMapper.convertValue(tResourceMountApplyDTO, Map.class);
processStartDTO.setVariables(variables); processStartDTO.setVariables(variables);
@ -103,4 +125,48 @@ public class ResourceMountController {
return dto; return dto;
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList())); }).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.error(resourceDTO.get().toString());
});
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.get(), 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.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -24,11 +23,12 @@ import java.util.Map;
/** /**
* 任务管理 * 任务管理
*
* @author Jone * @author Jone
*/ */
@RestController @RestController
@RequestMapping("/act/task") @RequestMapping("/act/task")
@Api(tags="任务管理") @Api(tags = "任务管理")
public class ActTaskController { public class ActTaskController {
@Autowired @Autowired
private ActTaskService actTaskService; private ActTaskService actTaskService;
@ -38,40 +38,42 @@ public class ActTaskController {
/** /**
* 获取用户任务列表 * 获取用户任务列表
* 根据用户ID或角色组获取任务信息 * 根据用户ID或角色组获取任务信息
*
* @return * @return
*/ */
@GetMapping("page") @GetMapping("page")
@ApiOperation("待办任务默认查询所有待办任务。根据用户ID或角色ID查询个人或组的任务") @ApiOperation("待办任务默认查询所有待办任务。根据用户ID或角色ID查询个人或组的任务")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") , @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 = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "roleIds", value = "roleIds", paramType = "query", dataType="String"), @ApiImplicitParam(name = "roleIds", value = "roleIds", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "userId", paramType = "query", dataType="String"), @ApiImplicitParam(name = "userId", value = "userId", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "isRoleGroup", value = "是否查询分组", paramType = "query", dataType="String") @ApiImplicitParam(name = "isRoleGroup", value = "是否查询分组", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @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); PageData<TaskDTO> page = actTaskService.page(params);
return new Result<PageData<TaskDTO>>().ok(page); return new Result<PageData<TaskDTO>>().ok(page);
} }
/** /**
* 我的待办列表 * 我的待办列表
*
* @return * @return
*/ */
@GetMapping("myToDoTaskPage") @GetMapping("myToDoTaskPage")
@ApiOperation("我的待办列表") @ApiOperation("我的待办列表")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") , @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 = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "taskName", value = "任务名称", paramType = "query", dataType="String") @ApiImplicitParam(name = "taskName", value = "任务名称", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @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()); params.put("userId", SecurityUser.getUserId().toString());
PageData<TaskDTO> page = actTaskService.page(params); PageData<TaskDTO> page = actTaskService.page(params);
for(TaskDTO taskDTO : page.getList()){ for (TaskDTO taskDTO : page.getList()) {
if(!StringUtils.isEmpty(taskDTO.getAssignee())){ if (!StringUtils.isEmpty(taskDTO.getAssignee())) {
SysUserDTO userDTO = sysUserService.get(Long.valueOf(taskDTO.getAssignee())); SysUserDTO userDTO = sysUserService.get(Long.valueOf(taskDTO.getAssignee()));
taskDTO.setAssigneeName(userDTO.getRealName()); taskDTO.setAssigneeName(userDTO.getRealName());
} }
@ -86,7 +88,7 @@ public class ActTaskController {
@ApiOperation("获取任务详情") @ApiOperation("获取任务详情")
@LogOperation("获取任务详情") @LogOperation("获取任务详情")
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result getTaskById(@PathVariable("id") String id){ public Result getTaskById(@PathVariable("id") String id) {
TaskDTO task = actTaskService.taskDetail(id); TaskDTO task = actTaskService.taskDetail(id);
return new Result().ok(task); return new Result().ok(task);
} }
@ -96,10 +98,10 @@ public class ActTaskController {
*/ */
@PostMapping("claim") @PostMapping("claim")
@ApiOperation("认领任务") @ApiOperation("认领任务")
@ApiImplicitParam(name = "taskId", value = "taskId", paramType = "query", dataType="String") @ApiImplicitParam(name = "taskId", value = "taskId", paramType = "query", dataType = "String")
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result claimTask(String taskId){ public Result claimTask(String taskId) {
if(StringUtils.isEmpty(taskId)){ if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.claimTask(taskId); actTaskService.claimTask(taskId);
@ -111,10 +113,10 @@ public class ActTaskController {
*/ */
@PostMapping("unclaim") @PostMapping("unclaim")
@ApiOperation("释放任务") @ApiOperation("释放任务")
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String") @ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String")
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result unclaimTask(String taskId){ public Result unclaimTask(String taskId) {
if(StringUtils.isEmpty(taskId)){ if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.unclaimTask(taskId); actTaskService.unclaimTask(taskId);
@ -127,25 +129,26 @@ public class ActTaskController {
@PostMapping("complete") @PostMapping("complete")
@ApiOperation("任务处理(完成任务)") @ApiOperation("任务处理(完成任务)")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"), @ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "审批意见", paramType = "query", dataType="String") @ApiImplicitParam(name = "comment", value = "审批意见", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result completeTask(String taskId, String comment){ public Result completeTask(String taskId, String comment) {
if(StringUtils.isEmpty(taskId)){ if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.completeTask(taskId, comment); actTaskService.completeTask(taskId, comment);
return new Result(); return new Result();
} }
/** /**
* 带参数的任务处理 * 带参数的任务处理
*/ */
@PostMapping("completeByVariables") @PostMapping("completeByVariables")
@ApiOperation("带参数的任务处理(完成任务)") @ApiOperation("带参数的任务处理(完成任务)")
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result completeTaskByVariables(@RequestBody TaskDTO taskDTO){ public Result completeTaskByVariables(@RequestBody TaskDTO taskDTO) {
if(StringUtils.isEmpty(taskDTO.getTaskId())){ if (StringUtils.isEmpty(taskDTO.getTaskId())) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.completeTaskByVariables(taskDTO); actTaskService.completeTaskByVariables(taskDTO);
@ -158,12 +161,12 @@ public class ActTaskController {
@PostMapping("entrust") @PostMapping("entrust")
@ApiOperation("任务委托") @ApiOperation("任务委托")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"), @ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "assignee", value = "受理人", paramType = "query", dataType="String") @ApiImplicitParam(name = "assignee", value = "受理人", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result taskEntrust(String taskId, String assignee){ public Result taskEntrust(String taskId, String assignee) {
if(StringUtils.isEmpty(taskId) || StringUtils.isEmpty(assignee)){ if (StringUtils.isEmpty(taskId) || StringUtils.isEmpty(assignee)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
String depositorId = SecurityUser.getUserId().toString(); String depositorId = SecurityUser.getUserId().toString();
@ -177,12 +180,12 @@ public class ActTaskController {
@GetMapping("getTaskVariables") @GetMapping("getTaskVariables")
@ApiOperation("获取流程变量") @ApiOperation("获取流程变量")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType="String"), @ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "variableName", value = "参数的键", paramType = "query", dataType="String") @ApiImplicitParam(name = "variableName", value = "参数的键", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result getTaskVariables(String taskId, String variableName){ public Result getTaskVariables(String taskId, String variableName) {
if(StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)){ if (StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
return new Result().ok(actTaskService.getTaskVariables(taskId, variableName)); return new Result().ok(actTaskService.getTaskVariables(taskId, variableName));
@ -194,8 +197,8 @@ public class ActTaskController {
@PostMapping("updateTaskVariable") @PostMapping("updateTaskVariable")
@ApiOperation("更新任务变量") @ApiOperation("更新任务变量")
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result updateTaskVariable(@RequestBody TaskDTO taskDTO){ public Result updateTaskVariable(@RequestBody TaskDTO taskDTO) {
if(StringUtils.isEmpty(taskDTO.getTaskId())){ if (StringUtils.isEmpty(taskDTO.getTaskId())) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.updateTaskVariable(taskDTO); actTaskService.updateTaskVariable(taskDTO);
@ -207,10 +210,10 @@ public class ActTaskController {
*/ */
@DeleteMapping("deleteTaskVariables") @DeleteMapping("deleteTaskVariables")
@ApiOperation("删除任务的所有变量") @ApiOperation("删除任务的所有变量")
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType="String") @ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType = "String")
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result deleteTaskVariables(String taskId){ public Result deleteTaskVariables(String taskId) {
if(StringUtils.isEmpty(taskId)){ if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.deleteTaskVariables(taskId); actTaskService.deleteTaskVariables(taskId);
@ -223,13 +226,13 @@ public class ActTaskController {
@DeleteMapping("deleteVariable") @DeleteMapping("deleteVariable")
@ApiOperation("删除指定变量,默认删除本地变量") @ApiOperation("删除指定变量,默认删除本地变量")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType="String"), @ApiImplicitParam(name = "taskId", value = "当前任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "variableName", value = "变量名", paramType = "query", dataType="String"), @ApiImplicitParam(name = "variableName", value = "变量名", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "scope", value = "变量的范围local本地global,全局)", paramType = "query", dataType="String") @ApiImplicitParam(name = "scope", value = "变量的范围local本地global,全局)", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result deleteVariable(String taskId, String variableName, String scope){ public Result deleteVariable(String taskId, String variableName, String scope) {
if(StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)){ if (StringUtils.isEmpty(taskId) || StringUtils.isEmpty(variableName)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.deleteTaskVariable(taskId, variableName, scope); actTaskService.deleteTaskVariable(taskId, variableName, scope);
@ -242,12 +245,12 @@ public class ActTaskController {
@PostMapping("backPreviousTask") @PostMapping("backPreviousTask")
@ApiOperation("回退任务到上一节点") @ApiOperation("回退任务到上一节点")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"), @ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "回退审核意见", paramType = "query", dataType="String") @ApiImplicitParam(name = "comment", value = "回退审核意见", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result backPreviousTask(String taskId, String comment){ public Result backPreviousTask(String taskId, String comment) {
if(StringUtils.isEmpty(taskId)){ if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.doBackPreviousTask(taskId, comment); actTaskService.doBackPreviousTask(taskId, comment);
@ -260,11 +263,11 @@ public class ActTaskController {
@PostMapping("endProcess") @PostMapping("endProcess")
@ApiOperation("终止流程") @ApiOperation("终止流程")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"), @ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "终止审核意见", paramType = "query", dataType="String") @ApiImplicitParam(name = "comment", value = "终止审核意见", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result endProcess(String taskId, String comment){ public Result endProcess(String taskId, String comment) {
actTaskService.endProcess(taskId, comment); actTaskService.endProcess(taskId, comment);
return new Result(); return new Result();
} }
@ -275,12 +278,12 @@ public class ActTaskController {
@PostMapping("backToFirst") @PostMapping("backToFirst")
@ApiOperation("驳回,回退至第一个用户任务") @ApiOperation("驳回,回退至第一个用户任务")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType="String"), @ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "驳回审核意见", paramType = "query", dataType="String") @ApiImplicitParam(name = "comment", value = "驳回审核意见", paramType = "query", dataType = "String")
}) })
// @RequiresPermissions("sys:task:all") // @RequiresPermissions("sys:task:all")
public Result backToFirst(String taskId, String comment){ public Result backToFirst(String taskId, String comment) {
if(StringUtils.isEmpty(taskId)){ if (StringUtils.isEmpty(taskId)) {
return new Result().error(ErrorCode.PARAMS_GET_ERROR); return new Result().error(ErrorCode.PARAMS_GET_ERROR);
} }
actTaskService.backToFirst(taskId, comment); actTaskService.backToFirst(taskId, comment);

View File

@ -6,6 +6,8 @@ import io.renren.modules.activiti.dto.ProcessInstanceDTO;
import io.renren.modules.activiti.dto.TaskDTO; import io.renren.modules.activiti.dto.TaskDTO;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService; 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.dto.TResourceMountApplyDTO;
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.security.user.SecurityUser;
@ -72,6 +74,8 @@ public class ActHistoryService {
@Autowired @Autowired
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired
private ResourceService resourceService;
@Autowired @Autowired
private TAbilityApplicationService tAbilityApplicationService; private TAbilityApplicationService tAbilityApplicationService;
@ -267,6 +271,12 @@ public class ActHistoryService {
if (resourceMountApplyDTO != null) { if (resourceMountApplyDTO != null) {
dto.setName(resourceMountApplyDTO.getResourceDTO().getName()); dto.setName(resourceMountApplyDTO.getResourceDTO().getName());
dto.setResourceId(resourceMountApplyDTO.getResourceDTO().getId().toString()); dto.setResourceId(resourceMountApplyDTO.getResourceDTO().getId().toString());
} else {
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceDTO != null) {
dto.setName(resourceDTO.getName());
dto.setResourceId(resourceDTO.getId().toString());
}
} }
} }
} }

View File

@ -12,6 +12,8 @@ import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.service.TDemandDataService; import io.renren.modules.demanData.service.TDemandDataService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService; 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.dto.TResourceMountApplyDTO;
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.security.user.SecurityUser;
@ -79,6 +81,8 @@ public class ActTaskService extends BaseServiceImpl {
@Autowired @Autowired
private TDemandDataService tDemandDataService; private TDemandDataService tDemandDataService;
@Autowired
private ResourceService resourceService;
/** /**
* 根据参数获取当前运行的任务信息 * 根据参数获取当前运行的任务信息
@ -122,25 +126,37 @@ public class ActTaskService extends BaseServiceImpl {
for (Task task : list) { for (Task task : list) {
TaskDTO dto = new TaskDTO(); TaskDTO dto = new TaskDTO();
this.convertTaskInfo(task, dto); this.convertTaskInfo(task, dto);
ObjectMapper oMapper = new ObjectMapper();
TAbilityApplicationDTO abilityApplicationDTO = TAbilityApplicationDTO abilityApplicationDTO =
tAbilityApplicationService.get(Long.valueOf(dto.getBusinessKey())); 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) { if (abilityApplicationDTO != null) {
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(abilityApplicationDTO, Map.class); Map<String, Object> variables = oMapper.convertValue(abilityApplicationDTO, Map.class);
dto.setParams(variables); dto.setParams(variables);
} else if (resourceMountApplyDTO != null) { listDto.add(dto);
ObjectMapper oMapper = new ObjectMapper(); continue;
}
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceMountApplyDTO != null) {
Map<String, Object> variables = oMapper.convertValue(resourceMountApplyDTO, Map.class); Map<String, Object> variables = oMapper.convertValue(resourceMountApplyDTO, Map.class);
dto.setParams(variables); dto.setParams(variables);
} else if (tDemandDataDTO != null) { listDto.add(dto);
ObjectMapper oMapper = new ObjectMapper(); continue;
}
TDemandDataDTO tDemandDataDTO = tDemandDataService.get(Long.valueOf(dto.getBusinessKey()));
if (tDemandDataDTO != null) {
Map<String, Object> variables = oMapper.convertValue(tDemandDataDTO, Map.class); Map<String, Object> variables = oMapper.convertValue(tDemandDataDTO, Map.class);
dto.setParams(variables); 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()); 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); JsonElement jsonElement = gson.toJsonTree(kv);
TDemandDataDTO demandDataDTO = gson.fromJson(jsonElement, TDemandDataDTO.class); TDemandDataDTO demandDataDTO = gson.fromJson(jsonElement, TDemandDataDTO.class);
if (demandDataDTO != null) { if (demandDataDTO != null && demandDataDTO.getApplyUserDeptId() != null) {
logger.error(JSONObject.toJSONString(demandDataDTO)); logger.error(JSONObject.toJSONString(demandDataDTO));
SysDeptDTO deptDTO = SysDeptDTO deptDTO =
sysDeptService.get(Long.valueOf(demandDataDTO.getApplyUserDeptId())); sysDeptService.get(Long.valueOf(demandDataDTO.getApplyUserDeptId()));

View File

@ -2,12 +2,9 @@ package io.renren.modules.processForm.listener;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import io.renren.modules.activiti.service.ActTaskService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.ApiGatewayService;
import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntity;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO; import io.renren.modules.sys.dto.SysRoleDTO;
@ -52,17 +49,12 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
@Autowired @Autowired
private HistoryService historyService;
@Autowired
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired @Autowired
private SysRoleUserService sysRoleUserService; private SysRoleUserService sysRoleUserService;
@Autowired @Autowired
private SysDeptService sysDeptService; private SysDeptService sysDeptService;
@Autowired
private ApiGatewayService apiGatewayService;
@Autowired @Autowired
private ResourceService resourceService; private ResourceService resourceService;
@Autowired @Autowired
@ -76,9 +68,6 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
case EVENTNAME_CREATE: case EVENTNAME_CREATE:
create(delegateTask); create(delegateTask);
break; break;
case EVENTNAME_COMPLETE:
complete(delegateTask);
break;
default: default:
} }
logger.error("-------------------------结束部门动态审批人流程-------------------------------"); logger.error("-------------------------结束部门动态审批人流程-------------------------------");
@ -91,7 +80,7 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
final String eventName = delegateExecution.getEventName(); final String eventName = delegateExecution.getEventName();
switch (eventName) { switch (eventName) {
case EVENTNAME_END: case EVENTNAME_END:
endTake(delegateExecution); endTake(delegateExecution.getVariables());
break; break;
} }
} }
@ -116,10 +105,9 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
/** /**
* 结束审批 * 结束审批
* *
* @param delegateExecution * @param kv
*/ */
private void endTake(DelegateExecution delegateExecution) { // 进入最后结束节点 private void endTake(Map<String, Object> kv) { // 进入最后结束节点
Map<String, Object> kv = delegateExecution.getVariables();
Gson gson = new Gson(); Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv); JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class); TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
@ -180,44 +168,4 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
taskService.setAssignee(delegateTask.getId(), "1516728698224427010"); taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
} }
} }
private void complete(DelegateTask delegateTask) {
Map<String, Object> kv = delegateTask.getVariables();
//如果有code说明已经注册过了,以及只有通过的流程申请
if (kv.get("gatewayCode") != null ||
!ActTaskService.Task_HANDLE_STATE_AGREE.equals(kv.get(ActTaskService.Task_HANDLE_STATE))) return;
Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
applyCode(delegateTask, abilityApplicationDTO);
}
/**
* 审批通过申请code
* @param delegateTask
* @param abilityApplicationDTO
*/
private void applyCode(DelegateTask delegateTask, TAbilityApplicationDTO abilityApplicationDTO) {
logger.info("-------能力申请code-------");
ResourceEntity resourceEntity = resourceService.selectById(abilityApplicationDTO.getResourceId());
//没有groupid当做没有接口直接跳过
if (resourceEntity.getGroupId() == null)
return;
String code = UUID.randomUUID().toString();
apiGatewayService.subscribeCode(String.valueOf(abilityApplicationDTO.getId()), code);
delegateTask.setVariable("gatewayCode", code);
String apiPrefix = "/juapi/" + abilityApplicationDTO.getResourceId();
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
String msg = String.format("您的能力申请已通过接口认证code为%s, 接口公共前缀为:%s",code, apiPrefix);
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), msg);
}
} }

View File

@ -1,5 +1,10 @@
package io.renren.modules.processForm.listener; package io.renren.modules.processForm.listener;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO; import io.renren.modules.sys.dto.SysRoleDTO;
import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.dto.SysUserDTO;
@ -17,6 +22,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Optional;
/** /**
* 大数据局动态审批人 * 大数据局动态审批人
*/ */
@ -39,6 +47,8 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
private SysRoleUserService sysRoleUserService; private SysRoleUserService sysRoleUserService;
@Autowired @Autowired
private SysDeptService sysDeptService; private SysDeptService sysDeptService;
@Autowired
private ResourceService resourceService;
@Override @Override
public void notify(DelegateExecution delegateExecution) throws Exception { public void notify(DelegateExecution delegateExecution) throws Exception {
@ -96,5 +106,18 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
delegateTask.setAssignee("1516728698224427010"); delegateTask.setAssignee("1516728698224427010");
logger.info("未查到该部门对应 " + roleName); logger.info("未查到该部门对应 " + roleName);
} }
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
Optional<ResourceDTO> resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId())));
resourceDTOOptional.ifPresent(resource -> {
if ("免批申请".equals(resource.getShareCondition())) { // 针对免批资源申请
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
}
});
} }
} }

View File

@ -50,7 +50,9 @@ public class ResourceController {
@ApiImplicitParam(name = "creator", value = "创建者用户id", paramType = "query", dataType = "String") @ApiImplicitParam(name = "creator", value = "创建者用户id", paramType = "query", dataType = "String")
}) })
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) { public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
params.put("del_flag", 0); if (!params.containsKey("del_flag")) {
params.put("del_flag", 0);
}
PageData<ResourceDTO> page = resourceService.page(params); PageData<ResourceDTO> page = resourceService.page(params);
page.getList().forEach(item -> { page.getList().forEach(item -> {
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId())); item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
@ -65,11 +67,18 @@ public class ResourceController {
return new Result<>().ok(resourceService.pageWithAttrs(jsonObject)); 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}") @GetMapping("/select/{id}")
@ApiOperation("查询资源详细信息") @ApiOperation("查询资源详细信息")
@LogOperation("查询资源详细信息") @LogOperation("查询资源详细信息")
//@RequiresPermissions("resource:resource:info") //@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); ResourceDTO data = resourceService.selectWithAttrs(id);
return new Result<ResourceDTO>().ok(data); return new Result<ResourceDTO>().ok(data);
} }

View File

@ -3,6 +3,7 @@ package io.renren.modules.resource.dao;
import io.renren.common.dao.BaseDao; import io.renren.common.dao.BaseDao;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.entity.ResourceEntity;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -10,11 +11,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 资源表 * 资源表
* *
* @author dg * @author dg
* @since 1.0 2022-04-13 * @since 1.0 2022-04-13
*/ */
@Mapper @Mapper
public interface ResourceDao extends BaseDao<ResourceEntity> { public interface ResourceDao extends BaseDao<ResourceEntity> {
@ -28,13 +29,21 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap); List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);
ResourceDTO selectDTOById(@Param("id") Long id,@Param("userId") Long userId); ResourceDTO selectDTOById(@Param("id") Long id, @Param("userId") Long userId);
List<ResourceDTO> selectDTOPage(@Param("dto")ResourceDTO resourceDTO, List<ResourceDTO> selectDTOPage(@Param("dto") ResourceDTO resourceDTO,
@Param("pageNum") Integer pageNum, @Param("pageNum") Integer pageNum,
@Param("pageSize") Integer pageSize, @Param("pageSize") Integer pageSize,
@Param("orderField")String orderField, @Param("orderField") String orderField,
@Param("orderType") String orderType); @Param("orderType") String orderType);
List<Map> selectApplyArea(Long userId); List<Map> selectApplyArea(Long userId);
/**
* 获取各类资源数目
*
* @return
*/
@MapKey("type")
List<Map<String, Object>> getAmountGroupByType();
} }

View File

@ -1,6 +1,7 @@
package io.renren.modules.resource.dto; package io.renren.modules.resource.dto;
import io.renren.modules.resource.entity.AttrEntity; import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -8,13 +9,14 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* 资源表 * 资源表
* *
* @author dg * @author dg
* @since 1.0 2022-04-13 * @since 1.0 2022-04-13
*/ */
@Data @Data
@ApiModel(value = "资源表") @ApiModel(value = "资源表")
public class ResourceDTO implements Serializable { public class ResourceDTO implements Serializable {
@ -54,6 +56,8 @@ public class ResourceDTO implements Serializable {
private Long visits; private Long visits;
@ApiModelProperty(value = "删除标志0:正常1:已删除2:待审核3:审核中9其他") @ApiModelProperty(value = "删除标志0:正常1:已删除2:待审核3:审核中9其他")
private Integer delFlag; private Integer delFlag;
@ApiModelProperty(value = "删除标志tip0:正常1:已删除2:待审核3:审核中9其他")
private String delFlagTip;
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private Long creator; private Long creator;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@ -92,5 +96,23 @@ public class ResourceDTO implements Serializable {
@ApiModelProperty(value = "附件") @ApiModelProperty(value = "附件")
private String enclosure; private String enclosure;
@ApiModelProperty(value = "下架理由")
private String undercarriageReason;
@ApiModelProperty(value = "提起下架人员姓名")
private String undercarriageUserName;
public String getDelFlagTip() {
if (this.delFlag != null) {
Optional<ResourceEntityDelFlag> resourceEntityDelFlagOptional = Optional.ofNullable(ResourceEntityDelFlag.getByFlag(this.delFlag));
if (resourceEntityDelFlagOptional.isPresent()) {
return resourceEntityDelFlagOptional.get().getTip();
}
return "";
}
return "";
}
public void setDelFlagTip(String delFlagTip) {
this.delFlagTip = delFlagTip;
}
} }

View File

@ -19,11 +19,6 @@ import java.util.Date;
public class ResourceEntity extends BaseEntity { public class ResourceEntity extends BaseEntity {
private static final long serialVersionUID = 1L; 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其他 * 删除标志0:正常1:已删除9其他
*/ */
private Integer delFlag; 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 enclosure;
/**
* 下架理由
*/
private String undercarriageReason;
/**
* 提起下架人员
*/
private String undercarriageUserName;
} }

View File

@ -0,0 +1,73 @@
package io.renren.modules.resource.entity;
import java.util.Arrays;
/**
* ResourceEntity del_flag 枚举
*/
public enum ResourceEntityDelFlag {
/**
* 正常
*/
NORMAL(0, "正常"),
/**
* 已删除
*/
DELETED(1, "已删除"),
/**
* 上架待审核
*/
PENDING_REVIEW(2, "上架待审核"),
/**
* 上架审核中
*/
UNDER_REVIEW(3, "上架审核中"),
/**
* 下架审核中
*/
UNDERCARRIAGE_REVIEW(4, "下架审核中"),
/**
* 已下架
*/
UNDERCARRIAGE(5, "已下架"),
/**
* 其他
*/
OTHER(9, "其他"),
/**
* 未知
*/
UNKNOWN(10, "未知");
private int flag;
private String tip;
ResourceEntityDelFlag(int flag, String tip) {
this.flag = flag;
this.tip = tip;
}
public static ResourceEntityDelFlag getByFlag(int flag) {
ResourceEntityDelFlag[] index = ResourceEntityDelFlag.values();
return Arrays.asList(index).stream().filter(index_ -> index_.flag == flag).findAny().orElse(ResourceEntityDelFlag.UNKNOWN);
}
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
}

View File

@ -0,0 +1,152 @@
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;
}
logger.error("----------------------结束审批通过节点---------------------------");
}
/**
* 下架审核通过
*
* @param kv
*/
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) {
logger.error(kv.toString());
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

@ -7,6 +7,7 @@ import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.entity.ResourceEntity;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 资源表 * 资源表
@ -38,4 +39,5 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectRecommend(); Object selectRecommend();
List<Map<String, Object>> getAmountGroupByType();
} }

View File

@ -15,6 +15,7 @@ import io.renren.modules.resource.dao.ResourceDao;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity; import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.entity.ResourceEntity;
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.resourceCar.dao.ResourceCarDao; import io.renren.modules.resourceCar.dao.ResourceCarDao;
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao; import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
@ -72,13 +73,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
}); });
// wrapper.eq("type", params.get("type").toString())
// .like(StringUtils.isNotBlank(params.get("name").toString()),"name", params.get("name").toString())
// .orderByDesc("create_date")
// .eq(StringUtils.isNotBlank(params.get("creator").toString()),"creator", params.get("creator").toString())
// .eq("del_flag", 0);
wrapper.orderByDesc("create_date"); wrapper.orderByDesc("create_date");
if (!params.containsKey("creator")) { if (!params.containsKey("creator")) { // 创建者查询时
wrapper.eq("del_flag", params.get("del_flag") == null ? 0 : Integer.valueOf(params.get("del_flag").toString())); wrapper.eq("del_flag", params.get("del_flag") == null ? 0 : Integer.valueOf(params.get("del_flag").toString()));
} }
return wrapper; return wrapper;
@ -92,7 +88,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Long resourceID = IdWorker.getId(resourceEntity); Long resourceID = IdWorker.getId(resourceEntity);
resourceEntity.setId(resourceID); resourceEntity.setId(resourceID);
if (dto.getDelFlag() == null) { if (dto.getDelFlag() == null) {
resourceEntity.setDelFlag(0); resourceEntity.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
} }
resourceDao.insert(resourceEntity); resourceDao.insert(resourceEntity);
@ -100,7 +96,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<AttrEntity> attrEntities = dto.getInfoList(); List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> { attrEntities.forEach(item -> {
item.setDelFlag(0); item.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
item.setDataResourceId(resourceID); item.setDataResourceId(resourceID);
attrDao.insert(item); attrDao.insert(item);
}); });
@ -130,7 +126,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
attrDao.delete4Resource(list); attrDao.delete4Resource(list);
List<AttrEntity> attrEntities = dto.getInfoList(); List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> { attrEntities.forEach(item -> {
item.setDelFlag(0); item.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
attrDao.insert(item); attrDao.insert(item);
}); });
} }
@ -144,7 +140,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>(); QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
wrapper.eq("data_resource_id", id) wrapper.eq("data_resource_id", id)
.eq("del_flag", 0); .eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag());
List<AttrEntity> attrEntities = attrDao.selectList(wrapper); List<AttrEntity> attrEntities = attrDao.selectList(wrapper);
resourceDTO.setInfoList(attrEntities == null ? new ArrayList<>() : attrEntities); // npe? resourceDTO.setInfoList(attrEntities == null ? new ArrayList<>() : attrEntities); // npe?
return resourceDTO; return resourceDTO;
@ -189,7 +185,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public List<AttrEntity> selectAttrsByResourceId(Long resourceId) { public List<AttrEntity> selectAttrsByResourceId(Long resourceId) {
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>(); QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
wrapper.eq("data_resource_id", resourceId) wrapper.eq("data_resource_id", resourceId)
.eq("del_flag", 0) .eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.orderByDesc("attr_type"); .orderByDesc("attr_type");
return attrDao.selectList(wrapper); return attrDao.selectList(wrapper);
} }
@ -212,7 +208,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("create_date") queryWrapper.orderByDesc("create_date")
.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")) .eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"))
.eq("del_flag", 0); .eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag());
IPage<ResourceEntity> entityIPage = resourceDao.selectPage(page, queryWrapper); IPage<ResourceEntity> entityIPage = resourceDao.selectPage(page, queryWrapper);
return entityIPage; return entityIPage;
@ -225,7 +221,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<ResourceDTO> resourceDTOS = resourceDao.selectMostPopular(selectMap); List<ResourceDTO> resourceDTOS = resourceDao.selectMostPopular(selectMap);
page.setRecords(resourceDTOS); page.setRecords(resourceDTOS);
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag", 0).eq("type", jsonObject.getString("type")); queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).eq("type", jsonObject.getString("type"));
Integer count = resourceDao.selectCount(queryWrapper); Integer count = resourceDao.selectCount(queryWrapper);
page.setTotal(count); page.setTotal(count);
return page; return page;
@ -239,7 +235,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
UpdateWrapper<ResourceEntity> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<ResourceEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda() updateWrapper.lambda()
.eq(ResourceEntity::getId, resourceEntity.getId()) .eq(ResourceEntity::getId, resourceEntity.getId())
.eq(ResourceEntity::getDelFlag, 0); .eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
resourceDao.update(entity, updateWrapper); resourceDao.update(entity, updateWrapper);
} }
@ -255,4 +251,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
return null; return null;
} }
@Override
public List<Map<String, Object>> getAmountGroupByType() {
List<Map<String, Object>> amountInfo = resourceDao.getAmountGroupByType();
return amountInfo;
}
} }

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

@ -3,7 +3,6 @@ package io.renren.modules.resourceMountApply.listener;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import io.renren.modules.activiti.service.ActTaskService;
import io.renren.modules.processForm.service.ApiGatewayService; import io.renren.modules.processForm.service.ApiGatewayService;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
@ -128,7 +127,7 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
} }
/** /**
* 流程结束接口推送api * 流程结束推送
* *
* @param delegateTask * @param delegateTask
*/ */
@ -138,10 +137,7 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
JsonElement jsonElement = gson.toJsonTree(kv); JsonElement jsonElement = gson.toJsonTree(kv);
TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class); TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class);
Long resourceID = resourceMountApplyDTO.getResourceDTO().getId(); Long resourceID = resourceMountApplyDTO.getResourceDTO().getId();
// apiGatewayService.registerApi2Gateway(String.valueOf(resourceID));
if (ActTaskService.Task_HANDLE_STATE_AGREE.equals(kv.get(ActTaskService.Task_HANDLE_STATE))) {
apiGatewayService.registerApi2Gateway(String.valueOf(resourceID));
}
ResourceDTO re = resourceMountApplyDTO.getResourceDTO(); ResourceDTO re = resourceMountApplyDTO.getResourceDTO();
if (re != null) { if (re != null) {

View File

@ -82,6 +82,7 @@ public class ShiroConfig {
*/ */
filterMap.put("/upload", "anon"); filterMap.put("/upload", "anon");
filterMap.put("/upload/**", "anon"); filterMap.put("/upload/**", "anon");
filterMap.put("/census/center/**", "anon"); // 全局各类统计
filterMap.put("/**", "oauth2"); filterMap.put("/**", "oauth2");
shiroFilter.setFilterChainDefinitionMap(filterMap); shiroFilter.setFilterChainDefinitionMap(filterMap);

View File

@ -39,4 +39,6 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
* @return * @return
*/ */
SysUserEntity getByDeptIdAndRoleId(@Param("deptId") Long deptId, @Param("roleId") Long roleId); SysUserEntity getByDeptIdAndRoleId(@Param("deptId") Long deptId, @Param("roleId") Long roleId);
Long countAllUser();
} }

View File

@ -48,4 +48,11 @@ public interface SysUserService extends BaseService<SysUserEntity> {
SysUserDTO getByDeptIdAndRoleId(Long deptId, Long roleId); SysUserDTO getByDeptIdAndRoleId(Long deptId, Long roleId);
/**
* 统计所有有效的用户
*
* @return
*/
Long countAllUser();
} }

View File

@ -167,4 +167,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
return ConvertUtils.sourceToTarget(entity, SysUserDTO.class); return ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
} }
/**
* 统计所有有效的用户
*
* @return
*/
@Override
public Long countAllUser() {
return baseDao.countAllUser();
}
} }

View File

@ -2,6 +2,9 @@
big_date: big_date:
name: 青岛市大数据发展管理局 name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人 assignee_role_name: 部门审批人
# 需要进行统计数目的资源 type
census:
type: 组件服务,应用资源,基础设施,数据资源,知识库
# Tomcat # Tomcat
server: server:
tomcat: tomcat:

View File

@ -89,7 +89,7 @@
SET del_flag = 1, SET del_flag = 1,
update_date = NOW() update_date = NOW()
WHERE 1 = 1 WHERE 1 = 1
AND id IN AND id IN
<foreach collection="ids" item="item" open="(" separator="," close=")"> <foreach collection="ids" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
@ -104,14 +104,19 @@
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
IFNULL(sd.name, '暂无部门信息') AS "deptName", IFNULL(sd.name, '暂无部门信息') AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
(IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS total (IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS
total
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
FROM tb_resource_collection WHERE
1 = 1 1 = 1
AND del_flag = 0 AND del_flag = 0
AND user_id = #{dto.creator} AND user_id = #{dto.creator}
@ -121,18 +126,18 @@
WHERE 1 = 1 WHERE 1 = 1
AND tdr.type = #{dto.type} AND tdr.type = #{dto.type}
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''" > <if test="dto.name != null and dto.name != ''">
AND tdr.name like CONCAT('%',#{dto.name},'%') AND tdr.name like CONCAT('%',#{dto.name},'%')
</if> </if>
<if test="dto.districtId != null and dto.districtId != ''" > <if test="dto.districtId != null and dto.districtId != ''">
AND tdr.district_id = #{dto.districtId} AND tdr.district_id = #{dto.districtId}
</if> </if>
<if test="dto.deptId != null and dto.deptId != ''" > <if test="dto.deptId != null and dto.deptId != ''">
AND tdr.dept_id = #{dto.deptId} AND tdr.dept_id = #{dto.deptId}
</if> </if>
<if test="dto.infoList.size > 0"> <if test="dto.infoList.size > 0">
AND AND
tda.data_resource_id IN ( tda.data_resource_id IN (
SELECT data_resource_id SELECT data_resource_id
FROM ( FROM (
SELECT tb.data_resource_id SELECT tb.data_resource_id
@ -153,102 +158,115 @@
<select id="selectTypeCount" resultType="java.util.Map"> <select id="selectTypeCount" resultType="java.util.Map">
SELECT SELECT
type, type,
count(id) AS "count" count(id) AS "count"
FROM tb_data_resource FROM tb_data_resource
WHERE 1 = 1 WHERE 1 = 1
AND del_flag = 0 AND del_flag = 0
<if test="deptId != null and deptId != ''"> <if test="deptId != null and deptId != ''">
AND dept_id = #{deptId} AND dept_id = #{deptId}
</if> </if>
GROUP BY type GROUP BY type
ORDER BY type ORDER BY type
</select> </select>
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO"> <select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT SELECT
tdr.*, tdr.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total (IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN ( SELECT resource_id, SUM(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id LEFT JOIN ( SELECT resource_id, SUM(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
WHERE WHERE
1 = 1 1 = 1
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="type != null and type != ''"> <if test="type != null and type != ''">
AND tdr.type = #{type} AND tdr.type = #{type}
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
AND tdr.name LIKE CONCAT('%',#{name},'%') AND tdr.name LIKE CONCAT('%',#{name},'%')
</if> </if>
ORDER BY ${orderFiled} ${orderType} ORDER BY ${orderFiled} ${orderType}
LIMIT ${pageNum}, ${pageSize} LIMIT ${pageNum}, ${pageSize}
</select> </select>
<select id="selectDTOById" resultMap="resourceDTO"> <select id="selectDTOById" resultMap="resourceDTO">
SELECT SELECT
tdr.*, tdr.*,
tda.*, tda.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name as "deptName", sd.name as "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState" IFNULL(taa2.applyState, 'false') AS "applyState"
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
1 = 1 AND del_flag = 0 AND user_id = #{userId} LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS "applyState" FROM t_ability_application WHERE LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
1 = 1 AND del_flag = 0 AND user_id = #{userId} FROM tb_resource_collection WHERE
GROUP BY id) taa2 ON tdr.id = taa2.resource_id 1 = 1 AND del_flag = 0 AND user_id = #{userId}
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS
"applyState" FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{userId}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1 WHERE 1 = 1
AND tdr.del_flag = 0 <!-- AND tdr.del_flag = 0-->
AND tdr.id = #{id} AND tdr.id = #{id}
</select> </select>
<select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO"> <select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT SELECT
tdr.*, tdr.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name AS "deptName", sd.name AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState", IFNULL(taa2.applyState, 'false') AS "applyState",
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total (IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS "applyState" FROM t_ability_application WHERE LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} FROM tb_resource_collection WHERE
GROUP BY id) taa2 ON tdr.id = taa2.resource_id 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS
"applyState" FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1 WHERE 1 = 1
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''" > <if test="dto.name != null and dto.name != ''">
AND tdr.name LIKE CONCAT('%',#{dto.name},'%') AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
</if> </if>
<if test="dto.type != null and dto.type != ''" > <if test="dto.type != null and dto.type != ''">
AND tdr.type = #{dto.type} AND tdr.type = #{dto.type}
</if> </if>
<if test="dto.districtId != null and dto.districtId != ''" > <if test="dto.districtId != null and dto.districtId != ''">
AND tdr.district_id = #{dto.districtId} AND tdr.district_id = #{dto.districtId}
</if> </if>
ORDER BY ${orderField} ${orderType} ORDER BY ${orderField} ${orderType}
@ -257,35 +275,47 @@
<select id="selectApplyArea" resultType="java.util.Map"> <select id="selectApplyArea" resultType="java.util.Map">
SELECT SELECT
* *
FROM FROM
( (
SELECT SELECT
attr_value, attr_value,
IFNULL( COUNT( trc.id ), 0 ) AS "colCount", IFNULL( COUNT( trc.id ), 0 ) AS "colCount",
IFNULL( COUNT( taa.id ), 0 ) AS "aplCount", IFNULL( COUNT( taa.id ), 0 ) AS "aplCount",
( (
IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total
FROM FROM
tb_data_attr tda tb_data_attr tda
LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id
AND trc.del_flag = 0 AND trc.del_flag = 0
AND trc.user_id = #{userId} AND trc.user_id = #{userId}
LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id
AND taa.del_flag = 0 AND taa.del_flag = 0
AND taa.user_id = #{userId} AND taa.user_id = #{userId}
WHERE
1 = 1
AND tda.attr_type = '应用领域'
AND tda.del_flag = 0
AND ( attr_value != '' AND attr_value IS NOT NULL )
GROUP BY
attr_value
ORDER BY
total DESC
) temp
WHERE WHERE
temp.total != 0 1 = 1
AND tda.attr_type = '应用领域'
AND tda.del_flag = 0
AND ( attr_value != '' AND attr_value IS NOT NULL )
GROUP BY
attr_value
ORDER BY
total DESC
) temp
WHERE
temp.total != 0
</select>
<select id="getAmountGroupByType" resultType="java.util.Map">
SELECT
COUNT( id ) AS amount,
type AS type
FROM
tb_data_resource
WHERE
del_flag = 0
GROUP BY
type
</select> </select>
</mapper> </mapper>

View File

@ -45,7 +45,7 @@
select trc.* select trc.*
from tb_resource_car trc from tb_resource_car trc
<if test="(params.type != null and params.type != '') or (params.name != null and params.name != '')"> <if test="(params.type != null and params.type != '') or (params.name != null and params.name != '')">
left join tb_data_resource tdr on trc.resource_id = tdr.id and tdr.del_flag = 0 left join tb_data_resource tdr on trc.resource_id = tdr.id and tdr.del_flag != 1
</if> </if>
where 1 = 1 where 1 = 1
and trc.del_flag = 0 and trc.del_flag = 0

View File

@ -57,7 +57,7 @@
SELECT trc.* SELECT trc.*
FROM tb_resource_collection trc FROM tb_resource_collection trc
<if test="(params.type != null and params.type != '') or (params.name != null and params.name != '')"> <if test="(params.type != null and params.type != '') or (params.name != null and params.name != '')">
LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id AND tdr.del_flag = 0 LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id AND tdr.del_flag != 1
</if> </if>
WHERE 1 = 1 WHERE 1 = 1
AND trc.del_flag = 0 AND trc.del_flag = 0

View File

@ -6,10 +6,10 @@
<select id="getList" resultType="io.renren.modules.sys.entity.SysUserEntity"> <select id="getList" resultType="io.renren.modules.sys.entity.SysUserEntity">
select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName
from sys_user t1 from sys_user t1
<if test = "postId != null and postId.trim() != '' "> <if test="postId != null and postId.trim() != '' ">
left join sys_user_post t3 on t1.id = t3.user_id left join sys_user_post t3 on t1.id = t3.user_id
</if> </if>
where t1.super_admin = 0 where t1.super_admin = 0
<if test="username != null and username.trim() != ''"> <if test="username != null and username.trim() != ''">
and t1.username like #{username} and t1.username like #{username}
</if> </if>
@ -65,5 +65,13 @@
AND t2.dept_id = #{deptId} AND t2.dept_id = #{deptId}
LIMIT 1 LIMIT 1
</select> </select>
<select id="countAllUser" resultType="java.lang.Long">
SELECT
COUNT( id )
FROM
sys_user
WHERE
`status` = 1
</select>
</mapper> </mapper>