Commit 9c2488fc by wubh

包活干V1.9.1-修改:调整代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@28020 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 5a0f8af7
......@@ -86,18 +86,13 @@ public class DscFeedbackServiceImpl implements DscFeedbackService {
public DSCResultObject syncOrder(Integer orderId) {
this.logger.info("==== DscFeedbackService syncOrder param: {}", orderId);
SysOrder order = orderMapper.selectByPrimaryKey(orderId);
SysOrderDevice example = new SysOrderDevice();
example.setOrderId(orderId);
List<SysOrderDevice> orderDeviceList = orderDeviceMapper.getOrderDeviceList(example);
SysOrderDevice odExample = new SysOrderDevice();
odExample.setOrderId(orderId);
List<SysOrderDevice> orderDeviceList = orderDeviceMapper.getOrderDeviceList(odExample);
DSCResultObject dscResult;
try {
if (!BizConstants.DA_SOU_CHE.equalsIgnoreCase(order.getChannel())) {
this.logger.info("==== Channel = {},no need to sync to DaSouChe DSC",
order.getChannel());
dscResult = new DSCResultObject(ResultCodeEnum.SUCCESS.getCode() + "",
ResultCodeEnum.SUCCESS.getMsg());
} else {
if (BizConstants.DA_SOU_CHE.equalsIgnoreCase(order.getChannel())) {
if (BizConstants.ORDER_TYPE_INSTALL == order.getOrderType()) {
// 安装单
dscResult = this.syncInstallOrder(order, orderDeviceList);
......@@ -112,6 +107,11 @@ public class DscFeedbackServiceImpl implements DscFeedbackService {
dscResult = new DSCResultObject(ResultCodeEnum.SUCCESS.getCode() + "",
ResultCodeEnum.SUCCESS.getMsg());
}
} else {
this.logger.info("==== Channel = {},no need to sync to DaSouChe DSC",
order.getChannel());
dscResult = new DSCResultObject(ResultCodeEnum.SUCCESS.getCode() + "",
ResultCodeEnum.SUCCESS.getMsg());
}
} catch (DSCBusinessException e) {
this.logger.error("==== DscFeedbackService syncOrder ERROR: ", e);
......
......@@ -4604,7 +4604,7 @@ public class OrderServiceImpl implements IOrderService {
ResultCodeEnum.SUCCESS.getMsg());
} else {
order.setIfRepair(this.isAfterSaleOrder(orderId));
data.put("syncUrl", savedSyncUrl);
data.put("syncUrl", syncUrl);
data.put("order", order);
strategy.setData(data);
result = strategy.sync();
......
package com.glsx.ordercenter.strategy.impl;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.req.DaSouCheBaseReq;
import com.glsx.ordercenter.dto.resp.DSCResultObject;
import com.glsx.ordercenter.mapper.SysOrderDeviceMapper;
import com.glsx.ordercenter.pojo.SysOrderDevice;
import com.glsx.ordercenter.strategy.BaseOrderSyncStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
......@@ -18,17 +24,53 @@ import org.springframework.stereotype.Component;
*/
@Component("dscOrderSyncStrategy")
public class DscOrderSyncStrategy extends BaseOrderSyncStrategy {
@Autowired
private SysOrderDeviceMapper orderDeviceMapper;
@Override
public ResultObject sync() throws Exception {
ResultObject result;
DaSouCheBaseReq req = new DaSouCheBaseReq();
//this.wrapBizParam(req);
req.setData(JSON.toJSONString(super.order.getId()));
String respJson = this.postForResult(req);
result = this.proceedResult(respJson);
super.logger.info("==== DscOrderSyncStrategy result: {}", JSON.toJSONString(result));
return result;
}
private void wrapBizParam(DaSouCheBaseReq req) {
JSONObject reqData = new JSONObject();
List<SysOrderDevice> deviceList;
if (StringUtils.isEmpty(super.orderDeviceList)) {
// 没有设备信息:同步接口调用的
SysOrderDevice odExample = new SysOrderDevice();
odExample.setOrderId(super.order.getId());
deviceList = this.orderDeviceMapper.selectByOrderDevice(odExample);
} else {
// 有设备信息:安装、拆除、检修之后调用的
deviceList = super.orderDeviceList;
}
reqData.put("orderDeviceList", deviceList);
req.setData(JSON.toJSONString(reqData));
}
private String postForResult(DaSouCheBaseReq req) throws Exception {
String reqJson = JSON.toJSONString(req);
super.logger.info("==== DscOrderSyncStrategy url: {}, param: {}", super.syncUrl, reqJson);
String respJson = super.httpUtils.postJson(super.syncUrl, reqJson);
super.logger.info("==== DscOrderSyncStrategy response: {}", respJson);
return respJson;
}
private ResultObject proceedResult(String respJson) {
ResultObject result;
DSCResultObject dscResult = JSON.parseObject(respJson, DSCResultObject.class);
if (String.valueOf(ResultCodeEnum.DSC_SUCCESS.getCode()).equals(dscResult.getCode())) {
result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(),
......@@ -38,7 +80,6 @@ public class DscOrderSyncStrategy extends BaseOrderSyncStrategy {
dscResult.getData());
}
super.logger.info("==== DscOrderSyncStrategy result: {}", JSON.toJSONString(result));
return result;
}
}
......@@ -54,7 +54,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
JSONObject req = new JSONObject();
this.wrapBizParam(req);
String respJson = this.postForResult(req);
result = this.processResult(respJson);
result = this.proceedResult(respJson);
} catch (Exception e) {
logger.error("设备同步错误", e);
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(),
......@@ -225,7 +225,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
return respJson;
}
private ResultObject processResult(String respJson) {
private ResultObject proceedResult(String respJson) {
ResultObject result;
JSONObject resp = JSON.parseObject(respJson);
String respCode = resp.getString("returnCode");
......
......@@ -50,7 +50,7 @@ public class DscDeviceVerifyTask implements Callable<DSCResultObject> {
String respJson = this.postForResult(req);
// 返回的是个JSON格式的String:"{\"code\": 111, \"message\": \"xxxx\"}"
// 所以要先转换成正常的字符串
dscResult = this.processResult(JSON.parseObject(respJson, String.class));
dscResult = this.proceedResult(JSON.parseObject(respJson, String.class));
} catch (Exception e) {
this.logger.error("==== DscDeviceVerifyTask ERROR: ", e);
dscResult = new DSCResultObject(ResultCodeEnum.ERROR.getCode() + "",
......@@ -108,7 +108,7 @@ public class DscDeviceVerifyTask implements Callable<DSCResultObject> {
* @param respJson 请求结果
* @return 结果
*/
private DSCResultObject processResult(String respJson) {
private DSCResultObject proceedResult(String respJson) {
DSCResultObject dscResult = new DSCResultObject();
JSONObject resp = JSON.parseObject(respJson);
String respCode = resp.getString("code");
......
......@@ -105,7 +105,7 @@ public class OraReturnOrderFinishTask implements Callable<OraResultObject> {
//发送请求
HttpUtils httpUtils = new HttpUtils();
String result = httpUtils.postJson(urlBuf.toString(), params);
oraResult = this.processResult(result);
oraResult = this.proceedResult(result);
} catch (BusinessException e) {
logger.error("欧拉回传工单安装结果异常: ", e);
oraResult = new OraResultObject(e.getResultEntity());
......@@ -125,7 +125,7 @@ public class OraReturnOrderFinishTask implements Callable<OraResultObject> {
* @param respJson 响应数据
* @return 结果
*/
private OraResultObject processResult(String respJson) {
private OraResultObject proceedResult(String respJson) {
OraResultObject oraResult;
JSONObject respObj = JSON.parseObject(respJson);
String code = respObj.getString("code");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!