|
|
|
@ -8,10 +8,8 @@ import com.docus.server.collect.infrastructure.dao.CollectTypeEnum;
|
|
|
|
|
import com.docus.server.collect.infrastructure.dao.StateEnum;
|
|
|
|
|
import com.docus.server.collect.infrastructure.enums.IIntegerEnum;
|
|
|
|
|
import com.docus.server.tool.SpringUtils;
|
|
|
|
|
import com.docus.server.ws.HttpResultAdapter;
|
|
|
|
|
import com.docus.server.ws.IHttpResult;
|
|
|
|
|
import com.docus.server.ws.IResult;
|
|
|
|
|
import com.docus.server.ws.ITaskOriginalMessageService;
|
|
|
|
|
import com.docus.server.ws.IWsResult;
|
|
|
|
|
import com.docus.server.ws.convert.IConverter;
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -25,7 +23,7 @@ import java.util.Map;
|
|
|
|
|
public class VisitorProcessor extends AbstractProcessor {
|
|
|
|
|
private ITaskOriginalMessageService messageService;
|
|
|
|
|
private IConverter converter;
|
|
|
|
|
private IWsResult wsResult;
|
|
|
|
|
private IResult result;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前置通知
|
|
|
|
@ -38,7 +36,8 @@ public class VisitorProcessor extends AbstractProcessor {
|
|
|
|
|
if (Func.isEmpty(message)) {
|
|
|
|
|
throw new RuntimeException("参数为空");
|
|
|
|
|
}
|
|
|
|
|
String jsonStr = JSON.toJSON(converter.convert(message, context.getMethodName()));
|
|
|
|
|
Object convert = converter.convert(message, context.getMethodName());
|
|
|
|
|
String jsonStr = JSON.toJSON(convert);
|
|
|
|
|
Long taskId = messageService.insertTaskOriginalMessage(jsonStr, message, IIntegerEnum.fromDisplay(CollectTypeEnum.class, context.getGroup()));
|
|
|
|
|
Map<String, Object> params = context.getParams();
|
|
|
|
|
params.put("taskId", taskId);
|
|
|
|
@ -66,15 +65,15 @@ public class VisitorProcessor extends AbstractProcessor {
|
|
|
|
|
if (!context.isError()) {
|
|
|
|
|
log.info("=== AOP 后置通知 ===");
|
|
|
|
|
params.put("msg", "操作成功!");
|
|
|
|
|
return wsResult.ok(params);
|
|
|
|
|
return result.ok(params);
|
|
|
|
|
} else {
|
|
|
|
|
log.info("=== AOP 异常通知 ===");
|
|
|
|
|
messageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.FAIL);
|
|
|
|
|
return wsResult.fail(params);
|
|
|
|
|
return result.fail(params);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
return wsResult.fail(params);
|
|
|
|
|
return result.fail(params);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -82,10 +81,8 @@ public class VisitorProcessor extends AbstractProcessor {
|
|
|
|
|
* 初始化bean
|
|
|
|
|
*/
|
|
|
|
|
private void initBeans(String[] beanNames) {
|
|
|
|
|
HttpResultAdapter httpResultAdapter = new HttpResultAdapter((IHttpResult) SpringUtils.getBean(beanNames[0]));
|
|
|
|
|
SpringUtils.initializeBean(httpResultAdapter);
|
|
|
|
|
this.converter = (IConverter) SpringUtils.getBean(beanNames[0]);
|
|
|
|
|
this.wsResult = (IWsResult) SpringUtils.getBean(beanNames[1]);
|
|
|
|
|
this.result = (IResult) SpringUtils.getBean(beanNames[1]);
|
|
|
|
|
this.messageService = SpringUtils.getBean(ITaskOriginalMessageService.class);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|