Commit 4fd8d2df by wubh

包活干V2.3.0-调整代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@30388 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 73d9bfbf
...@@ -8,6 +8,7 @@ import com.glsx.ordercenter.constants.ResultCodeEnum; ...@@ -8,6 +8,7 @@ import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.resp.MsResultObject; import com.glsx.ordercenter.dto.resp.MsResultObject;
import com.glsx.ordercenter.service.MsDeviceService; import com.glsx.ordercenter.service.MsDeviceService;
import com.glsx.ordercenter.utils.MsSignUtil; import com.glsx.ordercenter.utils.MsSignUtil;
import com.glsx.plat.common.utils.StringUtils;
import com.souche.api.SoucheApiException; import com.souche.api.SoucheApiException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -35,13 +36,13 @@ public class MsDeviceServiceImpl implements MsDeviceService { ...@@ -35,13 +36,13 @@ public class MsDeviceServiceImpl implements MsDeviceService {
for (String deviceNo : deviceNoList) { for (String deviceNo : deviceNoList) {
JSONObject reqData = new JSONObject(); JSONObject reqData = new JSONObject();
reqData.put("imei", deviceNo); reqData.put("imei", deviceNo);
MsResultObject checkResult = this.invokeRemoteApi(deviceCheckApi, reqData); String checkMessage = this.invokeRemoteApi(deviceCheckApi, reqData);
if (checkResult.getCode() != 200) { if (StringUtils.isNotBlank(checkMessage)) {
resultData.put(deviceNo, checkResult.getMessage()); resultData.put(deviceNo, checkMessage);
} }
} }
msResult = resultData.isEmpty() msResult = resultData.isEmpty()
? new MsResultObject(ResultCodeEnum.DSC_SUCCESS) ? new MsResultObject(ResultCodeEnum.SUCCESS)
: new MsResultObject(ResultCodeEnum.FAIL, resultData); : new MsResultObject(ResultCodeEnum.FAIL, resultData);
} catch (Exception e) { } catch (Exception e) {
log.error("==== MsDeviceService checkDevice ERROR: ", e); log.error("==== MsDeviceService checkDevice ERROR: ", e);
...@@ -58,29 +59,24 @@ public class MsDeviceServiceImpl implements MsDeviceService { ...@@ -58,29 +59,24 @@ public class MsDeviceServiceImpl implements MsDeviceService {
* @param data 请求数据 * @param data 请求数据
* @return 结果 * @return 结果
*/ */
private MsResultObject invokeRemoteApi(String api, Object data) throws SoucheApiException { private String invokeRemoteApi(String api, Object data) throws SoucheApiException {
MsResultObject msResult = new MsResultObject(); String checkMessage;
JSONObject msResp = MsSignUtil.postForObject(api, data); JSONObject msResp = MsSignUtil.postForObject(api, data);
String respCode = msResp.getString("code"); Integer respCode = msResp.getInteger("code");
Integer respStatus = msResp.getInteger("status"); Integer respStatus = msResp.getInteger("status");
String respMsg = msResp.getString("message"); String respMsg = msResp.getString("message");
JSONObject respData = msResp.getJSONObject("data"); JSONObject respData = msResp.getJSONObject("data");
if ("0".equals(respCode) && respStatus == 200) { if (respCode == ResultCodeEnum.SUCCESS.getCode() && respStatus == 200) {
// 定位正常,判断是否在时效内 // 定位正常,判断是否在时效内
boolean locationValid = this.isDeviceLocationValid(respData); boolean locationValid = this.isDeviceLocationValid(respData);
msResult.setCode(locationValid ? respStatus : -1); checkMessage = locationValid ? "" : ResultCodeEnum.DEVICE_GPS_VERIFY_FAIL.getMsg();
msResult.setMessage(locationValid
? respMsg : ResultCodeEnum.DEVICE_GPS_VERIFY_FAIL.getMsg());
} else { } else {
// 定位不正常 // 定位不正常
msResult.setCode(-1); checkMessage = ResultCodeEnum.DEVICE_GPS_VERIFY_FAIL.getMsg();
msResult.setMessage(ResultCodeEnum.DEVICE_GPS_VERIFY_FAIL.getMsg());
} }
msResult.setData(respData); return checkMessage;
return msResult;
} }
/** /**
......
...@@ -478,7 +478,7 @@ public class MsFeedbackServiceImpl implements MsFeedbackService { ...@@ -478,7 +478,7 @@ public class MsFeedbackServiceImpl implements MsFeedbackService {
private MsResultObject invokeRemoteApi(String api, Object data) throws Exception { private MsResultObject invokeRemoteApi(String api, Object data) throws Exception {
JSONObject msResp = MsSignUtil.postForObject(api, data); JSONObject msResp = MsSignUtil.postForObject(api, data);
MsResultObject msResult; MsResultObject msResult;
if ("200".equals(msResp.getString("code"))) { if (msResp.getInteger("code") == ResultCodeEnum.SUCCESS.getCode()) {
msResult = new MsResultObject(ResultCodeEnum.SUCCESS); msResult = new MsResultObject(ResultCodeEnum.SUCCESS);
} else { } else {
msResult = new MsResultObject(ResultCodeEnum.FAIL.getCode(), msResult = new MsResultObject(ResultCodeEnum.FAIL.getCode(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!