#EC-HJ-17# 去掉日志输出

feature-LeeD-20221025
shilei 3 years ago
parent 3c03a68f26
commit f61db4f586

@ -34,16 +34,17 @@ public class HttpReqUtils extends BaseBean{
.build();
try {
Response response = client.newCall(request).execute();
bb.writeLog("response.code():"+response.code());
bb.writeLog("response.body():"+response.body().string());
if(response!=null && response.code() == 200){
msgData = response.body().string();
int code = response.code();
String bodyMsg = msgData = response.body().string();
bb.writeLog("response.code():"+code);
bb.writeLog("response.body():"+bodyMsg);
if(code == 200){
msgData = bodyMsg;
}
} catch (IOException e) {
e.printStackTrace();
}
bb.writeLog("msgData:"+msgData);
return msgData;
}

@ -36,15 +36,17 @@ public class HttpRequestUtil extends BaseBean{
try {
Response response = client.newCall(request).execute();
bb.writeLog("response.code():"+response.code());
bb.writeLog("response.body():"+response.body().string());
if(response!=null && response.code() == 200){
msgData = response.body().string();
int code = response.code();
String bodyMsg = msgData = response.body().string();
bb.writeLog("response.code():"+code);
bb.writeLog("response.body():"+bodyMsg);
if(code == 200){
msgData = bodyMsg;
}
} catch (IOException e) {
e.printStackTrace();
}
bb.writeLog("msgData:"+msgData);
return msgData;
}

@ -2,6 +2,7 @@ package com.customization.sendtodo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
@ -12,8 +13,8 @@ import java.util.regex.Pattern;
public class SendPortalTodoUtil {
public static String EMAIL_REGEX_DEFAULT = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
//public static String EMAIL_REGEX_DEFAULT = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
public static String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
/***
*
* @param requestId
@ -117,32 +118,34 @@ public class SendPortalTodoUtil {
requestObject.put("taskObjectList",taskObjectList);
String email = Util.null2String(rs.getString("email")) ;
bb.writeLog("email1:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
}
}
bb.writeLog("dataJsonnew:"+requestObject.toJSONString());
//bb.writeLog("dataJsonnew:"+requestObject.toJSONString());
// String username = "admin";
// String passwd = "Uportal_123";
// String todourl = "http://172.16.25.133/portal-web/centerTodo/sync" ;
String auth = username + ":" + passwd;
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
bb.writeLog("msgdata:"+msgdata);
if(!"".equals(msgdata)){
if(StringUtils.isNotEmpty(msgdata)){
JSONObject msgObject = JSONObject.parseObject(msgdata);
//{"resultCode":"1","resultMsg":"No Result"}
if(msgObject.containsKey("resultCode")){
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
System.out.println(emailArray.toJSONString());
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestId,emailArray.toJSONString(),notificationSubject,notificationContent);
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
{
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestId,emailArray.toJSONString(),notificationSubject,notificationContent);
}
}else{
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();
@ -265,6 +268,7 @@ public class SendPortalTodoUtil {
taskObjectList.add(taskObject);
String email = Util.null2String(rs.getString("email")) ;
bb.writeLog("email2:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
@ -274,7 +278,7 @@ public class SendPortalTodoUtil {
requestObject.put("taskObjectList",taskObjectList);
String auth = username + ":" + passwd;
bb.writeLog("requestObject:"+requestObject.toJSONString());
//bb.writeLog("requestObject:"+requestObject.toJSONString());
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
bb.writeLog("msgdata:"+msgdata);
if(!"".equals(msgdata)){
@ -284,12 +288,13 @@ public class SendPortalTodoUtil {
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
System.out.println(emailArray.toJSONString());
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray.toJSONString(),notificationSubject,notificationContent);
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
{
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray.toJSONString(),notificationSubject,notificationContent);
}
}else{
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();
}
@ -483,6 +488,7 @@ public class SendPortalTodoUtil {
taskObjectList.add(taskObject);
String email = Util.null2String(rs.getString("email")) ;
bb.writeLog("email3:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
@ -492,7 +498,7 @@ public class SendPortalTodoUtil {
}
String auth = username + ":" + passwd;
bb.writeLog("requestObject:"+requestObject.toJSONString());
//bb.writeLog("requestObject:"+requestObject.toJSONString());
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
bb.writeLog("msgdata:"+msgdata);
if(!"".equals(msgdata)){
@ -502,10 +508,14 @@ public class SendPortalTodoUtil {
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
System.out.println(emailArray.toJSONString());
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray.toJSONString(),notificationSubject,notificationContent);
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
{
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray.toJSONString(),notificationSubject,notificationContent);
}
}else{
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();
@ -615,7 +625,6 @@ public class SendPortalTodoUtil {
JSONObject taskObject = new JSONObject();
String objectCode = usercode ;
String operatorCode = usercode ;
taskObject.put("objectAction",objectAction);
@ -626,6 +635,7 @@ public class SendPortalTodoUtil {
taskObjectList.add(taskObject);
String email = Util.null2String(rs.getString("email")) ;
bb.writeLog("email4:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
@ -636,7 +646,7 @@ public class SendPortalTodoUtil {
requestObject.put("taskObjectList",taskObjectList);
String auth = username + ":" + passwd;
bb.writeLog("requestObject:"+requestObject.toJSONString());
//bb.writeLog("requestObject:"+requestObject.toJSONString());
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
bb.writeLog("msgdata:"+msgdata);
if(!"".equals(msgdata)){
@ -646,13 +656,13 @@ public class SendPortalTodoUtil {
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
System.out.println(emailArray.toJSONString());
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray.toJSONString(),notificationSubject,notificationContent);
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
{
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
sendMailUtil.sendMail(requestid,emailArray.toJSONString(),notificationSubject,notificationContent);
}
}else{
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();
}

@ -33,52 +33,52 @@ public class HttpRequestUtil extends BaseBean{
* @throws ParseException
* @throws IOException
*/
public String sendPost(String url, Map<String,String> headers,String encoding){
String body = "";
BaseBean bb = new BaseBean();
bb.writeLog("url ==" + url);
//创建httpclient对象
CloseableHttpClient client = HttpClients.createDefault();
//创建post方式请求对象
HttpPost httpPost = new HttpPost(url);
//设置参数到请求对象中
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
bb.writeLog("key:"+entry.getKey());
bb.writeLog("val:"+entry.getValue());
httpPost.addHeader(entry.getKey(),entry.getValue());
}
}
//设置header信息
//指定报文头【Content-type】、【User-Agent】
// httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//执行请求操作,并拿到结果(同步阻塞)
CloseableHttpResponse response = null;
try {
response = client.execute(httpPost);
bb.writeLog(response.getStatusLine().getStatusCode());
//获取结果实体
HttpEntity entity = response.getEntity();
if (entity != null) {
//按指定编码转换结果实体为String类型
body = EntityUtils.toString(entity, encoding);
}
EntityUtils.consume(entity);
//释放链接
response.close();
} catch (IOException e) {
e.printStackTrace();
bb.writeLog("e:"+e);
}
return body;
}
// public String sendPost(String url, Map<String,String> headers,String encoding){
// String body = "";
//
// BaseBean bb = new BaseBean();
// bb.writeLog("url ==" + url);
//
// //创建httpclient对象
// CloseableHttpClient client = HttpClients.createDefault();
// //创建post方式请求对象
// HttpPost httpPost = new HttpPost(url);
//
// //设置参数到请求对象中
// if (headers != null && headers.size() > 0) {
// for (Map.Entry<String, String> entry : headers.entrySet()) {
// bb.writeLog("key:"+entry.getKey());
// bb.writeLog("val:"+entry.getValue());
// httpPost.addHeader(entry.getKey(),entry.getValue());
// }
// }
//
// //设置header信息
// //指定报文头【Content-type】、【User-Agent】
//// httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//
// //执行请求操作,并拿到结果(同步阻塞)
// CloseableHttpResponse response = null;
// try {
//
// response = client.execute(httpPost);
// bb.writeLog(response.getStatusLine().getStatusCode());
// //获取结果实体
// HttpEntity entity = response.getEntity();
// if (entity != null) {
// //按指定编码转换结果实体为String类型
// body = EntityUtils.toString(entity, encoding);
// }
// EntityUtils.consume(entity);
// //释放链接
// response.close();
// } catch (IOException e) {
// e.printStackTrace();
// bb.writeLog("e:"+e);
// }
//
// return body;
// }
/**
@ -89,69 +89,69 @@ public class HttpRequestUtil extends BaseBean{
* name1=value1&name2=value2
* @return result
*/
public String sendGet(String url, Map<String,String> headers,String uid) {
String result = "";
BufferedReader in = null;
BaseBean bb = new BaseBean();
bb.writeLog("url ==" + url);
bb.writeLog("uid ==" + uid);
try {
String urlNameString = url ;
URL realUrl = new URL(urlNameString); // 打开和URL之间的连接
HttpURLConnection connection= (HttpURLConnection) 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.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestMethod("GET");
//connection.addRequestProperty("Cookie", "SESSION="+uid);
if (headers != null && headers.size() > 0)
{
for (Map.Entry<String, String> entry : headers.entrySet()) {
bb.writeLog("key:"+entry.getKey());
bb.writeLog("val:"+entry.getValue());
connection.addRequestProperty(entry.getKey(), entry.getValue());
}
}
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
//Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
//for (String key : map.keySet()) {
// System.out.println(key + "--->" + map.get(key));
//}
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream(),"UTF-8"));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
bb.writeLog("发送GET请求出现异常" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
// public String sendGet(String url, Map<String,String> headers,String uid) {
// String result = "";
// BufferedReader in = null;
//
// BaseBean bb = new BaseBean();
// bb.writeLog("url ==" + url);
// bb.writeLog("uid ==" + uid);
// try {
// String urlNameString = url ;
// URL realUrl = new URL(urlNameString); // 打开和URL之间的连接
// HttpURLConnection connection= (HttpURLConnection) 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.setDoOutput(true);
// connection.setDoInput(true);
// connection.setUseCaches(false);
// connection.setRequestMethod("GET");
//
// //connection.addRequestProperty("Cookie", "SESSION="+uid);
//
// if (headers != null && headers.size() > 0)
// {
// for (Map.Entry<String, String> entry : headers.entrySet()) {
// bb.writeLog("key:"+entry.getKey());
// bb.writeLog("val:"+entry.getValue());
// connection.addRequestProperty(entry.getKey(), entry.getValue());
// }
// }
//
// // 建立实际的连接
// connection.connect();
// // 获取所有响应头字段
// //Map<String, List<String>> map = connection.getHeaderFields();
// // 遍历所有的响应头字段
// //for (String key : map.keySet()) {
// // System.out.println(key + "--->" + map.get(key));
// //}
// // 定义 BufferedReader输入流来读取URL的响应
// in = new BufferedReader(new InputStreamReader(
// connection.getInputStream(),"UTF-8"));
// String line;
// while ((line = in.readLine()) != null) {
// result += line;
// }
// } catch (Exception e) {
// bb.writeLog("发送GET请求出现异常" + e);
// e.printStackTrace();
// }
// // 使用finally块来关闭输入流
// finally {
// try {
// if (in != null) {
// in.close();
// }
// } catch (Exception e2) {
// e2.printStackTrace();
// }
// }
//
// return result;
// }
/***
@ -164,7 +164,7 @@ public class HttpRequestUtil extends BaseBean{
public String httpGet1(String url, Map<String,String> headers, String encode){
BaseBean bb = new BaseBean();
bb.writeLog("url",url);
//bb.writeLog("url",url);
if(encode == null){
encode = "UTF-8";
}
@ -187,7 +187,7 @@ public class HttpRequestUtil extends BaseBean{
httpResponse = closeableHttpClient.execute(httpGet);
if(httpResponse.getStatusLine().getStatusCode() == 200){
bb.writeLog(httpResponse.getStatusLine().getStatusCode());
//bb.writeLog(httpResponse.getStatusLine().getStatusCode());
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
}
@ -217,58 +217,58 @@ public class HttpRequestUtil extends BaseBean{
* @param encode
* @return
*/
public String httpGet2(String url,Map<String,String> headers,String encode)
{
BaseBean bb = new BaseBean();
bb.writeLog("url",url);
if(encode == null){
encode = "UTF-8";
}
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
String content = null;
//since 4.3 不再使用 DefaultHttpClient
try {
closeableHttpClient = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet(url);
//设置header
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
bb.writeLog("key:"+entry.getKey());
bb.writeLog("val:"+entry.getValue());
httpGet.addHeader(entry.getKey(),entry.getValue());
}
}
httpGet.setHeader("Accept", "*");
httpResponse = closeableHttpClient.execute(httpGet);
if(httpResponse.getStatusLine().getStatusCode() == 200)
{
bb.writeLog(httpResponse.getStatusLine().getStatusCode());
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
}
} catch (Exception e) {
e.printStackTrace();
bb.writeLog("er333:"+e);
}finally{
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
// public String httpGet2(String url,Map<String,String> headers,String encode)
// {
//
// BaseBean bb = new BaseBean();
// bb.writeLog("url",url);
// if(encode == null){
// encode = "UTF-8";
// }
// CloseableHttpResponse httpResponse = null;
// CloseableHttpClient closeableHttpClient = null;
// String content = null;
// //since 4.3 不再使用 DefaultHttpClient
// try {
// closeableHttpClient = HttpClientBuilder.create().build();
// HttpGet httpGet = new HttpGet(url);
// //设置header
// if (headers != null && headers.size() > 0) {
// for (Map.Entry<String, String> entry : headers.entrySet()) {
//
// bb.writeLog("key:"+entry.getKey());
// bb.writeLog("val:"+entry.getValue());
//
// httpGet.addHeader(entry.getKey(),entry.getValue());
// }
// }
//
// httpGet.setHeader("Accept", "*");
//
// httpResponse = closeableHttpClient.execute(httpGet);
// if(httpResponse.getStatusLine().getStatusCode() == 200)
// {
// bb.writeLog(httpResponse.getStatusLine().getStatusCode());
// HttpEntity entity = httpResponse.getEntity();
// content = EntityUtils.toString(entity, encode);
// }
// } catch (Exception e) {
// e.printStackTrace();
// bb.writeLog("er333:"+e);
// }finally{
// try {
// httpResponse.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// try { //关闭连接、释放资源
// closeableHttpClient.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// return content;
// }
/***
*
@ -276,37 +276,37 @@ public class HttpRequestUtil extends BaseBean{
* @param jsonstr
* @return
*/
public static String doPostByAuth(String url,String jsonstr,String auth){
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try{
String authStr = new String(Base64.encode(auth));
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
// String head_param_encode = urlEncode(head_param);
System.out.println("authStr:"+authStr);
httpPost.addHeader("Connection", "Keep-Alive");
httpPost.addHeader("Cache-Control", "No-Cache");
httpPost.addHeader("Accept", "*/*");
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
httpPost.addHeader("Authorization", "Basic " + authStr);
httpPost.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
StringEntity se = new StringEntity(jsonstr);
se.setContentType("application/json;charset=utf-8");
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if(response != null){
HttpEntity resEntity = response.getEntity();
if(resEntity != null){
result = EntityUtils.toString(resEntity,"utf-8");
}
}
}catch(Exception ex){
ex.printStackTrace();
}
return result;
}
// public static String doPostByAuth(String url,String jsonstr,String auth){
// CloseableHttpClient httpClient = null;
// HttpPost httpPost = null;
// String result = null;
// try{
// String authStr = new String(Base64.encode(auth));
// httpClient = HttpClients.createDefault();
// httpPost = new HttpPost(url);
//// String head_param_encode = urlEncode(head_param);
// System.out.println("authStr:"+authStr);
// httpPost.addHeader("Connection", "Keep-Alive");
// httpPost.addHeader("Cache-Control", "No-Cache");
// httpPost.addHeader("Accept", "*/*");
// httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
// httpPost.addHeader("Authorization", "Basic " + authStr);
// httpPost.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
// StringEntity se = new StringEntity(jsonstr);
// se.setContentType("application/json;charset=utf-8");
// httpPost.setEntity(se);
// HttpResponse response = httpClient.execute(httpPost);
// if(response != null){
// HttpEntity resEntity = response.getEntity();
// if(resEntity != null){
// result = EntityUtils.toString(resEntity,"utf-8");
// }
// }
// }catch(Exception ex){
// ex.printStackTrace();
// }
// return result;
// }
// public static String urlEncode(String url) throws UnsupportedEncodingException {
@ -327,29 +327,29 @@ public class HttpRequestUtil extends BaseBean{
// }
public String doPostByAuth2(String dataJson){
BaseBean bb = new BaseBean();
String msgData = "" ;
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, dataJson);
Request request = new Request.Builder()
.url("http://172.16.25.133/portal-web/centerTodo/sync")
.method("POST", body)
.addHeader("Authorization", "Basic YWRtaW46VXBvcnRhbF8xMjM=")
.addHeader("Content-Type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
bb.writeLog("response.code():"+response.code());
bb.writeLog("response.body():"+response.body().string());
msgData = response.body().string();
} catch (IOException e) {
e.printStackTrace();
}
return msgData;
}
// public String doPostByAuth2(String dataJson){
// BaseBean bb = new BaseBean();
// String msgData = "" ;
// OkHttpClient client = new OkHttpClient().newBuilder()
// .build();
// MediaType mediaType = MediaType.parse("application/json");
// RequestBody body = RequestBody.create(mediaType, dataJson);
// Request request = new Request.Builder()
// .url("http://172.16.25.133/portal-web/centerTodo/sync")
// .method("POST", body)
// .addHeader("Authorization", "Basic YWRtaW46VXBvcnRhbF8xMjM=")
// .addHeader("Content-Type", "application/json")
// .build();
// try {
// Response response = client.newCall(request).execute();
// bb.writeLog("response.code():"+response.code());
// bb.writeLog("response.body():"+response.body().string());
//
// msgData = response.body().string();
// } catch (IOException e) {
// e.printStackTrace();
// }
// return msgData;
// }
}

@ -41,10 +41,10 @@ public class PortalLoginBeforeFilter implements Filter {
boolean isExcludedPage = false;
String requestURL = request.getRequestURL().toString();
bb.writeLog("bpmHostList:" + bpmHostList.size());
//bb.writeLog("bpmHostList:" + bpmHostList.size());
if (!bpmHostList.isEmpty()) {
for (String bpm_host_val : bpmHostList) {
bb.writeLog("bpm_host_val:" + bpm_host_val);
//bb.writeLog("bpm_host_val:" + bpm_host_val);
if (requestURL.contains(bpm_host_val)) {
isExcludedPage = true;
}
@ -61,7 +61,7 @@ public class PortalLoginBeforeFilter implements Filter {
}
}
bb.writeLog("getRequestURI:" + getRequestURI + " isExcludedPage:" + isExcludedPage);
//bb.writeLog("getRequestURI:" + getRequestURI + " isExcludedPage:" + isExcludedPage);
if (!isExcludedPage) {
User loginuser = (User) request.getSession(true).getAttribute("weaver_user@bean");
@ -91,7 +91,7 @@ public class PortalLoginBeforeFilter implements Filter {
if (StringUtils.isNotEmpty(uid)) {
String url = bb.getPropValue("PORTAL_INFO", "portal_user_auth");
//String url = "http://172.16.25.133/portal-web/user/current" ;
bb.writeLog("url:" + url);
//bb.writeLog("url:" + url);
HttpRequestUtil HttpRequestUtil = new HttpRequestUtil();
Map<String, String> headMap = new HashMap<String, String>();
@ -111,7 +111,7 @@ public class PortalLoginBeforeFilter implements Filter {
} else {
sql = " select * from HrmResource where loginid =? ";
}
bb.writeLog("sql:" + sql);
//bb.writeLog("sql:" + sql);
rs.executeQuery(sql, new Object[]{staffCode});
if (rs.next()) {
user_new = new User();
@ -184,7 +184,7 @@ public class PortalLoginBeforeFilter implements Filter {
if (StringUtils.isNotEmpty(uid)) {
String url = bb.getPropValue("PORTAL_INFO", "portal_user_auth");
//String url = "http://172.16.25.133/portal-web/user/current" ;
bb.writeLog("url:" + url);
//bb.writeLog("url:" + url);
HttpRequestUtil HttpRequestUtil = new HttpRequestUtil();
Map<String, String> headMap = new HashMap<String, String>();

@ -133,11 +133,11 @@ public class PortalLoginFilter implements Filter
if(!isExcludedPage)
{
bb.writeLog("getRequestURI:"+getRequestURI+" isExcludedPage:"+isExcludedPage);
//bb.writeLog("getRequestURI:"+getRequestURI+" isExcludedPage:"+isExcludedPage);
User loginuser = (User) request.getSession(true).getAttribute("weaver_user@bean");
if (loginuser == null)
{
bb.writeLog("loginuser is null");
//bb.writeLog("loginuser is null");
String uid = "" ;
String cookies = request.getHeader("cookie");
if(!"".equals(cookies))
@ -165,7 +165,7 @@ public class PortalLoginFilter implements Filter
if(StringUtils.isNotEmpty(uid))
{
bb.writeLog("portal_user_auth:"+portal_user_auth);
//bb.writeLog("portal_user_auth:"+portal_user_auth);
//String url = "http://172.16.25.133/portal-web/user/current" ;
HttpRequestUtil HttpRequestUtil = new HttpRequestUtil();
Map<String,String> headMap = new HashMap<String,String>();
@ -188,7 +188,7 @@ public class PortalLoginFilter implements Filter
}else{
sql = " select * from HrmResource where loginid =? ";
}
bb.writeLog("sql:"+sql);
//bb.writeLog("sql:"+sql);
rs.executeQuery(sql,new Object[]{staffCode});
if(rs.next()){
user_new = new User();
@ -271,7 +271,7 @@ public class PortalLoginFilter implements Filter
}
}else{
bb.writeLog("uid-- is null");
//bb.writeLog("uid-- is null");
response.setHeader("Access-Control-Allow-Origin", "*"); //解决跨域访问报错
response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600"); //设置过期时间

@ -16,7 +16,7 @@ public class SendMailUtil{
String emailenable = baseBean.getPropValue("PORTAL_INFO","emailenable");
public void sendMail(String requestid,String emails,String notificationSubject,String notificationContent){
baseBean.writeLog("emailenable:"+emailenable);
if(!"1".equals(emailenable)){
return;
}
@ -40,6 +40,7 @@ public class SendMailUtil{
try{
String responseData = doGetAccessToken();
baseBean.writeLog("responseData:"+responseData);
String accessToken = "" ;
if(StringUtils.isNotEmpty(responseData)){
JSONObject responseObject = JSONObject.parseObject(responseData);
@ -63,7 +64,7 @@ public class SendMailUtil{
jsonObject.put("content",requestJson);
// "{\r\n \"access_token\": \"\",\r\n \"method\": \"sendNotification\",\r\n \"version\": \"1.0\",\r\n \"content\": {\"eventCode\":\"\", \r\n \"transId\":\"\", \r\n \"triggerTime\":\"20221020094013\",\r\n \"notificationType\":\"EMAIL\",\r\n \"email\":\"798989044@qq.com\", \r\n \"channel\":\"OA\", \r\n \"notificationSubject\":\"新待办到达\",\r\n \"notificationContent\":\"新待办到达,清及时处理\" }\r\n}"
System.out.println(jsonObject.toJSONString());
baseBean.writeLog("jsonObject:"+jsonObject.toJSONString());
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
@ -111,14 +112,14 @@ public class SendMailUtil{
try {
// 生成签名
String sign = RSAUtils.generateSign("", emainAppCode, emailAppSecret, timestamp, emailPrivateKey);
// System.out.println("sign == " + sign);
baseBean.writeLog("sign == " + sign);
JSONObject jsonObject = new JSONObject();
jsonObject.put("appCode",emainAppCode);
jsonObject.put("appSecret",emailAppSecret);
jsonObject.put("responseType",emailResponseType);
jsonObject.put("timestamp",timestamp);
jsonObject.put("sign",sign);
System.out.println(jsonObject.toJSONString());
baseBean.writeLog("jsonObject:"+jsonObject.toJSONString());
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");

Loading…
Cancel
Save