From b2f03e421884b91e7cefee45dbe01e3b3b10d50f Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 12 Dec 2022 15:57:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=B6=89=E5=8F=8A=E7=9A=84?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E5=8D=8F=E4=BD=9C=E7=BB=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActTaskController.java | 2 +- .../renren/modules/activiti/dto/TaskDTO.java | 2 + .../activiti/service/ActTaskService.java | 49 +++++-- .../controller/SysAuditTeamController.java | 137 ++++++++++++++++++ .../audit_team/dao/SysAuditTeamDao.java | 27 ++++ .../audit_team/dto/SysAuditTeamDTO.java | 36 +++++ .../audit_team/entity/SysAuditTeamEntity.java | 42 ++++++ .../audit_team/excel/SysAuditTeamExcel.java | 32 ++++ .../service/SysAuditTeamService.java | 17 +++ .../service/impl/SysAuditTeamServiceImpl.java | 36 +++++ .../src/main/resources/application.yml | 3 + .../mapper/audit_team/SysAuditTeamDao.xml | 35 +++++ 12 files changed, 406 insertions(+), 12 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/audit_team/controller/SysAuditTeamController.java create mode 100644 renren-admin/src/main/java/io/renren/modules/audit_team/dao/SysAuditTeamDao.java create mode 100644 renren-admin/src/main/java/io/renren/modules/audit_team/dto/SysAuditTeamDTO.java create mode 100644 renren-admin/src/main/java/io/renren/modules/audit_team/entity/SysAuditTeamEntity.java create mode 100644 renren-admin/src/main/java/io/renren/modules/audit_team/excel/SysAuditTeamExcel.java create mode 100644 renren-admin/src/main/java/io/renren/modules/audit_team/service/SysAuditTeamService.java create mode 100644 renren-admin/src/main/java/io/renren/modules/audit_team/service/impl/SysAuditTeamServiceImpl.java create mode 100644 renren-admin/src/main/resources/mapper/audit_team/SysAuditTeamDao.xml diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java index ef6edab0..d249ebd7 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java @@ -113,7 +113,7 @@ public class ActTaskController { if (userId.equals(taskDTO.getAssignee())) { taskDTO.setSynergism(Boolean.FALSE); } else { - taskDTO.setSynergism(Boolean.FALSE); + taskDTO.setSynergism(Boolean.TRUE); } } } diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/dto/TaskDTO.java b/renren-admin/src/main/java/io/renren/modules/activiti/dto/TaskDTO.java index c666d17a..41bf5d18 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/dto/TaskDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/dto/TaskDTO.java @@ -102,6 +102,8 @@ public class TaskDTO { private String provideDept; @ApiModelProperty(value = "是否为审核组内协助任务") private Boolean synergism; + @ApiModelProperty(value = "审核组名称") + private String auditTeamName; @Override diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index 4feeb584..3a158c58 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -11,6 +11,8 @@ import io.renren.common.page.PageData; import io.renren.common.service.impl.BaseServiceImpl; import io.renren.common.utils.MessageUtils; import io.renren.modules.activiti.dto.TaskDTO; +import io.renren.modules.audit_team.dto.SysAuditTeamDTO; +import io.renren.modules.audit_team.service.SysAuditTeamService; import io.renren.modules.demanData.dto.TDemandDataDTO; import io.renren.modules.demanData.service.TDemandDataService; import io.renren.modules.demandComment.dto.TDemandCommentDTO; @@ -60,6 +62,7 @@ import org.codehaus.jackson.map.ObjectMapper; 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.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -81,6 +84,8 @@ public class ActTaskService extends BaseServiceImpl { private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors(); private static final ExecutorService executor = Executors.newWorkStealingPool(CPUNUM * 2); + private static final ExecutorService executor_task = Executors.newCachedThreadPool(); + public static String Task_HANDLE_STATE = "handleState"; //任务节点处理状态key public static String Task_HANDLE_STATE_AGREE = "agree"; //同意 public static String Task_HANDLE_STATE_REJECTED = "rejected"; //驳回 @@ -123,6 +128,11 @@ public class ActTaskService extends BaseServiceImpl { private SysNoticeService sysNoticeService; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private SysAuditTeamService sysAuditTeamService; + + @Value("#{new Boolean(${auditteam.enable})}") + private Boolean auditteam; // 是否进行审核组 /** * 根据参数获取当前运行的任务信息 @@ -131,11 +141,23 @@ public class ActTaskService extends BaseServiceImpl { * @return */ public PageData page(Map params) { - // TODO 同一审核组内成员 - List groupUserId = new ArrayList() {{ // 测试 - - }}; String userId = (String) params.get("userId"); + // 同一审核组内成员 + List groupUserId = new ArrayList<>(); + List sysAuditTeamDTOS = new ArrayList<>(); + if (auditteam) { + sysAuditTeamDTOS = sysAuditTeamService.selectByMemberOne(userId); + groupUserId = sysAuditTeamDTOS + .stream() + .map(index -> index.getMember()) + .filter(Objects::nonNull) + .flatMap(index -> index.stream()) + .map(index -> (String) index.get("id")) + .filter(index -> !userId.equals(index)) // 过滤非本人 + .distinct() + .collect(Collectors.toList()); + } + Integer curPage = 1; Integer limit = 10; if (params.get(Constant.PAGE) != null) { @@ -158,9 +180,11 @@ public class ActTaskService extends BaseServiceImpl { if (StringUtils.isNotEmpty(userId)) { where.append("AND ( RES.ASSIGNEE_ = #{userId} "); // 处理同一工作组内 - groupUserId.stream().forEach(index -> { - where.append(String.format(" OR RES.ASSIGNEE_ = '%s' ", index)); - }); + if (auditteam) { // 进行审核组协作时 + groupUserId.stream().forEach(index -> { + where.append(String.format(" OR RES.ASSIGNEE_ = '%s' ", index)); + }); + } where.append(")"); } @@ -193,7 +217,7 @@ public class ActTaskService extends BaseServiceImpl { List completableFutures = new ArrayList(); final TaskQuery taskQuery = taskService.createTaskQuery(); List list_ = tasks.stream().map(index -> { - CompletableFuture tempTask = CompletableFuture.supplyAsync(() -> taskQuery.taskId(index.getId()).includeProcessVariables().singleResult(), executor); + CompletableFuture tempTask = CompletableFuture.supplyAsync(() -> taskQuery.taskId(index.getId()).includeProcessVariables().singleResult(), executor_task); Task temp = null; try { temp = (Task) tempTask.get(); @@ -205,7 +229,8 @@ public class ActTaskService extends BaseServiceImpl { return temp; }).filter(Objects::nonNull).collect(Collectors.toList()); CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join(); - return new PageData<>(tasks2TaskDtos(list_), (int) count); + String name = sysAuditTeamDTOS.stream().map(index -> index.getName()).findFirst().orElse(""); + return new PageData<>(tasks2TaskDtos(list_, name), (int) count); // 以下注释为原实现方案 // TaskQuery taskQuery = taskService.createTaskQuery(); // if (StringUtils.isNotEmpty(userId)) { @@ -266,7 +291,7 @@ public class ActTaskService extends BaseServiceImpl { .listPage((finalCurPage - 1) * finalLimit, finalCurPage * finalLimit); count.add(taskQuery.taskAssignee(index.getId().toString()) .orderByTaskCreateTime().desc().count()); - taskDtoList.addAll(tasks2TaskDtos(list)); + taskDtoList.addAll(tasks2TaskDtos(list, "")); }); return completableFuture; }).collect(Collectors.toList()); @@ -287,11 +312,13 @@ public class ActTaskService extends BaseServiceImpl { return page; } - private List tasks2TaskDtos(List list) { + private List tasks2TaskDtos(List list, String audioTeamName) { List listDto = new ArrayList<>(); for (Task task : list) { TaskDTO dto = new TaskDTO(); this.convertTaskInfo(task, dto); + // 填入审核协作组名称 + dto.setAuditTeamName(audioTeamName); Map processVariable = new LinkedHashMap<>(); if (task.getProcessVariables().containsKey("tAbilityApplicationDTOList")) { diff --git a/renren-admin/src/main/java/io/renren/modules/audit_team/controller/SysAuditTeamController.java b/renren-admin/src/main/java/io/renren/modules/audit_team/controller/SysAuditTeamController.java new file mode 100644 index 00000000..9299a462 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/audit_team/controller/SysAuditTeamController.java @@ -0,0 +1,137 @@ +package io.renren.modules.audit_team.controller; + +import io.renren.common.annotation.LogOperation; +import io.renren.common.constant.Constant; +import io.renren.common.page.PageData; +import io.renren.common.utils.ExcelUtils; +import io.renren.common.utils.Result; +import io.renren.common.validator.AssertUtils; +import io.renren.common.validator.ValidatorUtils; +import io.renren.common.validator.group.AddGroup; +import io.renren.common.validator.group.DefaultGroup; +import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.audit_team.dto.SysAuditTeamDTO; +import io.renren.modules.audit_team.excel.SysAuditTeamExcel; +import io.renren.modules.audit_team.service.SysAuditTeamService; +import io.renren.modules.category.util.CommonUtils; +import io.renren.modules.sys.dto.SysUserDTO; +import io.renren.modules.sys.service.SysUserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + + +/** + * 流程审核组组员 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-12-12 + */ +@RestController +@RequestMapping("audit_team/sysauditteam") +@Api(tags = "流程审核组组员") +public class SysAuditTeamController { + @Autowired + private SysAuditTeamService sysAuditTeamService; + @Autowired + private SysUserService sysUserService; + + @GetMapping("page") + @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 = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String") + }) +// @RequiresPermissions("audit_team:sysauditteam:page") + public Result> page(@ApiIgnore @RequestParam Map params) { + PageData page = sysAuditTeamService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") +// @RequiresPermissions("audit_team:sysauditteam:info") + public Result get(@PathVariable("id") Long id) { + SysAuditTeamDTO data = sysAuditTeamService.get(id); + + return new Result().ok(data); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") +// @RequiresPermissions("audit_team:sysauditteam:save") + public Result save(@RequestBody SysAuditTeamDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + dto.setIndex(CommonUtils.getPinYinHeadChar(dto.getName())); // 索引设置为名称拼音 + dto.setMember(dto.getMember().stream().map(index -> { + Optional sysUserDTO = Optional.ofNullable(sysUserService.get(Long.parseLong((String) index.get("id")))); + if (sysUserDTO.isPresent()) { + index.put("name", sysUserDTO.get().getRealName()); + index.put("dept_name", sysUserDTO.get().getDeptName()); + } + return index; + }).collect(Collectors.toList())); + sysAuditTeamService.save(dto); + return new Result(); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") +// @RequiresPermissions("audit_team:sysauditteam:update") + public Result update(@RequestBody SysAuditTeamDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + dto.setIndex(CommonUtils.getPinYinHeadChar(dto.getName())); // 索引设置为名称拼音 + dto.setMember(dto.getMember().stream().map(index -> { + Optional sysUserDTO = Optional.ofNullable(sysUserService.get((long) index.get("id"))); + if (sysUserDTO.isPresent()) { + index.put("name", sysUserDTO.get().getRealName()); + index.put("dept_name", sysUserDTO.get().getDeptName()); + } + return index; + }).collect(Collectors.toList())); + sysAuditTeamService.update(dto); + + return new Result(); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") +// @RequiresPermissions("audit_team:sysauditteam:delete") + public Result delete(@RequestBody Long[] ids) { + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + sysAuditTeamService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") +// @RequiresPermissions("audit_team:sysauditteam:export") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = sysAuditTeamService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, "流程审核组组员", list, SysAuditTeamExcel.class); + } + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/audit_team/dao/SysAuditTeamDao.java b/renren-admin/src/main/java/io/renren/modules/audit_team/dao/SysAuditTeamDao.java new file mode 100644 index 00000000..0bb304c2 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/audit_team/dao/SysAuditTeamDao.java @@ -0,0 +1,27 @@ +package io.renren.modules.audit_team.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.audit_team.dto.SysAuditTeamDTO; +import io.renren.modules.audit_team.entity.SysAuditTeamEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 流程审核组组员 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-12-12 + */ +@Mapper +public interface SysAuditTeamDao extends BaseDao { + + /** + * 根据审核组成员用户id,获取审核组列表 + * + * @param member + * @return + */ + List selectByMemberOne(@Param("member") String member); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/audit_team/dto/SysAuditTeamDTO.java b/renren-admin/src/main/java/io/renren/modules/audit_team/dto/SysAuditTeamDTO.java new file mode 100644 index 00000000..3e438067 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/audit_team/dto/SysAuditTeamDTO.java @@ -0,0 +1,36 @@ +package io.renren.modules.audit_team.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 流程审核组组员 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-12-12 + */ +@Data +@ApiModel(value = "流程审核组组员") +public class SysAuditTeamDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + private Long id; + @ApiModelProperty(value = "创建人") + private Long creator; + @ApiModelProperty(value = "创建时间") + private Date createDate; + @ApiModelProperty(value = "审核组名称") + private String name; + @ApiModelProperty(value = "审核组成员id数组") + private List member; + @ApiModelProperty(value = "审核组索引") + private String index; + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/audit_team/entity/SysAuditTeamEntity.java b/renren-admin/src/main/java/io/renren/modules/audit_team/entity/SysAuditTeamEntity.java new file mode 100644 index 00000000..20c0fb04 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/audit_team/entity/SysAuditTeamEntity.java @@ -0,0 +1,42 @@ +package io.renren.modules.audit_team.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; +import io.renren.common.entity.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * 流程审核组组员 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-12-12 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName(value = "sys_audit_team", autoResultMap = true) +public class SysAuditTeamEntity extends BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 审核组名称 + */ + private String name; + + /** + * 审核组成员id数组 + */ + @TableField(value = "member", typeHandler = FastjsonTypeHandler.class) + private List member; + + /** + * 审核组索引 + */ + @TableField(value = "`index`") + private String index; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/audit_team/excel/SysAuditTeamExcel.java b/renren-admin/src/main/java/io/renren/modules/audit_team/excel/SysAuditTeamExcel.java new file mode 100644 index 00000000..3ec03faa --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/audit_team/excel/SysAuditTeamExcel.java @@ -0,0 +1,32 @@ +package io.renren.modules.audit_team.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; + +/** + * 流程审核组组员 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-12-12 + */ +@Data +@ContentRowHeight(20) +@HeadRowHeight(20) +@ColumnWidth(25) +public class SysAuditTeamExcel { + @ExcelProperty(value = "主键ID", index = 0) + private Object id; + @ExcelProperty(value = "创建人", index = 1) + private Object creator; + @ExcelProperty(value = "创建时间", index = 2) + private Object createDate; + @ExcelProperty(value = "审核组名称", index = 3) + private Object name; + @ExcelProperty(value = "审核组成员id数组", index = 4) + private Object member; + @ExcelProperty(value = "审核组索引", index = 5) + private Object index; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/audit_team/service/SysAuditTeamService.java b/renren-admin/src/main/java/io/renren/modules/audit_team/service/SysAuditTeamService.java new file mode 100644 index 00000000..2cf6c23d --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/audit_team/service/SysAuditTeamService.java @@ -0,0 +1,17 @@ +package io.renren.modules.audit_team.service; + +import io.renren.common.service.CrudService; +import io.renren.modules.audit_team.dto.SysAuditTeamDTO; +import io.renren.modules.audit_team.entity.SysAuditTeamEntity; + +import java.util.List; + +/** + * 流程审核组组员 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-12-12 + */ +public interface SysAuditTeamService extends CrudService { + List selectByMemberOne(String member); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/audit_team/service/impl/SysAuditTeamServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/audit_team/service/impl/SysAuditTeamServiceImpl.java new file mode 100644 index 00000000..86e9ce48 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/audit_team/service/impl/SysAuditTeamServiceImpl.java @@ -0,0 +1,36 @@ +package io.renren.modules.audit_team.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.modules.audit_team.dao.SysAuditTeamDao; +import io.renren.modules.audit_team.dto.SysAuditTeamDTO; +import io.renren.modules.audit_team.entity.SysAuditTeamEntity; +import io.renren.modules.audit_team.service.SysAuditTeamService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * 流程审核组组员 + * + * @author wangliwen wangliwen2@hisense.com + * @since 1.0 2022-12-12 + */ +@Service +public class SysAuditTeamServiceImpl extends CrudServiceImpl implements SysAuditTeamService { + + @Override + public QueryWrapper getWrapper(Map params) { + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + } + + + @Override + public List selectByMemberOne(String member) { + return baseDao.selectByMemberOne(member); + } +} \ No newline at end of file diff --git a/renren-admin/src/main/resources/application.yml b/renren-admin/src/main/resources/application.yml index 853b9125..afad6a31 100644 --- a/renren-admin/src/main/resources/application.yml +++ b/renren-admin/src/main/resources/application.yml @@ -182,4 +182,7 @@ reminders: # 恩科会议 enke: enable: true +# 开启审核组成员支持 +auditteam: + enable: true diff --git a/renren-admin/src/main/resources/mapper/audit_team/SysAuditTeamDao.xml b/renren-admin/src/main/resources/mapper/audit_team/SysAuditTeamDao.xml new file mode 100644 index 00000000..c830806f --- /dev/null +++ b/renren-admin/src/main/resources/mapper/audit_team/SysAuditTeamDao.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file