Commit 72c9eece authored by Quxl's avatar Quxl

x

parent ff693850
......@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService.SI004INVENTORYSyncOutServiceTask;
import com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService.SI011ACTUALSALESSyncOutServiceTask;
import com.egolm.sso.clients.Z_MI_SD_009_SO_CREATION.ZMISD009SOCREATIONServiceTask;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.util.DateUtil;
@RestController
......@@ -28,7 +28,7 @@ public class TestController {
private boolean isUsedTestController;
@Autowired
private CommonService common;
private TraceService trace;
@Autowired
private ZMISD009SOCREATIONServiceTask sp009Task;
......@@ -87,14 +87,14 @@ public class TestController {
@GetMapping("getToken")
public Object getToken() {
this.verify();
String token = common.getToken();
String token = trace.getToken();
return token;
}
@GetMapping("saveOrderTracking")
public Object saveOrderTracking() {
this.verify();
return common.saveOrderTracking("sapmaterialmaster" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATETIME), "MaterialMaster", "123456", "123456", "G", null, "操作失败", "操作失败");
return trace.saveOrderTracking("sapmaterialmaster" + DateUtil.formatDate(new Date(), DateUtil.FMT_DATETIME), "MaterialMaster", "123456", "123456", "G", null, "操作失败", "操作失败");
}
}
......@@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.clients.ServiceFactory;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.util.CollectionUtil;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
......@@ -41,6 +42,9 @@ public class SI004INVENTORYSyncOutServiceTask {
@Autowired
private CommonService common;
@Autowired
private TraceService trace;
@Value("${schneider.username}")
private String username;
......@@ -142,7 +146,7 @@ public class SI004INVENTORYSyncOutServiceTask {
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(traceNo, "004_INVENTORY", null, disCode, "D", (isSuccess ? "S" : "F"), message, errorMessage);
trace.saveOrderTracking(traceNo, "004_INVENTORY", null, disCode, "D", (isSuccess ? "S" : "F"), message, errorMessage);
} catch (Throwable e1) {
logger.error("追踪数据保存失败", e1);
}
......
......@@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.clients.ServiceFactory;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.util.CollectionUtil;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
......@@ -41,6 +42,9 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Autowired
private CommonService common;
@Autowired
private TraceService trace;
@Value("${schneider.username}")
private String username;
......@@ -149,7 +153,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(traceNo, "011_ACTUAL_SALES", null, disCode, "D", (isSuccess ? "S" : "F"), message, errorMessage);
trace.saveOrderTracking(traceNo, "011_ACTUAL_SALES", null, disCode, "D", (isSuccess ? "S" : "F"), message, errorMessage);
} catch (Throwable e1) {
logger.error("追踪数据保存失败", e1);
}
......
......@@ -20,6 +20,7 @@ import com.egolm.sso.clients.Z_MI_SD_009_SO_CREATION.ZDTSD009SOCREATION.Header;
import com.egolm.sso.clients.Z_MI_SD_009_SO_CREATION.ZDTSD009SOCREATION.ITEM;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.ThrowableUtil;
......@@ -37,6 +38,9 @@ public class ZMISD009SOCREATIONServiceTask {
@Autowired
private CommonService common;
@Autowired
private TraceService trace;
@Value("${schneider.username}")
private String username;
......@@ -140,7 +144,7 @@ public class ZMISD009SOCREATIONServiceTask {
logger.error("数据上传日志记录失败", e1);
}
try {
common.saveOrderTracking(traceNo, "SoCreation", null, disCode, "D", (isSuccess ? "S" : "F"), message, errorMessage);
trace.saveOrderTracking(traceNo, "SoCreation", null, disCode, "D", (isSuccess ? "S" : "F"), message, errorMessage);
} catch (Throwable e1) {
logger.error("追踪数据保存失败", e1);
}
......
......@@ -14,10 +14,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.config.XRException;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.HttpUtil;
import com.egolm.sso.util.SqlUtil;
import com.egolm.sso.util.SqlUtil.Sql;
import com.egolm.sso.util.StringUtil;
......@@ -108,68 +106,11 @@ public class CommonService {
sName = sPrefix + "_" + sName + "_" + dateString;
return dateString + "-" + this.getNextval(sName);
}
public String getNextTrace(Date now, String sPrefix, String sName) {
String dateString = DateUtil.formatDate(now, DateUtil.FMT_DATE);
String timeString = DateUtil.formatDate(now, "yyyyMMddHHmmssSSS");
return sPrefix + timeString + this.getNextval(sName + "_TRACE_" + dateString);
}
@Value("${dataTracking.tokenExpireMinute}")
private Long tokenExpireMinute;
private static String token;
private static Date tokenCreateTime;
public String getToken() {
Date now = new Date();
if (token != null && tokenCreateTime != null
&& (tokenCreateTime.getTime() + ((tokenExpireMinute - 2) * 60L * 1000L)) > now.getTime()) {
return token;
}
String requestUrl = baseUrl + tokenUri;
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("appId", appId);
parameters.put("appSecret", appSecret);
parameters.put("username", username);
String resultText = HttpUtil.post(requestUrl, parameters, null);
JSONObject jsonObject = JSONObject.parseObject(resultText);
Boolean isSuccess = jsonObject.getBoolean("success");
if (isSuccess != null && isSuccess) {
tokenCreateTime = now;
token = jsonObject.getString("token");
return token;
} else {
throw new TrackingTokenException(jsonObject.getString("message"));
}
}
public String saveOrderTracking(String traceNo, String orderType, String orderNo, String disCode, String action,
String result, String message, String errorMessage) {
if (isOpen) {
String requestUrl = baseUrl + insertOrderTrackingUri;
String token = this.getToken();
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Bearer " + token);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("traceNo", traceNo);
parameters.put("orderType", orderType);
parameters.put("orderNo", orderNo);
parameters.put("disCode", disCode);
parameters.put("action", action);
parameters.put("result", result);
parameters.put("message", message);
parameters.put("errorMessage", errorMessage);
return HttpUtil.postRaw(requestUrl, parameters, headers);
}
return null;
}
public static class TrackingTokenException extends RuntimeException {
private static final long serialVersionUID = 1L;
public TrackingTokenException(String msg) {
super(msg);
}
}
}
......@@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.HEADER;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.ITEM_DATA;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION.ITEM_PRICING;
......@@ -35,10 +36,13 @@ import com.google.gson.Gson;
public class ConfirmQuotationServiceImpl implements ConfirmQuotationService {
@Autowired
JdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
private CommonService common;
@Autowired
private TraceService trace;
@Value("${xmlRoot}")
private String xmlRoot;
......@@ -183,7 +187,7 @@ public class ConfirmQuotationServiceImpl implements ConfirmQuotationService {
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(TRACE_NO, traceName, VBELN, KUNNR, traceAction, isSuccess ? "S" : "F", message, errorMessage);
trace.saveOrderTracking(TRACE_NO, traceName, VBELN, KUNNR, traceAction, isSuccess ? "S" : "F", message, errorMessage);
} catch (Exception e1) {
logger.error(timeString, e1);
}
......
......@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.SqlUtil;
......@@ -29,10 +30,13 @@ public class DNDeletionServiceImpl implements DNDeletionService {
@Autowired
JdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
private CommonService common;
@Autowired
private TraceService trace;
@Value("${xmlRoot}")
private String xmlRoot;
......@@ -92,7 +96,7 @@ public class DNDeletionServiceImpl implements DNDeletionService {
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(TRACE_NO, traceName, null, SOLD_TO, traceAction, isSuccess ? "S" : "F", message, errorMessage);
trace.saveOrderTracking(TRACE_NO, traceName, null, SOLD_TO, traceAction, isSuccess ? "S" : "F", message, errorMessage);
} catch (Exception e1) {
logger.error(timeString, e1);
}
......
......@@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.HEADER_SENDING;
import com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.ITEM;
import com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.RECORD;
......@@ -32,10 +33,13 @@ import com.google.gson.Gson;
public class MaterialMasterServiceImpl implements MaterialMasterService {
@Autowired
JdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
private CommonService common;
@Autowired
private TraceService trace;
@Value("${xmlRoot}")
private String xmlRoot;
......@@ -138,7 +142,7 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(TRACE_NO, traceName, null, DIS_CODE, traceAction, isSuccess ? "S" : "F", message, errorMessage);
trace.saveOrderTracking(TRACE_NO, traceName, null, DIS_CODE, traceAction, isSuccess ? "S" : "F", message, errorMessage);
} catch (Exception e1) {
logger.error(timeString, e1);
}
......
......@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_GENERAL_DATA;
......@@ -34,20 +35,23 @@ 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.google.gson.Gson;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.ThrowableUtil;
import com.egolm.sso.util.XMLUtil;
import com.google.gson.Gson;
@Component
@WebService(serviceName = "PrformaInvoiceService", targetNamespace = "http://prforma_invoice.sso.egolm.com", endpointInterface = "com.egolm.sso.services.prforma_invoice.PrformaInvoiceService")
public class PrformaInvoiceServiceImpl implements PrformaInvoiceService {
@Autowired
JdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
private CommonService common;
@Autowired
private TraceService trace;
@Value("${xmlRoot}")
private String xmlRoot;
......@@ -266,7 +270,7 @@ public class PrformaInvoiceServiceImpl implements PrformaInvoiceService {
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(TRACE_NO, traceName, null, BATCH_CODE, traceAction, isSuccess ? "S" : "F", message, errorMessage);
trace.saveOrderTracking(TRACE_NO, traceName, null, BATCH_CODE, traceAction, isSuccess ? "S" : "F", message, errorMessage);
} catch (Exception e1) {
logger.error(timeString, e1);
}
......
......@@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
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;
......@@ -32,10 +33,13 @@ import com.google.gson.Gson;
public class PriceListServiceImpl implements PriceListService {
@Autowired
JdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
private CommonService common;
@Autowired
private TraceService trace;
@Value("${xmlRoot}")
private String xmlRoot;
......@@ -123,7 +127,7 @@ public class PriceListServiceImpl implements PriceListService {
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(TRACE_NO, traceName, null, KUNNR, traceAction, isSuccess ? "S" : "F", message, errorMessage);
trace.saveOrderTracking(TRACE_NO, traceName, null, KUNNR, traceAction, isSuccess ? "S" : "F", message, errorMessage);
} catch (Exception e1) {
logger.error(timeString, e1);
}
......
......@@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService;
import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DATE;
import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_DELIVERY;
import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.HEADER_PARTNER;
......@@ -38,10 +39,13 @@ import com.google.gson.Gson;
public class ShippingNotificationServiceImpl implements ShippingNotificationService {
@Autowired
JdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
private CommonService common;
@Autowired
private TraceService trace;
@Value("${xmlRoot}")
private String xmlRoot;
......@@ -192,7 +196,7 @@ public class ShippingNotificationServiceImpl implements ShippingNotificationServ
logger.error(timeString, e1);
}
try {
common.saveOrderTracking(TRACE_NO, traceName, null, BATCH_CODE, traceAction, isSuccess ? "S" : "F", message, errorMessage);
trace.saveOrderTracking(TRACE_NO, traceName, null, BATCH_CODE, traceAction, isSuccess ? "S" : "F", message, errorMessage);
} catch (Exception e1) {
logger.error(timeString, e1);
}
......
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