Commit 97eaf3fe authored by 曲欣红's avatar 曲欣红

发货通知接口

parent ea3cac80
package com.egolm.sso.bean;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE", namespace="http://schneider-distributor.com/")
public class Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE {
Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE;
public Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE getZ_DT_SD_007_SHIPPING_NOTIFICATION_FILE() {
return Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE;
}
public void setZ_DT_SD_007_SHIPPING_NOTIFICATION_FILE(
Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE z_DT_SD_007_SHIPPING_NOTIFICATION_FILE) {
Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE = z_DT_SD_007_SHIPPING_NOTIFICATION_FILE;
}
public static class Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE{
HEADER_DELIVERY HEADER_DELIVERY;
public HEADER_DELIVERY getHEADER_DELIVERY() {
return HEADER_DELIVERY;
}
public void setHEADER_DELIVERY(HEADER_DELIVERY hEADER_DELIVERY) {
HEADER_DELIVERY = hEADER_DELIVERY;
}
}
public static class HEADER_DELIVERY{
String VBELN;
String LFART;
String INCO1;
String BTGEW;
String GEWEI;
String CMGST;
String VKORG;
List<HEADER_PARTNER> HEADER_PARTNER;
List<HEADER_DATE> HEADER_DATE;
List<ITEM> ITEM;
public String getVKORG() {
return VKORG;
}
public void setVKORG(String vKORG) {
VKORG = vKORG;
}
public String getCMGST() {
return CMGST;
}
public void setCMGST(String cMGST) {
CMGST = cMGST;
}
public String getLFART() {
return LFART;
}
public void setLFART(String lFART) {
LFART = lFART;
}
public String getVBELN() {
return VBELN;
}
public void setVBELN(String vBELN) {
VBELN = vBELN;
}
public String getINCO1() {
return INCO1;
}
public void setINCO1(String iNCO1) {
INCO1 = iNCO1;
}
public String getBTGEW() {
return BTGEW;
}
public void setBTGEW(String bTGEW) {
BTGEW = bTGEW;
}
public String getGEWEI() {
return GEWEI;
}
public void setGEWEI(String gEWEI) {
GEWEI = gEWEI;
}
public List<HEADER_PARTNER> getHEADER_PARTNER() {
return HEADER_PARTNER;
}
public void setHEADER_PARTNER(List<HEADER_PARTNER> hEADER_PARTNER) {
HEADER_PARTNER = hEADER_PARTNER;
}
public List<HEADER_DATE> getHEADER_DATE() {
return HEADER_DATE;
}
public void setHEADER_DATE(List<HEADER_DATE> hEADER_DATE) {
HEADER_DATE = hEADER_DATE;
}
public List<ITEM> getITEM() {
return ITEM;
}
public void setITEM(List<ITEM> iTEM) {
ITEM = iTEM;
}
}
public static class HEADER_PARTNER{
String PARTNER_Q;
String PARTNER_ID;
String NAME1;
String NAME2;
String POSTL_COD1;
String CITY1;
public String getNAME1() {
return NAME1;
}
public void setNAME1(String nAME1) {
NAME1 = nAME1;
}
public String getNAME2() {
return NAME2;
}
public void setNAME2(String nAME2) {
NAME2 = nAME2;
}
public String getPOSTL_COD1() {
return POSTL_COD1;
}
public void setPOSTL_COD1(String pOSTL_COD1) {
POSTL_COD1 = pOSTL_COD1;
}
public String getCITY1() {
return CITY1;
}
public void setCITY1(String cITY1) {
CITY1 = cITY1;
}
public String getPARTNER_Q() {
return PARTNER_Q;
}
public void setPARTNER_Q(String pARTNER_Q) {
PARTNER_Q = pARTNER_Q;
}
public String getPARTNER_ID() {
return PARTNER_ID;
}
public void setPARTNER_ID(String pARTNER_ID) {
PARTNER_ID = pARTNER_ID;
}
}
public static class HEADER_DATE{
String QUALF;
String NTEND;
public String getQUALF() {
return QUALF;
}
public void setQUALF(String qUALF) {
QUALF = qUALF;
}
public String getNTEND() {
return NTEND;
}
public void setNTEND(String nTEND) {
NTEND = nTEND;
}
}
public static class ITEM{
String POSNR;
String VTWEG;
String MATNR;
String DMATNR;
String LFIMG;
String VRKME;
List<ITEM_REFERENCE_SO> ITEM_REFERENCE_SO;
List<ITEM_REFERENCE_PO_TYPE> ITEM_REFERENCE_PO_TYPE;
public String getDMATNR() {
return DMATNR;
}
public void setDMATNR(String dMATNR) {
DMATNR = dMATNR;
}
public String getVTWEG() {
return VTWEG;
}
public void setVTWEG(String vTWEG) {
VTWEG = vTWEG;
}
public String getPOSNR() {
return POSNR;
}
public void setPOSNR(String pOSNR) {
POSNR = pOSNR;
}
public String getMATNR() {
return MATNR;
}
public void setMATNR(String mATNR) {
MATNR = mATNR;
}
public String getLFIMG() {
return LFIMG;
}
public void setLFIMG(String lFIMG) {
LFIMG = lFIMG;
}
public String getVRKME() {
return VRKME;
}
public void setVRKME(String vRKME) {
VRKME = vRKME;
}
public List<ITEM_REFERENCE_SO> getITEM_REFERENCE_SO() {
return ITEM_REFERENCE_SO;
}
public void setITEM_REFERENCE_SO(List<ITEM_REFERENCE_SO> iTEM_REFERENCE_SO) {
ITEM_REFERENCE_SO = iTEM_REFERENCE_SO;
}
public List<ITEM_REFERENCE_PO_TYPE> getITEM_REFERENCE_PO_TYPE() {
return ITEM_REFERENCE_PO_TYPE;
}
public void setITEM_REFERENCE_PO_TYPE(List<ITEM_REFERENCE_PO_TYPE> iTEM_REFERENCE_PO_TYPE) {
ITEM_REFERENCE_PO_TYPE = iTEM_REFERENCE_PO_TYPE;
}
}
public static class ITEM_REFERENCE_SO{
String QUALF;
String BELNR;
String POSNR;
public String getQUALF() {
return QUALF;
}
public void setQUALF(String qUALF) {
QUALF = qUALF;
}
public String getBELNR() {
return BELNR;
}
public void setBELNR(String bELNR) {
BELNR = bELNR;
}
public String getPOSNR() {
return POSNR;
}
public void setPOSNR(String pOSNR) {
POSNR = pOSNR;
}
}
public static class ITEM_REFERENCE_PO_TYPE{
String TDID;
List<ITEM_REFERENCE_PO_DATA> ITEM_REFERENCE_PO_DATA;
public String getTDID() {
return TDID;
}
public void setTDID(String tDID) {
TDID = tDID;
}
public List<ITEM_REFERENCE_PO_DATA> getITEM_REFERENCE_PO_DATA() {
return ITEM_REFERENCE_PO_DATA;
}
public void setITEM_REFERENCE_PO_DATA(List<ITEM_REFERENCE_PO_DATA> iTEM_REFERENCE_PO_DATA) {
ITEM_REFERENCE_PO_DATA = iTEM_REFERENCE_PO_DATA;
}
}
public static class ITEM_REFERENCE_PO_DATA{
String TDLINE;
public String getTDLINE() {
return TDLINE;
}
public void setTDLINE(String tDLINE) {
TDLINE = tDLINE;
}
}
}
......@@ -22,6 +22,7 @@ import org.springframework.context.annotation.Configuration;
import com.egolm.sso.service.MaterialMasterService;
import com.egolm.sso.service.PriceListService;
import com.egolm.sso.service.ProFormaInvoiceService;
import com.egolm.sso.service.ShippingNotificationService;
import com.egolm.sso.service.SoConfirmQuotationService;
......@@ -66,6 +67,14 @@ public class WsConfig {
return endpoint;
}
@Bean
public Endpoint getShippingNotificationPoint(ShippingNotificationService shippingNotificationService) {
EndpointImpl endpoint = new EndpointImpl(bus, shippingNotificationService);
endpoint.setInInterceptors(Arrays.asList(authInterceptor));
endpoint.publish("/shipping_notification");
return endpoint;
}
@Value("${wsUsername}")
private String wsUername;
......
package com.egolm.sso.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://price_list.sso.egolm.com")
public interface ShippingNotificationService {
@WebMethod
public void execute(String xml);
}
package com.egolm.sso.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DATE;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DELIVERY;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_PARTNER;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.ITEM;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.ITEM_REFERENCE_PO_DATA;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.ITEM_REFERENCE_PO_TYPE;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.ITEM_REFERENCE_SO;
import com.egolm.sso.bean.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE;
import com.egolm.sso.service.CommonService;
import com.egolm.sso.service.ShippingNotificationService;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
@Component
@WebService(serviceName = "ShippingNotificationService", targetNamespace = "http://price_list.sso.egolm.com", endpointInterface = "com.egolm.sso.service.ShippingNotificationService")
public class ShippingNotificationServiceImpl implements ShippingNotificationService {
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
@Override
public void execute(String xml) {
Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE = XMLUtil.toBeanByJxab(xml, Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.class);
System.out.println(JSON.toJSONString(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE));
Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime();
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();
HEADER_DELIVERY HEADER_DELIVERY = Z_DT_SD_007_SHIPPING_NOTIFICATION_FILE.getHEADER_DELIVERY();
header.put("DELIVERY_VBELN", HEADER_DELIVERY.getVBELN());
header.put("DELIVERY_LFART", HEADER_DELIVERY.getLFART());
header.put("DELIVERY_INCO1", HEADER_DELIVERY.getINCO1());
header.put("DELIVERY_BTGEW", StringUtil.toDouble(HEADER_DELIVERY.getBTGEW()));
header.put("DELIVERY_GEWEI", HEADER_DELIVERY.getGEWEI());
header.put("DELIVERY_CMGST", HEADER_DELIVERY.getCMGST());
header.put("DELIVERY_VKORG", HEADER_DELIVERY.getVKORG());
List<HEADER_PARTNER> HEADER_PARTNERs = HEADER_DELIVERY.getHEADER_PARTNER();
for(int i=0; i<HEADER_PARTNERs.size(); i++) {
HEADER_PARTNER HEADER_PARTNER = HEADER_PARTNERs.get(i);
String PARTNER_Q = HEADER_PARTNER.getPARTNER_Q();
String PARTNER_ID = HEADER_PARTNER.getPARTNER_ID();
String NAME1 = HEADER_PARTNER.getNAME1();
String NAME2 = HEADER_PARTNER.getNAME2();
String POSTL_COD1 = HEADER_PARTNER.getPOSTL_COD1();
String CITY1 = HEADER_PARTNER.getCITY1();
if(PARTNER_Q!=null) {
header.put("PARTNER_Q"+(i+1), PARTNER_Q);
}
if(PARTNER_ID!=null) {
header.put("PARTNER_ID"+(i+1), PARTNER_ID);
}
if(NAME1!=null) {
header.put("PARTNER_NAME1_"+(i+1), NAME1);
}
if(NAME2!=null) {
header.put("PARTNER_NAME2_"+(i+1), NAME2);
}
if(POSTL_COD1!=null) {
header.put("PARTNER_POSTLCOD1_"+(i+1), POSTL_COD1);
}
if(CITY1!=null) {
header.put("PARTNER_CITY1_"+(i+1), CITY1);
}
}
List<HEADER_DATE> HEADER_DATEs= HEADER_DELIVERY.getHEADER_DATE();
if(HEADER_DATEs!=null&&HEADER_DATEs.size()>0) {
HEADER_DATE HEADER_DATE = HEADER_DATEs.get(0);
header.put("QUALF", HEADER_DATE.getQUALF());
header.put("NTEND", HEADER_DATE.getNTEND());
}
header.put("BATCH", today+"-"+common.getNextval("T_SHIPPING_NOTIFICATION_HEADER_BATCH_"+today));
header.put("SEND_STATUS", "N");
header.put("TRACE_NO", "sapshippingnotification"+DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
header.put("CREATED", now);
header.put("CREATEDBY", "system");
Long hID = Long.valueOf(time+StringUtil.format(common.getNextval("T_SHIPPING_NOTIFICATION_HEADER_ID_"+today), "00000"));
header.put("ID", hID);
insertTo(header, "t_shipping_notification_header");
List<ITEM> ITEMs = HEADER_DELIVERY.getITEM();
for(ITEM ITEM : ITEMs) {
Map<String, Object> item = new HashMap<>();
Long iID = Long.valueOf(time+StringUtil.format(common.getNextval("T_SHIPPING_NOTIFICATION_ITEM_ID_"+today), "00000"));
item.put("ID", iID);
item.put("HEADER_ID", hID);
item.put("POSNR", ITEM.getPOSNR());
item.put("VTWEG", ITEM.getVTWEG());
item.put("MATNR", ITEM.getMATNR());
item.put("DMATNR", ITEM.getDMATNR());
item.put("LFIMG", ITEM.getLFIMG());
item.put("VRKME", ITEM.getVRKME());
List<ITEM_REFERENCE_SO> ITEM_REFERENCE_SOs = ITEM.getITEM_REFERENCE_SO();
if(ITEM_REFERENCE_SOs!=null&&ITEM_REFERENCE_SOs.size()>0) {
ITEM_REFERENCE_SO ITEM_REFERENCE_SO = ITEM_REFERENCE_SOs.get(0);
item.put("REFERENCE_SO_QUALF", ITEM_REFERENCE_SO.getQUALF());
item.put("REFERENCE_SO_BELNR", ITEM_REFERENCE_SO.getBELNR());
item.put("REFERENCE_SO_POSNR", ITEM_REFERENCE_SO.getPOSNR());
}
List<ITEM_REFERENCE_PO_TYPE> ITEM_REFERENCE_PO_TYPEs = ITEM.getITEM_REFERENCE_PO_TYPE();
for(int i=0; i<ITEM_REFERENCE_PO_TYPEs.size(); i++) {
ITEM_REFERENCE_PO_TYPE ITEM_REFERENCE_PO_TYPE = ITEM_REFERENCE_PO_TYPEs.get(i);
item.put("REFERENCE_PO_TYPE_TDID"+(i+1), ITEM_REFERENCE_PO_TYPE.getTDID());
List<ITEM_REFERENCE_PO_DATA> ITEM_REFERENCE_PO_DATAs = ITEM_REFERENCE_PO_TYPE.getITEM_REFERENCE_PO_DATA();
if(ITEM_REFERENCE_PO_DATAs!=null&&ITEM_REFERENCE_PO_DATAs.size()>0) {
ITEM_REFERENCE_PO_DATA ITEM_REFERENCE_PO_DATA = ITEM_REFERENCE_PO_DATAs.get(0);
item.put("REFERENCE_PO_TYPE_TDLINE"+(i+1), ITEM_REFERENCE_PO_DATA.getTDLINE());
}
}
item.put("CREATED", now);
item.put("CREATEDBY", "system");
insertTo(item, "t_shipping_notification_item");
}
}
private void insertTo(Map<String, Object> obj, String table) {
String insertSql = "insert into "+table+" ";
String fieldSql = "(";
String valuesSql = "(";
List<Object> values = new ArrayList<>();
for(Entry<String, Object> entry : obj.entrySet()) {
Object value = entry.getValue();
if(value!=null) {
fieldSql = fieldSql + entry.getKey() + ", ";
valuesSql = valuesSql + "?, ";
values.add(entry.getValue());
}
}
fieldSql = fieldSql.substring(0, fieldSql.length()-2);
valuesSql = valuesSql.substring(0, valuesSql.length()-2);
insertSql = insertSql + fieldSql + ") values " + valuesSql + ")";
jdbcTemplate.update(insertSql, values.toArray());
}
}
package test;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback;
import com.alibaba.fastjson.JSON;
import com.egolm.sso.util.FileUtil;
public class ShippingNotificationTest {
private static final String username = "test";
private static final String password = "78258c537d6e4d5fb210a57d05619fb6";
public static void main(String[] args) throws Exception {
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/shipping_notification?wsdl");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.put(WSHandlerConstants.USER, username);
properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
pc.setPassword(password);
}
}
});
WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor();
interceptor.setProperties(properties);
client.setOutInterceptors(Arrays.asList(interceptor));
System.out.println(JSON.toJSONString(client.invoke("execute", FileUtil.readText("D:/data/sso/007.XML"))));
}
}
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