Commit dd12d377 authored by Quxl's avatar Quxl

x

parent a806f714
...@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_004_INVENTORY_SyncOutService; ...@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_004_INVENTORY_SyncOutService;
import java.io.File; import java.io.File;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component; ...@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.config.XRException;
import com.egolm.sso.distributors.ServiceFactory; import com.egolm.sso.distributors.ServiceFactory;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.CommonService.Page; import com.egolm.sso.services.CommonService.Page;
import com.egolm.sso.util.CollectionUtil; import com.egolm.sso.util.CollectionUtil;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil; import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.ThrowableUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component @Component
public class SI004INVENTORYSyncOutServiceTask { public class SI004INVENTORYSyncOutServiceTask {
...@@ -42,6 +49,9 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -42,6 +49,9 @@ public class SI004INVENTORYSyncOutServiceTask {
@Value("${WSDLPATH}") @Value("${WSDLPATH}")
private String WSDLPATH; private String WSDLPATH;
@Value("${xmlRoot}")
private String xmlRoot;
@Transactional @Transactional
//@Scheduled(cron="${cronSi004}") //@Scheduled(cron="${cronSi004}")
public void execute() { public void execute() {
...@@ -59,6 +69,8 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -59,6 +69,8 @@ public class SI004INVENTORYSyncOutServiceTask {
} }
private void sendData(SI004INVENTORYSyncOut SI004INVENTORYSyncOut) { private void sendData(SI004INVENTORYSyncOut SI004INVENTORYSyncOut) {
Date now = new Date();
String timeString = DateUtil.formatDate(now, "yyyyMMddHHmmssSSS");
Page page = new Page(1L, 1000L, new String[] {"DIS_CODE", "INVENTORY_DATE"}); Page page = new Page(1L, 1000L, new String[] {"DIS_CODE", "INVENTORY_DATE"});
String sql = "SELECT * FROM t_dis_inventory WHERE SEND_STATUS = 'N'"; String sql = "SELECT * FROM t_dis_inventory WHERE SEND_STATUS = 'N'";
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
...@@ -71,35 +83,52 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -71,35 +83,52 @@ public class SI004INVENTORYSyncOutServiceTask {
} while(tmp != null && tmp.size() > 0); } while(tmp != null && tmp.size() > 0);
Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "INVENTORY_DATE"); Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "INVENTORY_DATE");
for(List<Map<String, Object>> vList : datas.values()) { for(List<Map<String, Object>> vList : datas.values()) {
JSONObject headerObject = new JSONObject(vList.get(0)); boolean isSuccess = true;
ZDTSD004INVENTORYSENDING mt004INVENTORY = new ZDTSD004INVENTORYSENDING(); ZDTSD004INVENTORYSENDING mt004INVENTORY = new ZDTSD004INVENTORYSENDING();
ZDTSD004INVENTORYSENDING.RECORD RECORD = new ZDTSD004INVENTORYSENDING.RECORD(); try {
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD INVENTORYRECORD = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD(); JSONObject headerObject = new JSONObject(vList.get(0));
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER INVENTORYRECORD_HEADER = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER(); ZDTSD004INVENTORYSENDING.RECORD RECORD = new ZDTSD004INVENTORYSENDING.RECORD();
INVENTORYRECORD_HEADER.setKUNNR(headerObject.getString("DIS_CODE")); ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD INVENTORYRECORD = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD();
INVENTORYRECORD_HEADER.setNAME1(headerObject.getString("DIS_NAME")); ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER INVENTORYRECORD_HEADER = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER();
INVENTORYRECORD_HEADER.setZDATE(headerObject.getString("INVENTORY_DATE")); INVENTORYRECORD_HEADER.setKUNNR(headerObject.getString("DIS_CODE"));
INVENTORYRECORD_HEADER.setZSPART(headerObject.getString("MPG")); INVENTORYRECORD_HEADER.setNAME1(headerObject.getString("DIS_NAME"));
INVENTORYRECORD.setHEADER(INVENTORYRECORD_HEADER); INVENTORYRECORD_HEADER.setZDATE(headerObject.getString("INVENTORY_DATE"));
RECORD.setINVENTORYRECORD(INVENTORYRECORD); INVENTORYRECORD_HEADER.setZSPART(headerObject.getString("MPG"));
mt004INVENTORY.setRECORD(RECORD); INVENTORYRECORD.setHEADER(INVENTORYRECORD_HEADER);
List<ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM> NVENTORYR_ITEM_LIST = INVENTORYRECORD.getITEM(); RECORD.setINVENTORYRECORD(INVENTORYRECORD);
List<BigInteger> idList = new ArrayList<BigInteger>(); mt004INVENTORY.setRECORD(RECORD);
for(Map<String, Object> map : vList) { List<ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM> NVENTORYR_ITEM_LIST = INVENTORYRECORD.getITEM();
JSONObject jsonObject = new JSONObject(map); List<BigInteger> idList = new ArrayList<BigInteger>();
idList.add(jsonObject.getBigInteger("ID")); for(Map<String, Object> map : vList) {
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM NVENTORYR_ITEM = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM(); JSONObject jsonObject = new JSONObject(map);
NVENTORYR_ITEM.setMAKTX(jsonObject.getString("DIS_SPEC")); idList.add(jsonObject.getBigInteger("ID"));
NVENTORYR_ITEM.setMATNR(jsonObject.getString("DIS_GOODS_CODE")); ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM NVENTORYR_ITEM = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM();
NVENTORYR_ITEM.setMENGE(jsonObject.getString("DIS_QTY")); NVENTORYR_ITEM.setMAKTX(jsonObject.getString("DIS_SPEC"));
NVENTORYR_ITEM.setPOSNR(jsonObject.getString("INVENTORY_LINE")); NVENTORYR_ITEM.setMATNR(jsonObject.getString("DIS_GOODS_CODE"));
NVENTORYR_ITEM.setZPRIC(jsonObject.getString("DIS_TAX_PRICE")); NVENTORYR_ITEM.setMENGE(jsonObject.getString("DIS_QTY"));
NVENTORYR_ITEM.setZVALU(jsonObject.getString("DIS_TAX_AMOUNT")); NVENTORYR_ITEM.setPOSNR(jsonObject.getString("INVENTORY_LINE"));
NVENTORYR_ITEM_LIST.add(NVENTORYR_ITEM); NVENTORYR_ITEM.setZPRIC(jsonObject.getString("DIS_TAX_PRICE"));
NVENTORYR_ITEM.setZVALU(jsonObject.getString("DIS_TAX_AMOUNT"));
NVENTORYR_ITEM_LIST.add(NVENTORYR_ITEM);
}
SI004INVENTORYSyncOut.si004INVENTORYSyncOut(mt004INVENTORY);
String updateSql = "UPDATE t_dis_inventory SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")";
jdbcTemplate.update(updateSql, idList.toArray());
} catch (Throwable e) {
isSuccess = false;
throw new XRException(ThrowableUtil.getCaused(e).getMessage() + " -- " + timeString, e);
} finally {
String xmlName = "004_INVENTORY";
try {
String xml = XMLUtil.toXml(mt004INVENTORY);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(now, DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + timeString + ".XML";
FileUtil.writeText(xmlFullName, xml);
String json = new Gson().toJson(mt004INVENTORY);
FileUtil.writeText(xmlFullName + ".JSON", json);
} catch (Exception e) {
throw new XRException(ThrowableUtil.getCaused(e).getMessage(), e);
}
} }
SI004INVENTORYSyncOut.si004INVENTORYSyncOut(mt004INVENTORY);
String updateSql = "UPDATE t_dis_inventory SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")";
jdbcTemplate.update(updateSql, idList.toArray());
} }
} }
......
...@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_011_ACTUAL_SALES_SyncOutService; ...@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_011_ACTUAL_SALES_SyncOutService;
import java.io.File; import java.io.File;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component; ...@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.config.XRException;
import com.egolm.sso.distributors.ServiceFactory; import com.egolm.sso.distributors.ServiceFactory;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.CommonService.Page; import com.egolm.sso.services.CommonService.Page;
import com.egolm.sso.util.CollectionUtil; import com.egolm.sso.util.CollectionUtil;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.StringUtil; import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.ThrowableUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component @Component
public class SI011ACTUALSALESSyncOutServiceTask { public class SI011ACTUALSALESSyncOutServiceTask {
...@@ -42,6 +49,9 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -42,6 +49,9 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Value("${WSDLPATH}") @Value("${WSDLPATH}")
private String WSDLPATH; private String WSDLPATH;
@Value("${xmlRoot}")
private String xmlRoot;
@Transactional @Transactional
//@Scheduled(cron="${cronSi011}") //@Scheduled(cron="${cronSi011}")
public void execute() { public void execute() {
...@@ -59,6 +69,8 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -59,6 +69,8 @@ public class SI011ACTUALSALESSyncOutServiceTask {
} }
private void sendData(SI011ACTUALSALESSyncOut SI011ACTUALSALESSyncOut) { private void sendData(SI011ACTUALSALESSyncOut SI011ACTUALSALESSyncOut) {
Date now = new Date();
String timeString = DateUtil.formatDate(now, "yyyyMMddHHmmssSSS");
Page page = new Page(1L, 1000L, new String[] {"DIS_CODE", "SALES_NO"}); Page page = new Page(1L, 1000L, new String[] {"DIS_CODE", "SALES_NO"});
String sql = "SELECT * FROM t_dis_sales WHERE SEND_STATUS = 'N'"; String sql = "SELECT * FROM t_dis_sales WHERE SEND_STATUS = 'N'";
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
...@@ -71,42 +83,59 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -71,42 +83,59 @@ public class SI011ACTUALSALESSyncOutServiceTask {
} while(tmp != null && tmp.size() > 0); } while(tmp != null && tmp.size() > 0);
Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "SALES_NO"); Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "SALES_NO");
for(List<Map<String, Object>> vList : datas.values()) { for(List<Map<String, Object>> vList : datas.values()) {
boolean isSuccess = true;
ZDTSD011ACTUALSALESSENDING mt011ACTUALSALES = new ZDTSD011ACTUALSALESSENDING(); ZDTSD011ACTUALSALESSENDING mt011ACTUALSALES = new ZDTSD011ACTUALSALESSENDING();
ZDTSD011ACTUALSALESSENDING.RECORD RECORD = new ZDTSD011ACTUALSALESSENDING.RECORD(); try {
mt011ACTUALSALES.setRECORD(RECORD); ZDTSD011ACTUALSALESSENDING.RECORD RECORD = new ZDTSD011ACTUALSALESSENDING.RECORD();
ZDTSD011ACTUALSALESSENDING.RECORD.HEADER header = new ZDTSD011ACTUALSALESSENDING.RECORD.HEADER(); mt011ACTUALSALES.setRECORD(RECORD);
List<ZDTSD011ACTUALSALESSENDING.RECORD.ITEM> itemList = RECORD.getITEM(); ZDTSD011ACTUALSALESSENDING.RECORD.HEADER header = new ZDTSD011ACTUALSALESSENDING.RECORD.HEADER();
JSONObject headerObject = new JSONObject(vList.get(0)); List<ZDTSD011ACTUALSALESSENDING.RECORD.ITEM> itemList = RECORD.getITEM();
header.setAUBEL(headerObject.getString("SALES_NO")); JSONObject headerObject = new JSONObject(vList.get(0));
header.setFXSNA(headerObject.getString("DIS_NAME")); header.setAUBEL(headerObject.getString("SALES_NO"));
header.setFXSNO(headerObject.getString("DIS_CODE")); header.setFXSNA(headerObject.getString("DIS_NAME"));
header.setSDATE(headerObject.getString("SALES_DATE")); header.setFXSNO(headerObject.getString("DIS_CODE"));
RECORD.setHEADER(header); header.setSDATE(headerObject.getString("SALES_DATE"));
List<BigInteger> idList = new ArrayList<BigInteger>(); RECORD.setHEADER(header);
for(Map<String, Object> itemMap : vList) { List<BigInteger> idList = new ArrayList<BigInteger>();
JSONObject itemObject = new JSONObject(itemMap); for(Map<String, Object> itemMap : vList) {
idList.add(itemObject.getBigInteger("ID")); JSONObject itemObject = new JSONObject(itemMap);
ZDTSD011ACTUALSALESSENDING.RECORD.ITEM item = new ZDTSD011ACTUALSALESSENDING.RECORD.ITEM(); idList.add(itemObject.getBigInteger("ID"));
item.setCUSNA(itemObject.getString("DIS_STORE_NAME")); ZDTSD011ACTUALSALESSENDING.RECORD.ITEM item = new ZDTSD011ACTUALSALESSENDING.RECORD.ITEM();
item.setCUSNO(itemObject.getString("DIS_STORE_CODE")); item.setCUSNA(itemObject.getString("DIS_STORE_NAME"));
item.setCUSTY(itemObject.getString("DIS_STORE_TYPE")); item.setCUSNO(itemObject.getString("DIS_STORE_CODE"));
item.setFAMOU(itemObject.getString("DIS_TAX_AMOUNT")); item.setCUSTY(itemObject.getString("DIS_STORE_TYPE"));
item.setFCITY(itemObject.getString("DIS_STORE_CITY")); item.setFAMOU(itemObject.getString("DIS_TAX_AMOUNT"));
item.setFDNO(itemObject.getString("SALES_LINE")); item.setFCITY(itemObject.getString("DIS_STORE_CITY"));
item.setFITEM(itemObject.getString("DIS_GOODS_CODE")); item.setFDNO(itemObject.getString("SALES_LINE"));
item.setFPRIC(itemObject.getString("DIS_TAX_PRICE")); item.setFITEM(itemObject.getString("DIS_GOODS_CODE"));
item.setFPROV(itemObject.getString("DIS_STORE_PROV")); item.setFPRIC(itemObject.getString("DIS_TAX_PRICE"));
item.setFQTY(itemObject.getString("DIS_QTY")); item.setFPROV(itemObject.getString("DIS_STORE_PROV"));
item.setFSNDP(itemObject.getString("PURCHASING_PRICE")); item.setFQTY(itemObject.getString("DIS_QTY"));
item.setMPG(itemObject.getString("MPG")); item.setFSNDP(itemObject.getString("PURCHASING_PRICE"));
item.setYLZD1(itemObject.getString("YLZD1")); item.setMPG(itemObject.getString("MPG"));
item.setYLZD2(itemObject.getString("YLZD2")); item.setYLZD1(itemObject.getString("YLZD1"));
item.setYLZD3(itemObject.getString("YLZD3")); item.setYLZD2(itemObject.getString("YLZD2"));
itemList.add(item); item.setYLZD3(itemObject.getString("YLZD3"));
itemList.add(item);
}
SI011ACTUALSALESSyncOut.si011ACTUALSALESSyncOut(mt011ACTUALSALES);
String updateSql = "UPDATE t_dis_sales SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")";
jdbcTemplate.update(updateSql, idList.toArray());
} catch (Throwable e) {
isSuccess = false;
e.printStackTrace();
} finally {
String xmlName = "011_ACTUAL_SALES";
try {
String xml = XMLUtil.toXml(mt011ACTUALSALES);
String xmlFullName = xmlRoot + "/sap/" + xmlName + "/" + DateUtil.formatDate(now, DateUtil.FMT_DATE) + "/" + (isSuccess?"success":"error") + "/" + xmlName + "-" + timeString + ".XML";
FileUtil.writeText(xmlFullName, xml);
String json = new Gson().toJson(mt011ACTUALSALES);
FileUtil.writeText(xmlFullName + ".JSON", json);
} catch (Exception e) {
throw new XRException(ThrowableUtil.getCaused(e).getMessage(), e);
}
} }
SI011ACTUALSALESSyncOut.si011ACTUALSALESSyncOut(mt011ACTUALSALES);
String updateSql = "UPDATE t_dis_sales SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")";
jdbcTemplate.update(updateSql, idList.toArray());
} }
} }
......
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