Commit 0c3f8bbd authored by 曲欣红's avatar 曲欣红

1

parent 02af6f48
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_001_MATERIAL_MASTER")
public class Z_MT_SD_001_MATERIAL_MASTER {
RECORD RECORD;
public RECORD getRECORD() {
return RECORD;
}
public void setRECORD(RECORD rECORD) {
RECORD = rECORD;
}
public static class RECORD{
HEADER_SENDING HEADER_SENDING;
List<ITEM> ITEM;
public HEADER_SENDING getHEADER_SENDING() {
return HEADER_SENDING;
}
public void setHEADER_SENDING(HEADER_SENDING hEADER_SENDING) {
HEADER_SENDING = hEADER_SENDING;
}
public List<ITEM> getITEM() {
return ITEM;
}
public void setITEM(List<ITEM> iTEM) {
ITEM = iTEM;
}
}
public static class HEADER_SENDING{
String KUNNR;
String DATUM;
String UZEIT;
public String getKUNNR() {
return KUNNR;
}
public void setKUNNR(String kUNNR) {
KUNNR = kUNNR;
}
public String getDATUM() {
return DATUM;
}
public void setDATUM(String dATUM) {
DATUM = dATUM;
}
public String getUZEIT() {
return UZEIT;
}
public void setUZEIT(String uZEIT) {
UZEIT = uZEIT;
}
}
public static class ITEM{
String MATNR;
String BRGEW;
String NTGEW;
String GEWEI;
String PLINE;
String ERSDA;
String LAEDA;
String NORMT;
String NORMT_EN;
String LIFNR;
String VMSTA;
String MSTAV;
String STKTYP;
String UMREZ;
String AUMNG;
String VRKME;
String MEINS;
String SCHME;
String LAENG;
String BREIT;
String HOEHE;
String MEABM;
String LAENG_B;
String BREIT_B;
String HOEHE_B;
String MEABM_B;
String PUBLIC;
String INTERNET;
public String getMATNR() {
return MATNR;
}
public void setMATNR(String mATNR) {
MATNR = mATNR;
}
public String getBRGEW() {
return BRGEW;
}
public void setBRGEW(String bRGEW) {
BRGEW = bRGEW;
}
public String getNTGEW() {
return NTGEW;
}
public void setNTGEW(String nTGEW) {
NTGEW = nTGEW;
}
public String getGEWEI() {
return GEWEI;
}
public void setGEWEI(String gEWEI) {
GEWEI = gEWEI;
}
public String getPLINE() {
return PLINE;
}
public void setPLINE(String pLINE) {
PLINE = pLINE;
}
public String getERSDA() {
return ERSDA;
}
public void setERSDA(String eRSDA) {
ERSDA = eRSDA;
}
public String getLAEDA() {
return LAEDA;
}
public void setLAEDA(String lAEDA) {
LAEDA = lAEDA;
}
public String getNORMT() {
return NORMT;
}
public void setNORMT(String nORMT) {
NORMT = nORMT;
}
public String getNORMT_EN() {
return NORMT_EN;
}
public void setNORMT_EN(String nORMT_EN) {
NORMT_EN = nORMT_EN;
}
public String getLIFNR() {
return LIFNR;
}
public void setLIFNR(String lIFNR) {
LIFNR = lIFNR;
}
public String getVMSTA() {
return VMSTA;
}
public void setVMSTA(String vMSTA) {
VMSTA = vMSTA;
}
public String getMSTAV() {
return MSTAV;
}
public void setMSTAV(String mSTAV) {
MSTAV = mSTAV;
}
public String getSTKTYP() {
return STKTYP;
}
public void setSTKTYP(String sTKTYP) {
STKTYP = sTKTYP;
}
public String getUMREZ() {
return UMREZ;
}
public void setUMREZ(String uMREZ) {
UMREZ = uMREZ;
}
public String getAUMNG() {
return AUMNG;
}
public void setAUMNG(String aUMNG) {
AUMNG = aUMNG;
}
public String getVRKME() {
return VRKME;
}
public void setVRKME(String vRKME) {
VRKME = vRKME;
}
public String getMEINS() {
return MEINS;
}
public void setMEINS(String mEINS) {
MEINS = mEINS;
}
public String getSCHME() {
return SCHME;
}
public void setSCHME(String sCHME) {
SCHME = sCHME;
}
public String getLAENG() {
return LAENG;
}
public void setLAENG(String lAENG) {
LAENG = lAENG;
}
public String getBREIT() {
return BREIT;
}
public void setBREIT(String bREIT) {
BREIT = bREIT;
}
public String getHOEHE() {
return HOEHE;
}
public void setHOEHE(String hOEHE) {
HOEHE = hOEHE;
}
public String getMEABM() {
return MEABM;
}
public void setMEABM(String mEABM) {
MEABM = mEABM;
}
public String getLAENG_B() {
return LAENG_B;
}
public void setLAENG_B(String lAENG_B) {
LAENG_B = lAENG_B;
}
public String getBREIT_B() {
return BREIT_B;
}
public void setBREIT_B(String bREIT_B) {
BREIT_B = bREIT_B;
}
public String getHOEHE_B() {
return HOEHE_B;
}
public void setHOEHE_B(String hOEHE_B) {
HOEHE_B = hOEHE_B;
}
public String getMEABM_B() {
return MEABM_B;
}
public void setMEABM_B(String mEABM_B) {
MEABM_B = mEABM_B;
}
public String getPUBLIC() {
return PUBLIC;
}
public void setPUBLIC(String pUBLIC) {
PUBLIC = pUBLIC;
}
public String getINTERNET() {
return INTERNET;
}
public void setINTERNET(String iNTERNET) {
INTERNET = iNTERNET;
}
}
}
......@@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.jws.WebService;
......@@ -14,10 +15,16 @@ 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_001_MATERIAL_MASTER;
import com.egolm.sso.bean.Z_MT_SD_001_MATERIAL_MASTER.HEADER_SENDING;
import com.egolm.sso.bean.Z_MT_SD_001_MATERIAL_MASTER.ITEM;
import com.egolm.sso.bean.Z_MT_SD_001_MATERIAL_MASTER.RECORD;
import com.egolm.sso.service.CommonService;
import com.egolm.sso.service.MaterialMasterService;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
@Component
@WebService(serviceName = "MaterialMasterService", targetNamespace = "http://material_master.sso.egolm.com", endpointInterface = "com.egolm.sso.service.MaterialMasterService")
......@@ -35,7 +42,87 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Long time = now.getTime();
String regex = "xmlns:[a-zA-Z\\d]+=\"[a-zA-Z]+:\\S+\"";
xml = xml.replaceAll("<[a-zA-Z\\d]+:", "<");
xml = xml.replaceAll("</[a-zA-Z\\d]+:", "</");
xml = xml.replaceAll(regex, "");
Z_MT_SD_001_MATERIAL_MASTER Z_MT_SD_001_MATERIAL_MASTER = XMLUtil.toBeanByJxab(xml, Z_MT_SD_001_MATERIAL_MASTER.class);
System.out.println(JSON.toJSONString(Z_MT_SD_001_MATERIAL_MASTER));
RECORD RECORD = Z_MT_SD_001_MATERIAL_MASTER.getRECORD();
HEADER_SENDING h = RECORD.getHEADER_SENDING();
String DIS_CODE = h.getKUNNR();
String DATUM = h.getDATUM();
String UZEIT = h.getUZEIT();
List<ITEM> items = RECORD.getITEM();
for(ITEM item : items) {
String GOODS_CODE = item.getMATNR();
Map<String, Object> goods = getGoods(DIS_CODE, GOODS_CODE);
if (goods == null) {
goods = new HashMap<>();
}
goods.put("DIS_CODE", DIS_CODE);
goods.put("DATUM", DateUtil.parseDate(DATUM, DateUtil.FMT_DATE));
goods.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME));
goods.put("GOODS_CODE", GOODS_CODE);
goods.put("ROUGH_WEIGHT", Double.valueOf(item.getBRGEW()));
goods.put("NET_WEIGHT", Double.valueOf(item.getNTGEW()));
goods.put("WETGHT_UNIT", item.getGEWEI());
goods.put("CATEGORY_CODE", item.getPLINE());
goods.put("CREATION_DATE", DateUtil.parseDate(item.getERSDA(), DateUtil.FMT_DATE));
goods.put("LAST_CHANGE_DATE", DateUtil.parseDate(item.getLAEDA(), DateUtil.FMT_DATE));
goods.put("GOODS_NAME", item.getNORMT());
goods.put("VMSTA", item.getVMSTA());
goods.put("STKTYP", item.getSTKTYP());
goods.put("SPEC", item.getUMREZ());
goods.put("GOODS_NAME_EN", item.getNORMT_EN());
goods.put("AUMNG", item.getAUMNG());
goods.put("VRKME", item.getVRKME());
goods.put("BASE_UNIT", item.getMEINS());
goods.put("STATISTICS_UNIT", item.getSCHME());// (统计单位--》发货单位)
goods.put("LAENG", item.getLAENG());
goods.put("BREIT", item.getBREIT());
goods.put("HOEHE", item.getHOEHE());
goods.put("MEABM", item.getMEABM());
goods.put("LAENG_B", item.getLAENG_B());
goods.put("BREIT_B", item.getBREIT_B());
goods.put("HOEHE_B", item.getHOEHE_B());
goods.put("MEABM_B", item.getMEABM_B());
goods.put("PUBLIC", item.getPUBLIC());
goods.put("INTERNET", item.getINTERNET());
/*
goods.put("CATEGORY_NAME", "");// 品类名称
goods.put("PRODUCTION_LINE_CODE", "");// 产线(产地)编码
goods.put("PRODUCTION_LINE_NAME", "");// 产线(产地)名称
goods.put("MSTAV", "");// 停产标志2
goods.put("BARCODE", "");// 物料条码
goods.put("TAX_RATE", 0);// 税率
goods.put("GOODS_KEY", "");// 物料唯一码
goods.put("SEND_TIME", now);// 发送时间
goods.put("DIS_UPDATE_STATUS", "N");// 分销商更新结果(Y成功,N失败)
*/
Long BATCHID = common.getNextval(today + "_t_ven_goods_BATCH_" + DIS_CODE + "_" + GOODS_CODE);
String BATCH = today+"-"+BATCHID;
goods.put("TRACE_NO", "sapmaterialmaster" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
goods.put("BATCH", BATCH);
goods.put("SEND_STATUS", "N");
goods.put("UPDATED", DateUtil.formatDate(now, DateUtil.FMT_DATE_TIME));
if (goods.get("ID") != null) {
updateGoods(goods);
} else {
insertGoods(goods);
}
}
/*
Element record = StringUtil.getDataElement(xml, "RECORD");
Element headerSending = record.element("HEADER_SENDING");
......@@ -46,6 +133,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
List<Element> itemList = record.elements("ITEM");
try {
for (Element element : itemList) {
String GOODS_CODE = element.elementText("MATNR");
......@@ -55,13 +143,10 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods = new HashMap<>();
}
/*************** header **************/
goods.put("DIS_CODE", DIS_CODE);
goods.put("DATUM", DateUtil.parseDate(DATUM, DateUtil.FMT_DATE));
goods.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME)/* timef.parse(UZEIT) */);
/*************** header **************/
goods.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME));
/*************** item **************/
goods.put("GOODS_CODE", GOODS_CODE);
goods.put("ROUGH_WEIGHT", Double.valueOf(element.elementText("BRGEW")));
goods.put("NET_WEIGHT", Double.valueOf(element.elementText("NTGEW")));
......@@ -74,7 +159,6 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("STKTYP", element.elementText("STKTYP"));
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"));
......@@ -90,9 +174,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("MEABM_B", element.elementText("MEABM_B"));
goods.put("PUBLIC", element.elementText("PUBLIC"));
goods.put("INTERNET", element.elementText("INTERNET"));
/******************* 新增字段,样例中没有 ******************/
/********************* 缺 *********************/
goods.put("CATEGORY_NAME", "");// 品类名称
goods.put("PRODUCTION_LINE_CODE", "");// 产线(产地)编码
goods.put("PRODUCTION_LINE_NAME", "");// 产线(产地)名称
......@@ -102,12 +184,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("GOODS_KEY", "");// 物料唯一码
goods.put("SEND_TIME", now);// 发送时间
goods.put("DIS_UPDATE_STATUS", "N");// 分销商更新结果(Y成功,N失败)
/********************* 缺 *********************/
/*************** item **************/
/**
* 数据库没有数据追踪号对应字段TRACE_NO
*/
Long BATCHID = common.getNextval(today + "_t_ven_goods_BATCH_" + DIS_CODE + "" + GOODS_CODE);
String BATCH = today+"-"+BATCHID;
......@@ -115,7 +192,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
goods.put("BATCH", BATCH);
goods.put("SEND_STATUS", "N");
goods.put("UPDATED",
DateUtil.formatDate(now, DateUtil.FMT_DATE_TIME)/* datetimef.format(new Date()) */);
DateUtil.formatDate(now, DateUtil.FMT_DATE_TIME));
if (goods.get("ID") != null) {
updateGoods(goods);
......@@ -126,6 +203,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
} catch (Exception e) {
e.printStackTrace();
}
*/
}
private void updateGoods(Map<String, Object> goods) {
......
......@@ -26,16 +26,20 @@ public class DateUtil {
return fmt.format(d);
}
public static Date parseDate(String d, String fmt) throws ParseException {
public static Date parseDate(String d, String fmt) {
DateFormat df = getFmt(fmt);
return parseDate(d, df);
}
public static Date parseDate(String d, DateFormat fmt) throws ParseException {
return fmt.parse(d);
public static Date parseDate(String d, DateFormat fmt) {
try {
return fmt.parse(d);
} catch (ParseException e) {
throw new RuntimeException(d + " parse to" + fmt, e);
}
}
public static Date parseDateNoEmpty(String d, String fmt) throws ParseException {
public static Date parseDateNoEmpty(String d, String fmt) {
Date res;
if(d!=null&&!d.equals("")) {
res = parseDate(d, fmt);
......@@ -45,7 +49,7 @@ public class DateUtil {
return res;
}
public static Date parseDateNoEmpty(String d, DateFormat fmt) throws ParseException {
public static Date parseDateNoEmpty(String d, DateFormat fmt) {
Date res;
if(d!=null&&!d.equals("")) {
res = parseDate(d, fmt);
......
......@@ -43,7 +43,7 @@ public class MaterialMasterServiceTest {
WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor();
interceptor.setProperties(pro);
client.setOutInterceptors(Arrays.asList(interceptor));
client.invoke("execute", "XML");
client.invoke("execute", readText("D:/data/sso/001.XML"));
}
private static String readText(String path) throws IOException {
......
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