#EC-HJ-18# 优化代码

feature-LeeD-20221025
shilei 3 years ago
parent 6031129542
commit 0ffaa7595a

@ -35,7 +35,7 @@ public class HttpReqUtils extends BaseBean{
try {
Response response = client.newCall(request).execute();
int code = response.code();
String bodyMsg = msgData = response.body().string();
String bodyMsg = response.body().string();
bb.writeLog("response.code():"+code);
bb.writeLog("response.body():"+bodyMsg);
if(code == 200){

@ -37,7 +37,7 @@ public class HttpRequestUtil extends BaseBean{
Response response = client.newCall(request).execute();
int code = response.code();
String bodyMsg = msgData = response.body().string();
String bodyMsg = response.body().string();
bb.writeLog("response.code():"+code);
bb.writeLog("response.body():"+bodyMsg);
if(code == 200){

@ -31,7 +31,7 @@ public class SendPortalTodoUtil {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
JSONArray emailArray = new JSONArray();
String emailArray = "";
String requestname = "";
String requestremark = "" ;
@ -128,7 +128,7 @@ public class SendPortalTodoUtil {
bb.writeLog("email1:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
}
}
@ -146,12 +146,12 @@ public class SendPortalTodoUtil {
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
bb.writeLog("emailArray:"+emailArray);
if(StringUtils.isNotEmpty(emailArray))
{
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);
sendMailUtil.sendMail(requestId,emailArray,notificationSubject,notificationContent);
}
}else{
@ -183,7 +183,7 @@ public class SendPortalTodoUtil {
String requestremark = "" ;
JSONObject requestObject = new JSONObject();
JSONArray emailArray = new JSONArray();
String emailArray = "";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
BaseBean bb = new BaseBean();
@ -282,7 +282,7 @@ public class SendPortalTodoUtil {
bb.writeLog("email2:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
}
}
@ -299,12 +299,12 @@ public class SendPortalTodoUtil {
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
bb.writeLog("emailArray:"+emailArray);
if(StringUtils.isNotEmpty(emailArray))
{
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);
sendMailUtil.sendMail(requestid,emailArray,notificationSubject,notificationContent);
}
}else{
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();
@ -342,7 +342,7 @@ public class SendPortalTodoUtil {
String objectId = "" ;
String requestname = "" ;
JSONArray emailArray = new JSONArray();
String emailArray = "";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
try {
@ -509,7 +509,7 @@ public class SendPortalTodoUtil {
bb.writeLog("email3:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
}
}
requestObject.put("taskObjectList",taskObjectList);
@ -526,15 +526,14 @@ public class SendPortalTodoUtil {
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
bb.writeLog("emailArray:"+emailArray);
if(StringUtils.isNotEmpty(emailArray))
{
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);
sendMailUtil.sendMail(requestid,emailArray,notificationSubject,notificationContent);
}
}else{
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();
}
@ -560,7 +559,7 @@ public class SendPortalTodoUtil {
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
JSONObject requestObject = new JSONObject();
JSONArray emailArray = new JSONArray();
String emailArray = "";
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
BaseBean bb = new BaseBean();
@ -659,9 +658,8 @@ public class SendPortalTodoUtil {
bb.writeLog("email4:"+email);
Matcher matcher = regex.matcher(email);
if(matcher.matches()){
emailArray.add(email);
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
}
}
requestObject.put("taskObjectList",taskObjectList);
@ -677,12 +675,12 @@ public class SendPortalTodoUtil {
String resultCode = msgObject.getString("resultCode");
if("0".equals(resultCode)){
bb.writeLog("emailArray:"+emailArray.toJSONString());
if(emailArray.size() > 0)
bb.writeLog("emailArray:"+emailArray);
if(StringUtils.isNotEmpty(emailArray))
{
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);
sendMailUtil.sendMail(requestid,emailArray,notificationSubject,notificationContent);
}
}else{
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();

@ -1,5 +1,6 @@
package weaver.interfaces.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import okhttp3.*;
import org.apache.commons.lang.StringUtils;
@ -17,9 +18,8 @@ public class SendMailUtil{
public void sendMail(String requestid, String emails, String notificationSubject, String notificationContent){
baseBean.writeLog("emailenable:"+emailenable);
if(!"1".equals(emailenable)){
return;
}
if("1".equals(emailenable))
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String emailUrl = baseBean.getPropValue("PORTAL_INFO","emailUrl");
String emailMethod = baseBean.getPropValue("PORTAL_INFO","emailMethod");
@ -75,12 +75,10 @@ public class SendMailUtil{
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
baseBean.writeLog("response.code():"+response.code());
baseBean.writeLog("response.body():"+response.body().string());
if(response!=null && response.code() != 200){
baseBean.writeLog(response.body().string());
}
int code = response.code();
String bodyMsg = response.body().string();
baseBean.writeLog("response.code():"+code);
baseBean.writeLog("response.body():"+bodyMsg);
}
}catch (IOException e) {
e.printStackTrace();
@ -90,12 +88,15 @@ public class SendMailUtil{
}
}
}
/***
*
* @return
*/
public String doGetAccessToken(){
baseBean.writeLog("doGetAccessToken == ");
String responseData = "" ;
RSAUtils RSAUtils = new RSAUtils();
@ -105,6 +106,8 @@ public class SendMailUtil{
String emailResponseType = baseBean.getPropValue("PORTAL_INFO","emailResponseType") ; //token
String emailPrivateKey = baseBean.getPropValue("PORTAL_INFO","emailPrivateKey") ;
baseBean.writeLog("emainAppCode == "+emainAppCode);
//String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCt49VVhOmTZVpWPK/bB/ZvpoxrpXt3c9h8DJtHq9vWLGPVMS0a2l+v4U+g8zFpq6Rb6G6nnJ+pYXmojygQhqKG6izWxEojdAF2znt6URsikGe1wRxUpUewRbZVse7Rs0jvJmGZeVZ08gC1iKogyHtHeRinnHJNxC4v/5yhkOBpR6oe4t2IutKNFhSmHdJP5bEkei5gWAZ4xi15pvcWBcUSVEQliW7qRTX9yQUdCq1KzCLEGYNfm27SzKvFpRUAXpgjfFftmB3u7pZ9qhAn/25b0h9sE90Xjwg/UNmLqxUerNNDbIrqWy0x6g/+2Q/c4OXKLk5FlkkEURoBINNDbYgdAgMBAAECggEAAsfZ6XwuoATG5QojZcVC05Y+OJp01vwrQhCRixvccBhVoFsg9YT4cr+PnmtFJwNvpWiaHGQMyZCdeWyQn3MHtlCYVvbcmKSKQXQb1WDmpi7Y+bcU1OWvt8nlmIk34HKVf/2FIgcmssgL6ts8nTmXfxUYp9WAnm28r1fPEWZXsFdGNilFxg6Vymct+5hfnXUA5OMm1RgSvYR/12F4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\n\t\"responseType\":\"token\",\r\n\t\"timestamp\":\"1592212221795\",\r\n\t\"sign\":\"LE4MPesIy8BCxOa958cQxX0cW1ObvOfCn2dDUK6AzCukcvyS6EvFMLzSBFiCgcMT1w9cYAbSIOWL2SENvpC2qxXrgtWJd6B3J1dUmL5ZBtOEGZ6ymRz7IAQraA1TG82Y0ZTgVFhOGS/TtbTjdEhurwcclWdbSPEy6uZesoQpyF7MAW+hb5Y5ioqe1ky7RE15W/gwJDONgLifUoZnXhowjsJHBJ/xCwdfQi48/wu0CX+G46C+fSYHKncGbeeg7hFyaltNWsco0ScWLB/JjKA1qZv+pPFGaWGidfoTErq7Ux8fIYH3cRjRoSNknOcawi+zjy8GMBDjxIk9lX7+Oz1wYA==\"\r\n}"
@ -130,13 +133,20 @@ public class SendMailUtil{
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
baseBean.writeLog("response.code():"+response.code());
baseBean.writeLog("response.body():"+response.body().string());
responseData = response.body().string();
int code = response.code();
String bodyMsg = response.body().string();
baseBean.writeLog("response.code():"+code);
baseBean.writeLog("response.body():"+bodyMsg);
if(code == 200){
responseData = bodyMsg;
}
} catch (IOException e) {
e.printStackTrace();
baseBean.writeLog(e);
} catch (Exception e) {
e.printStackTrace();
baseBean.writeLog(e);
}
return responseData;
}

Loading…
Cancel
Save