Commit 667c2dab by 李小惠

Merge branch 'develop' of http://gitlab.sothing.top/843502640/jyzb_platformV2 into develop-lxh

parents a4a66b23 307cf403
......@@ -77,7 +77,7 @@ public class CounterSignListener implements ExecutionListener {
}
else if (Type.equals("2"))//指定角色
else if (Type.equals("5"))//指定角色
{
List<String> Roles=group.getApproverIds();
if (Roles.size()>0)//角色不为空
......@@ -103,7 +103,7 @@ public class CounterSignListener implements ExecutionListener {
}
else if (Type.equals("3"))//指定组织机构中的角色
else if (Type.equals("7"))//指定组织机构中的角色
{
// List<UserListDTO> userList=orgUserMapper.QueryUserByRoleIdAndOrg(role);
List<String> Roles=group.getApproverIds();
......@@ -138,7 +138,7 @@ public class CounterSignListener implements ExecutionListener {
}
}
else if (Type.equals("5"))//上级审批
else if (Type.equals("1"))//上级审批
{
LoginUser StartUser= LoginContext.getContext().getLoginUser();
List<UserListDTO> userList= orgUserMapper.QueryUserWithParentOrg(StartUser.getUserId().toString());
......
......@@ -121,7 +121,8 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
{
StartProcessInstanceDTO startProcessInstanceDTO=new StartProcessInstanceDTO();
startProcessInstanceDTO.setProcessDefinitionId(req.getProcessDefinitionId());
WorkProcessService.start(startProcessInstanceDTO);
String ProcessInstanceId= WorkProcessService.start(startProcessInstanceDTO);
order.setProcessId(ProcessInstanceId);
}
orderDetailService.saveBatch(detailList);
//设置总价格和总数量
......
......@@ -101,8 +101,9 @@ public class BpmnController {
}
@ApiOperation("通过流程定义id启动流程")
@PostMapping("start")
public ApiRes<Boolean> start(@RequestBody StartProcessInstanceDTO startProcessInstanceDTO) {
return WorkProcessService.start(startProcessInstanceDTO);
public ApiRes<String> start(@RequestBody StartProcessInstanceDTO startProcessInstanceDTO) {
return ApiRes.success(WorkProcessService.start(startProcessInstanceDTO));
}
@ApiOperation("通过流程实例查看审批记录")
@PostMapping("record")
......
......@@ -10,7 +10,7 @@ import lombok.Data;
@Data
public class UserInfo {
private String id;
private String userId;
private Long userId;
private String name;
private String type;
private String sex;
......
......@@ -97,7 +97,7 @@ public interface WorkProcessService {
*
* @return
*/
ApiRes<Boolean> start(StartProcessInstanceDTO startProcessInstanceDTO);
String start(StartProcessInstanceDTO startProcessInstanceDTO);
/**
* 通过流程定义id启动流程
......
......@@ -608,32 +608,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
return new Inout(id, id);
}
private BpmnModel assemBpmnModel(FlowChildNode childNode,
Integer groupId) {
BpmnModel bpmnModel = new BpmnModel();
List<SequenceFlow> sequenceFlows = Lists.newArrayList();
Map<String, ChildNode> childNodeMap = new HashMap<>();
bpmnModel.setTargetNamespace(groupId + "");
Process process = new Process();
process.setId(WorkFlowConstants.PROCESS_PREFIX);
bpmnModel.addProcess(process);
StartEvent startEvent = createStartEvent();
process.addFlowElement(startEvent);
String lastNode = null;
EndEvent endEvent = createEndEvent();
process.addFlowElement(endEvent);
List<FlowableListener> executionListeners = new ArrayList<>();
FlowableListener flowableListener = new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation("${processListener}");
executionListeners.add(flowableListener);
process.setExecutionListeners(executionListeners);
new BpmnAutoLayout(bpmnModel).execute();
return bpmnModel;
}
......@@ -662,14 +637,14 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
* @return
*/
@Override
public ApiRes<Boolean> start(StartProcessInstanceDTO processInstanceDto) {
public String start(StartProcessInstanceDTO processInstanceDto) {
try {
LoginUser StartUser=new LoginUser();
// StartUser.setUserId(Long.valueOf(1000));
// StartUser.setUserId(Long.valueOf("1694954953210986498"));
StartUser= LoginContext.getContext().getLoginUser();
//
JSONObject formData = processInstanceDto.getFormData();
Authentication.setAuthenticatedUserId(StartUser.getUserId().toString());
Map<String,Object> processVariables= new HashMap<>();
......@@ -703,24 +678,24 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
.businessStatus(BUSINESS_STATUS_1)
.start();
//手动完成第一个任务
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
Object ts=new Object();
if(task!=null){
taskService.complete(task.getId());
}
return ApiRes.success(true);
// Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
// Object ts=new Object();
// if(task!=null){
// taskService.complete(task.getId());
//
// }
return processInstance.getProcessInstanceId();
}
catch (Exception e){
Throwable cause = e.getCause();
if(cause instanceof WorkFlowException){
WorkFlowException workFlowException=(WorkFlowException)cause;
return ApiRes.failure(workFlowException.getMessage());
return workFlowException.getMessage();
}
e.printStackTrace();
return ApiRes.failure("流程不存在或已挂起");
return "流程不存在或已挂起";
}
}
......@@ -804,7 +779,15 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
*/
@Override
public PageResult<HistoryProcessInstanceVO> applyList(ApplyDTO applyDTO) {
LoginUser StartUser= LoginContext.getContext().getLoginUser();
LoginUser StartUser=new LoginUser();
if (applyDTO.getCurrentUserInfo().getUserId()!=null)//优先拿接口中的信息,方便调试
{
StartUser.setUserId(applyDTO.getCurrentUserInfo().getUserId());
}
else
{
StartUser= LoginContext.getContext().getLoginUser();
}
PageResult<HistoryProcessInstanceVO> pageResult=new PageResult<HistoryProcessInstanceVO>();
List<HistoricProcessInstance> historicProcessInstances =
historyService.createHistoricProcessInstanceQuery()
......@@ -862,15 +845,15 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
*/
@Override
public PageResult<TaskVO> toDoList(TaskDTO taskDTO) {
LoginUser StartUser=new LoginUser();
if (taskDTO.getCurrentUserInfo().getUserId()!=null)//优先拿接口中的信息,方便调试
{
StartUser.setUserId(taskDTO.getCurrentUserInfo().getUserId());
}
else
{
StartUser= LoginContext.getContext().getLoginUser();
}
LoginUser StartUser=new LoginUser();
if (taskDTO.getCurrentUserInfo().getUserId()!=null)//优先拿接口中的信息,方便调试
{
StartUser.setUserId(taskDTO.getCurrentUserInfo().getUserId());
}
else
{
StartUser= LoginContext.getContext().getLoginUser();
}
List<Task> tasks = taskService.createTaskQuery().taskAssignee(StartUser.getUserId().toString())
.includeProcessVariables()
......@@ -940,12 +923,25 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
for (HistoricTaskInstance task : tasks) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
Boolean flag = historicProcessInstance.getEndTime() == null ? false : true;
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
BpmnModel bpmnModel = null;
try {
bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
} catch (Exception e) {
// 处理获取BpmnModel异常的情况
e.printStackTrace(); // 可以将异常信息打印到日志中
// 可以在这里设置默认的BpmnModel或采取其他处理措施
}
Map<String, Object> processVariables = task.getProcessVariables();
TaskVO taskVO = new TaskVO();
taskVO.setTaskId(task.getId());
taskVO.setProcessInstanceId(task.getProcessInstanceId());
taskVO.setProcessDefinitionName(bpmnModel.getMainProcess().getName());
if (bpmnModel!=null)
{
taskVO.setProcessDefinitionName(bpmnModel.getMainProcess().getName());
}
taskVO.setStartUser(JSONObject.parseObject(MapUtil.getStr(processVariables, START_USER_INFO), new TypeReference<UserInfo>() {
}));
taskVO.setStartTime(historicProcessInstance.getStartTime());
......
......@@ -25,7 +25,9 @@ public class BpmnConvert {
@Resource
private IdWorker idWorker;
private static String id(String prefix) {
return prefix + "_" + UUID.randomUUID().toString().replace("-", "").toLowerCase();
}
public static BpmnModel toBpmn(JsonNode processNode, JsonNode formNode,String formName,String templateId) {
//表单存储
JSONObject jsonObject=new JSONObject();
......@@ -55,15 +57,24 @@ public class BpmnConvert {
bpmnModel.addProcess(process);
// 二.开始结束节点
StartEvent startEvent = new StartEvent();// 新建开始节点
startEvent.setId("_start");
startEvent.setId(id("start"));
startEvent.setInitiator("initiator");
process.addFlowElement(startEvent);// 绘制到图纸
EndEvent endEvent = new EndEvent(); // 新建结束节点
endEvent.setId("_end");// 绘制到图纸
endEvent.setId(id("end"));// 绘制到图纸
process.addFlowElement(endEvent);
// 三.递归绘制节点
drawNode("0",process, processNode,formNode, "_start", "_end", null);
drawNode("0",process, processNode,formNode, startEvent.getId(), endEvent.getId(), null);
List<FlowableListener> executionListeners =new ArrayList<>();
FlowableListener flowableListener=new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation("${processListener}");
executionListeners.add(flowableListener);
process.setExecutionListeners(executionListeners);
// 四.自动布局
new BpmnAutoLayout(bpmnModel).execute();
// 五.转xml
......@@ -88,6 +99,7 @@ public class BpmnConvert {
if (node.get("childNode").toString().equals("null")) {
// 没有下一步, 绘制指向结束的线
process.addFlowElement(createSequenceFlow(inout.getOut(), endId, null));
} else {
// 有下一步, 递归绘制下一个节点
drawNode("",process, node.get("childNode"),formJson, inout.getOut(), endId, null);
......@@ -211,12 +223,7 @@ public class BpmnConvert {
listener.setEvent(ExecutionListener.EVENTNAME_START);//监听任务启动
listener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
listener.setImplementation("${counterSignListener}");//启动角色分配监听事件
FlowableListener flowableListener = new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation("${processListener}");
taskListeners.add(listener);
taskListeners.add(flowableListener);
return taskListeners;
}
......@@ -247,6 +254,8 @@ public class BpmnConvert {
String condition = JsonToELConverter.convertToEL(conditionGroup);
//条件线路 根前端数据对接 内容为EL表达式
process.addFlowElement(createSequenceFlow(startId, endId, condition));
} else {
// 有子流程,递归绘制子流程
//解释JSON数据,转换为EL表达式
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论