Commit 6000ae89 by wubh

包活干V2.3.0-E盾接口同步方式修改

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@30489 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent b98caaa1
......@@ -5,11 +5,11 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.StringUtils;
import com.glsx.common.utils.UserUtils;
......@@ -39,9 +39,6 @@ import org.springframework.stereotype.Component;
@Component("edunOrderSyncStrategy")
public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
@Autowired
private UserClient userClient;
@Autowired
private OrderUtil orderUtil;
@Autowired
......@@ -62,14 +59,12 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
try {
SysOrder savedOrder = this.orderMapper.selectByPrimaryKey(super.order.getId());
savedOrder.setIfRepair(super.order.getIfRepair());
JSONObject req = new JSONObject();
this.wrapBizParam(req, savedOrder);
JSONObject req = this.buildReqParam(savedOrder);
String respJson = this.postForResult(req);
result = this.proceedResult(respJson, savedOrder);
} catch (Exception e) {
logger.error("设备同步错误", e);
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(),
ResultCodeEnum.FAIL.getMsg());
throw BusinessException.create(ResultCodeEnum.FAIL);
}
super.logger.info("==== EdunOrderSyncStrategy result: {}", JSON.toJSONString(result));
......@@ -79,28 +74,21 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
/**
* 封装业务参数
*
* @param req 请求参数
* @param order 订单
*/
private void wrapBizParam(JSONObject req, SysOrder order) {
private JSONObject buildReqParam(SysOrder order) {
JSONObject req = new JSONObject();
this.wrapOrderInfo(req, order);
this.wrapDeviceInfo(req, order);
this.wrapInstallPicture(req, order);
this.wrapStatusName(req, order);
req.put("eDunWorkOrderNo", order.getWorkOrderNo());
req.put("name", order.getCarOwner());
req.put("standNo", order.getVinNo());
req.put("workOrderNo", order.getOrderSn());
req.put("ifRepair", order.getIfRepair());
req.put("nodeTime", DateUtil.formatDateYmd(new Date()));
return req;
}
private void wrapOrderInfo(JSONObject req, SysOrder order) {
// 工单信息
req.put("eDunWorkOrderNo", order.getWorkOrderNo());
req.put("ownerName", order.getCarOwner());
req.put("vin", order.getVinNo());
req.put("workOrderNo", order.getOrderSn());
req.put("nodeTime", DateUtil.formatDateYmd(new Date()));
req.put("ifRepair", order.getIfRepair());
// 数据类型:1 激活,2 检修,3 试驾
if (StringUtils.isBlank(order.getChannel())) {
......@@ -111,9 +99,13 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
}
// 车辆信息
req.put("vin", order.getVinNo());
// 新车架号,没有
req.put("newStandNo", "");
// 车主性别,没有
req.put("ownerSex", "");
req.put("ownerName", order.getCarOwner());
req.put("ownerTel", order.getCarOwnerPhone());
req.put("ownerSex", "");
CarInfo carInfo = orderUtil.getCarInfo(order.getCarBrand(),
order.getCarSeries(), order.getCarType());
req.put("carBrandId", order.getCarBrand());
......@@ -132,8 +124,6 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
req.put("color", order.getCarColor());
// 车牌,没有
req.put("licensePlate", "");
// 新车架号,没有
req.put("newStandNo", "");
// 商户信息
JSONObject merchantObj = UserUtils.getMerchantInfo(order.getShopId());
......@@ -168,31 +158,6 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
deviceList = super.orderDeviceList;
}
//// TODO 使用 UserUtils 获取技工信息
//String mechanicName;
//String mechanicNumberPhone;
//JSONObject mechanicObj = userClient.getMechanicById(order.getMechanicId());
//if (mechanicObj != null
// && mechanicObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
// JSONObject data = mechanicObj.getJSONObject("data");
// mechanicName = data.getString("name");
// mechanicNumberPhone = data.getString("phoneNumber");
//} else {
// mechanicName = "";
// mechanicNumberPhone = "";
//}
//// TODO 使用 UserUtils 获取服务商信息
//String providerName;
//JSONObject providerObj = userClient.getServiceById(order.getMerchantId());
//if (providerObj != null
// && providerObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
// JSONObject data = providerObj.getJSONObject("data");
// providerName = data.getString("providerName");
//} else {
// providerName = "";
//}
String repairTypeName;
if (ifRepair) {
Map<Byte, String> map = new HashMap<>();
......@@ -210,8 +175,6 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
deviceInfo.put("installDeviceType", orderDevice.getDeviceType());
deviceInfo.put("installLocation", (orderDevice.getInstallLocation() == null)
? "" : orderDevice.getInstallLocation());
//deviceInfo.put("mechanicName", mechanicName);
//deviceInfo.put("mechanicNumberPhone", mechanicNumberPhone);
String newSn;
if (ifRepair && repairType == 1) {
......@@ -226,7 +189,6 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
deviceInfo.put("newSn", (newSn == null) ? "" : newSn);
deviceInfo.put("newStandNo", "");
deviceInfo.put("repairType", repairTypeName);
//deviceInfo.put("serviceName", providerName);
deviceInfo.put("sn", orderDevice.getDeviceNo());
deviceInfos.add(deviceInfo);
}
......@@ -254,16 +216,12 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
}
if (ifRepair) {
req.put("installLocionPicture", null);
req.put("installLocationPicture", null);
} else {
//只传给E盾照片列表
List<String> pictureList = new ArrayList<>();
for (SysOrderFile orderFile : fileList) {
String filePath = orderFile.getFilePath();
pictureList.add(filePath);
}
req.put("installLocionPicture", pictureList);
// 只传给E盾照片列表
List<String> pictureList = fileList.stream().map(SysOrderFile::getFilePath)
.collect(Collectors.toList());
req.put("installLocationPicture", pictureList);
}
}
......@@ -274,7 +232,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
* @param order 订单
*/
private void wrapStatusName(JSONObject req, SysOrder order) {
//已取消
// 已取消
if (order.getCanceled() == 0) {
req.put("nodeName", "已取消");
req.put("nodeStatus", "03");
......@@ -282,6 +240,7 @@ public class EdunOrderSyncStrategy extends BaseOrderSyncStrategy {
req.put("nodeName", "已完成");
req.put("nodeStatus", "02");
}
req.put("nodeTime", DateUtil.formatDateYmd(new Date()));
}
private String postForResult(JSONObject req) throws Exception {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!