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 { ...@@ -86,18 +86,13 @@ public class DscFeedbackServiceImpl implements DscFeedbackService {
public DSCResultObject syncOrder(Integer orderId) { public DSCResultObject syncOrder(Integer orderId) {
this.logger.info("==== DscFeedbackService syncOrder param: {}", orderId); this.logger.info("==== DscFeedbackService syncOrder param: {}", orderId);
SysOrder order = orderMapper.selectByPrimaryKey(orderId); SysOrder order = orderMapper.selectByPrimaryKey(orderId);
SysOrderDevice example = new SysOrderDevice(); SysOrderDevice odExample = new SysOrderDevice();
example.setOrderId(orderId); odExample.setOrderId(orderId);
List<SysOrderDevice> orderDeviceList = orderDeviceMapper.getOrderDeviceList(example); List<SysOrderDevice> orderDeviceList = orderDeviceMapper.getOrderDeviceList(odExample);
DSCResultObject dscResult; DSCResultObject dscResult;
try { try {
if (!BizConstants.DA_SOU_CHE.equalsIgnoreCase(order.getChannel())) { 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.ORDER_TYPE_INSTALL == order.getOrderType()) { if (BizConstants.ORDER_TYPE_INSTALL == order.getOrderType()) {
// 安装单 // 安装单
dscResult = this.syncInstallOrder(order, orderDeviceList); dscResult = this.syncInstallOrder(order, orderDeviceList);
...@@ -112,6 +107,11 @@ public class DscFeedbackServiceImpl implements DscFeedbackService { ...@@ -112,6 +107,11 @@ public class DscFeedbackServiceImpl implements DscFeedbackService {
dscResult = new DSCResultObject(ResultCodeEnum.SUCCESS.getCode() + "", dscResult = new DSCResultObject(ResultCodeEnum.SUCCESS.getCode() + "",
ResultCodeEnum.SUCCESS.getMsg()); 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) { } catch (DSCBusinessException e) {
this.logger.error("==== DscFeedbackService syncOrder ERROR: ", e); this.logger.error("==== DscFeedbackService syncOrder ERROR: ", e);
......
...@@ -4604,7 +4604,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4604,7 +4604,7 @@ public class OrderServiceImpl implements IOrderService {
ResultCodeEnum.SUCCESS.getMsg()); ResultCodeEnum.SUCCESS.getMsg());
} else { } else {
order.setIfRepair(this.isAfterSaleOrder(orderId)); order.setIfRepair(this.isAfterSaleOrder(orderId));
data.put("syncUrl", savedSyncUrl); data.put("syncUrl", syncUrl);
data.put("order", order); data.put("order", order);
strategy.setData(data); strategy.setData(data);
result = strategy.sync(); result = strategy.sync();
......
package com.glsx.ordercenter.strategy.impl; package com.glsx.ordercenter.strategy.impl;
import java.util.List;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.ordercenter.constants.ResultCodeEnum; import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.req.DaSouCheBaseReq; import com.glsx.ordercenter.dto.req.DaSouCheBaseReq;
import com.glsx.ordercenter.dto.resp.DSCResultObject; 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 com.glsx.ordercenter.strategy.BaseOrderSyncStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
...@@ -18,17 +24,53 @@ import org.springframework.stereotype.Component; ...@@ -18,17 +24,53 @@ import org.springframework.stereotype.Component;
*/ */
@Component("dscOrderSyncStrategy") @Component("dscOrderSyncStrategy")
public class DscOrderSyncStrategy extends BaseOrderSyncStrategy { public class DscOrderSyncStrategy extends BaseOrderSyncStrategy {
@Autowired
private SysOrderDeviceMapper orderDeviceMapper;
@Override @Override
public ResultObject sync() throws Exception { public ResultObject sync() throws Exception {
ResultObject result; ResultObject result;
DaSouCheBaseReq req = new DaSouCheBaseReq(); DaSouCheBaseReq req = new DaSouCheBaseReq();
//this.wrapBizParam(req);
req.setData(JSON.toJSONString(super.order.getId())); 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); String reqJson = JSON.toJSONString(req);
super.logger.info("==== DscOrderSyncStrategy url: {}, param: {}", super.syncUrl, reqJson); super.logger.info("==== DscOrderSyncStrategy url: {}, param: {}", super.syncUrl, reqJson);
String respJson = super.httpUtils.postJson(super.syncUrl, reqJson); String respJson = super.httpUtils.postJson(super.syncUrl, reqJson);
super.logger.info("==== DscOrderSyncStrategy response: {}", respJson); super.logger.info("==== DscOrderSyncStrategy response: {}", respJson);
return respJson;
}
private ResultObject proceedResult(String respJson) {
ResultObject result;
DSCResultObject dscResult = JSON.parseObject(respJson, DSCResultObject.class); DSCResultObject dscResult = JSON.parseObject(respJson, DSCResultObject.class);
if (String.valueOf(ResultCodeEnum.DSC_SUCCESS.getCode()).equals(dscResult.getCode())) { if (String.valueOf(ResultCodeEnum.DSC_SUCCESS.getCode()).equals(dscResult.getCode())) {
result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(), result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(),
...@@ -38,7 +80,6 @@ public class DscOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -38,7 +80,6 @@ public class DscOrderSyncStrategy extends BaseOrderSyncStrategy {
dscResult.getData()); dscResult.getData());
} }
super.logger.info("==== DscOrderSyncStrategy result: {}", JSON.toJSONString(result));
return result; return result;
} }
} }
...@@ -54,7 +54,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -54,7 +54,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
JSONObject req = new JSONObject(); JSONObject req = new JSONObject();
this.wrapBizParam(req); this.wrapBizParam(req);
String respJson = this.postForResult(req); String respJson = this.postForResult(req);
result = this.processResult(respJson); result = this.proceedResult(respJson);
} catch (Exception e) { } catch (Exception e) {
logger.error("设备同步错误", e); logger.error("设备同步错误", e);
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), throw BusinessException.create(ResultCodeEnum.FAIL.getCode(),
...@@ -225,7 +225,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -225,7 +225,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
return respJson; return respJson;
} }
private ResultObject processResult(String respJson) { private ResultObject proceedResult(String respJson) {
ResultObject result; ResultObject result;
JSONObject resp = JSON.parseObject(respJson); JSONObject resp = JSON.parseObject(respJson);
String respCode = resp.getString("returnCode"); String respCode = resp.getString("returnCode");
......
...@@ -50,7 +50,7 @@ public class DscDeviceVerifyTask implements Callable<DSCResultObject> { ...@@ -50,7 +50,7 @@ public class DscDeviceVerifyTask implements Callable<DSCResultObject> {
String respJson = this.postForResult(req); String respJson = this.postForResult(req);
// 返回的是个JSON格式的String:"{\"code\": 111, \"message\": \"xxxx\"}" // 返回的是个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) { } catch (Exception e) {
this.logger.error("==== DscDeviceVerifyTask ERROR: ", e); this.logger.error("==== DscDeviceVerifyTask ERROR: ", e);
dscResult = new DSCResultObject(ResultCodeEnum.ERROR.getCode() + "", dscResult = new DSCResultObject(ResultCodeEnum.ERROR.getCode() + "",
...@@ -108,7 +108,7 @@ public class DscDeviceVerifyTask implements Callable<DSCResultObject> { ...@@ -108,7 +108,7 @@ public class DscDeviceVerifyTask implements Callable<DSCResultObject> {
* @param respJson 请求结果 * @param respJson 请求结果
* @return 结果 * @return 结果
*/ */
private DSCResultObject processResult(String respJson) { private DSCResultObject proceedResult(String respJson) {
DSCResultObject dscResult = new DSCResultObject(); DSCResultObject dscResult = new DSCResultObject();
JSONObject resp = JSON.parseObject(respJson); JSONObject resp = JSON.parseObject(respJson);
String respCode = resp.getString("code"); String respCode = resp.getString("code");
......
...@@ -105,7 +105,7 @@ public class OraReturnOrderFinishTask implements Callable<OraResultObject> { ...@@ -105,7 +105,7 @@ public class OraReturnOrderFinishTask implements Callable<OraResultObject> {
//发送请求 //发送请求
HttpUtils httpUtils = new HttpUtils(); HttpUtils httpUtils = new HttpUtils();
String result = httpUtils.postJson(urlBuf.toString(), params); String result = httpUtils.postJson(urlBuf.toString(), params);
oraResult = this.processResult(result); oraResult = this.proceedResult(result);
} catch (BusinessException e) { } catch (BusinessException e) {
logger.error("欧拉回传工单安装结果异常: ", e); logger.error("欧拉回传工单安装结果异常: ", e);
oraResult = new OraResultObject(e.getResultEntity()); oraResult = new OraResultObject(e.getResultEntity());
...@@ -125,7 +125,7 @@ public class OraReturnOrderFinishTask implements Callable<OraResultObject> { ...@@ -125,7 +125,7 @@ public class OraReturnOrderFinishTask implements Callable<OraResultObject> {
* @param respJson 响应数据 * @param respJson 响应数据
* @return 结果 * @return 结果
*/ */
private OraResultObject processResult(String respJson) { private OraResultObject proceedResult(String respJson) {
OraResultObject oraResult; OraResultObject oraResult;
JSONObject respObj = JSON.parseObject(respJson); JSONObject respObj = JSON.parseObject(respJson);
String code = respObj.getString("code"); 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!