Commit 2d3d5753 authored by Quxl's avatar Quxl

x

parent 93a4b99d
......@@ -7,14 +7,18 @@ import java.util.Map;
import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.SqlUtil;
import com.egolm.sso.util.SqlUtil.Sql;
import com.egolm.sso.util.XMLUtil;
@Component
@WebService(serviceName = "DNDeletionService", targetNamespace = "http://dn_deletion.sso.egolm.com", endpointInterface = "com.egolm.sso.services.dn_deletion.DNDeletionService")
......@@ -27,28 +31,46 @@ public class DNDeletionServiceImpl implements DNDeletionService {
@Autowired
CommonService common;
@Value("${xmlRoot}")
private String xmlRoot;
@Override
@Transactional
public void execute(DELETED_DOCUMENTS DELETED_DOCUMENTS) {
boolean isSuccess = true;
Date now = new Date();
String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
Map<String, Object> map = new HashMap<String, Object>();
map.put("MSGID", DELETED_DOCUMENTS.getMSGID());
map.put("TARGET_SYSTEM", DELETED_DOCUMENTS.getTARGET_SYSTEM());
map.put("DOCTYPE", DELETED_DOCUMENTS.getDOCTYPE());
map.put("DOCNUMBER", DELETED_DOCUMENTS.getDOCNUMBER());
map.put("SALES_ORG", DELETED_DOCUMENTS.getSALES_ORG());
map.put("DELETED_BY", DELETED_DOCUMENTS.getDELETED_BY());
map.put("SOLD_TO", DELETED_DOCUMENTS.getSOLD_TO());
map.put("BATCH", dateString + "-" + common.getNextval("T_SO_DN_DELETION_BATCH" + dateString));
map.put("SEND_STATUS", "N");
map.put("SEND_TIME", now);
map.put("CREATED", now);
map.put("CREATEDBY", "system");
map.put("UPDATED", now);
map.put("UPDATEDBY", "system");
Sql headerSql = SqlUtil.insertSql("t_so_dn_deletion", map);
jdbcTemplate.update(headerSql.getSql(), headerSql.getArgs());
try {
Map<String, Object> map = new HashMap<String, Object>();
map.put("MSGID", DELETED_DOCUMENTS.getMSGID());
map.put("TARGET_SYSTEM", DELETED_DOCUMENTS.getTARGET_SYSTEM());
map.put("DOCTYPE", DELETED_DOCUMENTS.getDOCTYPE());
map.put("DOCNUMBER", DELETED_DOCUMENTS.getDOCNUMBER());
map.put("SALES_ORG", DELETED_DOCUMENTS.getSALES_ORG());
map.put("DELETED_BY", DELETED_DOCUMENTS.getDELETED_BY());
map.put("SOLD_TO", DELETED_DOCUMENTS.getSOLD_TO());
map.put("BATCH", dateString + "-" + common.getNextval("T_SO_DN_DELETION_BATCH" + dateString));
map.put("SEND_STATUS", "N");
map.put("SEND_TIME", now);
map.put("CREATED", now);
map.put("CREATEDBY", "system");
map.put("UPDATED", now);
map.put("UPDATEDBY", "system");
Sql headerSql = SqlUtil.insertSql("t_so_dn_deletion", map);
jdbcTemplate.update(headerSql.getSql(), headerSql.getArgs());
} catch (Exception e) {
isSuccess = false;
throw new XRException("数据保存失败", e);
} finally {
String xmlName = DELETED_DOCUMENTS.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(DELETED_DOCUMENTS);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
}
}
}
}
......@@ -124,7 +124,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
String xmlName = Z_MT_SD_001_MATERIAL_MASTER.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(Z_MT_SD_001_MATERIAL_MASTER);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(dateString + "MATERIAL_MASTER_FILE_NAME" + dateString) + ".XML";
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
......
......@@ -10,16 +10,20 @@ import java.util.Map.Entry;
import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.HEADER_SENDING;
import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.ITEM;
import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST.RECORD;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component
......@@ -32,56 +36,73 @@ public class PriceListServiceImpl implements PriceListService {
@Autowired
CommonService common;
@Value("${xmlRoot}")
private String xmlRoot;
@Override
@Transactional
public void execute(Z_MT_SD_002_PRICE_LIST Z_MT_SD_002_PRICE_LIST) {
boolean isSuccess = true;
Date now = new Date();
String today = DateUtil.formatDate(now, DateUtil.FMT_DATE);
String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
System.out.println(new Gson().toJson(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<>();
}
try {
RECORD r = Z_MT_SD_002_PRICE_LIST.getRECORD();
HEADER_SENDING h = r.getHEADER_SENDING();
List<ITEM> items = r.getITEM();
priceObj.put("KUNNR", KUNNR);
priceObj.put("DATUM", DateUtil.parseDate(DATUM, DateUtil.FMT_DATE));
priceObj.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME));
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", DateUtil.parseDate(item.getDATAM(), DateUtil.FMT_DATE));
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("T_PRICE_LIST_BATCH_" + today);
String BATCH = today + "-" + BATCHID;
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", DateUtil.parseDate(DATUM, DateUtil.FMT_DATE));
priceObj.put("UZEIT", DateUtil.parseDate(UZEIT, DateUtil.FMT_TIME));
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", DateUtil.parseDate(item.getDATAM(), DateUtil.FMT_DATE));
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("T_PRICE_LIST_BATCH_" + dateString);
String BATCH = dateString + "-" + BATCHID;
priceObj.put("TRACE_NO", "sappricelist" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
priceObj.put("BATCH", BATCH);
if (priceObj.get("ID") != null) {
updatePriceObj(priceObj);
} else {
insertPriceObj(priceObj);
priceObj.put("TRACE_NO", "sappricelist" + DateUtil.formatDate(now, DateUtil.FMT_DATETIME));
priceObj.put("BATCH", BATCH);
if (priceObj.get("ID") != null) {
updatePriceObj(priceObj);
} else {
insertPriceObj(priceObj);
}
}
} catch (Exception e) {
isSuccess = false;
throw new XRException("数据保存失败", e);
} finally {
String xmlName = Z_MT_SD_002_PRICE_LIST.getClass().getSimpleName();
try {
String xml = XMLUtil.toXml(Z_MT_SD_002_PRICE_LIST);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + common.getNextval(xmlName + "_" + dateString) + ".XML";
FileUtil.writeText(xmlFullName, xml);
} catch (Exception e) {
throw new XRException("报文保存失败", e);
}
}
}
......
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