Commit f988e474 authored by Quxl's avatar Quxl

x

parent 1203be12
package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.egolm.sso.distributors.SI_004_INVENTORY_SyncOutService package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _MT004INVENTORY_QNAME = new QName("http://distributors.edi.digital.cn.se.com", "MT_004_INVENTORY");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.egolm.sso.distributors.SI_004_INVENTORY_SyncOutService
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING }
*
*/
public ZDTSD004INVENTORYSENDING createZDTSD004INVENTORYSENDING() {
return new ZDTSD004INVENTORYSENDING();
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING.RECORD }
*
*/
public ZDTSD004INVENTORYSENDING.RECORD createZDTSD004INVENTORYSENDINGRECORD() {
return new ZDTSD004INVENTORYSENDING.RECORD();
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO }
*
*/
public ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO createZDTSD004INVENTORYSENDINGRECORDREVENUERATIO() {
return new ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO();
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD }
*
*/
public ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD createZDTSD004INVENTORYSENDINGRECORDINVENTORYRECORD() {
return new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD();
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO.HEADER }
*
*/
public ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO.HEADER createZDTSD004INVENTORYSENDINGRECORDREVENUERATIOHEADER() {
return new ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO.HEADER();
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO.ITEM }
*
*/
public ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO.ITEM createZDTSD004INVENTORYSENDINGRECORDREVENUERATIOITEM() {
return new ZDTSD004INVENTORYSENDING.RECORD.REVENUERATIO.ITEM();
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER }
*
*/
public ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER createZDTSD004INVENTORYSENDINGRECORDINVENTORYRECORDHEADER() {
return new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER();
}
/**
* Create an instance of {@link ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM }
*
*/
public ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM createZDTSD004INVENTORYSENDINGRECORDINVENTORYRECORDITEM() {
return new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link ZDTSD004INVENTORYSENDING }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://distributors.edi.digital.cn.se.com", name = "MT_004_INVENTORY")
public JAXBElement<ZDTSD004INVENTORYSENDING> createMT004INVENTORY(ZDTSD004INVENTORYSENDING value) {
return new JAXBElement<ZDTSD004INVENTORYSENDING>(_MT004INVENTORY_QNAME, ZDTSD004INVENTORYSENDING.class, null, value);
}
}
package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by Apache CXF 3.2.9
* 2019-08-08T11:40:45.767+08:00
* Generated source version: 3.2.9
*
*/
@WebService(targetNamespace = "http://distributors.edi.digital.cn.se.com", name = "SI_004_INVENTORY_SyncOut")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface SI004INVENTORYSyncOut {
@WebMethod(operationName = "SI_004_INVENTORY_SyncOut", action = "http://sap.com/xi/WebService/soap1.1")
@Oneway
public void si004INVENTORYSyncOut(
@WebParam(partName = "MT_004_INVENTORY", name = "MT_004_INVENTORY", targetNamespace = "http://distributors.edi.digital.cn.se.com")
ZDTSD004INVENTORYSENDING mt004INVENTORY
);
}
package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
/**
* This class was generated by Apache CXF 3.2.9
* 2019-08-08T11:40:45.802+08:00
* Generated source version: 3.2.9
*
*/
@WebServiceClient(name = "SI_004_INVENTORY_SyncOutService",
wsdlLocation = "file:SI_004_INVENTORY_SyncOutService.wsdl",
targetNamespace = "http://distributors.edi.digital.cn.se.com")
public class SI004INVENTORYSyncOutService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://distributors.edi.digital.cn.se.com", "SI_004_INVENTORY_SyncOutService");
public final static QName HTTPSPort = new QName("http://distributors.edi.digital.cn.se.com", "HTTPS_Port");
public final static QName HTTPPort = new QName("http://distributors.edi.digital.cn.se.com", "HTTP_Port");
static {
URL url = null;
try {
url = new URL("file:SI_004_INVENTORY_SyncOutService.wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(SI004INVENTORYSyncOutService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "file:SI_004_INVENTORY_SyncOutService.wsdl");
}
WSDL_LOCATION = url;
}
public SI004INVENTORYSyncOutService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public SI004INVENTORYSyncOutService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public SI004INVENTORYSyncOutService() {
super(WSDL_LOCATION, SERVICE);
}
public SI004INVENTORYSyncOutService(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features);
}
public SI004INVENTORYSyncOutService(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features);
}
public SI004INVENTORYSyncOutService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns SI004INVENTORYSyncOut
*/
@WebEndpoint(name = "HTTPS_Port")
public SI004INVENTORYSyncOut getHTTPSPort() {
return super.getPort(HTTPSPort, SI004INVENTORYSyncOut.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns SI004INVENTORYSyncOut
*/
@WebEndpoint(name = "HTTPS_Port")
public SI004INVENTORYSyncOut getHTTPSPort(WebServiceFeature... features) {
return super.getPort(HTTPSPort, SI004INVENTORYSyncOut.class, features);
}
/**
*
* @return
* returns SI004INVENTORYSyncOut
*/
@WebEndpoint(name = "HTTP_Port")
public SI004INVENTORYSyncOut getHTTPPort() {
return super.getPort(HTTPPort, SI004INVENTORYSyncOut.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns SI004INVENTORYSyncOut
*/
@WebEndpoint(name = "HTTP_Port")
public SI004INVENTORYSyncOut getHTTPPort(WebServiceFeature... features) {
return super.getPort(HTTPPort, SI004INVENTORYSyncOut.class, features);
}
}
package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.clients.ServiceFactory;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.CommonService.Page;
import com.egolm.sso.util.CollectionUtil;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.ThrowableUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component
public class SI004INVENTORYSyncOutServiceTask {
Log logger = LogFactory.getLog(SI004INVENTORYSyncOutServiceTask.class);
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private CommonService common;
@Value("${schneider.username}")
private String username;
@Value("${schneider.password}")
private String password;
@Value("${WSDLPATH}")
private String WSDLPATH;
@Value("${xmlRoot}")
private String xmlRoot;
@Transactional
//@Scheduled(cron="${cronSi004}")
public void execute() {
this.runTask();
}
public void runTask() {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_004_INVENTORY_SyncOutService.wsdl";
SI004INVENTORYSyncOut service = ServiceFactory.create(SI004INVENTORYSyncOut.class, wsdlLocation, "http://distributors.edi.digital.cn.se.com", "SI_004_INVENTORY_SyncOutService", username, password);
this.sendData(service);
}
private void sendData(SI004INVENTORYSyncOut SI004INVENTORYSyncOut) {
Date now = new Date();
String timeString = DateUtil.formatDate(now, "yyyyMMddHHmmssSSS");
String apiName = "SAP库存数据接口";
String apiPath = "/XISOAPAdapter/MessageServlet/si004INVENTORYSyncOut";
Page page = new Page(1L, 1000L, new String[] {"DIS_CODE", "INVENTORY_DATE"});
String sql = "SELECT * FROM t_dis_inventory WHERE SEND_STATUS = 'N'";
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> tmp = null;
do {
String limitSql = common.limitByMysql(sql, page);
tmp = jdbcTemplate.queryForList(limitSql);
list.addAll(tmp);
page.toNextPage();
} while(tmp != null && tmp.size() > 0);
Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "INVENTORY_DATE");
for(List<Map<String, Object>> vList : datas.values()) {
boolean isSuccess = true;
ZDTSD004INVENTORYSENDING mt004INVENTORY = new ZDTSD004INVENTORYSENDING();
try {
JSONObject headerObject = new JSONObject(vList.get(0));
ZDTSD004INVENTORYSENDING.RECORD RECORD = new ZDTSD004INVENTORYSENDING.RECORD();
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD INVENTORYRECORD = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD();
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER INVENTORYRECORD_HEADER = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER();
INVENTORYRECORD_HEADER.setKUNNR(headerObject.getString("DIS_CODE"));
INVENTORYRECORD_HEADER.setNAME1(headerObject.getString("DIS_NAME"));
INVENTORYRECORD_HEADER.setZDATE(headerObject.getString("INVENTORY_DATE"));
INVENTORYRECORD_HEADER.setZSPART(headerObject.getString("MPG"));
INVENTORYRECORD.setHEADER(INVENTORYRECORD_HEADER);
RECORD.setINVENTORYRECORD(INVENTORYRECORD);
mt004INVENTORY.setRECORD(RECORD);
List<ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM> NVENTORYR_ITEM_LIST = INVENTORYRECORD.getITEM();
List<BigInteger> idList = new ArrayList<BigInteger>();
for(Map<String, Object> map : vList) {
JSONObject jsonObject = new JSONObject(map);
idList.add(jsonObject.getBigInteger("ID"));
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM NVENTORYR_ITEM = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM();
NVENTORYR_ITEM.setMAKTX(jsonObject.getString("DIS_SPEC"));
NVENTORYR_ITEM.setMATNR(jsonObject.getString("DIS_GOODS_CODE"));
NVENTORYR_ITEM.setMENGE(jsonObject.getString("DIS_QTY"));
NVENTORYR_ITEM.setPOSNR(jsonObject.getString("INVENTORY_LINE"));
NVENTORYR_ITEM.setZPRIC(jsonObject.getString("DIS_TAX_PRICE"));
NVENTORYR_ITEM.setZVALU(jsonObject.getString("DIS_TAX_AMOUNT"));
NVENTORYR_ITEM_LIST.add(NVENTORYR_ITEM);
}
SI004INVENTORYSyncOut.si004INVENTORYSyncOut(mt004INVENTORY);
String updateSql = "UPDATE t_dis_inventory SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")";
jdbcTemplate.update(updateSql, idList.toArray());
} catch (Throwable e) {
isSuccess = false;
throw new XRException(ThrowableUtil.getCaused(e).getMessage() + " -- " + timeString, e);
} finally {
try {
common.saveApiAccessLog(apiName, apiPath, isSuccess ? "S" : "F");
} catch (Exception e1) {
logger.error(timeString, e1);
}
String xmlName = "004_INVENTORY";
try {
String xml = XMLUtil.toXml(mt004INVENTORY);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(now, DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + timeString + ".XML";
FileUtil.writeText(xmlFullName, xml);
String json = new Gson().toJson(mt004INVENTORY);
FileUtil.writeText(xmlFullName + ".JSON", json);
} catch (Exception e) {
throw new XRException(ThrowableUtil.getCaused(e).getMessage(), e);
}
}
}
}
}
@javax.xml.bind.annotation.XmlSchema(namespace = "http://distributors.edi.digital.cn.se.com")
package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.egolm.sso.distributors.SI_011_ACTUAL_SALES_SyncOutService package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _MT011ACTUALSALES_QNAME = new QName("http://distributors.edi.digital.cn.se.com", "MT_011_ACTUAL_SALES");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.egolm.sso.distributors.SI_011_ACTUAL_SALES_SyncOutService
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link ZDTSD011ACTUALSALESSENDING }
*
*/
public ZDTSD011ACTUALSALESSENDING createZDTSD011ACTUALSALESSENDING() {
return new ZDTSD011ACTUALSALESSENDING();
}
/**
* Create an instance of {@link ZDTSD011ACTUALSALESSENDING.RECORD }
*
*/
public ZDTSD011ACTUALSALESSENDING.RECORD createZDTSD011ACTUALSALESSENDINGRECORD() {
return new ZDTSD011ACTUALSALESSENDING.RECORD();
}
/**
* Create an instance of {@link ZDTSD011ACTUALSALESSENDING.RECORD.HEADER }
*
*/
public ZDTSD011ACTUALSALESSENDING.RECORD.HEADER createZDTSD011ACTUALSALESSENDINGRECORDHEADER() {
return new ZDTSD011ACTUALSALESSENDING.RECORD.HEADER();
}
/**
* Create an instance of {@link ZDTSD011ACTUALSALESSENDING.RECORD.ITEM }
*
*/
public ZDTSD011ACTUALSALESSENDING.RECORD.ITEM createZDTSD011ACTUALSALESSENDINGRECORDITEM() {
return new ZDTSD011ACTUALSALESSENDING.RECORD.ITEM();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link ZDTSD011ACTUALSALESSENDING }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://distributors.edi.digital.cn.se.com", name = "MT_011_ACTUAL_SALES")
public JAXBElement<ZDTSD011ACTUALSALESSENDING> createMT011ACTUALSALES(ZDTSD011ACTUALSALESSENDING value) {
return new JAXBElement<ZDTSD011ACTUALSALESSENDING>(_MT011ACTUALSALES_QNAME, ZDTSD011ACTUALSALESSENDING.class, null, value);
}
}
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by Apache CXF 3.2.9
* 2019-08-08T11:41:02.603+08:00
* Generated source version: 3.2.9
*
*/
@WebService(targetNamespace = "http://distributors.edi.digital.cn.se.com", name = "SI_011_ACTUAL_SALES_SyncOut")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface SI011ACTUALSALESSyncOut {
@WebMethod(operationName = "SI_011_ACTUAL_SALES_SyncOut", action = "http://sap.com/xi/WebService/soap1.1")
@Oneway
public void si011ACTUALSALESSyncOut(
@WebParam(partName = "MT_011_ACTUAL_SALES", name = "MT_011_ACTUAL_SALES", targetNamespace = "http://distributors.edi.digital.cn.se.com")
ZDTSD011ACTUALSALESSENDING mt011ACTUALSALES
);
}
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
/**
* This class was generated by Apache CXF 3.2.9
* 2019-08-08T11:41:02.636+08:00
* Generated source version: 3.2.9
*
*/
@WebServiceClient(name = "SI_011_ACTUAL_SALES_SyncOutService",
wsdlLocation = "file:SI_011_ACTUAL_SALES_SyncOutService.wsdl",
targetNamespace = "http://distributors.edi.digital.cn.se.com")
public class SI011ACTUALSALESSyncOutService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://distributors.edi.digital.cn.se.com", "SI_011_ACTUAL_SALES_SyncOutService");
public final static QName HTTPSPort = new QName("http://distributors.edi.digital.cn.se.com", "HTTPS_Port");
public final static QName HTTPPort = new QName("http://distributors.edi.digital.cn.se.com", "HTTP_Port");
static {
URL url = null;
try {
url = new URL("file:SI_011_ACTUAL_SALES_SyncOutService.wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(SI011ACTUALSALESSyncOutService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "file:SI_011_ACTUAL_SALES_SyncOutService.wsdl");
}
WSDL_LOCATION = url;
}
public SI011ACTUALSALESSyncOutService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public SI011ACTUALSALESSyncOutService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public SI011ACTUALSALESSyncOutService() {
super(WSDL_LOCATION, SERVICE);
}
public SI011ACTUALSALESSyncOutService(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features);
}
public SI011ACTUALSALESSyncOutService(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features);
}
public SI011ACTUALSALESSyncOutService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns SI011ACTUALSALESSyncOut
*/
@WebEndpoint(name = "HTTPS_Port")
public SI011ACTUALSALESSyncOut getHTTPSPort() {
return super.getPort(HTTPSPort, SI011ACTUALSALESSyncOut.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns SI011ACTUALSALESSyncOut
*/
@WebEndpoint(name = "HTTPS_Port")
public SI011ACTUALSALESSyncOut getHTTPSPort(WebServiceFeature... features) {
return super.getPort(HTTPSPort, SI011ACTUALSALESSyncOut.class, features);
}
/**
*
* @return
* returns SI011ACTUALSALESSyncOut
*/
@WebEndpoint(name = "HTTP_Port")
public SI011ACTUALSALESSyncOut getHTTPPort() {
return super.getPort(HTTPPort, SI011ACTUALSALESSyncOut.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns SI011ACTUALSALESSyncOut
*/
@WebEndpoint(name = "HTTP_Port")
public SI011ACTUALSALESSyncOut getHTTPPort(WebServiceFeature... features) {
return super.getPort(HTTPPort, SI011ACTUALSALESSyncOut.class, features);
}
}
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.clients.ServiceFactory;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.CommonService.Page;
import com.egolm.sso.util.CollectionUtil;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.ThrowableUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component
public class SI011ACTUALSALESSyncOutServiceTask {
Log logger = LogFactory.getLog(SI011ACTUALSALESSyncOutServiceTask.class);
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private CommonService common;
@Value("${schneider.username}")
private String username;
@Value("${schneider.password}")
private String password;
@Value("${WSDLPATH}")
private String WSDLPATH;
@Value("${xmlRoot}")
private String xmlRoot;
@Transactional
//@Scheduled(cron="${cronSi011}")
public void execute() {
this.runTask();
}
public void runTask() {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_011_ACTUAL_SALES_SyncOutService.wsdl";
SI011ACTUALSALESSyncOut service = ServiceFactory.create(SI011ACTUALSALESSyncOut.class, wsdlLocation, "http://distributors.edi.digital.cn.se.com", "SI_011_ACTUAL_SALES_SyncOutService", username, password);
this.sendData(service);
}
private void sendData(SI011ACTUALSALESSyncOut SI011ACTUALSALESSyncOut) {
Date now = new Date();
String timeString = DateUtil.formatDate(now, "yyyyMMddHHmmssSSS");
String apiName = "SAP库存数据接口";
String apiPath = "/XISOAPAdapter/MessageServlet/si011ACTUALSALESSyncOut";
Page page = new Page(1L, 1000L, new String[] {"DIS_CODE", "SALES_NO"});
String sql = "SELECT * FROM t_dis_sales WHERE SEND_STATUS = 'N'";
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> tmp = null;
do {
String limitSql = common.limitByMysql(sql, page);
tmp = jdbcTemplate.queryForList(limitSql);
list.addAll(tmp);
page.toNextPage();
} while(tmp != null && tmp.size() > 0);
Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "SALES_NO");
for(List<Map<String, Object>> vList : datas.values()) {
boolean isSuccess = true;
ZDTSD011ACTUALSALESSENDING mt011ACTUALSALES = new ZDTSD011ACTUALSALESSENDING();
try {
ZDTSD011ACTUALSALESSENDING.RECORD RECORD = new ZDTSD011ACTUALSALESSENDING.RECORD();
mt011ACTUALSALES.setRECORD(RECORD);
ZDTSD011ACTUALSALESSENDING.RECORD.HEADER header = new ZDTSD011ACTUALSALESSENDING.RECORD.HEADER();
List<ZDTSD011ACTUALSALESSENDING.RECORD.ITEM> itemList = RECORD.getITEM();
JSONObject headerObject = new JSONObject(vList.get(0));
header.setAUBEL(headerObject.getString("SALES_NO"));
header.setFXSNA(headerObject.getString("DIS_NAME"));
header.setFXSNO(headerObject.getString("DIS_CODE"));
header.setSDATE(headerObject.getString("SALES_DATE"));
RECORD.setHEADER(header);
List<BigInteger> idList = new ArrayList<BigInteger>();
for(Map<String, Object> itemMap : vList) {
JSONObject itemObject = new JSONObject(itemMap);
idList.add(itemObject.getBigInteger("ID"));
ZDTSD011ACTUALSALESSENDING.RECORD.ITEM item = new ZDTSD011ACTUALSALESSENDING.RECORD.ITEM();
item.setCUSNA(itemObject.getString("DIS_STORE_NAME"));
item.setCUSNO(itemObject.getString("DIS_STORE_CODE"));
item.setCUSTY(itemObject.getString("DIS_STORE_TYPE"));
item.setFAMOU(itemObject.getString("DIS_TAX_AMOUNT"));
item.setFCITY(itemObject.getString("DIS_STORE_CITY"));
item.setFDNO(itemObject.getString("SALES_LINE"));
item.setFITEM(itemObject.getString("DIS_GOODS_CODE"));
item.setFPRIC(itemObject.getString("DIS_TAX_PRICE"));
item.setFPROV(itemObject.getString("DIS_STORE_PROV"));
item.setFQTY(itemObject.getString("DIS_QTY"));
item.setFSNDP(itemObject.getString("PURCHASING_PRICE"));
item.setMPG(itemObject.getString("MPG"));
item.setYLZD1(itemObject.getString("YLZD1"));
item.setYLZD2(itemObject.getString("YLZD2"));
item.setYLZD3(itemObject.getString("YLZD3"));
itemList.add(item);
}
SI011ACTUALSALESSyncOut.si011ACTUALSALESSyncOut(mt011ACTUALSALES);
String updateSql = "UPDATE t_dis_sales SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")";
jdbcTemplate.update(updateSql, idList.toArray());
} catch (Throwable e) {
isSuccess = false;
throw new XRException(ThrowableUtil.getCaused(e).getMessage() + " -- " + timeString, e);
} finally {
try {
common.saveApiAccessLog(apiName, apiPath, isSuccess ? "S" : "F");
} catch (Exception e1) {
logger.error(timeString, e1);
}
String xmlName = "011_ACTUAL_SALES";
try {
String xml = XMLUtil.toXml(mt011ACTUALSALES);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(now, DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + timeString + ".XML";
FileUtil.writeText(xmlFullName, xml);
String json = new Gson().toJson(mt011ACTUALSALES);
FileUtil.writeText(xmlFullName + ".JSON", json);
} catch (Exception e) {
throw new XRException(ThrowableUtil.getCaused(e).getMessage(), e);
}
}
}
}
}
@javax.xml.bind.annotation.XmlSchema(namespace = "http://distributors.edi.digital.cn.se.com")
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
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