Commit b41bafcd authored by 赵啸非's avatar 赵啸非

工作流相关开发与前端页面

parent bec90ada

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -53,6 +53,12 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......
......@@ -19,6 +19,8 @@ public class RequestTaskReq {
private String deployId;
private String procDefId;
private String userId;
private String dataKey;
......@@ -28,5 +30,6 @@ public class RequestTaskReq {
//设置审核人
private String assignee;
private Integer state;
}
......@@ -20,7 +20,9 @@ public class FlowNextPdu implements Serializable {
private String vars;
//指定人员
private List<SysUser> userList;
//指定租
private List<SysRole> roleList;
}
package com.mortals.xhx.common.pdu.flow;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 工作流任务
*
* @author: finegirl
* @date: 2021/7/31 23:38
*/
@Getter
@Setter
@ApiModel("工作流任务相关-返回参数")
public class FlowTaskVoPdu implements Serializable {
@ApiModelProperty("任务Id")
private String taskId;
@ApiModelProperty("用户Id")
private String userId;
@ApiModelProperty("任务意见")
private String comment;
@ApiModelProperty("流程实例Id")
private String instanceId;
@ApiModelProperty("节点")
private String targetKey;
@ApiModelProperty("流程变量信息")
private Map<String, Object> values;
@ApiModelProperty("审批人")
private String assignee;
@ApiModelProperty("候选人")
private List<String> candidateUsers;
@ApiModelProperty("审批组")
private List<String> candidateGroups;
}
package com.mortals.xhx.common.pdu.flow;
import lombok.Data;
import java.io.Serializable;
@Data
public class FlowUserTaskPdu implements Serializable {
private String id;
private String name;
}
......@@ -46,7 +46,7 @@ public interface IApiFlowDefinitionFeign extends IFeign {
/**
* 启动流程
*
* @param deployId 部署的流程 Id,来自 ACT_RE_PROCDEF
* @param procDefId 部署的流程 Id,来自 ACT_RE_PROCDEF
* @param userId 业务发起人
* @param dataKey 业务数据 Key,业务键,一般为表单数据的 ID,仅作为表单数据与流程实例关联的依据
* @param variables 变量集合,json对象
......@@ -54,7 +54,7 @@ public interface IApiFlowDefinitionFeign extends IFeign {
* @throws AppException
*/
@PostMapping("/flowable/def/start")
ApiRespPdu<String> start(@RequestParam(value = "deployId") String deployId,
ApiRespPdu<String> start(@RequestParam(value = "procDefId") String procDefId,
@RequestParam(value = "userId") String userId,
@RequestParam(value = "dataKey") String dataKey,
@RequestBody Map<String, Object> variables);
......
......@@ -85,8 +85,8 @@ public interface IApiFlowFeign extends IFeign {
* @param taskId 任务 Id,来自 ACT_RU_TASK
* @return
*/
@RequestMapping(value = "/flowable/api/task/{taskId}", method = RequestMethod.POST)
ApiRespPdu<String> task(@PathVariable(value = "taskId") String taskId);
@RequestMapping(value = "/flowable/api/task", method = RequestMethod.POST)
ApiRespPdu<String> task(@RequestParam(value = "taskId") String taskId);
/**
......@@ -97,7 +97,7 @@ public interface IApiFlowFeign extends IFeign {
* @param map 完成任务需要的条件参数
* @return
*/
@RequestMapping(value = "/flowable/api/task", method = RequestMethod.POST)
@RequestMapping(value = "/flowable/api/taskByAssignee", method = RequestMethod.POST)
ApiRespPdu<String> taskByAssignee(@RequestParam(value = "taskId") String taskId,
@RequestParam(value = "assignee") String assignee,
@RequestBody Map<String, Object> map);
......@@ -118,7 +118,7 @@ public interface IApiFlowFeign extends IFeign {
*
* @return
*/
@RequestMapping(value = "/flowable/api/getRuntimeDataId", method = RequestMethod.GET)
@RequestMapping(value = "/flowable/api/getRuntimeDataId", method = RequestMethod.POST)
ApiRespPdu<List<String>> getRuntimeDataId();
......
......@@ -4,9 +4,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.common.pdu.api.ApiRespPdu;
import com.mortals.xhx.common.pdu.flow.FlowNextPdu;
import com.mortals.xhx.common.pdu.flow.FlowProcDefPdu;
import com.mortals.xhx.common.pdu.flow.FlowTaskPdu;
import com.mortals.xhx.common.pdu.flow.*;
import com.mortals.xhx.feign.IFeign;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -50,11 +48,11 @@ public interface IApiFlowTaskFeign extends IFeign {
/**
* 取消申请
*
* @param flowTaskPdu
* @param flowTaskVoPdu
* @return
*/
@PostMapping("/flowable/task/stopProcess")
ApiRespPdu<String> stopProcess(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> stopProcess(@RequestBody FlowTaskVoPdu flowTaskVoPdu);
/**
......@@ -62,14 +60,12 @@ public interface IApiFlowTaskFeign extends IFeign {
* 获取的列表需要和业务系统数据合并
*
* @param userId
* @param pageNum
* @param pageSize
* @param pageInfo
* @return
*/
@PostMapping("/flowable/task/todoList")
ApiRespPdu<List<FlowTaskPdu>> todoList(@RequestParam(value = "userId") String userId,
@RequestParam(value = "pageNum") Integer pageNum,
@RequestParam(value = "pageSize") Integer pageSize);
ApiRespPdu<Result<FlowTaskPdu>> todoList(@RequestParam(value = "userId") String userId,
@RequestBody PageInfo pageInfo);
/**
......@@ -77,14 +73,12 @@ public interface IApiFlowTaskFeign extends IFeign {
* 获取的列表需要和业务系统数据合并
*
* @param userId
* @param pageNum
* @param pageSize
* @param pageInfo
* @return
*/
@PostMapping("/flowable/task/finishedList")
ApiRespPdu<List<FlowTaskPdu>> finishedList(@RequestParam(value = "userId") String userId,
@RequestParam(value = "pageNum") Integer pageNum,
@RequestParam(value = "pageSize") Integer pageSize);
ApiRespPdu<Result<FlowTaskPdu>> finishedList(@RequestParam(value = "userId") String userId,
@RequestBody PageInfo pageInfo);
/**
......@@ -111,29 +105,29 @@ public interface IApiFlowTaskFeign extends IFeign {
/**
* 审批任务
*
* @param flowTaskPdu
* @param flowTaskVoPdu
* @return
*/
@PostMapping("/flowable/task/complete")
ApiRespPdu<String> complete(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> complete(@RequestBody FlowTaskVoPdu flowTaskVoPdu);
/**
* 驳回任务
*
* @param flowTaskPdu
* @param flowTaskVoPdu
* @return
*/
@PostMapping("/flowable/task/reject")
ApiRespPdu<String> reject(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> reject(@RequestBody FlowTaskVoPdu flowTaskVoPdu);
/**
* 退回任务
*
* @param flowTaskPdu
* @param flowTaskVoPdu
* @return
*/
@PostMapping("/flowable/task/return")
ApiRespPdu<String> taskReturn(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> taskReturn(@RequestBody FlowTaskVoPdu flowTaskVoPdu);
/**
* 删除任务
......@@ -142,7 +136,7 @@ public interface IApiFlowTaskFeign extends IFeign {
* @return
*/
@PostMapping("/flowable/task/delete")
ApiRespPdu<String> delete(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> delete(@RequestBody FlowTaskVoPdu flowTaskPdu);
/**
* 认领/签收任务
......@@ -151,7 +145,7 @@ public interface IApiFlowTaskFeign extends IFeign {
* @return
*/
@PostMapping("/flowable/task/claim")
ApiRespPdu<String> claim(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> claim(@RequestBody FlowTaskVoPdu flowTaskPdu);
/**
* 取消认领/签收任务
......@@ -160,7 +154,7 @@ public interface IApiFlowTaskFeign extends IFeign {
* @return
*/
@PostMapping("/flowable/task/unClaim")
ApiRespPdu<String> unClaim(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> unClaim(@RequestBody FlowTaskVoPdu flowTaskPdu);
/**
* 委派任务
......@@ -169,7 +163,7 @@ public interface IApiFlowTaskFeign extends IFeign {
* @return
*/
@PostMapping("/flowable/task/delegate")
ApiRespPdu<String> delegateTask(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> delegateTask(@RequestBody FlowTaskVoPdu flowTaskPdu);
/**
* 转办任务
......@@ -178,17 +172,27 @@ public interface IApiFlowTaskFeign extends IFeign {
* @return
*/
@PostMapping("/flowable/task/assign")
ApiRespPdu<String> assignTask(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<String> assignTask(@RequestBody FlowTaskVoPdu flowTaskPdu);
/**
* 获取所有可回退的节点
*
* @param flowTaskVoPdu
* @return
*/
@PostMapping("/flowable/task/findReturnTaskList")
ApiRespPdu<List<FlowUserTaskPdu>> findReturnTaskList(@RequestBody FlowTaskVoPdu flowTaskVoPdu);
/**
* 获取下一节点
*
* @param flowTaskPdu
* @param flowTaskVoPdu
* @return
*/
@PostMapping("/flowable/task/nextFlowNode")
ApiRespPdu<FlowNextPdu> getNextFlowNode(@RequestBody FlowTaskPdu flowTaskPdu);
ApiRespPdu<FlowNextPdu> getNextFlowNode(@RequestBody FlowTaskVoPdu flowTaskVoPdu);
}
......
......@@ -68,22 +68,56 @@
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-basic</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>${flowable.version}</version>
</dependency>
<!--flowable工作流依赖-->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-rest</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-logic</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-conf</artifactId>
<version>${flowable.version}</version>
<exclusions>
<exclusion>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- &lt;!&ndash;flowable工作流依赖&ndash;&gt;
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>${flowable.version}</version>
</dependency>
<!-- flowable-engine -->
&lt;!&ndash; flowable-engine &ndash;&gt;
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>${flowable.version}</version>
</dependency>
<!-- flowable 集成依赖 rest,logic,conf -->
&lt;!&ndash; flowable 集成依赖 rest,logic,conf &ndash;&gt;
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-rest</artifactId>
......@@ -104,7 +138,7 @@
<artifactId>liquibase-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>-->
<dependency>
<groupId>org.liquibase</groupId>
......@@ -112,6 +146,12 @@
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.eweb4j</groupId>
<artifactId>fel</artifactId>
<version>0.8</version>
</dependency>
</dependencies>
......
......@@ -4,8 +4,7 @@ import com.mortals.framework.springcloud.boot.BaseWebApplication;
import com.mortals.xhx.exception.GlobalExceptionHandler;
import com.mortals.xhx.flowable.conf.AppDispatcherServletConfiguration;
import com.mortals.xhx.flowable.conf.ApplicationConfiguration;
import com.mortals.xhx.flowable.conf.DatabaseAutoConfiguration;
import org.flowable.ui.modeler.conf.DatabaseConfiguration;
import org.apache.commons.configuration.DatabaseConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
......
......@@ -8,8 +8,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
/**
* 全局异常拦截器
* @author: linjinp
* @create: 2019-05-08 11:16
**/
@ControllerAdvice
@ResponseBody
......
......@@ -25,13 +25,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
/**
* 示例代码,请勿在项目中使用
* @author: linjinp
* @create: 2019-11-05 14:55
**/
@RestController
*
*
* @author: finegirl
* @date: 2021/7/31 11:54
* @description:
*/
//Controller
@RequestMapping("/flowable/api")
public class FlowableApiController {
......@@ -88,6 +89,8 @@ public class FlowableApiController {
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
// 部署流程
repositoryService.createDeployment()
.name(modelData.getName())
......
......@@ -12,19 +12,21 @@ import org.flowable.bpmn.model.BpmnModel;
import org.flowable.engine.*;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.image.ProcessDiagramGenerator;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.ui.modeler.domain.Model;
import org.flowable.ui.modeler.serviceapi.ModelService;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author: finegirl
......@@ -39,6 +41,7 @@ public class ApiFlowImpl implements IApiFlowFeign {
@Resource
private ProcessEngine processEngine;
// 部署服务
@Resource
private RepositoryService repositoryService;
......@@ -94,8 +97,9 @@ public class ApiFlowImpl implements IApiFlowFeign {
String processName = modelData.getName() + ".bpmn20.xml";
// 部署流程
repositoryService.createDeployment()
Deployment deploy = repositoryService.createDeployment()
.name(modelData.getName())
.key("test")
.addBytes(processName, bpmnBytes)
.deploy();
......@@ -114,9 +118,9 @@ public class ApiFlowImpl implements IApiFlowFeign {
// 设置发起人
identityService.setAuthenticatedUserId(userId);
// 根据流程 ID 启动流程
ProcessInstance processInstance = runtimeService.startProcessInstanceById(deployId, dataKey);
log.info("流程启动成功:" + deployId + " processInstance:" + JSON.toJSONString(processInstance));
rsp.setData(JSON.toJSONString(processInstance));
runtimeService.startProcessInstanceById(deployId, dataKey);
log.info("流程启动成功:" + deployId );
//rsp.setData(JSON.toJSONString(processInstance));
return rsp;
}
......@@ -135,6 +139,7 @@ public class ApiFlowImpl implements IApiFlowFeign {
// 完成任务
taskService.complete(taskId, map);
log.info("任务完成:" + taskId + " " + new Date());
return rsp;
......@@ -142,32 +147,136 @@ public class ApiFlowImpl implements IApiFlowFeign {
@Override
public ApiRespPdu<String> deleteProcess(String processId) {
return null;
log.info("中止流程,processId:" + processId);
ApiRespPdu<String> rsp = new ApiRespPdu<>();
rsp.setCode(YesNoEnum.YES.getValue());
runtimeService.deleteProcessInstance(processId, "中止流程");
return rsp;
}
@Override
public ApiRespPdu<List<String>> getRuntimeDataId() {
return null;
ApiRespPdu<List<String>> rsp = new ApiRespPdu<>();
rsp.setCode(YesNoEnum.YES.getValue());
// 获取正在执行的任务列表
List<Execution> list = runtimeService.createExecutionQuery().onlyProcessInstanceExecutions().list();
List<String> idList = list.stream().map(item -> {
// 根据任务获取流程实例
// 获取流程实例种的业务 key
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(item.getProcessInstanceId()).singleResult();
return pi.getBusinessKey();
}).collect(Collectors.toList());
rsp.setData(idList);
return rsp;
}
@Override
public ApiRespPdu<List<Map<String, Object>>> getRuntimeBusinessKeyByUser(String userId) {
return null;
ApiRespPdu<List<Map<String, Object>>> rsp = new ApiRespPdu<>();
rsp.setCode(YesNoEnum.YES.getValue());
// 根据用户获取正在进行的任务
List<Task> tasks = taskService.createTaskQuery().taskAssignee(userId).list();
List<Map<String, Object>> idList = tasks.stream().map(task -> {
Map<String, Object> data = new HashMap<>();
// 根据任务获取流程实例
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
// 获取流程实例中的业务键
data.put("businessKey", processInstance.getBusinessKey());
// 获取任务 Id
data.put("taskId", task.getId());
// 流程定义名称
data.put("processInstanceName", processInstance.getProcessDefinitionName());
// 流程开始时间
data.put("startTime", processInstance.getStartTime());
return data;
}).collect(Collectors.toList());
log.info("userId :"+userId+"idList:"+JSON.toJSONString(idList));
rsp.setData(idList);
return rsp;
}
@Override
public ApiRespPdu<List<Map<String, Object>>> getRuntimeBusinessKeyByGroup(List<String> groupIds) {
return null;
ApiRespPdu<List<Map<String, Object>>> rsp = new ApiRespPdu<>();
rsp.setCode(YesNoEnum.YES.getValue());
if (ObjectUtils.isEmpty(groupIds)) {
rsp.setCode(YesNoEnum.NO.getValue());
rsp.setMsg("groupIds is null");
return rsp;
}
// 根据发起人获取正在执行的任务列表
List<Task> tasks = taskService.createTaskQuery().taskCandidateGroupIn(groupIds).list();
List<Map<String, Object>> idList = tasks.stream().map(task -> {
Map<String, Object> data = new HashMap<>();
// 根据任务获取流程实例
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
// 获取流程实例中的业务键
data.put("businessKey", processInstance.getBusinessKey());
// 获取任务 Id
data.put("taskId", task.getId());
// 流程定义名称
data.put("processInstanceName", processInstance.getProcessDefinitionName());
// 流程开始时间
data.put("startTime", processInstance.getStartTime());
return data;
}).collect(Collectors.toList());
rsp.setData(idList);
return rsp;
}
@Override
public ApiRespPdu<List<Map<String, Object>>> getHistoryByUser(String userId) {
return null;
ApiRespPdu<List<Map<String, Object>>> rsp = new ApiRespPdu<>();
rsp.setCode(YesNoEnum.YES.getValue());
// 根据用户,查询任务实例历史
List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskAssignee(userId).finished().orderByHistoricTaskInstanceEndTime().desc().list();
List<Map<String, Object>> historyList = list.stream().map(historicTaskInstance -> {
// 历史流程实例
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(historicTaskInstance.getProcessInstanceId()).singleResult();
// 获取需要的历史数据
Map<String, Object> historyInfo = new HashMap<>();
historyInfo.put("assignee", historicTaskInstance.getAssignee());
// 节点名称
historyInfo.put("nodeName", historicTaskInstance.getName());
// 流程开始时间
historyInfo.put("startTime", historicTaskInstance.getCreateTime());
// 节点操作时间(本流程节点结束时间)
historyInfo.put("endTime", historicTaskInstance.getEndTime());
// 流程定义名称
historyInfo.put("processName", hpi.getProcessDefinitionName());
// 流程实例 ID
historyInfo.put("processInstanceId", historicTaskInstance.getProcessInstanceId());
// 业务键
historyInfo.put("businessKey", hpi.getBusinessKey());
return historyInfo;
}).collect(Collectors.toList());
rsp.setData(historyList);
return rsp;
}
@Override
public ApiRespPdu<Boolean> checkProcessInstanceFinish(String processInstanceId) {
return null;
ApiRespPdu<Boolean> rsp = new ApiRespPdu<>();
rsp.setCode(YesNoEnum.YES.getValue());
boolean isFinish = false;
// 根据流程 ID 获取未完成的流程中是否存在此流程
long count = historyService.createHistoricProcessInstanceQuery().unfinished().processInstanceId(processInstanceId).count();
// 不存在说明没有结束
if (count == 0) {
isFinish = true;
}
rsp.setData(isFinish);
return rsp;
}
@Override
......@@ -178,7 +287,6 @@ public class ApiFlowImpl implements IApiFlowFeign {
rsp.setMsg(YesNoEnum.YES.getDesc());
String processInstanceId = taskService.createTaskQuery().taskId(taskId).singleResult().getProcessInstanceId();
runtimeService.setVariables(processInstanceId, map);
return rsp;
}
......@@ -225,11 +333,19 @@ public class ApiFlowImpl implements IApiFlowFeign {
@Override
public ApiRespPdu<String> getTaskInfo(String taskId) {
log.info("receive taskId:"+taskId);
ApiRespPdu<String> rsp = new ApiRespPdu<>();
rsp.setCode(YesNoEnum.YES.getValue());
rsp.setMsg(YesNoEnum.YES.getDesc());
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
rsp.setData(task.getProcessInstanceId());
if(!ObjectUtils.isEmpty(task)){
rsp.setData(task.getProcessInstanceId());
}else{
rsp.setCode(YesNoEnum.NO.getValue());
rsp.setMsg("taskinfo is null taskId:"+taskId);
}
return rsp;
}
......
......@@ -37,10 +37,11 @@ public class MyListener implements ExecutionListener {
public void notify(DelegateExecution delegateExecution) {
// 调用 runtimeService 示例
ProcessInstance processInstance = myListener.runtimeService.createProcessInstanceQuery().processInstanceId(delegateExecution.getProcessInstanceId()).singleResult();
System.out.println(processInstance.getProcessDefinitionId());
log.info(processInstance.getProcessDefinitionId());
// 获取页面配置参数的值
System.out.println(num.getExpressionText());
log.info("获取页面配置参数的值"+num.getExpressionText());
// 校验 okNum 是否已经存在
if (!delegateExecution.hasVariable("okNum")) {
......@@ -49,5 +50,14 @@ public class MyListener implements ExecutionListener {
// 已审核次数,审核一次 +1
int okNum = (int) delegateExecution.getVariable("okNum") + 1;
delegateExecution.setVariable("okNum", okNum);
log.info("okNum:"+okNum);
if(okNum==3){
//完成当前实例
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flowable.ui.common.security;
import org.flowable.idm.api.User;
import org.flowable.ui.common.model.RemoteUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import java.util.ArrayList;
import java.util.List;
/**
* Utility class for Spring Security.
*/
public class SecurityUtils {
private static User assumeUser;
private SecurityUtils() {
}
/**
* Get the login of the current user.
*/
public static String getCurrentUserId() {
User user = getCurrentUserObject();
if (user != null) {
return user.getId();
}
return null;
}
/**
* @return the {@link User} object associated with the current logged in user.
*/
public static User getCurrentUserObject() {
if (assumeUser != null) {
return assumeUser;
}
RemoteUser user = new RemoteUser();
user.setId("admin");
user.setDisplayName("Administrator");
user.setFirstName("Administrator");
user.setLastName("Administrator");
user.setEmail("admin@flowable.com");
user.setPassword("123456");
List<String> pris = new ArrayList<>();
pris.add(DefaultPrivileges.ACCESS_MODELER);
pris.add(DefaultPrivileges.ACCESS_IDM);
pris.add(DefaultPrivileges.ACCESS_ADMIN);
pris.add(DefaultPrivileges.ACCESS_TASK);
pris.add(DefaultPrivileges.ACCESS_REST_API);
user.setPrivileges(pris);
return user;
}
public static FlowableAppUser getCurrentFlowableAppUser() {
FlowableAppUser user = null;
SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext != null && securityContext.getAuthentication() != null) {
Object principal = securityContext.getAuthentication().getPrincipal();
if (principal instanceof FlowableAppUser) {
user = (FlowableAppUser) principal;
}
}
return user;
}
public static boolean currentUserHasCapability(String capability) {
FlowableAppUser user = getCurrentFlowableAppUser();
for (GrantedAuthority grantedAuthority : user.getAuthorities()) {
if (capability.equals(grantedAuthority.getAuthority())) {
return true;
}
}
return false;
}
public static void assumeUser(User user) {
assumeUser = user;
}
public static void clearAssumeUser() {
assumeUser = null;
}
}
///* Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//package org.flowable.ui.common.security;
//
//import org.flowable.idm.api.User;
//import org.flowable.ui.common.model.RemoteUser;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.context.SecurityContext;
//import org.springframework.security.core.context.SecurityContextHolder;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Utility class for Spring Security.
// */
//public class SecurityUtils {
//
// private static User assumeUser;
//
// private SecurityUtils() {
// }
//
// /**
// * Get the login of the current user.
// */
// public static String getCurrentUserId() {
// User user = getCurrentUserObject();
// if (user != null) {
// return user.getId();
// }
// return null;
// }
//
// /**
// * @return the {@link User} object associated with the current logged in user.
// */
// public static User getCurrentUserObject() {
// if (assumeUser != null) {
// return assumeUser;
// }
//
// RemoteUser user = new RemoteUser();
// user.setId("admin");
// user.setDisplayName("Administrator");
// user.setFirstName("Administrator");
// user.setLastName("Administrator");
// user.setEmail("admin@flowable.com");
// user.setPassword("123456");
// List<String> pris = new ArrayList<>();
// pris.add(DefaultPrivileges.ACCESS_MODELER);
// pris.add(DefaultPrivileges.ACCESS_IDM);
// pris.add(DefaultPrivileges.ACCESS_ADMIN);
// pris.add(DefaultPrivileges.ACCESS_TASK);
// pris.add(DefaultPrivileges.ACCESS_REST_API);
// user.setPrivileges(pris);
// return user;
// }
//
// public static FlowableAppUser getCurrentFlowableAppUser() {
// FlowableAppUser user = null;
// SecurityContext securityContext = SecurityContextHolder.getContext();
// if (securityContext != null && securityContext.getAuthentication() != null) {
// Object principal = securityContext.getAuthentication().getPrincipal();
// if (principal instanceof FlowableAppUser) {
// user = (FlowableAppUser) principal;
// }
// }
// return user;
// }
//
// public static boolean currentUserHasCapability(String capability) {
// FlowableAppUser user = getCurrentFlowableAppUser();
// for (GrantedAuthority grantedAuthority : user.getAuthorities()) {
// if (capability.equals(grantedAuthority.getAuthority())) {
// return true;
// }
// }
// return false;
// }
//
// public static void assumeUser(User user) {
// assumeUser = user;
// }
//
// public static void clearAssumeUser() {
// assumeUser = null;
// }
//
//}
spring:
main:
allow-bean-definition-overriding: true
\ No newline at end of file
......@@ -50,8 +50,13 @@
"eslint-plugin-vue": "7.2.0",
"less": "^3.0.4",
"less-loader": "^4.1.0",
"lint-staged": "10.5.3",
"node-sass": "^5.0.0",
"runjs": "4.4.2",
"sass": "1.32.0",
"sass-loader": "^10.1.0",
"script-ext-html-webpack-plugin": "2.1.5",
"svg-sprite-loader": "5.1.1",
"vue-formatter": "^0.0.8",
"vue-template-compiler": "^2.6.10"
},
......
......@@ -7,16 +7,12 @@ export function listDefinition(query) {
// 部署流程实例
export function definitionStart(procDefId,data) {
// return request({
// url: '/flowable/definition/start/' + procDefId,
// method: 'post',
// data: data
// })
return normalCallPost('/flowable/definition/start', {"procDefId": procDefId,data:data})
}
// 获取流程变量
export function getProcessVariables(taskId) {
return normalCallPost('/flowable/task/processVariables', {"taskId":taskId})
return normalCallPost('/task/process/processVariables', {"taskId":taskId})
// return request({
// url: '/flowable/task/processVariables/' + taskId,
// method: 'get'
......
......@@ -7,12 +7,6 @@ export function listForm(query,pageInfo) {
"/form/list",
{query:query,pageInfo:pageInfo}
)
// return request({
// url: '/flowable/form/list',
// method: 'get',
// params: query
// })
}
// 查询流程表单详细
......
import {normalCallPost} from '@/assets/utils/index';
//import da from "element-ui/src/locale/lang/da";
// 我的发起的流程
......@@ -21,11 +21,7 @@ export function complete(data) {
// 取消申请
export function stopProcess(data) {
// return request({
// url: '/flowable/task/stopProcess',
// method: 'post',
// data: data
// })
return normalCallPost('/task/process/stopProcess', data)
}
// 驳回任务
......
import {normalCallPost} from '@/assets/utils/index';
// 查询待办任务列表
export function todoList(query) {
......@@ -11,6 +11,7 @@ export function todoList(query) {
// 完成任务
export function complete(data) {
return normalCallPost('/task/process/complete', data)
// return request({
// url: '/flowable/task/complete',
// method: 'post',
......@@ -56,6 +57,7 @@ export function returnList(data) {
// 下一节点
export function getNextFlowNode(data) {
return normalCallPost('/task/process/nextFlowNode', {"data":JSON.stringify(data)})
// return request({
// url: '/flowable/task/nextFlowNode',
// method: 'post',
......
......@@ -150,7 +150,7 @@ export default {
default: () => {
return {
enable: false,
level: 1, // 1,仅区域
level:1, // 1,仅区域
}
},
},
......
......@@ -38,10 +38,10 @@ const router = new Router({
builder('flowable/task/record/index', 'flowable/task/record/index'),//流程申请
...restBuilder('task/process', 'flowable/task/process'), //我的流程
...restBuilder('task/todo', 'flowable/task/todo'), //代办列表
...restBuilder('device', 'device'), // 设备管理-连接历史
//在此添加业务模块
......
......@@ -441,6 +441,11 @@ export default {
type: "text",
label: "名称",
},
{
name: "area",
type: "cascader",
label: "区域",
},
],
columns: [
{
......
......@@ -68,33 +68,33 @@ export default {
mixins: [table],
methods: {
/** 查询流程表单列表 */
getList() {
this.loading = true;
listForm(this.queryParams).then((response) => {
this.formList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// getList() {
// this.loading = true;
// listForm(this.queryParams).then((response) => {
// this.formList = response.rows;
// this.total = response.total;
// this.loading = false;
// });
// },
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
formId: null,
formName: null,
formContent: null,
createTime: null,
updateTime: null,
createBy: null,
updateBy: null,
remark: null,
};
this.resetForm("form");
},
// cancel() {
// this.open = false;
// this.reset();
// },
// // 表单重置
// reset() {
// this.form = {
// formId: null,
// formName: null,
// formContent: null,
// createTime: null,
// updateTime: null,
// createBy: null,
// updateBy: null,
// remark: null,
// };
// this.resetForm("form");
// },
/** 表单配置信息 */
......
......@@ -140,12 +140,13 @@ export default {
},
/** 取消流程申请 */
handleStop(row) {
console.log(row);
const params = {
instanceId: row.procInsId,
};
stopProcess(params).then((res) => {
this.msgSuccess(res.msg);
this.getList();
this.$message.success(res.msg);
this.getData();
});
},
/** 流程流转记录 */
......@@ -315,7 +316,7 @@ export default {
},
{
prop: "version",
prop: "procDefVersion",
label: "流程版本",
},
......
......@@ -186,8 +186,6 @@ export default {
},
created() {
console.log("index",this.$route.query);
this.taskForm.deployId = this.$route.query && this.$route.query.deployId;
this.taskForm.taskId = this.$route.query && this.$route.query.taskId;
this.taskForm.procInsId = this.$route.query && this.$route.query.procInsId;
......@@ -203,6 +201,7 @@ export default {
this.getNextFlowNode(this.taskForm.taskId)
this.taskForm.deployId = null
}
//获取审批记录
this.getFlowRecordList( this.taskForm.procInsId, this.taskForm.deployId);
this.finished = this.$route.query && this.$route.query.finished
......@@ -226,6 +225,7 @@ export default {
// 发送请求,获取xml
console.log("发送请求,获取xml deployId:"+deployId);
readXml(deployId).then(res =>{
console.log(res);
this.xmlData = res.data
})
},
......@@ -265,8 +265,8 @@ export default {
getFlowRecordList(procInsId, deployId) {
console.log("流程流转记录 procInsId:"+procInsId+" deployId:"+deployId);
const params = {procInsId: procInsId, deployId: deployId}
flowRecord(params).then(res => {
console.log("flowRecord res:",res);
this.flowRecordList = res.data.flowList;
// 流程过程中不存在初始化表单 直接读取的流程变量中存储的表单值
if (res.data.formData) {
......@@ -274,6 +274,7 @@ export default {
this.formConfOpen = true
}
}).catch(res => {
console.log(2222);
this.goBack();
})
},
......@@ -291,6 +292,9 @@ export default {
// 提交流程申请时填写的表单存入了流程变量中后续任务处理时需要展示
getProcessVariables(taskId).then(res => {
// this.variables = res.data.variables;
console.log(res);
//console.log("variablesData",this.variablesData);
//let json=JSON.parse(res.data.data);
this.variablesData = res.data.variables;
this.variableOpen = true
});
......@@ -328,7 +332,7 @@ export default {
this.$refs["taskForm"].validate(valid => {
if (valid) {
complete(this.taskForm).then(response => {
this.msgSuccess(response.msg);
this.$message.success(response.msg);
this.goBack();
});
}
......@@ -373,6 +377,9 @@ export default {
},
/** 申请流程表单数据提交 */
submitForm(data) {
console.log("submitForm",data);
if (data) {
const variables = data.valData;
const formData = data.formData;
......@@ -382,7 +389,7 @@ export default {
variables.variables = formData;
// 启动流程并将表单数据加入流程变量
definitionStart(this.taskForm.procDefId, JSON.stringify(variables)).then(res => {
this.msgSuccess(res.msg);
this.$message.success(res.msg);
this.goBack();
})
}
......@@ -393,7 +400,7 @@ export default {
this.$refs["taskForm"].validate(valid => {
if (valid) {
rejectTask(this.taskForm).then(res => {
this.msgSuccess(res.msg);
this.$message.success(res.msg);
this.goBack();
});
}
......@@ -421,7 +428,7 @@ export default {
this.$refs["taskForm"].validate(valid => {
if (valid) {
returnTask(this.taskForm).then(res => {
this.msgSuccess(res.msg);
this.$message.success(res.msg);
this.goBack()
});
}
......
......@@ -289,7 +289,9 @@ export default {
that.form = res.data.entity;
})
}else {
if (formConfInDB) {
console.log("2222");
that.formConf = formConfInDB
}
}
......@@ -453,6 +455,7 @@ export default {
const script = vueScript(makeUpJs(this.formData, type))
const html = vueTemplate(makeUpHtml(this.formData, type))
const css = cssStyle(makeUpCss(this.formData))
return beautifier.html(html + script + css, beautifierConf.html)
},
showJson() {
......@@ -511,9 +514,17 @@ export default {
},
/** 表单基本信息 */
handleForm(){
console.log("表单基本信息");
// this.formData = {
// fields: deepClone(this.drawingList),
// }
this.formData = {
fields: deepClone(this.drawingList),
...this.formConf
}
console.log("表单JSON:",JSON.stringify(this.formData));
this.form.formContent = JSON.stringify(this.formData);
this.formOpen = true;
this.formTitle = "添加表单";
......
This diff is collapsed.
......@@ -52,6 +52,16 @@
<artifactId>spring-data-redis</artifactId>
</dependency>
<!--集成EasyExcel -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.10</version>
</dependency>
</dependencies>
</project>
......@@ -44,7 +44,7 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
this.doHandlerLog(platformMark, null, "", loginName, requestUrl, content, ip, new Date());
}
@Pointcut("execution(public * com.mortals.iot.module..*Controller.*(..))")
@Pointcut("execution(public * com.mortals.xhx..*Controller.*(..))")
public void accessLog() {
}
......
......@@ -25,7 +25,6 @@ import com.mortals.framework.springcloud.config.SpringBootVFS;
@Configuration
//@AutoConfigureAfter(DataSourceAutoConfiguration.class)
public class MybatisConfiguration extends AbstractMybatisConfiguration {
private static Log logger = LogFactory.getLog(MybatisConfiguration.class);
// 配置类型别名
......@@ -34,7 +33,6 @@ public class MybatisConfiguration extends AbstractMybatisConfiguration {
// 配置类型别名
@Value("${mybatis.root-path}")
private String rootPath;
private static final String ROOT_PATH_SPLIT = ",";
// 配置类型别名
@Value("${mybatis.type-aliases-package}")
......@@ -48,96 +46,32 @@ public class MybatisConfiguration extends AbstractMybatisConfiguration {
@Value("${mybatis.config-location}")
private String configLocation;
private final String PATH_SEPARATOR = "/";
// 提供SqlSeesion
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactoryBean(@Qualifier("dataSource") DataSource dataSource) {
return super.getSqlSessionFactoryBean(dataSource);
// return getSqlSessionFactoryBean(dataSource);
}
public SqlSessionFactory getSqlSessionFactoryBean(DataSource dataSource) {
try {
// 解决myBatis下 不能从嵌套jar文件中读取class的问题
VFS.addImplClass(SpringBootVFS.class);
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource);
// 读取配置
sessionFactoryBean.setTypeAliasesPackage(getTypeAliasesPackage());
//
Resource[] resources = new PathMatchingResourcePatternResolver().getResources(mapperLocations);
sessionFactoryBean.setMapperLocations(resources);
// //
Resource[] configLocations = new PathMatchingResourcePatternResolver().getResources(configLocation);
sessionFactoryBean.setConfigLocation(configLocations[0]);
// 添加插件 (改为使用配置文件加载了)
// sqlSessionFactoryBean.setPlugins(new
// Interceptor[]{pageHelper()});
return sessionFactoryBean.getObject();
} catch (IOException e) {
logger.error("mybatis resolver mapper*xml is error", e);
return null;
} catch (Exception e) {
logger.error("mybatis sqlSessionFactoryBean create error", e);
return null;
}
@Override
public String getTypeAliasesRootPackage() {
return rootPath;
}
public String getTypeAliasesPackage() {
if (StringUtils.isEmpty(typeAliasesPackage)) {
return "";
}
rootPath = rootPath.trim().replace(".", PATH_SEPARATOR);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
StringBuffer typeAliasesPackageStringBuffer = new StringBuffer();
try {
for (String location : typeAliasesPackage.split(ROOT_PATH_SPLIT)) {
if (StringUtils.isEmpty(location)) {
continue;
}
if (location.contains("*")) {
location = "classpath*:" + location.trim().replace(".", PATH_SEPARATOR);
location = getResources(resolver, location);
}
if (location.endsWith(PATH_SEPARATOR)) {
location = location.substring(0, location.length() - 1);
}
typeAliasesPackageStringBuffer.append(location + ROOT_PATH_SPLIT);
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
if (typeAliasesPackageStringBuffer.length() == 0) {
throw new RuntimeException(
"mybatis typeAliasesPackage 路径扫描错误!请检查applicationContext.xml@sqlSessionFactory配置!");
}
String allTypeAliasesPackage = typeAliasesPackageStringBuffer.toString().replace(PATH_SEPARATOR, ".");
logger.info("allTypeAliasesPackage:" + allTypeAliasesPackage);
return allTypeAliasesPackage;
@Override
public String getSqlMappers() {
return mapperLocations;
}
private String getResources(ResourcePatternResolver resolver, String location) throws IOException {
StringBuffer resourcePathStringBuffer = new StringBuffer();
for (Resource resource : resolver.getResources(location)) {
if (resource == null || resource.getURL() == null) {
continue;
}
String path = resource == null ? "" : resource.getURL().getPath();
path = URLDecoder.decode(path, "UTF-8");// 对URL进行解码
path = path.replaceAll("\\\\", PATH_SEPARATOR);// 将所有反斜杠(\)替换成正斜杠(/)
if (StringUtils.isEmpty(path) || path.indexOf(rootPath) == -1) {
continue;
}
if (path.endsWith(PATH_SEPARATOR)) {
path = path.substring(0, path.length() - 1);
}
resourcePathStringBuffer.append(path.substring(path.indexOf(rootPath))).append(ROOT_PATH_SPLIT);
}
return resourcePathStringBuffer.toString();
@Override
public String getMybatisConfig() {
return configLocation;
}
@Override
public String getTypeAliasesPackage() {
logger.info("typeAliasesPackage:"+typeAliasesPackage);
return typeAliasesPackage;
}
}
\ No newline at end of file
......@@ -70,9 +70,9 @@ public class AreaController extends BaseCRUDJsonMappingController<AreaService, A
if (form.getQuery().getStatus() == null) {
form.getQuery().setStatus(YesNo.YES.getValue());
}
if(StringUtils.isEmpty(form.getQuery().getName())){
form.getQuery().setLevel(AreaLevelEnum.PROVINCE.getValue());
}
// if(StringUtils.isEmpty(form.getQuery().getName())){
// form.getQuery().setLevel(AreaLevelEnum.PROVINCE.getValue());
// }
return super.list(request, response, form);
}catch(Exception e){
log.error("查询区域信息列表错误",e);
......
package com.mortals.xhx.common.code;
import com.mortals.framework.common.IBaseEnum;
import java.util.LinkedHashMap;
import java.util.Map;
public enum FlowStatusEnum implements IBaseEnum{
FLOW_RUNNING(1, "进行中"),
FLOW_FINISH(2, "已完成");
private int value;
private String desc;
FlowStatusEnum(int value, String desc) {
this.value = value;
this.desc = desc;
}
@Override
public int getValue() {
return this.value;
}
public String getDesc() {
return desc;
}
public static FlowStatusEnum getByValue(int value) {
for (FlowStatusEnum YesNoEnum : FlowStatusEnum.values()) {
if (YesNoEnum.getValue() == value) {
return YesNoEnum;
}
}
return null;
}
/**
* 获取Map集合
* @param eItem 不包含项
* @return
*/
public static Map<String,String> getEnumMap(int... eItem) {
Map<String,String> resultMap= new LinkedHashMap<String,String>();
for (FlowStatusEnum item : FlowStatusEnum.values()) {
try{
boolean hasE = false;
for (int e : eItem){
if(item.getValue()==e){
hasE = true;
break;
}
}
if(!hasE){
resultMap.put(item.getValue()+"", item.getDesc());
}
}catch(Exception ex){
}
}
return resultMap;
}
}
package com.mortals.xhx.common.excel.annotation;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface ExcelAttribute {
/**
* 导出到Excel中的名字.
*/
String name();
/**
* 配置列的名称,对应A,B,C,D....
*/
String column();
/**
* 提示信息
*/
String prompt() default "";
/**
* 列宽
*/
String colWidth() default "4000";
/**
* 设置只能选择不能输入的列内容.
*/
String[] combo() default {};
/**
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
*/
boolean isExport() default true;
}
\ No newline at end of file
package com.mortals.xhx.common.excel.annotation;
import java.lang.annotation.*;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface ExcelElement {
/**
*
* 默认属性
* @return String 返回类型
* @throws
*/
String value() default "";
}
package com.mortals.xhx.common.excel.annotation;
import java.lang.annotation.*;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface ExcelID {
/**
*
* 默认属性
* @return String 返回类型
* @throws
*/
String value() default "";
}
package com.mortals.xhx.common.excel.config;
/**
* @描述
* @创建人 zxfei
* @创建时间 2021/3/4
* @修改人和其它信息
*/
public enum ElementTypePath {
SET("java.util.Set"),MAP("java.util.Map"),LIST("java.util.List");
private String path;
private ElementTypePath(String path){
this.path = path;
}
/**
*
* 获取元素
* @param path
* @return ElementTypePath 返回类型
* @throws
*/
public static ElementTypePath getElementTypePath(String path){
for(ElementTypePath elementTypePath:ElementTypePath.values()){
if(elementTypePath.path.equals(path)){
return elementTypePath;
}
}
return null;
}
@SuppressWarnings("static-access")
@Override
public String toString() {
return this.valueOf(path).getPath();
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
package com.mortals.xhx.common.excel.core;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import java.util.List;
import java.util.Map;
/**
*
* 定义需要重写的细节
* @author 神盾局
* @date 2016年8月9日 下午3:26:55
*
* @param <T>
*/
public abstract class AbstractExcelUtil<T> implements IExcelUtil<T>{
public abstract void createHeader(HSSFWorkbook wb, HSSFSheet sheet, Map<String, String> configFieldMap);
public abstract void createHeaderFlat(HSSFWorkbook wb, HSSFSheet sheet, Map<String, String> configFieldMap);
public abstract void createRow(HSSFWorkbook wb,Object t,HSSFSheet sheet);
/**
* 填充定制化数据
* @param wb
* @param t
* @param sheet
*/
public abstract void createRowFlat(HSSFWorkbook wb,Object t,HSSFSheet sheet);
public abstract int mergedRegio(Object t,HSSFSheet sheet,int rowStart);
public abstract List<T> dispatch(Sheet sheet);
}
package com.mortals.xhx.common.excel.core;
import lombok.SneakyThrows;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @描述
* @创建人 zxfei
* @创建时间 2021/3/4
* @修改人和其它信息
*/
public abstract class AbstractExcelUtils<T> extends AbstractExcelUtil<T> {
@SneakyThrows
@Override
public List<T> importExcel(String sheetName, String fileName, InputStream input) {
List<T> list = null;
try {
Workbook workbook = WorkbookFactory.create(input);
Sheet sheet = workbook.getSheetAt(0);
list = dispatch(sheet);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
@SuppressWarnings("unchecked")
@Override
public boolean exportExcel(List<T> list, String sheetName, OutputStream output, Map<String, String> configFieldMap) {
//此处 对类型进行转换
List<T> ilist = new ArrayList<>();
for (T t : list) {
ilist.add(t);
}
List<T>[] lists = new ArrayList[1];
lists[0] = ilist;
String[] sheetNames = new String[1];
sheetNames[0] = sheetName;
return exportExcel(lists, sheetNames, output, configFieldMap);
}
@Override
public boolean exportExcel(List<T>[] lists, String[] sheetNames, OutputStream output, Map<String, String> configFieldMap) {
if (lists.length != sheetNames.length) {
System.out.println("数组长度不一致");
return false;
}
// 创建excel工作簿
HSSFWorkbook wb = ExcelTool.createWorkbook();
// 创建第一个sheet(页),命名为 new sheet
for (int i = 0; i < lists.length; i++) {
List<T> list = lists[i];
ExcelTool.setNum(0);
// 产生工作表对象
HSSFSheet sheet = ExcelTool.createSheet(i, sheetNames[i]);
// 创建表头
createHeader(wb, sheet, configFieldMap);
// 写入数据
int rowStart = 1;
for (T t : list) {
createRow(wb, t, sheet);
ExcelTool.setNum(ExcelTool.getNum() + 1);
// rowStart = mergedRegio(t, sheet, rowStart);
}
}
try {
output.flush();
wb.write(output);
output.close();
return true;
} catch (IOException e) {
e.printStackTrace();
System.out.println("Output is closed ");
return false;
}
}
@SuppressWarnings("unchecked")
@Override
public boolean exportExcelFlat(List<T> list, String sheetName, OutputStream output, Map<String, String> configFieldMap) {
//此处 对类型进行转换
List<T> ilist = new ArrayList<>();
for (T t : list) {
ilist.add(t);
}
List<T>[] lists = new ArrayList[1];
lists[0] = ilist;
String[] sheetNames = new String[1];
sheetNames[0] = sheetName;
return exportExcelFlat(lists, sheetNames, output, configFieldMap);
}
@Override
public boolean exportExcelFlat(List<T>[] lists, String[] sheetNames, OutputStream output, Map<String, String> configFieldMap) {
if (lists.length != sheetNames.length) {
System.out.println("数组长度不一致");
return false;
}
//这里创建工作簿和sheet 构建初始化的模板
// 创建excel工作簿
HSSFWorkbook wb = ExcelTool.createWorkbook();
List<T> list = lists[0];
// 产生工作表对象及其表名
HSSFSheet sheet = ExcelTool.createSheet(0, sheetNames[0]);
ExcelTool.setNum(0);
// 创建第一行与第二行相关模板数据
createHeaderFlat(wb, sheet, configFieldMap);
//创建第三行表调数据
ExcelTool.setNum(2);
// 创建表头
createHeader(wb, sheet, configFieldMap);
// 填充写入数据
for (T t : list) {
//填充第一行与第二行数据
createRowFlat(wb, t, sheet);
//填充第三行以后数据
createRow(wb, t, sheet);
ExcelTool.setNum(ExcelTool.getNum() + 1);
}
//
// // 创建excel工作簿
// HSSFWorkbook wb = ExcelTool.createWorkbook();
// // 创建第一个sheet(页),命名为 new sheet
// for (int i = 0; i < lists.length; i++) {
// List<T> list = lists[i];
// ExcelTool.setNum(2);
// // 产生工作表对象
// HSSFSheet sheet = ExcelTool.createSheet(i, sheetNames[i]);
// // 创建表头
// createHeader(wb, sheet, configFieldMap);
// // 写入数据
// for (T t : list) {
// createRow(wb, t, sheet);
// ExcelTool.setNum(ExcelTool.getNum() + 1);
//
// }
//
// }
try {
output.flush();
wb.write(output);
output.close();
return true;
} catch (IOException e) {
e.printStackTrace();
System.out.println("Output is closed ");
return false;
}
}
}
package com.mortals.xhx.common.excel.core;
import com.mortals.xhx.common.excel.annotation.ExcelAttribute;
import com.mortals.xhx.common.excel.annotation.ExcelElement;
import com.mortals.xhx.common.excel.config.ElementTypePath;
import org.apache.poi.hssf.usermodel.DVConstraint;
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.util.CellRangeAddressList;
import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.List;
/**
* @描述
* @创建人 zxfei
* @创建时间 2021/3/4
* @修改人和其它信息
*/
public abstract class AbstractExcelUtilss<T> extends AbstractExcelUtils<T> {
/**
*
* 获取所有字段
* @param clazz
* @param listField
* @return List<Field> 返回类型
* @throws
*/
protected List<Field> getAllField(Class<?> clazz, List<Field> listField) {
if (listField == null) {
listField = new ArrayList<>();
}
// 获取所有属性
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
Type fieldType = field.getType();
if (field.isAnnotationPresent(ExcelAttribute.class)) {
listField.add(field);
// 类名,属性名
} else if (field.isAnnotationPresent(ExcelElement.class)) {
switch (ElementTypePath.getElementTypePath(fieldType.getTypeName())) {
case SET:
case LIST:
Type genericFieldType = field.getGenericType();
getAllField(getClass(genericFieldType, 0), listField);
break;
case MAP:
listField.add(field);
break;
default:
getAllField(field.getClass(), null);
break;
}
}
}
return listField;
}
/**
*
* 得到泛型类对象 @param type @param i @return Class 返回类型 @throws
*/
@SuppressWarnings("rawtypes")
protected static Class getClass(Type type, int i) {
if (type instanceof ParameterizedType) { // 处理泛型类型
return getGenericClass((ParameterizedType) type, i);
} else if (type instanceof TypeVariable) {
return (Class) getClass(((TypeVariable) type).getBounds()[0], 0); // 处理泛型擦拭对象
} else {// class本身也是type,强制转型
return (Class) type;
}
}
@SuppressWarnings("rawtypes")
private static Class getGenericClass(ParameterizedType parameterizedType, int i) {
Object genericClass = parameterizedType.getActualTypeArguments()[i];
if (genericClass instanceof ParameterizedType) { // 处理多级泛型
return (Class) ((ParameterizedType) genericClass).getRawType();
} else if (genericClass instanceof GenericArrayType) { // 处理数组泛型
return (Class) ((GenericArrayType) genericClass).getGenericComponentType();
} else if (genericClass instanceof TypeVariable) { // 处理泛型擦拭对象
return (Class) getClass(((TypeVariable) genericClass).getBounds()[0], 0);
} else {
return (Class) genericClass;
}
}
/**
* 将EXCEL中A,B,C,D,E列映射成0,1,2,3
*
* @param col
*/
protected static int getExcelCol(String col) {
col = col.toUpperCase();
// 从-1开始计算,字母重1开始运算。这种总数下来算数正好相同。
int count = -1;
char[] cs = col.toCharArray();
for (int i = 0; i < cs.length; i++) {
count += (cs[i] - 64) * Math.pow(26, cs.length - 1 - i);
}
return count;
}
/**
* 设置单元格上提示
*
* @param sheet
* 要设置的sheet.
* @param promptTitle
* 标题
* @param promptContent
* 内容
* @param firstRow
* 开始行
* @param endRow
* 结束行
* @param firstCol
* 开始列
* @param endCol
* 结束列
* @return 设置好的sheet.
*/
protected static HSSFSheet setHSSFPrompt(HSSFSheet sheet, String promptTitle, String promptContent, int firstRow,
int endRow, int firstCol, int endCol) {
// 构造constraint对象
DVConstraint constraint = DVConstraint.createCustomFormulaConstraint("DD1");
// 四个参数分别是:起始行、终止行、起始列、终止列
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
// 数据有效性对象
HSSFDataValidation data_validation_view = new HSSFDataValidation(regions, constraint);
data_validation_view.createPromptBox(promptTitle, promptContent);
sheet.addValidationData(data_validation_view);
return sheet;
}
/**
* 设置某些列的值只能输入预制的数据,显示下拉框.
*
* @param sheet
* 要设置的sheet.
* @param textlist
* 下拉框显示的内容
* @param firstRow
* 开始行
* @param endRow
* 结束行
* @param firstCol
* 开始列
* @param endCol
* 结束列
* @return 设置好的sheet.
*/
protected static HSSFSheet setHSSFValidation(HSSFSheet sheet, String[] textlist, int firstRow, int endRow,
int firstCol, int endCol) {
// 加载下拉列表内容
DVConstraint constraint = DVConstraint.createExplicitListConstraint(textlist);
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
// 数据有效性对象
HSSFDataValidation data_validation_list = new HSSFDataValidation(regions, constraint);
sheet.addValidationData(data_validation_list);
return sheet;
}
}
package com.mortals.xhx.common.excel.core;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* @描述
* @创建人 zxfei
* @创建时间 2021/3/4
* @修改人和其它信息
*/
public class ExcelTool {
//当前行数
private static int num = 0;
private static HSSFWorkbook wb;
private static HSSFCell cell;
private static HSSFRow row;
public static HSSFWorkbook createWorkbook() {
wb = new HSSFWorkbook();
return wb;
}
/**
* 创建一个sheet
*
* @param sheetname
* @return HSSFSheet 返回类型
* @throws
*/
public static HSSFSheet createSheet(int ii, String sheetname) {
// 创建excel工作簿
HSSFSheet sheet = wb.createSheet();
wb.setSheetName(ii, sheetname);
return sheet;
}
/**
* 创建一行
*
* @param sheet
* @return HSSFRow 返回类型
* @throws
*/
public static HSSFRow createRow(HSSFSheet sheet) {
row = sheet.createRow(num);
num++;
return row;
}
/**
* 创建一格
*
* @param row
* @param col
* @return HSSFCell 返回类型
* @throws
*/
public static HSSFCell createCell(HSSFRow row, int col) {
cell = row.createCell(col);// 创建cell
return cell;
}
/**
* 获取合并单元格的值
*
* @param sheet
* @param row
* @param column
* @return
*/
public static String getMergedRegionValue(Sheet sheet, int row, int column) {
int sheetMergeCount = sheet.getNumMergedRegions();
for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();
if (row >= firstRow && row <= lastRow) {
if (column >= firstColumn && column <= lastColumn) {
Row fRow = sheet.getRow(firstRow);
Cell fCell = fRow.getCell(firstColumn);
return getCellValue(fCell);
}
}
}
return null;
}
/**
* 判断指定的单元格是否是合并单元格
*
* @param sheet
* @param row
* @param column
* @return
*/
public static boolean isMergedRegion(Sheet sheet, int row, int column) {
int sheetMergeCount = sheet.getNumMergedRegions();
for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();
if (row >= firstRow && row <= lastRow) {
if (column >= firstColumn && column <= lastColumn) {
return true;
}
}
}
return false;
}
/**
* 获取单元格的值
*
* @param cell
* @return
*/
public static String getCellValue(Cell cell) {
if (cell == null)
return "";
if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
return cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
return String.valueOf(cell.getBooleanCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
return cell.getCellFormula();
} else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
return String.valueOf(cell.getNumericCellValue());
}
return "";
}
public static int getNum() {
return num;
}
public static void setNum(int num) {
ExcelTool.num = num;
}
public static HSSFWorkbook getWb() {
return wb;
}
public static void setWb(HSSFWorkbook wb) {
ExcelTool.wb = wb;
}
public static HSSFCell getCell() {
return cell;
}
public static void setCell(HSSFCell cell) {
ExcelTool.cell = cell;
}
public static HSSFRow getRow() {
return row;
}
public static void setRow(HSSFRow row) {
ExcelTool.row = row;
}
}
package com.mortals.xhx.common.excel.core;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
* @描述
* @创建人 zxfei
* @创建时间 2021/3/4
* @修改人和其它信息
*/
public interface IExcelUtil<T> {
/**
*
* 构建一个导入导出工具
* @param clazz 一个类类型
* @return IExcelUtil<T> 返回类型
*/
IExcelUtil<T> build(Class<T> clazz);
/**
*
* 数据导出
* @param sheetName
* @param input
* @return List<T> 导出数据
*/
List<T> importExcel(String sheetName,String fileName, InputStream input);
/**
*
* 导出到一个 sheet中
* @param list
* @param sheetName
* @param output
* @return boolean
*/
boolean exportExcel(List<T> list, String sheetName, OutputStream output, Map<String, String> configFieldMap);
/**
*
* 导出到多个 sheet中
* @param lists
* @param sheetNames
* @param output
* @return boolean
*/
boolean exportExcel(List<T> lists[], String sheetNames[], OutputStream output,Map<String, String> configFieldMap);
/**
*
* 导出到一个 sheet中
* @param list
* @param sheetName
* @param output
* @return boolean
*/
boolean exportExcelFlat(List<T> list, String sheetName, OutputStream output, Map<String, String> configFieldMap);
/**
*
* 导出到多个 sheet中
* @param lists
* @param sheetNames
* @param output
* @return boolean
*/
boolean exportExcelFlat(List<T> lists[], String sheetNames[], OutputStream output,Map<String, String> configFieldMap);
}
package com.mortals.xhx.common.excel.util;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* @描述
* @创建人 zxfei
* @创建时间 2021/3/4
* @修改人和其它信息
*/
@Deprecated
public class ExceMergedRegion {
/**
* 获取合并单元格的值
*
* @param sheet
* @param row
* @param column
* @return
*/
public String getMergedRegionValue(Sheet sheet, int row, int column) {
int sheetMergeCount = sheet.getNumMergedRegions();
for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();
if (row >= firstRow && row <= lastRow) {
if (column >= firstColumn && column <= lastColumn) {
Row fRow = sheet.getRow(firstRow);
Cell fCell = fRow.getCell(firstColumn);
return getCellValue(fCell);
}
}
}
return null;
}
/**
* 判断指定的单元格是否是合并单元格
*
* @param sheet
* @param row
* @param column
* @return
*/
public boolean isMergedRegion(Sheet sheet, int row, int column) {
int sheetMergeCount = sheet.getNumMergedRegions();
for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();
if (row >= firstRow && row <= lastRow) {
if (column >= firstColumn && column <= lastColumn) {
return true;
}
}
}
return false;
}
/**
* 获取单元格的值
*
* @param cell
* @return
*/
public String getCellValue(Cell cell) {
if (cell == null)
return "";
if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
return cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
return String.valueOf(cell.getBooleanCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
return cell.getCellFormula();
} else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
return String.valueOf(cell.getNumericCellValue());
}
return "";
}
}
......@@ -8,6 +8,7 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
......@@ -147,6 +148,8 @@ public class BeanUtil {
String str="'";
System.out.println(BeanUtil.isConSpeChar(str));
ObjectMapper mapper = new ObjectMapper();
//Map<String, String> map = mapper.readValue(json, Map.class);
}
}
......@@ -9,4 +9,63 @@ Content-Type: application/json
POST {{baseUrl}}/m/test/task/deploy
Content-Type: application/json
{"seq":"123456","transmission":{"processInstanceId":"11111","modelId":"f589444d-efa8-11eb-99ca-c25bd865180b"}}
\ No newline at end of file
{"seq":"123456","transmission":{"processInstanceId":"11111","modelId":"f589444d-efa8-11eb-99ca-c25bd865180b"}}
###流程启动
POST {{baseUrl}}/m/test/process/start
Content-Type: application/json
{"seq":"123456","transmission":{"dataKey":"mydata","deployId":"t5:6:30516","processInstanceId":"11111","userId":"admin"}}
###测试excel导入
POST {{baseUrl}}/m/test/testImport
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="test.xlsx"
Content-Type: multipart/form-data
< ./test.xlsx
--WebAppBoundary--
###测试bpmn.xml导入
POST {{baseUrl}}/m/test/importXml
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="test.xlsx"
Content-Type: multipart/form-data
< ./bpmn.xml
--WebAppBoundary--
###readXml
POST {{baseUrl}}/m/test/readXml
Content-Type: application/json
{"seq":"123456","transmission":{"dataKey":"mydata","deployId":"f177da63-f41b-11eb-9cf4-c25bd865180b","processInstanceId":"11111","userId":"admin"}}
###readImage
POST {{baseUrl}}/m/test/readImage
Content-Type: application/json
{"seq":"123456","transmission":{"dataKey":"mydata","deployId":"f177da63-f41b-11eb-9cf4-c25bd865180b","processInstanceId":"11111","userId":"admin"}}
###delete
POST {{baseUrl}}/m/test/delete
Content-Type: application/json
{"seq":"123456","transmission":{"dataKey":"mydata","deployId":"f177da63-f41b-11eb-9cf4-c25bd865180b","processInstanceId":"11111","userId":"admin"}}
###list
POST {{baseUrl}}/m/test/list
Content-Type: application/json
{"seq":"123456","transmission":{"dataKey":"mydata","deployId":"f177da63-f41b-11eb-9cf4-c25bd865180b","processInstanceId":"11111","userId":"admin"}}
......@@ -9,25 +9,30 @@ import com.mortals.xhx.common.pdu.flow.FlowProcDefPdu;
import com.mortals.xhx.common.pdu.flow.FlowSaveXmlPdu;
import com.mortals.xhx.module.flowable.model.FlowableDefinitionEntity;
import com.mortals.xhx.module.flowable.model.FlowableDefinitionQuery;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* <p>Title: 流程定义表</p>
* <p>Description: FlowableDefinitionService service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* @version 1.0.0
*/
* <p>Title: 流程定义表</p>
* <p>Description: FlowableDefinitionService service接口 </p>
* <p>Copyright: Copyright &reg; </p>
*
* @version 1.0.0
*/
public interface FlowableDefinitionService extends ICRUDService<FlowableDefinitionEntity,Long>{
public interface FlowableDefinitionService extends ICRUDService<FlowableDefinitionEntity, Long> {
Result<FlowableDefinitionEntity> getDefinList(FlowableDefinitionQuery query,PageInfo pageInfo, Context context);
Result<FlowableDefinitionEntity> getDefinList(FlowableDefinitionQuery query, PageInfo pageInfo, Context context);
String readImage(String deployId);
String readXml(String deployId);
String saveXml(FlowSaveXmlPdu flowSaveXmlPdu);
String start(String procDefId, String data, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.flowable.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
......@@ -17,6 +18,7 @@ import com.mortals.xhx.module.flowable.model.FlowableDefinitionQuery;
import com.mortals.xhx.module.form.model.FormEntity;
import com.mortals.xhx.module.form.model.FormQuery;
import com.mortals.xhx.module.form.service.FormService;
import lombok.SneakyThrows;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -27,7 +29,9 @@ import com.mortals.xhx.module.flowable.service.FlowableDefinitionService;
import org.springframework.util.ObjectUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -49,75 +53,116 @@ public class FlowableDefinitionServiceImpl extends AbstractCRUDServiceImpl<Flowa
@Override
public Result<FlowableDefinitionEntity> getDefinList(FlowableDefinitionQuery query, PageInfo pageInfo, Context context) {
Result<FlowableDefinitionEntity> result = new Result<>();
FlowProcDefPdu flowProcDefPdu = new FlowProcDefPdu();
try {
if (!ObjectUtils.isEmpty(query)) {
BeanUtils.copyProperties(query, flowProcDefPdu, BeanUtil.getNullPropertyNames(query));
}
if (!ObjectUtils.isEmpty(query)) {
BeanUtils.copyProperties(query, flowProcDefPdu, BeanUtil.getNullPropertyNames(query));
}
ApiRespPdu<Result<FlowProcDefPdu>> resp = apiFlowDefinitionFeign.list(context.getUser().getLoginName(), pageInfo);
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("获取流程定义列表异常:" + resp.getMsg());
throw new AppException("获取流程定义列表异常:" + resp.getMsg());
}
ApiRespPdu<Result<FlowProcDefPdu>> resp = apiFlowDefinitionFeign.list(context.getUser().getLoginName(), pageInfo);
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("获取流程定义列表异常:" + resp.getMsg());
throw new AppException("获取流程定义列表异常:" + resp.getMsg());
}
if (!ObjectUtils.isEmpty(resp.getData())) {
List<FlowableDefinitionEntity> collect = resp.getData().getList().stream().map(item -> {
FlowableDefinitionEntity definitionEntity = new FlowableDefinitionEntity();
BeanUtils.copyProperties(item, definitionEntity, BeanUtil.getNullPropertyNames(item));
definitionEntity.setVersion("v" + item.getVersion());
if (!ObjectUtils.isEmpty(resp.getData())) {
List<FlowableDefinitionEntity> collect = resp.getData().getList().stream().map(item -> {
FlowableDefinitionEntity definitionEntity = new FlowableDefinitionEntity();
BeanUtils.copyProperties(item, definitionEntity, BeanUtil.getNullPropertyNames(item));
definitionEntity.setVersion("v"+item.getVersion());
definitionEntity.setProcDefId(item.getId());
//查询关联的form表单
DeployFormQuery deployFormQuery = new DeployFormQuery();
deployFormQuery.setDeployId(item.getDeploymentId());
DeployFormEntity deployFormEntity = deployFormService.find(deployFormQuery, null).stream().findFirst().orElseGet(() -> null);
if (!ObjectUtils.isEmpty(deployFormEntity)) {
FormEntity formEntity = formService.get(deployFormEntity.getFormId(), context);
if (!ObjectUtils.isEmpty(formEntity)) {
definitionEntity.setFormId(deployFormEntity.getFormId());
definitionEntity.setFormName(formEntity.getFormName() == null ? "" : formEntity.getFormName());
definitionEntity.setProcDefId(item.getId());
//查询关联的form表单
DeployFormQuery deployFormQuery = new DeployFormQuery();
deployFormQuery.setDeployId(item.getDeploymentId());
DeployFormEntity deployFormEntity = deployFormService.find(deployFormQuery, null).stream().findFirst().orElseGet(() -> null);
if (!ObjectUtils.isEmpty(deployFormEntity)) {
FormEntity formEntity = formService.get(deployFormEntity.getFormId(), context);
if (!ObjectUtils.isEmpty(formEntity)) {
definitionEntity.setFormId(deployFormEntity.getFormId());
definitionEntity.setFormName(formEntity.getFormName() == null ? "" : formEntity.getFormName());
}
}
}
return definitionEntity;
}).collect(Collectors.toList());
result.setList(collect);
result.setPageInfo(resp.getData().getPageInfo());
} else {
result.setList(Collections.emptyList());
return definitionEntity;
}).collect(Collectors.toList());
result.setList(collect);
result.setPageInfo(resp.getData().getPageInfo());
} else {
result.setList(Collections.emptyList());
}
return result;
} catch (Exception e) {
log.error("获取流程定义列表异常", e);
throw new AppException("获取流程定义列表异常:" + e.getMessage());
}
return result;
}
@Override
public String readImage(String deployId) {
ApiRespPdu<String> resp = apiFlowDefinitionFeign.readImage(deployId);
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("获取流程图片异常:" + resp.getMsg());
throw new AppException("获取流程图片异常:" + resp.getMsg());
try {
ApiRespPdu<String> resp = apiFlowDefinitionFeign.readImage(deployId);
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("获取流程图片异常:" + resp.getMsg());
throw new AppException("获取流程图片异常:" + resp.getMsg());
}
return resp.getData();
} catch (Exception e) {
log.error("获取流程图片异常", e);
throw new AppException("获取流程图片异常:" + e.getMessage());
}
return resp.getData();
}
@Override
public String readXml(String deployId) {
ApiRespPdu<String> resp = apiFlowDefinitionFeign.readXml(deployId);
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("获取流程XML异常:" + resp.getMsg());
throw new AppException("获取流程XML异常:" + resp.getMsg());
try {
ApiRespPdu<String> resp = apiFlowDefinitionFeign.readXml(deployId);
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("获取流程XML异常:" + resp.getMsg());
throw new AppException("获取流程XML异常:" + resp.getMsg());
}
return resp.getData();
} catch (Exception e) {
log.error("获取流程XML异常", e);
throw new AppException("获取流程XML异常:" + e.getMessage());
}
return resp.getData();
}
@Override
public String saveXml(FlowSaveXmlPdu flowSaveXmlPdu) {
try {
ApiRespPdu<String> resp = apiFlowDefinitionFeign.save(flowSaveXmlPdu.getName(), flowSaveXmlPdu.getCategory(), flowSaveXmlPdu.getXml());
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("保存流程XML异常:" + resp.getMsg());
throw new AppException("保存流程XML异常:" + resp.getMsg());
}
return resp.getData();
} catch (Exception e) {
log.error("保存流程XML异常", e);
throw new AppException("保存流程XML异常:" + e.getMessage());
}
}
@SneakyThrows
@Override
public String start(String procDefId, String data, Context context) {
ApiRespPdu<String> resp = apiFlowDefinitionFeign.save(flowSaveXmlPdu.getName(), flowSaveXmlPdu.getCategory(), flowSaveXmlPdu.getXml());
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("保存流程XML异常:" + resp.getMsg());
throw new AppException("保存流程XML异常:" + resp.getMsg());
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> variables = mapper.readValue(data, Map.class);
// Map<String, Object> variables = new HashMap<>();
// variables.put("data", data);
String busiKey = "test";
try {
ApiRespPdu<String> resp = apiFlowDefinitionFeign.start(procDefId, context.getUser().getLoginName(), busiKey, variables);
if (YesNoEnum.NO.getValue() == resp.getCode()) {
log.error("流程实例化异常:" + resp.getMsg());
throw new AppException("流程实例化异常:" + resp.getMsg());
}
return resp.getData();
} catch (Exception e) {
log.error("流程实例化异常", e);
throw new AppException("流程实例化异常:" + e.getMessage());
}
return resp.getData();
}
}
\ No newline at end of file
package com.mortals.xhx.module.task.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.task.model.TaskTodoEntity;
/**
* <p>Title: 工作代办表</p>
* <p>Description: TaskTodoDao DAO接口 </p>
* @author
* @version 1.0.0
*/
public interface TaskTodoDao extends ICRUDDao<TaskTodoEntity,Long>{
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment