优化代码

dev_xds
姜玉琦 2023-09-20 22:28:45 +08:00
parent 3803bb90f6
commit 9d617720df
13 changed files with 306 additions and 44 deletions

View File

@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.flowable.domain.dto.FlowSaveXmlVo;
import com.ruoyi.flowable.domain.vo.ProcKeyRole;
import com.ruoyi.flowable.service.IFlowDefinitionService;
import com.ruoyi.system.domain.FlowProcDefDto;
import com.ruoyi.system.domain.SysExpression;
@ -62,9 +63,10 @@ public class FlowDefinitionController extends BaseController {
@ApiOperation(value = "流程定义列表", response = FlowProcDefDto.class)
public AjaxResult list(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize,
@ApiParam(value = "发起角色", required = false) @RequestParam(required = false) String roleId,
@ApiParam(value = "流程类型", required = false) @RequestParam(required = false) String category,
@ApiParam(value = "流程名称", required = false) @RequestParam(required = false) String name) {
return AjaxResult.success(flowDefinitionService.list(category, name, pageNum, pageSize));
return AjaxResult.success(flowDefinitionService.list(roleId, category, name, pageNum, pageSize));
}
@GetMapping(value = "/myList")
@ -176,6 +178,22 @@ public class FlowDefinitionController extends BaseController {
}
@ApiOperation(value = "流程发起角色配置")
@Log(title = "流程发起角色配置", businessType = BusinessType.UPDATE)
@PostMapping("/updateProcKeyByRoleId")
public AjaxResult updateProcKeyByRoleId(@RequestBody ProcKeyRole procKeyRole) {
flowDefinitionService.updateProcKeyByRoleId(procKeyRole.getRoleId(),procKeyRole.getKeys());
return success();
}
@ApiOperation(value = "流程发起排序设置")
@Log(title = "流程发起排序设置", businessType = BusinessType.UPDATE)
@PostMapping("/updateProcKeyRoleSort")
public AjaxResult updateProcKeyRoleSort(@RequestBody ProcKeyRole procKeyRole) {
flowDefinitionService.updateProcKeyRoleSort(procKeyRole);
return success();
}
@ApiOperation(value = "激活或挂起流程定义")
@PutMapping(value = "/updateState")
public AjaxResult updateState(@ApiParam(value = "1:激活,2:挂起", required = true) @RequestParam Integer state,

View File

@ -0,0 +1,50 @@
package com.ruoyi.flowable.domain.vo;
import java.io.Serializable;
import java.util.List;
public class ProcKeyRole implements Serializable
{
private static final long serialVersionUID = 1L;
private String roleId;
private String key;
private String sort;
private List<String> keys;
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public List<String> getKeys() {
return keys;
}
public void setKeys(List<String> keys) {
this.keys = keys;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.flowable.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.flowable.domain.vo.ProcKeyRole;
import com.ruoyi.system.domain.FlowProcDefDto;
import org.flowable.bpmn.model.FlowElement;
@ -21,13 +22,14 @@ public interface IFlowDefinitionService {
/**
*
*
* @param roleId
* @param category
* @param name
* @param pageNum
* @param pageSize
* @return
*/
Page<FlowProcDefDto> list(String category,String name,Integer pageNum, Integer pageSize);
Page<FlowProcDefDto> list(String roleId, String category, String name, Integer pageNum, Integer pageSize);
/**
*
@ -93,5 +95,25 @@ public interface IFlowDefinitionService {
*/
InputStream readImage(String deployId);
/**
*
* @param deployId
* @return
*/
public List<FlowElement> readNodes(String deployId);
/**
*
* @param roleId
* @param keys
* @return
*/
public void updateProcKeyByRoleId(String roleId,List<String> keys);
/**
*
* @param procKeyRole
* @return
*/
public void updateProcKeyRoleSort(ProcKeyRole procKeyRole);
}

View File

@ -7,6 +7,7 @@ import com.ruoyi.common.core.text.Convert;
import com.ruoyi.flowable.common.constant.ProcessConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.flowable.common.enums.FlowComment;
import com.ruoyi.flowable.domain.vo.ProcKeyRole;
import com.ruoyi.system.domain.FlowProcDefDto;
import com.ruoyi.flowable.factory.FlowServiceFactory;
import com.ruoyi.flowable.service.IFlowDefinitionService;
@ -74,6 +75,7 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
/**
*
*
* @param roleId
* @param category
* @param name
* @param pageNum
@ -81,18 +83,18 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
* @return
*/
@Override
public Page<FlowProcDefDto> list(String category, String name, Integer pageNum, Integer pageSize) {
public Page<FlowProcDefDto> list(String roleId, String category, String name, Integer pageNum, Integer pageSize) {
Page<FlowProcDefDto> page = new Page<>();
PageHelper.startPage(pageNum, pageSize);
final List<FlowProcDefDto> dataList = flowDeployMapper.selectDeployList(category,name);
final List<FlowProcDefDto> dataList = flowDeployMapper.selectDeployList(roleId,category,name);
// 加载挂表单
for (FlowProcDefDto procDef : dataList) {
SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getDeploymentId());
if (Objects.nonNull(sysForm)) {
procDef.setFormName(sysForm.getFormName());
procDef.setFormId(sysForm.getFormId());
}
}
//for (FlowProcDefDto procDef : dataList) {
// SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getDeploymentId());
// if (Objects.nonNull(sysForm)) {
// procDef.setFormName(sysForm.getFormName());
// procDef.setFormId(sysForm.getFormId());
// }
//}
page.setTotal(new PageInfo(dataList).getTotal());
page.setRecords(dataList);
return page;
@ -183,6 +185,11 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
}
/**
*
* @param deployId
* @return
*/
@Override
public List<FlowElement> readNodes(String deployId) {
List<FlowElement> list = new ArrayList<>();
@ -271,5 +278,35 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
repositoryService.deleteDeployment(deployId, true);
}
/**
*
* @param roleId
* @param keys
* @return
*/
@Override
public void updateProcKeyByRoleId(String roleId,List<String> keys) {
//根据角色删除原有流程定义
flowDeployMapper.deleteDeployByRoleId(roleId);
if(keys.size()>0){
List<Map<String, Object>> list = new ArrayList<>();
for(int i=0;i<keys.size();i++){
Map<String, Object> map = new HashMap<>();
map.put("key",keys.get(i));
map.put("roleId",roleId);
list.add(map);
}
flowDeployMapper.batchDeployRoleRole(list);
}
}
/**
*
* @param procKeyRole
* @return
*/
public void updateProcKeyRoleSort(ProcKeyRole procKeyRole) {
flowDeployMapper.updateProcKeyRoleSort(procKeyRole.getRoleId(),procKeyRole.getKey(),procKeyRole.getSort());
}
}

View File

@ -55,5 +55,10 @@ public class FlowProcDefDto implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date deploymentTime;
@ApiModelProperty("发起角色")
private String roleNames;
@ApiModelProperty("流程角色排序")
private String sorts;
}

View File

@ -4,6 +4,7 @@ import com.ruoyi.system.domain.FlowProcDefDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
*
@ -16,11 +17,12 @@ public interface FlowDeployMapper {
/**
*
* @param roleId
* @param category
* @param name
* @return
*/
List<FlowProcDefDto> selectDeployList(@Param("category")String category, @Param("name")String name);
List<FlowProcDefDto> selectDeployList(@Param("roleId")String roleId, @Param("category")String category, @Param("name")String name);
/**
*
@ -30,4 +32,28 @@ public interface FlowDeployMapper {
* @return
*/
List<FlowProcDefDto> selectMyDeployList(@Param("username")String username, @Param("category")String category, @Param("name")String name);
/**
*
* @param roleId
* @return
*/
int deleteDeployByRoleId(String roleId);
/**
*
* @param items
* @return
*/
int batchDeployRoleRole(List<Map<String, Object>> items);
/**
*
* @param roleId
* @param key
* @param sort
* @return
*/
int updateProcKeyRoleSort(@Param("roleId")String roleId, @Param("key")String key, @Param("sort")String sort);
}

View File

@ -13,11 +13,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
rp.key_ as flowKey,
rp.version_ as version,
rp.suspension_state_ as suspensionState,
rd.deploy_time_ as deploymentTime
rd.deploy_time_ as deploymentTime,
group_concat(sr.role_name) as roleNames,
group_concat(rpr.SORT_) as sorts
FROM
act_re_procdef rp
LEFT JOIN act_re_deployment rd ON rp.deployment_id_ = rd.id_
left join act_re_procdef_role rpr on rp.key_ = rpr.PROCDEF_KEY_
left join sys_role sr on sr.role_id = rpr.ROLE_ID_
<where>
<if test="roleId != null and roleId != ''">
and rpr.ROLE_ID_ = #{roleId}
</if>
<if test="name != null and name != ''">
and rd.name_ like concat('%', #{name}, '%')
</if>
@ -25,7 +32,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and rd.category_ = #{category}
</if>
</where>
order by rd.deploy_time_ desc
GROUP BY rp.key_
order by rpr.SORT_
</select>
<select id="selectMyDeployList" resultType="com.ruoyi.system.domain.FlowProcDefDto">
@ -58,5 +66,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by rd.deploy_time_ desc
</select>
<delete id="deleteDeployByRoleId" parameterType="string">
delete from act_re_procdef_role where ROLE_ID_ = #{roleId}
</delete>
<insert id="batchDeployRoleRole">
insert into act_re_procdef_role( PROCDEF_KEY_, ROLE_ID_) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.key}, #{item.roleId})
</foreach>
</insert>
<update id="updateProcKeyRoleSort">
update act_re_procdef_role set SORT_=#{sort} where PROCDEF_KEY_=#{key} and ROLE_ID_=#{roleId}
</update>
</mapper>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -147,3 +147,21 @@ export function exportDeployment(query) {
params: query
})
}
// 流程角色设置
export function updateProcKeyByRoleId(data) {
return request({
url: '/flowable/definition/updateProcKeyByRoleId',
method: 'post',
data: data
})
}
// 流程排序设置
export function updateProcKeyRoleSort(data) {
return request({
url: '/flowable/definition/updateProcKeyRoleSort',
method: 'post',
data: data
})
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -2,13 +2,13 @@
<div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
<transition name="sidebarLogoFade">
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
<img v-if="logo" src="logo/logo.png" class="sidebar-logo" style="width: 90%;"/>
<img v-if="logo" src="logo/logo.png" class="sidebar-logo" style="width: 80%;margin-top: 10px;"/>
<!--
<h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
-->
</router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/">
<img v-if="logo" src="logo/logo.png" class="sidebar-logo" style="height: 90%;"/>
<img v-if="logo" src="logo/logo.png" class="sidebar-logo" style="width: 80%;margin-top: 10px;"/>
<!--
<h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
-->

View File

@ -1,16 +1,46 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="名称" prop="name">
<el-form-item label="流程名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
placeholder="请输入流程名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="开始时间" prop="deployTime">
<el-form-item label="流程类型" prop="category">
<el-select
v-model="queryParams.category"
@keyup.enter.native="handleQuery"
placeholder="请选择流程类型"
clearable
>
<el-option
v-for="dict in dict.type.sys_process_category"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="流程角色" prop="roleId">
<el-select
v-model="queryParams.roleId"
@keyup.enter.native="handleQuery"
placeholder="请选择流程角色"
clearable
>
<el-option
v-for="(it,idx) in roleNodes"
:key="idx"
:label="it.roleName"
:value="it.roleId"
/>
</el-select>
</el-form-item>
<el-form-item label="开始时间" prop="deployTime" v-if="false">
<el-date-picker clearable size="small"
v-model="queryParams.deployTime"
type="date"
@ -54,6 +84,24 @@
v-hasPermi="['system:deployment:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-s-custom"
size="mini"
@click="handleRole"
>流程发起角色配置</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-medal-1"
size="mini"
@click="handleRoleOrder"
>流程发起排序设置</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-alert title="流程设计说明" type="success">
@ -69,15 +117,19 @@
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="流程编号" align="center" prop="deploymentId" :show-overflow-tooltip="true"/>
<el-table-column label="流程标识" align="center" prop="flowKey" :show-overflow-tooltip="true" />
<el-table-column label="流程分类" align="center" prop="category" />
<el-table-column label="流程名称" align="center" width="120" :show-overflow-tooltip="true">
<el-table-column label="流程分类" align="center" prop="category" >
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_process_category" :value="scope.row.category" />
</template>
</el-table-column>
<el-table-column label="流程名称" align="center" width="250" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-button type="text" @click="handleReadImage(scope.row.deploymentId)">
<span>{{ scope.row.name }}</span>
</el-button>
</template>
</el-table-column>
<el-table-column label="业务表单" align="center" :show-overflow-tooltip="true">
<el-table-column label="业务表单" align="center" width="100" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-button v-if="scope.row.formId" type="text" @click="handleForm(scope.row.formId)">
<span>{{ scope.row.formName }}</span>
@ -85,7 +137,7 @@
<label v-else></label>
</template>
</el-table-column>
<el-table-column label="流程版本" align="center">
<el-table-column label="流程版本" align="center" width="100">
<template slot-scope="scope">
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
</template>
@ -97,7 +149,7 @@
</template>
</el-table-column>
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180"/>
<el-table-column label="操作" width="250" fixed="right"class-name="small-padding fixed-width">
<el-table-column label="操作" width="250" fixed="right" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button @click="handleLoadXml(scope.row)" icon="el-icon-edit-outline" type="text" size="small">设计</el-button>
<el-button @click="handleAddForm(scope.row)" icon="el-icon-edit-el-icon-s-promotion" type="text" size="small" v-if="scope.row.formId == null"></el-button>
@ -221,17 +273,8 @@
</el-col>
</el-row>
</el-dialog>
<!-- &lt;!&ndash;流程设计器&ndash;&gt;-->
<!-- <el-dialog-->
<!-- title="流程配置"-->
<!-- :visible.sync="dialogVisible"-->
<!-- :close-on-press-escape="false"-->
<!-- :fullscreen=true-->
<!-- :before-close="handleClose"-->
<!-- append-to-body>-->
<!-- <Model :deployId="deployId"/>-->
<!-- </el-dialog>-->
<indexDrawer ref="indexDrawer"></indexDrawer>
<indexOrderDrawer ref="indexOrderDrawer"></indexOrderDrawer>
</div>
</template>
@ -244,13 +287,16 @@ import {
updateDeployment,
exportDeployment,
definitionStart,
flowXmlAndNode
flowXmlAndNode,
roleList
} from "@/api/flowable/definition";
import { getToken } from "@/utils/auth";
import { getForm, addDeployForm ,listForm } from "@/api/flowable/form";
import Parser from '@/components/parser/Parser'
import flow from '@/views/flowable/task/myProcess/send/flow'
import Model from './model';
import indexDrawer from "./indexDrawer.vue";
import indexOrderDrawer from "./indexOrderDrawer.vue";
export default {
name: "Definition",
@ -258,7 +304,9 @@ export default {
components: {
Parser,
flow,
Model
Model,
indexDrawer,
indexOrderDrawer
},
data() {
return {
@ -319,7 +367,8 @@ export default {
derivedFrom: null,
derivedFromRoot: null,
parentDeploymentId: null,
engineVersion: null
engineVersion: null,
roleId:null,
},
formQueryParams:{
pageNum: 1,
@ -337,12 +386,13 @@ export default {
//
form: {},
//
rules: {
}
rules: {},
roleNodes:[]
};
},
created() {
this.getList();
this.getRoleList();
},
activated() {
const time = this.$route.query.t;
@ -390,6 +440,11 @@ export default {
};
this.resetForm("form");
},
getRoleList(){
roleList({pageNum:1,pageSize:100,roleKey:'lc_'}).then(response => {
this.roleNodes = response.data;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
@ -541,6 +596,14 @@ export default {
this.$modal.msgSuccess("删除成功");
})
},
/** 流程发起角色设置 */
handleRole(){
this.$refs.indexDrawer.show();
},
/** 流程发起排序设置 */
handleRoleOrder(){
this.$refs.indexOrderDrawer.show();
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;

View File

@ -33,7 +33,7 @@
v-model="loginForm.code"
auto-complete="off"
placeholder="验证码"
style="width: 63%"
style="width: 68%"
@keyup.enter.native="handleLogin"
>
<svg-icon
@ -169,13 +169,13 @@ export default {
<style rel="stylesheet/scss" lang="scss">
.login-bg {
background-image: url("/images/bg.jpg");
background-image: url("/images/bg1.png");
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
opacity: 0.4;
/** opacity: 0.4; */
}
.login {
display: flex;
@ -197,6 +197,8 @@ export default {
background: #ffffff;
width: 400px;
padding: 25px 25px 5px 25px;
z-index: 9;
opacity: 0.9;
.el-input {
height: 38px;
input {
@ -215,7 +217,7 @@ export default {
color: #bfbfbf;
}
.login-code {
width: 33%;
width: 29%;
height: 38px;
float: right;
img {