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,8 +83,10 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -71,8 +83,10 @@ 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();
try {
JSONObject headerObject = new JSONObject(vList.get(0));
ZDTSD004INVENTORYSENDING.RECORD RECORD = new ZDTSD004INVENTORYSENDING.RECORD(); ZDTSD004INVENTORYSENDING.RECORD RECORD = new ZDTSD004INVENTORYSENDING.RECORD();
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD INVENTORYRECORD = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD(); ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD INVENTORYRECORD = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD();
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER INVENTORYRECORD_HEADER = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER(); ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER INVENTORYRECORD_HEADER = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER();
...@@ -100,6 +114,21 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -100,6 +114,21 @@ public class SI004INVENTORYSyncOutServiceTask {
SI004INVENTORYSyncOut.si004INVENTORYSyncOut(mt004INVENTORY); SI004INVENTORYSyncOut.si004INVENTORYSyncOut(mt004INVENTORY);
String updateSql = "UPDATE t_dis_inventory SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")"; 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()); 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);
}
}
} }
} }
......
...@@ -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,7 +83,9 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -71,7 +83,9 @@ 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();
try {
ZDTSD011ACTUALSALESSENDING.RECORD RECORD = new ZDTSD011ACTUALSALESSENDING.RECORD(); ZDTSD011ACTUALSALESSENDING.RECORD RECORD = new ZDTSD011ACTUALSALESSENDING.RECORD();
mt011ACTUALSALES.setRECORD(RECORD); mt011ACTUALSALES.setRECORD(RECORD);
ZDTSD011ACTUALSALESSENDING.RECORD.HEADER header = new ZDTSD011ACTUALSALESSENDING.RECORD.HEADER(); ZDTSD011ACTUALSALESSENDING.RECORD.HEADER header = new ZDTSD011ACTUALSALESSENDING.RECORD.HEADER();
...@@ -107,6 +121,21 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -107,6 +121,21 @@ public class SI011ACTUALSALESSyncOutServiceTask {
SI011ACTUALSALESSyncOut.si011ACTUALSALESSyncOut(mt011ACTUALSALES); SI011ACTUALSALESSyncOut.si011ACTUALSALESSyncOut(mt011ACTUALSALES);
String updateSql = "UPDATE t_dis_sales SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN (" + StringUtil.join("?", ", ", idList.size(), "", "") + ")"; 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()); 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);
}
}
} }
} }
......
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