配置文件修改取值方式

feature-LeeD-20221025
李栋 2 years ago
parent ba69494d15
commit 07435a0b2f

@ -7,6 +7,7 @@ import com.engine.ditoSsologin.service.MobileSsoLoginService;
import org.apache.commons.lang3.StringUtils;
import weaver.general.BaseBean;
import weaver.hrm.User;
import weaver.interfaces.comInfo.PropBean;
import weaver.interfaces.util.HttpUtils;
import java.io.IOException;
@ -36,7 +37,7 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
return dataMap;
}
//请求链接地址
String userAccessTokenUrl = baseBean.getPropValue("weaverssologin", "userAccessTokenUrl");
String userAccessTokenUrl = PropBean.getUfPropValue("userAccessTokenUrl");
dataMap.put("api_status", false);
try {
String authCode = (String) paramMap.get("auth_code");
@ -88,7 +89,8 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
baseBean.writeLog("accessToken:" + accessToken);
// String userAccessToken = (String) Util_DataCache.getObjVal(SSO_LOGIN_USER_ACCESS_TOKEN + user.getLoginid());
//请求链接地址
String userInfoUrl = baseBean.getPropValue("weaverssologin", "userInfoUrl");
String userInfoUrl = PropBean.getUfPropValue("userInfoUrl");
// String userInfoUrl = baseBean.getPropValue("weaverssologin", "userInfoUrl");
dataMap.put("api_status", false);
HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put("auth_code", authCode);
@ -125,9 +127,13 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
return dataMap;
}
//请求链接地址
String accessTokenUrl = baseBean.getPropValue("weaverssologin", "accessTokenUrl");
String appKey = baseBean.getPropValue("weaverssologin", "appKey");
String appSecret = baseBean.getPropValue("weaverssologin", "appSecret");
String accessTokenUrl = PropBean.getUfPropValue("accessTokenUrl");
String appKey = PropBean.getUfPropValue("appKey");
String appSecret = PropBean.getUfPropValue("appSecret");
// String accessTokenUrl = baseBean.getPropValue("weaverssologin", "accessTokenUrl");
// String appKey = baseBean.getPropValue("weaverssologin", "appKey");
// String appSecret = baseBean.getPropValue("weaverssologin", "appSecret");
dataMap.put("api_status", false);
try {
HashMap<String, Object> requestMap = new HashMap<>();

@ -10,6 +10,7 @@ import weaver.conn.util.IdGenerator;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.comInfo.PropBean;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.interfaces.util.HttpUtils;
@ -38,16 +39,24 @@ public class WorkflowSyncCronJob extends BaseCronJob {
bb.writeLog("WorkflowSyncCronJob start");
try {
//推送流程url
String synchronizeFlowUrl = bb.getPropValue("PORTAL_INFO", "synchronizeFlowUrl");
String synchronizeFlowUrl = PropBean.getUfPropValue("synchronizeFlowUrl");
// String synchronizeFlowUrl = bb.getPropValue("PORTAL_INFO", "synchronizeFlowUrl");
//同步人员权限url
String synchronizeUserUrl = bb.getPropValue("PORTAL_INFO", "synchronizeUserUrl");
String synchronizeUserUrl = PropBean.getUfPropValue("synchronizeUserUrl");
// String synchronizeUserUrl = bb.getPropValue("PORTAL_INFO", "synchronizeUserUrl");
//新建流程推送到目录code
String center = bb.getPropValue("PORTAL_INFO", "newWorkflowCenter");
String workflowAuthTable = bb.getPropValue("PORTAL_INFO", "workflowAuthTable");
String timeNodeTable = bb.getPropValue("PORTAL_INFO", "timeNodeTable");
String accountName = bb.getPropValue("PORTAL_INFO", "username");
String password = bb.getPropValue("PORTAL_INFO", "passwd");
String timeNodeFormModeId = bb.getPropValue("PORTAL_INFO", "timeNodeFormModeId");
String center = PropBean.getUfPropValue("newWorkflowCenter");
String workflowAuthTable = PropBean.getUfPropValue("workflowAuthTable");
String timeNodeTable = PropBean.getUfPropValue("timeNodeTable");
String accountName = PropBean.getUfPropValue("username");
String password = PropBean.getUfPropValue("passwd");
String timeNodeFormModeId = PropBean.getUfPropValue("timeNodeFormModeId");
// String center = bb.getPropValue("PORTAL_INFO", "newWorkflowCenter");
// String workflowAuthTable = bb.getPropValue("PORTAL_INFO", "workflowAuthTable");
// String timeNodeTable = bb.getPropValue("PORTAL_INFO", "timeNodeTable");
// String accountName = bb.getPropValue("PORTAL_INFO", "username");
// String password = bb.getPropValue("PORTAL_INFO", "passwd");
// String timeNodeFormModeId = bb.getPropValue("PORTAL_INFO", "timeNodeFormModeId");
//全量同步使用全量同步方法
if (SYNC_ALL.equals(syncType)) {
bb.writeLog("WorkflowSyncCronJob ALL start");

@ -1,148 +0,0 @@
package weaver.interfaces.util;
/**
* @version 1.0
* @Title ecology-9
* @Company
* @CreateDate 2022/11/16
* @Description ${description}
* @Author Lee
*/
import com.alibaba.fastjson.JSONObject;
import com.customization.sendtodo.HttpRequestUtil;
import org.apache.commons.collections.MapUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.*;
import java.net.*;
import java.util.HashMap;
import java.util.Map;
public class HttpUtils2 {
public static void main(String[] args) throws IOException {
HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put("appKey", "2022111517310001-0m7929Wan81B7");
requestMap.put("appSecret", "f2blp7rpMb1iZbeb7Xv3eu6TtxbACW");
// requestMap.put("appKey", "D20220926160400001-4t08Rhu3l94");
// requestMap.put("appSecret", "080Jc0z4Bi0afVv93802e8UmHR2lVq");
// JSONObject jsonObject = new JSONObject(requestMap);
// String jsonString = JSONObject.toJSONString(requestMap);
// System.out.println(jsonString);
String s = HttpUtils.ssoLoginDoPost("https://sapp-test-idito.dito.ph:30443/open-apis/auth/v1/oauth/app_access_token", requestMap);
// String s = HttpUtils.ssoLoginDoPost("http://10.10.178.100/open-apis/auth/v1/oauth/app_access_token", requestMap);
System.out.println(s);
// String s = HttpRequestUtil.doPostByAuth("https://10.10.178.100/open-apis/auth/v1/oauth/app_access_token", jsonObject.toString(), null);
// System.out.println(s);
}
/**
* URL GET
*
* @param url URL
* @param param name1=value1&name2=value2
* @return
*/
public static String doGet(String url, String param) {
StringBuilder result = new StringBuilder();
BufferedReader in = null;
String urlNameString = url;
try {
if (param != null || param != "") {
urlNameString = urlNameString + "?" + param;
}
URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.connect();
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result.append(line);
}
} catch (ConnectException e) {
e.printStackTrace();
} catch (SocketTimeoutException | ConnectTimeoutException e) {
e.printStackTrace();
//SocketTimeoutException是Java包下抛出的异常这定义了Socket读数据的超时时间即从server获取响应数据须要等待的时间当读取或者接收Socket超时会抛出SocketTimeoutException
System.out.println("sendGet SocketTimeoutException, url=" + url + ",param=" + param);
} catch (IOException e) {
e.printStackTrace();
System.out.println("sendGet IOException, url=" + url + ",param=" + param);
} catch (Exception e) {
e.printStackTrace();
System.out.println("sendGet Exception, url=" + url + ",param=" + param);
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("sendGet Exception, url=" + url + ",param=" + param);
}
}
return result.toString();
}
/**
* post
*
* @param path url
* @param Info jsonobject
* @return
* @throws IOException
*/
public static String doPost(String path, JSONObject Info, Map<String, String> headers) throws IOException {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(path);
post.setHeader("Content-Type", "application/json");
if (MapUtils.isNotEmpty(headers)) {
for (String key : headers.keySet()) {
post.addHeader(key, headers.get(key));
}
}
String result = "";
try {
StringEntity s = new StringEntity(Info.toString(), "utf-8");
s.setContentEncoding("application/json");
post.setEntity(s);
// 发送请求
HttpResponse httpResponse = client.execute(post);
// 获取响应输入流
InputStream inStream = httpResponse.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "utf-8"));
StringBuilder strber = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
strber.append(line + "\n");
}
inStream.close();
result = strber.toString();
} catch (Exception e) {
System.out.println("请求异常");
throw new RuntimeException(e);
}
return result;
}
}
Loading…
Cancel
Save