add : 工单流程交互开发
This commit is contained in:
@@ -23,26 +23,7 @@ public class FlwInstanceController {
|
||||
@Lazy
|
||||
private FlwInstanceService instanceService;
|
||||
|
||||
/**
|
||||
* 发起流程
|
||||
*/
|
||||
@RequestMapping("/startFlowInstance")
|
||||
public R startFlowInstance(@RequestParam Map<String, Object> params){
|
||||
|
||||
instanceService.startFlowInstance(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起流程
|
||||
*/
|
||||
@RequestMapping("/startFlowInstance1")
|
||||
public R startFlowInstance1(@RequestParam Map<String, Object> params){
|
||||
|
||||
instanceService.startFlowInstance1(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,7 +58,7 @@ public class FlwInstanceController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批通过
|
||||
* 提交审批
|
||||
*/
|
||||
@PostMapping("/completeFlow")
|
||||
public R completeFlow(@RequestBody Map<String, Object> params){
|
||||
@@ -86,30 +67,6 @@ public class FlwInstanceController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 任务节点1审批通过工单完结
|
||||
*/
|
||||
@PostMapping("/completeFlow1")
|
||||
public R completeFlow1(@RequestBody Map<String, Object> params){
|
||||
|
||||
R r = instanceService.completeTaskById1(params);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 任务节点1无法解决进入下一个节点
|
||||
*/
|
||||
@PostMapping("/deleteFlow1")
|
||||
public R deleteFlow1(@RequestBody Map<String, Object> params){
|
||||
|
||||
R r = instanceService.deleteFlow1(params);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 终结流程
|
||||
|
||||
@@ -9,13 +9,11 @@ import java.util.Map;
|
||||
public interface FlwInstanceService {
|
||||
void startFlowInstance(Map<String, Object> params);
|
||||
|
||||
void startFlowInstance1(Map<String, Object> params);
|
||||
|
||||
R getTodoTaskList(Map<String, Object> params);
|
||||
|
||||
R completeTaskById(Map<String, Object> id);
|
||||
|
||||
R completeTaskById1(Map<String, Object> id);
|
||||
|
||||
void unclaimTask(String id);
|
||||
|
||||
@@ -33,5 +31,4 @@ public interface FlwInstanceService {
|
||||
|
||||
R deleteFlow(Map<String, Object> params);
|
||||
|
||||
R deleteFlow1(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -215,26 +215,7 @@ public class FlwDeployServiceImpl extends FlowServiceNoFactory implements FlwDep
|
||||
map.put("value", "");
|
||||
map.put("key", findFlowDefUserOrGroup(assignee));
|
||||
list.add(map);
|
||||
} else if (candidateUsers != null && candidateUsers.size() > 0) {
|
||||
// 指定的候选人
|
||||
String join = String.join(",", candidateUsers);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", flowElement.getName());
|
||||
map.put("type", "candidateUsers");
|
||||
// ${user1} ${user2},${user3} ${group1}
|
||||
map.put("value", "");
|
||||
map.put("key", findFlowDefUserOrGroup(join));
|
||||
list.add(map);
|
||||
|
||||
} else if (candidateGroups != null && candidateGroups.size() > 0) {
|
||||
String join = String.join(",", candidateGroups);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", flowElement.getName());
|
||||
map.put("type", "candidateGroups");
|
||||
// ${user1} ${user2},${user3} ${group1}
|
||||
map.put("value", "");
|
||||
map.put("key", findFlowDefUserOrGroup(join));
|
||||
list.add(map);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ import com.boge.modules.sys.entity.SysUserEntity;
|
||||
import com.boge.modules.sys.service.SysRoleService;
|
||||
import com.boge.modules.sys.service.SysUserService;
|
||||
import com.boge.modules.sys.service.impl.SysUserServiceImpl;
|
||||
import com.boge.modules.tickets.dao.TicketsDao;
|
||||
import com.boge.modules.tickets.entity.TicketsEntity;
|
||||
import com.boge.modules.tickets.enums.TicketUserEnums;
|
||||
import com.boge.modules.tickets.enums.TicketsStatusEnums;
|
||||
import com.boge.modules.tickets.service.TicketsService;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
@@ -69,7 +71,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
|
||||
@Value("${ProcessInstance.defId}")
|
||||
private String defId;
|
||||
|
||||
@Autowired
|
||||
private TicketsDao ticketsDao;
|
||||
//发送消息的类型
|
||||
private final static String MSGTYPE = "text";
|
||||
//将消息发送给所有成员
|
||||
@@ -84,7 +87,6 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
private final static String CREATE_SESSION_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void startFlowInstance(Map<String, Object> params) {
|
||||
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||
@@ -101,7 +103,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
// 启动流程
|
||||
try {
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(defId, variable);
|
||||
}catch (FlowableException e){
|
||||
} catch (FlowableException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SysUserEntity user = sysUserService.getById(userId);
|
||||
@@ -114,8 +116,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
// ticketsEntity.setAssignUserId(userId);
|
||||
// ticketsService.updateById(ticketsEntity);
|
||||
|
||||
if (StrUtil.isEmpty(user.getWexinId())){
|
||||
throw new RRException("企业id为空,企业微信消息无法推送");
|
||||
if (StrUtil.isEmpty(user.getWexinId())) {
|
||||
throw new RRException("企业id为空,企业微信消息无法推送");
|
||||
}
|
||||
|
||||
String accessToken = getAccessToken();
|
||||
@@ -124,17 +126,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startFlowInstance1(Map<String, Object> params) {
|
||||
// 启动流程
|
||||
try {
|
||||
Map<String, Object> startVars = new HashMap<>();
|
||||
runtimeService.startProcessInstanceById(defId, startVars); }
|
||||
catch (FlowableException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取access_token
|
||||
@@ -179,7 +171,6 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void sendWeChatMessage(String toUser, String content, String ACCESS_TOKEN, String ticketsId) {
|
||||
//请求串
|
||||
String url = CREATE_SESSION_URL + ACCESS_TOKEN;
|
||||
@@ -190,7 +181,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
JSONObject contentJSon = new JSONObject();
|
||||
contentJSon.put("title", "[协同提醒] - 工单审批待处理");
|
||||
contentJSon.put("description", "点击查看详情");
|
||||
contentJSon.put("url", "http://localhost:8001/#/tickets-detail?id="+ticketsId);
|
||||
contentJSon.put("url", "http://localhost:8001/#/tickets-detail?id=" + ticketsId);
|
||||
contentJSon.put("btntxt", "处理");
|
||||
|
||||
jsonObject.put("textcard", contentJSon);
|
||||
@@ -219,7 +210,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(result);
|
||||
int errcode = jsonObject1.getInteger("errcode");
|
||||
if (Objects.equals(42001, errcode)) {
|
||||
throw new RRException("发送企业微信 token 失效");
|
||||
throw new RRException("发送企业微信 token 失效");
|
||||
}
|
||||
if (Objects.equals(0, errcode)) {
|
||||
System.out.println("消息发送成功");
|
||||
@@ -242,33 +233,31 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void packageData(Map<String, Object> params, Set<String> keys, Map<String, Object> variable) {
|
||||
if(keys != null){
|
||||
if (keys != null) {
|
||||
for (String key : keys) {
|
||||
if("id".equals(key) || "t".equals(key)){
|
||||
if ("id".equals(key) || "t".equals(key)) {
|
||||
continue;
|
||||
}
|
||||
String value = (String) params.get(key);
|
||||
if(key.contains(",")){
|
||||
if (key.contains(",")) {
|
||||
String[] split = key.split(",");
|
||||
int i = 0;
|
||||
for (String s : split) {
|
||||
if(value.contains(",")){
|
||||
if (value.contains(",")) {
|
||||
String[] split1 = value.split(",");
|
||||
if(split1.length >= i){
|
||||
variable.put(s,split1[i]);
|
||||
}else{
|
||||
variable.put(s,split1[0]);
|
||||
if (split1.length >= i) {
|
||||
variable.put(s, split1[i]);
|
||||
} else {
|
||||
variable.put(s, split1[0]);
|
||||
}
|
||||
}else{
|
||||
variable.put(s,value);
|
||||
} else {
|
||||
variable.put(s, value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}else{
|
||||
variable.put(key,value);
|
||||
} else {
|
||||
variable.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,9 +265,9 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
|
||||
/**
|
||||
* 查询我的待办任务
|
||||
* 审批人
|
||||
* 候选人
|
||||
* 候选人组
|
||||
* 审批人
|
||||
* 候选人
|
||||
* 候选人组
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
@@ -286,8 +275,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
@Override
|
||||
public R getTodoTaskList(Map<String, Object> params) {
|
||||
// 获取到分页的信息
|
||||
Integer page = Integer.parseInt((String)params.getOrDefault(Constant.PAGE,1));
|
||||
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT,5));
|
||||
Integer page = Integer.parseInt((String) params.getOrDefault(Constant.PAGE, 1));
|
||||
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT, 5));
|
||||
// 获取当前的登录用户
|
||||
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||
TaskQuery taskQuery = taskService.createTaskQuery()
|
||||
@@ -303,13 +292,13 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
List<Task> tasks = taskQuery.listPage((page - 1) * limit, page * limit);
|
||||
long count = taskQuery.count();
|
||||
List<FlwTaskEntity> list = new ArrayList<>();
|
||||
if(tasks != null && tasks.size() > 0){
|
||||
if (tasks != null && tasks.size() > 0) {
|
||||
for (Task task : tasks) {
|
||||
FlwTaskEntity entity = new FlwTaskEntity();
|
||||
entity.setTaskId(task.getId());
|
||||
entity.setCategory(task.getCategory());
|
||||
entity.setAssigneeId(task.getAssignee());
|
||||
if(task.getAssignee() != null){
|
||||
if (task.getAssignee() != null) {
|
||||
SysUserEntity assigneeUser = userService.getById(task.getAssignee());
|
||||
entity.setAssigneeName(assigneeUser.getNickname());
|
||||
}
|
||||
@@ -327,91 +316,99 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
// 任务的发起人
|
||||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(entity.getProcInsId()).singleResult();
|
||||
if(historicProcessInstance != null){
|
||||
if (historicProcessInstance != null) {
|
||||
String startUserId = historicProcessInstance.getStartUserId();
|
||||
entity.setStartTime(historicProcessInstance.getStartTime());
|
||||
entity.setStartUserId(startUserId);
|
||||
if(StringUtils.isNotBlank(startUserId)){
|
||||
if (StringUtils.isNotBlank(startUserId)) {
|
||||
SysUserEntity startUser = userService.getById(startUserId);
|
||||
entity.setStartUserName(startUser.getNickname());
|
||||
}
|
||||
}
|
||||
// 通过 BpmnModel 对象来检查当前的节点的 定义信息
|
||||
entity.setStatus(getUserTaskStatus(task.getProcessDefinitionId(),task.getTaskDefinitionKey()));
|
||||
entity.setStatus(getUserTaskStatus(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
|
||||
list.add(entity);
|
||||
}
|
||||
}
|
||||
PageUtils pageUtils = new PageUtils(list,(int)count,limit,page);
|
||||
return R.ok("操作成功").put("page",pageUtils);
|
||||
PageUtils pageUtils = new PageUtils(list, (int) count, limit, page);
|
||||
return R.ok("操作成功").put("page", pageUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R completeTaskById(Map<String, Object> params) {
|
||||
String processInstance = (String) params.get("processInstance");
|
||||
// Integer ticketsId = (Integer) params.get("ticketsId");
|
||||
if(StringUtils.isBlank(processInstance)){
|
||||
Integer ticketsId = (Integer) params.get("ticketsId");
|
||||
String result = (String) params.get("result");
|
||||
String opinion = (String) params.get("opinion");
|
||||
|
||||
if (StringUtils.isBlank(processInstance)) {
|
||||
return R.error("流程Id不能为空");
|
||||
}
|
||||
TaskQuery taskQuery = taskService.createTaskQuery().active().processInstanceId(processInstance);
|
||||
List<Task> tasks = taskQuery.list();
|
||||
if (!tasks.isEmpty()){
|
||||
taskService.complete(tasks.get(0).getId());
|
||||
if (StringUtils.isBlank(processInstance)) {
|
||||
return R.error("流程Id不能为空");
|
||||
}
|
||||
Task secondTask = taskService.createTaskQuery()
|
||||
.processInstanceId(processInstance)
|
||||
.singleResult();
|
||||
Map<String, Object> secondApprovalVars = new HashMap<>();
|
||||
TicketsEntity ticketsEntity = new TicketsEntity();
|
||||
// 完结流程
|
||||
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("完结")) {
|
||||
secondApprovalVars.put("approvalResult", true);
|
||||
ticketsEntity.setStatus(TicketsStatusEnums.FINISH.getCode());
|
||||
ticketsEntity.setFinishTime(new Date());
|
||||
ticketsEntity.setAssignUserId(TicketUserEnums.SPECIALIST.getCode());
|
||||
taskService.complete(secondTask.getId(), secondApprovalVars);
|
||||
}
|
||||
// 继续流程
|
||||
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("同意")) {
|
||||
secondApprovalVars.put("approvalResult", false);
|
||||
ticketsEntity.setAssignUserId(TicketUserEnums.MANAGER.getCode());
|
||||
taskService.complete(secondTask.getId(), secondApprovalVars);
|
||||
}
|
||||
|
||||
// 指派处理人
|
||||
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("指派")) {
|
||||
String userId = String.valueOf(params.get("userId"));
|
||||
Map<String, Object> startVars = new HashMap<>();
|
||||
startVars.put("user1",userId);
|
||||
ticketsEntity.setAssignUserId(Long.valueOf(userId));
|
||||
taskService.complete(secondTask.getId(), startVars);
|
||||
}
|
||||
|
||||
// 继续流程
|
||||
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("提交")) {
|
||||
ticketsEntity.setAssignUserId(TicketUserEnums.SPECIALIST.getCode());
|
||||
taskService.complete(secondTask.getId(), secondApprovalVars);
|
||||
}
|
||||
|
||||
String processName = ticketsDao.selectByProcessInstance(processInstance);
|
||||
if (StringUtils.isNotBlank(processName)&& processName.contains("完结")){
|
||||
ticketsEntity.setStatus(TicketsStatusEnums.FINISH.getCode());
|
||||
}
|
||||
|
||||
//更新工单审批id
|
||||
// TicketsEntity ticketsEntity = new TicketsEntity();
|
||||
// ticketsEntity.setTicketsId(Long.valueOf(ticketsId));
|
||||
// ticketsEntity.setStatus(TicketsStatusEnums.CANCEL.getCode());
|
||||
// ticketsEntity.setUpdateTime(new Date());
|
||||
// ticketsService.updateById(ticketsEntity);
|
||||
ticketsEntity.setTicketsId(Long.valueOf(ticketsId));
|
||||
ticketsEntity.setUpdateTime(new Date());
|
||||
ticketsService.updateById(ticketsEntity);
|
||||
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public R completeTaskById1(Map<String, Object> params) {
|
||||
String processInstance = (String) params.get("processInstance");
|
||||
if(StringUtils.isBlank(processInstance)){
|
||||
return R.error("流程Id不能为空");
|
||||
}
|
||||
Task secondTask = taskService.createTaskQuery()
|
||||
.processInstanceId(processInstance)
|
||||
.singleResult();
|
||||
Map<String, Object> secondApprovalVars = new HashMap<>();
|
||||
secondApprovalVars.put("approvalResult", true);
|
||||
taskService.complete(secondTask.getId(), secondApprovalVars);
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public R deleteFlow1(Map<String, Object> params) {
|
||||
String processInstance = (String) params.get("processInstance");
|
||||
if(StringUtils.isBlank(processInstance)){
|
||||
return R.error("流程Id不能为空");
|
||||
}
|
||||
Task secondTask = taskService.createTaskQuery()
|
||||
.processInstanceId(processInstance)
|
||||
.singleResult();
|
||||
Map<String, Object> secondApprovalVars = new HashMap<>();
|
||||
secondApprovalVars.put("approvalResult", false);
|
||||
secondApprovalVars.put("user1", 2);
|
||||
taskService.complete(secondTask.getId(), secondApprovalVars);
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public R deleteFlow(Map<String, Object> params) {
|
||||
String processInstance = (String) params.get("processInstance");
|
||||
// Integer ticketsId = (Integer) params.get("ticketsId");
|
||||
if(StringUtils.isBlank(processInstance)){
|
||||
if (StringUtils.isBlank(processInstance)) {
|
||||
return R.error("流程Id不能为空");
|
||||
}
|
||||
//查询活跃任务
|
||||
TaskQuery taskQuery = taskService.createTaskQuery().active().processInstanceId(processInstance);
|
||||
List<Task> tasks = taskQuery.list();
|
||||
if (tasks.isEmpty()){
|
||||
if (tasks.isEmpty()) {
|
||||
return R.error("没有可终结的任务");
|
||||
}
|
||||
runtimeService.deleteProcessInstance(processInstance, "测试终结流程");
|
||||
@@ -433,7 +430,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
|
||||
@Override
|
||||
public void claimTask(String id) {
|
||||
taskService.claim(id,ShiroUtils.getUserId().toString());
|
||||
taskService.claim(id, ShiroUtils.getUserId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -475,7 +472,6 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取流程图
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
ProcessEngineConfiguration configuration = processEngine.getProcessEngineConfiguration();
|
||||
@@ -488,7 +484,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
byte[] b = new byte[in.available()];
|
||||
in.read(b);
|
||||
return b;
|
||||
}catch (IOException e){
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
return null;
|
||||
@@ -498,8 +494,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
@Override
|
||||
public R getMyStartTaskList(Map<String, Object> params) {
|
||||
// 获取到分页的信息
|
||||
Integer page = Integer.parseInt((String)params.getOrDefault(Constant.PAGE,1));
|
||||
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT,5));
|
||||
Integer page = Integer.parseInt((String) params.getOrDefault(Constant.PAGE, 1));
|
||||
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT, 5));
|
||||
// 获取当前的登录用户
|
||||
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||
// 我们需要根据当前登录用户查询所有发起的流程
|
||||
@@ -512,7 +508,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
List<HistoricProcessInstance> tasks = historicProcessInstanceQuery.listPage((page - 1) * limit, page * limit);
|
||||
long count = historicProcessInstanceQuery.count();
|
||||
List<FlwMyFlowEntity> list = new ArrayList<>();
|
||||
if(tasks != null && tasks.size() > 0){
|
||||
if (tasks != null && tasks.size() > 0) {
|
||||
for (HistoricProcessInstance historicProcessInstance : tasks) {
|
||||
HistoricProcessInstanceEntityImpl impl = (HistoricProcessInstanceEntityImpl) historicProcessInstance;
|
||||
FlwMyFlowEntity entity = new FlwMyFlowEntity();
|
||||
@@ -525,7 +521,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
entity.setFlowProceId(impl.getProcessInstanceId());
|
||||
|
||||
// 任务的发起人
|
||||
if(historicProcessInstance != null){
|
||||
if (historicProcessInstance != null) {
|
||||
String startUserId = historicProcessInstance.getStartUserId();
|
||||
entity.setStartDate(historicProcessInstance.getStartTime());
|
||||
entity.setEndDate(historicProcessInstance.getEndTime());
|
||||
@@ -535,12 +531,13 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
list.add(entity);
|
||||
}
|
||||
}
|
||||
PageUtils pageUtils = new PageUtils(list,(int)count,limit,page);
|
||||
return R.ok("操作成功").put("page",pageUtils);
|
||||
PageUtils pageUtils = new PageUtils(list, (int) count, limit, page);
|
||||
return R.ok("操作成功").put("page", pageUtils);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程实例ID获取对应的流转记录
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@@ -550,7 +547,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
.processInstanceId(id).orderByTaskCreateTime().asc().list();
|
||||
|
||||
List<FlwHiTaskEntity> ress = new ArrayList<>();
|
||||
if(list != null){
|
||||
if (list != null) {
|
||||
for (HistoricTaskInstance entity : list) {
|
||||
FlwHiTaskEntity task = new FlwHiTaskEntity();
|
||||
task.setId(entity.getId());
|
||||
@@ -559,26 +556,26 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
task.setAssignee(entity.getAssignee());
|
||||
task.setStartTime(entity.getCreateTime());
|
||||
Long durationInMillis = entity.getDurationInMillis();
|
||||
if(durationInMillis != null){
|
||||
if (durationInMillis != null) {
|
||||
task.setDuration(durationInMillis);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(entity.getAssignee())){
|
||||
if (StringUtils.isNotBlank(entity.getAssignee())) {
|
||||
// 需要查询到用户的名称
|
||||
SysUserEntity userEntity = userService.getById(entity.getAssignee());
|
||||
String username = userEntity.getUsername();
|
||||
String nickname = userEntity.getNickname();
|
||||
if(StringUtils.isNotBlank(nickname)){
|
||||
if (StringUtils.isNotBlank(nickname)) {
|
||||
task.setAssigneeName(nickname);
|
||||
}else{
|
||||
} else {
|
||||
task.setAssigneeName(username);
|
||||
}
|
||||
}
|
||||
// 查询当前的节点的状态
|
||||
if(entity.getEndTime() != null){
|
||||
if (entity.getEndTime() != null) {
|
||||
// 这个节点已经审批完成了
|
||||
task.setStatus("finish");
|
||||
}else{
|
||||
} else {
|
||||
task.setStatus("wait");
|
||||
}
|
||||
ress.add(task);
|
||||
@@ -591,16 +588,16 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
@Override
|
||||
public R getMyCompleteTaskList(Map<String, Object> params) {
|
||||
// 获取到分页的信息
|
||||
Integer page = Integer.parseInt((String)params.getOrDefault(Constant.PAGE,1));
|
||||
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT,5));
|
||||
Integer page = Integer.parseInt((String) params.getOrDefault(Constant.PAGE, 1));
|
||||
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT, 5));
|
||||
// 获取当前的登录用户
|
||||
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||
// 我的已办 可以通过当前登录用户 匹配 act_hi_taskinst 中的审批人来找到对应的流程实例id
|
||||
List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery()
|
||||
.taskAssignee(loginUser.getUserId().toString()).list();
|
||||
if(taskInstances == null || taskInstances.size() == 0){
|
||||
PageUtils pageUtils = new PageUtils(null,0,limit,page);
|
||||
return R.ok("操作成功").put("page",pageUtils);
|
||||
if (taskInstances == null || taskInstances.size() == 0) {
|
||||
PageUtils pageUtils = new PageUtils(null, 0, limit, page);
|
||||
return R.ok("操作成功").put("page", pageUtils);
|
||||
}
|
||||
Set<String> processInsIds = taskInstances.stream().map(item -> {
|
||||
return item.getProcessInstanceId();
|
||||
@@ -615,7 +612,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
List<HistoricProcessInstance> tasks = historicProcessInstanceQuery.listPage((page - 1) * limit, page * limit);
|
||||
long count = historicProcessInstanceQuery.count();
|
||||
List<FlwMyFlowEntity> list = new ArrayList<>();
|
||||
if(tasks != null && tasks.size() > 0){
|
||||
if (tasks != null && tasks.size() > 0) {
|
||||
for (HistoricProcessInstance historicProcessInstance : tasks) {
|
||||
HistoricProcessInstanceEntityImpl impl = (HistoricProcessInstanceEntityImpl) historicProcessInstance;
|
||||
FlwMyFlowEntity entity = new FlwMyFlowEntity();
|
||||
@@ -628,10 +625,10 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
entity.setFlowProceId(impl.getProcessInstanceId());
|
||||
|
||||
// 任务的发起人
|
||||
if(historicProcessInstance != null){
|
||||
if (historicProcessInstance != null) {
|
||||
String startUserId = historicProcessInstance.getStartUserId();
|
||||
SysUserEntity userEntity = userService.getById(startUserId);
|
||||
if(userEntity != null){
|
||||
if (userEntity != null) {
|
||||
entity.setUserName(userEntity.getNickname());
|
||||
}
|
||||
entity.setStartDate(historicProcessInstance.getStartTime());
|
||||
@@ -642,8 +639,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
list.add(entity);
|
||||
}
|
||||
}
|
||||
PageUtils pageUtils = new PageUtils(list,(int)count,limit,page);
|
||||
return R.ok("操作成功").put("page",pageUtils);
|
||||
PageUtils pageUtils = new PageUtils(list, (int) count, limit, page);
|
||||
return R.ok("操作成功").put("page", pageUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -653,7 +650,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
|
||||
List<FlwHiTaskEntity> ress = new ArrayList<>();
|
||||
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||
if(list != null){
|
||||
if (list != null) {
|
||||
for (HistoricTaskInstance entity : list) {
|
||||
FlwHiTaskEntity task = new FlwHiTaskEntity();
|
||||
task.setId(entity.getId());
|
||||
@@ -662,30 +659,30 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
task.setAssignee(entity.getAssignee());
|
||||
task.setStartTime(entity.getCreateTime());
|
||||
Long durationInMillis = entity.getDurationInMillis();
|
||||
if(durationInMillis != null){
|
||||
if (durationInMillis != null) {
|
||||
task.setDuration(durationInMillis);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(entity.getAssignee())){
|
||||
if (StringUtils.isNotBlank(entity.getAssignee())) {
|
||||
// 需要查询到用户的名称
|
||||
SysUserEntity userEntity = userService.getById(entity.getAssignee());
|
||||
String username = userEntity.getUsername();
|
||||
String nickname = userEntity.getNickname();
|
||||
if(StringUtils.isNotBlank(nickname)){
|
||||
if (StringUtils.isNotBlank(nickname)) {
|
||||
task.setAssigneeName(nickname);
|
||||
}else{
|
||||
} else {
|
||||
task.setAssigneeName(username);
|
||||
}
|
||||
}
|
||||
// 查询当前的节点的状态
|
||||
if(entity.getEndTime() != null){
|
||||
if (entity.getEndTime() != null) {
|
||||
// 这个节点已经审批完成了
|
||||
task.setStatus("finish");
|
||||
}else{
|
||||
} else {
|
||||
task.setStatus("wait");
|
||||
}
|
||||
|
||||
if(entity.getAssignee() != null && entity.getAssignee().equals(loginUser.getUserId().toString())){
|
||||
if (entity.getAssignee() != null && entity.getAssignee().equals(loginUser.getUserId().toString())) {
|
||||
task.setStatus("success");
|
||||
}
|
||||
ress.add(task);
|
||||
@@ -695,21 +692,21 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
return ress;
|
||||
}
|
||||
|
||||
private Integer getUserTaskStatus(String processDef,String taskDefKey){
|
||||
private Integer getUserTaskStatus(String processDef, String taskDefKey) {
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDef);
|
||||
Process mainProcess = bpmnModel.getMainProcess();
|
||||
Collection<FlowElement> flowElements = mainProcess.getFlowElements();
|
||||
Integer status = 0;
|
||||
if(flowElements != null && flowElements.size() > 0){
|
||||
if (flowElements != null && flowElements.size() > 0) {
|
||||
for (FlowElement flowElement : flowElements) {
|
||||
if(flowElement instanceof UserTask){
|
||||
if (flowElement instanceof UserTask) {
|
||||
UserTask userTask = (UserTask) flowElement;
|
||||
if(userTask.getId().equals(taskDefKey)){
|
||||
if (userTask.getId().equals(taskDefKey)) {
|
||||
String assignee = userTask.getAssignee();
|
||||
if(StringUtils.isNotBlank(assignee)){
|
||||
if (StringUtils.isNotBlank(assignee)) {
|
||||
// 说明是制定的审批人
|
||||
status = 0;
|
||||
}else{
|
||||
} else {
|
||||
status = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -17,4 +17,6 @@ public interface TicketsDao extends BaseMapper<TicketsEntity> {
|
||||
|
||||
|
||||
TicketsDTO getTicketsDTOById(String ticketsId);
|
||||
|
||||
String selectByProcessInstance(String processInstance);
|
||||
}
|
||||
|
||||
@@ -78,4 +78,9 @@ public class TicketsDTO {
|
||||
* 审批流id
|
||||
*/
|
||||
private String processInstance;
|
||||
|
||||
/**
|
||||
* 审批结点
|
||||
*/
|
||||
private String processInstanceUser;
|
||||
}
|
||||
|
||||
@@ -76,11 +76,14 @@ public class TicketsEntity implements Serializable {
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 工单关闭时间
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 完结时间
|
||||
*/
|
||||
private Date finishTime;
|
||||
|
||||
/**
|
||||
* 审批流id
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.boge.modules.tickets.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TicketUserEnums {
|
||||
|
||||
|
||||
SPECIALIST(2L, "专员"),
|
||||
MANAGER(3L, "经理");
|
||||
|
||||
private Long code;
|
||||
private String msg;
|
||||
|
||||
public static String getStatus(String code) {
|
||||
for (TicketUserEnums value : values()) {
|
||||
if (value.code.equals(code)) {
|
||||
return value.msg;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import lombok.Getter;
|
||||
UNCHECK(0, "未开始"),
|
||||
CHECKED(1, "已指派"),
|
||||
REJECT(2, "处理中"),
|
||||
CANCEL(3, "已完成");
|
||||
FINISH(3, "已完成");
|
||||
|
||||
private Integer code;
|
||||
private String msg;
|
||||
|
||||
@@ -12,7 +12,9 @@ import com.boge.modules.sys.entity.SysUserEntity;
|
||||
import com.boge.modules.sys.service.SysUserRoleService;
|
||||
import com.boge.modules.sys.service.impl.SysUserServiceImpl;
|
||||
import com.boge.modules.tickets.dto.TicketsDTO;
|
||||
import com.boge.modules.tickets.enums.TicketUserEnums;
|
||||
import org.flowable.common.engine.api.FlowableException;
|
||||
import org.flowable.engine.IdentityService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -54,6 +56,9 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
|
||||
@Autowired
|
||||
protected RuntimeService runtimeService;
|
||||
|
||||
@Autowired
|
||||
protected IdentityService identityService;
|
||||
|
||||
@Value("${ProcessInstance.defId}")
|
||||
private String defId;
|
||||
|
||||
@@ -91,11 +96,11 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
|
||||
ticketsEntityQueryWrapper.eq("create_user", loginUser.getUsername());
|
||||
}
|
||||
if (TicketsTypeEnums.TO_BE_DONE.getCode().equals(params.get("type"))) {
|
||||
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.CHECKED.getCode());
|
||||
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.REJECT.getCode());
|
||||
}
|
||||
|
||||
if (TicketsTypeEnums.FINISH.getCode().equals(params.get("type"))) {
|
||||
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.CANCEL.getCode());
|
||||
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.FINISH.getCode());
|
||||
}
|
||||
|
||||
|
||||
@@ -112,11 +117,15 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
|
||||
public void saveTicket(TicketsEntity tickets) {
|
||||
// 启动流程
|
||||
try {
|
||||
// 记录流程的发起人
|
||||
identityService.setAuthenticatedUserId(ShiroUtils.getUserId().toString());
|
||||
Map<String, Object> startVars = new HashMap<>();
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(defId, startVars);
|
||||
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||
tickets.setCreateTime(new Date());
|
||||
tickets.setCreateUser(loginUser.getNickname());
|
||||
tickets.setStatus(TicketsStatusEnums.REJECT.getCode());
|
||||
tickets.setAssignUserId(TicketUserEnums.SPECIALIST.getCode());
|
||||
tickets.setProcessInstance(processInstance.getProcessInstanceId());
|
||||
ticketsDao.insert(tickets);
|
||||
} catch (Exception e) {
|
||||
@@ -127,6 +136,9 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
|
||||
@Override
|
||||
public TicketsDTO getTicketsById(String ticketsId) {
|
||||
TicketsDTO tickets = ticketsDao.getTicketsDTOById(ticketsId);
|
||||
|
||||
String processName = ticketsDao.selectByProcessInstance(tickets.getProcessInstance());
|
||||
tickets.setProcessInstanceUser(processName);
|
||||
return tickets;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
left join sys_car as c on a.car_type = c.car_id
|
||||
where a.tickets_id = #{ticketsId}
|
||||
</select>
|
||||
<select id="selectByProcessInstance" resultType="java.lang.String" parameterType="java.lang.String">
|
||||
select NAME_ from act_ru_task where PROC_INST_ID_ = #{processInstance}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user