Commit ce33ee2c by gechengyang

修复mt转mx时MxType、MtType以及转换结果为空的缺陷

parent a773e328
...@@ -9,6 +9,8 @@ import com.brilliance.swift.util.SwiftTransferUtil; ...@@ -9,6 +9,8 @@ import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo; import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport; import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.MessagePriority; import com.brilliance.swift.vo.common.MessagePriority;
import com.brilliance.swift.vo.common.TranslationResultCode;
import com.prowidesoftware.swift.model.MxId;
import com.prowidesoftware.swift.model.SwiftBlock5; import com.prowidesoftware.swift.model.SwiftBlock5;
import com.prowidesoftware.swift.model.SwiftBlock5Field; import com.prowidesoftware.swift.model.SwiftBlock5Field;
import com.prowidesoftware.swift.model.mt.AbstractMT; import com.prowidesoftware.swift.model.mt.AbstractMT;
...@@ -88,6 +90,19 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{ ...@@ -88,6 +90,19 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
} }
} }
public void setMxType(AbstractMX abstractMX,SwiftTranslationReport str){
if(abstractMX==null){
return;
}
MxId mxId=abstractMX.getMxId();
if (mxId != null) {
str.setMxType(mxId.getBusinessProcess().name()
+ mxId.getFunctionality()
+ mxId.getVariant()
+ mxId.getVersion());
}
}
@Override @Override
public void postProcess() { public void postProcess() {
String swiftGsonStr = new JSONObject(jsonMaps).toJSONString(); String swiftGsonStr = new JSONObject(jsonMaps).toJSONString();
...@@ -95,6 +110,11 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{ ...@@ -95,6 +110,11 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
String xml = abstractMX.message(); String xml = abstractMX.message();
SwiftTranslationReport str = context.get(SwiftTranslationReport.class); SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
str.setMessage(xml); str.setMessage(xml);
//设置报文MX类型 modified by gechengyang 20230828
str.setTranslationResult(TranslationResultCode.TROK.value());
MxId mxId=abstractMX.getMxId();
setMxType(abstractMX,str);
// str.setMxType(((BusinessAppHdrV02) abstractMX.getAppHdr()).getMsgDefIdr());
try { try {
String outputFilePath = (String)context.get(Mt2MxContextIdentifier.MT_TO_MX_OUTPUT_FILE_PATH, true); String outputFilePath = (String)context.get(Mt2MxContextIdentifier.MT_TO_MX_OUTPUT_FILE_PATH, true);
if (StringUtil.isNotEmpty(outputFilePath)) { if (StringUtil.isNotEmpty(outputFilePath)) {
...@@ -107,6 +127,8 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{ ...@@ -107,6 +127,8 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
stream.close(); stream.close();
} }
} catch (IOException e) { } catch (IOException e) {
str.setTranslationResult(TranslationResultCode.TRNK.value());
str.setMessage(e.getMessage());
throw new SwiftException(e.getMessage()); throw new SwiftException(e.getMessage());
} }
} }
......
...@@ -50,6 +50,9 @@ public class Mt2MxCreatorManager { ...@@ -50,6 +50,9 @@ public class Mt2MxCreatorManager {
} }
creator.postProcess(); creator.postProcess();
SwiftTranslationReport str = context.get(SwiftTranslationReport.class); SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
if(abstractMT!=null){
str.setMtType(abstractMT.getMessageType());
}
return str; return str;
} }
......
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