Commit 3e6bf885 by wangnb

包活干V1.9.0设备信息验证接口--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@27042 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent b981664f
......@@ -3,6 +3,7 @@ package com.glsx.ordercenter.controller.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.controller.BaseController;
......@@ -16,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
......@@ -163,6 +165,21 @@ public class OraOrderController extends BaseController {
return str;
}
/**
*
* @return
*/
@RequestMapping(value = "/deviceStatus", method = RequestMethod.POST)
public OraResultObject deviceStatus(@RequestParam(value = "deviceNo")String deviceNo) {
if(StringUtils.isEmpty(deviceNo)){
return new OraResultObject(ResultCodeEnum.PARAM_ERROR);
}
OraResultObject object = oraOrderService.getDeviceData(deviceNo);
logger.info("/api/ora/deviceStatus接口处理数据返回结果:{}", object.toString());
return object;
}
private SysOrder orderDataTrans(JSONObject jsonObject) {
SysOrder order = new SysOrder();
order.setChannel(BizConstants.CC_ORA); //渠道
......@@ -170,7 +187,7 @@ public class OraOrderController extends BaseController {
order.setWorkOrderNumber(jsonObject.getString("workOrderNumber")); //聚合工单编号
order.setOrderType(jsonObject.getByte("workOrderType")); //聚合传来工单类型(1新装、2维修、3拆除、4移机)后续需要处理
//todo 产品id未接收
order.setServiceCode("");
order.setServiceCode(jsonObject.getString("productId"));
//todo 长城传市级id 后台为区级id 后续处理
order.setDistrict(jsonObject.getInteger("cityId")); //市区编码
order.setAddress(jsonObject.getString("installAddress")); //预约安装地址,包含区级地址
......
......@@ -25,6 +25,13 @@ public interface OraOrderService {
OraResultObject update(SysOrder sysOrder);
/**
* 获取设备信息返回验证
* @param deviceNo
* @return
*/
OraResultObject getDeviceData(String deviceNo);
/**
* 工单取消
* @param orderIds 工单数组
* @param channel 渠道
......
package com.glsx.ordercenter.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.Constants;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.StringUtils;
import com.glsx.common.utils.map.AMapUtils;
import com.glsx.ordercenter.constants.BizConstants;
......@@ -22,17 +24,16 @@ import com.glsx.ordercenter.service.IOrderService;
import com.glsx.ordercenter.service.OraOrderService;
import com.glsx.ordercenter.service.StandardOrderService;
import com.glsx.ordercenter.utils.OraOperationUtil;
import com.glsx.ordercenter.utils.OraSignUtil;
import com.glsx.ordercenter.utils.OrderUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author think.wang
......@@ -47,6 +48,24 @@ public class OraOrderServiceImpl implements OraOrderService {
private Logger logger = LoggerFactory.getLogger(OraOrderServiceImpl.class);
@Value("${ora.api.url}")
private String oraUrl;
@Value("${ora.appKey}")
private String appKey;
@Value("${ora.appSecret}")
private String appSecret;
@Value("${ora.version}")
private String version;
@Value("${ora.format}")
private String format;
@Value("${ora.workorder.getStatus}")
private String method;
@Autowired
private SysOrderMapper sysOrderMapper;
......@@ -403,6 +422,44 @@ public class OraOrderServiceImpl implements OraOrderService {
}
@Override
public OraResultObject getDeviceData(String deviceNo) {
//业务参数封装
JSONObject object = new JSONObject();
object.put("equipmentNumber",deviceNo);
String params = JSON.toJSONString(object);
logger.info("工单设备信息验证业务参数:{}", params);
Map<String, String> map = new HashMap<>();
//系统参数封装
map.put("appkey", appKey);
map.put("format", format);
map.put("v", version);
String nonce = OraOperationUtil.getRandomString(16); //随机字符串
map.put("nonce", nonce);
String timeStamp = String.valueOf(new Date().getTime() / 1000); //秒级时间戳
map.put("timestamp", timeStamp);
String sign = OraSignUtil.sign(map, null, appSecret); //除了sign所有参数进行验签
map.put("sign", sign);
StringBuffer urlBuf = new StringBuffer(oraUrl + method + "?appkey=" + appKey);
urlBuf.append("&format=" + format);
urlBuf.append("&v=" + version);
urlBuf.append("&nonce=" + nonce);
urlBuf.append("&timestamp=" + timeStamp);
urlBuf.append("&sign=" + sign);
HttpUtils httpUtils = new HttpUtils();
try {
String result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("设备No:{}获取设备验证信息响应数据:{}", deviceNo , result);
OraResultObject oreResult = JSON.parseObject(result, OraResultObject.class);
return oreResult;
} catch (Exception e) {
logger.error("调用欧拉设备信息验证接口异常:{}", e.getMessage());
return new OraResultObject(ResultCodeEnum.FAIL);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public List<OraResultObject> cancelOrder(String[] orderIds, String channel) {
List<OraResultObject> resultList = new ArrayList<>();
......
......@@ -73,7 +73,7 @@ public class OraReturnPdfTask implements Runnable{
object.put("startTime",startTime);
object.put("endTime",DateUtil.addMonthDate(startTime, insurancePolicy.getInsurancePeriod(), "yyyy-MM-dd 00:00:00"));
String params = JSON.toJSONString(object);
this.logger.info("获取pdf签名参数值为:{}", params);
this.logger.info("回传pdf路径给欧拉业务参数:{}", params);
Map<String, String> map = new HashMap<>();
//系统参数封装
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!