Commit 5b35d508 authored by Quxl's avatar Quxl

x

parent 9834809f
package com.egolm.sso.service.impl;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.jws.WebService;
import javax.xml.bind.JAXBException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.HEADER_GENERAL_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.HEADER_ORGANIZATIONAL_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.HEADER_PARTNER_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.HEADER_REFERENCE_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.SUMMARY_GENERAL;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE;
import com.egolm.sso.service.CommonService;
import com.egolm.sso.service.ProFormaInvoiceService;
import com.egolm.sso.util.FileUtil;
......@@ -28,13 +40,58 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService {
@Override
public void execute(String xml) {
try {
Z_MT_SD_005_PERFORM_INVOICE bean = XMLUtil.toBeanByJxab(xml, Z_MT_SD_005_PERFORM_INVOICE.class);
System.out.println(new Gson().toJson(bean));
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Date now = new Date();
Z_MT_SD_005_PERFORM_INVOICE bean = XMLUtil.toBeanByJxab(xml, Z_MT_SD_005_PERFORM_INVOICE.class);
System.out.println(new Gson().toJson(bean));
Map<String, Object> headMap = new HashMap<String, Object>();
Z_DT_SD_005_PERFORM_INVOICE Z_DT_SD_005_PERFORM_INVOICE = bean.getZ_DT_SD_005_PERFORM_INVOICE();
HEADER_GENERAL_DATA HEADER_GENERAL_DATA = Z_DT_SD_005_PERFORM_INVOICE.getHEADER_GENERAL_DATA();
List<HEADER_PARTNER_DATA> partnerList = Z_DT_SD_005_PERFORM_INVOICE.getHEADER_PARTNER_DATA();
HEADER_DOCU_DATE HEADER_DOCU_DATE = Z_DT_SD_005_PERFORM_INVOICE.getHEADER_DOCU_DATE();
HEADER_REFERENCE_DATA HEADER_REFERENCE_DATA = Z_DT_SD_005_PERFORM_INVOICE.getHEADER_REFERENCE_DATA();
HEADER_BANK_DATA HEADER_BANK_DATA = Z_DT_SD_005_PERFORM_INVOICE.getHEADER_BANK_DATA();
HEADER_ORGANIZATIONAL_DATA HEADER_ORGANIZATIONAL_DATA = Z_DT_SD_005_PERFORM_INVOICE.getHEADER_ORGANIZATIONAL_DATA();
List<SUMMARY_GENERAL> summaryList = Z_DT_SD_005_PERFORM_INVOICE.getSUMMARY_GENERAL();
headMap.put("GENERAL_BELNR", HEADER_GENERAL_DATA.getBELNR());
headMap.put("GENERAL_ZTERM", HEADER_GENERAL_DATA.getZTERM());
for(HEADER_PARTNER_DATA HEADER_PARTNER_DATA : partnerList) {
if("AG".equals(HEADER_PARTNER_DATA.getPARVW())) {
headMap.put("PARTNER_PARVW1", HEADER_PARTNER_DATA.getPARVW());
headMap.put("PARTNER_PARTN1", HEADER_PARTNER_DATA.getPARTN());
} else if("WE".equals(HEADER_PARTNER_DATA.getPARVW())) {
headMap.put("PARTNER_PARVW2", HEADER_PARTNER_DATA.getPARVW());
headMap.put("PARTNER_PARTN2", HEADER_PARTNER_DATA.getPARTN());
}
}
headMap.put("DOCU_IDDAT", HEADER_DOCU_DATE.getIDDAT());
headMap.put("DOCU_DATUM", HEADER_DOCU_DATE.getDATUM());
headMap.put("EFERENCE_QUALF", HEADER_REFERENCE_DATA.getQUALF());
headMap.put("EFERENCE_BELNR", HEADER_REFERENCE_DATA.getBELNR());
headMap.put("EFERENCE_DATUM", HEADER_REFERENCE_DATA.getDATUM());
headMap.put("BANK_ACNUM", HEADER_BANK_DATA.getACNUM());
headMap.put("ORGANIZATIONAL_QUALF", HEADER_ORGANIZATIONAL_DATA.getQUALF());
headMap.put("ORGANIZATIONAL_ORGID", HEADER_ORGANIZATIONAL_DATA.getORGID());
for(int i = 0; i < summaryList.size(); i++) {
SUMMARY_GENERAL SUMMARY_GENERAL = summaryList.get(i);
headMap.put("SUMMARY_SUMID" + i, SUMMARY_GENERAL.getSUMID());
headMap.put("SUMMARY_SUMME" + i, SUMMARY_GENERAL.getSUMME());
headMap.put("SUMMARY_WAERQ" + i, SUMMARY_GENERAL.getWAERQ());
}
String dateString = new SimpleDateFormat("yyyyMMdd").format(now);
headMap.put("BATCH", dateString + "-" + common.getNextval("T_PERFORM_INVOICE_HEADER_BATCH_" + dateString));
headMap.put("SEND_STATUS", 'N');
headMap.put("SEND_TIME", now);
headMap.put("TRACE_NO", null);
headMap.put("CREATED", null);
headMap.put("CREATEDBY", null);
headMap.put("UPDATED", null);
headMap.put("UPDATEDBY", null);
}
public static void main(String[] args) throws IOException {
......
......@@ -7,6 +7,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import com.egolm.sso.config.XRException;
import com.thoughtworks.xstream.XStream;
public class XMLUtil {
......@@ -22,13 +23,17 @@ public class XMLUtil {
return bean;
}
public static <T> T toBeanByJxab(String XML, Class<T> requireType) throws JAXBException {
JAXBContext jc = JAXBContext.newInstance(requireType);
Unmarshaller uma = jc.createUnmarshaller();
InputStream inputStream = new ByteArrayInputStream(XML.getBytes());
@SuppressWarnings("unchecked")
T bean = (T) uma.unmarshal(inputStream);
return bean;
public static <T> T toBeanByJxab(String XML, Class<T> requireType) {
try {
JAXBContext jc = JAXBContext.newInstance(requireType);
Unmarshaller uma = jc.createUnmarshaller();
InputStream inputStream = new ByteArrayInputStream(XML.getBytes());
@SuppressWarnings("unchecked")
T bean = (T) uma.unmarshal(inputStream);
return bean;
} catch (JAXBException e) {
throw new XRException("XML转换错误", e);
}
}
......
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