提交 231f2ed0 authored 作者: kxjia's avatar kxjia

优化代码

......@@ -315,6 +315,11 @@
"isAttr": true,
"type": "String"
},
{
"name": "isRead",
"isAttr": true,
"type": "Boolean"
},
{
"name": "followUpDate",
"isAttr": true,
......
......@@ -26,6 +26,10 @@
expId?: string
async?: boolean
userName?: string
isRead?: boolean
isTransmit?: boolean
isReject?: boolean
isSend?: boolean
[key: string]: any
}
......@@ -43,7 +47,11 @@
const bpmnFormData = reactive<BpmnFormData>({
async: false,
userType: 'user'
userType: 'user',
isTransmit: true,
isReject: true,
isSend: true,
isRead: true,
});
const selectData = reactive<SelectData>({})
......@@ -109,20 +117,6 @@
}
}
// 获取用户列表
// const getUserList = async (params) => {
// try {
// loading.value = true;
// const userList = await defHttp.get({ url: "/sys/user/list", params });
// return userList;
// } catch (error) {
// console.error('获取用户列表失败:', error);
// return [];
// } finally {
// loading.value = false;
// }
// }
const formSchema: FormSchema[] = [
{
label: '异步',
......@@ -211,7 +205,7 @@
updateCustomElement("userType", "role")
emit('update', { candidateGroups, userType: 'role' })
if (bpmnFormData.userType !== 'role') {
if(bpmnFormData.userType !== 'role') {
bpmnFormData.userType = 'role'
isUser.value = false
updateCustomElement("userType", "role")
......@@ -253,7 +247,79 @@
emit('update', { priority })
}
}
}
},
{
label: '是否转阅',
field: 'isRead',
component: 'RadioGroup',
defaultValue: true,
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
disabled: props.readonly,
onChange: (isRead: boolean) => {
bpmnFormData.isRead = isRead
updateCustomElement("isRead", isRead)
emit('update', { isRead })
}
}
},
{
label: '是否转办',
field: 'isTransmit',
component: 'RadioGroup',
defaultValue: true,
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
disabled: props.readonly,
onChange: (isTransmit: boolean) => {
bpmnFormData.isTransmit = isTransmit
updateCustomElement("isTransmit", isTransmit)
emit('update', { isTransmit })
}
}
},
{
label: '是否可退',
field: 'isReject',
component: 'RadioGroup',
defaultValue: true,
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
disabled: props.readonly,
onChange: (isReject: boolean) => {
bpmnFormData.isReject = isReject
updateCustomElement("isReject", isReject)
emit('update', { isReject })
}
}
},
{
label: '是否发送',
field: 'isSend',
component: 'RadioGroup',
defaultValue: true,
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
disabled: props.readonly,
onChange: (isSend: boolean) => {
bpmnFormData.isSend = isSend
updateCustomElement("isSend", isSend)
emit('update', { isSend })
}
}
},
];
const [registerForm, { updateSchema, setFieldsValue, getFieldsValue, setProps }] = useForm({
......@@ -283,6 +349,58 @@
});
};
// 保存所有自定义属性(打包成 JSON)
const saveCustomProperties = (element: any, customData: Record<string, any>) => {
if (!modelerStore.modeler || !element) {
return false
}
try {
const modeling = modelerStore.modeler.get('modeling')
let targetElement = element
if (isProxy(element)) {
targetElement = toRaw(element)
}
// 将所有自定义属性转为 JSON 字符串存储
const customDataStr = JSON.stringify(customData)
modeling.updateProperties(targetElement, {
'customData': customDataStr
})
return true
} catch (error) {
console.error('保存自定义属性失败:', error)
return false
}
}
// 读取所有自定义属性
const getCustomProperties = (element: any): Record<string, any> => {
if (!element || !element.businessObject) {
return {}
}
try {
const customDataStr = element.businessObject.customData
if (customDataStr) {
return JSON.parse(customDataStr)
}
return {}
} catch (error) {
console.error('读取自定义属性失败:', error)
return {}
}
}
// 获取单个自定义属性
const getCustomProperty = (element: any, key: string, defaultValue: any = null) => {
const customProps = getCustomProperties(element)
return customProps[key] !== undefined ? customProps[key] : defaultValue
}
// 更新自定义流程节点/参数信息
const updateCustomElement = (key: string, value: any) => {
if (!modelerStore.modeler || !modelerStore.element) {
......@@ -291,13 +409,19 @@
}
try {
const taskAttr: Record<string, any> = {}
taskAttr[key] = value
const success = safeUpdateProperties(modelerStore.element, taskAttr)
// BPMN 标准属性列表(这些可以直接更新)
const standardProps = ['async', 'dueDate', 'priority', 'assignee', 'candidateGroups', 'userType']
if (!success) {
console.error('更新自定义属性失败')
if (standardProps.includes(key)) {
// 标准属性直接更新
const taskAttr: Record<string, any> = {}
taskAttr[key] = value
safeUpdateProperties(modelerStore.element, taskAttr)
} else {
// 自定义属性:先获取现有自定义属性,更新后统一保存
const currentCustomProps = getCustomProperties(modelerStore.element)
currentCustomProps[key] = value
saveCustomProperties(modelerStore.element, currentCustomProps)
}
} catch (error) {
console.error('更新自定义属性失败:', error)
......@@ -339,7 +463,11 @@
if (!modelerStore.element?.businessObject || modelerStore.element.type === 'bpmn:Process') {
return
}
const businessObject = modelerStore.element.businessObject
const element = modelerStore.element
const businessObject = element.businessObject
// 获取所有自定义属性
const customProps = getCustomProperties(element)
// 重置表单数据
const formData: BpmnFormData = {
......@@ -348,7 +476,12 @@
assignee: businessObject.assignee || '',
candidateGroups: businessObject.candidateGroups || '',
dueDate: businessObject.dueDate || '',
priority: businessObject.priority || 'medium'
priority: businessObject.priority || 'medium',
// 从自定义属性中读取
isRead: customProps.isRead !== undefined ? customProps.isRead : true,
isTransmit: customProps.isTransmit !== undefined ? customProps.isTransmit : true,
isReject: customProps.isReject !== undefined ? customProps.isReject : true,
isSend: customProps.isSend !== undefined ? customProps.isSend : true
}
isUser.value = formData.userType === "user"
......
......@@ -5,8 +5,9 @@
<div class="form-header">
<span class="form-title">当前待办<font color="red">[{{ editableNode?.name || '无' }}]</font></span>
<a-space>
<a-button v-if="props.showApprovalPanel" type="primary" ghost @click="handleApproval">审批</a-button>
<a-button v-else type="primary" ghost @click="handleSend">发送</a-button>
<a-button v-show="props.showApprovalPanel" type="primary" ghost @click="handleApproval">审批</a-button>
<a-button v-show="!props.showApprovalPanel" type="primary" ghost @click="handleSend">保存</a-button>
<a-button v-show="!props.showApprovalPanel" type="primary" ghost @click="handleSend">保存并发送</a-button>
<a-button v-show="!props.showApprovalPanel" type="primary" ghost @click="handleReject">驳回</a-button>
<a-button type="primary" ghost @click="handleTransmit">转办</a-button>
<a-button type="primary" ghost @click="handleRead">转阅</a-button>
......
<template>
<BasicDrawer
title="任务指派"
title="发送任务"
width="30%"
:closable="true"
:mask-closable="false"
......@@ -10,7 +10,7 @@
:header-style="{ backgroundColor: '#018ffb', borderBottom: '1px solid #e8eef2' }"
>
<div class="drawer-content" style="height: 80vh">
<a-card title="选择任务指派人" :bordered="false" class="assignee-card">
<a-card title="选择任务接收人" :bordered="false" class="assignee-card">
<a-form layout="vertical">
<a-form-item label="用户类型" required>
<a-radio-group v-model:value="localUserType" disabled>
......@@ -47,8 +47,12 @@
</a-form>
<div class="assignee-actions">
<a-space>
<a-button @click="handleClose">取消</a-button>
<a-button type="primary" :loading="confirmLoading" @click="handleConfirm">确认</a-button>
<a-button @click="handleClose" block style="width: 150px;">取消</a-button>
<a-button type="primary" style="width: 150px;"
:loading="confirmLoading"
@click="handleConfirm" block>
确认
</a-button>
</a-space>
</div>
</a-card>
......@@ -68,6 +72,11 @@ import { UserOutlined, TeamOutlined } from '@ant-design/icons-vue'
import UserSelectModal from '/@/components/Form/src/jeecg/components/modal/UserSelectModal.vue'
import RoleSelectModal from '/@/components/Form/src/jeecg/components/modal/RoleSelectModal.vue'
import { complete, getMyTaskFlow } from '/@/components/Process/api/todo'
import { queryUserById } from '/@/views/system/user/user.api'
import { queryRoleById } from '/@/views/system/role/role.api'
import { useMessage } from '/@/hooks/web/useMessage'
const { createConfirm } = useMessage()
const emit = defineEmits(['success', 'error', 'close'])
......@@ -81,7 +90,7 @@ const confirmLoading = ref(false)
const dataId = ref('')
const deployId = ref('')
const [registerBasicDrawer, { closeDrawer }] = useDrawerInner((data) => {
const [registerBasicDrawer, { closeDrawer }] = useDrawerInner(async (data) => {
if (data) {
dataId.value = data.dataId || ''
deployId.value = data.deployId || ''
......@@ -89,6 +98,11 @@ const [registerBasicDrawer, { closeDrawer }] = useDrawerInner((data) => {
localUserType.value = data.userType === 'role' ? 'role' : 'user'
assigneeId.value = data.assignee
assigneeDisplayName.value = data.assigneeName || ''
if(localUserType.value === 'user') {
await setUserInfo( assigneeId.value, data.assigneeName || '')
} else {
await setRoleInfo( assigneeId.value, data.assigneeName || '')
}
} else {
localUserType.value = data.userType === 'role' ? 'role' : 'user'
}
......@@ -124,29 +138,41 @@ const handleClose = () => {
}
const handleConfirm = async () => {
confirmLoading.value = true
try {
if (dataId.value && deployId.value) {
const myTaskFlow = await getMyTaskFlow({ deploymentId: deployId.value, dataId: dataId.value })
if (myTaskFlow?.taskId) {
await complete({
instanceId: myTaskFlow.procInsId || '',
deployId: myTaskFlow.deployId || '',
taskId: myTaskFlow.taskId,
dataId: dataId.value,
comment: '',
values: { approval: assigneeId.value, approvalType: localUserType.value },
})
createConfirm({
title: '确认发送任务吗?',
okText: '确认',
okType: 'danger',
iconType: 'warning',
onOk: async () => {
if (!assigneeId.value) {
message.warning('请选择任务接收人')
return
}
confirmLoading.value = true
try {
if (dataId.value && deployId.value) {
const myTaskFlow = await getMyTaskFlow({ deploymentId: deployId.value, dataId: dataId.value })
if (myTaskFlow?.taskId) {
await complete({
instanceId: myTaskFlow.procInsId || '',
deployId: myTaskFlow.deployId || '',
taskId: myTaskFlow.taskId,
dataId: dataId.value,
comment: '',
values: { approval: assigneeId.value, approvalType: localUserType.value },
})
}
}
emit('success', dataId.value)
message.success('任务发送成功')
handleClose()
} catch (error) {
emit('error', error)
} finally {
confirmLoading.value = false
}
}
}
emit('success', dataId.value)
message.success('任务发送成功')
handleClose()
} catch (error) {
emit('error', error)
} finally {
confirmLoading.value = false
}
})
}
const getAssigneeData = () => ({
......@@ -160,15 +186,32 @@ const setUserInfo = (userId: string, userNameValue: string) => {
assigneeId.value = userId
assigneeDisplayName.value = userNameValue
localUserType.value = 'user'
if(userNameValue) return
queryUserById({ id:userId }).then(res => {
if (res?.realname) {
assigneeDisplayName.value = res.realname || ''
}
})
}
const setRoleInfo = (roleId: string, roleNameValue: string) => {
assigneeId.value = roleId
assigneeDisplayName.value = roleNameValue
localUserType.value = 'role'
if(roleNameValue) return
queryRoleById({ id: roleId }).then(res => {
if (res) {
assigneeDisplayName.value = res.roleName || ''
}
})
}
defineExpose({ getAssigneeData, submit: handleConfirm, setUserInfo, setRoleInfo })
defineExpose({
getAssigneeData,
submit: handleConfirm,
setUserInfo,
setRoleInfo
})
</script>
<style scoped lang="scss">
......
......@@ -538,7 +538,10 @@
if (!showApprovalUi.value) {
await complete(submitData);
const result =await complete(submitData);
message.success('任务结束成功');
emit('success', result);
emit('callback');
return false;
}
......
......@@ -408,7 +408,7 @@
if (needStartFlow && record.deployId) {
try {
const formData = { dataId, dataName: 'id' };
const formData = { dataId, dataName: 'id',tasktitle:record.projectName };
const startResRaw = await definitionStartByDeployId(record.deployId, formData);
const startRes = pickStartResult(startResRaw);
......
......@@ -15,6 +15,8 @@
import { columns } from './StProblemCheck.data';
import { list, problemArchive } from './StProblemCheck.api';
const { createConfirm } = useMessage();
const props = defineProps({
currentFlowNode: { type: Object, default: () => ({}) },
});
......@@ -37,7 +39,14 @@
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
function handleArchive(record: Recordable) {
problemArchive({ id: record.id }).then(handleSuccess);
createConfirm({
title: '确认归档问题吗?',
okText: '确认',
okType: 'danger',
onOk: () => {
problemArchive({ id: record.id }).then(handleSuccess);
},
});
}
function handleSuccess() {
......@@ -46,7 +55,11 @@
}
function getTableAction(record) {
return [{ label: '问题归档', onClick: handleArchive.bind(null, record) }];
return [
{
label: '问题归档',
onClick: handleArchive.bind(null, record)
}];
}
</script>
......
......@@ -69,6 +69,7 @@ export const columns: BasicColumn[] = [
return render.renderDict(text, 'bpm_status');
},
sorter: true,
ifShow: false,
},
];
//查询数据
......
......@@ -22,7 +22,7 @@
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template>
</BasicTable>
<StProblemCheckModal @register="registerModal" @success="handleSuccess" :center="true" />
<StProblemCheckModal @register="registerModal" @success="handleSuccess" :centered="true" />
</div>
</template>
......@@ -35,6 +35,8 @@
import StProblemCheckModal from './components/StProblemCheckModal.vue';
import { columns, searchFormSchema } from './StProblemCheck.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate } from './StProblemCheck.api';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
const props = defineProps({
beforeFlowNode: { type: Object, default: () => ({}) },
......@@ -113,6 +115,7 @@
}
async function handleFlow(record: Recordable) {
emit('sendWorkFlow', record);
}
......
......@@ -25,6 +25,7 @@ enum Api {
saveRoleIndex = '/sys/sysRoleIndex/add',
editRoleIndex = '/sys/sysRoleIndex/edit',
queryIndexByCode = '/sys/sysRoleIndex/queryByCode',
queryById = '/sys/role/queryById',
}
/**
* 导出api
......@@ -186,3 +187,10 @@ export const saveOrUpdateRoleIndex = (params, isUpdate) => {
* @param params
*/
export const queryIndexByCode = (params) => defHttp.get({ url: Api.queryIndexByCode, params }, { isTransformResponse: false });
/**
*
* @param params
* @returns
*/
export const queryRoleById = (params) => defHttp.get({ url: Api.queryById, params });
......@@ -23,6 +23,8 @@ enum Api {
changePassword = '/sys/user/changePassword',
frozenBatch = '/sys/user/frozenBatch',
queryById = '/sys/user/queryById',
getQuitList = '/sys/user/getQuitList',
putCancelQuit = '/sys/user/putCancelQuit',
resetPassword = '/sys/user/resetPassword',
......@@ -265,4 +267,11 @@ export const saveOrUpdateAgent = (params) => {
export const userQuitAgent = (params) => {
return defHttp.put({ url: Api.userQuitAgent, params });
};
\ No newline at end of file
};
/**
*
* @param params
* @returns
*/
export const queryUserById = (params) => defHttp.get({ url: Api.queryById, params });
\ No newline at end of file
......@@ -83,5 +83,37 @@ public class ProcessConstants {
*/
public static final String PROCESS_ISAPPROVE = "isApprove";
/**
* 节点类型-发起
*/
public static final String TASK_TYPE_START = "发起";
/**
* 节点类型-参与
*/
public static final String TASK_TYPE_HAND = "参与";
/**
* 操作类型-转阅
*/
public static final String OPTION_TYPE_READ = "转阅";
/**
* 操作类型-审批
*/
public static final String OPTION_TYPE_APPROVE = "审批";
/**
* 操作类型-办理
*/
public static final String OPTION_TYPE_HAND = "办理";
/**
* 操作类型-转办
*/
public static final String OPTION_TYPE_ASSIGN = "转办";
/**
* 操作类型-驳回
*/
public static final String OPTION_TYPE_REJECT = "驳回";
}
......@@ -22,9 +22,11 @@ import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessS
import org.jeecg.modules.flowable.apithird.entity.SysUser;
import org.jeecg.modules.flowable.apithird.service.IFlowThirdService;
import org.jeecg.modules.flowable.common.constant.ProcessConstants;
import org.jeecg.modules.flowable.domain.dto.FlowNextDto;
import org.jeecg.modules.flowable.domain.dto.FlowProcDefDto;
import org.jeecg.modules.flowable.factory.FlowServiceFactory;
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
import org.jeecg.modules.flowable.service.IFlowTaskService;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import org.jeecg.modules.stm.my.service.IMyTaskFlowHisService;
import org.springframework.beans.BeanUtils;
......@@ -57,6 +59,7 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
private IMyTaskFlowHisService myTaskFlowHisService;
private static final String BPMN_FILE_SUFFIX = ".bpmn";
@Override
......@@ -363,7 +366,7 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
String curdate = sdf.format(cdate);
try {
String flowname ="";
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.deploymentId(DeployId) // 替换为你的deploymentId
.singleResult();
......@@ -371,6 +374,7 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
if (processDefinition != null) {
procDefId = processDefinition.getId();
// 使用 procDefId
flowname=processDefinition.getName();
}
......@@ -390,11 +394,35 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
// 流程发起时 跳过发起人节点
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
String OptionType="";
Boolean isnodeisApprove=false;
FlowNextDto flowtDto=flowTaskService.getFlowNodeType(task.getId());
if(flowtDto!=null){
isnodeisApprove=flowtDto.isNodeisApprove();
}
if(isnodeisApprove){
OptionType=ProcessConstants.OPTION_TYPE_APPROVE;//审核
}else{
OptionType=ProcessConstants.OPTION_TYPE_HAND;//办理
}
result.put("deployId", DeployId);
result.put("taskId", task.getId());
result.put("procInsId", task.getProcessInstanceId());
result.put("executionId", task.getExecutionId());
result.put("instanceId", task.getProcessInstanceId());
//需要返回 节点审批设置
if(isnodeisApprove){
result.put("nodeisApprove", flowtDto.isNodeisApprove());
}else{
result.put("nodeisApprove", false);
}
String Title=task.getName();
//
......@@ -413,15 +441,19 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
if(flowForm!=null){
String zdmc="";
String zdval="";
String tasktitle="";
if(variables.get("dataName")==null){
Map zdv=(Map)variables.get("_value");
zdmc=(String)zdv.get("dataName");
zdval=zdv.get("dataId").toString();
tasktitle=(String)zdv.get("tasktitle");
}else{
zdmc=(String)variables.get("dataName");
zdval=variables.get("dataId").toString();
tasktitle=(String)variables.get("tasktitle");
}
......@@ -469,11 +501,12 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
taskFlowHis.setOptionTime(cdate);
taskFlowHis.setOptionId(sysUser.getId());
taskFlowHis.setOptionType("操作类型");
taskFlowHis.setTaskType("发起");//发起 办理 转办 结束
taskFlowHis.setOptionType(OptionType);//审核 转办 转阅
taskFlowHis.setTaskType(ProcessConstants.TASK_TYPE_START);//发起 参与
taskFlowHis.setTaskName(task.getName());
taskFlowHis.setTaskTitle("标题");
taskFlowHis.setFlowName("");
taskFlowHis.setTaskTitle(tasktitle);
taskFlowHis.setFlowName(flowname);
myTaskFlowHisService.save(taskFlowHis);
......
......@@ -126,14 +126,33 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
if (Objects.isNull(task)) {
return Result.error("任务不存在");
}
String OptionType="";
Boolean isnodeisApprove=false;
FlowNextDto flowtDto=getFlowNodeType(task.getId());
if(flowtDto!=null){
isnodeisApprove=flowtDto.isNodeisApprove();
}
if(isnodeisApprove){
OptionType=ProcessConstants.OPTION_TYPE_APPROVE;//审核
}else{
OptionType=ProcessConstants.OPTION_TYPE_HAND;//办理
}
// 根据流程定义ID查询流程定义对象
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(task.getProcessDefinitionId())
.singleResult();
String deploymentId ="";
String flowname ="";
if (processDefinition != null) {
// 获取部署ID - 这就是你想要的deployId
deploymentId = processDefinition.getDeploymentId();
flowname=processDefinition.getName();
}
......@@ -146,6 +165,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
Map<String, Object> formValues = getProcessVariables(taskVo.getTaskId());
String zdmc="";
String zdval="";
String tasktitle="";
if(formValues.get("dataName")==null){
if(formValues.get("_value")!=null) {
......@@ -153,11 +173,13 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
Map zdv = (Map) formValues.get("_value");
zdmc = (String) zdv.get("dataName");
zdval = zdv.get("dataId").toString();
tasktitle = (String) zdv.get("tasktitle");
}
}else{
zdmc=(String)formValues.get("dataName");
zdval=formValues.get("dataId").toString();
tasktitle=(String)formValues.get("tasktitle");
}
......@@ -205,11 +227,12 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
taskFlowHis.setOptionTime(cdate);
taskFlowHis.setOptionId(loginUser.getId());
taskFlowHis.setOptionType("操作类型");
taskFlowHis.setTaskType("节点类型");//发起 办理 转办 结束
taskFlowHis.setOptionType(OptionType);//审核 转办 转阅
taskFlowHis.setTaskType(ProcessConstants.TASK_TYPE_HAND);//发起 参与
taskFlowHis.setTaskName(task.getName());
taskFlowHis.setTaskTitle("标题");
taskFlowHis.setFlowName("");
taskFlowHis.setTaskTitle(tasktitle);
taskFlowHis.setFlowName(flowname);
myTaskFlowHisService.save(taskFlowHis);
......@@ -356,6 +379,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
@Override
public void taskReject(FlowTaskVo flowTaskVo) {
if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
throw new CustomException("任务处于挂起状态!");
}
......@@ -449,6 +473,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
}));
// 设置驳回意见
currentTaskIds.forEach(item -> taskService.addComment(item, task.getProcessInstanceId(), FlowComment.REJECT.getType(), flowTaskVo.getComment()));
// 1. 获取当前运行的任务(源节点)
Task sourceTask = taskService.createTaskQuery().taskId(task.getId()).singleResult();
// 获取流程实例ID(可以从 sourceTask 中获取)
String processInstanceId = sourceTask.getProcessInstanceId();
try {
// 如果父级任务多于 1 个,说明当前节点不是并行节点,原因为不考虑多对多情况
......@@ -465,6 +493,83 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
.processInstanceId(task.getProcessInstanceId())
.moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)).changeState();
}
// 根据流程定义ID查询流程定义对象
/**
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(task.getProcessDefinitionId())
.singleResult();
*/
String deploymentId ="";
String flowname ="";
if (processDefinition != null) {
// 获取部署ID - 这就是你想要的deployId
deploymentId = processDefinition.getDeploymentId();
flowname=processDefinition.getName();
}
// 查询该流程实例下最新的运行中任务,即驳回后的新任务
Task newTask = taskService.createTaskQuery()
.processInstanceId(processInstanceId)
.active() // 只查询未完成的任务
.singleResult(); // 单节点流程通常只有一个当前任务
Long tformId = Long.parseLong(newTask.getFormKey());
FlowForm sysForm = flowFormService.getById(tformId); // 假设有这个方法
// 获取任务关联的本地变量
Map<String, Object> formValues = taskService.getVariables(newTask.getId());
String zdmc="";
String zdval="";
String tasktitle="";
String userType ="";
String approvalId="";
if(formValues.get("dataName")==null){
if(formValues.get("_value")!=null) {
Map zdv = (Map) formValues.get("_value");
zdmc = (String) zdv.get("dataName");
zdval = zdv.get("dataId").toString();
tasktitle = (String) zdv.get("tasktitle");
userType= (String) zdv.get("approvalType");
approvalId = zdv.get("approval").toString();
}
}else{
zdmc=(String)formValues.get("dataName");
zdval=formValues.get("dataId").toString();
tasktitle=(String)formValues.get("tasktitle");
userType=(String)formValues.get("approvalType");
approvalId=formValues.get("approval").toString();
}
//写入待办
//有了以上信息,可以向相关表写入 相关信息了
MyTaskFlow taskFlow=new MyTaskFlow();
taskFlow.setTaskId(newTask.getId());
taskFlow.setProcDefId(newTask.getProcessDefinitionId());
taskFlow.setProcInsId(newTask.getProcessInstanceId());
taskFlow.setExecutionId(newTask.getExecutionId());
if(zdval!=null&&!zdval.equals("")){
taskFlow.setTargetId(zdval);
}
taskFlow.setDeployId(deploymentId);
taskFlow.setFormTableName(sysForm.getFormTableName());
if(userType.equals("user")) {
taskFlow.setUid(approvalId);
} else {
taskFlow.setRoleid(approvalId);
}
taskFlow.setTaskDefinitionKey(newTask.getTaskDefinitionKey());
myTaskFlowService.save(taskFlow);
} catch (FlowableObjectNotFoundException e) {
throw new CustomException("未找到流程实例,流程可能已发生变化");
} catch (FlowableException e) {
......@@ -2521,6 +2626,12 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
@Override
@Transactional(rollbackFor = Exception.class)
public void assignReadTask(FlowTaskVo flowTaskVo) {
// 删除指定的历史流程实例
//historyService.deleteHistoricProcessInstance("778a6343-330f-11f1-a134-02423b4bce10");
// 删除指定的流程实例,需要传入流程实例ID和删除原因
//runtimeService.deleteProcessInstance("14e72dca-3324-11f1-8430-02423b4bce10", "测试数据清理");
SysUser loginUser = iFlowThirdService.getLoginUser();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论