Commit a806f714 authored by Quxl's avatar Quxl

x

parent 921d1dd0
package com.egolm.sso.distributors.SI_004_INVENTORY_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
......@@ -9,9 +13,14 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
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.StringUtil;
@Component
public class SI004INVENTORYSyncOutServiceTask {
......@@ -33,18 +42,65 @@ public class SI004INVENTORYSyncOutServiceTask {
@Value("${WSDLPATH}")
private String WSDLPATH;
@Transactional
//@Scheduled(cron="${cronSi004}")
public void execute() {
this.runTask();
}
public void runTask() {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_011_ACTUAL_SALES_SyncOutService.wsdl";
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_004_INVENTORY_SyncOutService.wsdl";
SI004INVENTORYSyncOut service = ServiceFactory.create(SI004INVENTORYSyncOut.class, wsdlLocation, "http://distributors.edi.digital.cn.se.com", "SI_004_INVENTORY_SyncOutService", username, password);
this.sendData(service);
}
private void sendData(SI004INVENTORYSyncOut SI004INVENTORYSyncOut) {
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>>();
List<Map<String, Object>> tmp = null;
do {
String limitSql = common.limitByMysql(sql, page);
tmp = jdbcTemplate.queryForList(limitSql);
list.addAll(tmp);
page.toNextPage();
} 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));
ZDTSD004INVENTORYSENDING mt004INVENTORY = new ZDTSD004INVENTORYSENDING();
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();
INVENTORYRECORD_HEADER.setKUNNR(headerObject.getString("DIS_CODE"));
INVENTORYRECORD_HEADER.setNAME1(headerObject.getString("DIS_NAME"));
INVENTORYRECORD_HEADER.setZDATE(headerObject.getString("INVENTORY_DATE"));
INVENTORYRECORD_HEADER.setZSPART(headerObject.getString("MPG"));
INVENTORYRECORD.setHEADER(INVENTORYRECORD_HEADER);
RECORD.setINVENTORYRECORD(INVENTORYRECORD);
mt004INVENTORY.setRECORD(RECORD);
List<ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM> NVENTORYR_ITEM_LIST = INVENTORYRECORD.getITEM();
List<BigInteger> idList = new ArrayList<BigInteger>();
for(Map<String, Object> map : vList) {
JSONObject jsonObject = new JSONObject(map);
idList.add(jsonObject.getBigInteger("ID"));
ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM NVENTORYR_ITEM = new ZDTSD004INVENTORYSENDING.RECORD.INVENTORYRECORD.ITEM();
NVENTORYR_ITEM.setMAKTX(jsonObject.getString("DIS_SPEC"));
NVENTORYR_ITEM.setMATNR(jsonObject.getString("DIS_GOODS_CODE"));
NVENTORYR_ITEM.setMENGE(jsonObject.getString("DIS_QTY"));
NVENTORYR_ITEM.setPOSNR(jsonObject.getString("INVENTORY_LINE"));
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());
}
}
}
......@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.distributors.ServiceFactory;
......@@ -41,6 +42,12 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Value("${WSDLPATH}")
private String WSDLPATH;
@Transactional
//@Scheduled(cron="${cronSi011}")
public void execute() {
this.runTask();
}
public void runTask() {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
......@@ -63,8 +70,6 @@ public class SI011ACTUALSALESSyncOutServiceTask {
page.toNextPage();
} 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()) {
ZDTSD011ACTUALSALESSENDING mt011ACTUALSALES = new ZDTSD011ACTUALSALESSENDING();
ZDTSD011ACTUALSALESSENDING.RECORD RECORD = new ZDTSD011ACTUALSALESSENDING.RECORD();
......
......@@ -48,10 +48,6 @@ public class ZMISD009SOCREATIONServiceTask {
this.runTask();
}
public static void main(String[] args) {
new ZMISD009SOCREATIONServiceTask().execute();
}
public void runTask() {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
......
package com.egolm.sso.util;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class CollectionUtil {
public static Map<String, List<Map<String, Object>>> toGroupList(List<Map<String, Object>> datas, String... keyName) {
Map<String, List<Map<String, Object>>> mapDatas = new LinkedHashMap<String, List<Map<String, Object>>>();
if(datas != null) {
for(Map<String, Object> map : datas) {
if(map.size() > 0) {
List<String> keys = new ArrayList<String>();
for(String key : keyName) {
Object obj = map.get(key);
if(obj != null) {
keys.add(String.valueOf(obj));
}
}
String fullKey = StringUtil.join(",", "", "", "", keys);
List<Map<String, Object>> list = mapDatas.get(fullKey);
if(list == null) {
list = new ArrayList<Map<String, Object>>();
}
list.add(map);
mapDatas.put(fullKey, list);
}
}
}
return mapDatas;
}
public static Map<String, Map<String, Object>> toGroupMap(List<Map<String, Object>> datas, String... keyName) {
Map<String, Map<String, Object>> mapDatas = new LinkedHashMap<String, Map<String, Object>>();
if(datas != null) {
for(Map<String, Object> map : datas) {
if(map.size() > 0) {
List<String> keys = new ArrayList<String>();
for(String key : keyName) {
Object obj = map.get(key);
if(obj != null) {
keys.add(String.valueOf(obj));
}
}
String fullKey = StringUtil.join(",", "", "", "", keys);
mapDatas.put(fullKey, map);
}
}
}
return mapDatas;
}
}
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