Commit dbe62962 authored by Quxl's avatar Quxl

x

parent 13dacb3a
......@@ -12,6 +12,7 @@ import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
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;
......@@ -20,11 +21,14 @@ 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.ITEM_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;
import com.egolm.sso.util.SqlUtil;
import com.egolm.sso.util.SqlUtil.Sql;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
......@@ -39,6 +43,7 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService {
CommonService common;
@Override
@Transactional
public void execute(String xml) {
Date now = new Date();
Z_MT_SD_005_PERFORM_INVOICE bean = XMLUtil.toBeanByJxab(xml, Z_MT_SD_005_PERFORM_INVOICE.class);
......@@ -53,7 +58,7 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService {
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();
List<ITEM_DATA> itemList = Z_DT_SD_005_PERFORM_INVOICE.getITEM_DATA();
headMap.put("GENERAL_BELNR", HEADER_GENERAL_DATA.getBELNR());
headMap.put("GENERAL_ZTERM", HEADER_GENERAL_DATA.getZTERM());
......@@ -92,6 +97,14 @@ public class ProFormaInvoiceServiceImpl implements ProFormaInvoiceService {
headMap.put("UPDATEDBY", null);
for(ITEM_DATA ITEM_DATA : itemList) {
}
Sql sql = SqlUtil.insertSql("t_perform_invoice_header", headMap);
jdbcTemplate.update(sql.getSql(), sql.getArgs());
}
public static void main(String[] args) throws IOException {
......
package com.egolm.sso.util;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
......@@ -9,17 +7,30 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
public class SqlUtil {
private static String tipRight = "`";
private static String tipLeft = "`";
public Sql argsInsert(String tableName, Map<String, Object> objMap) {
public static Sql insertSqlBatch(String table_name, List<Map<String, Object>> objs) {
List<String> names = new ArrayList<String>();
Object[][] vals = new Object[objs.size()][];
for(int i = 0; i < objs.size(); i++) {
Map<String, Object> map = objs.get(i);
List<Object> valsAry = new ArrayList<Object>();
for(String key : map.keySet()) {
if(i == 0) {
names.add(key);
}
valsAry.add(map.get(key));
}
vals[i] = valsAry.toArray();
}
String sql = "insert into " + table_name + StringUtil.join(tipRight + ", " + tipLeft, " (" + tipLeft, tipRight + ") ", "", names) + " values" + StringUtil.join("?", ", ", names.size(), " (", ")");
return new Sql(sql, vals);
}
public static Sql insertSql(String tableName, Map<String, Object> objMap) {
String table_name = tableName;
Set<String> keySet = objMap.keySet();
String[] setArray = keySet.toArray(new String[keySet.size()]);
......@@ -65,98 +76,4 @@ public class SqlUtil {
}
public static class Desc {
private final String name;
private final String[] fieldPkNames;
private final String[] columnPkNames;
private final String[] fieldNames;
private final String[] columnNames;
public Desc(Class<?> clz) {
Field[] objectFields = clz.getDeclaredFields();
String tableName = null;
if(clz.isAnnotationPresent(Entity.class)) {
Entity entity = clz.getAnnotation(Entity.class);
String tableAnnoName = entity.name();
if(tableAnnoName != null && tableAnnoName.trim().length() > 0) {
tableName = tableAnnoName;
} else {
tableName = clz.getSimpleName();
}
}
List<String> all_field_names = new ArrayList<String>();
List<String> all_column_names = new ArrayList<String>();
List<String> pk_field_names = new ArrayList<String>();
List<String> pk_column_names = new ArrayList<String>();
for(int i = 0; i < objectFields.length; i++) {
Field field = objectFields[i];
int mod = field.getModifiers();
if(!Modifier.isStatic(mod) && !Modifier.isFinal(mod)) {
String fieldName = field.getName();
String columnName = null;
if(field.isAnnotationPresent(Column.class)) {
Column column = field.getAnnotation(Column.class);
String columnAnnoName = column.name();
if(columnAnnoName != null && columnAnnoName.trim().length() > 0 ) {
columnName = columnAnnoName;
} else {
columnName = fieldName;
}
} else {
columnName = fieldName;
}
if(field.isAnnotationPresent(Id.class)) {
pk_field_names.add(fieldName);
pk_column_names.add(columnName);
}
all_field_names.add(fieldName);
all_column_names.add(columnName);
}
}
this.name = tableName;
this.fieldNames = all_field_names.toArray(new String[all_field_names.size()]);
this.columnNames = all_column_names.toArray(new String[all_column_names.size()]);
this.fieldPkNames = pk_field_names.toArray(new String[pk_field_names.size()]);
this.columnPkNames = pk_column_names.toArray(new String[pk_column_names.size()]);
}
public String[] getColumnsByFidlds(String[] fields) {
List<String> columns = new ArrayList<String>();
for(String field : fields) {
String columnName = null;
for(int i = 0; i < fieldNames.length; i++) {
if(field.equals(fieldNames[i])) {
columnName = columnNames[i];
}
}
columns.add(columnName);
}
return columns.toArray(new String[columns.size()]);
}
public String getName() {
return name;
}
public String[] getFieldPkNames() {
return fieldPkNames;
}
public String[] getColumnPkNames() {
return columnPkNames;
}
public String[] getFieldNames() {
return fieldNames;
}
public String[] getColumnNames() {
return columnNames;
}
}
}
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