适配IResult,让ws和被动http自动适配不同返回值

segment2.0
beeajax 2 years ago
parent f5188f5685
commit 898668a70a

@ -1,11 +1,18 @@
package com.docus.server.collect.basic.http;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.log.context.TrackContext;
import com.docus.server.ws.IHttpResult;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* httpcontroller
*
* @see com.docus.server.collect.controller.BasicController#insertHttpPassiveBasic(String)
* @see com.docus.server.visitor.VisitorProcessor#doProcess(TrackContext)
*/
@Component("httpBasicResultImpl")
public class HttpBasicResultImpl implements IHttpResult {

@ -8,6 +8,12 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* http,
*
* @see IHttpCollector
* @see com.docus.server.collect.job.basic.TBasicHttpCollectJob#getTBasics(Date, Date, long, long)
*/
@Component("httpTBasicCollectorImpl")
public class HttpTBasicCollectorImpl implements IHttpCollector<TBasicDTO> {
@Override

@ -1,10 +1,17 @@
package com.docus.server.collect.basic.ws;
import com.docus.core.util.DateUtil;
import com.docus.log.context.TrackContext;
import com.docus.server.record.pojo.dto.TBasicDTO;
import com.docus.server.ws.convert.IConverter;
import org.springframework.stereotype.Component;
/**
*
*
* @see com.docus.server.ws.impl.BasicServerImpl#setTBasic(String)
* @see com.docus.server.visitor.VisitorProcessor#beforeProcess(TrackContext)
*/
@Component("tBasicConverter")
public class TBasicConverter implements IConverter<TBasicDTO> {

@ -2,12 +2,19 @@ package com.docus.server.collect.basic.ws;
import com.docus.core.util.DateUtil;
import com.docus.core.util.Func;
import com.docus.log.context.TrackContext;
import com.docus.server.ws.IWsResult;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
/**
* webservicecontroller
*
* @see com.docus.server.ws.impl.BasicServerImpl#setTBasic(String)
* @see com.docus.server.visitor.VisitorProcessor#doProcess(TrackContext)
*/
@Component("wsBasicResultImpl")
public class WsBasicResultImpl implements IWsResult {
@ -21,35 +28,35 @@ public class WsBasicResultImpl implements IWsResult {
public String fail(Map<String, Object> params) {
String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
return "<MCCI_IN000002UV01 xmlns=\"urn:hl7-org:v3\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ITSVersion=\"XML_1.0\" xsi:schemaLocation=\"urn:hl7-org:v3 file:///E:/hl7/HL7/v3ballot_fullsite_2011MAY/v3ballot/html/processable/multicacheschemas/MCCI_IN000002UV01.xsd\"> \n" +
" <id extension=\"" + Func.randomUUID() + "\"/> \n" +
" <creationTime value=\"" + createTime + "\"/> \n" +
" <interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/> \n" +
" <processingCode code=\"P\"/> \n" +
" <processingModeCode/> \n" +
" <acceptAckCode code=\"AL\"/> \n" +
" <receiver typeCode=\"RCV\"> \n" +
" <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" +
" <id> \n" +
" <item extension=\"" + params.get("receive") + "\"/> \n" +
" </id> \n" +
" </device> \n" +
" </receiver> \n" +
" <sender typeCode=\"SND\"> \n" +
" <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" +
" <id> \n" +
" <item extension=\"" + params.get("send") + "\"/> \n" +
" </id> \n" +
" </device> \n" +
" </sender> \n" +
" <acknowledgement typeCode=\"AE\"> \n" +
" <!--请求消息ID--> \n" +
" <targetMessage> \n" +
" <id extension=\"" + params.get("serialId") + "\"/> \n" +
" </targetMessage> \n" +
" <acknowledgementDetail> \n" +
" <text value=\"" + params.get("msg") + "\"/> \n" +
" </acknowledgementDetail> \n" +
" </acknowledgement> \n" +
"</MCCI_IN000002UV01>\n";
" <id extension=\"" + Func.randomUUID() + "\"/> \n" +
" <creationTime value=\"" + createTime + "\"/> \n" +
" <interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/> \n" +
" <processingCode code=\"P\"/> \n" +
" <processingModeCode/> \n" +
" <acceptAckCode code=\"AL\"/> \n" +
" <receiver typeCode=\"RCV\"> \n" +
" <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" +
" <id> \n" +
" <item extension=\"" + params.get("receive") + "\"/> \n" +
" </id> \n" +
" </device> \n" +
" </receiver> \n" +
" <sender typeCode=\"SND\"> \n" +
" <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" +
" <id> \n" +
" <item extension=\"" + params.get("send") + "\"/> \n" +
" </id> \n" +
" </device> \n" +
" </sender> \n" +
" <acknowledgement typeCode=\"AE\"> \n" +
" <!--请求消息ID--> \n" +
" <targetMessage> \n" +
" <id extension=\"" + params.get("serialId") + "\"/> \n" +
" </targetMessage> \n" +
" <acknowledgementDetail> \n" +
" <text value=\"" + params.get("msg") + "\"/> \n" +
" </acknowledgementDetail> \n" +
" </acknowledgement> \n" +
"</MCCI_IN000002UV01>\n";
}
}

@ -36,8 +36,7 @@ public class VisitorProcessor extends AbstractProcessor {
if (Func.isEmpty(message)) {
throw new RuntimeException("参数为空");
}
Object convert = converter.convert(message, context.getMethodName());
String jsonStr = JSON.toJSON(convert);
String jsonStr = JSON.toJSON(converter.convert(message, context.getMethodName()));
Long taskId = messageService.insertTaskOriginalMessage(jsonStr, message, IIntegerEnum.fromDisplay(CollectTypeEnum.class, context.getGroup()));
Map<String, Object> params = context.getParams();
params.put("taskId", taskId);

Loading…
Cancel
Save