工作流和角色
This commit is contained in:
@ -34,4 +34,9 @@ public class SysRoleProjectDto {
|
||||
* 角色id列表
|
||||
*/
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 角色名称列表
|
||||
*/
|
||||
private List<Long> appRoleIds;
|
||||
}
|
||||
|
||||
@ -84,7 +84,8 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
QueryWrapper<SysRole> wrapper = Wrappers.query();
|
||||
wrapper.eq("r.del_flag", SystemConstants.NORMAL)
|
||||
.eq(StringUtils.isNotBlank(bo.getRoleSource()), "r.role_source", bo.getRoleSource())
|
||||
.eq(ObjectUtil.isNotNull(bo.getDeptId()), "r.dept_id", bo.getDeptId())
|
||||
.notIn("2".equals(bo.getRoleSource()), "r.role_id", Arrays.asList( 2L,3L,4L))
|
||||
//.eq(ObjectUtil.isNotNull(bo.getDeptId()), "r.dept_id", bo.getDeptId())
|
||||
.eq(ObjectUtil.isNotNull(bo.getIsSpecial()), "r.is_special", bo.getIsSpecial())
|
||||
.eq(ObjectUtil.isNotNull(bo.getRoleId()), "r.role_id", bo.getRoleId())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleName()), "r.role_name", bo.getRoleName())
|
||||
@ -93,6 +94,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
"r.create_time", params.get("beginTime"), params.get("endTime"))
|
||||
.orderByAsc("r.role_sort").orderByAsc("r.create_time");
|
||||
// 添加部门ID或角色ID在2,3,4中的条件
|
||||
if (ObjectUtil.isNotNull(bo.getDeptId())) {
|
||||
wrapper.and(w -> w.eq("r.dept_id", bo.getDeptId()).or().in("r.role_id", Arrays.asList(2L, 3L, 4L)));
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@ -208,8 +213,16 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
for (Map.Entry<Long, List<SysUserRole>> entry : map.entrySet()) {
|
||||
Long key = entry.getKey();
|
||||
SysRoleProjectDto dto = new SysRoleProjectDto();
|
||||
List<Long> roleIds = StreamUtils.toList(entry.getValue(), SysUserRole::getRoleId);
|
||||
|
||||
List<SysRole> sysRoles = baseMapper.selectList(Wrappers.<SysRole>lambdaQuery()
|
||||
.in(SysRole::getRoleId, roleIds)
|
||||
);
|
||||
List<Long> appRoleIds = sysRoles.stream().filter(vo -> "2".equals(vo.getRoleSource())).map(SysRole::getRoleId).distinct().toList();
|
||||
roleIds.removeAll(appRoleIds);
|
||||
dto.setProjectId(key);
|
||||
dto.setRoleIds(StreamUtils.toList(entry.getValue(), SysUserRole::getRoleId));
|
||||
dto.setRoleIds(roleIds);
|
||||
dto.setAppRoleIds(appRoleIds);
|
||||
if (projectMap.containsKey(key)) {
|
||||
BusProject project = projectMap.get(key).getFirst();
|
||||
dto.setProjectName(project.getProjectName());
|
||||
|
||||
@ -9,8 +9,12 @@ import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.entity.Definition;
|
||||
import org.dromara.warm.flow.core.entity.Node;
|
||||
import org.dromara.warm.flow.core.entity.Skip;
|
||||
import org.dromara.warm.flow.core.service.DefService;
|
||||
import org.dromara.warm.flow.core.utils.AssertUtil;
|
||||
import org.dromara.warm.flow.orm.entity.FlowDefinition;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.domain.bo.FlowDefinitionBo;
|
||||
@ -23,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 流程定义管理 控制层
|
||||
@ -190,4 +195,50 @@ public class FlwDefinitionController extends BaseController {
|
||||
return R.ok(active ? defService.active(id) : defService.unActive(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制流程定义到另一项目
|
||||
*
|
||||
* @param id 流程定义id
|
||||
*/
|
||||
@Log(title = "复制流程定义到另一项目", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/copyToProject/{id}/{projectId}")
|
||||
@RepeatSubmit()
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<Boolean> copyToProjectById(@PathVariable Long id, @PathVariable Long projectId) {
|
||||
Definition definition = FlowEngine.defService().getById(id).copy();
|
||||
definition.setVersion("1");
|
||||
AssertUtil.isNull(definition, "流程定义不存在!");
|
||||
String[] split = definition.getFlowCode().split("_");
|
||||
definition.setFlowCode(projectId + "_" + split[1]);
|
||||
List<Node> nodeList = (List) FlowEngine.nodeService().getByDefId(id).stream().map(Node::copy).collect(Collectors.toList());
|
||||
List<Skip> skipList = (List)FlowEngine.skipService().getByDefId(id).stream().map(Skip::copy).collect(Collectors.toList());
|
||||
FlowEngine.dataFillHandler().idFill(definition);
|
||||
nodeList.forEach((node) -> {
|
||||
node.setDefinitionId(definition.getId()).setVersion(definition.getVersion());
|
||||
});
|
||||
FlowEngine.nodeService().saveBatch(nodeList);
|
||||
skipList.forEach((skip) -> {
|
||||
skip.setDefinitionId(definition.getId());
|
||||
});
|
||||
FlowEngine.skipService().saveBatch(skipList);
|
||||
boolean save = FlowEngine.defService().save(definition);
|
||||
return R.ok(save);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/copyAllProject/{projectId}/{toProjectId}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RepeatSubmit()
|
||||
public R<Boolean> copyToProject(@PathVariable Long projectId,@PathVariable Long toProjectId) {
|
||||
FlowDefinitionBo flowDefinitionBo = new FlowDefinitionBo();
|
||||
flowDefinitionBo.setProjectId(projectId);
|
||||
PageQuery pageQuery = new PageQuery(9999,1);
|
||||
TableDataInfo<FlowDefinitionVo> flowDefinitionVoTableDataInfo = flwDefinitionService.queryList(flowDefinitionBo, pageQuery);
|
||||
List<FlowDefinitionVo> list = flowDefinitionVoTableDataInfo.getRows();
|
||||
for (FlowDefinitionVo flowDefinitionVo : list) {
|
||||
copyToProjectById(flowDefinitionVo.getId(),toProjectId);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -209,4 +209,10 @@ public class FlwTaskController extends BaseController {
|
||||
return R.ok(flwTaskService.currentTaskAllUser(taskId));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/copyRead/{flowUserId}")
|
||||
public R<Void> copyRead(@PathVariable Long flowUserId) {
|
||||
flwTaskService.copyRead(flowUserId);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,4 +54,10 @@ public class FlowTaskBo implements Serializable {
|
||||
*/
|
||||
private List<Long> createByIds;
|
||||
|
||||
|
||||
/**
|
||||
* 是否已读
|
||||
*/
|
||||
private String isRead;
|
||||
|
||||
}
|
||||
|
||||
@ -187,4 +187,8 @@ public class FlowTaskVo implements Serializable {
|
||||
*/
|
||||
private List<ButtonPermissionVo> buttonList;
|
||||
|
||||
private Long flowUserId;
|
||||
|
||||
private String isRead;
|
||||
|
||||
}
|
||||
|
||||
@ -56,5 +56,10 @@ public interface FlwTaskMapper {
|
||||
* @return 结果
|
||||
*/
|
||||
Page<FlowTaskVo> getTaskCopyByPage(@Param("page") Page<FlowTaskVo> page, @Param(Constants.WRAPPER) QueryWrapper<FlowTaskBo> queryWrapper);
|
||||
|
||||
Page<FlowTaskVo> getTaskCopyDefinitionIdsByPage(@Param("page") Page<FlowTaskVo> page,@Param("definitionIds") List<Long> definitionIds, @Param(Constants.WRAPPER) QueryWrapper<FlowTaskBo> queryWrapper);
|
||||
|
||||
void copyRead(@Param("flowUserId") Long flowUserId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import org.dromara.warm.flow.orm.entity.FlowTask;
|
||||
import org.dromara.workflow.domain.bo.*;
|
||||
import org.dromara.workflow.domain.vo.FlowHisTaskVo;
|
||||
import org.dromara.workflow.domain.vo.FlowTaskVo;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -215,4 +216,7 @@ public interface IFlwTaskService {
|
||||
* @return 节点
|
||||
*/
|
||||
FlowNode getByNodeCode(String nodeCode, Long definitionId);
|
||||
|
||||
|
||||
void copyRead(@PathVariable Long flowUserId);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
@ -24,6 +25,9 @@ import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.sse.dto.SeeMessageContentDto;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.entity.*;
|
||||
@ -405,6 +409,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
queryWrapper.eq(StringUtils.isNotBlank(flowTaskBo.getIsRead()),"t.is_read", flowTaskBo.getIsRead());
|
||||
queryWrapper.in("t.processed_by", LoginHelper.getUserIdStr());
|
||||
Page<FlowTaskVo> page = flwTaskMapper.getTaskCopyDefinitionIdsByPage(pageQuery.build(),definitionIds, queryWrapper);
|
||||
return TableDataInfo.build(page);
|
||||
@ -808,4 +813,17 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
.eq(FlowNode::getDefinitionId, definitionId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyRead(Long flowUserId) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
flwTaskMapper.copyRead(flowUserId);
|
||||
SseMessageDto dto = new SseMessageDto();
|
||||
SeeMessageContentDto contentDto = new SeeMessageContentDto();
|
||||
contentDto.setType("count");
|
||||
contentDto.setContent("统计");
|
||||
dto.setMessage(JSONUtil.toJsonStr(contentDto));
|
||||
dto.setIsRecord(false);
|
||||
dto.setUserIds(Collections.singletonList(userId));
|
||||
SseMessageUtils.publishMessage(dto);
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +219,9 @@
|
||||
d.flow_code,
|
||||
d.category,
|
||||
d.version,
|
||||
bp.project_name
|
||||
bp.project_name,
|
||||
a.id as flowUserId,
|
||||
a.is_read
|
||||
from flow_user a
|
||||
left join flow_his_task b on a.associated = b.task_id
|
||||
left join flow_instance c on b.instance_id = c.id
|
||||
@ -238,4 +240,10 @@
|
||||
) t
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
<update id="copyRead">
|
||||
update flow_user
|
||||
set is_read = '1'
|
||||
where id = #{flowUserId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user