Commit 48c86dfe authored by suhuiguang's avatar suhuiguang

1.删除暂时不用代码

parent 83f16ff0
package com.yeejoin.amos.boot.module.jg.biz.listener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.biz.message.WorkFlowMessageListener;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.annotation.PostConstruct;
import java.util.List;
@Slf4j
@Component
public class PublicWorkFlowMessage extends EmqxListener {
@Autowired
protected EmqKeeper emqKeeper;
@Autowired
AmosRequestContext amosAuth;
private List<WorkFlowMessageListener> workFlowMessageListeners;
public PublicWorkFlowMessage(List<WorkFlowMessageListener> workFlowMessageListeners) {
this.workFlowMessageListeners = workFlowMessageListeners;
}
/**
* 创建任务主题
*/
private static final String WORKFLOW_TASK_CREATED = "workflow/task/created";
/**
* 执行完成任务主题
*/
private static final String WORKFLOW_TASK_COMPLETED = "workflow/task/completed";
/**
* 流程执行结束主题
*/
private static final String WORKFLOW_PROCESS_COMPLETE = "workflow/process/complete";
@Autowired
StartPlatformTokenService platformTokenService;
@Autowired
AmosRequestContext amosRequestContext;
@PostConstruct
void init() throws Exception {
emqKeeper.subscript(WORKFLOW_TASK_CREATED, 2, this);
emqKeeper.subscript(WORKFLOW_TASK_COMPLETED, 2, this);
emqKeeper.subscript(WORKFLOW_PROCESS_COMPLETE, 2, this);
}
@Override
public void processMessage(String topic, MqttMessage message) {
JSONObject messageObject = JSON.parseObject(new String(message.getPayload()));
log.info("收到工作流消息,主题:{},内容:{}", topic, messageObject);
String processDefinitionKey = messageObject.get("processDefinitionKey").toString();
String type = getApprovalStatusStr(messageObject);
WorkFlowMessageListener.BizTypeEnum bizTypeEnum = WorkFlowMessageListener.getEnum(processDefinitionKey);
RequestContext.setToken(amosRequestContext.getToken());
RequestContext.setAppKey(amosRequestContext.getAppKey());
RequestContext.setProduct(amosRequestContext.getProduct());
workFlowMessageListeners.forEach(h -> {
if (h.canHandlerType().equals(bizTypeEnum)) {
switch (topic) {
case WORKFLOW_TASK_CREATED:
h.afterCreate(messageObject);
break;
case WORKFLOW_TASK_COMPLETED:
h.afterComplete(type, messageObject);
break;
case WORKFLOW_PROCESS_COMPLETE:
h.afterFinish(messageObject);
break;
default:
break;
}
}
});
}
private String getApprovalStatusStr(JSONObject messageObject) {
String type = "";
JSONObject variables = messageObject.getJSONObject("variables");
if (variables != null) {
type = variables.getString("approvalStatus");
}
return type;
}
}
package com.yeejoin.amos.boot.module.jg.biz.message;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author Administrator
*/
@Component
public class InstallationNoticeMsgListener implements WorkFlowMessageListener {
@Autowired
JgInstallationNoticeServiceImpl jgInstallationNoticeService;
/**
* 处理消息方法-Create
* 1.更新业务数据【instanceId、nextExecutedIds、status、instanceStatus(所有执行过的加下一步待执行角色)】
* 2.创建待办(初始未完成状态)
* @param message message 消息内容
*/
@Override
public void afterCreate(JSONObject message) {
jgInstallationNoticeService.updateByWorkFlow(message);
}
@Override
public void afterComplete(String type, JSONObject message) {
jgInstallationNoticeService.completeWorkFlow(type, message);
}
@Override
public void afterFinish(JSONObject message) {
String businessKey = message.getString("businessKey");
JgInstallationNotice jgInstallationNotice = jgInstallationNoticeService.getBaseMapper().selectById(businessKey);
jgInstallationNoticeService.finishTask(jgInstallationNotice);
}
@Override
public BizTypeEnum canHandlerType() {
return BizTypeEnum.installationNotificationNew;
}
}
package com.yeejoin.amos.boot.module.jg.biz.message;
import com.alibaba.fastjson.JSONObject;
/**
* @author Administrator
*/
public interface WorkFlowMessageListener {
/**
* 处理消息方法-Create
* 1.更新业务数据【instanceId、nextExecutedIds、status、instanceStatus(所有执行过的加下一步待执行角色)】
* 2.创建待办(初始未完成状态)
* @param message message 消息内容
*/
void afterCreate(JSONObject message);
/**
* 处理消息方法-完成
* 1.更新代办(更新为已完成状态)
* 2.更新业务数据【status、instanceStatus(所有执行过的加下一步待执行角色)、新增字段-taskResult(工作流节点执行结果)】
* @param approvalStatus 工作流任务状态
* @param message message 消息内容
*/
void afterComplete(String approvalStatus, JSONObject message);
/**
* 处理消息方法-流程结束
* 1.业务处理
* @param message message 消息内容
*/
void afterFinish(JSONObject message);
/**
* 可处理的消息类型
* @return BizTypeEnum
*/
BizTypeEnum canHandlerType();
enum BizTypeEnum{
// 更名变更登记
unitRename,
// 单位变更
unitChange,
// 移装变更登记
changeRegistrationTransfer,
// 使用登记审核
useRegistration,
// 安装告知
installationNotificationNew,
// 维保备案
maintenanceFiling,
// 电梯注销
scrapCancel,
// 改造变更登记
renovationRegistrationReviewNew,
// 维修告知
maintainNotice,
// 改造告知
renovationNoticeNew,
// 电梯停用启用
deactivateEnable,
// 移装告知
transferNotice,
// 设备移交
equipmentHandover
}
static BizTypeEnum getEnum(String name){
return BizTypeEnum.valueOf(name);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment