Browse Source

修正:工作流补偿机制消息发送修改

zhongwei
ty 3 months ago
parent
commit
2bf6cd4002
  1. 4
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java
  2. 39
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java
  3. 2
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java

4
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java

@ -49,8 +49,8 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
throw new ServiceException("消息转换失败,消息内容为:" + message); throw new ServiceException("消息转换失败,消息内容为:" + message);
}); });
if (ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ if (ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){
ticketServiceList.get(0).pushFailMessage(Long.valueOf(response.getTaskId()),response.getBusinessKey(), ticketServiceList.get(0).pushFailMessage(response.getTaskId(),response.getProcessDefinitionKey(),
response.getUserId(), response.getTaskName(),response.getResult(),response.getDeptId()); response.getTaskName(),response.getResult(),response.getDeptId());
} }
// 保存日志 // 保存日志
WorkflowOperationLog log = BeanUtil.copy(response, WorkflowOperationLog.class); WorkflowOperationLog log = BeanUtil.copy(response, WorkflowOperationLog.class);

39
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java

@ -4,13 +4,14 @@ import com.hnac.hzims.middle.processflow.entity.ProcessDict;
import com.hnac.hzims.middle.processflow.service.ProcessDictService; import com.hnac.hzims.middle.processflow.service.ProcessDictService;
import com.hnac.hzims.middle.processflow.strategy.service.ProcessService; import com.hnac.hzims.middle.processflow.strategy.service.ProcessService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.message.MessageConstants; import org.springblade.message.MessageConstants;
import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.dto.BusinessMessageFlowDTO;
import org.springblade.message.fegin.IMessageClient; import org.springblade.message.fegin.IMessageClient;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
@ -60,7 +61,7 @@ public abstract class ProcessAbstractService implements ProcessService {
log.error("开启流程失败:{}",result); log.error("开启流程失败:{}",result);
log.error("流程信息为{}",variables); log.error("流程信息为{}",variables);
r.setData(variables); r.setData(variables);
pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg()); pushStartFailMessage(dictValue,taskId,userId,processName,result.getMsg());
} }
return r; return r;
}catch (Exception e){ }catch (Exception e){
@ -85,9 +86,9 @@ public abstract class ProcessAbstractService implements ProcessService {
// return r; // return r;
// } // }
public void pushStartFailMessage(String dictValue,Long taskId, String userId, String content,String reason) { public void pushStartFailMessage(String dictValue,String taskId, String userId, String content,String reason) {
ProcessDict processDict = processDictService.selectDictLabelByKey(dictValue); ProcessDict processDict = processDictService.selectDictLabelByKey(dictValue);
BusinessMessageDTO message = new BusinessMessageDTO(); BusinessMessageFlowDTO message = new BusinessMessageFlowDTO();
// 计划Id // 计划Id
message.setTaskId(taskId); message.setTaskId(taskId);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
@ -108,13 +109,14 @@ public abstract class ProcessAbstractService implements ProcessService {
} }
message.setCreateUser(admin.getId()); message.setCreateUser(admin.getId());
message.setUserIds(userId); message.setUserIds(userId);
messageClient.sendAppAndWsMsgByUsers(message); messageClient.sendAppAndWsMsgByUsersFlow(message);
} }
@Override @Override
public void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId) { public void pushFailMessage(String taskId, String proessKey, String content,String reason,String deptId) {
ProcessDict processDict = processDictService.selectDictLabelByKey(proessKey); ProcessDict processDict = processDictService.selectDictLabelByKey(proessKey);
BusinessMessageDTO message = new BusinessMessageDTO(); BusinessMessageFlowDTO message = new BusinessMessageFlowDTO();
// BusinessMessageDTO message = new BusinessMessageDTO();
// 计划Id // 计划Id
message.setTaskId(taskId); message.setTaskId(taskId);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
@ -126,18 +128,27 @@ public abstract class ProcessAbstractService implements ProcessService {
processDict.getDictLabel(), reason); processDict.getDictLabel(), reason);
message.setContent(res); message.setContent(res);
message.setTenantId("200000"); message.setTenantId("200000");
R<List<User>> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.valueOf(deptId), PROJECT_MANAGER); R<List<User>> userListR = userClient.queryUserByRoleAlias("200000", Long.valueOf(deptId), PROJECT_MANAGER);
User admin = userClient.userByAccount("200000", "admin").getData(); User admin = userClient.userByAccount("200000", "admin").getData();
User createUser = userClient.userInfoById(Long.valueOf(userId)).getData(); message.setDeptId(Long.valueOf(deptId));
message.setDeptId(createUser.getCreateDept()); R<String> result = sysClient.getDeptName(Long.valueOf(deptId));
R<String> result = sysClient.getDeptName(createUser.getCreateDept());
if (result.isSuccess()) { if (result.isSuccess()) {
message.setDeptName(result.getData()); message.setDeptName(result.getData());
} }
if (CollectionUtil.isNotEmpty(userListR.getData())){
List<User> data = userListR.getData(); List<User> data = userListR.getData();
String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(","));
message.setCreateUser(admin.getId());
message.setUserIds(userIds); message.setUserIds(userIds);
messageClient.sendAppAndWsMsgByUsers(message); }else {
R<List<User>> listR = userClient.queryUserByRoleAlias("200000", Long.valueOf(20000001), PROJECT_MANAGER);
if (ObjectUtil.isEmpty(listR)||CollectionUtil.isEmpty(listR.getData())){
return;
}
List<User> data =listR.getData();
String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(","));
message.setUserIds(userIds);
}
message.setCreateUser(admin.getId());
messageClient.sendAppAndWsMsgByUsersFlow(message);
} }
} }

2
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java

@ -16,7 +16,7 @@ public interface ProcessService {
R startFlow(String userId, String dictValue, String taskId, String processName, Map<String, Object> variables) ; R startFlow(String userId, String dictValue, String taskId, String processName, Map<String, Object> variables) ;
void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId); void pushFailMessage(String taskId, String proessKey, String content,String reason,String deptId);
/** /**
* 设置执行那种实现类 * 设置执行那种实现类
* @param flowQueue * @param flowQueue

Loading…
Cancel
Save