工作流代码提交

This commit is contained in:
2023-04-14 15:03:13 +08:00
parent 4490758e8a
commit d7981936f2
26 changed files with 1170 additions and 47 deletions

View File

@@ -1,5 +1,6 @@
package com.njcn.prepare.harmonic.pojo.po; package com.njcn.prepare.harmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -24,6 +25,7 @@ public class ThsSupervise {
* 技术监督Guid * 技术监督Guid
*/ */
@ApiModelProperty(name = "supIndex", value = "技术监督Guid", required = true) @ApiModelProperty(name = "supIndex", value = "技术监督Guid", required = true)
@TableId
private String supIndex; private String supIndex;
/** /**
* 部门id * 部门id

View File

@@ -118,4 +118,9 @@ public class SuperviseVo {
@ApiModelProperty(name = "progressTime", value = "进行时间(天)") @ApiModelProperty(name = "progressTime", value = "进行时间(天)")
private Integer progressTime; private Integer progressTime;
private String deploymentId;
private String execId;
} }

View File

@@ -32,7 +32,7 @@
<if test="param.type !=null"> <if test="param.type !=null">
and tda.type=#{param.type} and tda.type=#{param.type}
</if> </if>
and tws.Big_Type=1
</where> </where>
</select> </select>

View File

@@ -25,6 +25,7 @@ import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
import com.njcn.process.annotaion.HarCurrent; import com.njcn.process.annotaion.HarCurrent;
import com.njcn.process.annotaion.HarVoltage; import com.njcn.process.annotaion.HarVoltage;
import com.njcn.process.annotaion.InterharVoltage; import com.njcn.process.annotaion.InterharVoltage;
import com.njcn.process.api.FlowableDefineFeignClient;
import com.njcn.process.pojo.po.LimitRate; import com.njcn.process.pojo.po.LimitRate;
import com.njcn.process.pojo.po.ThsWarnStrategyAss; import com.njcn.process.pojo.po.ThsWarnStrategyAss;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
@@ -32,6 +33,7 @@ import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient; import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept; import com.njcn.user.pojo.po.Dept;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@@ -54,31 +56,33 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor
public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, ThsSupervise> implements ThsSuperviseService { public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, ThsSupervise> implements ThsSuperviseService {
@Autowired
private PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
@Autowired
private ThsWarnStrategyMapper thsWarnStrategyMapper;
@Autowired private final ThsWarnStrategyMapper thsWarnStrategyMapper;
private ThsWarnStrategyAssMapper thsWarnStrategyAssMapper;
@Autowired private final ThsWarnStrategyAssMapper thsWarnStrategyAssMapper;
private PmsMonitorMapper pmsMonitorMapper;
@Autowired private final PmsMonitorMapper pmsMonitorMapper;
private LimitRateMapper limitRateMapper;
@Autowired private final LimitRateMapper limitRateMapper;
private DicDataFeignClient dicDataFeignClient;
@Autowired private final DicDataFeignClient dicDataFeignClient;
private ThsSuperviseMapper thsSuperviseMapper;
@Autowired private final ThsSuperviseMapper thsSuperviseMapper;
private ThsOverRunLogMapper thsOverRunLogMapper;
@Autowired private final ThsOverRunLogMapper thsOverRunLogMapper;
private DeptFeignClient deptFeignClient;
@Autowired private final DeptFeignClient deptFeignClient;
private FileStorageUtil fileStorageUtil;
private final FileStorageUtil fileStorageUtil;
private static final String DESCRIPTION = "description"; private static final String DESCRIPTION = "description";
private final FlowableDefineFeignClient flowableDefineFeignClient;
@Override @Override
@Async("asyncExecutor") @Async("asyncExecutor")
@@ -217,6 +221,10 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
String overItem = str.substring(0, str.indexOf("") - 1); String overItem = str.substring(0, str.indexOf("") - 1);
thsSupervise.setName(DateUtil.today() + dept.getName() + overRunLogList.get(0).getName() + "" + overRunLogList.size() + "个监测点" + overItem); thsSupervise.setName(DateUtil.today() + dept.getName() + overRunLogList.get(0).getName() + "" + overRunLogList.size() + "个监测点" + overItem);
thsSuperviseMapper.insert(thsSupervise); thsSuperviseMapper.insert(thsSupervise);
//TODO 解决工作流写死问题
Map<String, Object> mapParam = new HashMap<>();
flowableDefineFeignClient.start("flow_yzep99kb:1:c0ff8a75-da73-11ed-829f-b07b253cdad9",thsSupervise.getSupIndex(),mapParam).getData();
for (ThsOverRunLog thsOverRunLog : overRunLogList) { for (ThsOverRunLog thsOverRunLog : overRunLogList) {
thsOverRunLogMapper.insert(thsOverRunLog); thsOverRunLogMapper.insert(thsOverRunLog);
} }

View File

@@ -0,0 +1,32 @@
package com.njcn.process.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.pojo.dto.OverLimitFlagDTO;
import com.njcn.process.api.fallback.FlowableDefineFallbackFactory;
import com.njcn.process.api.fallback.RStatWorkOrderFallbackFactory;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
* 工作流
* @author cdf
* @date 2023/4/13
*/
@FeignClient(value = ServerInfo.PROCESS,path = "/flowable/definition",fallbackFactory = FlowableDefineFallbackFactory.class)
public interface FlowableDefineFeignClient {
@PostMapping("/start")
HttpResult<String> start(@RequestParam(value = "procDefId") String procDefId,
@RequestParam("thsIndex") String thsIndex,
@RequestBody Map<String, Object> variables);
}

View File

@@ -0,0 +1,22 @@
package com.njcn.process.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.pojo.dto.OverLimitFlagDTO;
import com.njcn.process.api.fallback.FlowableTaskFallbackFactory;
import com.njcn.process.api.fallback.RStatWorkOrderFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* 工作流
* @author cdf
* @date 2023/4/13
*/
@FeignClient(value = ServerInfo.PROCESS,path = "/flowable/task",fallbackFactory = FlowableTaskFallbackFactory.class)
public interface FlowableTaskFeignClient {
}

View File

@@ -0,0 +1,48 @@
package com.njcn.process.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.pojo.dto.OverLimitFlagDTO;
import com.njcn.process.api.FlowableDefineFeignClient;
import com.njcn.process.api.RStatWorkOrderFeignClient;
import com.njcn.process.utils.ProcessEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
/**
*
* @author cdf
* @date 2023/4/13
*/
@Slf4j
@Component
public class FlowableDefineFallbackFactory implements FallbackFactory<FlowableDefineFeignClient> {
@Override
public FlowableDefineFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = ProcessEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new FlowableDefineFeignClient() {
@Override
public HttpResult<String> start(String procDefId,
String thsIndex,
Map<String, Object> variables) {
log.error("{}异常,降级处理,异常为:{}", "流程开始", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,39 @@
package com.njcn.process.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.pojo.dto.OverLimitFlagDTO;
import com.njcn.process.api.FlowableTaskFeignClient;
import com.njcn.process.api.RStatWorkOrderFeignClient;
import com.njcn.process.utils.ProcessEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @author cdf
* @date 2023/4/13
*/
@Slf4j
@Component
public class FlowableTaskFallbackFactory implements FallbackFactory<FlowableTaskFeignClient> {
@Override
public FlowableTaskFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = ProcessEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new FlowableTaskFeignClient() {
};
}
}

View File

@@ -0,0 +1,23 @@
package com.njcn.process.pojo.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author Tony
* @date 2021/4/21 20:55
*/
@Data
public class FlowViewerDto implements Serializable {
/**
* 流程key
*/
private String key;
/**
* 是否完成(已经审批)
*/
private boolean completed;
}

View File

@@ -0,0 +1,42 @@
package com.njcn.process.pojo.po;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
*
* </p>
*
* @author hongawen
* @since 2023-04-13
*/
@Getter
@Setter
@TableName("ths_flowable_ass")
public class FlowableAss{
private static final long serialVersionUID = 1L;
/**
* 技术监督主键
*/
@TableId
private String thsIndex;
/**
* 流程实例主键对应部署id deploymentId
*/
private String proIndex;
/**
* 步骤主键
*/
private String execIndex;
}

View File

@@ -0,0 +1,32 @@
package com.njcn.process.pojo.vo.flowable;
import lombok.Data;
/**
* <p>流程任务<p>
*
* @author Tony
* @date 2021-04-03
*/
@Data
public class FlowQueryVo {
private String name;
private String startTime;
private String endTime;
private Integer pageNum;
private Integer pageSize;
}

View File

@@ -0,0 +1,55 @@
package com.njcn.process.pojo.vo.flowable;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* <p>流程任务<p>
*
* @author Tony
* @date 2021-04-03
*/
@Data
public class FlowTaskVo {
private String taskId;
private String userId;
private String comment;
private String instanceId;
private String targetKey;
private String deploymentId;
private String defId;
private String currentChildExecutionId;
private Boolean flag;
private Map<String, Object> variables;
private String assignee;
private List<String> candidateUsers;
private List<String> candidateGroups;
}

View File

@@ -0,0 +1,21 @@
package com.njcn.process.pojo.vo.flowable;
import lombok.Data;
/**
* <p>可退回节点<p>
*
* @author tony
* @date 2022-04-23 11:01:52
*/
@Data
public class ReturnTaskNodeVo {
private String id;
private String name;
}

View File

@@ -90,6 +90,27 @@
<artifactId>common-oss</artifactId> <artifactId>common-oss</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<!-- 多数据源切换当数据源为oracle时需要使用 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<!--flowable-->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.7.2</version>
<!-- 排除flowable自带的权限认证 -->
<exclusions>
<exclusion>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-security</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -0,0 +1,95 @@
package com.njcn.process.controller.flowable;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.service.flowable.IFlowDefinitionService;
import com.njcn.process.service.flowable.IFlowTaskService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Objects;
/**
* pqs
* 工作流
* @author cdf
* @date 2023/4/10
*/
@Slf4j
@Api(tags = "工作流")
@RestController
@RequestMapping("/flowable/definition")
@RequiredArgsConstructor
public class FlowDefinitionController extends BaseController {
private final IFlowDefinitionService flowDefinitionService;
private final RepositoryService repositoryService;
private final RuntimeService runtimeService;
private final TaskService taskService;
private final HistoryService historyService;
private final IFlowTaskService flowTaskService;
@GetMapping("deployment")
@ApiOperation(value = "工作流_部署流程")
public void createDeployment() {
Deployment deployment = repositoryService.createDeployment()
.addClasspathResource("aa.bpmn20.xml")
.name("技术监督预警流程").category("testCategory")
.deploy();
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
repositoryService.setProcessDefinitionCategory(definition.getId(), "testCategory");
System.out.println(deployment.getId());
}
@ApiOperation(value = "工作流_发起流程")
@PostMapping("/start")
public HttpResult<String> start(@ApiParam(value = "流程定义id") @RequestParam(value = "procDefId") String procDefId,
@ApiParam(value = "监督单id") @RequestParam(value = "thsIndex") String thsIndex,
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
String methodDescribe = getMethodDescribe("start");
String res = flowDefinitionService.startProcessInstanceById(procDefId,thsIndex, variables);
if(Objects.nonNull(res)){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
@ApiOperation(value = "工作流_定义删除")
@DeleteMapping(value = "delete/{deployIds}")
public HttpResult<Object> delete(@PathVariable String[] deployIds) {
String methodDescribe = getMethodDescribe("delete");
for (String deployId : deployIds) {
flowDefinitionService.delete(deployId);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -0,0 +1,74 @@
package com.njcn.process.controller.flowable;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.pojo.vo.flowable.FlowQueryVo;
import com.njcn.process.pojo.vo.flowable.FlowTaskVo;
import com.njcn.process.service.flowable.IFlowTaskService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
/**
* <p>工作流任务管理<p>
*
* @author Tony
* @date 2021-04-03
*/
@Slf4j
@Api(tags = "工作流流程任务管理")
@RestController
@RequestMapping("/flowable/task")
@RequiredArgsConstructor
public class FlowTaskController extends BaseController {
private final IFlowTaskService flowTaskService;
@ApiOperation(value = "工作流_审批任务")
@PostMapping(value = "/complete")
public HttpResult complete(@RequestBody FlowTaskVo flowTaskVo) {
boolean res = flowTaskService.complete(flowTaskVo);
return null;
}
/**
* 流程节点信息
*
* @param procInsId 流程实例id
* @return
*/
@GetMapping("/flowXmlAndNode")
@ApiOperation(value = "工作流_流程节点信息")
public HttpResult flowXmlAndNode(@RequestParam(value = "procInsId", required = false) String procInsId,
@RequestParam(value = "deployId", required = false) String deployId) {
String methodDescribe = getMethodDescribe("flowXmlAndNode");
Map<String, Object> res = flowTaskService.flowXmlAndNode(procInsId, deployId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}
}

View File

@@ -0,0 +1,41 @@
package com.njcn.process.factory;
import lombok.Getter;
import org.flowable.engine.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* flowable 引擎注入封装
* @author Tony
* @date 2021-04-03
*/
@Component
@Getter
public class FlowServiceFactory {
@Resource
protected RepositoryService repositoryService;
@Resource
protected RuntimeService runtimeService;
@Resource
protected IdentityService identityService;
@Resource
protected TaskService taskService;
@Resource
protected HistoryService historyService;
@Resource
protected ManagementService managementService;
@Qualifier("processEngine")
@Resource
protected ProcessEngine processEngine;
}

View File

@@ -0,0 +1,17 @@
package com.njcn.process.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.process.pojo.po.FlowableAss;
/**
* <p>
* Mapper 接口
* </p>
*
* @author hongawen
* @since 2023-04-13
*/
public interface FlowableAssMapper extends BaseMapper<FlowableAss> {
}

View File

@@ -4,7 +4,9 @@
<!--查询技术监督列表--> <!--查询技术监督列表-->
<select id="querySuperviseList" parameterType="com.njcn.prepare.harmonic.pojo.dto.SuperviseDto" <select id="querySuperviseList" parameterType="com.njcn.prepare.harmonic.pojo.dto.SuperviseDto"
resultType="com.njcn.prepare.harmonic.pojo.vo.SuperviseVo"> resultType="com.njcn.prepare.harmonic.pojo.vo.SuperviseVo">
select ts.* from ths_supervise ts where 1=1 select ts.*,ass.pro_index as deploymentId,exec_index as execId from ths_supervise ts
left join ths_flowable_ass ass on ts.sup_index = ass.ths_index
where 1=1
<if test="param.searchValue != null and param.searchValue != ''"> <if test="param.searchValue != null and param.searchValue != ''">
AND ts.name like CONCAT(CONCAT('%', #{param.searchValue}), '%') AND ts.name like CONCAT(CONCAT('%', #{param.searchValue}), '%')
</if> </if>

View File

@@ -0,0 +1,54 @@
package com.njcn.process.service.flowable;
import com.njcn.common.pojo.response.HttpResult;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import java.util.Map;
/**
* @author Tony
* @date 2021-04-03 14:41
*/
public interface IFlowDefinitionService {
/**
* 根据流程定义ID启动流程实例
*
* @param procDefId 流程模板ID
* @param variables 流程变量
* @return
*/
String startProcessInstanceById(String procDefId,String thsIndex, Map<String, Object> variables);
/**
* 删除流程定义
*
* @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
*/
void delete(String deployId);
/**
* 删除流程实例ID
*
* @param instanceId 流程实例ID
* @param deleteReason 删除原因
*/
void deleteInstance(String instanceId, String deleteReason);
/**
* 根据实例ID查询历史实例数据
*
* @param processInstanceId
* @return
*/
HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId);
}

View File

@@ -0,0 +1,48 @@
package com.njcn.process.service.flowable;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.process.pojo.vo.flowable.FlowTaskVo;
import org.flowable.task.api.Task;
import java.util.Map;
/**
* @author Tony
* @date 2021-04-03 14:42
*/
public interface IFlowTaskService {
Boolean getNextFlowNodeByStart(FlowTaskVo flowTaskVo);
/**
* 流程节点信息
* @param procInsId
* @return
*/
Map<String, Object> flowXmlAndNode(String procInsId, String deployId);
Boolean deleteDeployment();
/**
* 审批任务
*
*
*/
Boolean complete(FlowTaskVo taskVo);
/**
* 获取任务
* @author cdf
* @date 2023/4/14
*/
Task getTask(String proIndex);
}

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -30,9 +31,13 @@ import com.njcn.process.annotaion.InterharVoltage;
import com.njcn.process.enums.*; import com.njcn.process.enums.*;
import com.njcn.process.mapper.*; import com.njcn.process.mapper.*;
import com.njcn.process.pojo.param.FileParam; import com.njcn.process.pojo.param.FileParam;
import com.njcn.process.pojo.po.FlowableAss;
import com.njcn.process.pojo.po.LimitRate; import com.njcn.process.pojo.po.LimitRate;
import com.njcn.process.pojo.po.ThsAlarmFormwork; import com.njcn.process.pojo.po.ThsAlarmFormwork;
import com.njcn.process.pojo.vo.flowable.FlowTaskVo;
import com.njcn.process.service.ThsSuperviseService; import com.njcn.process.service.ThsSuperviseService;
import com.njcn.process.service.flowable.IFlowDefinitionService;
import com.njcn.process.service.flowable.IFlowTaskService;
import com.njcn.process.utils.ReadPatientExcelUtil; import com.njcn.process.utils.ReadPatientExcelUtil;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
@@ -40,9 +45,11 @@ import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept; import com.njcn.user.pojo.po.Dept;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -70,31 +77,40 @@ import java.util.zip.ZipOutputStream;
*/ */
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor
public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, ThsSupervise> implements ThsSuperviseService { public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, ThsSupervise> implements ThsSuperviseService {
@Autowired
private PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
@Autowired private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private ThsWarnStrategyMapper thsWarnStrategyMapper;
@Autowired
private ThsWarnStrategyAssMapper thsWarnStrategyAssMapper; private final ThsWarnStrategyMapper thsWarnStrategyMapper;
@Autowired
private MonitorClient monitorClient; private final ThsWarnStrategyAssMapper thsWarnStrategyAssMapper;
@Autowired
private DicDataFeignClient dicDataFeignClient; private final MonitorClient monitorClient;
@Autowired
private ThsSuperviseMapper thsSuperviseMapper; private final DicDataFeignClient dicDataFeignClient;
@Autowired
private ThsOverRunLogMapper thsOverRunLogMapper; private final ThsSuperviseMapper thsSuperviseMapper;
@Autowired
private DeptFeignClient deptFeignClient; private final ThsOverRunLogMapper thsOverRunLogMapper;
@Autowired
private FileStorageUtil fileStorageUtil; private final DeptFeignClient deptFeignClient;
@Autowired
private ThsAlarmFormworkMapper thsAlarmFormworkMapper; private final FileStorageUtil fileStorageUtil;
private final ThsAlarmFormworkMapper thsAlarmFormworkMapper;
private static final String DESCRIPTION = "description"; private static final String DESCRIPTION = "description";
private final IFlowDefinitionService iFlowDefinitionService;
private final IFlowTaskService iFlowTaskService;
private final FlowableAssMapper flowableAssMapper;
/** /**
* 构建技术监督名称 * 构建技术监督名称
* *
@@ -127,6 +143,10 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
thsSupervise.setSupIndex(IdUtil.simpleUUID()); thsSupervise.setSupIndex(IdUtil.simpleUUID());
this.buildSuperviseName(thsSupervise, superviceRunLogVo.getOverRunLog(), dept); this.buildSuperviseName(thsSupervise, superviceRunLogVo.getOverRunLog(), dept);
this.thsSuperviseMapper.insert(thsSupervise); this.thsSuperviseMapper.insert(thsSupervise);
//TODO 解决工作流写死问题
Map<String, Object> mapParam = new HashMap<>();
iFlowDefinitionService.startProcessInstanceById("flow_yzep99kb:1:a100b48b-da75-11ed-8335-b07b253cdad9",thsSupervise.getSupIndex(),mapParam);
for (ThsOverRunLog thsOverRunLog : superviceRunLogVo.getOverRunLog()) { for (ThsOverRunLog thsOverRunLog : superviceRunLogVo.getOverRunLog()) {
thsOverRunLog.setCreateTime(date); thsOverRunLog.setCreateTime(date);
thsOverRunLog.setSupIndex(thsSupervise.getSupIndex()); thsOverRunLog.setSupIndex(thsSupervise.getSupIndex());
@@ -175,31 +195,58 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public HttpResult deleteSupervise(SuperviseDto superviseDto) { public HttpResult deleteSupervise(SuperviseDto superviseDto) {
if (CollectionUtil.isNotEmpty(superviseDto.getDeleteIds())) { if (CollectionUtil.isNotEmpty(superviseDto.getDeleteIds())) {
superviseDto.getDeleteIds().forEach(id -> { superviseDto.getDeleteIds().forEach(id -> {
thsOverRunLogMapper.delete(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, id)); thsOverRunLogMapper.delete(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, id));
thsSuperviseMapper.delete(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, id)); thsSuperviseMapper.delete(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, id));
//删除同时删除工作流程
FlowableAss flowableAss = flowableAssMapper.selectById(id);
if(Objects.nonNull(flowableAss)) {
iFlowDefinitionService.deleteInstance(flowableAss.getExecIndex(), "");
flowableAssMapper.deleteById(id);
}
}); });
} }
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, null);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "删除技术监督");
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void uploadSuperviseTicket(String id, String supIndex, Integer ticketType, MultipartFile[] files, HttpServletResponse response) { public void uploadSuperviseTicket(String id, String supIndex, Integer ticketType, MultipartFile[] files, HttpServletResponse response) {
ThsSupervise thsSupervise = new ThsSupervise(); ThsSupervise thsSupervise = new ThsSupervise();
thsSupervise.setSupIndex(supIndex); thsSupervise.setSupIndex(supIndex);
ThsSupervise thsSuperObj = thsSuperviseMapper.selectById(supIndex);
if (files != null && files.length == 1) { if (files != null && files.length == 1) {
ThsOverRunLog thsOverRunLog = thsOverRunLogMapper.selectById(id); ThsOverRunLog thsOverRunLog = thsOverRunLogMapper.selectById(id);
thsOverRunLog.setId(id); thsOverRunLog.setId(id);
String path = fileStorageUtil.uploadMultipart(files[0], OssPath.ELECTRICITY_QUALITY); String path = fileStorageUtil.uploadMultipart(files[0], OssPath.ELECTRICITY_QUALITY);
this.updateSuperviesData(path, thsOverRunLog, ticketType, thsSupervise); this.updateSuperviesData(path, thsOverRunLog, ticketType, thsSupervise);
this.updateProcess(thsSupervise, ticketType); this.updateProcess(thsSupervise, ticketType,thsSuperObj.getType());
} }
if (files != null && files.length > 1) { if (files != null && files.length > 1) {
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex)); List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
this.batchUploadFile(thsSupervise, thsOverRunLogs, files, ticketType); this.batchUploadFile(thsSupervise, thsOverRunLogs, files, ticketType);
this.updateProcess(thsSupervise, ticketType); this.updateProcess(thsSupervise, ticketType,thsSuperObj.getType());
}
//判断当监督单下面的监测点报告都被上传则认为流程完成
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
List<String> fileNames = thsOverRunLogs.stream().filter(item-> StrUtil.isNotBlank(item.getFeedback())).map(ThsOverRunLog::getFileName).distinct().collect(Collectors.toList());
if(fileNames.size() == thsOverRunLogs.size()){
FlowableAss flowableAss = flowableAssMapper.selectById(supIndex);
Task task = iFlowTaskService.getTask(flowableAss.getExecIndex());
FlowTaskVo flowTaskVo = new FlowTaskVo();
flowTaskVo.setAssignee(RequestUtil.getUserIndex());
flowTaskVo.setTaskId(task.getId());
iFlowTaskService.complete(flowTaskVo);
} }
} }
@@ -208,8 +255,9 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
* *
* @param thsSupervise * @param thsSupervise
* @param ticketType * @param ticketType
* @param type
*/ */
private void updateProcess(ThsSupervise thsSupervise, Integer ticketType) { private void updateProcess(ThsSupervise thsSupervise, Integer ticketType,Integer type) {
TicketTypeEnum ticketTypeEnum = TicketTypeEnum.getTicketTypeEnumByCode(ticketType); TicketTypeEnum ticketTypeEnum = TicketTypeEnum.getTicketTypeEnumByCode(ticketType);
if (ticketTypeEnum == null) { if (ticketTypeEnum == null) {
throw new BusinessException("上传单据参数类型错误!"); throw new BusinessException("上传单据参数类型错误!");
@@ -219,7 +267,11 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
thsSupervise.setProgress(ProgressEnum.TEST_REPORT.getCode()); thsSupervise.setProgress(ProgressEnum.TEST_REPORT.getCode());
break; break;
case TEST_REPORT: case TEST_REPORT:
thsSupervise.setProgress(ProgressEnum.REVISE_NOTICE_ISSUE.getCode()); if(AlarmTypeEnum.EARLY_WARN.getCode().equals(type)){
thsSupervise.setProgress(ProgressEnum.END.getCode());
}else {
thsSupervise.setProgress(ProgressEnum.REVISE_NOTICE_ISSUE.getCode());
}
break; break;
case REVISE_FEEDBACK: case REVISE_FEEDBACK:
thsSupervise.setProgress(ProgressEnum.END.getCode()); thsSupervise.setProgress(ProgressEnum.END.getCode());
@@ -318,6 +370,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void uploadAlarmFormwork(Integer type, Integer formworkType, MultipartFile file, HttpServletResponse response) { public void uploadAlarmFormwork(Integer type, Integer formworkType, MultipartFile file, HttpServletResponse response) {
thsAlarmFormworkMapper.delete(new LambdaQueryWrapper<ThsAlarmFormwork>().eq(ThsAlarmFormwork::getFormworkType, formworkType) thsAlarmFormworkMapper.delete(new LambdaQueryWrapper<ThsAlarmFormwork>().eq(ThsAlarmFormwork::getFormworkType, formworkType)
.eq(ThsAlarmFormwork::getType, type)); .eq(ThsAlarmFormwork::getType, type));
@@ -328,9 +381,14 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
alarmFormwork.setFormworkType(formworkType); alarmFormwork.setFormworkType(formworkType);
alarmFormwork.setPath(path); alarmFormwork.setPath(path);
thsAlarmFormworkMapper.insert(alarmFormwork); thsAlarmFormworkMapper.insert(alarmFormwork);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public String dowloadAlarmFormwork(Integer type, Integer formworkType, String supIndex, HttpServletResponse response) { public String dowloadAlarmFormwork(Integer type, Integer formworkType, String supIndex, HttpServletResponse response) {
ThsAlarmFormwork thsAlarmFormwork = thsAlarmFormworkMapper.selectOne(new LambdaQueryWrapper<ThsAlarmFormwork>().eq(ThsAlarmFormwork::getFormworkType, formworkType) ThsAlarmFormwork thsAlarmFormwork = thsAlarmFormworkMapper.selectOne(new LambdaQueryWrapper<ThsAlarmFormwork>().eq(ThsAlarmFormwork::getFormworkType, formworkType)
.eq(ThsAlarmFormwork::getType, type).last("limit 1")); .eq(ThsAlarmFormwork::getType, type).last("limit 1"));
@@ -352,6 +410,15 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
} }
thsOverRunLogMapper.update(thsOverRunLog, new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex)); thsOverRunLogMapper.update(thsOverRunLog, new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
thsSuperviseMapper.update(thsSupervise, new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, supIndex)); thsSuperviseMapper.update(thsSupervise, new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, supIndex));
FlowableAss flowableAss = flowableAssMapper.selectById(supIndex);
Task task = iFlowTaskService.getTask(flowableAss.getExecIndex());
FlowTaskVo flowTaskVo = new FlowTaskVo();
flowTaskVo.setAssignee(RequestUtil.getUserIndex());
flowTaskVo.setTaskId(task.getId());
iFlowTaskService.complete(flowTaskVo);
return fileUrl; return fileUrl;
} }

View File

@@ -0,0 +1,149 @@
package com.njcn.process.service.impl.flowable;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.process.factory.FlowServiceFactory;
import com.njcn.process.mapper.FlowableAssMapper;
import com.njcn.process.pojo.po.FlowableAss;
import com.njcn.process.service.flowable.IFlowDefinitionService;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.repository.ProcessDefinitionQuery;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.image.impl.DefaultProcessDiagramGenerator;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 流程定义
*
* @author Tony
* @date 2021-04-03
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService {
private static final String BPMN_FILE_SUFFIX = ".bpmn";
private final FlowableAssMapper flowableAssMapper;
/**
* 根据流程定义ID启动流程实例
*
* @param procDefId 流程模板ID
* @param variables 流程变量
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String startProcessInstanceById(String procDefId,String thsIndex, Map<String, Object> variables) {
try {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
.latestVersion().singleResult();
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
throw new BusinessException("流程已被挂起,请先激活流程");
}
// 设置流程发起人Id到流程中
identityService.setAuthenticatedUserId(RequestUtil.getUserIndex());
variables.put("INITIATOR", RequestUtil.getUserIndex());
ProcessInstance res = runtimeService.startProcessInstanceById(procDefId, variables);
FlowableAss flowableAss = new FlowableAss();
flowableAss.setThsIndex(thsIndex);
flowableAss.setProIndex(res.getDeploymentId());
flowableAss.setExecIndex(res.getProcessInstanceId());
flowableAssMapper.insert(flowableAss);
return res.getCallbackId();
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("开始流程出错!");
}
}
/**
* 删除流程定义
*
* @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
*/
@Override
public void delete(String deployId) {
// true 允许级联删除 ,不设置会导致数据库外键关联异常
repositoryService.deleteDeployment(deployId, true);
flowableAssMapper.delete(new LambdaQueryWrapper<FlowableAss>().eq(FlowableAss::getProIndex,deployId));
}
/**
* 删除流程实例ID
*
* @param instanceId 流程实例ID
* @param deleteReason 删除原因
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteInstance(String instanceId, String deleteReason) {
// 查询历史数据
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstanceById(instanceId);
if (historicProcessInstance.getEndTime() != null) {
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
return;
}
// 删除流程实例
runtimeService.deleteProcessInstance(instanceId, deleteReason);
// 删除历史流程实例
historyService.deleteHistoricProcessInstance(instanceId);
}
/**
* 根据实例ID查询历史实例数据
*
* @param processInstanceId
* @return
*/
@Override
public HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId) {
HistoricProcessInstance historicProcessInstance =
historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (Objects.isNull(historicProcessInstance)) {
throw new FlowableObjectNotFoundException("流程实例不存在: " + processInstanceId);
}
return historicProcessInstance;
}
}

View File

@@ -0,0 +1,144 @@
package com.njcn.process.service.impl.flowable;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.process.factory.FlowServiceFactory;
import com.njcn.process.pojo.dto.FlowViewerDto;
import com.njcn.process.pojo.vo.flowable.FlowTaskVo;
import com.njcn.process.service.flowable.IFlowTaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.*;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.impl.cmd.AddMultiInstanceExecutionCmd;
import org.flowable.engine.impl.cmd.DeleteMultiInstanceExecutionCmd;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.engine.task.Comment;
import org.flowable.identitylink.api.history.HistoricIdentityLink;
import org.flowable.image.ProcessDiagramGenerator;
import org.flowable.task.api.DelegationState;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* @author Tony
* @date 2021-04-03
**/
@Service
@Slf4j
public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTaskService {
@Override
public Boolean getNextFlowNodeByStart(FlowTaskVo flowTaskVo) {
return null;
}
@Override
public Map<String, Object> flowXmlAndNode(String procInsId, String deployId) {
try {
List<FlowViewerDto> flowViewerList = new ArrayList<>();
// 获取已经完成的节点
List<HistoricActivityInstance> listFinished = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(procInsId)
.finished()
.list();
// 保存已经完成的流程节点编号
listFinished.forEach(s -> {
FlowViewerDto flowViewerDto = new FlowViewerDto();
flowViewerDto.setKey(s.getActivityId());
flowViewerDto.setCompleted(true);
flowViewerList.add(flowViewerDto);
});
// 获取代办节点
List<HistoricActivityInstance> listUnFinished = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(procInsId)
.unfinished()
.list();
// 保存需要代办的节点编号
listUnFinished.forEach(s -> {
FlowViewerDto flowViewerDto = new FlowViewerDto();
flowViewerDto.setKey(s.getActivityId());
flowViewerDto.setCompleted(false);
flowViewerList.add(flowViewerDto);
});
Map<String, Object> result = new HashMap();
// xmlData 数据
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName());
String xmlData = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
result.put("nodeData", flowViewerList);
result.put("xmlData", xmlData);
return result;
} catch (Exception e) {
throw new BusinessException("");
}
}
@Override
public Boolean deleteDeployment() {
return null;
}
/**
* 完成任务
*
* @param taskVo 请求实体参数
*/
@Transactional(rollbackFor = Exception.class)
@Override
public Boolean complete(FlowTaskVo taskVo) {
Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult();
if (Objects.isNull(task)) {
throw new BusinessException("任务不存在");
}
if (DelegationState.PENDING.equals(task.getDelegationState())) {
//taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment());
//taskService.resolveTask(taskVo.getTaskId(), taskVo.getVariables());
} else {
//taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment());
//Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
taskService.setAssignee(taskVo.getTaskId(), "1");
taskService.complete(taskVo.getTaskId(), taskVo.getVariables());
}
return true;
}
@Override
public Task getTask(String proIndex) {
return taskService.createTaskQuery()
.processInstanceId(proIndex).singleResult();
}
}

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0"
xmlns:flowable="http://flowable.org/bpmn"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.flowable.org/processdef">
<process id="flow_yzep99kb" name="flow_pjpqvxgw" flowable:processCategory="null">
<startEvent id="start_event" name="开始">
<outgoing>Flow_1wrqzmd</outgoing>
</startEvent>
<userTask id="Activity_11eo5gu" name="监督单下发" flowable:userType="assignee" flowable:dataType="dynamic" flowable:assignee="${INITIATOR}">
<incoming>Flow_1wrqzmd</incoming>
<outgoing>Flow_0q5q2pr</outgoing>
</userTask>
<sequenceFlow id="Flow_1wrqzmd" name="" sourceRef="start_event" targetRef="Activity_11eo5gu" />
<userTask id="Activity_1xjk88s" name="监督反馈单上传" flowable:userType="assignee" flowable:dataType="dynamic" flowable:assignee="${INITIATOR}">
<incoming>Flow_0q5q2pr</incoming>
<outgoing>Flow_17er5rz</outgoing>
</userTask>
<sequenceFlow id="Flow_0q5q2pr" name="" sourceRef="Activity_11eo5gu" targetRef="Activity_1xjk88s" />
<endEvent id="Event_12lq7e1" name="结束">
<incoming>Flow_01tmwhj</incoming>
</endEvent>
<sequenceFlow id="Flow_17er5rz" name="" sourceRef="Activity_1xjk88s" targetRef="Activity_04362zn" />
<userTask id="Activity_04362zn" name="测试报告上传" flowable:userType="candidateUsers" flowable:dataType="dynamic" flowable:candidateUsers="${INITIATOR}">
<incoming>Flow_17er5rz</incoming>
<outgoing>Flow_01tmwhj</outgoing>
</userTask>
<sequenceFlow id="Flow_01tmwhj" name="" sourceRef="Activity_04362zn" targetRef="Event_12lq7e1" />
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_flow">
<bpmndi:BPMNPlane id="BPMNPlane_flow" bpmnElement="flow_yzep99kb">
<bpmndi:BPMNShape id="BPMNShape_start_event" bpmnElement="start_event" bioc:stroke="">
<omgdc:Bounds x="-225" y="105" width="30" height="30" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="-222" y="142" width="23" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_11eo5gu_di" bpmnElement="Activity_11eo5gu">
<omgdc:Bounds x="-120" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1xjk88s_di" bpmnElement="Activity_1xjk88s">
<omgdc:Bounds x="60" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_12lq7e1_di" bpmnElement="Event_12lq7e1">
<omgdc:Bounds x="442" y="102" width="36" height="36" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="449" y="145" width="23" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_04362zn_di" bpmnElement="Activity_04362zn">
<omgdc:Bounds x="250" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1wrqzmd_di" bpmnElement="Flow_1wrqzmd">
<di:waypoint x="-195" y="120" />
<di:waypoint x="-120" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0q5q2pr_di" bpmnElement="Flow_0q5q2pr">
<di:waypoint x="-20" y="120" />
<di:waypoint x="60" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_17er5rz_di" bpmnElement="Flow_17er5rz">
<di:waypoint x="160" y="120" />
<di:waypoint x="250" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_01tmwhj_di" bpmnElement="Flow_01tmwhj">
<di:waypoint x="350" y="120" />
<di:waypoint x="442" y="120" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

View File

@@ -39,6 +39,9 @@ spring:
max-file-size: 100MB max-file-size: 100MB
max-request-size: 100MB max-request-size: 100MB
flowable:
#关闭定时任务JOB
async-executor-activate: false
#项目日志的配置 #项目日志的配置
logging: logging: