Commit b83eaecf by lixinyi

pom文件修改,新增根据smhinr找到对应报文功能

parent 7ca717cd
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8" />
<meta charset="gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
......
......@@ -28,6 +28,13 @@ export default{
data:data
})
},
mx2Json(data){
return new link({
url:`/mx2Json`,
method:"post",
data:data
})
},
mxType(data){
return new link({
url:`/mxType`,
......
......@@ -10,6 +10,7 @@
</parent>
<groupId>com.brilliance</groupId>
<artifactId>swift-editor</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>swift-editor</name>
<description>swift报文手工拟报</description>
......@@ -27,6 +28,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
......@@ -35,6 +40,12 @@
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
......@@ -111,7 +122,6 @@
<excludes>
<exclude>js/**</exclude>
<exclude>json/*</exclude>
<exclude>static/**</exclude>
<exclude>swiftXml/**</exclude>
<!--<exclude>application.properties</exclude>
<exclude>log4j2.xml</exclude>-->
......@@ -180,6 +190,21 @@
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.basedir}/libs</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -96,6 +96,82 @@ public class MxTransfer {
}
}
public static Map<String, Object> transfer2(String gsonStr, String identifier, String tp) {
Map<String, Object> gsonMaps = JSON.parseObject(gsonStr);
InputStream resourceAsStream = null;
InputStream resourceAsStream2 = null;
if ("rtgs".equals(tp)) {
resourceAsStream = MessageUtil.class.getResourceAsStream("/templates/" + identifier + "_rtgs.properties");
resourceAsStream2 = MessageUtil.class.getResourceAsStream("/templates/head00100102_rtgs.properties");
} else {
resourceAsStream = MessageUtil.class.getResourceAsStream("/templates/" + identifier + ".properties");
}
if (resourceAsStream == null) {
throw new SwiftException("没找到对应的配置文件" + identifier);
}
List<String> properties = StringUtil.inputStreamToLines(resourceAsStream);
if (resourceAsStream2 != null) {
List<String> properties2 = StringUtil.inputStreamToLines(resourceAsStream2);
properties.addAll(properties2);
}
Map<String, Object> maps = new HashMap<>();
for (String property : properties) {
if (property.startsWith("#")) {
continue;//过滤注释
}
String[] strArr = property.split("=");
if (strArr.length != 2) {
continue;//过滤掉不符合规则的配置
}
String key = strArr[0].trim();
String path = strArr[1].trim();
if (path.indexOf("@") > -1) {
path = path.substring(0, path.indexOf("@"));
}
putValue2(gsonMaps, key, path, maps, tp);
}
return maps;
}
public static Map<String, Object> putValue2(Map<String, Object> gsonMaps, String key, String path, Map<String, Object> maps, String tp) {
String[] keys = key.split("\\.");
Map<String, Object> tmpMaps = null;
tmpMaps = gsonMaps;
Map<String, Object> appHdr = null;
for (int i = 0; i < keys.length; i++) {
String tmpKey = keys[i];
if (i == (keys.length - 1)) {
if (key.contains("appHdr") && "rtgs".equals(tp)) {
if (!Objects.isNull(maps.get("appHdr"))) {
appHdr = (Map<String, Object>) maps.get("appHdr");
} else {
appHdr = new HashMap<>();
}
appHdr.put(path, tmpMaps.get(tmpKey));
maps.put("appHdr", appHdr);
} else {
maps.put(path, tmpMaps.get(tmpKey));
}
} else {
if (tmpKey.endsWith("*")) { //表示此节点是JSONARRAY,
tmpKey = tmpKey.substring(0, tmpKey.indexOf("*"));
}
if (tmpMaps.get(tmpKey) instanceof JSONArray) {
tmpMaps = (JSONObject) ((JSONArray) tmpMaps.get(tmpKey)).get(0);
} else if (tmpMaps.get(tmpKey) instanceof JSONObject) {
tmpMaps = (JSONObject) tmpMaps.get(tmpKey);
} else {
if (!Objects.isNull(tmpMaps.get(tmpKey))) {
maps.put(path, tmpMaps.get(tmpKey));
}
}
}
}
return maps;
}
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\src\\main\\resources\\json\\pacs00800108.json");
// File file = new File("d:/test/tst.json");
......
......@@ -2,6 +2,8 @@ package com.brilliance.mxeditor.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.brilliance.mxeditor.MxTransfer;
import com.brilliance.mxeditor.exception.SwiftException;
import com.brilliance.mxeditor.util.StringUtil;
import com.brilliance.mxeditor.config.EditorEnvConfig;
......@@ -12,7 +14,9 @@ import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.prowidesoftware.swift.model.MxId;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import com.prowidesoftware.swift.model.mx.NamespaceReader;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -164,6 +168,23 @@ public class MxEditorController {
}
}
@RequestMapping(value = "/mx2Json", method = RequestMethod.POST)
@ResponseBody
public JSONObject mx2Json(@RequestBody SwiftVo swiftVo) {
String xmlStr = "";
// 本地测试打开下面注释代码
File file = FileUtils.toFile(MxEditorController.class.getResource("/xml/rtgs/pacs00800108.xml"));
try {
xmlStr = FileUtils.readFileToString(file, "UTF-8");
} catch (IOException e) {
}
AbstractMX abstractMX = AbstractMX.parse(xmlStr);
String s = abstractMX.toJson();
Map<String, Object> maps = MxTransfer.transfer2(s, "pacs00800108", "rtgs");
JSONObject json = new JSONObject(maps);
return json;
}
public static boolean validateMx(String xml) {
try {
boolean b1 = false;
......
.inputDeep[data-v-0826e2f4] .el-input__inner{background-color:#fff}.el_table[data-v-151331da]{border:1px solid #ebebeb}.tipCls[data-v-151331da]{color:#f56c6c;font-size:12px;margin-left:5px;float:left}[data-v-151331da] .isError .el-input__inner{border-color:#f56c6c}.tip[data-v-81e69ab8]{color:red}.page_title[data-v-126fffb6]{text-align:center}.node_nonleaf[data-v-126fffb6]{color:#169bff;border-bottom:1px dotted #169bff}.msg_title input[data-v-126fffb6]{vertical-align:top;margin-right:0}.el-form-item[data-v-126fffb6]{margin-bottom:0}[data-v-126fffb6] .el-form-item__content{padding-left:23px}[data-v-126fffb6] .el-tree-node__content{height:auto}.el-button+.el-button[data-v-126fffb6]{margin-left:0}.el-button--mini.is-circle[data-v-126fffb6]{padding:1px}.tree_node[data-v-126fffb6]{flex:1;display:flex;align-items:center;font-size:14px}.iso_tools[data-v-126fffb6]{position:fixed;top:150px;right:10px;z-index:9}.left[data-v-126fffb6],.right[data-v-126fffb6]{width:50%;height:100%;background:#fff;float:left}.title1[data-v-126fffb6]{background:red;text-align:center}.title2[data-v-126fffb6]{background:green;text-align:center}.textleft[data-v-126fffb6],.textright[data-v-126fffb6]{width:100%;height:600px}a[data-v-8aebcede]{text-decoration:none}.box[data-v-91a4afba]{width:100%;height:100%;margin:1% 0;overflow:hidden;box-shadow:-1px 9px 10px 3px rgba(0,0,0,.11)}.left[data-v-91a4afba],.mid[data-v-91a4afba]{width:50%;height:100%;background:#fff;float:left}.title1[data-v-91a4afba]{background:red;text-align:center}.title2[data-v-91a4afba]{background:green;text-align:center}.textleft[data-v-91a4afba],.textright[data-v-91a4afba]{width:100%;height:600px}.box[data-v-6b5c7b01]{width:100%;height:100%;margin:1% 0;overflow:hidden;box-shadow:-1px 9px 10px 3px rgba(0,0,0,.11)}.left[data-v-6b5c7b01],.mid[data-v-6b5c7b01]{width:50%;height:100%;background:#fff;float:left}.title1[data-v-6b5c7b01]{background:red;text-align:center}.title2[data-v-6b5c7b01]{background:green;text-align:center}.textleft[data-v-6b5c7b01],.textright[data-v-6b5c7b01]{width:100%;height:600px}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<!doctype html><html lang=""><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="/favicon.ico"/><title>ISO手工拟报</title><script defer="defer" src="/js/chunk-vendors.fc4c27d7.js"></script><script defer="defer" src="/js/app.2003477a.js"></script><link href="/css/chunk-vendors.0b0c58b7.css" rel="stylesheet"><link href="/css/app.abbc3a25.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but swiftiso-editor doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file
<!doctype html><html lang=""><head><meta charset="gb2312"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="/favicon.ico"/><title>ISO手工拟报</title><script defer="defer" src="/js/chunk-vendors.ed29fde2.js"></script><script defer="defer" src="/js/app.5e6c3c01.js"></script><link href="/css/chunk-vendors.ab49d789.css" rel="stylesheet"><link href="/css/app.c68f2234.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but swiftiso-editor doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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