Commit 9ac3634d authored by Quxl's avatar Quxl

x

parent 9fdb8d74
...@@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.egolm.sso.services.material_master.TestMaterialMaster; import com.egolm.sso.services.material_master.MaterialMasterService;
import com.egolm.sso.services.price_list.PriceListService; import com.egolm.sso.services.price_list.PriceListService;
...@@ -30,13 +30,10 @@ public class WsConfig { ...@@ -30,13 +30,10 @@ public class WsConfig {
@Autowired @Autowired
WSS4JInInterceptor authInterceptor; WSS4JInInterceptor authInterceptor;
@Autowired
TestMaterialMaster testMaterialMaster;
@Bean @Bean
public Endpoint getMaterialMasterPoint() { public Endpoint getMaterialMasterPoint(MaterialMasterService materialMasterService) {
EndpointImpl endpoint = new EndpointImpl(bus, testMaterialMaster); EndpointImpl endpoint = new EndpointImpl(bus, materialMasterService);
endpoint.publish("/material_master"); endpoint.publish("/material_master");
return endpoint; return endpoint;
} }
......
package com.egolm.sso.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://service.sso.egolm.com")
public interface MaterialMasterService {
@WebMethod
public void execute(String xml);
}
package com.egolm.sso.service.impl;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
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.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
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.service.CommonService;
import com.egolm.sso.service.MaterialMasterService;
@Component
@WebService(serviceName = "MaterialMasterService", targetNamespace = "http://service.sso.egolm.com", endpointInterface = "com.egolm.sso.service.MaterialMasterService")
public class MaterialMasterServiceImpl implements MaterialMasterService {
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
private static DateFormat datef = new SimpleDateFormat("yyyyMMdd");
private static DateFormat datetimef = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static DateFormat timef = new SimpleDateFormat("HHmmss");
@Override
public void execute(String xml) {
System.out.println(common.getNextval("Test"));
System.out.println(xml);
Element record = getRecordElement(xml);
Map<String, String> header = new HashMap<>();
Element headerSending = record.element("HEADER_SENDING");
String DIS_CODE = headerSending.elementText("KUNNR");
String DATUM = headerSending.elementText("DATUM");
String UZEIT = headerSending.elementText("UZEIT");
List<Map<String, String>> items = new ArrayList<>();
List<Element> itemList = record.elements("ITEM");
try {
for (Element element : itemList) {
String GOODS_CODE = element.elementText("MATNR");
Map<String, Object> goods = getGoods(DIS_CODE, GOODS_CODE);
if(goods == null) {
goods = new HashMap<>();
}
/***************header**************/
goods.put("DIS_CODE", DIS_CODE);
goods.put("DATUM", datef.parse(DATUM));
goods.put("UZEIT", timef.parse(UZEIT));
/***************header**************/
/***************item**************/
goods.put("GOODS_CODE", GOODS_CODE);
goods.put("ROUGH_WEIGHT", element.elementText("BRGEW"));
goods.put("NET_WEIGHT", element.elementText("NTGEW"));
goods.put("WETGHT_UNIT", element.elementText("GEWEI"));
goods.put("CATEGORY_CODE", element.elementText("PLINE"));
goods.put("CREATION_DATE", datef.parse(element.elementText("ERSDA")));
goods.put("LAST_CHANGE_DATE", datef.parse(element.elementText("LAEDA")));
goods.put("GOODS_NAME", element.elementText("NORMT"));
goods.put("VMSTA", element.elementText("VMSTA"));
goods.put("MSTAV", element.elementText("MSTAV"));
goods.put("STKTYP", element.elementText("STKTYP"));
goods.put("PRODUCTION_LINE_CODE", element.elementText("LIFNR"));
goods.put("SPEC", element.elementText("UMREZ"));
/*******************新增字段,样例中没有******************/
goods.put("GOODS_NAME_EN", element.elementText("NORMT_EN"));
goods.put("AUMNG", element.elementText("AUMNG"));
goods.put("VRKME", element.elementText("VRKME"));
goods.put("BASE_UNIT", element.elementText("MEINS"));
goods.put("STATISTICS_UNIT", element.elementText("SCHME"));//(统计单位--》发货单位)
goods.put("LAENG", element.elementText("LAENG"));
goods.put("BREIT", element.elementText("BREIT"));
goods.put("HOEHE", element.elementText("HOEHE"));
goods.put("MEABM", element.elementText("MEABM"));
goods.put("LAENG_B", element.elementText("LAENG_B"));
goods.put("BREIT_B", element.elementText("BREIT_B"));
goods.put("HOEHE_B", element.elementText("HOEHE_B"));
goods.put("MEABM_B", element.elementText("MEABM_B"));
goods.put("PUBLIC", element.elementText("PUBLIC"));
goods.put("INTERNET", element.elementText("INTERNET"));
/*******************新增字段,样例中没有******************/
/***************item**************/
String BATCH = (String) goods.get("BATCH");
if(BATCH==null||"".equals(BATCH.trim())) {
BATCH = datef.format(new Date())+"-1";
}else {
String[] ss = BATCH.split("-");
String newDate = datef.format(new Date());
int v = 1;
if(ss[0].equals(newDate)) {
v = Integer.valueOf(ss[1])+1;
}
BATCH = newDate+"-"+v;
}
goods.put("BATCH", BATCH);
goods.put("SEND_STATUS", "N");
goods.put("UPDATED", datetimef.format(new Date()));
if(goods.get("ID")!=null) {
updateGoods(goods);
}else {
insertGoods(goods);
}
}
}catch(Exception e) {
e.printStackTrace();
}
}
private void updateGoods(Map<String, Object> goods) {
goods.put("UPDATEDBY", "");
String sql = "update t_ven_goods set ";
List<Object> args = new ArrayList<>();
for (Entry<String, Object> entry : goods.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if(!key.equals("ID")) {
sql = sql + key + " = ?, ";
args.add(value);
}
}
sql = sql.substring(0, sql.length()-2);
sql = sql + " where ID = ?";
args.add(goods.get("ID"));
jdbcTemplate.update(sql, args);
}
private void insertGoods(Map<String, Object> goods) {
String countSql = "select count(1) from t_ven_goods";
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
String ID = System.currentTimeMillis() + prependZero(count, 5);
goods.put("ID", ID);
goods.put("CREATED", datetimef.format(new Date()));
goods.put("CREATEDBY", "");
String insertSql = "insert into t_ven_goods ";
String fieldSql = "(";
String valuesSql = "(";
List<Object> values = new ArrayList<>();
for(Entry<String, Object> entry : goods.entrySet()) {
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);
}
private String prependZero(int Num, int length) {
return prependZero(Num+"", length);
}
private String prependZero(String Num, int length) {
String prepend = "";
for(int i=Num.length(); i<=length; i++) {
prepend = prepend + "0";
}
return prepend + Num;
}
private Map<String, Object> getGoods(String DIS_CODE, String GOODS_CODE){
String sql = "select * from t_ven_goods where DIS_CODE = ? and GOODS_CODE = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, DIS_CODE, GOODS_CODE);
if(list!=null&&list.size()>0) {
return list.get(0);
}
return null;
}
public static Element getRecordElement(String xml) {
Document doc = null;
Element el = null;
try {
doc = DocumentHelper.parseText(xml);
Element root = doc.getRootElement();
el = root.element("RECORD");
} catch (DocumentException e) {
e.printStackTrace();
}
return el;
}
}
...@@ -4,7 +4,7 @@ import javax.jws.WebMethod; ...@@ -4,7 +4,7 @@ import javax.jws.WebMethod;
import javax.jws.WebService; import javax.jws.WebService;
@WebService(targetNamespace = "http://material_master.sso.egolm.com") @WebService(targetNamespace = "http://material_master.sso.egolm.com")
public interface TestMaterialMaster { public interface MaterialMasterService {
@WebMethod @WebMethod
public void execute(Z_MI_SD_001_MATERIAL_MASTER Z_MI_SD_001_MATERIAL_MASTER); public void execute(Z_MI_SD_001_MATERIAL_MASTER Z_MI_SD_001_MATERIAL_MASTER);
......
...@@ -7,8 +7,8 @@ import org.springframework.stereotype.Component; ...@@ -7,8 +7,8 @@ import org.springframework.stereotype.Component;
import com.google.gson.Gson; import com.google.gson.Gson;
@Component @Component
@WebService(serviceName = "TestMaterialMaster", targetNamespace = "http://material_master.sso.egolm.com", endpointInterface = "com.egolm.sso.services.material_master.TestMaterialMaster") @WebService(serviceName = "MaterialMasterService", targetNamespace = "http://material_master.sso.egolm.com", endpointInterface = "com.egolm.sso.services.material_master.MaterialMasterService")
public class TestMaterialMasterImpl implements TestMaterialMaster { public class MaterialMasterServiceImpl implements MaterialMasterService {
@Override @Override
public void execute(Z_MI_SD_001_MATERIAL_MASTER Z_MI_SD_001_MATERIAL_MASTER) { public void execute(Z_MI_SD_001_MATERIAL_MASTER Z_MI_SD_001_MATERIAL_MASTER) {
......
...@@ -9,13 +9,13 @@ import javax.xml.ws.ResponseWrapper; ...@@ -9,13 +9,13 @@ import javax.xml.ws.ResponseWrapper;
/** /**
* This class was generated by Apache CXF 3.2.9 * This class was generated by Apache CXF 3.2.9
* 2019-07-05T15:19:41.150+08:00 * 2019-07-05T17:48:29.267+08:00
* Generated source version: 3.2.9 * Generated source version: 3.2.9
* *
*/ */
@WebService(targetNamespace = "http://material_master.sso.egolm.com", name = "TestMaterialMaster") @WebService(targetNamespace = "http://material_master.sso.egolm.com", name = "MaterialMasterService")
@XmlSeeAlso({ObjectFactory.class}) @XmlSeeAlso({ObjectFactory.class})
public interface TestMaterialMaster { public interface MaterialMasterService {
@WebMethod @WebMethod
@RequestWrapper(localName = "execute", targetNamespace = "http://material_master.sso.egolm.com", className = "com.egolm.sso.material_master.Execute") @RequestWrapper(localName = "execute", targetNamespace = "http://material_master.sso.egolm.com", className = "com.egolm.sso.material_master.Execute")
......
...@@ -10,52 +10,52 @@ import javax.xml.ws.Service; ...@@ -10,52 +10,52 @@ import javax.xml.ws.Service;
/** /**
* This class was generated by Apache CXF 3.2.9 * This class was generated by Apache CXF 3.2.9
* 2019-07-05T15:19:41.182+08:00 * 2019-07-05T17:48:29.300+08:00
* Generated source version: 3.2.9 * Generated source version: 3.2.9
* *
*/ */
@WebServiceClient(name = "TestMaterialMaster", @WebServiceClient(name = "MaterialMasterService",
wsdlLocation = "http://localhost:8080/sso/services/material_master?wsdl", wsdlLocation = "http://localhost:8080/sso/services/material_master?wsdl",
targetNamespace = "http://material_master.sso.egolm.com") targetNamespace = "http://material_master.sso.egolm.com")
public class TestMaterialMaster_Service extends Service { public class MaterialMasterService_Service extends Service {
public final static URL WSDL_LOCATION; public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://material_master.sso.egolm.com", "TestMaterialMaster"); public final static QName SERVICE = new QName("http://material_master.sso.egolm.com", "MaterialMasterService");
public final static QName TestMaterialMasterImplPort = new QName("http://material_master.sso.egolm.com", "TestMaterialMasterImplPort"); public final static QName MaterialMasterServiceImplPort = new QName("http://material_master.sso.egolm.com", "MaterialMasterServiceImplPort");
static { static {
URL url = null; URL url = null;
try { try {
url = new URL("http://localhost:8080/sso/services/material_master?wsdl"); url = new URL("http://localhost:8080/sso/services/material_master?wsdl");
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(TestMaterialMaster_Service.class.getName()) java.util.logging.Logger.getLogger(MaterialMasterService_Service.class.getName())
.log(java.util.logging.Level.INFO, .log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "http://localhost:8080/sso/services/material_master?wsdl"); "Can not initialize the default wsdl from {0}", "http://localhost:8080/sso/services/material_master?wsdl");
} }
WSDL_LOCATION = url; WSDL_LOCATION = url;
} }
public TestMaterialMaster_Service(URL wsdlLocation) { public MaterialMasterService_Service(URL wsdlLocation) {
super(wsdlLocation, SERVICE); super(wsdlLocation, SERVICE);
} }
public TestMaterialMaster_Service(URL wsdlLocation, QName serviceName) { public MaterialMasterService_Service(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName); super(wsdlLocation, serviceName);
} }
public TestMaterialMaster_Service() { public MaterialMasterService_Service() {
super(WSDL_LOCATION, SERVICE); super(WSDL_LOCATION, SERVICE);
} }
public TestMaterialMaster_Service(WebServiceFeature ... features) { public MaterialMasterService_Service(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features); super(WSDL_LOCATION, SERVICE, features);
} }
public TestMaterialMaster_Service(URL wsdlLocation, WebServiceFeature ... features) { public MaterialMasterService_Service(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features); super(wsdlLocation, SERVICE, features);
} }
public TestMaterialMaster_Service(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { public MaterialMasterService_Service(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features); super(wsdlLocation, serviceName, features);
} }
...@@ -65,11 +65,11 @@ public class TestMaterialMaster_Service extends Service { ...@@ -65,11 +65,11 @@ public class TestMaterialMaster_Service extends Service {
/** /**
* *
* @return * @return
* returns TestMaterialMaster * returns MaterialMasterService
*/ */
@WebEndpoint(name = "TestMaterialMasterImplPort") @WebEndpoint(name = "MaterialMasterServiceImplPort")
public TestMaterialMaster getTestMaterialMasterImplPort() { public MaterialMasterService getMaterialMasterServiceImplPort() {
return super.getPort(TestMaterialMasterImplPort, TestMaterialMaster.class); return super.getPort(MaterialMasterServiceImplPort, MaterialMasterService.class);
} }
/** /**
...@@ -77,11 +77,11 @@ public class TestMaterialMaster_Service extends Service { ...@@ -77,11 +77,11 @@ public class TestMaterialMaster_Service extends Service {
* @param features * @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. * 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 * @return
* returns TestMaterialMaster * returns MaterialMasterService
*/ */
@WebEndpoint(name = "TestMaterialMasterImplPort") @WebEndpoint(name = "MaterialMasterServiceImplPort")
public TestMaterialMaster getTestMaterialMasterImplPort(WebServiceFeature... features) { public MaterialMasterService getMaterialMasterServiceImplPort(WebServiceFeature... features) {
return super.getPort(TestMaterialMasterImplPort, TestMaterialMaster.class, features); return super.getPort(MaterialMasterServiceImplPort, MaterialMasterService.class, features);
} }
} }
...@@ -2,16 +2,16 @@ package test; ...@@ -2,16 +2,16 @@ package test;
import java.util.List; import java.util.List;
import com.egolm.sso.material_master.TestMaterialMaster; import com.egolm.sso.material_master.MaterialMasterService;
import com.egolm.sso.material_master.TestMaterialMaster_Service; import com.egolm.sso.material_master.MaterialMasterService_Service;
import com.egolm.sso.material_master.ZMISD001MATERIALMASTER; import com.egolm.sso.material_master.ZMISD001MATERIALMASTER;
public class MaterialMasterServiceTest { public class MaterialMasterServiceTest {
public static void main(String[] args) { public static void main(String[] args) {
TestMaterialMaster_Service service = new TestMaterialMaster_Service(); MaterialMasterService_Service service = new MaterialMasterService_Service();
TestMaterialMaster testMaterialMaster = service.getTestMaterialMasterImplPort(); MaterialMasterService materialMasterService = service.getMaterialMasterServiceImplPort();
testMaterialMaster.execute(getZMISD001MATERIALMASTER()); materialMasterService.execute(getZMISD001MATERIALMASTER());
} }
private static ZMISD001MATERIALMASTER getZMISD001MATERIALMASTER() { private static ZMISD001MATERIALMASTER getZMISD001MATERIALMASTER() {
......
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