diff --git a/com/engine/custom/sl/entity/JourneyInfo.java b/com/engine/custom/sl/entity/JourneyInfo.java
index e0e93dc..e2a4d62 100644
--- a/com/engine/custom/sl/entity/JourneyInfo.java
+++ b/com/engine/custom/sl/entity/JourneyInfo.java
@@ -1,5 +1,15 @@
package com.engine.custom.sl.entity;
+import com.engine.custom.hg.service.TextDocFileService;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
public class JourneyInfo {
private String startDate;
private String endDate;
@@ -7,6 +17,17 @@ public class JourneyInfo {
private String jrnyPath;
private String jrnyExpln;
+
+ public String toXMLString() {
+ return "" +
+ "" + startDate + ""+
+ "" + endDate +
+ "" + bsnTrpDays +
+ "" + jrnyPath +
+ "" + jrnyExpln +
+ "" ;
+ }
+
@Override
public String toString() {
return "JourneyInfo{" +
@@ -57,4 +78,49 @@ public class JourneyInfo {
public void setJrnyExpln(String jrnyExpln) {
this.jrnyExpln = jrnyExpln;
}
+
+
+
+ public static String convertObjectToXml(Object object) {
+ StringBuilder xmlBuilder = new StringBuilder("<" + object.getClass().getSimpleName() + ">");
+ Field[] fields = object.getClass().getDeclaredFields();
+ Map attributes = new LinkedHashMap<>();
+
+ try {
+ for (Field field : fields) {
+ field.setAccessible(true);
+ Object value = field.get(object);
+ if (value != null) {
+ String fieldName = field.getName();
+ xmlBuilder.append("<").append(fieldName).append(">")
+ .append(value)
+ .append("").append(fieldName).append(">");
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ xmlBuilder.append("" + object.getClass().getSimpleName() + ">");
+ return xmlBuilder.toString();
+ }
+
+
+
+ public static void main(String[] args) {
+ TravelToEsbBean textDocFileService = new TravelToEsbBean();
+ textDocFileService.setAcsryNums("1");
+ textDocFileService.setExpnsAmt("2");
+ textDocFileService.setExpnsRsn("3");
+ textDocFileService.setRemark("5");
+ textDocFileService.setOperatorName("fjkgnvbhui");
+
+ // 调用工具类将对象转换为 XML 字符串
+ String xmlString = null;
+
+ xmlString = convertObjectToXml(textDocFileService);
+
+
+ // 打印生成的 XML 字符串
+ System.out.println(xmlString);
+ }
}
diff --git a/com/engine/custom/sl/entity/TravelToEsbBean.java b/com/engine/custom/sl/entity/TravelToEsbBean.java
index f16a423..9cadf20 100644
--- a/com/engine/custom/sl/entity/TravelToEsbBean.java
+++ b/com/engine/custom/sl/entity/TravelToEsbBean.java
@@ -14,6 +14,23 @@ public class TravelToEsbBean {
private List jrnyInfoArray;
private List acsryArray;
+ public String toXMLString() {
+ return
+ "" + oaTrvlBnsExpnsAcctNo +"" +
+ "" + operatorNo + "" +
+ "" + operatorName + "" +
+ "" + acsryNums + "" +
+ "" + expnsAmt + "" +
+ "" + expnsRsn +"" +
+ "" + remark + "" +
+ ", expndArray=" + expndArray +
+ ", jrnyInfoArray=" + jrnyInfoArray +
+ ", acsryArray=" + acsryArray;
+
+ }
+
+
+
@Override
public String toString() {
return "TravelToEsbBean{" +