Commit b2db1ecd authored by Quxl's avatar Quxl

x

parent dbe62962
...@@ -2,6 +2,7 @@ package com.egolm.sso.service.impl; ...@@ -2,6 +2,7 @@ package com.egolm.sso.service.impl;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -21,7 +22,12 @@ import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.HEADER_GENERAL_DATA; ...@@ -21,7 +22,12 @@ 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_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_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.HEADER_REFERENCE_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.ITEM_AMOUNT_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.ITEM_DATA; import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.ITEM_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.ITEM_MATERIAL_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_DATA;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_PO_TYPE;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.ITEM_VAT_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.SUMMARY_GENERAL;
import com.egolm.sso.bean.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE; 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.CommonService;
...@@ -29,8 +35,8 @@ import com.egolm.sso.service.ProFormaInvoiceService; ...@@ -29,8 +35,8 @@ import com.egolm.sso.service.ProFormaInvoiceService;
import com.egolm.sso.util.FileUtil; import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.SqlUtil; import com.egolm.sso.util.SqlUtil;
import com.egolm.sso.util.SqlUtil.Sql; import com.egolm.sso.util.SqlUtil.Sql;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil; import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component @Component
@WebService(serviceName = "ProFormaInvoiceService", targetNamespace = "http://pro_forma_invoice.sso.egolm.com", endpointInterface = "com.egolm.sso.service.ProFormaInvoiceService") @WebService(serviceName = "ProFormaInvoiceService", targetNamespace = "http://pro_forma_invoice.sso.egolm.com", endpointInterface = "com.egolm.sso.service.ProFormaInvoiceService")
...@@ -46,9 +52,8 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService { ...@@ -46,9 +52,8 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService {
@Transactional @Transactional
public void execute(String xml) { public void execute(String xml) {
Date now = new Date(); Date now = new Date();
String dateString = new SimpleDateFormat("yyyyMMdd").format(now);
Z_MT_SD_005_PERFORM_INVOICE bean = XMLUtil.toBeanByJxab(xml, Z_MT_SD_005_PERFORM_INVOICE.class); 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>(); 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(); 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(); HEADER_GENERAL_DATA HEADER_GENERAL_DATA = Z_DT_SD_005_PERFORM_INVOICE.getHEADER_GENERAL_DATA();
...@@ -60,33 +65,47 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService { ...@@ -60,33 +65,47 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService {
List<SUMMARY_GENERAL> summaryList = Z_DT_SD_005_PERFORM_INVOICE.getSUMMARY_GENERAL(); List<SUMMARY_GENERAL> summaryList = Z_DT_SD_005_PERFORM_INVOICE.getSUMMARY_GENERAL();
List<ITEM_DATA> itemList = Z_DT_SD_005_PERFORM_INVOICE.getITEM_DATA(); List<ITEM_DATA> itemList = Z_DT_SD_005_PERFORM_INVOICE.getITEM_DATA();
headMap.put("GENERAL_BELNR", HEADER_GENERAL_DATA.getBELNR()); Long headerId = common.getNextval("T_PERFORM_INVOICE_HEADER_ID");
headMap.put("GENERAL_ZTERM", HEADER_GENERAL_DATA.getZTERM()); headMap.put("ID", headerId);
for(HEADER_PARTNER_DATA HEADER_PARTNER_DATA : partnerList) { if(HEADER_GENERAL_DATA != null) {
if("AG".equals(HEADER_PARTNER_DATA.getPARVW())) { headMap.put("GENERAL_BELNR", HEADER_GENERAL_DATA.getBELNR());
headMap.put("PARTNER_PARVW1", HEADER_PARTNER_DATA.getPARVW()); headMap.put("GENERAL_ZTERM", HEADER_GENERAL_DATA.getZTERM());
headMap.put("PARTNER_PARTN1", HEADER_PARTNER_DATA.getPARTN()); }
} else if("WE".equals(HEADER_PARTNER_DATA.getPARVW())) { if(partnerList != null) {
headMap.put("PARTNER_PARVW2", HEADER_PARTNER_DATA.getPARVW()); for(HEADER_PARTNER_DATA HEADER_PARTNER_DATA : partnerList) {
headMap.put("PARTNER_PARTN2", HEADER_PARTNER_DATA.getPARTN()); 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()); if(HEADER_DOCU_DATE != null) {
headMap.put("DOCU_DATUM", HEADER_DOCU_DATE.getDATUM()); headMap.put("DOCU_IDDAT", HEADER_DOCU_DATE.getIDDAT());
headMap.put("EFERENCE_QUALF", HEADER_REFERENCE_DATA.getQUALF()); headMap.put("DOCU_DATUM", HEADER_DOCU_DATE.getDATUM());
headMap.put("EFERENCE_BELNR", HEADER_REFERENCE_DATA.getBELNR()); }
headMap.put("EFERENCE_DATUM", HEADER_REFERENCE_DATA.getDATUM()); if(HEADER_REFERENCE_DATA != null) {
headMap.put("BANK_ACNUM", HEADER_BANK_DATA.getACNUM()); headMap.put("EFERENCE_QUALF", HEADER_REFERENCE_DATA.getQUALF());
headMap.put("ORGANIZATIONAL_QUALF", HEADER_ORGANIZATIONAL_DATA.getQUALF()); headMap.put("EFERENCE_BELNR", HEADER_REFERENCE_DATA.getBELNR());
headMap.put("ORGANIZATIONAL_ORGID", HEADER_ORGANIZATIONAL_DATA.getORGID()); headMap.put("EFERENCE_DATUM", HEADER_REFERENCE_DATA.getDATUM());
for(int i = 0; i < summaryList.size(); i++) { }
SUMMARY_GENERAL SUMMARY_GENERAL = summaryList.get(i); if(HEADER_BANK_DATA != null) {
headMap.put("SUMMARY_SUMID" + i, SUMMARY_GENERAL.getSUMID()); headMap.put("BANK_ACNUM", HEADER_BANK_DATA.getACNUM());
headMap.put("SUMMARY_SUMME" + i, SUMMARY_GENERAL.getSUMME()); }
headMap.put("SUMMARY_WAERQ" + i, SUMMARY_GENERAL.getWAERQ()); if(HEADER_ORGANIZATIONAL_DATA != null) {
headMap.put("ORGANIZATIONAL_QUALF", HEADER_ORGANIZATIONAL_DATA.getQUALF());
headMap.put("ORGANIZATIONAL_ORGID", HEADER_ORGANIZATIONAL_DATA.getORGID());
}
if(summaryList != null) {
for(int i = 0; i < summaryList.size(); i++) {
SUMMARY_GENERAL SUMMARY_GENERAL = summaryList.get(i);
headMap.put("SUMMARY_SUMID" + (i + 1), SUMMARY_GENERAL.getSUMID());
headMap.put("SUMMARY_SUMME" + (i + 1), SUMMARY_GENERAL.getSUMME());
headMap.put("SUMMARY_WAERQ" + (i + 1), SUMMARY_GENERAL.getWAERQ());
}
} }
String dateString = new SimpleDateFormat("yyyyMMdd").format(now);
headMap.put("BATCH", dateString + "-" + common.getNextval("T_PERFORM_INVOICE_HEADER_BATCH_" + dateString)); headMap.put("BATCH", dateString + "-" + common.getNextval("T_PERFORM_INVOICE_HEADER_BATCH_" + dateString));
headMap.put("SEND_STATUS", 'N'); headMap.put("SEND_STATUS", 'N');
headMap.put("SEND_TIME", now); headMap.put("SEND_TIME", now);
...@@ -97,14 +116,66 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService { ...@@ -97,14 +116,66 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService {
headMap.put("UPDATEDBY", null); headMap.put("UPDATEDBY", null);
List<Map<String, Object>> itemDatas = new ArrayList<Map<String, Object>>();
for(ITEM_DATA ITEM_DATA : itemList) { if(itemList != null) {
for(ITEM_DATA ITEM_DATA : itemList) {
Map<String, Object> itemDataMap = new HashMap<String, Object>();
Long itemId = Long.valueOf("" + System.currentTimeMillis() + StringUtil.format(common.getNextval("T_PERFORM_INVOICE_HEADER_ID_" + dateString), "00000"));
ITEM_REFERENCE_DATA ITEM_REFERENCE_DATA = ITEM_DATA.getITEM_REFERENCE_DATA();
ITEM_MATERIAL_DATA ITEM_MATERIAL_DATA = ITEM_DATA.getITEM_MATERIAL_DATA();
List<ITEM_AMOUNT_DATA> itemAmountList = ITEM_DATA.getITEM_AMOUNT_DATA();
ITEM_VAT_DATA ITEM_VAT_DATA = ITEM_DATA.getITEM_VAT_DATA();
List<ITEM_REFERENCE_PO_TYPE> poTypeList = ITEM_DATA.getITEM_REFERENCE_PO_TYPE();
itemDataMap.put("ID", itemId);
itemDataMap.put("HEADER_ID", headerId);
if(ITEM_DATA != null) {
itemDataMap.put("POSEX", ITEM_DATA.getPOSEX());
itemDataMap.put("MENGE", ITEM_DATA.getMENGE());
itemDataMap.put("MENEE", ITEM_DATA.getMENEE());
itemDataMap.put("WERKS", ITEM_DATA.getWERKS());
}
if(ITEM_REFERENCE_DATA != null) {
itemDataMap.put("REFERENCE_QUALF", ITEM_REFERENCE_DATA.getQUALF());
itemDataMap.put("REFERENCE_BELNR", ITEM_REFERENCE_DATA.getBELNR());
itemDataMap.put("REFERENCE_ZEILE", ITEM_REFERENCE_DATA.getZEILE());
itemDataMap.put("REFERENCE_QUALF_DN", ITEM_REFERENCE_DATA.getQUALF_DN());
itemDataMap.put("REFERENCE_BELNR_DN", ITEM_REFERENCE_DATA.getBELNR_DN());
itemDataMap.put("REFERENCE_ZEILE_DN", ITEM_REFERENCE_DATA.getZEILE_DN());
}
if(ITEM_MATERIAL_DATA != null) {
itemDataMap.put("MATERIAL_QUALF", ITEM_MATERIAL_DATA.getQUALF());
itemDataMap.put("MATERIAL_IDTNR", ITEM_MATERIAL_DATA.getIDTNR());
itemDataMap.put("MATERIAL_DIDTNR", null);
}
if(itemAmountList != null) {
for(int i = 0; i < itemAmountList.size(); i++) {
ITEM_AMOUNT_DATA ITEM_AMOUNT_DATA = itemAmountList.get(i);
headMap.put("AMOUNT_QUALF" + (i + 1), ITEM_AMOUNT_DATA.getQUALF());
headMap.put("AMOUNT_BETRG" + (i + 1), ITEM_AMOUNT_DATA.getBETRG());
}
}
if(ITEM_VAT_DATA != null) {
itemDataMap.put("VAT_MWSKZ", ITEM_VAT_DATA.getMWSKZ());
itemDataMap.put("VAT_MWSBT", ITEM_VAT_DATA.getMWSBT());
}
if(poTypeList != null) {
for(int i = 0; i < poTypeList.size(); i++) {
ITEM_REFERENCE_PO_TYPE ITEM_REFERENCE_PO_TYPE = poTypeList.get(i);
headMap.put("REFERENCE_PO_TYPE_TDID" + (i + 1), ITEM_REFERENCE_PO_TYPE.getTDID());
headMap.put("REFERENCE_PO_DATA_TDLINE" + (i + 1), ITEM_REFERENCE_PO_TYPE.getITEM_REFERENCE_PO_DATA().getTDLINE());
}
}
itemDataMap.put("CREATED", now);
itemDataMap.put("CREATEDBY", "system");
itemDataMap.put("UPDATED", headerId);
itemDataMap.put("UPDATEDBY", headerId);
itemDatas.add(itemDataMap);
}
} }
Sql headerSql = SqlUtil.insertSql("t_perform_invoice_header", headMap);
jdbcTemplate.update(headerSql.getSql(), headerSql.getArgs());
Sql sql = SqlUtil.insertSql("t_perform_invoice_header", headMap); Sql itemDataSql = SqlUtil.insertSqlBatch("t_perform_invoice_item", itemDatas);
jdbcTemplate.update(sql.getSql(), sql.getArgs()); jdbcTemplate.batchUpdate(itemDataSql.getSql(), itemDataSql.getBachArgs());
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
......
...@@ -55,11 +55,13 @@ public class SqlUtil { ...@@ -55,11 +55,13 @@ public class SqlUtil {
public static class Sql { public static class Sql {
private String sql; private String sql;
private Object[][] args; private List<Object[]> args = new ArrayList<Object[]>();
public Sql(String sql, Object[]... args) { public Sql(String sql, Object[]... argsAry) {
this.sql = sql; this.sql = sql;
this.args = args; for(Object[] ary : argsAry) {
this.args.add(ary);
}
} }
public String getSql() { public String getSql() {
...@@ -67,10 +69,10 @@ public class SqlUtil { ...@@ -67,10 +69,10 @@ public class SqlUtil {
} }
public Object[] getArgs() { public Object[] getArgs() {
return (args != null && args.length > 0) ? args[0] : new Object[]{}; return (args != null && args.size() > 0) ? args.get(0) : new Object[]{};
} }
public Object[][] getBachArgs() { public List<Object[]> getBachArgs() {
return args; return args;
} }
......
...@@ -72,4 +72,11 @@ public class StringUtil { ...@@ -72,4 +72,11 @@ public class StringUtil {
return String.valueOf(sb); return String.valueOf(sb);
} }
} }
public static String format(Object no, String format) {
String strno = String.valueOf(no);
Integer index = format.length() - strno.length();
return format.substring(0, index) + strno;
}
} }
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