Commit 2d3d5753 authored by Quxl's avatar Quxl

x

parent 93a4b99d
...@@ -10,18 +10,22 @@ import java.util.Map.Entry; ...@@ -10,18 +10,22 @@ import java.util.Map.Entry;
import javax.jws.WebService; import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.HEADER; import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.HEADER;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.ITEM_DATA; import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.ITEM_DATA;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.ITEM_PRICING; import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.ITEM_PRICING;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.RESPONSE; import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.RESPONSE;
import com.egolm.sso.util.DateUtil; import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil; import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
@Component @Component
@WebService(serviceName = "ConfirmQuotationService", targetNamespace = "http://confirm_quotation.sso.egolm.com", endpointInterface = "com.egolm.sso.services.confirm_quotation.ConfirmQuotationService") @WebService(serviceName = "ConfirmQuotationService", targetNamespace = "http://confirm_quotation.sso.egolm.com", endpointInterface = "com.egolm.sso.services.confirm_quotation.ConfirmQuotationService")
...@@ -33,15 +37,18 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService { ...@@ -33,15 +37,18 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService {
@Autowired @Autowired
CommonService common; CommonService common;
@Value("${xmlRoot}")
private String xmlRoot;
@Override @Override
@Transactional @Transactional
public void execute(Z_MT_SD_008_SO_CONFIRM_QUOTATION Z_MT_SD_008_SO_CONFIRM_QUOTATION) { public void execute(Z_MT_SD_008_SO_CONFIRM_QUOTATION Z_MT_SD_008_SO_CONFIRM_QUOTATION) {
boolean isSuccess = true;
Date now = new Date(); Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE); String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime(); Long time = now.getTime();
System.out.println(JSON.toJSONString(Z_MT_SD_008_SO_CONFIRM_QUOTATION)); System.out.println(JSON.toJSONString(Z_MT_SD_008_SO_CONFIRM_QUOTATION));
try {
Map<String, Object> header = new HashMap<>(); Map<String, Object> header = new HashMap<>();
RESPONSE res = Z_MT_SD_008_SO_CONFIRM_QUOTATION.getRESPONSE(); RESPONSE res = Z_MT_SD_008_SO_CONFIRM_QUOTATION.getRESPONSE();
HEADER h = res.getHEADER(); HEADER h = res.getHEADER();
...@@ -70,10 +77,10 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService { ...@@ -70,10 +77,10 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService {
header.put("WAERK", h.getWAERK()); header.put("WAERK", h.getWAERK());
header.put("DPFLAG", h.getDPFLAG()); header.put("DPFLAG", h.getDPFLAG());
header.put("SEND_STATUS", "N"); header.put("SEND_STATUS", "N");
header.put("BATCH", today+common.getNextval("T_SO_CONFIRMACTION_HEADER_BATCH_")+today); header.put("BATCH", dateString+common.getNextval("T_SO_CONFIRMACTION_HEADER_BATCH_")+dateString);
header.put("CREATED", now); header.put("CREATED", now);
header.put("CREATEDBY", "system"); header.put("CREATEDBY", "system");
String idIndex = StringUtil.format(common.getNextval("T_SO_CONFIRMATION_HEADER_ID_"+today), "00000"); String idIndex = StringUtil.format(common.getNextval("T_SO_CONFIRMATION_HEADER_ID_"+dateString), "00000");
Long hID = Long.valueOf(time+idIndex); Long hID = Long.valueOf(time+idIndex);
header.put("ID", hID); header.put("ID", hID);
header.put("TRACE_NO", "sapsoconfirmquotation"+DateUtil.formatDate(now, DateUtil.FMT_DATETIME)); header.put("TRACE_NO", "sapsoconfirmquotation"+DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
...@@ -108,7 +115,7 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService { ...@@ -108,7 +115,7 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService {
itemData.put("CITY1_I", id.getCITY1_I()); itemData.put("CITY1_I", id.getCITY1_I());
itemData.put("CREATED", now); itemData.put("CREATED", now);
itemData.put("CREATEDBY", "system"); itemData.put("CREATEDBY", "system");
String iidIndex = StringUtil.format(common.getNextval("T_SO_CONFIRMATION_ITEM_DATA_ID_"+today), "00000"); String iidIndex = StringUtil.format(common.getNextval("T_SO_CONFIRMATION_ITEM_DATA_ID_"+dateString), "00000");
Long iID = Long.valueOf(time+iidIndex); Long iID = Long.valueOf(time+iidIndex);
itemData.put("ID", iID); itemData.put("ID", iID);
itemDatas.put(id.getPOSNR(), itemData); itemDatas.put(id.getPOSNR(), itemData);
...@@ -130,10 +137,23 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService { ...@@ -130,10 +137,23 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService {
itemPricing.put("KWERT", StringUtil.toDouble(ip.getKWERT())); itemPricing.put("KWERT", StringUtil.toDouble(ip.getKWERT()));
itemPricing.put("CREATED", now); itemPricing.put("CREATED", now);
itemPricing.put("CREATEDBY", "system"); itemPricing.put("CREATEDBY", "system");
String itemPricingID = StringUtil.format(common.getNextval("T_SO_CONFIRMATION_ITEM_PRICING_ID_"+today), "00000"); String itemPricingID = StringUtil.format(common.getNextval("T_SO_CONFIRMATION_ITEM_PRICING_ID_"+dateString), "00000");
itemPricing.put("ID", Long.valueOf(time+itemPricingID)); itemPricing.put("ID", Long.valueOf(time+itemPricingID));
insertTo(itemPricing, "t_so_confirmation_item_pricing"); insertTo(itemPricing, "t_so_confirmation_item_pricing");
} }
} catch (Exception e) {
isSuccess = false;
throw new XRException("数据保存失败", e);
} finally {
String xmlName = Z_MT_SD_008_SO_CONFIRM_QUOTATION.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(Z_MT_SD_008_SO_CONFIRM_QUOTATION);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
}
}
} }
private void insertTo(Map<String, Object> obj, String table) { private void insertTo(Map<String, Object> obj, String table) {
......
...@@ -7,14 +7,18 @@ import java.util.Map; ...@@ -7,14 +7,18 @@ import java.util.Map;
import javax.jws.WebService; import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.util.DateUtil; import com.egolm.sso.util.DateUtil;
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.XMLUtil;
@Component @Component
@WebService(serviceName = "DNDeletionService", targetNamespace = "http://dn_deletion.sso.egolm.com", endpointInterface = "com.egolm.sso.services.dn_deletion.DNDeletionService") @WebService(serviceName = "DNDeletionService", targetNamespace = "http://dn_deletion.sso.egolm.com", endpointInterface = "com.egolm.sso.services.dn_deletion.DNDeletionService")
...@@ -27,11 +31,16 @@ public class DNDeletionServiceImpl implements DNDeletionService { ...@@ -27,11 +31,16 @@ public class DNDeletionServiceImpl implements DNDeletionService {
@Autowired @Autowired
CommonService common; CommonService common;
@Value("${xmlRoot}")
private String xmlRoot;
@Override @Override
@Transactional @Transactional
public void execute(DELETED_DOCUMENTS DELETED_DOCUMENTS) { public void execute(DELETED_DOCUMENTS DELETED_DOCUMENTS) {
boolean isSuccess = true;
Date now = new Date(); Date now = new Date();
String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE); String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
try {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put("MSGID", DELETED_DOCUMENTS.getMSGID()); map.put("MSGID", DELETED_DOCUMENTS.getMSGID());
map.put("TARGET_SYSTEM", DELETED_DOCUMENTS.getTARGET_SYSTEM()); map.put("TARGET_SYSTEM", DELETED_DOCUMENTS.getTARGET_SYSTEM());
...@@ -49,6 +58,19 @@ public class DNDeletionServiceImpl implements DNDeletionService { ...@@ -49,6 +58,19 @@ public class DNDeletionServiceImpl implements DNDeletionService {
map.put("UPDATEDBY", "system"); map.put("UPDATEDBY", "system");
Sql headerSql = SqlUtil.insertSql("t_so_dn_deletion", map); Sql headerSql = SqlUtil.insertSql("t_so_dn_deletion", map);
jdbcTemplate.update(headerSql.getSql(), headerSql.getArgs()); jdbcTemplate.update(headerSql.getSql(), headerSql.getArgs());
} catch (Exception e) {
isSuccess = false;
throw new XRException("数据保存失败", e);
} finally {
String xmlName = DELETED_DOCUMENTS.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(DELETED_DOCUMENTS);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
}
}
} }
} }
...@@ -124,7 +124,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService { ...@@ -124,7 +124,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
String xmlName = Z_MT_SD_001_MATERIAL_MASTER.getClass().getSimpleName(); String xmlName = Z_MT_SD_001_MATERIAL_MASTER.getClass().getSimpleName();
try { try {
String xml = XMLUtil.toXml(Z_MT_SD_001_MATERIAL_MASTER); String xml = XMLUtil.toXml(Z_MT_SD_001_MATERIAL_MASTER);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(dateString + "MATERIAL_MASTER_FILE_NAME" + dateString) + ".XML"; String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml); FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) { } catch (Exception e) {
throw new XRException("报文保存失败", e); throw new XRException("报文保存失败", e);
......
...@@ -9,10 +9,12 @@ import java.util.Map; ...@@ -9,10 +9,12 @@ import java.util.Map;
import javax.jws.WebService; import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA; import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE; import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE;
...@@ -29,9 +31,11 @@ import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_V ...@@ -29,9 +31,11 @@ import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_V
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.SUMMARY_GENERAL; import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.SUMMARY_GENERAL;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE; import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE;
import com.egolm.sso.util.DateUtil; import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.SqlUtil; import com.egolm.sso.util.SqlUtil;
import com.egolm.sso.util.StringUtil;
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;
@Component @Component
@WebService(serviceName = "PrformaInvoiceService", targetNamespace = "http://prforma_invoice.sso.egolm.com", endpointInterface = "com.egolm.sso.services.prforma_invoice.PrformaInvoiceService") @WebService(serviceName = "PrformaInvoiceService", targetNamespace = "http://prforma_invoice.sso.egolm.com", endpointInterface = "com.egolm.sso.services.prforma_invoice.PrformaInvoiceService")
...@@ -43,11 +47,16 @@ public class PrformaInvoiceServiceImpl implements PrformaInvoiceService { ...@@ -43,11 +47,16 @@ public class PrformaInvoiceServiceImpl implements PrformaInvoiceService {
@Autowired @Autowired
CommonService common; CommonService common;
@Value("${xmlRoot}")
private String xmlRoot;
@Override @Override
@Transactional @Transactional
public void execute(Z_MT_SD_005_PERFORM_INVOICE Z_MT_SD_005_PERFORM_INVOICE) { public void execute(Z_MT_SD_005_PERFORM_INVOICE Z_MT_SD_005_PERFORM_INVOICE) {
boolean isSuccess = true;
Date now = new Date(); Date now = new Date();
String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE); String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
try {
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 = Z_MT_SD_005_PERFORM_INVOICE.getZ_DT_SD_005_PERFORM_INVOICE(); Z_DT_SD_005_PERFORM_INVOICE Z_DT_SD_005_PERFORM_INVOICE = Z_MT_SD_005_PERFORM_INVOICE.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();
...@@ -165,6 +174,19 @@ public class PrformaInvoiceServiceImpl implements PrformaInvoiceService { ...@@ -165,6 +174,19 @@ public class PrformaInvoiceServiceImpl implements PrformaInvoiceService {
jdbcTemplate.update(headerSql.getSql(), headerSql.getArgs()); jdbcTemplate.update(headerSql.getSql(), headerSql.getArgs());
Sql itemDataSql = SqlUtil.insertSqlBatch("t_perform_invoice_item", itemDatas); Sql itemDataSql = SqlUtil.insertSqlBatch("t_perform_invoice_item", itemDatas);
jdbcTemplate.batchUpdate(itemDataSql.getSql(), itemDataSql.getBachArgs()); jdbcTemplate.batchUpdate(itemDataSql.getSql(), itemDataSql.getBachArgs());
} catch (Exception e) {
isSuccess = false;
throw new XRException("数据保存失败", e);
} finally {
String xmlName = Z_MT_SD_005_PERFORM_INVOICE.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(Z_MT_SD_005_PERFORM_INVOICE);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
}
}
} }
} }
...@@ -10,16 +10,20 @@ import java.util.Map.Entry; ...@@ -10,16 +10,20 @@ import java.util.Map.Entry;
import javax.jws.WebService; import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.HEADER_SENDING; import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.HEADER_SENDING;
import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.ITEM; import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.ITEM;
import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.RECORD; import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.RECORD;
import com.egolm.sso.util.DateUtil; import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil; import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
@Component @Component
...@@ -32,13 +36,17 @@ public class PriceListServiceImpl implements PriceListService { ...@@ -32,13 +36,17 @@ public class PriceListServiceImpl implements PriceListService {
@Autowired @Autowired
CommonService common; CommonService common;
@Value("${xmlRoot}")
private String xmlRoot;
@Override @Override
@Transactional @Transactional
public void execute(Z_MT_SD_002_PRICE_LIST Z_MT_SD_002_PRICE_LIST) { public void execute(Z_MT_SD_002_PRICE_LIST Z_MT_SD_002_PRICE_LIST) {
boolean isSuccess = true;
Date now = new Date(); Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE); String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
System.out.println(new Gson().toJson(Z_MT_SD_002_PRICE_LIST)); System.out.println(new Gson().toJson(Z_MT_SD_002_PRICE_LIST));
try {
RECORD r = Z_MT_SD_002_PRICE_LIST.getRECORD(); RECORD r = Z_MT_SD_002_PRICE_LIST.getRECORD();
HEADER_SENDING h = r.getHEADER_SENDING(); HEADER_SENDING h = r.getHEADER_SENDING();
List<ITEM> items = r.getITEM(); List<ITEM> items = r.getITEM();
...@@ -73,8 +81,8 @@ public class PriceListServiceImpl implements PriceListService { ...@@ -73,8 +81,8 @@ public class PriceListServiceImpl implements PriceListService {
priceObj.put("SEND_DATE", new Date(0));// 发送时间 priceObj.put("SEND_DATE", new Date(0));// 发送时间
*/ */
priceObj.put("SEND_STATUS", "N"); priceObj.put("SEND_STATUS", "N");
Long BATCHID = common.getNextval("T_PRICE_LIST_BATCH_" + today); Long BATCHID = common.getNextval("T_PRICE_LIST_BATCH_" + dateString);
String BATCH = today + "-" + BATCHID; String BATCH = dateString + "-" + BATCHID;
priceObj.put("TRACE_NO", "sappricelist" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME)); priceObj.put("TRACE_NO", "sappricelist" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
priceObj.put("BATCH", BATCH); priceObj.put("BATCH", BATCH);
...@@ -84,6 +92,19 @@ public class PriceListServiceImpl implements PriceListService { ...@@ -84,6 +92,19 @@ public class PriceListServiceImpl implements PriceListService {
insertPriceObj(priceObj); insertPriceObj(priceObj);
} }
} }
} catch (Exception e) {
isSuccess = false;
throw new XRException("数据保存失败", e);
} finally {
String xmlName = Z_MT_SD_002_PRICE_LIST.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(Z_MT_SD_002_PRICE_LIST);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
}
}
} }
private void updatePriceObj(Map<String, Object> priceObj) { private void updatePriceObj(Map<String, Object> priceObj) {
......
...@@ -10,11 +10,13 @@ import java.util.Map.Entry; ...@@ -10,11 +10,13 @@ import java.util.Map.Entry;
import javax.jws.WebService; import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DATE; import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DATE;
import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DELIVERY; import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DELIVERY;
...@@ -25,7 +27,9 @@ import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRM ...@@ -25,7 +27,9 @@ import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRM
import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.ITEM_REFERENCE_SO; import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.ITEM_REFERENCE_SO;
import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE; import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE;
import com.egolm.sso.util.DateUtil; import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil; import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
@Component @Component
@WebService(serviceName = "ShippingNotificationService", targetNamespace = "http://shipping_notfirmation.sso.egolm.com", endpointInterface = "com.egolm.sso.services.shipping_notfirmation.ShippingNotificationService") @WebService(serviceName = "ShippingNotificationService", targetNamespace = "http://shipping_notfirmation.sso.egolm.com", endpointInterface = "com.egolm.sso.services.shipping_notfirmation.ShippingNotificationService")
...@@ -38,15 +42,18 @@ public class ShippingNotificationServiceImpl implements ShippingNotificationServ ...@@ -38,15 +42,18 @@ public class ShippingNotificationServiceImpl implements ShippingNotificationServ
@Autowired @Autowired
CommonService common; CommonService common;
@Value("${xmlRoot}")
private String xmlRoot;
@Override @Override
@Transactional @Transactional
public void execute(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE) { public void execute(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE) {
boolean isSuccess = true;
System.out.println(JSON.toJSONString(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE)); System.out.println(JSON.toJSONString(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE));
Date now = new Date(); Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE); String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime(); Long time = now.getTime();
try {
Map<String, Object> header = new HashMap<>(); Map<String, Object> header = new HashMap<>();
Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE = Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.getZ_DT_SD_007_SHIPPING_NOTIFICATION_FILE(); Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE = Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.getZ_DT_SD_007_SHIPPING_NOTIFICATION_FILE();
HEADER_DELIVERY HEADER_DELIVERY = Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE.getHEADER_DELIVERY(); HEADER_DELIVERY HEADER_DELIVERY = Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE.getHEADER_DELIVERY();
...@@ -92,19 +99,19 @@ public class ShippingNotificationServiceImpl implements ShippingNotificationServ ...@@ -92,19 +99,19 @@ public class ShippingNotificationServiceImpl implements ShippingNotificationServ
header.put("QUALF", HEADER_DATE.getQUALF()); header.put("QUALF", HEADER_DATE.getQUALF());
header.put("NTEND", HEADER_DATE.getNTEND()); header.put("NTEND", HEADER_DATE.getNTEND());
} }
header.put("BATCH", today+"-"+common.getNextval("T_SHIPPING_NOTIFICATION_HEADER_BATCH_"+today)); header.put("BATCH", dateString+"-"+common.getNextval("T_SHIPPING_NOTIFICATION_HEADER_BATCH_"+dateString));
header.put("SEND_STATUS", "N"); header.put("SEND_STATUS", "N");
header.put("TRACE_NO", "sapshippingnotification"+DateUtil.formatDate(now, DateUtil.FMT_DATETIME)); header.put("TRACE_NO", "sapshippingnotification"+DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
header.put("CREATED", now); header.put("CREATED", now);
header.put("CREATEDBY", "system"); header.put("CREATEDBY", "system");
Long hID = Long.valueOf(time+StringUtil.format(common.getNextval("T_SHIPPING_NOTIFICATION_HEADER_ID_"+today), "00000")); Long hID = Long.valueOf(time+StringUtil.format(common.getNextval("T_SHIPPING_NOTIFICATION_HEADER_ID_"+dateString), "00000"));
header.put("ID", hID); header.put("ID", hID);
insertTo(header, "t_shipping_notification_header"); insertTo(header, "t_shipping_notification_header");
List<ITEM> ITEMs = HEADER_DELIVERY.getITEM(); List<ITEM> ITEMs = HEADER_DELIVERY.getITEM();
for(ITEM ITEM : ITEMs) { for(ITEM ITEM : ITEMs) {
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>();
Long iID = Long.valueOf(time+StringUtil.format(common.getNextval("T_SHIPPING_NOTIFICATION_ITEM_ID_"+today), "00000")); Long iID = Long.valueOf(time+StringUtil.format(common.getNextval("T_SHIPPING_NOTIFICATION_ITEM_ID_"+dateString), "00000"));
item.put("ID", iID); item.put("ID", iID);
item.put("HEADER_ID", hID); item.put("HEADER_ID", hID);
item.put("POSNR", ITEM.getPOSNR()); item.put("POSNR", ITEM.getPOSNR());
...@@ -134,6 +141,19 @@ public class ShippingNotificationServiceImpl implements ShippingNotificationServ ...@@ -134,6 +141,19 @@ public class ShippingNotificationServiceImpl implements ShippingNotificationServ
item.put("CREATEDBY", "system"); item.put("CREATEDBY", "system");
insertTo(item, "t_shipping_notification_item"); insertTo(item, "t_shipping_notification_item");
} }
} catch (Exception e) {
isSuccess = false;
throw new XRException("数据保存失败", e);
} finally {
String xmlName = Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
}
}
} }
private void insertTo(Map<String, Object> obj, String table) { private void insertTo(Map<String, Object> obj, String table) {
......
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