Commit dd12d377 authored by Quxl's avatar Quxl

x

parent a806f714
......@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_004_INVENTORY_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.config.XRException;
import com.egolm.sso.distributors.ServiceFactory;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.CommonService.Page;
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.ThrowableUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component
public class SI004INVENTORYSyncOutServiceTask {
......@@ -42,6 +49,9 @@ public class SI004INVENTORYSyncOutServiceTask {
@Value("${WSDLPATH}")
private String WSDLPATH;
@Value("${xmlRoot}")
private String xmlRoot;
@Transactional
//@Scheduled(cron="${cronSi004}")
public void execute() {
......@@ -59,6 +69,8 @@ public class SI004INVENTORYSyncOutServiceTask {
}
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"});
String sql = "SELECT * FROM t_dis_inventory WHERE SEND_STATUS = 'N'";
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
......@@ -71,8 +83,10 @@ public class SI004INVENTORYSyncOutServiceTask {
} while(tmp != null && tmp.size() > 0);
Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "INVENTORY_DATE");
for(List<Map<String, Object>> vList : datas.values()) {
JSONObject headerObject = new JSONObject(vList.get(0));
boolean isSuccess = true;
ZDTSD004INVENTORYSENDING mt004INVENTORY = new ZDTSD004INVENTORYSENDING();
try {
JSONObject headerObject = new JSONObject(vList.get(0));
ZDTSD004INVENTORYSENDING.RECORD RECORD = new ZDTSD004INVENTORYSENDING.RECORD();
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD INVENTORYRECORD = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD();
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER INVENTORYRECORD_HEADER = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.HEADER();
......@@ -100,6 +114,21 @@ public class SI004INVENTORYSyncOutServiceTask {
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);
}
}
}
}
......
......@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_011_ACTUAL_SALES_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.config.XRException;
import com.egolm.sso.distributors.ServiceFactory;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.CommonService.Page;
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.ThrowableUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component
public class SI011ACTUALSALESSyncOutServiceTask {
......@@ -42,6 +49,9 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Value("${WSDLPATH}")
private String WSDLPATH;
@Value("${xmlRoot}")
private String xmlRoot;
@Transactional
//@Scheduled(cron="${cronSi011}")
public void execute() {
......@@ -59,6 +69,8 @@ public class SI011ACTUALSALESSyncOutServiceTask {
}
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"});
String sql = "SELECT * FROM t_dis_sales WHERE SEND_STATUS = 'N'";
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
......@@ -71,7 +83,9 @@ public class SI011ACTUALSALESSyncOutServiceTask {
} while(tmp != null && tmp.size() > 0);
Map<String, List<Map<String, Object>>> datas = CollectionUtil.toGroupList(list, "DIS_CODE", "SALES_NO");
for(List<Map<String, Object>> vList : datas.values()) {
boolean isSuccess = true;
ZDTSD011ACTUALSALESSENDING mt011ACTUALSALES = new ZDTSD011ACTUALSALESSENDING();
try {
ZDTSD011ACTUALSALESSENDING.RECORD RECORD = new ZDTSD011ACTUALSALESSENDING.RECORD();
mt011ACTUALSALES.setRECORD(RECORD);
ZDTSD011ACTUALSALESSENDING.RECORD.HEADER header = new ZDTSD011ACTUALSALESSENDING.RECORD.HEADER();
......@@ -107,6 +121,21 @@ public class SI011ACTUALSALESSyncOutServiceTask {
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);
}
}
}
}
......
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