|
|
@@ -1,12 +1,12 @@
|
|
|
package com.jzg.quotation.taikang.crawler.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.jzg.commons.constants.quote.enums.quote.CarKindCode;
|
|
|
-import com.jzg.commons.constants.quote.enums.quote.VehicleUseCode;
|
|
|
+
|
|
|
import com.jzg.commons.entity.quote.vo.CarInfoVo;
|
|
|
import com.jzg.commons.entity.quote.vo.CustomerInfoVo;
|
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
+
|
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
|
import com.jzg.quotation.taikang.crawler.CodeUtil;
|
|
|
import com.jzg.quotation.taikang.crawler.JsonUtil;
|
|
|
@@ -395,137 +395,126 @@ public class TKHttpAPIService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 09 交管车辆类型校验
|
|
|
+ * 交管车辆类型校验
|
|
|
+ * <p>
|
|
|
+ * 该方法负责构建车辆类型校验参数,调用保司接口进行交管车辆类型校验。
|
|
|
+ * <p>
|
|
|
+ * 主要处理逻辑:
|
|
|
+ * 1. 参数初始化:设置渠道代码、订单ID和车型信息
|
|
|
+ * 2. 车主信息构建:从公司系统参数提取车主信息
|
|
|
+ * 3. 投保人信息构建:初始化投保人、被保险人、联系人信息
|
|
|
+ * 4. 车辆信息构建:设置车辆基本信息、类型、过户状态、使用性质等
|
|
|
+ * 5. 请求组装:组装完整的校验参数并调用保司接口
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @param session 登录会话信息
|
|
|
+ * @param commonQuoteVo 公司系统报价参数
|
|
|
+ * @param mainOrderId 主订单ID
|
|
|
+ * @param carModelinfoQueryResult 车型查询结果
|
|
|
+ * @return 校验结果
|
|
|
*/
|
|
|
public String carModelinfoCheckVehicleType(TKLoginSession session, QuoteVo commonQuoteVo, String mainOrderId, CarModelinfoQueryResult carModelinfoQueryResult) {
|
|
|
- CarModelinfoCheckVehicleTypeParam carModelinfoCheckVehicleTypeParam = new CarModelinfoCheckVehicleTypeParam();
|
|
|
- carModelinfoCheckVehicleTypeParam.setChannelCode("OffWeb");
|
|
|
- carModelinfoCheckVehicleTypeParam.setOrderId(mainOrderId);
|
|
|
- TKCarModel tkCarModel = CarModelsFilterUtils.to(carModelinfoQueryResult.getCarModel(), commonQuoteVo.getCarInfoVo());
|
|
|
+ // ========== 1. 参数初始化 ==========
|
|
|
+
|
|
|
+ CarModelinfoCheckVehicleTypeParam param = new CarModelinfoCheckVehicleTypeParam();
|
|
|
+ param.setChannelCode("OffWeb");
|
|
|
+ param.setOrderId(mainOrderId);
|
|
|
+
|
|
|
+ // 获取车型信息并设置必要字段
|
|
|
+ TKCarModel tkCarModel = CarModelsFilterUtils.to(
|
|
|
+ carModelinfoQueryResult.getCarModel(),
|
|
|
+ commonQuoteVo.getCarInfoVo()
|
|
|
+ );
|
|
|
tkCarModel.setVehicleStyleUniqueId("");
|
|
|
- CarModelinfoQueryResult.CarInfoDto carInfoDto = carModelinfoQueryResult.getCarInfoDto();
|
|
|
-
|
|
|
- // 车辆所有人信息
|
|
|
- TKCarOwnerVo carOwnerVo = new TKCarOwnerVo();
|
|
|
- CustomerInfoVo commonCustomersInfo = commonQuoteVo.getOwnersInfo();
|
|
|
- if (commonCustomersInfo != null) {
|
|
|
- carOwnerVo.setCarOwnerNature("1"); // todo
|
|
|
- carOwnerVo.setCertificateType("01"); // 身份证
|
|
|
- carOwnerVo.setId(commonCustomersInfo.getIdentifyNumber());
|
|
|
- carOwnerVo.setName(commonCustomersInfo.getName());
|
|
|
- carOwnerVo.setBirthDate(commonCustomersInfo.getBirthday());
|
|
|
- carOwnerVo.setSerialno(BigDecimal.ZERO);
|
|
|
- carOwnerVo.setSex(commonCustomersInfo.getGender()); // todo
|
|
|
- carOwnerVo.setInsuredAddress("");
|
|
|
- }
|
|
|
|
|
|
+ // ========== 2. 车主信息构建 ==========
|
|
|
+
|
|
|
+ TKCarOwnerVo carOwnerVo = TKCommonUtil.buildCarOwnerVo(commonQuoteVo.getOwnersInfo());
|
|
|
+
|
|
|
+ // ========== 3. 投保人信息构建 ==========
|
|
|
|
|
|
- // 投保人信息
|
|
|
SaveBasicInfoParam.InsureInfo insureInfo = new SaveBasicInfoParam.InsureInfo();
|
|
|
insureInfo.setAppliInfo(new SaveBasicInfoParam.AppliInfo());
|
|
|
insureInfo.setInsuredInfo(new SaveBasicInfoParam.InsuredInfo());
|
|
|
insureInfo.setContacts(new SaveBasicInfoParam.Contacts());
|
|
|
|
|
|
- // 车辆信息
|
|
|
- TKCar car = new TKCar();
|
|
|
- car.setFuelType(tkCarModel.getFuelType()); // todo 燃油类型
|
|
|
- car.setModelName(tkCarModel.getModelName()); // todo
|
|
|
- car.setBillDate(""); // 页面上没有输入框,可能是北京地区才用到
|
|
|
- car.setCarBookingTime(""); // 页面上没有输入框,原注释为“上海地区开具发票日期”,但感觉是车辆时间。
|
|
|
- car.setBillNo(""); // 页面上没有输入框,发票号
|
|
|
-
|
|
|
- CarInfoVo commonCarInfoVo = commonQuoteVo.getCarInfoVo();
|
|
|
-
|
|
|
- if (commonCarInfoVo != null) {
|
|
|
- // 车辆大类
|
|
|
- String carKindCode = commonCarInfoVo.getCarKindCode();
|
|
|
-
|
|
|
- if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A0.getCode())) {
|
|
|
- car.setCarType("A");
|
|
|
- } else if (carKindCode.equals(CarKindCode.CAR_KIND_CODE_A1.getCode())) {
|
|
|
- car.setCarType("D");
|
|
|
- } else {
|
|
|
- throw new RuntimeException("未知车辆大类:" + carKindCode);
|
|
|
- }
|
|
|
+ // ========== 4. 车辆信息构建 ==========
|
|
|
|
|
|
- CodeUtil.autoSetter(car::setLicenseNo, commonCarInfoVo::getLicenseNo, tkCarModel::getLicenseNo);
|
|
|
- car.setVinNo(commonCarInfoVo.getVinNo());
|
|
|
- car.setEngineNo(commonCarInfoVo.getEngineNo());
|
|
|
- car.setEnrollDate(commonCarInfoVo.getRegisterDate());
|
|
|
- CodeUtil.autoSetter(car::setTransferDate, commonCarInfoVo::getTransferDate, null);
|
|
|
- CodeUtil.autoSetter(car::setPurchasePrice, commonCarInfoVo::getPurchasePrice, tkCarModel::getReplacementValue);
|
|
|
- CodeUtil.autoSetter(car::setSelectedSeat, commonCarInfoVo::getSeatCount, () -> tkCarModel.getVehicleJingyou().getSeat());
|
|
|
- CodeUtil.autoSetter(car::setExhaustScale, commonCarInfoVo::getDisplacement, tkCarModel::getDisplacement); // 排量
|
|
|
- CodeUtil.autoSetter(car::setBrandName, commonCarInfoVo::getBrandName, tkCarModel::getModelName); // todo 与 tkCarModel.getModelName() 重复
|
|
|
-
|
|
|
- car.setSeatFlag(1); // todo
|
|
|
- car.setExhaustScale(tkCarModel.getDisplacement().substring(0, tkCarModel.getDisplacement().indexOf(".")));
|
|
|
- car.setPurchasePrice(tkCarModel.getPurchasePrice().substring(0, tkCarModel.getPurchasePrice().indexOf(".")));
|
|
|
-
|
|
|
- Double tonCount = commonCarInfoVo.getTonCountDouble();
|
|
|
- if (tonCount != null && tonCount > 2) {
|
|
|
- // 好像主要是货车使用此字段
|
|
|
- car.setTonnageFlag("1");
|
|
|
- } else {
|
|
|
- car.setTonnageFlag("0");
|
|
|
- }
|
|
|
-
|
|
|
- if (commonCarInfoVo.isTransfer()) {
|
|
|
- car.setChgOwnerFlag("1"); // 是过户
|
|
|
- car.setTransferDate(commonCarInfoVo.getTransferDate()); // 过户时间
|
|
|
- } else {
|
|
|
- car.setChgOwnerFlag("0"); // 不是过户
|
|
|
- car.setTransferDate("");
|
|
|
- }
|
|
|
-
|
|
|
- String vehicleUseCode = commonCarInfoVo.getVehicleUseCode();
|
|
|
-
|
|
|
- if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_05.getCode())) {
|
|
|
- // 05 家庭自用 = 8A 家庭自用
|
|
|
- car.setUseNatureCodeCode("8A"); // 页面上选择的家庭自用、非营业企业、、、、
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_06.getCode())) {
|
|
|
- // 06 非营业企业 = 8C 非营业党政机关事业团体
|
|
|
- car.setUseNatureCodeCode("8C");
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_07.getCode())) {
|
|
|
- // 07 非营业企业 = 8B 非营业企业
|
|
|
- car.setUseNatureCodeCode("8B");
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_01.getCode())) {
|
|
|
- // 01 营业出租租赁 = 9 营业
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_02.getCode())) {
|
|
|
- // 02 营业城市公交 = 9 营业
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_03.getCode())) {
|
|
|
- // 03 营业公路客运 = 9 营业
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
- } else if (vehicleUseCode.equals(VehicleUseCode.VEHICLE_USE_CODE_04.getCode())) {
|
|
|
- // 04 营业货运 = 9 营业
|
|
|
- car.setUseNatureCodeCode("9");
|
|
|
- } else {
|
|
|
- // 默认 8B 非营业企业
|
|
|
- car.setUseNatureCodeCode("8B");
|
|
|
- }
|
|
|
- TKSimpleService.setLicenseTypeByLicenseNo(car, car.getLicenseNo());
|
|
|
- }
|
|
|
+ TKCar car = new TKCar();
|
|
|
|
|
|
- String passengerSeat = this.carTypePassengerSeat(session.getToken(), session.getTplatformId(), session.getFromid(), session.getComCode());
|
|
|
+ // 设置车辆基本信息
|
|
|
+ TKCommonUtil.buildCarBasicInfo(car, tkCarModel);
|
|
|
+
|
|
|
+ // 使用 Optional 处理车辆信息的空值情况
|
|
|
+ Optional.ofNullable(commonQuoteVo.getCarInfoVo())
|
|
|
+ .ifPresent(commonCarInfoVo -> {
|
|
|
+ // 设置车辆大类(通过辅助方法解析)
|
|
|
+ car.setCarType(TKCommonUtil.resolveCarType(commonCarInfoVo.getCarKindCode()));
|
|
|
+
|
|
|
+ // 使用 autoSetter 设置可选字段(优先使用公司系统值,其次使用车型查询值)
|
|
|
+ CodeUtil.autoSetter(car::setLicenseNo, commonCarInfoVo::getLicenseNo, tkCarModel::getLicenseNo);
|
|
|
+ CodeUtil.autoSetter(car::setTransferDate, commonCarInfoVo::getTransferDate, null);
|
|
|
+ CodeUtil.autoSetter(car::setPurchasePrice, commonCarInfoVo::getPurchasePrice, tkCarModel::getReplacementValue);
|
|
|
+ CodeUtil.autoSetter(car::setSelectedSeat, commonCarInfoVo::getSeatCount, () -> tkCarModel.getVehicleJingyou().getSeat());
|
|
|
+ CodeUtil.autoSetter(car::setExhaustScale, commonCarInfoVo::getDisplacement, tkCarModel::getDisplacement);
|
|
|
+ CodeUtil.autoSetter(car::setBrandName, commonCarInfoVo::getBrandName, tkCarModel::getModelName);
|
|
|
+
|
|
|
+ // 设置固定字段和从车型提取的字段(去掉小数部分)
|
|
|
+ car.setSeatFlag(1);
|
|
|
+ car.setExhaustScale(TKCommonUtil.substringBeforeDot(tkCarModel.getDisplacement()));
|
|
|
+ car.setPurchasePrice(TKCommonUtil.substringBeforeDot(tkCarModel.getPurchasePrice()));
|
|
|
+ car.setVinNo(commonCarInfoVo.getVinNo());
|
|
|
+ car.setEngineNo(commonCarInfoVo.getEngineNo());
|
|
|
+ car.setEnrollDate(commonCarInfoVo.getRegisterDate());
|
|
|
+
|
|
|
+ // 设置吨位标志(两吨以上货车标记为1)
|
|
|
+ car.setTonnageFlag(Optional.ofNullable(commonCarInfoVo.getTonCountDouble())
|
|
|
+ .filter(ton -> ton > 2)
|
|
|
+ .map(ton -> "1")
|
|
|
+ .orElse("0"));
|
|
|
+
|
|
|
+ // 设置过户标志和过户时间
|
|
|
+ if (commonCarInfoVo.isTransfer()) {
|
|
|
+ car.setChgOwnerFlag("1");
|
|
|
+ car.setTransferDate(commonCarInfoVo.getTransferDate());
|
|
|
+ } else {
|
|
|
+ car.setChgOwnerFlag("0");
|
|
|
+ car.setTransferDate("");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置车辆使用性质(通过映射表转换,默认8B非营业企业)
|
|
|
+ String vehicleUseCode = commonCarInfoVo.getVehicleUseCode();
|
|
|
+ car.setUseNatureCodeCode(TKCommonUtil.VEHICLE_USE_CODE_MAP.getOrDefault(vehicleUseCode, "8B"));
|
|
|
+
|
|
|
+ // 设置车牌类型
|
|
|
+ TKSimpleService.setLicenseTypeByLicenseNo(car, car.getLicenseNo());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 根据渠道调整车辆类型
|
|
|
+ String passengerSeat = this.carTypePassengerSeat(
|
|
|
+ session.getToken(),
|
|
|
+ session.getTplatformId(),
|
|
|
+ session.getFromid(),
|
|
|
+ session.getComCode()
|
|
|
+ );
|
|
|
+ Optional.ofNullable(carType(passengerSeat, car.getCarType(), carOwnerVo.getCarOwnerNature()))
|
|
|
+ .ifPresent(car::setCarType);
|
|
|
+
|
|
|
+ // 设置车型列表和品牌名称
|
|
|
+ car.setCarModel(List.of(tkCarModel));
|
|
|
+ car.setBrandName(tkCarModel.getModelName());
|
|
|
|
|
|
- String carType = carType(passengerSeat, car.getCarType(), carOwnerVo.getCarOwnerNature());
|
|
|
+ // ========== 5. 请求组装与调用 ==========
|
|
|
|
|
|
- if (carType != null) {
|
|
|
- car.setCarType(carType);
|
|
|
- }
|
|
|
- car.setCarModel(Arrays.asList(tkCarModel));
|
|
|
- car.setBrandName(tkCarModel.getModelName());
|
|
|
+ // 将 TKCar 转换为接口所需的 CarInfoVo 类型
|
|
|
CarModelinfoCheckVehicleTypeParam.CarInfoVo carInfoVo = BeanUtil.copyProperties(car, CarModelinfoCheckVehicleTypeParam.CarInfoVo.class);
|
|
|
- carModelinfoCheckVehicleTypeParam.setCarInfoVo(carInfoVo);
|
|
|
-
|
|
|
+ param.setCarInfoVo(carInfoVo);
|
|
|
|
|
|
+ // 设置请求头并调用接口
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.add("tkCarRequestToken", session.getToken());
|
|
|
- StringResponse response = client.request(HttpURL.carModelinfoCheckVehicleType, carModelinfoCheckVehicleTypeParam, httpHeaders, StringResponse.class);
|
|
|
+ StringResponse response = client.request(HttpURL.carModelinfoCheckVehicleType, param, httpHeaders, StringResponse.class);
|
|
|
+
|
|
|
+ // 校验响应并返回结果
|
|
|
checkResponseUnknownField(response);
|
|
|
return response.getData();
|
|
|
}
|