Merge branch 'dev'

This commit is contained in:
wangliwen 2022-12-12 15:57:22 +08:00
commit 8d97144826
12 changed files with 406 additions and 12 deletions

View File

@ -113,7 +113,7 @@ public class ActTaskController {
if (userId.equals(taskDTO.getAssignee())) { if (userId.equals(taskDTO.getAssignee())) {
taskDTO.setSynergism(Boolean.FALSE); taskDTO.setSynergism(Boolean.FALSE);
} else { } else {
taskDTO.setSynergism(Boolean.FALSE); taskDTO.setSynergism(Boolean.TRUE);
} }
} }
} }

View File

@ -102,6 +102,8 @@ public class TaskDTO {
private String provideDept; private String provideDept;
@ApiModelProperty(value = "是否为审核组内协助任务") @ApiModelProperty(value = "是否为审核组内协助任务")
private Boolean synergism; private Boolean synergism;
@ApiModelProperty(value = "审核组名称")
private String auditTeamName;
@Override @Override

View File

@ -11,6 +11,8 @@ import io.renren.common.page.PageData;
import io.renren.common.service.impl.BaseServiceImpl; import io.renren.common.service.impl.BaseServiceImpl;
import io.renren.common.utils.MessageUtils; import io.renren.common.utils.MessageUtils;
import io.renren.modules.activiti.dto.TaskDTO; 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.dto.TDemandDataDTO;
import io.renren.modules.demanData.service.TDemandDataService; import io.renren.modules.demanData.service.TDemandDataService;
import io.renren.modules.demandComment.dto.TDemandCommentDTO; import io.renren.modules.demandComment.dto.TDemandCommentDTO;
@ -60,6 +62,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; 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 Integer CPUNUM = Runtime.getRuntime().availableProcessors();
private static final ExecutorService executor = Executors.newWorkStealingPool(CPUNUM * 2); 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 = "handleState"; //任务节点处理状态key
public static String Task_HANDLE_STATE_AGREE = "agree"; //同意 public static String Task_HANDLE_STATE_AGREE = "agree"; //同意
public static String Task_HANDLE_STATE_REJECTED = "rejected"; //驳回 public static String Task_HANDLE_STATE_REJECTED = "rejected"; //驳回
@ -123,6 +128,11 @@ public class ActTaskService extends BaseServiceImpl {
private SysNoticeService sysNoticeService; private SysNoticeService sysNoticeService;
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; 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 * @return
*/ */
public PageData<TaskDTO> page(Map<String, Object> params) { public PageData<TaskDTO> page(Map<String, Object> params) {
// TODO 同一审核组内成员
List<String> groupUserId = new ArrayList<String>() {{ // 测试
}};
String userId = (String) params.get("userId"); String userId = (String) params.get("userId");
// 同一审核组内成员
List<String> groupUserId = new ArrayList<>();
List<SysAuditTeamDTO> 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 curPage = 1;
Integer limit = 10; Integer limit = 10;
if (params.get(Constant.PAGE) != null) { if (params.get(Constant.PAGE) != null) {
@ -158,9 +180,11 @@ public class ActTaskService extends BaseServiceImpl {
if (StringUtils.isNotEmpty(userId)) { if (StringUtils.isNotEmpty(userId)) {
where.append("AND ( RES.ASSIGNEE_ = #{userId} "); where.append("AND ( RES.ASSIGNEE_ = #{userId} ");
// 处理同一工作组内 // 处理同一工作组内
if (auditteam) { // 进行审核组协作时
groupUserId.stream().forEach(index -> { groupUserId.stream().forEach(index -> {
where.append(String.format(" OR RES.ASSIGNEE_ = '%s' ", index)); where.append(String.format(" OR RES.ASSIGNEE_ = '%s' ", index));
}); });
}
where.append(")"); where.append(")");
} }
@ -193,7 +217,7 @@ public class ActTaskService extends BaseServiceImpl {
List<CompletableFuture> completableFutures = new ArrayList<CompletableFuture>(); List<CompletableFuture> completableFutures = new ArrayList<CompletableFuture>();
final TaskQuery taskQuery = taskService.createTaskQuery(); final TaskQuery taskQuery = taskService.createTaskQuery();
List<Task> list_ = tasks.stream().map(index -> { List<Task> 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; Task temp = null;
try { try {
temp = (Task) tempTask.get(); temp = (Task) tempTask.get();
@ -205,7 +229,8 @@ public class ActTaskService extends BaseServiceImpl {
return temp; return temp;
}).filter(Objects::nonNull).collect(Collectors.toList()); }).filter(Objects::nonNull).collect(Collectors.toList());
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join(); 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(); // TaskQuery taskQuery = taskService.createTaskQuery();
// if (StringUtils.isNotEmpty(userId)) { // if (StringUtils.isNotEmpty(userId)) {
@ -266,7 +291,7 @@ public class ActTaskService extends BaseServiceImpl {
.listPage((finalCurPage - 1) * finalLimit, finalCurPage * finalLimit); .listPage((finalCurPage - 1) * finalLimit, finalCurPage * finalLimit);
count.add(taskQuery.taskAssignee(index.getId().toString()) count.add(taskQuery.taskAssignee(index.getId().toString())
.orderByTaskCreateTime().desc().count()); .orderByTaskCreateTime().desc().count());
taskDtoList.addAll(tasks2TaskDtos(list)); taskDtoList.addAll(tasks2TaskDtos(list, ""));
}); });
return completableFuture; return completableFuture;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -287,11 +312,13 @@ public class ActTaskService extends BaseServiceImpl {
return page; return page;
} }
private List<TaskDTO> tasks2TaskDtos(List<Task> list) { private List<TaskDTO> tasks2TaskDtos(List<Task> list, String audioTeamName) {
List<TaskDTO> listDto = new ArrayList<>(); List<TaskDTO> listDto = new ArrayList<>();
for (Task task : list) { for (Task task : list) {
TaskDTO dto = new TaskDTO(); TaskDTO dto = new TaskDTO();
this.convertTaskInfo(task, dto); this.convertTaskInfo(task, dto);
// 填入审核协作组名称
dto.setAuditTeamName(audioTeamName);
Map<String, Object> processVariable = new LinkedHashMap<>(); Map<String, Object> processVariable = new LinkedHashMap<>();
if (task.getProcessVariables().containsKey("tAbilityApplicationDTOList")) { if (task.getProcessVariables().containsKey("tAbilityApplicationDTOList")) {

View File

@ -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<PageData<SysAuditTeamDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<SysAuditTeamDTO> page = sysAuditTeamService.page(params);
return new Result<PageData<SysAuditTeamDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
// @RequiresPermissions("audit_team:sysauditteam:info")
public Result<SysAuditTeamDTO> get(@PathVariable("id") Long id) {
SysAuditTeamDTO data = sysAuditTeamService.get(id);
return new Result<SysAuditTeamDTO>().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> 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> 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<String, Object> params, HttpServletResponse response) throws Exception {
List<SysAuditTeamDTO> list = sysAuditTeamService.list(params);
ExcelUtils.exportExcelToTarget(response, null, "流程审核组组员", list, SysAuditTeamExcel.class);
}
}

View File

@ -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<SysAuditTeamEntity> {
/**
* 根据审核组成员用户id获取审核组列表
*
* @param member
* @return
*/
List<SysAuditTeamDTO> selectByMemberOne(@Param("member") String member);
}

View File

@ -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<Map> member;
@ApiModelProperty(value = "审核组索引")
private String index;
}

View File

@ -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<Map> member;
/**
* 审核组索引
*/
@TableField(value = "`index`")
private String index;
}

View File

@ -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;
}

View File

@ -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<SysAuditTeamEntity, SysAuditTeamDTO> {
List<SysAuditTeamDTO> selectByMemberOne(String member);
}

View File

@ -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<SysAuditTeamDao, SysAuditTeamEntity, SysAuditTeamDTO> implements SysAuditTeamService {
@Override
public QueryWrapper<SysAuditTeamEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<SysAuditTeamEntity> wrapper = new QueryWrapper<>();
return wrapper;
}
@Override
public List<SysAuditTeamDTO> selectByMemberOne(String member) {
return baseDao.selectByMemberOne(member);
}
}

View File

@ -182,4 +182,7 @@ reminders:
# 恩科会议 # 恩科会议
enke: enke:
enable: true enable: true
# 开启审核组成员支持
auditteam:
enable: true

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.renren.modules.audit_team.dao.SysAuditTeamDao">
<resultMap type="io.renren.modules.audit_team.entity.SysAuditTeamEntity" id="sysAuditTeamMap">
<result property="id" column="id"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="name" column="name"/>
<result property="member" column="member"
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
<result property="index" column="`index`"/>
</resultMap>
<resultMap id="sysAuditTeamDTO" type="io.renren.modules.audit_team.dto.SysAuditTeamDTO">
<result property="id" column="id"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="name" column="name"/>
<result property="member" column="member"
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
<result property="index" column="`index`"/>
</resultMap>
<select id="selectByMemberOne" resultMap="sysAuditTeamDTO">
SELECT
*
FROM
sys_audit_team
WHERE
JSON_CONTAINS( sys_audit_team.member, JSON_OBJECT( "id", #{member} ));
</select>
</mapper>