Commit ea3cac80 authored by 曲欣红's avatar 曲欣红

1

parent 0c3f8bbd
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_002_PRICE_LIST")
public class Z_MT_SD_002_PRICE_LIST {
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 KBETR;
String KONWA;
String KPEIN;
String KMEIN;
String UMREZ;
String MAKTX;
String PRSCH;
String DATAM;
String DATBI;
String PLINE;
String PRSCH_1;
public String getMATNR() {
return MATNR;
}
public void setMATNR(String mATNR) {
MATNR = mATNR;
}
public String getKBETR() {
return KBETR;
}
public void setKBETR(String kBETR) {
KBETR = kBETR;
}
public String getKONWA() {
return KONWA;
}
public void setKONWA(String kONWA) {
KONWA = kONWA;
}
public String getKPEIN() {
return KPEIN;
}
public void setKPEIN(String kPEIN) {
KPEIN = kPEIN;
}
public String getKMEIN() {
return KMEIN;
}
public void setKMEIN(String kMEIN) {
KMEIN = kMEIN;
}
public String getUMREZ() {
return UMREZ;
}
public void setUMREZ(String uMREZ) {
UMREZ = uMREZ;
}
public String getMAKTX() {
return MAKTX;
}
public void setMAKTX(String mAKTX) {
MAKTX = mAKTX;
}
public String getPRSCH() {
return PRSCH;
}
public void setPRSCH(String pRSCH) {
PRSCH = pRSCH;
}
public String getDATAM() {
return DATAM;
}
public void setDATAM(String dATAM) {
DATAM = dATAM;
}
public String getDATBI() {
return DATBI;
}
public void setDATBI(String dATBI) {
DATBI = dATBI;
}
public String getPLINE() {
return PLINE;
}
public void setPLINE(String pLINE) {
PLINE = pLINE;
}
public String getPRSCH_1() {
return PRSCH_1;
}
public void setPRSCH_1(String pRSCH_1) {
PRSCH_1 = pRSCH_1;
}
}
}
......@@ -14,10 +14,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_002_PRICE_LIST;
import com.egolm.sso.bean.Z_MT_SD_002_PRICE_LIST.HEADER_SENDING;
import com.egolm.sso.bean.Z_MT_SD_002_PRICE_LIST.ITEM;
import com.egolm.sso.bean.Z_MT_SD_002_PRICE_LIST.RECORD;
import com.egolm.sso.service.CommonService;
import com.egolm.sso.service.PriceListService;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
@Component
@WebService(serviceName = "PriceListService", targetNamespace = "http://price_list.sso.egolm.com", endpointInterface = "com.egolm.sso.service.PriceListService")
......@@ -35,7 +41,62 @@ public class PriceListServiceImpl implements PriceListService {
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_002_PRICE_LIST Z_MT_SD_002_PRICE_LIST = XMLUtil.toBeanByJxab(xml, Z_MT_SD_002_PRICE_LIST.class);
System.out.println(JSON.toJSONString(Z_MT_SD_002_PRICE_LIST));
RECORD r = Z_MT_SD_002_PRICE_LIST.getRECORD();
HEADER_SENDING h = r.getHEADER_SENDING();
List<ITEM> items = r.getITEM();
String KUNNR = h.getKUNNR();
String DATUM = h.getDATUM();
String UZEIT = h.getUZEIT();
for(ITEM item : items) {
String MATNR = item.getMATNR();
Map<String, Object> priceObj = getPriceObj(KUNNR, MATNR);
if (priceObj == null) {
priceObj = new HashMap<>();
}
priceObj.put("KUNNR", KUNNR);
priceObj.put("DATUM", DATUM);
priceObj.put("UZEIT", UZEIT);
priceObj.put("MATNR", MATNR);
priceObj.put("KBETR", StringUtil.toDouble(item.getKBETR()));
priceObj.put("KONWA", item.getKONWA());
priceObj.put("KPEIN", item.getKPEIN());
priceObj.put("KMEIN", item.getKMEIN());
priceObj.put("UMREZ", item.getUMREZ());
priceObj.put("MAKTX", item.getMAKTX());
priceObj.put("PRSCH", StringUtil.toDouble(item.getPRSCH()));
priceObj.put("DATAM", item.getDATAM());
priceObj.put("DATBI", DateUtil.parseDateNoEmpty(item.getDATBI(), DateUtil.FMT_DATE));
priceObj.put("PLINE", item.getPLINE());
priceObj.put("PRSCH_1", StringUtil.toDouble(item.getPRSCH_1()));
/*
priceObj.put("SEND_DATE", new Date(0));// 发送时间
*/
priceObj.put("SEND_STATUS", "N");
Long BATCHID = common.getNextval(today + "_t_price_list_BATCH_" + KUNNR + "_" + MATNR);
String BATCH = today + "-" + BATCHID;
priceObj.put("TRACE_NO", "sappricelist" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
priceObj.put("BATCH", BATCH);
priceObj.put("UPDATED", now);
if (priceObj.get("ID") != null) {
updatePriceObj(priceObj);
} else {
insertPriceObj(priceObj);
}
}
/*
Element record = StringUtil.getDataElement(xml, "RECORD");
Element headerSending = record.element("HEADER_SENDING");
......@@ -54,12 +115,9 @@ public class PriceListServiceImpl implements PriceListService {
if (priceObj == null) {
priceObj = new HashMap<>();
}
/********** header ***********/
priceObj.put("KUNNR", KUNNR);
priceObj.put("DATUM", DATUM);
priceObj.put("UZEIT", UZEIT);
/********** header ***********/
/********** item ***********/
priceObj.put("MATNR", MATNR);
priceObj.put("KBETR", StringUtil.toDouble(element.elementText("KBETR")));
priceObj.put("KONWA", element.elementText("KONWA"));
......@@ -72,11 +130,8 @@ public class PriceListServiceImpl implements PriceListService {
priceObj.put("DATBI", DateUtil.parseDateNoEmpty(element.elementText("DATBI"), DateUtil.FMT_DATE));
priceObj.put("PLINE", element.elementText("PLINE"));
priceObj.put("PRSCH_1", StringUtil.toDouble(element.elementText("PRSCH_1")));
/********** item ***********/
/*********** 缺 **************/
priceObj.put("SEND_DATE", new Date(0));// 发送时间
/*********** 缺 **************/
priceObj.put("SEND_STATUS", "N");
......@@ -95,6 +150,7 @@ public class PriceListServiceImpl implements PriceListService {
} catch (Exception e) {
e.printStackTrace();
}
*/
}
private void updatePriceObj(Map<String, Object> priceObj) {
......
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