|
@@ -6,14 +6,18 @@ import java.util.Map;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import org.fouram.constants.WebConstants;
|
|
|
import org.fouram.core.base.dao.DAO;
|
|
|
import org.fouram.core.base.exception.PromptException;
|
|
|
import org.fouram.core.util.Base64Util;
|
|
|
import org.fouram.core.util.ConfConfig;
|
|
|
+import org.fouram.core.util.JsonNodeUtil;
|
|
|
import org.fouram.core.util.Tools;
|
|
|
import org.fouram.entity.SapUser;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
/**
|
|
@@ -23,6 +27,8 @@ public abstract class BaseService {
|
|
|
|
|
|
@Resource(name = "daoSupport")
|
|
|
private DAO dao;
|
|
|
+ @Autowired
|
|
|
+ protected RequestService requestService;
|
|
|
|
|
|
public Integer save(String sqlStr, Object paramObj) throws Exception {
|
|
|
return dao.save(sqlStr, paramObj);
|
|
@@ -57,12 +63,12 @@ public abstract class BaseService {
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
String sapApiUser = "APIADMIN@cmccoltdD:1234567";
|
|
|
String authorizationStr = stringBuilder.append("Basic ").append(Base64Util.encodeString(sapApiUser)).toString();
|
|
|
- System.out.println("测试:"+authorizationStr);
|
|
|
-
|
|
|
+ System.out.println("测试:" + authorizationStr);
|
|
|
+
|
|
|
stringBuilder = new StringBuilder();
|
|
|
sapApiUser = "API01@cmccoltd:cmccoltd123";
|
|
|
authorizationStr = stringBuilder.append("Basic ").append(Base64Util.encodeString(sapApiUser)).toString();
|
|
|
- System.out.println("正式:"+authorizationStr);
|
|
|
+ System.out.println("正式:" + authorizationStr);
|
|
|
}
|
|
|
|
|
|
public String getPersonIds(List<SapUser> sapUsers) {
|
|
@@ -80,9 +86,9 @@ public abstract class BaseService {
|
|
|
}
|
|
|
return userIds;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static String formatPosition(String str) {
|
|
|
- if(Tools.isEmpty(str)) {
|
|
|
+ if (Tools.isEmpty(str)) {
|
|
|
return "";
|
|
|
}
|
|
|
str = str.replace("\n", "");
|
|
@@ -90,14 +96,14 @@ public abstract class BaseService {
|
|
|
}
|
|
|
|
|
|
public static String formatBusinessPhone(String str) {
|
|
|
- if(Tools.isEmpty(str)) {
|
|
|
+ if (Tools.isEmpty(str)) {
|
|
|
return "";
|
|
|
}
|
|
|
// 021 80171999 -> 021-80171999
|
|
|
- if(str.length() == 12) {
|
|
|
+ if (str.length() == 12) {
|
|
|
str = str.replace(" ", "-");
|
|
|
}
|
|
|
- if(str.indexOf("x")>-1){
|
|
|
+ if (str.indexOf("x") > -1) {
|
|
|
str = str.replace("x", "-");
|
|
|
}
|
|
|
return str;
|
|
@@ -122,7 +128,7 @@ public abstract class BaseService {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public String getUserIdList(List<String> sapUserIds) {
|
|
|
String userIds = "";
|
|
|
for (String sapUser : sapUserIds) {
|
|
@@ -130,8 +136,28 @@ public abstract class BaseService {
|
|
|
}
|
|
|
return userIds;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void throwPromptException(String msg) throws Exception {
|
|
|
throw new PromptException(msg);
|
|
|
}
|
|
|
+
|
|
|
+ public String getLabelValue(String optionId) {
|
|
|
+ if (Tools.isEmpty(optionId)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if (WebConstants.LABEL_MAP.containsKey(optionId)) {
|
|
|
+ return WebConstants.LABEL_MAP.get(optionId);
|
|
|
+ } else {
|
|
|
+ String value = "";
|
|
|
+ try {
|
|
|
+ String url = "https://api15.sapsf.cn/odata/v2/PicklistLabel(locale='zh_CN',optionId=" + optionId
|
|
|
+ + ")?$format=json";
|
|
|
+ JsonNode node = requestService.getForObject(url, getHttpHeaders());
|
|
|
+ value = JsonNodeUtil.getValue(node, "d", "label");
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ WebConstants.LABEL_MAP.put(optionId, value);
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|