package com.xiaopeng.vehicleConvoy.util;
|
|
|
import java.io.ByteArrayInputStream;
|
import java.io.InputStream;
|
import java.security.MessageDigest;
|
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
import java.util.Base64;
|
|
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSONObject;
|
import com.xiaopeng.common.core.utils.StringUtils;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverBaseInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverCancelRegisterInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverContractInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverMobileTerminalInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverPositionInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverPunishInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverReputationInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverRegisterInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverStatisticsInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverTrainingInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationDriverVehicleRelationInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationOperateArriveInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationOrderCancelInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationOrderMatchInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationOrderCreateInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationOrderViolationInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationOperateDepartInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationOperatePayInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationVehicleCancelReportInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPassengerComplaintInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPassengerEvaluateInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPassengerBaseInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformAggregationInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformLicenseInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformPauseOperationRegisterInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformOperationRegisterInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformInvestorInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformPayInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformPriceInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationPlatformServiceInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationVehicleBaseInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationVehicleInsuranceInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationVehicleMileageInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationVehicleOperationRegisterInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationVehicleOperateLoginInfoDTO;
|
import com.xiaopeng.vehicleConvoy.model.dto.RegulationVehicleOperateLogoutInfoDTO;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.http.HttpResponse;
|
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.util.EntityUtils;
|
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.stereotype.Component;
|
|
|
/**
|
* 交通部接口对接
|
*/
|
@Slf4j
|
@Component
|
public class MinistryOfTransport {
|
|
/**
|
* 公司名称:广州易点智慧出行科技有限公司
|
*
|
* 平台简称:“有鹏出行”
|
* 标识:XPQCB67N
|
* key:gEhROt7lg4DEBanR
|
*
|
* 对接ip:127.0.0.1,125.71.236.64,47.98.173.145,116.62.136.48,39.108.249.22,47.105.208.135,47.112.126.81,114.55.179.11,39.170.77.50,120.26.242.215
|
*
|
* 接口地址:https://wycapi.jtj.gz.gov.cn/api/app/common/binapi
|
*/
|
|
public static final String DEFAULT_COMPANY_ID = "4401XPQCB67N";
|
|
public static final String DEFAULT_SYMBOL = "XPQCB67N_S0612018007357G";
|
|
public static final String DEFAULT_PROTOCOL_VERSION = "V2.0";
|
|
private final String companyId = DEFAULT_COMPANY_ID;//公司标识
|
|
private final String platform = "XPQCB67N";
|
|
private final String key = "gEhROt7lg4DEBanR";
|
|
private final String url = "https://wycapi.jtj.gz.gov.cn/api/app/common/binapi";
|
|
private static final DateTimeFormatter FILE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-ddHHmmssSSS");
|
|
public static final DateTimeFormatter DATA_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
/**
|
* 获取token
|
* @return
|
*/
|
public String getToken(){
|
try {
|
String format = LocalDateTime.now().format(FILE_TIME_FORMATTER);
|
String filename = platform + "_TOKEN_ACCESS_REQ_" + format + ".json";
|
JSONObject body = new JSONObject();
|
body.put("platform", platform);
|
body.put("key", key);
|
return uploadJsonFile(filename, body.toJSONString(), platform);
|
}catch (Exception e){
|
log.error("获取交通部token失败", e);
|
}
|
return null;
|
}
|
|
/**
|
* 报送网约车平台公司基本信息(PTJB)
|
*
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformBaseInfo() {
|
JSONObject item = buildPlatformBaseInfo();
|
return pushBasicReqInfo(item,"PTJB");
|
}
|
|
|
/**
|
* 报送网约车平台公司运营规模信息(PTYYGM)
|
*
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformOperationScaleInfo() {
|
JSONObject item = buildPlatformOperationScaleInfo();
|
return pushBasicReqInfo(item,"PTYYGM");
|
}
|
|
/**
|
* 报送网约车车辆基本信息(CLJB)
|
*
|
* @param dto 车辆基本信息
|
* @return 监管平台原始响应
|
*/
|
public String pushVehicleBaseInfo(RegulationVehicleBaseInfoDTO dto) {
|
JSONObject item = buildVehicleBaseInfo(dto);
|
return pushBasicReqInfo(item, "CLJB");
|
}
|
|
/**
|
* 报送网约车车辆保险信息(CLBX)
|
*
|
* @param dto 车辆保险信息
|
* @return 监管平台原始响应
|
*/
|
public String pushVehicleInsuranceInfo(RegulationVehicleInsuranceInfoDTO dto) {
|
JSONObject item = buildVehicleInsuranceInfo(dto);
|
return pushBasicReqInfo(item, "CLBX");
|
}
|
|
/**
|
* 报送网约车车辆里程信息(CLLC)
|
*
|
* @param dto 车辆里程信息
|
* @return 监管平台原始响应
|
*/
|
public String pushVehicleMileageInfo(RegulationVehicleMileageInfoDTO dto) {
|
JSONObject item = buildVehicleMileageInfo(dto);
|
return pushBasicReqInfo(item, "CLLC");
|
}
|
|
/**
|
* 报送网约车驾驶员基本信息(JSYJB)
|
*
|
* @param dto 驾驶员基本信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverBaseInfo(RegulationDriverBaseInfoDTO dto) {
|
JSONObject item = buildDriverBaseInfo(dto);
|
return pushBasicReqInfo(item, "JSYJB");
|
}
|
|
/**
|
* 报送网约车驾驶员培训信息(JSYPX)
|
*
|
* @param dto 驾驶员培训信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverTrainingInfo(RegulationDriverTrainingInfoDTO dto) {
|
JSONObject item = buildDriverTrainingInfo(dto);
|
return pushBasicReqInfo(item, "JSYPX");
|
}
|
|
/**
|
* 报送网约车驾驶员移动终端信息(JSYYDZD)
|
*
|
* @param dto 驾驶员移动终端信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverMobileTerminalInfo(RegulationDriverMobileTerminalInfoDTO dto) {
|
JSONObject item = buildDriverMobileTerminalInfo(dto);
|
return pushBasicReqInfo(item, "JSYYDZD");
|
}
|
|
/**
|
* 报送网约车驾驶员统计信息(JSYTJ)
|
*
|
* @param dto 驾驶员统计信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverStatisticsInfo(RegulationDriverStatisticsInfoDTO dto) {
|
JSONObject item = buildDriverStatisticsInfo(dto);
|
return pushBasicReqInfo(item, "JSYTJ");
|
}
|
|
/**
|
* 报送网约车乘客基本信息(CKJB)
|
*
|
* @param dto 乘客基本信息
|
* @return 监管平台原始响应
|
*/
|
public String pushPassengerBaseInfo(RegulationPassengerBaseInfoDTO dto) {
|
JSONObject item = buildPassengerBaseInfo(dto);
|
return pushBasicReqInfo(item, "CKJB");
|
}
|
|
/**
|
* 报送网约车平台投资人信息(PTTZR)
|
*
|
* @param dto 平台投资人信息
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformInvestorInfo(RegulationPlatformInvestorInfoDTO dto) {
|
JSONObject item = buildPlatformInvestorInfo(dto);
|
return pushBasicReqInfo(item, "PTTZR");
|
}
|
|
/**
|
* 报送驾驶员合同信息(GTJSYHT)
|
*
|
* @param dto 驾驶员合同信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverContractInfo(RegulationDriverContractInfoDTO dto) {
|
JSONObject item = buildDriverContractInfo(dto);
|
return pushBasicReqInfo(item, "GTJSYHT");
|
}
|
|
/**
|
* 报送订单发起(DDFQ)
|
*
|
* @param dto 订单发起信息
|
* @return 监管平台原始响应
|
*/
|
public String pushOrderCreateInfo(RegulationOrderCreateInfoDTO dto) {
|
JSONObject item = buildOrderCreateInfo(dto);
|
return pushOrderReqInfo(item, "DDFQ");
|
}
|
|
/**
|
* 报送订单成功(DDCG)
|
*
|
* @param dto 订单成功信息
|
* @return 监管平台原始响应
|
*/
|
public String pushOrderMatchInfo(RegulationOrderMatchInfoDTO dto) {
|
JSONObject item = buildOrderMatchInfo(dto);
|
return pushOrderReqInfo(item, "DDCG");
|
}
|
|
/**
|
* 报送订单撤销(DDCX)
|
*
|
* @param dto 订单撤销信息
|
* @return 监管平台原始响应
|
*/
|
public String pushOrderCancelInfo(RegulationOrderCancelInfoDTO dto) {
|
JSONObject item = buildOrderCancelInfo(dto);
|
return pushOrderReqInfo(item, "DDCX");
|
}
|
|
/**
|
* 报送订单违约(DDWY)
|
*
|
* @param dto 订单违约信息
|
* @return 监管平台原始响应
|
*/
|
public String pushOrderViolationInfo(RegulationOrderViolationInfoDTO dto) {
|
JSONObject item = buildOrderViolationInfo(dto);
|
return pushOrderReqInfo(item, "DDWY");
|
}
|
|
/**
|
* 报送车辆营运上线(CLYYSX)
|
*
|
* @param dto 车辆营运上线信息
|
* @return 监管平台原始响应
|
*/
|
public String pushVehicleOperateLoginInfo(RegulationVehicleOperateLoginInfoDTO dto) {
|
JSONObject item = buildVehicleOperateLoginInfo(dto);
|
return pushOperationReqInfo(item, "CLYYSX");
|
}
|
|
/**
|
* 报送车辆营运下线(CLYYXX)
|
*
|
* @param dto 车辆营运下线信息
|
* @return 监管平台原始响应
|
*/
|
public String pushVehicleOperateLogoutInfo(RegulationVehicleOperateLogoutInfoDTO dto) {
|
JSONObject item = buildVehicleOperateLogoutInfo(dto);
|
return pushOperationReqInfo(item, "CLYYXX");
|
}
|
|
/**
|
* 报送营运出发(YYCF)
|
*
|
* @param dto 营运出发信息
|
* @return 监管平台原始响应
|
*/
|
public String pushOperateDepartInfo(RegulationOperateDepartInfoDTO dto) {
|
JSONObject item = buildOperateDepartInfo(dto);
|
return pushOperationReqInfo(item, "YYCF");
|
}
|
|
/**
|
* 报送营运到达(YYDD)
|
*
|
* @param dto 营运到达信息
|
* @return 监管平台原始响应
|
*/
|
public String pushOperateArriveInfo(RegulationOperateArriveInfoDTO dto) {
|
JSONObject item = buildOperateArriveInfo(dto);
|
return pushOperationReqInfo(item, "YYDD");
|
}
|
|
/**
|
* 报送营运支付(YYZF)
|
*
|
* @param dto 营运支付信息
|
* @return 监管平台原始响应
|
*/
|
public String pushOperatePayInfo(RegulationOperatePayInfoDTO dto) {
|
JSONObject item = buildOperatePayInfo(dto);
|
return pushOperationReqInfo(item, "YYZF");
|
}
|
|
/**
|
* 报送驾驶员定位信息(JSYDW)
|
*
|
* @param dto 驾驶员定位信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverPositionInfo(RegulationDriverPositionInfoDTO dto) {
|
JSONObject item = buildDriverPositionInfo(dto);
|
return pushGpsReqInfo(item, "JSYDW");
|
}
|
|
/**
|
* 报送乘客评价信息(CKPJ)
|
*
|
* @param dto 乘客评价信息
|
* @return 监管平台原始响应
|
*/
|
public String pushPassengerEvaluateInfo(RegulationPassengerEvaluateInfoDTO dto) {
|
JSONObject item = buildPassengerEvaluateInfo(dto);
|
return pushQualityReqInfo(item, "CKPJ");
|
}
|
|
/**
|
* 报送乘客投诉处理信息(CKTSCL)
|
*
|
* @param dto 乘客投诉处理信息
|
* @return 监管平台原始响应
|
*/
|
public String pushPassengerComplaintInfo(RegulationPassengerComplaintInfoDTO dto) {
|
JSONObject item = buildPassengerComplaintInfo(dto);
|
return pushQualityReqInfo(item, "CKTSCL");
|
}
|
|
/**
|
* 报送车辆注销报备(CLZXBB)
|
*
|
* @param dto 车辆注销报备信息
|
* @return 监管平台原始响应
|
*/
|
public String pushVehicleCancelReportInfo(RegulationVehicleCancelReportInfoDTO dto) {
|
JSONObject item = buildVehicleCancelReportInfo(dto);
|
return pushRegistReqInfo(item, "CLZXBB");
|
}
|
|
/**
|
* 报送驾驶员处罚信息(JSYCF)
|
*
|
* @param dto 驾驶员处罚信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverPunishInfo(RegulationDriverPunishInfoDTO dto) {
|
JSONObject item = buildDriverPunishInfo(dto);
|
return pushQualityReqInfo(item, "JSYCF");
|
}
|
|
/**
|
* 报送驾驶员信誉信息(JSYXY)
|
*
|
* @param dto 驾驶员信誉信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverReputationInfo(RegulationDriverReputationInfoDTO dto) {
|
JSONObject item = buildDriverReputationInfo(dto);
|
return pushQualityReqInfo(item, "JSYXY");
|
}
|
|
/**
|
* 报送人车对应关系信息(RCDYGX)
|
*
|
* @param dto 人车对应关系信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverVehicleRelationInfo(RegulationDriverVehicleRelationInfoDTO dto) {
|
JSONObject item = buildDriverVehicleRelationInfo(dto);
|
return pushBasicReqInfo(item, "RCDYGX");
|
}
|
|
/**
|
* 报送平台营运报备(PTYYBB)
|
*
|
* @param dto 平台营运报备信息
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformOperationRegisterInfo(RegulationPlatformOperationRegisterInfoDTO dto) {
|
JSONObject item = buildPlatformOperationRegisterInfo(dto);
|
return pushRegistReqInfo(item, "PTYYBB");
|
}
|
|
/**
|
* 报送平台暂停营运报备(PTZTYYBB)
|
*
|
* @param dto 平台暂停营运报备信息
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformPauseOperationRegisterInfo(RegulationPlatformPauseOperationRegisterInfoDTO dto) {
|
JSONObject item = buildPlatformPauseOperationRegisterInfo(dto);
|
return pushRegistReqInfo(item, "PTZTYYBB");
|
}
|
|
/**
|
* 报送合作聚合平台信息(PTJHPTXX)
|
*
|
* @param dto 合作聚合平台信息
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformAggregationInfo(RegulationPlatformAggregationInfoDTO dto) {
|
JSONObject item = buildPlatformAggregationInfo(dto);
|
return pushRegistReqInfo(item, "PTJHPTXX");
|
}
|
|
/**
|
* 报送车辆营运报备(CLYYBB)
|
*
|
* @param dto 车辆营运报备信息
|
* @return 监管平台原始响应
|
*/
|
public String pushVehicleOperationRegisterInfo(RegulationVehicleOperationRegisterInfoDTO dto) {
|
JSONObject item = buildVehicleOperationRegisterInfo(dto);
|
return pushRegistReqInfo(item, "CLYYBB");
|
}
|
|
/**
|
* 报送驾驶员注册报备(JSYZCBB)
|
*
|
* @param dto 驾驶员注册报备信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverRegisterInfo(RegulationDriverRegisterInfoDTO dto) {
|
JSONObject item = buildDriverRegisterInfo(dto);
|
return pushRegistReqInfo(item, "JSYZCBB");
|
}
|
|
/**
|
* 报送驾驶员注销注册(JSYZXZC)
|
*
|
* @param dto 驾驶员注销注册信息
|
* @return 监管平台原始响应
|
*/
|
public String pushDriverCancelRegisterInfo(RegulationDriverCancelRegisterInfoDTO dto) {
|
JSONObject item = buildDriverCancelRegisterInfo(dto);
|
return pushRegistReqInfo(item, "JSYZXZC");
|
}
|
|
/**
|
* 报送网约车平台公司支付信息(PTZF)
|
*
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformPayInfo(RegulationPlatformPayInfoDTO dto) {
|
JSONObject item = buildPlatformPayInfo(dto);
|
return pushBasicReqInfo(item,"PTZF");
|
}
|
|
/**
|
* 网约车平台公司服务机构(PTFWJG)
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformServiceInfo(RegulationPlatformServiceInfoDTO dto) {
|
JSONObject item = buildPlatformServiceInfo(dto);
|
return pushBasicReqInfo(item,"PTFWJG");
|
}
|
|
/**
|
* 网约车平台公司经营许可(CPTJYXK)
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformLicenseInfo(RegulationPlatformLicenseInfoDTO dto) {
|
JSONObject item = buildPlatformLicenseInfo(dto);
|
return pushBasicReqInfo(item,"CPTJYXK");
|
}
|
|
/**
|
* 网约车平台公司计程计价方式(PTYJ)
|
* @return 监管平台原始响应
|
*/
|
public String pushPlatformPriceInfo(RegulationPlatformPriceInfoDTO dto) {
|
JSONObject item = buildPlatformPriceInfo(dto);
|
return pushBasicReqInfo(item,"PTYJ");
|
}
|
|
|
/**
|
* 推送基础信息
|
* @param item 推送基础信息
|
* @param command 推送基础信息类型
|
* @return 监管平台原始响应
|
*/
|
private String pushBasicReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"BASIC",command);
|
}
|
|
/**
|
* 推送订单信息
|
* @param item 推送基础信息
|
* @param command 推送基础信息类型
|
* @return 监管平台原始响应
|
*/
|
private String pushOrderReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"ORDER",command);
|
}
|
|
/**
|
* 推送营运信息
|
* @param item 推送营运信息
|
* @param command 推送营运信息类型
|
* @return 监管平台原始响应
|
*/
|
private String pushOperationReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"OPERATE",command);
|
}
|
|
/**
|
* 推送服务质量信息
|
* @param item 推送服务质量信息
|
* @param command 推送服务质量信息类型
|
* @return 监管平台原始响应
|
*/
|
private String pushQualityReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"QUALITY",command);
|
}
|
|
/**
|
* 推送注册报备信息
|
* @param item 推送注册报备信息
|
* @param command 推送注册报备信息类型
|
* @return 监管平台原始响应
|
*/
|
private String pushRegistReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"REGIST",command);
|
}
|
|
/**
|
* 推送GPS信息
|
* @param item 推送信息
|
* @param command 推送信息关键字
|
* @return 监管平台原始响应
|
*/
|
private String pushGpsReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"GPS",command);
|
}
|
|
/**
|
* 推送服务质量信息
|
* @param item 推送信息
|
* @param command 推送信息关键字
|
* @return 监管平台原始响应
|
*/
|
private String pushEvaluateReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"EVALUATE",command);
|
}
|
|
/**
|
* 推送人车关系信息
|
* @param item 推送信息
|
* @param command 推送信息关键字
|
* @return 监管平台原始响应
|
*/
|
private String pushRelationshipReqInfo(JSONObject item,String command) {
|
return pushReqInfo(item,"RELATIONSHIP",command);
|
}
|
|
|
|
/**
|
* 推送信息
|
* @param item 推送信息
|
* @param type 推送信息类型
|
* @param command 推送信息关键字
|
* @return 监管平台原始响应
|
*/
|
private String pushReqInfo(JSONObject item,String type,String command) {
|
String token = parseToken(getToken());
|
JSONObject body = new JSONObject();
|
JSONArray items = new JSONArray();
|
items.add(item);
|
body.put("items", items);
|
|
String format = LocalDateTime.now().format(FILE_TIME_FORMATTER);
|
String filename = platform + "_"+ type +"_"+ command +"_REQ_" + format + ".json";
|
return uploadJsonFile(filename, body.toJSONString(), token);
|
}
|
|
|
private JSONObject buildPlatformBaseInfo() {
|
JSONObject item = new JSONObject();
|
item.put("symbol", DEFAULT_SYMBOL);
|
item.put("companyId", companyId);
|
item.put("companyName", "广州易点智慧出行科技有限公司");
|
item.put("identifier", "91440101MA5AWEB67N");
|
item.put("contactPhone", "18306304567");
|
item.put("address", "440000");
|
item.put("businessScope", "网络预约出租汽车客运");
|
item.put("contactAddress", "广州市天河区岑村丰庄大街10号T2");
|
item.put("economicType", "159");
|
item.put("regCapital", "壹仟万元(人民币)");
|
item.put("legalName", "陈志远");
|
item.put("legalId", "445221199101121937");
|
item.put("legalPhone", "15915905487");
|
item.put("legalPhoto", encodePdf("陈志远新复印件.pdf"));
|
item.put("legalPhotoId", "");
|
item.put("identifierPhoto", encodePdf("易点智慧出行-营副-20250716.pdf"));
|
item.put("state", "0");
|
item.put("flag", "1");
|
item.put("updateTime", LocalDateTime.now().format(DATA_TIME_FORMATTER));
|
item.put("serviceItem", "网络预约出租汽车服务");
|
item.put("servicePromise", "严格遵守国家及地方有关网络预约出租汽车经营的法律法规及行业规范,依法取得相关许可,证照齐全、亮证经营");
|
item.put("protocolVersion", DEFAULT_PROTOCOL_VERSION);
|
return item;
|
}
|
|
private JSONObject buildPlatformOperationScaleInfo() {
|
JSONObject item = new JSONObject();
|
item.put("symbol", DEFAULT_SYMBOL);
|
item.put("companyId", companyId);
|
item.put("vehicleNum", "1"); //TODO 后续补充完整
|
item.put("driverNum", "1"); //TODO 后续补充完整
|
item.put("flag", "1");
|
item.put("updateTime", LocalDateTime.now().format(DATA_TIME_FORMATTER));
|
item.put("protocolVersion", DEFAULT_PROTOCOL_VERSION);
|
return item;
|
}
|
|
private JSONObject buildVehicleBaseInfo(RegulationVehicleBaseInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车车辆基本信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildVehicleInsuranceInfo(RegulationVehicleInsuranceInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车车辆保险信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildVehicleMileageInfo(RegulationVehicleMileageInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车车辆里程信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverBaseInfo(RegulationDriverBaseInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车驾驶员基本信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverTrainingInfo(RegulationDriverTrainingInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车驾驶员培训信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverMobileTerminalInfo(RegulationDriverMobileTerminalInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车驾驶员移动终端信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverStatisticsInfo(RegulationDriverStatisticsInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车驾驶员统计信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPassengerBaseInfo(RegulationPassengerBaseInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车乘客基本信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformInvestorInfo(RegulationPlatformInvestorInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车平台投资人信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverContractInfo(RegulationDriverContractInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("驾驶员合同信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildOrderCreateInfo(RegulationOrderCreateInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("订单发起信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildOrderMatchInfo(RegulationOrderMatchInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("订单成功信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildOrderCancelInfo(RegulationOrderCancelInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("订单撤销信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildOrderViolationInfo(RegulationOrderViolationInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("订单违约信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildVehicleOperateLoginInfo(RegulationVehicleOperateLoginInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("车辆营运上线信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildVehicleOperateLogoutInfo(RegulationVehicleOperateLogoutInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("车辆营运下线信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildOperateDepartInfo(RegulationOperateDepartInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("营运出发信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildOperateArriveInfo(RegulationOperateArriveInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("营运到达信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildOperatePayInfo(RegulationOperatePayInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("营运支付信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverPositionInfo(RegulationDriverPositionInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("驾驶员定位信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPassengerEvaluateInfo(RegulationPassengerEvaluateInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("乘客评价信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPassengerComplaintInfo(RegulationPassengerComplaintInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("乘客投诉处理信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildVehicleCancelReportInfo(RegulationVehicleCancelReportInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("车辆注销报备信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverPunishInfo(RegulationDriverPunishInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("驾驶员处罚信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverReputationInfo(RegulationDriverReputationInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("驾驶员信誉信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverVehicleRelationInfo(RegulationDriverVehicleRelationInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("人车对应关系信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformOperationRegisterInfo(RegulationPlatformOperationRegisterInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("平台营运报备信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformPauseOperationRegisterInfo(RegulationPlatformPauseOperationRegisterInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("平台暂停营运报备信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformAggregationInfo(RegulationPlatformAggregationInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("合作聚合平台信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildVehicleOperationRegisterInfo(RegulationVehicleOperationRegisterInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("车辆营运报备信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverRegisterInfo(RegulationDriverRegisterInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("驾驶员注册报备信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildDriverCancelRegisterInfo(RegulationDriverCancelRegisterInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("驾驶员注销注册信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformPayInfo(RegulationPlatformPayInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车平台公司支付信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformServiceInfo(RegulationPlatformServiceInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车平台公司服务机构信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformLicenseInfo(RegulationPlatformLicenseInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车平台公司经营许可信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private JSONObject buildPlatformPriceInfo(RegulationPlatformPriceInfoDTO dto) {
|
if (dto == null) {
|
throw new RuntimeException("网约车平台公司计程计价方式信息不能为空");
|
}
|
return (JSONObject) JSON.toJSON(dto);
|
}
|
|
private String encodePdf(String filename) {
|
if (filename == null || filename.trim().isEmpty()) {
|
return "";
|
}
|
String resourcePath = "files/" + filename.trim();
|
ClassPathResource resource = new ClassPathResource(resourcePath);
|
try {
|
long contentLength = resource.contentLength();
|
if (contentLength > 10 * 1024 * 1024) {
|
throw new RuntimeException("文件超过10M: " + filename);
|
}
|
try (InputStream inputStream = resource.getInputStream()) {
|
byte[] bytes = new byte[(int) contentLength];
|
int offset = 0;
|
int read;
|
while (offset < bytes.length && (read = inputStream.read(bytes, offset, bytes.length - offset)) != -1) {
|
offset += read;
|
}
|
if (offset != bytes.length) {
|
throw new RuntimeException("文件读取不完整: " + filename);
|
}
|
return Base64.getEncoder().encodeToString(bytes);
|
}
|
} catch (Exception e) {
|
throw new RuntimeException("读取PDF文件失败: " + filename, e);
|
}
|
}
|
|
private String uploadJsonFile(String filename, String jsonBody, String auth) {
|
try {
|
byte[] bytes = jsonBody.getBytes("UTF-8");
|
String md5 = hash(new ByteArrayInputStream(bytes));
|
HttpPost post = new HttpPost(url);
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
post.addHeader("binfile-md5", md5);
|
post.addHeader("binfile-auth", auth);
|
post.addHeader("binfile-gzip", "false");
|
post.addHeader("binfile-reqlen", String.valueOf(bytes.length));
|
builder.addBinaryBody("binFile", new ByteArrayInputStream(bytes), ContentType.DEFAULT_BINARY, filename);
|
builder.addTextBody("filename", filename, ContentType.create(ContentType.DEFAULT_TEXT.getMimeType(), "UTF-8"));
|
post.setEntity(builder.build());
|
|
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
|
RequestConfig requestConfig = RequestConfig.custom()
|
.setConnectTimeout(10000)
|
.build();
|
clientBuilder.setDefaultRequestConfig(requestConfig);
|
clientBuilder.disableContentCompression();
|
try (CloseableHttpClient client = clientBuilder.build()) {
|
HttpResponse response = client.execute(post);
|
String responseBody = response.getEntity() == null ? "" : EntityUtils.toString(response.getEntity(), "UTF-8");
|
log.info("交通部接口响应 status={}, filename={}, responseLength={}",
|
response.getStatusLine().getStatusCode(), filename, responseBody.length());
|
return responseBody;
|
}
|
} catch (Exception e) {
|
throw new RuntimeException("上传交通部接口文件失败: " + filename, e);
|
}
|
}
|
|
private String parseToken(String tokenResponse) {
|
if (StringUtils.isBlank(tokenResponse)) {
|
throw new RuntimeException("交通部token响应为空");
|
}
|
try {
|
JSONObject response = JSON.parseObject(tokenResponse);
|
String token = response.getString("token");
|
if (StringUtils.isNotBlank(token)) {
|
return token;
|
}
|
JSONArray items = response.getJSONArray("items");
|
if (items != null && !items.isEmpty()) {
|
token = items.getJSONObject(0).getString("token");
|
if (StringUtils.isNotBlank(token)) {
|
return token;
|
}
|
}
|
} catch (Exception e) {
|
throw new RuntimeException("解析交通部token失败: " + tokenResponse, e);
|
}
|
throw new RuntimeException("交通部token响应中未找到token: " + tokenResponse);
|
}
|
|
|
|
|
private static char[] commonDigit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
|
public static String hash(InputStream in)
|
{
|
try
|
{
|
byte[] buffer = new byte[1024];
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
int numRead = 0;
|
while ((numRead = in.read(buffer)) > 0)
|
{
|
md5.update(buffer, 0, numRead);
|
}
|
in.close();
|
return toHexString(md5.digest());
|
}
|
catch (Exception e)
|
{
|
return "";
|
}
|
}
|
|
private static String toHexString(byte[] b)
|
{
|
StringBuilder sb = new StringBuilder(b.length * 2);
|
for (int i = 0; i < b.length; i++)
|
{
|
sb.append(commonDigit[(b[i] & 0xf0) >>> 4]);
|
sb.append(commonDigit[b[i] & 0x0f]);
|
}
|
return sb.toString();
|
}
|
|
}
|