Commit 13d03bb8 by wubh

包活干V2.2.0-策略类调整

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@29292 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent e0f2cc3a
...@@ -402,11 +402,11 @@ public class OrderController extends BaseController { ...@@ -402,11 +402,11 @@ public class OrderController extends BaseController {
ResultObject result = orderService.dismantle(userId, order); ResultObject result = orderService.dismantle(userId, order);
if (ResultCodeEnum.SUCCESS.getCode() == result.getCode()) { if (ResultCodeEnum.SUCCESS.getCode() == result.getCode()) {
JSONObject data = new JSONObject(); //JSONObject data = new JSONObject();
// data.put("orderId", id); ////data.put("orderId", id);
// dscFeedbackService.syncOrder(data); ////dscFeedbackService.syncOrder(data);
data.put("orderId", id); //data.put("orderId", id);
orderService.syncOrderCore(data); // 2.2.0 同步工单信息到渠道,虎哥e盾、长城 orderService.syncOrderCore(order); // 2.2.0 同步工单信息到渠道,虎哥e盾、长城
} }
return result; return result;
} }
...@@ -444,12 +444,16 @@ public class OrderController extends BaseController { ...@@ -444,12 +444,16 @@ public class OrderController extends BaseController {
ResultObject result = orderService.repair(request, orderRepairReq); ResultObject result = orderService.repair(request, orderRepairReq);
if (ResultCodeEnum.SUCCESS.getCode() == result.getCode()) { if (ResultCodeEnum.SUCCESS.getCode() == result.getCode()) {
JSONObject data = new JSONObject(); //JSONObject data = new JSONObject();
data.put("orderId", orderRepairReq.getOrderId()); //data.put("orderId", orderRepairReq.getOrderId());
data.put("orderDeviceList", orderRepairReq.getOrderDeviceList()); //data.put("orderDeviceList", orderRepairReq.getOrderDeviceList());
data.put("orderFileList", orderRepairReq.getOrderFileList()); //data.put("orderFileList", orderRepairReq.getOrderFileList());
// dscFeedbackService.syncOrder(data); //dscFeedbackService.syncOrder(data);
orderService.syncOrderCore(data); // 2.2.0 同步工单信息到渠道,虎哥e盾、长城 SysOrder order = new SysOrder();
order.setId(orderRepairReq.getOrderId());
order.setOrderDeviceList(orderRepairReq.getOrderDeviceList());
order.setOrderFileList(orderRepairReq.getOrderFileList());
orderService.syncOrderCore(order); // 2.2.0 同步工单信息到渠道,虎哥e盾、长城
} }
return result; return result;
} }
...@@ -992,15 +996,19 @@ public class OrderController extends BaseController { ...@@ -992,15 +996,19 @@ public class OrderController extends BaseController {
byte auditStatus = (byte)obj; byte auditStatus = (byte)obj;
if (ResultCodeEnum.SUCCESS.getCode() == result.getCode() && (auditStatus == -1 if (ResultCodeEnum.SUCCESS.getCode() == result.getCode() && (auditStatus == -1
|| auditStatus == AuditStatusEnum.NORMALLY_PASSED.getCode() || auditStatus == AuditStatusEnum.ABNORMALLY_PASSED.getCode())) { || auditStatus == AuditStatusEnum.NORMALLY_PASSED.getCode() || auditStatus == AuditStatusEnum.ABNORMALLY_PASSED.getCode())) {
JSONObject data = new JSONObject(); //JSONObject data = new JSONObject();
// data.put("orderId", orderDeviceReq.getOrderId()); ////data.put("orderId", orderDeviceReq.getOrderId());
// data.put("orderDeviceList", orderDeviceReq.getOrderDeviceList()); ////data.put("orderDeviceList", orderDeviceReq.getOrderDeviceList());
// oraOrderService.synchronizeOrderFinishMessage(orderDeviceReq.getOrderId()); ////oraOrderService.synchronizeOrderFinishMessage(orderDeviceReq.getOrderId());
// dscFeedbackService.syncOrder(data); ////dscFeedbackService.syncOrder(data);
data.put("orderId", orderDeviceReq.getOrderId()); //data.put("orderId", orderDeviceReq.getOrderId());
data.put("orderDeviceList", orderDeviceReq.getOrderDeviceList()); //data.put("orderDeviceList", orderDeviceReq.getOrderDeviceList());
data.put("orderFileList", orderDeviceReq.getOrderFileList()); //data.put("orderFileList", orderDeviceReq.getOrderFileList());
orderService.syncOrderCore(data); // 2.2.0 同步工单信息到渠道,虎哥e盾、长城 SysOrder order = new SysOrder();
order.setId(orderDeviceReq.getOrderId());
order.setOrderDeviceList(orderDeviceReq.getOrderDeviceList());
order.setOrderFileList(orderDeviceReq.getOrderFileList());
orderService.syncOrderCore(order); // 2.2.0 同步工单信息到渠道,虎哥e盾、长城
} }
} }
return result; return result;
...@@ -1105,11 +1113,10 @@ public class OrderController extends BaseController { ...@@ -1105,11 +1113,10 @@ public class OrderController extends BaseController {
public ResultObject syncOrder(Integer orderId) { public ResultObject syncOrder(Integer orderId) {
super.logInfo("==== /syncOrder parameter", orderId); super.logInfo("==== /syncOrder parameter", orderId);
if (orderId == null) { if (orderId == null) {
throw BusinessException.create(ResultCodeEnum.PARAM_ERROR.getCode(), "orderId不能为空"); throw BusinessException.create(ResultCodeEnum.PARAM_ERROR.getCode(),
"orderId不能为空");
} }
JSONObject data = new JSONObject(); ResultObject result = this.orderService.syncOrder(orderId);
data.put("orderId", orderId);
ResultObject result = this.orderService.syncOrder(data);
super.logInfo("==== /syncOrder result", result); super.logInfo("==== /syncOrder result", result);
return result; return result;
} }
......
package com.glsx.ordercenter.service; package com.glsx.ordercenter.service;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.pojo.OderReceivingReq;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.dto.*;
import com.glsx.ordercenter.dto.req.SaveOrderSubsidyInfoReq;
import com.glsx.ordercenter.pojo.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.pojo.OderReceivingReq;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.dto.BizAmountResp;
import com.glsx.ordercenter.dto.CreateAfterSaleRepairReq;
import com.glsx.ordercenter.dto.MechanicBusiness;
import com.glsx.ordercenter.dto.OrderActivateReq;
import com.glsx.ordercenter.dto.OrderDeviceReq;
import com.glsx.ordercenter.dto.OrderRepairReq;
import com.glsx.ordercenter.dto.OrderStastic;
import com.glsx.ordercenter.dto.QueryOrderReq;
import com.glsx.ordercenter.dto.ServiceItemScale;
import com.glsx.ordercenter.dto.req.SaveOrderSubsidyInfoReq;
import com.glsx.ordercenter.pojo.OrderOnHand;
import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderDeviceSupplier;
import com.glsx.ordercenter.pojo.SysOrderExample;
import com.glsx.ordercenter.pojo.SysOrderStatus;
import com.glsx.ordercenter.pojo.SysServiceItem;
/** /**
* @author Zheng Xiajun * @author Zheng Xiajun
...@@ -346,9 +357,9 @@ public interface IOrderService { ...@@ -346,9 +357,9 @@ public interface IOrderService {
ResultObject getOrderSubSidyInfo(Integer orderId); ResultObject getOrderSubSidyInfo(Integer orderId);
ResultObject syncOrder(JSONObject data); ResultObject syncOrder(Integer orderId);
ResultObject syncOrderCore(JSONObject data); ResultObject syncOrderCore(SysOrder order);
void carOcr(OrderDeviceReq orderDeviceReq); void carOcr(OrderDeviceReq orderDeviceReq);
......
...@@ -3820,11 +3820,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3820,11 +3820,7 @@ public class OrderServiceImpl implements IOrderService {
} }
order.setIfRepair(this.isAfterSaleOrder(orderId)); order.setIfRepair(this.isAfterSaleOrder(orderId));
order.setOrderDeviceList(orderDeviceReq.getOrderDeviceList()); order.setOrderDeviceList(orderDeviceReq.getOrderDeviceList());
JSONObject data = new JSONObject(); result = strategy.verify(verifyUrl, order);
data.put("verifyUrl", verifyUrl);
data.put("order", order);
strategy.setData(data);
result = strategy.verify();
} }
//result = this.validateDeviceAndOrder(sysOrder, orderDeviceReq); //result = this.validateDeviceAndOrder(sysOrder, orderDeviceReq);
} catch (Exception e) { } catch (Exception e) {
...@@ -3834,33 +3830,33 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3834,33 +3830,33 @@ public class OrderServiceImpl implements IOrderService {
return result; return result;
} }
private ResultObject validateDeviceAndOrder(SysOrder order, OrderDeviceReq orderDeviceReq) throws Exception { //private ResultObject validateDeviceAndOrder(SysOrder order, OrderDeviceReq orderDeviceReq) throws Exception {
ResultObject result; // ResultObject result;
Integer orderId = order.getId(); // Integer orderId = order.getId();
//设备验证url校验 // //设备验证url校验
SysServiceItem serviceItem = this.getOrderServiceItem(orderId, false); // SysServiceItem serviceItem = this.getOrderServiceItem(orderId, false);
String verifyCode = (serviceItem != null) ? serviceItem.getDeviceVerifyUrl() : ""; // String verifyCode = (serviceItem != null) ? serviceItem.getDeviceVerifyUrl() : "";
if (StringUtils.isEmpty(verifyCode)) { // if (StringUtils.isEmpty(verifyCode)) {
logger.info("=====服务代码:{}的设备验证接口未配置,直接返回成功======", serviceItem.getServiceCode()); // logger.info("=====服务代码:{}的设备验证接口未配置,直接返回成功======", serviceItem.getServiceCode());
result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg()); // result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} else { // } else {
String channel = verifyCode.split("-")[1]; // String channel = verifyCode.split("-")[1];
Class<? extends DeviceVerifyStrategy> beanClass = DeviceVerifyStrategyEnum.getBeanClass(channel); // Class<? extends DeviceVerifyStrategy> beanClass = DeviceVerifyStrategyEnum.getBeanClass(channel);
DeviceVerifyStrategy strategy = SpringContextUtils.getBean(beanClass); // DeviceVerifyStrategy strategy = SpringContextUtils.getBean(beanClass);
String verifyUrl = PropertiesUtil.getProperty(BizConstants.DEVICE_VERIFY_PREFIX + channel); // String verifyUrl = PropertiesUtil.getProperty(BizConstants.DEVICE_VERIFY_PREFIX + channel);
if(StringUtils.isEmpty(verifyUrl)){ // if(StringUtils.isEmpty(verifyUrl)){
throw BusinessException.create(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg()); // throw BusinessException.create(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg());
} // }
order.setIfRepair(this.isAfterSaleOrder(orderId)); // order.setIfRepair(this.isAfterSaleOrder(orderId));
JSONObject data = new JSONObject(); // JSONObject data = new JSONObject();
data.put("verifyUrl", verifyUrl); // data.put("verifyUrl", verifyUrl);
data.put("order", order); // data.put("order", order);
data.put("orderDeviceList", orderDeviceReq.getOrderDeviceList()); // data.put("orderDeviceList", orderDeviceReq.getOrderDeviceList());
strategy.setData(data); // strategy.setData(data);
result = strategy.verify(); // result = strategy.verify();
} // }
return result; // return result;
} //}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -4598,12 +4594,11 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4598,12 +4594,11 @@ public class OrderServiceImpl implements IOrderService {
* 工单完成同步接口。 * 工单完成同步接口。
* 会做参数校验,仅用于订单重推接口使用。 * 会做参数校验,仅用于订单重推接口使用。
* *
* @param data 参数,主要需要其中的orderId,虎哥e盾则需要其中的orderDeviceList和orderFileList * @param orderId 订单ID
* @return 同步结果 * @return 同步结果
*/ */
@Override @Override
public ResultObject syncOrder(JSONObject data) { public ResultObject syncOrder(Integer orderId) {
Integer orderId = data.getInteger("orderId");
SysOrder order = orderMapper.selectByPrimaryKey(orderId); SysOrder order = orderMapper.selectByPrimaryKey(orderId);
if (order == null) { if (order == null) {
throw BusinessException.create(ResultCodeEnum.ORDER_NOT_EXIST.getCode(), throw BusinessException.create(ResultCodeEnum.ORDER_NOT_EXIST.getCode(),
...@@ -4615,26 +4610,21 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4615,26 +4610,21 @@ public class OrderServiceImpl implements IOrderService {
throw BusinessException.create(ResultCodeEnum.ORDER_SYNC_STATUS_MISMATCH.getCode(), throw BusinessException.create(ResultCodeEnum.ORDER_SYNC_STATUS_MISMATCH.getCode(),
ResultCodeEnum.ORDER_SYNC_STATUS_MISMATCH.getMsg()); ResultCodeEnum.ORDER_SYNC_STATUS_MISMATCH.getMsg());
} }
data.put("order", order); ResultObject result = this.syncOrderCore(order);
ResultObject result = this.syncOrderCore(data);
return result; return result;
} }
/** /**
* 工单同步核心流程。 * 工单同步核心流程。
* 不抛出异常情况,如果是订单重推接口的请求,会在 {@link #syncOrder(JSONObject)} 中做校验; * 不抛出异常情况,如果是订单重推接口的请求,会在 {@link IOrderService#syncOrder(Integer)} 中做校验;
* 如果是安装、检修等流程触发的同步,则不抛出异常。 * 如果是安装、检修等流程触发的同步,则不抛出异常。
* *
* @param data 参数 * @param order 订单数据
* @return 同步结果 * @return 同步结果
*/ */
@Override @Override
public ResultObject syncOrderCore(JSONObject data) { public ResultObject syncOrderCore(SysOrder order) {
Integer orderId = data.getInteger("orderId"); Integer orderId = order.getId();
// 如果是重推流程,order不为空;如果是安装、检修等流程,order为空
SysOrder savedOrder = (SysOrder) data.get("order");
SysOrder order = (savedOrder == null) ? this.orderMapper.selectByPrimaryKey(orderId) : savedOrder;
// 如果是重推流程,syncUrl不为空;如果是安装、检修等流程,syncUrl为空
SysServiceItem serviceItem = this.getOrderServiceItem(orderId, false); SysServiceItem serviceItem = this.getOrderServiceItem(orderId, false);
String syncCode = (serviceItem != null) ? serviceItem.getPushUrl() : ""; String syncCode = (serviceItem != null) ? serviceItem.getPushUrl() : "";
ResultObject result; ResultObject result;
...@@ -4652,10 +4642,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4652,10 +4642,7 @@ public class OrderServiceImpl implements IOrderService {
ResultCodeEnum.ORDER_SYNC_URL_NOT_CONFIGURED.getMsg()); ResultCodeEnum.ORDER_SYNC_URL_NOT_CONFIGURED.getMsg());
} }
order.setIfRepair(this.isAfterSaleOrder(orderId)); order.setIfRepair(this.isAfterSaleOrder(orderId));
data.put("syncUrl", syncUrl); result = strategy.sync(syncUrl, order);
data.put("order", order);
strategy.setData(data);
result = strategy.sync();
} catch (Exception e) { } catch (Exception e) {
logger.error("==== syncOrder ERROR: ", e); logger.error("==== syncOrder ERROR: ", e);
result = new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg()); result = new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
......
...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy; ...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.HttpUtils; import com.glsx.common.utils.HttpUtils;
import com.glsx.ordercenter.pojo.SysOrder; import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderDevice; import com.glsx.ordercenter.pojo.SysOrderDevice;
...@@ -19,7 +20,6 @@ import org.slf4j.LoggerFactory; ...@@ -19,7 +20,6 @@ import org.slf4j.LoggerFactory;
public abstract class BaseDeviceVerifyStrategy implements DeviceVerifyStrategy { public abstract class BaseDeviceVerifyStrategy implements DeviceVerifyStrategy {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final HttpUtils httpUtils = new HttpUtils(); protected final HttpUtils httpUtils = new HttpUtils();
private JSONObject data;
protected String verifyUrl; protected String verifyUrl;
protected SysOrder order; protected SysOrder order;
protected List<SysOrderDevice> orderDeviceList; protected List<SysOrderDevice> orderDeviceList;
...@@ -27,10 +27,17 @@ public abstract class BaseDeviceVerifyStrategy implements DeviceVerifyStrategy { ...@@ -27,10 +27,17 @@ public abstract class BaseDeviceVerifyStrategy implements DeviceVerifyStrategy {
public BaseDeviceVerifyStrategy() {} public BaseDeviceVerifyStrategy() {}
@Override @Override
public ResultObject verify(String verifyUrl, SysOrder order) throws Exception {
this.verifyUrl = verifyUrl;
this.order = order;
this.orderDeviceList = order.getOrderDeviceList();
return this.verify();
}
@Override
public void setData(JSONObject data) { public void setData(JSONObject data) {
this.data = data;
this.verifyUrl = data.getString("verifyUrl"); this.verifyUrl = data.getString("verifyUrl");
this.order = data.getObject("order", SysOrder.class); this.order = data.getObject("order", SysOrder.class);
this.orderDeviceList = order.getOrderDeviceList(); this.orderDeviceList = this.order.getOrderDeviceList();
} }
} }
...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy; ...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.HttpUtils; import com.glsx.common.utils.HttpUtils;
import com.glsx.ordercenter.pojo.SysOrder; import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderDevice; import com.glsx.ordercenter.pojo.SysOrderDevice;
...@@ -20,7 +21,6 @@ import org.slf4j.LoggerFactory; ...@@ -20,7 +21,6 @@ import org.slf4j.LoggerFactory;
public abstract class BaseOrderSyncStrategy implements OrderSyncStrategy { public abstract class BaseOrderSyncStrategy implements OrderSyncStrategy {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final HttpUtils httpUtils = new HttpUtils(); protected final HttpUtils httpUtils = new HttpUtils();
protected JSONObject data;
protected String syncUrl; protected String syncUrl;
protected SysOrder order; protected SysOrder order;
protected List<SysOrderDevice> orderDeviceList; protected List<SysOrderDevice> orderDeviceList;
...@@ -29,11 +29,19 @@ public abstract class BaseOrderSyncStrategy implements OrderSyncStrategy { ...@@ -29,11 +29,19 @@ public abstract class BaseOrderSyncStrategy implements OrderSyncStrategy {
public BaseOrderSyncStrategy() {} public BaseOrderSyncStrategy() {}
@Override @Override
public ResultObject sync(String syncUrl, SysOrder order) throws Exception {
this.syncUrl = syncUrl;
this.order = order;
this.orderDeviceList = order.getOrderDeviceList();
this.orderFileList = order.getOrderFileList();
return this.sync();
}
@Override
public void setData(JSONObject data) { public void setData(JSONObject data) {
this.data = data;
this.syncUrl = data.getString("syncUrl"); this.syncUrl = data.getString("syncUrl");
this.order = (SysOrder) data.get("order"); this.order = data.getObject("order", SysOrder.class);
this.orderDeviceList = (List<SysOrderDevice>) data.get("orderDeviceList"); this.orderDeviceList = this.order.getOrderDeviceList();
this.orderFileList = (List<SysOrderFile>) data.get("orderFileList"); this.orderFileList = this.order.getOrderFileList();
} }
} }
...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy; ...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.pojo.SysOrder;
/** /**
* <p>Description: 设备校验策略 * <p>Description: 设备校验策略
...@@ -14,5 +15,7 @@ import com.glsx.common.constants.ResultObject; ...@@ -14,5 +15,7 @@ import com.glsx.common.constants.ResultObject;
public interface DeviceVerifyStrategy { public interface DeviceVerifyStrategy {
ResultObject verify() throws Exception; ResultObject verify() throws Exception;
ResultObject verify(String verifyUrl, SysOrder order) throws Exception;
void setData(JSONObject data); void setData(JSONObject data);
} }
...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy; ...@@ -2,6 +2,7 @@ package com.glsx.ordercenter.strategy;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.pojo.SysOrder;
/** /**
* <p>Description: 订单同步策略 * <p>Description: 订单同步策略
...@@ -14,5 +15,7 @@ import com.glsx.common.constants.ResultObject; ...@@ -14,5 +15,7 @@ import com.glsx.common.constants.ResultObject;
public interface OrderSyncStrategy { public interface OrderSyncStrategy {
ResultObject sync() throws Exception; ResultObject sync() throws Exception;
ResultObject sync(String syncUrl, SysOrder order) throws Exception;
void setData(JSONObject data); void setData(JSONObject data);
} }
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.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;
/** /**
...@@ -24,9 +19,6 @@ import org.springframework.stereotype.Component; ...@@ -24,9 +19,6 @@ 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;
...@@ -42,20 +34,7 @@ public class DscOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -42,20 +34,7 @@ public class DscOrderSyncStrategy extends BaseOrderSyncStrategy {
private void wrapBizParam(DaSouCheBaseReq req) { private void wrapBizParam(DaSouCheBaseReq req) {
JSONObject reqData = new JSONObject(); 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("orderId", super.order.getId()); reqData.put("orderId", super.order.getId());
reqData.put("orderDeviceList", deviceList);
req.setData(JSON.toJSONString(reqData)); req.setData(JSON.toJSONString(reqData));
} }
......
...@@ -25,7 +25,6 @@ public class EdunDeviceVerifyStrategy extends BaseDeviceVerifyStrategy { ...@@ -25,7 +25,6 @@ public class EdunDeviceVerifyStrategy extends BaseDeviceVerifyStrategy {
public ResultObject verify() throws Exception { public ResultObject verify() throws Exception {
//虎哥E盾设备验证 //虎哥E盾设备验证
ResultObject result; ResultObject result;
Integer orderId = super.order.getId();
JSONObject req = new JSONObject(); JSONObject req = new JSONObject();
JSONArray deviceInfos = new JSONArray(); JSONArray deviceInfos = new JSONArray();
...@@ -60,7 +59,7 @@ public class EdunDeviceVerifyStrategy extends BaseDeviceVerifyStrategy { ...@@ -60,7 +59,7 @@ public class EdunDeviceVerifyStrategy extends BaseDeviceVerifyStrategy {
JSONArray data = resp.getJSONArray("data"); JSONArray data = resp.getJSONArray("data");
result = (data != null) result = (data != null)
? new ResultObject(ResultCodeEnum.SUCCESS.getCode(), message, data) ? new ResultObject(ResultCodeEnum.SUCCESS.getCode(), message, data)
: new ResultObject(Integer.parseInt(respCode), message, data); : new ResultObject(Integer.parseInt(respCode), message);
} }
this.logger.info("==== EdunDeviceVerifyStrategy result: {}", JSON.toJSONString(result)); this.logger.info("==== EdunDeviceVerifyStrategy result: {}", JSON.toJSONString(result));
......
...@@ -17,6 +17,7 @@ import com.glsx.ordercenter.constants.ResultCodeEnum; ...@@ -17,6 +17,7 @@ import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.exception.BusinessException; import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysOrderDeviceMapper; import com.glsx.ordercenter.mapper.SysOrderDeviceMapper;
import com.glsx.ordercenter.mapper.SysOrderFileMapper; import com.glsx.ordercenter.mapper.SysOrderFileMapper;
import com.glsx.ordercenter.mapper.SysOrderMapper;
import com.glsx.ordercenter.pojo.SysOrder; import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderDevice; import com.glsx.ordercenter.pojo.SysOrderDevice;
import com.glsx.ordercenter.pojo.SysOrderFile; import com.glsx.ordercenter.pojo.SysOrderFile;
...@@ -40,6 +41,8 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -40,6 +41,8 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
@Autowired @Autowired
private OrderUtil orderUtil; private OrderUtil orderUtil;
@Autowired @Autowired
private SysOrderMapper orderMapper;
@Autowired
private SysOrderDeviceMapper orderDeviceMapper; private SysOrderDeviceMapper orderDeviceMapper;
@Autowired @Autowired
private SysOrderFileMapper orderFileMapper; private SysOrderFileMapper orderFileMapper;
...@@ -47,14 +50,16 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -47,14 +50,16 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
@Override @Override
public ResultObject sync() throws Exception { public ResultObject sync() throws Exception {
super.logger.info("==== EdunOrderSyncStrategy url: {}, param: {}", super.logger.info("==== EdunOrderSyncStrategy url: {}, param: {}",
super.syncUrl, super.order.getId()); super.syncUrl, super.order);
ResultObject result; ResultObject result;
try { try {
SysOrder savedOrder = this.orderMapper.selectByPrimaryKey(super.order.getId());
savedOrder.setIfRepair(super.order.getIfRepair());
JSONObject req = new JSONObject(); JSONObject req = new JSONObject();
this.wrapBizParam(req); this.wrapBizParam(req, savedOrder);
String respJson = this.postForResult(req); String respJson = this.postForResult(req);
result = this.proceedResult(respJson); result = this.proceedResult(respJson, savedOrder);
} catch (Exception e) { } catch (Exception e) {
logger.error("设备同步错误", e); logger.error("设备同步错误", e);
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), throw BusinessException.create(ResultCodeEnum.FAIL.getCode(),
...@@ -70,14 +75,14 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -70,14 +75,14 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
* *
* @param req 请求参数 * @param req 请求参数
*/ */
private void wrapBizParam(JSONObject req) { private void wrapBizParam(JSONObject req, SysOrder order) {
this.wrapDeviceInfo(req, super.order); this.wrapDeviceInfo(req, order);
this.wrapInstallPicture(req, super.order); this.wrapInstallPicture(req, order);
this.wrapStatusName(req, super.order); this.wrapStatusName(req, order);
req.put("eDunWorkOrderNo", super.order.getWorkOrderNo()); req.put("eDunWorkOrderNo", order.getWorkOrderNo());
req.put("name", super.order.getCarOwner()); req.put("name", order.getCarOwner());
req.put("standNo", super.order.getVinNo()); req.put("standNo", order.getVinNo());
req.put("workOrderNo", super.order.getOrderSn()); req.put("workOrderNo", order.getOrderSn());
req.put("nodeTime", DateUtil.formatDateYmd(new Date())); req.put("nodeTime", DateUtil.formatDateYmd(new Date()));
} }
...@@ -101,7 +106,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -101,7 +106,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
String mechanicName; String mechanicName;
String mechanicNumberPhone; String mechanicNumberPhone;
JSONObject mechanicObj = userClient.getMechanicById(super.order.getMechanicId()); JSONObject mechanicObj = userClient.getMechanicById(order.getMechanicId());
if (mechanicObj != null if (mechanicObj != null
&& mechanicObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) { && mechanicObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
JSONObject data = mechanicObj.getJSONObject("data"); JSONObject data = mechanicObj.getJSONObject("data");
...@@ -113,7 +118,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -113,7 +118,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
} }
String providerName; String providerName;
JSONObject providerObj = userClient.getServiceById(super.order.getMerchantId()); JSONObject providerObj = userClient.getServiceById(order.getMerchantId());
if (providerObj != null if (providerObj != null
&& providerObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) { && providerObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
JSONObject data = providerObj.getJSONObject("data"); JSONObject data = providerObj.getJSONObject("data");
...@@ -225,7 +230,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -225,7 +230,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
return respJson; return respJson;
} }
private ResultObject proceedResult(String respJson) { private ResultObject proceedResult(String respJson, SysOrder order) {
ResultObject result; ResultObject result;
JSONObject resp = JSON.parseObject(respJson); JSONObject resp = JSON.parseObject(respJson);
String respCode = resp.getString("returnCode"); String respCode = resp.getString("returnCode");
...@@ -233,7 +238,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy { ...@@ -233,7 +238,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
if ("0".equals(respCode)) { if ("0".equals(respCode)) {
try { try {
orderUtil.sendActivateWechatRemind(super.order.getId()); orderUtil.sendActivateWechatRemind(order.getId());
} catch (Exception e) { } catch (Exception e) {
logger.error("订单完成微信消息推送失败", e); logger.error("订单完成微信消息推送失败", e);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!