Commit 08a4cb3b authored by jiaorz's avatar jiaorz

Merge branch 'master-background-bug' into dev

parents 11da718f 6e5144da
......@@ -6,7 +6,7 @@ import com.github.wxiaoqi.security.common.exception.auth.ClientTokenException;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.exception.auth.UserTokenException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.util.HttpRequestUtil;
import com.github.wxiaoqi.security.common.util.HttpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
......@@ -21,6 +21,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import static org.springframework.http.HttpStatus.NOT_EXTENDED;
......@@ -69,7 +71,15 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
if(0 == ex.getStatus()) {
response.setStatus(500);
}
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.getStackTrace().toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", ex.getMessage());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception e) {
logger.error(e.getMessage());
}
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
......@@ -82,10 +92,26 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
StringWriter stringWriter = new StringWriter();
cause.printStackTrace(new PrintWriter(stringWriter));
logger.error(cause.getMessage(), ex);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + stringWriter.toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", stringWriter.toString());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception e) {
logger.error(e.getMessage());
}
return new BaseResponse(5000, "Server exception: " + ex.getMessage());
}
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.getStackTrace().toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", ex.getMessage());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception e) {
logger.error(e.getMessage());
}
return new BaseResponse(CommonConstants.EX_OTHER_CODE, ex.getMessage());
}
}
......@@ -4,7 +4,7 @@ package com.github.wxiaoqi.security.common.handler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HttpRequestUtil;
import com.github.wxiaoqi.security.common.util.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
......@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
@RestControllerAdvice("com.xxfc.platform")
@Slf4j
......@@ -35,11 +37,27 @@ public class PlatformExceptionHandler {
StringWriter stringWriter = new StringWriter();
cause.printStackTrace(new PrintWriter(stringWriter));
log.error(cause.getMessage(), e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + stringWriter.toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", stringWriter.toString());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception ex) {
log.error(ex.getMessage());
}
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
log.error("Server exception: ", e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + e.getStackTrace().toString());
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", e.getMessage());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception ex) {
log.error(ex.getMessage());
}
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
......
package com.github.wxiaoqi.security.common.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.net.URLDecoder;
@Slf4j
public class HttpRequestUtil {
/**
* post请求
* @param url url地址
* @return
*/
public static String httpPost(String url){
//post请求返回结果
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost method = new HttpPost(url);
String str = "";
try {
HttpResponse result = httpClient.execute(method);
url = URLDecoder.decode(url, "UTF-8");
/**请求发送成功,并得到响应**/
if (result.getStatusLine().getStatusCode() == 200) {
try {
/**读取服务器返回过来的json字符串数据**/
str = EntityUtils.toString(result.getEntity(),"UTF-8");
} catch (Exception e) {
log.error("post请求提交失败:" + url, e);
}
}
} catch (IOException e) {
log.error("post请求提交失败:" + url, e);
}
return str;
}
/**
* 发送get请求
* @param url 路径
* @return
*/
public static String httpGet(String url){
//get请求返回结果
String strResult = null;
try {
DefaultHttpClient client = new DefaultHttpClient();
//发送get请求
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
/**请求发送成功,并得到响应**/
if (response.getStatusLine().getStatusCode() == org.apache.http.HttpStatus.SC_OK) {
/**读取服务器返回过来的json字符串数据**/
strResult = EntityUtils.toString(response.getEntity(),"UTF-8");
} else {
log.error("get请求提交失败:" + url);
}
} catch (IOException e) {
log.error("get请求提交失败:" + url, e);
}
return strResult;
}
}
......@@ -251,7 +251,6 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
}
Vehicle vehicle = null;
RestResponse<Vehicle> vehicleRestResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
log.info("获取车辆信息返回消息:{}", vehicleRestResponse.getMessage());
if (vehicleRestResponse.getData() != null) {
vehicle = vehicleRestResponse.getData();
} else {
......@@ -289,13 +288,13 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
vehicleDepartureVo.setCheckMan(checkUserInfoDto.getUsername());
vehicleDepartureVo.setCheckManTel(checkUserInfoDto.getTelephone());
}
log.info("小程序订单出车: " + vehicleDepartureVo.toString());
try {
RestResponse restResponse = vehicleFeign.departureBySmall(vehicleDepartureVo);
if (restResponse.getStatus() != 200) {
return ObjectRestResponse.createFailedResult(1001, restResponse.getMessage());
}
log.error("返回信息: " + restResponse.toString());
log.info("小程序订单出车成功: " + restResponse.getCode() + restResponse.getMessage());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(1001, e.getMessage());
}
......@@ -309,12 +308,13 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
vehicleArrivalVo.setRecycleManTel(checkUserInfoDto.getTelephone());
}
vehicleArrivalVo.setBookRecordId(orderRentVehicleDetail.getBookRecordId());
log.info("小程序订单还车: " + vehicleArrivalVo.toString());
try {
RestResponse restResponse = vehicleFeign.arrivalBySmall(vehicleArrivalVo);
if (restResponse.getStatus() != 200) {
return ObjectRestResponse.createFailedResult(1001, restResponse.getMessage());
}
log.error("返回信息: " + restResponse.toString());
log.info("小程序订单还车成功: " + restResponse.getCode() + restResponse.getMessage());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(500, e.getMessage());
}
......
......@@ -2,7 +2,7 @@ package com.xxfc.platform.universal.controller;
import com.xxfc.platform.universal.biz.MailServiceBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -13,7 +13,7 @@ public class EmailSendController {
@Autowired
MailServiceBiz mailServiceBiz;
@GetMapping(value = "/app/unauth/send")
@PostMapping(value = "/app/unauth/send")
public void senEmail(String toUser, String subject, String content) {
mailServiceBiz.run(toUser, subject, content);
}
......
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