流程状态变化,更新业务表操作实现
This commit is contained in:
@@ -32,6 +32,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>supervision-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>user-api</artifactId>
|
||||
|
||||
@@ -229,7 +229,7 @@ public class BpmTaskController extends BaseController {
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/return")
|
||||
@PostMapping("/return")
|
||||
@ApiOperation("回退任务")
|
||||
@ApiImplicitParam(name = "bpmTaskReturnParam", value = "查询参数", required = true)
|
||||
public HttpResult<Boolean> returnTask(@Validated @RequestBody BpmTaskReturnParam bpmTaskReturnParam) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.bpm.event;
|
||||
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEvent;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.bpm.event;
|
||||
package com.njcn.bpm.listener;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.bpm.listener;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
|
||||
/**
|
||||
* {@link BpmProcessInstanceStatusEvent} 的监听器
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public abstract class BpmProcessInstanceStatusEventListener
|
||||
implements ApplicationListener<BpmProcessInstanceStatusEvent> {
|
||||
|
||||
@Override
|
||||
public final void onApplicationEvent(BpmProcessInstanceStatusEvent event) {
|
||||
if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) {
|
||||
return;
|
||||
}
|
||||
onEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回监听的流程定义 Key
|
||||
*/
|
||||
protected abstract String getProcessDefinitionKey();
|
||||
|
||||
/**
|
||||
* 处理事件
|
||||
*
|
||||
* @param event 事件
|
||||
*/
|
||||
protected abstract void onEvent(BpmProcessInstanceStatusEvent event);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.bpm.listener.business;
|
||||
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEvent;
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEventListener;
|
||||
import com.njcn.supervision.api.UserReportFeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@Component
|
||||
public class BpmUserReportStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||
|
||||
@Resource
|
||||
private UserReportFeignClient userReportFeignClient;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return "build_user_info";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||
userReportFeignClient.updateUserReportStatus(event.getBusinessKey(), event.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.njcn.bpm.utils;
|
||||
|
||||
import com.njcn.bpm.event.BpmProcessInstanceStatusEvent;
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEvent;
|
||||
import com.njcn.bpm.pojo.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
|
||||
import com.njcn.bpm.pojo.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
|
||||
import com.njcn.bpm.pojo.dto.PageResult;
|
||||
@@ -9,7 +9,6 @@ import com.njcn.bpm.pojo.po.BpmProcessDefinitionInfo;
|
||||
import com.njcn.bpm.pojo.vo.BpmProcessDefinitionInfoVO;
|
||||
import com.njcn.bpm.pojo.vo.instance.BpmProcessInstanceVO;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.supervision.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.supervision.api.fallback.UserReportFeignClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
/**
|
||||
* 流程实例 Api 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.SUPERVISION, path = "/userReport", fallbackFactory = UserReportFeignClientFallbackFactory.class)
|
||||
public interface UserReportFeignClient {
|
||||
|
||||
@GetMapping("/updateUserReportStatus")
|
||||
HttpResult<Object> updateUserReportStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.supervision.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.supervision.api.UserReportFeignClient;
|
||||
import com.njcn.supervision.utils.SupervisionEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class UserReportFeignClientFallbackFactory implements FallbackFactory<UserReportFeignClient> {
|
||||
@Override
|
||||
public UserReportFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = SupervisionEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new UserReportFeignClient() {
|
||||
@Override
|
||||
public HttpResult<Object> updateUserReportStatus(String businessKey, Integer status) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "更新用户数据流程状态", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -92,4 +92,13 @@ public class UserReportManageController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReportVO, methodDescribe);
|
||||
}
|
||||
|
||||
@GetMapping("/updateUserReportStatus")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@Operation(summary = "根据id获取用户档案录入的详细数据")
|
||||
public HttpResult<Object> updateUserReportStatus(String businessKey,Integer status) {
|
||||
String methodDescribe = getMethodDescribe("updateUserReportStatus");
|
||||
userReportPOService.updateUserReportStatus(businessKey,status);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface UserReportPOService extends IService<UserReportPO> {
|
||||
Boolean removeUserReport(List<String> ids);
|
||||
|
||||
UserReportVO getVOById(String id);
|
||||
|
||||
void updateUserReportStatus(String businessKey, Integer status);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.bpm.api.BpmProcessFeignClient;
|
||||
import com.njcn.bpm.enums.BpmTaskStatusEnum;
|
||||
import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
@@ -72,6 +73,7 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
|
||||
UserReportPO userReportPO = new UserReportPO();
|
||||
BeanUtils.copyProperties(userReportParam, userReportPO);
|
||||
userReportPO.setState(DataStateEnum.ENABLE.getCode());
|
||||
userReportPO.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
this.save(userReportPO);
|
||||
if (
|
||||
CollectionUtil.newArrayList(
|
||||
@@ -191,6 +193,13 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
|
||||
return userReportVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserReportStatus(String businessKey, Integer status) {
|
||||
UserReportPO userReportPO = this.baseMapper.selectById(businessKey);
|
||||
userReportPO.setStatus(status);
|
||||
this.updateById(userReportPO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有字段为null的属性名
|
||||
|
||||
Reference in New Issue
Block a user