Commit b128f9b8 by wangnb

包活干V1.9.0问题修复--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@27053 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent a8ea4152
package com.glsx.ordercenter.controller;
import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import java.util.Map;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.constants.ResultCodeEnum;
import com.glsx.common.constants.ResultObject;
......@@ -16,9 +13,11 @@ import com.glsx.ordercenter.service.InsuranceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import java.util.Map;
/**
* <p>Description: 保单列表查询
......@@ -113,6 +112,23 @@ public class InsuranceController extends BaseController {
}
/**
* 投保操作
*
* @param id 保险id
* @return
*/
@AuthCheck
@RequestMapping(value = "/insure", method = {RequestMethod.POST, RequestMethod.GET})
public ResultObject insure(HttpServletRequest request, @RequestParam(value = "id")Integer id) {
if (id <= 0) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR);
}
ResultObject resultObject = insuranceService.insureCoreProcess(id);
super.logInfo("投保操作-结果", resultObject);
return resultObject;
}
/**
* 重新投保
*
* @param insuranceReq 请求体
......
......@@ -167,7 +167,7 @@ public class OraOrderController extends BaseController {
/**
*
* 验证设备状态
* @return
*/
@RequestMapping(value = "/deviceStatus", method = RequestMethod.POST)
......@@ -186,9 +186,8 @@ public class OraOrderController extends BaseController {
order.setWorkOrderNo(jsonObject.getString("orderId")); //聚合工单id
order.setWorkOrderNumber(jsonObject.getString("workOrderNumber")); //聚合工单编号
order.setOrderType(jsonObject.getByte("workOrderType")); //聚合传来工单类型(1新装、2维修、3拆除、4移机)后续需要处理
//todo 产品id未接收
order.setServiceCode(jsonObject.getString("productId"));
//todo 长城传市级id 后台为区级id 后续处理
//长城传市级id 后台为区级id 后续处理
order.setDistrict(jsonObject.getInteger("cityId")); //市区编码
order.setAddress(jsonObject.getString("installAddress")); //预约安装地址,包含区级地址
order.setExpectInstallTime(jsonObject.getDate("reserveInstallationTime")); //期望|预约安装时间
......
......@@ -55,6 +55,13 @@ public interface InsuranceService {
ResultObject reinsured(SysInsuranceReq sysInsuranceReq);
/**
* 投保核心流程
* @param id
* @return
*/
ResultObject insureCoreProcess(Integer id);
/**
* 重推保单service处理
* @param sysInsuranceReq
* @return
......
package com.glsx.ordercenter.service.impl;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Semaphore;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.common.constants.ResultObject;
......@@ -42,6 +37,12 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Semaphore;
/**
* <p>Description: 保险Service
*
......@@ -446,12 +447,12 @@ public class InsuranceServiceImpl extends BaseOrderService implements InsuranceS
while (retries-- > 0) {
try {
TspResp tspResp = this.tspApiInvoker
.with(this.appKey, this.secret)
.refund(tspRefundReq);
.with(this.appKey, this.secret)
.refund(tspRefundReq);
super.logInfo("TSP接口调用结果", tspResp);
// 判断是否调用成功
boolean invokeSuccess = TspResultCode.SUCCESS.getCode().equals(
tspResp.getCode());
tspResp.getCode());
if (invokeSuccess) {
// 成功,更新字段状态
......@@ -516,20 +517,25 @@ public class InsuranceServiceImpl extends BaseOrderService implements InsuranceS
insertPolicy.setPilferInsuranceMoney(oldPolicy.getPilferInsuranceMoney());
insertPolicy.setExpectedEffectiveTime(DateUtil.getStartDateOfNextDay(now));
int i = insuranceMapper.insertSelective(insertPolicy); //重投生成新的保单数据
if(i < 0){
return new ResultObject(com.glsx.common.constants.ResultCodeEnum.FAIL);
if (i < 0) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
//调用TSP接口投保
return this.insureCoreProcess(insertPolicy.getId());
}
@Override
public ResultObject insureCoreProcess(Integer id) {
//调用TSP接口投保
Semaphore semaphore = new Semaphore(1);
TspSaveInsuranceDataTask saveInsuranceTask = new TspSaveInsuranceDataTask(insertPolicy.getId(), insuranceMapper, semaphore);
TspSaveInsuranceDataTask saveInsuranceTask = new TspSaveInsuranceDataTask(id, insuranceMapper, semaphore);
taskExecutor.defaultThreadPool().execute(saveInsuranceTask);
//更新pdf
TspGetInsurancePdfTask getInsurancePdfTask = new TspGetInsurancePdfTask(insertPolicy.getId(), insuranceMapper, semaphore);
TspGetInsurancePdfTask getInsurancePdfTask = new TspGetInsurancePdfTask(id, insuranceMapper, semaphore);
taskExecutor.defaultThreadPool().execute(getInsurancePdfTask);
//请求结果返回给欧拉
OraReturnInsurancePdfTask returnPdfTask = new OraReturnInsurancePdfTask(insertPolicy.getId(), insuranceMapper, semaphore);
OraReturnInsurancePdfTask returnPdfTask = new OraReturnInsurancePdfTask(id, insuranceMapper, semaphore);
taskExecutor.defaultThreadPool().execute(returnPdfTask);
return new ResultObject(com.glsx.common.constants.ResultCodeEnum.SUCCESS);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
@Override
......@@ -538,22 +544,23 @@ public class InsuranceServiceImpl extends BaseOrderService implements InsuranceS
policy.setId(sysInsuranceReq.getId());
policy.setInsurancePdf(sysInsuranceReq.getInsurancePdf()); //保单地址更新
int i = insuranceMapper.updateByPrimaryKeySelective(policy); //更新保单数据
if(i < 0){
return new ResultObject(com.glsx.common.constants.ResultCodeEnum.FAIL);
if (i < 0) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
Semaphore semaphore = new Semaphore(1);
//回传保单pdf地址给欧拉
OraReturnInsurancePdfTask returnPdfTask = new OraReturnInsurancePdfTask(sysInsuranceReq.getId(), insuranceMapper, semaphore);
taskExecutor.defaultThreadPool().execute(returnPdfTask);
return new ResultObject(com.glsx.common.constants.ResultCodeEnum.SUCCESS);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
* 保单前端界面数据封装
*
* @param insuranceReq
* @return
*/
private SysInsurancePolicy setInsurancePolicyData(SysInsuranceReq insuranceReq){
private SysInsurancePolicy setInsurancePolicyData(SysInsuranceReq insuranceReq) {
SysInsurancePolicy policy = new SysInsurancePolicy();
policy.setCustomerType(insuranceReq.getCustomerType());
policy.setVehicleOwnerName(insuranceReq.getVehicleOwnerName());
......
......@@ -451,14 +451,36 @@ public class OraOrderServiceImpl implements OraOrderService {
try {
String result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("设备No:{}获取设备验证信息响应数据:{}", deviceNo , result);
OraResultObject oreResult = JSON.parseObject(result, OraResultObject.class);
return oreResult;
JSONObject jsonObject = JSON.parseObject(result);
return this.returnMessageHandler(jsonObject); //接口数据处理返回
} catch (Exception e) {
logger.error("调用欧拉设备信息验证接口异常:{}", e.getMessage());
return new OraResultObject(ResultCodeEnum.FAIL);
}
}
private OraResultObject returnMessageHandler(JSONObject jsonObject){
if("0".equals(jsonObject.getString("code"))){
JSONObject data = jsonObject.getJSONObject("data");
String onOffStatus = data.getString("onoffstatus");
if("1".equals(onOffStatus)){
return new OraResultObject(ResultCodeEnum.SUCCESS);
}
if("-1".equals(onOffStatus)){
return new OraResultObject(ResultCodeEnum.FAIL.getCode(), "设备未上线");
}
if("0".equals(onOffStatus)){
return new OraResultObject(ResultCodeEnum.FAIL.getCode(), "设备离线");
}
if("2".equals(onOffStatus)){
return new OraResultObject(ResultCodeEnum.FAIL.getCode(), "设备休眠");
}
}else{
return new OraResultObject(ResultCodeEnum.FAIL.getCode(), jsonObject.getString("message"));
}
return new OraResultObject(ResultCodeEnum.FAIL);
}
@Override
@Transactional(rollbackFor = Exception.class)
public List<OraResultObject> cancelOrder(String[] orderIds, String channel) {
......
package com.glsx.ordercenter.thread;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.resp.OraResultObject;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysOrderDeviceMapper;
import com.glsx.ordercenter.mapper.SysOrderMapper;
import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderDevice;
import com.glsx.ordercenter.utils.OraOperationUtil;
import com.glsx.ordercenter.utils.OraSignUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author think.wang
* @version 1.0.0
* @Title OraReturnReserveOrderInfoTask
* @Package com.glsx.ordercenter.thread
* @Description 欧拉接口回传工单安装结果
* @date 2020/5/28
*/
public class OraReturnOrderSetupTask implements Runnable {
private Logger logger = LoggerFactory.getLogger(OraReturnOrderSetupTask.class);
private Integer id;
private SysOrderMapper orderMapper;
private SysOrderDeviceMapper orderDeviceMapper;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public OraReturnOrderSetupTask(Integer id, SysOrderMapper orderMapper, SysOrderDeviceMapper orderDeviceMapper) {
this.id = id;
this.orderMapper = orderMapper;
this.orderDeviceMapper = orderDeviceMapper;
}
@Override
public void run() {
try {
//系统参数获取
String oraUrl = PropertiesUtil.getProperty("ora.api.url");
String appKey = PropertiesUtil.getProperty("ora.appKey");
String appSecret = PropertiesUtil.getProperty("ora.appSecret");
String version = PropertiesUtil.getProperty("ora.version");
String format = PropertiesUtil.getProperty("ora.format");
String method = PropertiesUtil.getProperty("ora.workorder.saveSetup");
SysOrder order = orderMapper.selectByPrimaryKey(id);
if (order == null) {
this.logger.error("通过id={}未找到工单数据", id);
return;
}
//业务参数封装
JSONObject object = this.setBusinessParams(order);
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); //随机字符串
String timeStamp = String.valueOf(new Date().getTime() / 1000); //秒级时间戳
map.put("nonce", nonce);
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);
//发送请求
String result = null;
int tryCount = this.TRY_COUNT;
while (tryCount-- > 0) {
try {
HttpUtils httpUtils = new HttpUtils();
result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("订单id:{}回传修改预约信息响应数据:{}", id, result);
OraResultObject oreResult = JSON.parseObject(result, OraResultObject.class);
if ("0".equals(oreResult.getCode())) {
break;
}
} catch (Exception e) {
Thread.sleep(this.TRY_WAIT_TIME);
continue;
}
}
} catch (BusinessException e) {
logger.error("欧拉更新工单预约信息数据异常:{}", e.getResultEntity().toString());
} catch (Exception e) {
logger.error("欧拉更新工单预约信息接口异常:{}", e.getMessage());
}
}
/**
* 业务参数封装
* @param order
* @return
*/
private JSONObject setBusinessParams(SysOrder order) {
String edumUrl = PropertiesUtil.getProperty("edun.access.platform.url") + "api/workOrder/getDeviceInfo";
HttpUtils httpUtils = new HttpUtils();
JSONObject object = new JSONObject();
object.put("orderId", order.getWorkOrderNo());
object.put("workOrderNumber", order.getWorkOrderNumber());
object.put("vin", order.getVinNo());
object.put("frameNumberPhoto", ""); //车架号图片
object.put("bigPicture", ""); //大合照图片
object.put("groupPhoto", ""); //人车合影图片
object.put("supplierAuditTime", order.getCompleteTime()); //工单审核时间
SysOrderDevice conditions = new SysOrderDevice();
conditions.setOrderId(id);
List<SysOrderDevice> deviceList = orderDeviceMapper.getOrderDeviceList(conditions);
JSONArray equipmentList = new JSONArray();
try {
if (deviceList != null && deviceList.size() > 0) {
for (SysOrderDevice orderDevice : deviceList) {
JSONObject equipment = new JSONObject();
equipment.put("equipmentNumber", orderDevice.getDeviceNo()); //设备号
//从虎哥E盾获取sim卡号
Map<String, String> params = new HashMap<>(1);
params.put("deviceNo", orderDevice.getDeviceNo());
String result = httpUtils.post(edumUrl, params, 100, "utf-8");
logger.info("从虎哥E盾获取设备sim卡信息响应数据:{}", result);
JSONObject jsonObject = JSON.parseObject(result);
if ("0".equals(jsonObject.getString("returnCode"))) {
JSONObject data = jsonObject.getJSONObject("data");
equipment.put("simNumber", data.getString("simNumber")); //sim卡号
} else {
equipment.put("simNumber", "暂无"); //sim卡号
}
equipment.put("installTime", order.getCompleteTime()); //设备安装时间
equipment.put("installPosition", orderDevice.getInstallLocation()); //设备安装位置
equipment.put("actualInstaller", ""); //设备的实际安装人
equipment.put("iswired", ""); //设备有线/无线(0:有线 1:无线)
equipment.put("installRemarks", ""); //设备安装备注
//设备照片,有线设备【图片路径以逗号拼接,顺序为有线(接线图)、有线(近照+远照)、有线(近照+远照)、其他照片】;无线设备【图片路径以逗号拼接,顺序为无线近照、无线远照、其他照片】
equipment.put("installPhotos", "");
equipmentList.add(equipment);
}
}
} catch (Exception e) {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), e.getMessage());
}
object.put("worksheetEquipmentList", equipmentList); //工单审核时间
return object;
}
}
......@@ -110,8 +110,12 @@ public class OraReturnReserveOrderInfoTask implements Runnable{
}
}
/**
* 业务参数封装
* @param order
* @return
*/
private JSONObject setBusinessParams(SysOrder order){
//业务参数封装
JSONObject object = new JSONObject();
object.put("orderId",order.getWorkOrderNo());
Integer district = order.getDistrict();
......@@ -136,7 +140,7 @@ public class OraReturnReserveOrderInfoTask implements Runnable{
}
object.put("installAddress",order.getAddress());
object.put("reserveInstallationTime",order.getReserveInstallTime());
object.put("installStore", ""); //todo 安装门店
object.put("installStore", order.getMerchantName());
object.put("storeContacts",order.getContact());
object.put("storeContactPhone",order.getPhoneNumber());
return object;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!