| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327 |
- package com.ydtech.modules.ins.service.impl;
- import cn.hutool.core.collection.CollUtil;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.fasterxml.jackson.annotation.JsonInclude;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.fasterxml.jackson.databind.*;
- import com.fasterxml.jackson.dataformat.xml.XmlMapper;
- import com.ydtech.components.InsAlltrustRequestApiComponents;
- import com.ydtech.constants.InsTaskHistoryEnum;
- import com.ydtech.constants.SysConstants;
- import com.ydtech.constants.enums.InsQuoteFlow;
- import com.ydtech.constants.enums.InsuranceRisk;
- import com.ydtech.constants.enums.dict.AttachInsureEnum;
- import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
- import com.ydtech.constants.enums.dict.WhetherEnum;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.admin.service.SysDeptService;
- import com.ydtech.modules.admin.service.SysUserService;
- import com.ydtech.modules.esm.dao.EsmInsAttachInsureDetailsMapper;
- import com.ydtech.modules.esm.dao.EsmInsAttachInsureMapper;
- import com.ydtech.modules.esm.model.*;
- import com.ydtech.modules.esm.service.*;
- import com.ydtech.modules.ins.dao.InsAlltrustRegionMapper;
- import com.ydtech.modules.ins.model.InsApiLog;
- import com.ydtech.modules.ins.model.InsOrder;
- import com.ydtech.modules.ins.model.dto.CarInsDateDto;
- import com.ydtech.modules.ins.model.dto.CarInsPolicyDto;
- import com.ydtech.modules.ins.model.vo.CarInfoVo;
- import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
- import com.ydtech.modules.ins.model.vo.QuoteRespVo;
- import com.ydtech.modules.ins.model.vo.RiskInfoVo;
- import com.ydtech.modules.ins.model.ya.CarModelDTO;
- import com.ydtech.modules.ins.model.ya.CarModel_Req;
- import com.ydtech.modules.ins.model.ya.YaQuoteInfoVo;
- import com.ydtech.modules.ins.model.yc.*;
- import com.ydtech.modules.ins.model.yc.accident.response.ResponseYwCvrg;
- import com.ydtech.modules.ins.model.yc.audit.Audit;
- import com.ydtech.modules.ins.model.yc.audit.response.AuditResponse;
- import com.ydtech.modules.ins.model.yc.callbackAnOrder.CallbackAnOrder;
- import com.ydtech.modules.ins.model.yc.imageUp.ImageUp;
- import com.ydtech.modules.ins.model.yc.imageUp.response.ImageUpResponse;
- import com.ydtech.modules.ins.model.yc.modelsQuery.ModelsQueryResponse;
- import com.ydtech.modules.ins.model.yc.modelsQuery.ModelsQueryXml;
- import com.ydtech.modules.ins.model.yc.accident.Accident;
- import com.ydtech.modules.ins.model.yc.pay.Pay;
- import com.ydtech.modules.ins.model.yc.pay.response.AccidentResponse;
- import com.ydtech.modules.ins.model.yc.pay.response.PayResponse;
- import com.ydtech.modules.ins.model.yc.policy.Policy;
- import com.ydtech.modules.ins.model.yc.policy.response.PolicyResponse;
- import com.ydtech.modules.ins.model.yc.ruote.*;
- import com.ydtech.modules.ins.model.yc.ruote.response.ProposalResponse;
- import com.ydtech.modules.ins.model.yc.ruote.response.RuoteResponse;
- import com.ydtech.modules.ins.model.yc.ruote.response.TfiWarnListResponse;
- import com.ydtech.modules.ins.service.*;
- import com.ydtech.modules.order.components.ConfigureParametersComponents;
- import com.ydtech.modules.order.components.InsOrdersComponents;
- import com.ydtech.modules.order.entity.InsAreaCompany;
- import com.ydtech.modules.order.entity.InsOrders;
- import com.ydtech.modules.order.entity.po.InsTaskImagesBase64;
- import com.ydtech.modules.order.entity.vo.*;
- import com.ydtech.modules.order.service.InsAreaCompanyService;
- import com.ydtech.modules.order.service.InsOrdersService;
- import com.ydtech.modules.order.service.InsTaskImagesService;
- import com.ydtech.modules.protocol.utils.AssertionUtils;
- import com.ydtech.utils.*;
- import com.ydtech.utils.baidu.FileUtil;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.BeanUtils;
- 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.io.IOException;
- import java.math.BigDecimal;
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- import java.text.SimpleDateFormat;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.util.*;
- import java.util.concurrent.atomic.AtomicInteger;
- import java.util.stream.Collectors;
- @Service
- public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
- private static final Logger log = LoggerFactory.getLogger("alltrust");
- @Autowired
- private InsAlltrustRequestApiComponents apiComponents;
- @Autowired
- private InsAlltrustRegionMapper insAlltrustRegionMapper;
- @Autowired
- private InsOrdersComponents insOrdersComponents;
- private AuthorityDataXml authorityDataXml = null;
- // private ObjectMapper xmlMapper = null;
- //请求信息列表
- List<String> requestInfoList = new ArrayList<>();
- @Value("${upload.file.path}")
- private String uploadFilePath;
- @Value("${upload.file.url}")
- private String showFileUrl;
- @Value("${api.url}")
- private String apiUrl;
- @Autowired
- private YcBuildData ycBuildData;
- @Autowired
- private SysUserService sysUserService;
- @Autowired
- private SysDeptService sysDeptService;
- @Autowired
- private EsmRetailService esmRetailService;
- @Autowired
- private EsmAgreementService esmAgreementService;
- @Autowired
- private EsmAgreementProdService esmAgreementProdService;
- // @Autowired
- // private EsmUserInternalService esmUserInternalService;
- @Autowired
- private InsTaskHistoryService insTaskHistoryService;
- @Autowired
- private InsAreaCompanyService insAreaCompanyService;
- @Autowired
- private InsOrdersService insOrdersService;
- @Autowired
- private InsTaskImagesService insTaskImagesService;
- @Autowired
- private EsmInsAttachInsureMapper esmInsAttachInsureMapper;
- @Autowired
- private EsmInsAttachInsureDetailsMapper esmInsAttachInsureDetailsMapper;
- @Autowired
- private EsmInsCompanyService esmInsCompanyService;
- @Autowired
- InsApiLogService insApiLogService;
- @Autowired
- ConfigureParametersComponents configureParametersComponents;
- // /**
- // * @description: 获取验证数据
- // * @author: lig
- // * @date: 2023年02月07日 0007
- // */
- // private AuthorityDataXml gainAuthorityDataXml() {
- // if (null == authorityDataXml) {
- // authorityDataXml = new AuthorityDataXml();
- // authorityDataXml.setUserName(apiComponents.getUserName());
- // authorityDataXml.setPassword(apiComponents.getPassword());
- // }
- // return authorityDataXml;
- // }
- // /**
- // * 获取渠道
- // */
- // public Agent gainAgent() {
- // return apiComponents.gainAgent();
- //// if (null == agent) {
- //// agent = new Agent();
- //// agent.setAgentCode(agentCode);
- //// agent.setConferCode(agentType);
- //// agent.setAgentType(agentType);
- //// agent.setAgentNme(agentNme);
- //// agent.setQlftNo(qlftNo);
- //// agent.setCustNature(custNature);
- //// agent.setAgentProfId(agentCode);
- //// agent.setSubCoNo(agentType);
- //// }
- //// return agent;
- // }
- private ObjectMapper gainXmlMapper() {
- ObjectMapper xmlMapper = new XmlMapper();
- xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- xmlMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
- xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- xmlMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
- xmlMapper.enable(MapperFeature.USE_STD_BEAN_NAMING);
- xmlMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
- return xmlMapper;
- }
- //
- //==============================API 方式
- //
- public void gainVehicleModel(YcConfigureParameters ycConfigureParameters, CarInfoVo carInfo) {
- CarModel_Req carModelReq = new CarModel_Req();
- carModelReq.setFrameNo(carInfo.getFrameNo());
- carModelReq.setEngineNo(carInfo.getEngineNo());
- carModelReq.setEnrollDate(carInfo.getRegisterDate().replaceAll("-", ""));
- log.info("===永诚--车型查询接口请求 =====参数确认:--" + ycConfigureParameters.getDptCde() + "===");
- ModelsQueryXml m = buildModelsQueryParam(carModelReq, ycConfigureParameters);
- log.info("===永诚--车型查询接口请求开始--" + carInfo.getLicenseNo() + "===");
- // InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
- String responseData = httpPostResultLog(m, YcBuildData.API_MODEL, "永诚API方式 - 车型查询(vin:"+carInfo.getVinNo()+") - ");
- AssertionUtils.isEmpty(responseData,"永诚 车型查询接口响应返回空!");
- // String responseData = apiLog.getResponseData();
- log.info("===永诚--车型查询接口请求结束--" + carInfo.getLicenseNo() + "===");
- ModelsQueryResponse rd = null;
- try {
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- rd = gainXmlMapper().readValue(cleanStr, ModelsQueryResponse.class);
- // List<ModelsQueryResponse.VehicleInfo> vehicleInfoList = buildCarModel(rd);
- } catch (IOException e) {
- throw new SystemException("车型查询接口异常,请联系管理。");
- }
- if (CollUtil.isEmpty(rd.getVehicleInfoList())) throw new SystemException("永诚车型库查找失败");
- //车辆年款不能超过注册日期
- List<ModelsQueryResponse.VehicleInfo> vehicleInfoList = rd.getVehicleInfoList().stream().filter(a -> DateTimeUtil.dateIsAfter(carInfo.getRegisterDate(), a.getVehicleYear())).sorted(Comparator.comparing(ModelsQueryResponse.VehicleInfo::getVehiclePrice)).collect(Collectors.toList());
- // List<ModelsQueryResponse.VehicleInfo> vehicleInfoList = rd.getVehicleInfoList().stream().filter(a -> DateTimeUtil.dateIsAfter(carInfo.getRegisterDate(), a.getVehicleYear())).collect(Collectors.toList());
- //匹配的车辆信息数据 为空
- if (CollUtil.isEmpty(vehicleInfoList)) {
- buildCarInfo(carInfo, rd.getVehicleInfoList().get(0));
- return;
- }
- //匹配的车辆信息数据
- ModelsQueryResponse.VehicleInfo matchVehicleInfo = vehicleInfoList.stream().filter(a -> a.getVehiclePrice().equals(carInfo.getPurchasePrice())).findFirst().orElse(null);
- if (null != matchVehicleInfo) {
- buildCarInfo(carInfo, matchVehicleInfo);
- return;
- }
- //匹配的车辆信息数据里 未匹配成功 默认选择第一条
- //排序 年款降序 金额升序
- vehicleInfoList = vehicleInfoList.stream().sorted(Comparator.comparing(ModelsQueryResponse.VehicleInfo::getVehicleYear)
- .thenComparing((o1, o2) -> Integer.compare(StringUtils.toInt(o2.getVehiclePrice()), StringUtils.toInt(o1.getVehiclePrice()))).reversed())
- .collect(Collectors.toList());
- buildCarInfo(carInfo, vehicleInfoList.get(0));
- }
- /**
- * 2 报价
- */
- @Override
- @Transactional
- public HttpResult quoteApi(BaseQuoteVo<AccidentalDrivingVo> quoteVo) {
- requestInfoList = new ArrayList<>();
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(quoteVo.getAgreementId());
- BaseQuoteInfoVo yaQuoteInfoVo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo());
- CarInfoVo carInfo = yaQuoteInfoVo.getCarInfo();
- //构造车辆信息
- gainVehicleModel(ycConfigureParameters, carInfo);
- // ObjectMapper xmlMapper = this.gainXmlMapper();
- InsAreaCompany iac = null;
- InsOrders order = insOrdersService.getById(yaQuoteInfoVo.getOrderNo());
- AccidentalDrivingVo adVo = quoteVo.getAccidentalDrivingVo();
- //1.1必填校验
- checkEmpty(yaQuoteInfoVo);
- //组装参数
- Ruote m = Ruote.buildQuoteParam(yaQuoteInfoVo, ycConfigureParameters, apiComponents, adVo);
- //构造地区
- buildRegion(m, yaQuoteInfoVo);
- RuoteResponse rr = null;
- boolean boo = false;
- boolean isRenewal = true;
- boolean isBiRepeat = true;
- String textHead = "==========永诚API方式 - 车架号:" + carInfo.getVinNo() + " - 报价 ";
- while (!boo) {
- rr = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0, textHead);
- if (rr.getHead().getErrorCode().equals("009999") && (rr.getHead().getErrorMessage().contains("车主") || rr.getHead().getErrorMessage().contains("投保人") || rr.getHead().getErrorMessage().contains("被保人")))
- return HttpResult.error(rr.getHead().getErrorMessage());
- //处理返回信息
- //1、交强险重复投保处理
- boo = ciRepetitionInsure(rr, m);
- if (!boo) {
- textHead += " - 交强险重复投保处理 ";
- continue;
- }
- //2、转保处理
- boo = reinsurance(rr, m);
- if (!boo) {
- textHead += " - 转保处理 ";
- continue;
- }
- if (isBiRepeat) {
- //3、商业险日期处理
- boo = biRepetitionInsure(rr, m);
- if (!boo) {
- isBiRepeat = false;
- textHead += " - 商业险日期处理 ";
- continue;
- }
- }
- int codeErrorNum = 0;
- if (codeErrorNum > 3) boo = true;
- //转保验证码错误
- boo = reinsuranceCodeError(rr, m);
- if (!boo) {
- codeErrorNum++;
- continue;
- }
- }
- if (null == rr) return HttpResult.error("远程请求报价失败");
- StringBuffer sb = new StringBuffer();
- if (rr.getHead().getErrorCode().equals("E0001") && rr.getHead().getErrorMessage().equals("车主省市县码值不符合规范"))
- sb.append("|永诚 - 保司 - 车主地区自动解析失败");
- // throw new SystemException("车主地区自动解析失败");
- if (rr.getHead().getErrorCode().equals("E0001") && rr.getHead().getErrorMessage().equals("投保人省市县码值不符合规范"))
- sb.append("|永诚 - 保司 - 投保人地区自动解析失败");
- // throw new SystemException("投保人地区自动解析失败");
- if (rr.getHead().getErrorCode().equals("E0001") && rr.getHead().getErrorMessage().equals("被保人省市县码值不符合规范"))
- sb.append("|永诚 - 保司 - 被保人地区自动解析失败");
- // throw new SystemException("被保人地区自动解析失败");
- if (StringUtils.isNotEmpty(sb)) throw new SystemException(sb.toString());
- if (!rr.getHead().getErrorCode().equals("000000")) return HttpResult.error(rr.getHead().getErrorMessage());
- QuoteRespVo quoteRespVo = YcBuildData.buildQuoteRespVo(order, rr, yaQuoteInfoVo);
- //8 生成订单
- iac = response_order(order, quoteRespVo, m, rr, quoteVo);
- // updateApiLog(apiLog, iac);
- quoteRespVo.setCompanyId(iac.getId());
- // CustomerInfoVo policyHolderInfo = yaQuoteInfoVo.getPolicyHolderInfo().set;
- // //被保人信息
- // CustomerInfoVo insuredPersonInfo = yaQuoteInfoVo.getInsuredPersonInfo();
- // //车主
- // CustomerInfoVo ownerInfo =
- //查询码交强
- String queryCodeJq = rr.getVhl().getCQryCdeJQ();
- //查询码商业
- String queryCodeSy = rr.getVhl().getCQryCdeSY();
- order.setOwnerinfo(JSONObject.parseObject(JSONObject.toJSONString(yaQuoteInfoVo.getOwnerInfo())));
- order.setInsureinfo(JSONObject.parseObject(JSONObject.toJSONString(yaQuoteInfoVo.getInsuredPersonInfo())));
- order.setApplyinfo(JSONObject.parseObject(JSONObject.toJSONString(yaQuoteInfoVo.getPolicyHolderInfo())));
- insOrdersService.updateById(order);
- if (CollUtil.isNotEmpty(requestInfoList)) {
- // requestInfoList.stream().forEach(c -> {
- // System.err.println("========请求流程信息==========:" + c);
- // });
- quoteRespVo.getWarnMessageList().addAll(requestInfoList);
- }
- return HttpResult.ok("报价成功", quoteRespVo);
- }
- /**
- * 报价 交强险 重复 投保业务处理
- */
- public boolean ciRepetitionInsure(RuoteResponse rr, Ruote m) {
- String errorMsg = rr.getHead().getErrorMessage();
- if (rr.getHead().getErrorCode().equals("009999") && errorMsg.contains("重复投保") && errorMsg.contains("终保日期") && errorMsg.contains("终保日期")) {
- requestInfoList.add(errorMsg);
- log.info("永诚API方式 - xml请求 ------------报价 -> 交强重复投保----------------");
- //截取0 到 机动车交通事故强制险
- String ciMsg = errorMsg;
- //终保日期
- String coverageEndDate = ciMsg.substring(ciMsg.indexOf("终保日期") + 5, ciMsg.indexOf("终保日期") + 5 + 16);
- LocalDateTime start = DateTimeUtil.parseLocalDateTime(coverageEndDate, DateTimeUtil.DATETIME_PATTERN_EXT1);
- LocalDateTime end = start.plusYears(1L).minusDays(1L);
- String newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
- if (start.getHour() > 0) {
- end = start.plusYears(1L);
- newStartDate = DateTimeUtil.format(start, DateTimeUtil.DATETIME_PATTERN);
- }
- String newEndDate = DateTimeUtil.getEndTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
- System.err.println("新起:" + newStartDate);
- System.err.println("新止:" + newEndDate);
- CarInsDateDto cidd = Base.buildInsDate(newStartDate,newEndDate);
- m.getRequestLabel().getCondition().getBase().setTInsrncBgnTmJQ(cidd.getStartDate());
- m.getRequestLabel().getCondition().getBase().setTInsrncEndTmJQ(cidd.getEndDate());
- m.getRequestLabel().getCondition().getBase().setCImmeffMrk(cidd.isForthwith()?"1":"0");
- return false;
- }
- return true;
- }
- /**
- * 报价 商业险 重复 投保业务处理
- */
- public boolean biRepetitionInsure(RuoteResponse rr, Ruote m) {
- if (rr.getHead().getErrorCode().equals("000000") && null != rr.getTfiWarnList() && CollUtil.isNotEmpty(rr.getTfiWarnList().getTfiWarnData())) {
- // List<TfiWarnListResponse.TfiWarnData> tfiWarnData = rr.getTfiWarnList().getTfiWarnData().stream().filter(item -> null != item).filter(item -> StringUtils.isNotEmpty(item.getWarnMessage())).collect(Collectors.toList());
- TfiWarnListResponse.TfiWarnData tfiWarnData = rr.getTfiWarnList().getTfiWarnData().stream().filter(item -> null != item).filter(item -> StringUtils.isNotEmpty(item.getWarnMessage())).filter(item -> item.getWarnMessage().contains("终保日期")).findFirst().orElse(null);
- if (null == tfiWarnData) return true;
- //截取0 到 机动车交通事故强制险
- String ciMsg = tfiWarnData.getWarnMessage();
- requestInfoList.add(ciMsg);
- if (ciMsg.contains("终保日期: 以上为所有结果信息")) return true;
- //终保日期
- String coverageEndDate = ciMsg.substring(ciMsg.indexOf("终保日期") + 5, ciMsg.indexOf("终保日期") + 5 + 12);
- LocalDateTime start = DateTimeUtil.parseLocalDateTime(coverageEndDate, DateTimeUtil.UNSIGNED_DATETIME_PATTERN_EXT1);
- LocalDateTime end = start.plusYears(1L).minusDays(1L);
- String newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
- String newEndDate = DateTimeUtil.getEndTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
- System.err.println("商业新起:" + newStartDate);
- System.err.println("商业新止:" + newEndDate);
- m.getRequestLabel().getCondition().getBase().setTInsrncBgnTmSY(newStartDate);
- m.getRequestLabel().getCondition().getBase().setTInsrncEndTmSY(newEndDate);
- //转保信息清空 重新报价
- // rr.getVhl().setCQryCdeJQ(null);
- // rr.getVhl().setCQryCdeSY(null);
- // rr.getVhl().setCBusType("0");
- m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(null);
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(null);
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY(null);
- m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(null);
- m.getRequestLabel().getCondition().getVhl().setCBusType("0");
- return false;
- }
- return true;
- }
- /**
- * 报价 转保校验码有误
- */
- public boolean reinsuranceCodeError(RuoteResponse rr, Ruote m) {
- if (rr.getHead().getErrorCode().equals("009999") && rr.getHead().getErrorMessage().contains("录入的校验码有误")) {
- requestInfoList.add(rr.getHead().getErrorMessage());
- //转保信息清空 重新报价
- m.getRequestLabel().getCondition().getVhl().setCBusType("0");
- m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ("");
- m.getRequestLabel().getCondition().getVhl().setCQryCdeSY("");
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ("");
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY("");
- return false;
- }
- return true;
- }
- /**
- * 报价 转保业务处理
- */
- public boolean reinsurance(RuoteResponse rr, Ruote m) {
- if (rr.getHead().getErrorCode().equals("000000")) {
- String cCheckCodeJQ = rr.getVhl().getCCheckCodeJQ();
- String cQryCdeJQ = rr.getVhl().getCQryCdeJQ();
- String cCheckCodeSY = rr.getVhl().getCCheckCodeSY();
- //转保调用自动识别转保码
- if (StringUtils.isNotEmpty(cCheckCodeJQ) || StringUtils.isNotEmpty(cCheckCodeSY)) {
- log.info(String.format("永诚API方式 - xml请求 报价,车牌号《%s》 -> 转保业务处理----------------", m.getRequestLabel().getCondition().getVhl().getCPlateNo()));
- // //丢失交强校验码图串
- // if (StringUtils.isEmpty(cCheckCodeJQ) && StringUtils.isNotEmpty(cQryCdeJQ)) {
- // TfiWarnListResponse.TfiWarnData tfiWarnData = rr.getTfiWarnList().getTfiWarnData().stream().filter(item -> null != item).filter(item -> StringUtils.isNotEmpty(item.getWarnMessage())).filter(item -> item.getWarnMessage().contains(cQryCdeJQ)).findFirst().orElse(null);
- // if (null != tfiWarnData) {
- // String msg = tfiWarnData.getWarnMessage().substring(tfiWarnData.getWarnMessage().indexOf("flatCheckCode--") + 15);
- // cCheckCodeJQ = msg;
- // }
- // }
- requestInfoList.add(rr.getHead().getErrorMessage());
- //调用python ocr
- String sendBody = "";
- Map bodyMap = new HashMap();
- bodyMap.put("jqImage", StringUtils.isNotEmpty(cCheckCodeJQ) ? cCheckCodeJQ : "");
- bodyMap.put("syImage", StringUtils.isNotEmpty(cCheckCodeSY) ? cCheckCodeSY : "");
- sendBody = JsonUtils.toJson(bodyMap);
- String ocrStr = HttpUtil.sendPost("http://47.92.254.66:8088/getres", sendBody);
- Map ocrMap = JsonUtils.toObject(ocrStr, Map.class);
- m.getRequestLabel().getCondition().getVhl().setCBusType("2");
- //交强
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(ocrMap.get("jqImageCode").toString());
- // m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(ocrMap.get("jqImageCode").toString());
- m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(StringUtils.isEmpty(ocrMap.get("jqImageCode").toString()) ? "" : rr.getVhl().getCQryCdeJQ());
- //商业
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY(ocrMap.get("syImageCode").toString());
- m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(rr.getVhl().getCQryCdeSY());
- return false;
- }
- }
- return true;
- }
- /**
- * 3 核保
- *
- * @param quoteOrderNo
- */
- @Override
- @Transactional
- public HttpResult auditApi(String quoteOrderNo) {
- String logNo = String.format("(日志号:%s)", IPUtil.gainServerNo());
- try {
- //子订单
- InsAreaCompany iac = insAreaCompanyService.getById(quoteOrderNo);
- AssertionUtils.isEmpty(iac,"子订单不存在");
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- //车主
- CustomerInfoVo ownerInfo = JSONObject.parseObject(order.getOwnerinfo().toJSONString(), CustomerInfoVo.class);
- //被保人
- CustomerInfoVo insureInfo = JSONObject.parseObject(order.getInsureinfo().toJSONString(), CustomerInfoVo.class);
- //投保人
- CustomerInfoVo applyInfo = JSONObject.parseObject(order.getApplyinfo().toJSONString(), CustomerInfoVo.class);
- //组装参数
- Audit m = Audit.buildAuditParam(ownerInfo, insureInfo, applyInfo, ycConfigureParameters, iac);
- List<String> insureProvinceData = insureInfo.getProvinceData();
- //构造被保人地区
- m.getRequestLabel().getCondition().getCustomer().setCProvince(insureProvinceData.get(0));
- m.getRequestLabel().getCondition().getCustomer().setCCity(insureProvinceData.get(1));
- m.getRequestLabel().getCondition().getCustomer().setCCounty(insureProvinceData.get(2));
- // //构造被保人地区
- // Map<String, String> insureMap = gainRegionCode(insureInfo.getAddr());
- // m.getRequestLabel().getCondition().getCustomer().setCProvince(insureMap.get("provinceCode"));
- // m.getRequestLabel().getCondition().getCustomer().setCCity(insureMap.get("cityCode"));
- // m.getRequestLabel().getCondition().getCustomer().setCCounty(insureMap.get("areaCode"));
- // findRegion()
- //接口请求
- String responseData = httpPostResultLog(m, YcBuildData.API_AUDIT, "永诚API方式 - 核保(车牌号:"+order.getLicenseno()+") - ");
- AssertionUtils.isEmpty(responseData,logNo + "核保请求超时请重试。");
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- AuditResponse rd = gainXmlMapper().readValue(cleanStr, AuditResponse.class);
- if (rd.getResponseHead().getReturnCode().equals("0000")) {
- String statusJq = StringUtils.toString(rd.getStatusJq(), "");
- String statusSy = StringUtils.toString(rd.getStatusSY(), "");
- if (statusJq.equals("0") || statusSy.equals("0")) {
- iac.setOrderstatus(InsOrderStatusEnum.WAIT_AUDIT.getCode());
- } else if (statusJq.equals("3") || statusSy.equals("3")) {
- iac.setOrderstatus(InsOrderStatusEnum.TO_BACK.getCode());
- StringBuffer sb = new StringBuffer();
- if (null != rd.getSailResponseMessagedate()) {
- sb.append(String.format("交强险提示信息:s%", rd.getSailResponseMessagedate().getCMessage()));
- }
- if (null != rd.getCiResponseMessagedate()) {
- sb.append(String.format(" 商业险提示信息:s%", rd.getCiResponseMessagedate().getCMessage()));
- }
- iac.setAuditopinion(sb.toString());
- } else if (statusJq.equals("9") || statusSy.equals("9")) {
- iac.setOrderstatus(InsOrderStatusEnum.WAIT_PAY.getCode());
- }
- //构造订单状态
- buildOrderStatus(order, iac);
- } else {
- return HttpResult.error(logNo + "核保失败,车牌号:"+ order.getLicenseno() + " ," + rd.getResponseHead().getReturnMessage());
- }
- iac.setAuditid(order.getUserid());
- iac.setInsOrderNo(rd.getOrderCode());
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- iac.setAudittime(LocalDateTime.now());
- iac.setJqapplyno(StringUtils.toString(rd.getPolicyAppNoJQ(), ""));
- iac.setSyapplyno(StringUtils.toString(rd.getPolicyAppNoSY(), ""));
- iac.setJqappoint(""); //交强特别约定
- iac.setSyappoint(""); //商业特别约定
- if (InsOrderStatusEnum.WAIT_PAY.getCode().equals(InsOrderStatusEnum.matchKey(iac.getOrderstatus()).getCode())) {
- //获取缴费地址
- getPayUrlApi(iac);
- }
- log.info(logNo + "车牌号:" + order.getLicenseno() + ",永诚核保未获取缴费地址,状态为:" + InsOrderStatusEnum.matchKey(iac.getOrderstatus()).getDesc());
- insAreaCompanyService.updateById(iac);
- insOrdersService.updateById(order);
- return HttpResult.ok("核保操作成功");
- } catch (SystemException e) {
- return HttpResult.error(e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- log.error("===永诚API方式--核保报错(订单号-{}):{}", quoteOrderNo, e.getMessage());
- return HttpResult.error("系统错误,请联系管理员");
- }
- }
- /**
- * 4 影像上传
- */
- @Override
- public HttpResult UploadImageApi(String quoteOrderNo) {
- String logNo = String.format("(日志号:%s)", IPUtil.gainServerNo());
- InsAreaCompany iac = insAreaCompanyService.getByIdIsExist(quoteOrderNo);
- if(!iac.getOrderstatus().equals(InsOrderStatusEnum.QUOTE_ING.getCode())) return HttpResult.error("报价中的订单才允许核保");
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- List<InsTaskImagesBase64> insTaskImages = insTaskImagesService.findByOrderNo(iac.getOrderno());
- if(CollUtil.isEmpty(insTaskImages)) return HttpResult.error("获取影像失败");
- //获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- insTaskImages.stream().forEach(a -> {
- InsApiLog apiLog = null;
- //组装参数
- //接口请求
- ImageUp iUp = ImageUp.buildImageUpParam(order, ycConfigureParameters, a.getBase64String(), a.getImageType());
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- // apiLog = httpPost(xmlMapper, iUp, YcBuildData.API_UPLOAD);
- String responseData = httpPostResultLog(iUp, YcBuildData.API_UPLOAD, logNo +"永诚API方式(车牌号:)"+order.getLicenseno()+" - 影像上传 - "+iUp.getNewImgUpLoadInfoRequest().getRequestBase().getPicTureName()+" - ");
- try {
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- log.error("===永诚API方式--上传影像清洗返回参数:" + cleanStr);
- ImageUpResponse iur = xmlMapper.readValue(cleanStr, ImageUpResponse.class);
- } catch (IOException e) {
- e.printStackTrace();
- log.error("===永诚API方式--上传影像报错:" + e.getMessage());
- throw new SystemException("系统错误,请联系管理员");
- }
- });
- return HttpResult.ok();
- }
- /**
- * 5 支付
- */
- @Override
- public InsAreaCompany getPayUrlApi(InsAreaCompany iac) {
- try {
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- //组装参数
- Pay pay = Pay.buildPayParam(iac, ycConfigureParameters.gainAuthorityDataXml(), apiComponents.getPayCallBack());
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- log.debug("=========永诚API方式 - xml请求 - 获取缴费链接开始======");
- String responseData = httpPostResultLog( pay, YcBuildData.API_PAY, "永诚API方式 - 获取缴费链接 - ");
- // InsApiLog apiLog = httpPost(xmlMapper, pay, YcBuildData.API_PAY);
- log.debug("=========永诚API方式 - xml请求 - 获取缴费链接结束!======");
- // verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_3);
- // String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- PayResponse payResp = xmlMapper.readValue(cleanStr, PayResponse.class);
- if (payResp.getReturnCode().equals("E0000")) {
- iac.setPaymentLink(payResp.getPayTransUrl());
- // insAreaCompanyService.updateById(iac);
- } else {
- log.error("永诚API方式 - 获取支付连接失败:" + payResp.getReturnMessage());
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new SystemException("获取支付连接失败");
- }
- return iac;
- }
- /**
- * 补传回调
- */
- @Override
- public HttpResult callbackAnOrder(String quoteOrderNo) {
- // log.debug("=========永诚API方式 - xml请求 - 补传回调开始======");
- try {
- InsAreaCompany iac = insAreaCompanyService.getById(quoteOrderNo);
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- if (iac == null) {
- return HttpResult.error("报价订单不存在");
- }
- if (StringUtils.isEmpty(iac.getAgreementId())) return HttpResult.error("协议号空");
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- //0 支付回调 1核保回调 5直接返回字符串信息
- // String type = "0";
- String type = "5";
- // if(iac.getOrderstatus().equals(InsOrderStatusEnum.WAIT_AUDIT.getCode())) type = "1";
- //组装参数
- CallbackAnOrder o = CallbackAnOrder.buildCallbackAnOrderParam(iac, ycConfigureParameters.gainAuthorityDataXml(), type);
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- // InsApiLog apiLog = httpPostResultLog(xmlMapper, o, YcBuildData.API_ORDER_QUERY);
- String respData = httpPostResultLog( o, YcBuildData.API_ORDER_QUERY, "永诚API方式 - 补传回调 - ");
- String cleanStr = YcBuildData.cleanResponseStr(respData);
- // CallbackAnOrderResponse callbackAnOrderResponse = xmlMapper.readValue(cleanStr, CallbackAnOrderResponse.class);
- if (StringUtils.isNotEmpty(cleanStr)) {
- if (cleanStr.equals("账户不存在或没有权限")) return HttpResult.ok("账户不存在或没有权限");
- log.info("永诚API方式 - 补传回调 - 参数:" + cleanStr);
- CallBackRequest param = CallBackRequest.buildCallBackParam(cleanStr);
- //成功
- if (param.getResult().equals("0")) {
- if (StringUtils.isEmpty(param.getBizPolicyNo()) && StringUtils.isEmpty(param.getCiPolicyNo()))
- return HttpResult.ok("操作成功,状态未变动。");
- ;
- if (StringUtils.isNotEmpty(param.getBizPolicyNo())) iac.setSypolicyno(param.getBizPolicyNo());
- if (StringUtils.isNotEmpty(param.getCiPolicyNo())) iac.setJqpolicyno(param.getCiPolicyNo());
- iac = buildCallBack(iac, param);
- //构造订单状态
- buildOrderStatus(order, iac);
- insAreaCompanyService.updateById(iac);
- insOrdersService.updateByOrderStatus(order.getOrderno(), order.getOrderstatus());
- } else {
- //失败原因
- log.info(String.format("永诚API方式 - 补传回调 - 失败,交强保单号:{} ,商业保单号:{},类型:{}", param.getCiPolicyNo(), param.getBizPolicyNo(), param.getType()));
- return HttpResult.error(param.getMessage());
- }
- return HttpResult.ok("操作成功,状态已更新。");
- }
- // if (cleanStr.equals("0000")) {
- // httpResult.setMsg("操作成功");
- // } else {
- // httpResult.setMsg(cleanStr);
- // }
- } catch (SystemException e) {
- return HttpResult.error(e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("系统错误,请联系管理员");
- }
- // log.debug("=========永诚API方式 - xml请求 - 补传回调结束!======");
- return HttpResult.error("操作失败,请联系管理员");
- }
- /**
- * 补传回调
- */
- @Override
- public void callbackAnOrder() {
- LambdaQueryWrapper<InsAreaCompany> lqw = new LambdaQueryWrapper<>();
- lqw.eq(InsAreaCompany::getOrderstatus, InsOrderStatusEnum.WAIT_PAY.getCode());
- lqw.gt(InsAreaCompany::getAudittime, LocalDate.now().minusDays(1));
- List<InsAreaCompany> list = insAreaCompanyService.list(lqw);
- if (null != list && list.size() > 0) {
- list.stream().forEach(a -> {
- callbackAnOrder(a.getId());
- });
- }
- }
- /**
- * 6 电子保单
- */
- @Override
- public HttpResult getPolicyPrintApi(PolicyPrintVo policyPrintVo) {
- HttpResult httpResult = new HttpResult();
- try {
- InsAreaCompany iac = insAreaCompanyService.getById(policyPrintVo.getCompanyId());
- AssertionUtils.isEmpty(iac, "报价订单不存在");
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- String ip = IPUtil.gainServerNo();
- log.debug("------------------------------");
- log.debug("----测试服务器IP----" + ip);
- log.debug("------------------------------");
- String jqbz = "-交强险标志.pdf";
- String jqbd = "-交强险保单.pdf";
- String sybd = "-商业险保单.pdf";
- String licensePlate = order.getLicenseno();
- Map m = new HashMap();
- CarInsPolicyDto cipDto = new CarInsPolicyDto();
- String insFlag = "dj";
- if (StringUtils.isNotEmpty(iac.getJqapplyno()) && StringUtils.isNotEmpty(iac.getSyapplyno()))
- insFlag = "js";
- if (StringUtils.isEmpty(iac.getJqapplyno()) && StringUtils.isNotEmpty(iac.getSyapplyno())) insFlag = "ds";
- //单交
- if (insFlag.equals("dj")) {
- String jqFlagUrl = gainExistCarInsPolicy(licensePlate + jqbz, licensePlate);
- String jqUrl = gainExistCarInsPolicy(licensePlate + jqbd, licensePlate);
- if (StringUtils.isNotEmpty(jqFlagUrl) && StringUtils.isNotEmpty(jqUrl)) {
- cipDto.setJqFlagUrl(jqFlagUrl);
- cipDto.setJqUrl(jqUrl);
- return HttpResult.ok(cipDto);
- }
- } else if (insFlag.equals("ds")) {//单商
- String syUrl = gainExistCarInsPolicy(licensePlate + sybd, licensePlate);
- if (StringUtils.isNotEmpty(syUrl)) {
- cipDto.setSyUrl(syUrl);
- return HttpResult.ok(cipDto);
- }
- } else if (insFlag.equals("js")) {//交商业
- String syUrl = gainExistCarInsPolicy(licensePlate + sybd, licensePlate);
- String jqFlagUrl = gainExistCarInsPolicy(licensePlate + jqbz, licensePlate);
- String jqUrl = gainExistCarInsPolicy(licensePlate + jqbd, licensePlate);
- if (StringUtils.isNotEmpty(jqFlagUrl) && StringUtils.isNotEmpty(jqUrl) && StringUtils.isNotEmpty(syUrl)) {
- cipDto.setJqFlagUrl(jqFlagUrl);
- cipDto.setJqUrl(jqUrl);
- cipDto.setSyUrl(syUrl);
- return HttpResult.ok(cipDto);
- }
- }
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- String policyNo = policyPrintVo.getRiskCode().equals("0507") ? iac.getJqpolicyno() : iac.getSypolicyno();
- //组装参数
- Policy p = Policy.buildPolicyParam(policyNo, ycConfigureParameters.gainAuthorityDataXml());
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- String responseData = httpPostResultLog( p, YcBuildData.API_GUARANTEE_SLIP, "车牌号:" + order.getLicenseno() + ",永诚API方式 - 获取保单 - ");
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- PolicyResponse pResp = xmlMapper.readValue(cleanStr, PolicyResponse.class);
- if (pResp.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- //标志
- if (StringUtils.isNotEmpty(pResp.getPolicyBZUrl())) {
- String bzInsUrl = pResp.getPolicyBZUrl().replaceAll(";pkid", "&pkid");
- String jqFlagUrl = gainCarInsPolicy(bzInsUrl, licensePlate + jqbz, licensePlate);
- cipDto.setJqFlagUrl(jqFlagUrl);
- }
- //交强
- if (StringUtils.isNotEmpty(pResp.getJqpolicyUrl())) {
- String jqInsUrl = pResp.getJqpolicyUrl().replaceAll(";pkid", "&pkid");
- String jqUrl = gainCarInsPolicy(jqInsUrl, licensePlate + jqbd, licensePlate);
- cipDto.setJqUrl(jqUrl);
- }
- //商业
- if (StringUtils.isNotEmpty(pResp.getSypolicyUrl())) {
- String syInsUrl = pResp.getSypolicyUrl().replaceAll(";pkid", "&pkid");
- String syUrl = gainCarInsPolicy(syInsUrl, licensePlate + sybd, licensePlate);
- cipDto.setSyUrl(syUrl);
- }
- return HttpResult.ok(pResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription(), cipDto);
- } else {
- return HttpResult.error(pResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- }
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("系统错误,请联系管理员");
- }
- }
- /**
- * 驾意外险
- */
- @Override
- public HttpResult gainAccidentList(AccidentalDrivingQueryVo accidentalDrivingVo) {
- HttpResult httpResult = new HttpResult();
- try {
- // InsAreaCompany iac = insAreaCompanyService.getById(quoteOrderNo);
- // InsOrders order = insOrdersService.getById(iac.getOrderno());
- // if (iac == null) {
- // return HttpResult.error("报价订单不存在");
- // }
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(accidentalDrivingVo.getAgreementId());
- //组装参数
- Accident accident = Accident.buildPayParam(accidentalDrivingVo, ycConfigureParameters, null);
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询开始======");
- String responseData = httpPostResultLog( accident, YcBuildData.API_ACCIDENT, "永诚API方式 - 获取意健险方案及险种 - ");
- // InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询结束!======");
- // verifyRequest(apiLog, iac,InsQuoteFlow.);
- // String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- AccidentResponse accidentResp = xmlMapper.readValue(cleanStr, AccidentResponse.class);
- if (accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- //清空旧的存入表
- LambdaQueryWrapper<EsmInsAttachInsure> lqw = new LambdaQueryWrapper<EsmInsAttachInsure>();
- lqw.eq(EsmInsAttachInsure::getCompanyId, accidentalDrivingVo.getCompanyCode());
- lqw.eq(EsmInsAttachInsure::getSeating, accidentalDrivingVo.getSeatNum());
- esmInsAttachInsureMapper.delete(lqw);
- List<ResponseYwCvrg.CvrgList> cList = accidentResp.getResponseYwCvrg().getCvrgList();
- List<EsmInsAttachInsure> eiaiList = new ArrayList<>();
- cList.stream().forEach(a -> {
- EsmInsAttachInsure ati = new EsmInsAttachInsure();
- ati.setCode(a.getCInsuranceTypeCode());
- ati.setName(a.getCInsuranceType());
- ati.setSeating(accidentalDrivingVo.getSeatNum() + "");
- ati.setCompanyId(accidentalDrivingVo.getCompanyCode());
- ati.setType(AttachInsureEnum.AI001.getCode());
- ati.setEnable(WhetherEnum.YES.getCode());
- ati.setRestrictNum(StringUtils.toInt(a.getNPurchaseLimitsNum()));
- esmInsAttachInsureMapper.insert(ati);
- eiaiList.add(ati);
- });
- httpResult.setData(eiaiList);
- // httpResult.setData(accidentResp.getResponseYwCvrg().getCvrgList());
- httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- } else {
- httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- }
- } catch (SystemException e) {
- return HttpResult.error(e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("系统错误,请联系管理员");
- }
- return httpResult;
- }
- /**
- * 驾意外险 同步
- */
- @Override
- public HttpResult syncAccidentInsure(AccidentalDrivingQueryVo accidentalDrivingVo) {
- AccidentResponse ar = gainAccidentInsure(accidentalDrivingVo, null);
- // List<EsmInsAttachInsure> eiaiList = new ArrayList<>();
- if (ar.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- //清空旧的存入表
- LambdaQueryWrapper<EsmInsAttachInsure> lqw = new LambdaQueryWrapper<EsmInsAttachInsure>();
- lqw.eq(EsmInsAttachInsure::getCompanyId, accidentalDrivingVo.getCompanyCode());
- lqw.eq(EsmInsAttachInsure::getSeating, accidentalDrivingVo.getSeatNum());
- lqw.select(EsmInsAttachInsure::getId);
- List<EsmInsAttachInsure> eiaiList = esmInsAttachInsureMapper.selectList(lqw);
- //删除已经存在的数据
- if (null != eiaiList && eiaiList.size() > 0) {
- List<String> ids = new ArrayList<>();
- eiaiList.stream().forEach(i -> {
- ids.add(i.getId());
- });
- LambdaQueryWrapper<EsmInsAttachInsureDetails> lqwDetails = new LambdaQueryWrapper<>();
- lqwDetails.in(EsmInsAttachInsureDetails::getAttachInsureId, ids);
- //详情删除
- esmInsAttachInsureDetailsMapper.delete(lqwDetails);
- // esmInsAttachInsureMapper.delete(lqw);
- esmInsAttachInsureMapper.deleteBatchIds(ids);
- }
- List<ResponseYwCvrg.CvrgList> cList = ar.getResponseYwCvrg().getCvrgList();
- cList.stream().forEach(a -> {
- EsmInsAttachInsure ati = new EsmInsAttachInsure();
- ati.setCode(a.getCInsuranceTypeCode());
- ati.setName(a.getCInsuranceType());
- ati.setSeating(accidentalDrivingVo.getSeatNum() + "");
- ati.setCompanyId(accidentalDrivingVo.getCompanyCode());
- ati.setType(AttachInsureEnum.AI001.getCode());
- ati.setEnable(WhetherEnum.YES.getCode());
- ati.setRestrictNum(StringUtils.toInt(a.getNPurchaseLimitsNum()));
- esmInsAttachInsureMapper.insert(ati);
- //具体方案信息
- AccidentResponse arCode = gainAccidentInsure(accidentalDrivingVo, a.getCInsuranceTypeCode());
- if (arCode.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- AtomicInteger total = new AtomicInteger(0);
- List<ResponseYwCvrg.CvrgList> cListDetails = arCode.getResponseYwCvrg().getCvrgList();
- cListDetails.stream().forEach(d -> {
- EsmInsAttachInsureDetails atiDetails = new EsmInsAttachInsureDetails();
- atiDetails.setAttachInsureId(ati.getId());
- atiDetails.setName(d.getCInsuranceLiability());
- atiDetails.setCarSum(d.getNInsuranceAmountCar());
- atiDetails.setSeatSum(d.getNInsuranceAmountSeat());
- atiDetails.setPremium(d.getNLiabilityPremium());
- total.addAndGet(StringUtils.toInt(d.getNLiabilityPremium()));
- esmInsAttachInsureDetailsMapper.insert(atiDetails);
- });
- ati.setPremium(total.get() + "");
- esmInsAttachInsureMapper.updateById(ati);
- }
- // eiaiList.add(ati);
- });
- }
- return HttpResult.ok("同步成功");
- }
- /**
- * 驾意外险
- */
- @Override
- public AccidentResponse gainAccidentInsure(AccidentalDrivingQueryVo accidentalDrivingVo, String schemeNo) {
- HttpResult httpResult = new HttpResult();
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(accidentalDrivingVo.getAgreementId());
- //组装参数
- Accident accident = Accident.buildPayParam(accidentalDrivingVo, ycConfigureParameters, schemeNo);
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询开始======");
- String responseData = httpPostResultLog( accident, YcBuildData.API_ACCIDENT, "永诚API方式 - 获取意健险方案及险种 - ");
- // InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询结束!======");
- // verifyRequest(apiLog, iac,InsQuoteFlow.);
- // String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- AccidentResponse accidentResp = null;
- try {
- accidentResp = xmlMapper.readValue(cleanStr, AccidentResponse.class);
- } catch (JsonProcessingException e) {
- log.error("转换错误 方法:gainAccidentInsure 类:AccidentResponse");
- throw new RuntimeException(e);
- }
- return accidentResp;
- // if (accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- // //清空旧的存入表
- // LambdaQueryWrapper<EsmInsAttachInsure> lqw = new LambdaQueryWrapper<EsmInsAttachInsure>();
- // lqw.eq(EsmInsAttachInsure::getCompanyId,accidentalDrivingVo.getCompanyCode());
- // lqw.eq(EsmInsAttachInsure::getSeating,accidentalDrivingVo.getSeatNum());
- // esmInsAttachInsureMapper.delete(lqw);
- //
- // List<ResponseYwCvrg.CvrgList> cList = accidentResp.getResponseYwCvrg().getCvrgList();
- //
- // List<EsmInsAttachInsure> eiaiList = new ArrayList<>();
- // cList.stream().forEach(a ->{
- // EsmInsAttachInsure ati = new EsmInsAttachInsure();
- // ati.setCode(a.getCInsuranceTypeCode());
- // ati.setName(a.getCInsuranceType());
- // ati.setSeating(accidentalDrivingVo.getSeatNum() + "");
- // ati.setCompanyId(accidentalDrivingVo.getCompanyCode());
- // ati.setType(AttachInsureEnum.AI001.getCode());
- // ati.setEnable(WhetherEnum.YES.getCode());
- // ati.setRestrictNum(StringUtils.toInt(a.getNPurchaseLimitsNum()));
- //
- // esmInsAttachInsureMapper.insert(ati);
- // eiaiList.add(ati);
- // });
- //
- //
- //
- //
- // httpResult.setData(eiaiList);
- //// httpResult.setData(accidentResp.getResponseYwCvrg().getCvrgList());
- // httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- // } else {
- // httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- // }
- }
- @Override
- @Transactional
- public HttpResult callBackApi(CallBackRequest param) {
- // if (StringUtils.isNotEmpty(param.getType())) return HttpResult.error("字段:type(回调类型) 参数为空");
- //成功
- if (param.getResult().equals("0")) {
- LambdaQueryWrapper<InsAreaCompany> lqw = new LambdaQueryWrapper();
- //交强投保单号查询
- lqw.eq(StringUtils.isNotEmpty(param.getCiPolicyAppNo()), InsAreaCompany::getJqapplyno, param.getCiPolicyAppNo());
- //商业投保单号查询
- lqw.eq(StringUtils.isNotEmpty(param.getBizPolicyAppNo()), InsAreaCompany::getSyapplyno, param.getBizPolicyAppNo());
- InsAreaCompany iac = insAreaCompanyService.getOne(lqw);
- if (null != iac) {
- if (StringUtils.isNotEmpty(param.getBizPolicyNo())) iac.setSypolicyno(param.getBizPolicyNo());
- if (StringUtils.isNotEmpty(param.getCiPolicyNo())) iac.setJqpolicyno(param.getCiPolicyNo());
- iac = buildCallBack(iac, param);
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- if (StringUtils.toInt(order.getOrderstatus()) < StringUtils.toInt(iac.getOrderstatus())) {
- order.setOrderstatus(iac.getOrderstatus());
- }
- insAreaCompanyService.updateById(iac);
- insOrdersService.updateByOrderStatus(order.getOrderno(), order.getOrderstatus());
- //支付后 手工确认意外险
- } else {
- log.info(String.format("永诚API方式 - 回调 - 信息,订单不存在,交强保单号:{} ,商业保单号:{}", param.getCiPolicyNo(), param.getBizPolicyNo()));
- }
- } else {
- //失败原因
- param.getMessage();
- log.info(String.format("永诚API方式 - 回调 - 失败,交强保单号:{} ,商业保单号:{},类型:{}", param.getCiPolicyNo(), param.getBizPolicyNo(), param.getType()));
- }
- return HttpResult.ok(param);
- }
- /**
- * @description:构造车型查询参数
- * @author: lig
- * @date: 2023年02月08日 0008
- */
- private ModelsQueryXml buildModelsQueryParam(CarModel_Req carModelReq, YcConfigureParameters ycConfigureParameters) {
- ModelsQueryXml m = new ModelsQueryXml();
- ModelsQueryXml.RequestLabel requestLabel = new ModelsQueryXml.RequestLabel();
- requestLabel.setSearchKeyword(carModelReq.getFrameNo().substring(0, 8));
- requestLabel.setVid(carModelReq.getFrameNo());
- requestLabel.setEngineNo(carModelReq.getEngineNo());
- requestLabel.setDptCde(ycConfigureParameters.getDptCde());
- requestLabel.setProno("0326");
- requestLabel.setMotorTypeCode("11");
- requestLabel.setCFstRegYm(carModelReq.getEnrollDate());
- requestLabel.setAuthorityData(ycConfigureParameters.gainAuthorityDataXml(ycConfigureParameters));
- m.setRequestLabel(requestLabel);
- return m;
- }
- /**
- * @description: 构造返回内容,参考永安
- * @author: lig
- * @date: 2023年02月07日 0007
- */
- private List<ModelsQueryResponse.VehicleInfo> buildCarModel(ModelsQueryResponse modelsQueryResponse) {
- // private List<CarModelDTO> buildCarModel(ModelsQueryResponse modelsQueryResponse) {
- List<ModelsQueryResponse.VehicleInfo> vList = modelsQueryResponse.getVehicleInfoList();
- return vList;
- // List<CarModelDTO> carModelList = new ArrayList<>();
- //
- // vList.stream().forEach(a -> {
- // CarModelDTO dto = new CarModelDTO();
- // BeanUtils.copyProperties(a, dto);
- // carModelList.add(dto);
- // });
- // return carModelList;
- }
- // private <T> InsApiLog httpPost(ObjectMapper mapper, T requestData, String apiName) {
- //
- // String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
- // xmlString += "<soapenv:Body>";
- // try {
- // mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- // xmlString += mapper.writeValueAsString(requestData);
- //
- // xmlString += "</soapenv:Body>\n" +
- // "</soapenv:Envelope>";
- //
- // } catch (JsonProcessingException e) {
- // throw new RuntimeException("永诚API方式-xml转换失败");
- // }
- // InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
- //// log.info("永诚API方式 - xml请求 - 参数:" + iplog.getRequestData());
- //// log.info("永诚API方式 - xml请求 ------------分割线----------------");
- //// log.info("永诚API方式 - xml请求 - 响应:" + iplog.getResponseData());
- // return iplog;
- // }
- /**
- * 日志返回处理
- *
- * @author: lig
- * @date: 2023年09月02日 0002
- */
- private <T> String httpPostResultLog(T requestData, String apiName, String textHead) {
- String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
- xmlString += "<soapenv:Body>";
- try {
- ObjectMapper xmlMapper = new XmlMapper();
- xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- xmlMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
- xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- xmlMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
- xmlMapper.enable(MapperFeature.USE_STD_BEAN_NAMING);
- xmlMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
- xmlString += xmlMapper.writeValueAsString(requestData);
- xmlString += "</soapenv:Body>\n" +
- "</soapenv:Envelope>";
- } catch (JsonProcessingException e) {
- throw new RuntimeException("永诚API方式-xml转换失败");
- }
- // InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
- return HttpXmlUtil.sendXmlPostReq(apiComponents.getUrl() + apiName, xmlString, log, textHead);
- }
- // /**
- // * 日志返回处理
- // *
- // * @author: lig
- // * @date: 2023年09月02日 0002
- // */
- // private <T> InsApiLog httpPostResultLog(ObjectMapper mapper, T requestData, String apiName) {
- //
- // String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
- // xmlString += "<soapenv:Body>";
- // try {
- // mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- // xmlString += mapper.writeValueAsString(requestData);
- //
- // xmlString += "</soapenv:Body>\n" +
- // "</soapenv:Envelope>";
- //
- // } catch (JsonProcessingException e) {
- // throw new RuntimeException("永诚API方式-xml转换失败");
- // }
- // InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
- //
- // return iplog;
- // }
- /**
- * @description: 拷贝永安方法,可以封装
- * @author: lig
- * @date: 2023年02月08日 0008
- */
- private void checkEmpty(YaQuoteInfoVo yaQuoteInfoVo) {
- if (yaQuoteInfoVo.getCarInfo() == null) {
- throw new SystemException("carInfo不能为空!");
- }
- if (yaQuoteInfoVo.getPolicyHolderInfo() == null || yaQuoteInfoVo.getInsuredPersonInfo() == null) {
- throw new SystemException("policyHolderInfo/insuredPersonInfo 不能为空!");
- }
- if (yaQuoteInfoVo.getRiskList() == null || yaQuoteInfoVo.getRiskList().size() == 0) {
- throw new SystemException("riskList 不能为空!");
- } else {
- for (RiskInfoVo riskInfoVo : yaQuoteInfoVo.getRiskList()) {
- if (riskInfoVo.getStartDate() == null || riskInfoVo.getEndDate() == null) {
- throw new SystemException("riskList.startDate / riskList.endDate不能为空!");
- }
- }
- }
- }
- // /**
- // * 生成订单 拷贝永安
- // *
- // * @author: lig
- // * @date: 2023年02月16日 0016
- // */
- // protected InsOrders gene_order(YaQuoteInfoVo record) {
- // InsOrders insOrder = new InsOrders();
- // String orderno = IdGenerate.nextId();
- // insOrder.setOrderno(orderno);
- // insOrder.setQuoteno(String.valueOf(record.getQuoteno()));
- // insOrder.setOrderstatus("0"); //0报价 1待核保 2已核保待缴费 3核保退回 4核保不通过
- // insOrder.setFrameno(record.getCarInfo().getFrameNo());
- // insOrder.setLicenseno(record.getCarInfo().getLicenseNo());
- //
- // insOrder.setCarinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getCarInfo())));
- // SysUser user = sysUserService.selectByPk(record.getUserId());
- // if (user == null) {
- // throw new SystemException("userId不存在");
- // }
- // if (org.springframework.util.StringUtils.isEmpty(record.getCarInfo().getFrameNo())) {
- // throw new SystemException("车架号不能为空");
- // }
- // // 关闭订单 不含当前报价号
- // InsOrders orderObj = insOrderService.queryQuoteno(new Object[]{record.getUserId(), record.getCarInfo().getFrameNo(), record.getQuoteno()});
- // if (orderObj != null) {
- // List<InsOrder> listo = insOrderService.selectList(" where quoteno=?", new Object[]{orderObj.getQuoteno()});
- // String status = "0";
- // for (InsOrder order : listo) {
- // if (!"0".equals(order.getOrderstatus())) {
- // status = order.getOrderstatus();
- // }
- // }
- // //0报价中 1待核保 2已核保 3核保退回 4核保不通过 5已核保待缴费 6已缴费 7已承保 99已关闭
- // if ("0".equals(status)) {//关闭订单
- // insOrderService.closeOrder(orderObj.getOrderno(), "99");
- // } else if (!"99".equals(status)) {
- // throw new SystemException("此车辆已提交核保,重新报价请先关闭订单,任务号:" + orderObj.getQuoteno());
- // }
- // }
- // insOrder.setUserid(user.getId());
- // insOrder.setUsername(user.getName());
- // insOrder.setDeptid(user.getDeptId());
- // SysDept dept = sysDeptService.selectByPk(user.getDeptId());
- // insOrder.setDeptname(dept == null ? "" : dept.getName());
- //
- // double retailRate = countRetail(user.getDeptId(), user.getId());
- //
- // insOrder.setOwnerinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getOwnerInfo())));
- // insOrder.setApplyinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getPolicyHolderInfo())));
- // insOrder.setInsureinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getInsuredPersonInfo())));
- //
- // insOrder.setInsuredname(record.getPolicyHolderInfo().getName());
- //
- //
- // List<RiskInfoVo> risks = record.getRiskList();
- // for (RiskInfoVo risk : risks) {
- // if ("0507".equals(risk.getRiskCode())) {//交强
- // insOrder.setJqstartdate(risk.getStartDate());
- // insOrder.setJqenddate(risk.getEndDate());
- // }
- // if ("0510".equals(risk.getRiskCode())) {//商业
- // insOrder.setSystartdate(risk.getStartDate());
- // insOrder.setSyenddate(risk.getEndDate());
- // }
- // }
- //
- // List<KindInfoVo> kinds = record.getKindList();
- // String productId = "";
- // String productname = "";
- //
- // List<EsmAgreement> agreements = esmAgreementService.selectList(" where t.agreestatus='1' and t.insure1 like ? " + "and exists (select 1 from esm_agreement_prod t2 where t.id=t2.agreeid and t2.authcomcode like ?)", new Object[]{"000006140400%", "%" + user.getDeptId() + "%"});
- // if (agreements.size() == 0) {
- // throw new SystemException("不存在有效协议或机构" + user.getDeptId() + "未授权");
- // }
- // String agreeid = agreements.get(0).getId();
- // insOrder.setAgreeid(agreeid);
- // //匹配协议,获取费用
- // StringBuffer whereStr = new StringBuffer();
- // List params = new ArrayList();// where t.agreeid=? and t.productid in ()
- // whereStr.append("where t.agreeid=? ");
- // params.add(agreeid);
- // if (risks.size() == 1 && "0507".equals(risks.get(0).getRiskCode())) {
- // productId = "ZG01001";
- // productname = "单交强";
- // whereStr.append(" and t.productid=?");
- // params.add(productId);
- // } else if (risks.size() == 1 && kinds.size() == 1 && "B".equals(kinds.get(0).getKindCode())) {
- // productId = "ZG01002";
- // productname = "单三者";
- // whereStr.append(" and t.productid=?");
- // params.add(productId);
- // } else if (risks.size() == 1) {
- // productId = "ZG01003";
- // productname = "单商业";
- // whereStr.append(" and t.productid=?");
- // params.add(productId);
- // } else if (risks.size() == 2 && kinds.size() == 1 && "B".equals(kinds.get(0).getKindCode())) {
- // productId = "ZG01004";
- // productname = "交强+三者";
- // whereStr.append(" and t.productid in (?,?)");
- // params.add("ZG01004");
- // params.add("ZG01005");
- // } else {
- // productId = "ZG01006";
- // productname = "交强+商业";
- // whereStr.append(" and t.productid in (?,?)");
- // params.add("ZG01006");
- // params.add("ZG01007");
- // }
- //
- // insOrder.setProductid(productId);
- // insOrder.setProduct(productname);
- // List<EsmAgreementProd> agreementProds = esmAgreementProdService.selectList(whereStr.toString(), params.toArray());
- // for (EsmAgreementProd prod : agreementProds) {
- // if ("ZG01001".equals(prod.getProductid()) || "ZG01004".equals(prod.getProductid()) || "ZG01006".equals(prod.getProductid())) {
- //
- // insOrder.setFeerate(prod.getProductrate()); //交强手续费比例
- // insOrder.setJqdiscountrate(prod.getFeerate() - retailRate); //交强优惠比例=业务员绩效-分销费用
- // } else {
- // insOrder.setDisrate(prod.getProductrate()); //商业手续费比例
- // insOrder.setSydiscountrate(prod.getFeerate() - retailRate); //商业优惠比例=业务员绩效-分销费用
- //
- // }
- // insOrder.setProductid(prod.getId());
- // }
- //
- // insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(record.getRiskList())));
- // insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(record.getKindList())));
- // SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //
- // insOrder.setInscompany("永安财险");
- // insOrder.setCreatetime(sdfm.format(new Date()));
- //
- // return insOrder;
- //
- // }
- // /**
- // * 分销费用统计 拷贝永安
- // *
- // * @param deptid
- // * @param userid
- // * @return
- // */
- // public double countRetail(String deptid, String userid) {
- // double retailRate = 0;
- //
- // //1、根据机构匹配分销规则,获取分销比例
- // List<EsmRetail> list = esmRetailService.selectList(" where deptid = ? and status=?", new Object[]{deptid, "1"});
- // //2、根据userid查询三级推荐人
- // List<SysUser> users = esmUserInternalService.getSuperior(userid);
- //
- // if (list != null && list.size() > 0 && users.size() > 0 && !"0".equals(list.get(0).getRetailtype())) {
- // EsmRetail retail = list.get(0);
- // List<Double> rateList = new ArrayList<Double>();
- // rateList.add(retail.getDisrate1());
- // rateList.add(retail.getDisrate2());
- // rateList.add(retail.getDisrate3());
- //
- // if ("1".equals(retail.getRetailtype())) {//一级分销
- // retailRate += rateList.get(0);
- // } else if ("2".equals(retail.getRetailtype())) {//二级分销
- // int num = users.size() > 2 ? 2 : users.size();
- // for (int i = 0; i < num; i++) {
- // retailRate += rateList.get(i);
- // }
- //
- // } else {//三级分销
- // int num = users.size() > 2 ? 3 : users.size();
- // for (int i = 0; i < num; i++) {
- // retailRate += rateList.get(i);
- // }
- //
- // }
- //
- // }
- //
- // return retailRate;
- // }
- /**
- * 新订单 - 子订单
- *
- * @author: lig
- * @date: 2023年02月16日 0016
- */
- private InsAreaCompany response_order(InsOrders insOrder, QuoteRespVo quoteRespVo, Ruote requestData, RuoteResponse responseData, BaseQuoteVo<AccidentalDrivingVo> quoteVo) {
- //交强保费 含税
- double jqPremium = StringUtils.toDouble(responseData.getBase().getNBefTaxPrmJQ()) + StringUtils.toDouble(responseData.getBase().getNAppTaxAmtJQ());
- //商业保费 含税
- double syPremium = StringUtils.toDouble(responseData.getBase().getNBefTaxPrmSY()) + StringUtils.toDouble(responseData.getBase().getNAppTaxAmtSY());
- //保险公司订单号
- String insOrderNo = responseData.getBase().getCresvTxt6();
- //查询码交强
- String queryCodeJq = responseData.getVhl().getCQryCdeJQ();
- //查询码商业
- String queryCodeSy = responseData.getVhl().getCQryCdeSY();
- EsmInsCompany eic = esmInsCompanyService.getById(quoteVo.getCompanyId());
- boolean jq_falg = jqPremium > 0 ? true : false;
- //保存订单信息
- InsAreaCompany insAreaCompany = new InsAreaCompany();
- insAreaCompany.setOrderno(insOrder.getOrderno());
- insAreaCompany.setReptxt(JSONObject.parseObject(JSONObject.toJSONString(responseData)));
- insAreaCompany.setJqpremium(BigDecimal.valueOf(jq_falg ? jqPremium : 0));
- insAreaCompany.setSypremium(BigDecimal.valueOf(syPremium));
- insAreaCompany.setTaxamount(BigDecimal.valueOf(jq_falg ? quoteRespVo.getTaxAmount() : 0));
- insAreaCompany.setSumpremium(BigDecimal.valueOf(quoteRespVo.getSumPermium()));
- // insAreaCompany.setSumpremium(BigDecimal.valueOf(add(quoteRespVo.getSumPermium(), insOrder.getTaxamount())));
- insAreaCompany.setOrderstatus(InsTaskHistoryEnum.IN_QUOTATION.getState() + "");
- insAreaCompany.setCreatetime(LocalDateTime.now());
- insAreaCompany.setInsOrderNo(insOrderNo);
- insAreaCompany.setJqapplyno(queryCodeJq);
- insAreaCompany.setSyapplyno(queryCodeSy);
- insAreaCompany.setCompanyId(eic.getId());
- insAreaCompany.setInscompany(eic.getNamesimple());
- insAreaCompany.setAgreementId(quoteVo.getAgreementId());
- insAreaCompany.setJqStartDate(responseData.getBase().getTInsrncBgnTmJQ());
- insAreaCompany.setJqEndDate(responseData.getBase().getTInsrncEndTmJQ());
- insAreaCompany.setSyStartDate(responseData.getBase().getTInsrncBgnTmSY());
- insAreaCompany.setSyEndDate(responseData.getBase().getTInsrncEndTmSY());
- if (CollUtil.isEmpty(quoteRespVo.getRiskList())) {
- insAreaCompany.setRiskinfo(new JSONArray());
- } else {
- insAreaCompany.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteRespVo.getRiskList())));
- }
- if (CollUtil.isEmpty(quoteRespVo.getKindList())) {
- insAreaCompany.setKindinfo(new JSONArray());
- } else {
- insAreaCompany.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteRespVo.getKindList())));
- }
- //出险信息
- insAreaCompany.setAccidentStrInfo(quoteRespVo.getAccidentInfoStr());
- //评分
- insAreaCompany.setScore(quoteRespVo.getILogPreUdwMess());
- //欠税信息
- if(null != quoteRespVo.getTaxArrears()){
- insAreaCompany.setTaxArrears(JSONObject.parseArray(JSONObject.toJSONString(quoteRespVo.getTaxArrears())));
- }
- insAreaCompanyService.save(insAreaCompany);
- return insAreaCompany;
- }
- public static double add(double v1, double v2) {
- BigDecimal b1 = new BigDecimal(Double.toString(v1));
- BigDecimal b2 = new BigDecimal(Double.toString(v2));
- return b1.add(b2).doubleValue();
- }
- public static String getUserName() {
- return "";
- // String userName = null;
- // Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- //
- // if (principal instanceof UserDetails) {
- // userName = ((UserDetails) principal).getUsername();
- // } else {
- // userName = principal.toString();
- // }
- // return userName;
- }
- /**
- * 验证远程请求
- *
- * @author: lig
- * @date: 2023年02月22日 0022
- */
- private void verifyRequest(InsApiLog apiLog, InsAreaCompany insAreaCompany, InsQuoteFlow iqf) {
- //增加api日志
- insApiLogService.insertAsync(new InsApiLog(insAreaCompany, apiLog, iqf));
- if (StringUtils.isNotEmpty(apiLog.getExceptionMsg())) {
- throw new SystemException("远程接口调用异常");
- // throw new RuntimeException("远程接口调用异常");
- }
- }
- // /**
- // * 验证远程请求
- // *
- // * @author: lig
- // * @date: 2023年02月22日 0022
- // */
- // private void verifyRequest(InsApiLog apiLog, InsAreaCompany insAreaCompany) {
- // //增加api日志
- // insApiLogService.insertAsync(new InsApiLog(insAreaCompany, apiLog));
- // if (StringUtils.isNotEmpty(apiLog.getExceptionMsg())) {
- // throw new RuntimeException("远程接口调用异常");
- // }
- //
- // }
- /**
- * 更新api log
- *
- * @author: lig
- * @date: 2023-03-21
- */
- private void updateApiLog(InsApiLog apiLog, InsAreaCompany iac) {
- if (null != apiLog && null != iac) {
- apiLog.setOrderNo(StringUtils.toString(iac.getId()));
- // apiLog.setOrderStatus(iac.getOrderstatus());
- insApiLogService.UpdateAsync(apiLog);
- }
- }
- @Override
- public Map<String, String> gainRegionCode(String address) {
- log.debug("*********永诚API方式 - 身份证地址解析 参数:" + address);
- Map rMap = new HashMap();
- // if (address.indexOf("湖北省仙桃市") == 0) {
- // rMap.put("provinceCode", "420000");
- // rMap.put("cityCode", "429004");
- // rMap.put("areaCode", "");
- // return rMap;
- // }
- if (address.contains("邢台县")) {
- address.replaceAll("邢台县", "信都区");
- }
- if (address.contains("旬阳县")) {
- address.replaceAll("旬阳县", "旬阳市");
- }
- if (address.contains("开县")) {
- address.replaceAll("开县", "开州区");
- }
- Map<String, String> m = IDCardUtils.addressResolution(address);
- if (null == m) return null;
- String city = m.get("city");
- String district = m.get("district");
- // if(StringUtils.isNullOrEmpty(district)){
- // //第二级赋值到第三级
- // district = city;
- // }
- List<InsAlltrustRegion> areaList = new ArrayList<>();
- if (StringUtils.isNotEmpty(district)) {
- //查询地区
- LambdaQueryWrapper<InsAlltrustRegion> lqw = new LambdaQueryWrapper<>();
- lqw.eq(InsAlltrustRegion::getArea, district);
- areaList = insAlltrustRegionMapper.selectList(lqw);
- }
- //如果地区查不到 用城市当地区查
- if (null == areaList || areaList.size() < 1) {
- LambdaQueryWrapper<InsAlltrustRegion> cityLqw = new LambdaQueryWrapper<>();
- cityLqw.eq(InsAlltrustRegion::getArea, city);
- areaList = insAlltrustRegionMapper.selectList(cityLqw);
- }
- //如果地区查不到 用城市当地区查
- if (null == areaList || areaList.size() < 1) {
- LambdaQueryWrapper<InsAlltrustRegion> cityLqw = new LambdaQueryWrapper<>();
- cityLqw.eq(InsAlltrustRegion::getArea, city);
- areaList = insAlltrustRegionMapper.selectList(cityLqw);
- }
- //如果地区查不到 查市
- if (null == areaList || areaList.size() < 1) {
- LambdaQueryWrapper<InsAlltrustRegion> cityLqw = new LambdaQueryWrapper<>();
- cityLqw.eq(InsAlltrustRegion::getCity, city);
- areaList = insAlltrustRegionMapper.selectList(cityLqw);
- }
- if (null != areaList && areaList.size() > 0) {
- rMap.put("provinceCode", areaList.get(0).getProvinceCode());
- rMap.put("cityCode", areaList.get(0).getCityCode());
- rMap.put("areaCode", areaList.get(0).getAreaCode());
- return rMap;
- }
- throw new SystemException("永诚(日志号:" + IPUtil.gainServerNo() + ") - 被保人地区自动解析失败,请手动填写。");
- // return null;
- }
- /**
- * 新的
- *
- * @author: lig
- * @date: 2023年10月12日 0012
- */
- public Map<String, String> gainRegionCode(String address, String type) {
- log.debug("*********永诚API方式 - 身份证地址解析 参数:" + address);
- Map rMap = new HashMap();
- // if (address.indexOf("湖北省仙桃市") == 0) {
- // rMap.put("provinceCode", "420000");
- // rMap.put("cityCode", "429004");
- // rMap.put("areaCode", "");
- // return rMap;
- // }
- // if (address.contains("邢台县")) {
- // address.replaceAll("邢台县", "信都区");
- // }
- if (address.contains("旬阳县")) {
- address.replaceAll("旬阳县", "旬阳市");
- }
- if (address.contains("开县")) {
- address.replaceAll("开县", "开州区");
- }
- Map<String, String> m = IDCardUtils.addressResolution(address);
- if (null == m) return null;
- String city = m.get("city");
- String district = m.get("district");
- // if(StringUtils.isNullOrEmpty(district)){
- // //第二级赋值到第三级
- // district = city;
- // }
- List<InsAlltrustRegion> areaList = new ArrayList<>();
- if (StringUtils.isNotEmpty(district)) {
- //查询地区
- LambdaQueryWrapper<InsAlltrustRegion> lqw = new LambdaQueryWrapper<>();
- lqw.eq(InsAlltrustRegion::getArea, district);
- areaList = insAlltrustRegionMapper.selectList(lqw);
- }
- //如果地区查不到 用城市当地区查
- if (null == areaList || areaList.size() < 1) {
- LambdaQueryWrapper<InsAlltrustRegion> cityLqw = new LambdaQueryWrapper<>();
- cityLqw.eq(InsAlltrustRegion::getArea, city);
- areaList = insAlltrustRegionMapper.selectList(cityLqw);
- }
- //如果地区查不到 用城市当地区查
- if (null == areaList || areaList.size() < 1) {
- LambdaQueryWrapper<InsAlltrustRegion> cityLqw = new LambdaQueryWrapper<>();
- cityLqw.eq(InsAlltrustRegion::getArea, city);
- areaList = insAlltrustRegionMapper.selectList(cityLqw);
- }
- //如果地区查不到 查市
- if (null == areaList || areaList.size() < 1) {
- LambdaQueryWrapper<InsAlltrustRegion> cityLqw = new LambdaQueryWrapper<>();
- cityLqw.eq(InsAlltrustRegion::getCity, city);
- areaList = insAlltrustRegionMapper.selectList(cityLqw);
- }
- if (null != areaList && areaList.size() > 0) {
- rMap.put("provinceCode", areaList.get(0).getProvinceCode());
- rMap.put("cityCode", areaList.get(0).getCityCode());
- rMap.put("areaCode", areaList.get(0).getAreaCode());
- return rMap;
- }
- return null;
- }
- private void buildRegion(Ruote m, BaseQuoteInfoVo yaQuoteInfoVo) {
- //车主
- CustomerInfoVo owner = yaQuoteInfoVo.getOwnerInfo();
- //被保人
- CustomerInfoVo insured = yaQuoteInfoVo.getInsuredPersonInfo();
- //投保人
- CustomerInfoVo applicant = yaQuoteInfoVo.getPolicyHolderInfo();
- Map<String, String> ownerMap = null;
- //被保人省市区
- Map<String, String> insureMap = null;
- Map<String, String> applicantMap = null;
- //车主省市区
- List<String> ownerProvinceData = owner.getProvinceData();
- //被保人省市区
- List<String> insuredProvinceData = insured.getProvinceData();
- //投保人 省市区
- List<String> applicantProvinceData = applicant.getProvinceData();
- if (CollUtil.isNotEmpty(ownerProvinceData) && CollUtil.isNotEmpty(insuredProvinceData) && CollUtil.isNotEmpty(applicantProvinceData)) {
- //构造参数
- buildRegionParam(m, yaQuoteInfoVo, ownerProvinceData, insuredProvinceData, applicantProvinceData);
- // yaQuoteInfoVo.getOwnerInfo().setProvinceData(ownerProvinceData);
- // m.getRequestLabel().getCondition().getVhlowner().setCProvince(ownerProvinceData.get(0));
- // m.getRequestLabel().getCondition().getVhlowner().setCCity(ownerProvinceData.get(1));
- // m.getRequestLabel().getCondition().getVhlowner().setCCounty(ownerProvinceData.get(2));
- //
- //
- // yaQuoteInfoVo.getInsuredPersonInfo().setProvinceData(insuredProvinceData);
- // m.getRequestLabel().getCondition().getInsured().setCProvince(insuredProvinceData.get(0));
- // m.getRequestLabel().getCondition().getInsured().setCCity(insuredProvinceData.get(1));
- // m.getRequestLabel().getCondition().getInsured().setCCounty(insuredProvinceData.get(2));
- //
- //
- // yaQuoteInfoVo.getPolicyHolderInfo().setProvinceData(applicantProvinceData);
- // m.getRequestLabel().getCondition().getApplicant().setCProvince(applicantProvinceData.get(0));
- // m.getRequestLabel().getCondition().getApplicant().setCCity(applicantProvinceData.get(1));
- // m.getRequestLabel().getCondition().getApplicant().setCCounty(applicantProvinceData.get(2));
- return;
- }
- if (null != owner && CollUtil.isEmpty(ownerProvinceData)) {
- ownerProvinceData = new ArrayList<>();
- //处理地区 车主
- ownerMap = gainRegionCode(owner.getAddr(), "车主");
- // if(CollUtil.isNotEmpty(ownerMap)){
- // m.getRequestLabel().getCondition().getVhlowner().setCProvince(ownerMap.get("provinceCode"));
- // m.getRequestLabel().getCondition().getVhlowner().setCCity(ownerMap.get("cityCode"));
- // m.getRequestLabel().getCondition().getVhlowner().setCCounty(ownerMap.get("areaCode"));
- // }
- }
- if (null != insured && CollUtil.isEmpty(insuredProvinceData)) {
- insuredProvinceData = new ArrayList<>();
- //处理地区 被保人
- insureMap = gainRegionCode(insured.getAddr(), "被保人");
- // if(CollUtil.isNotEmpty(insureMap)){
- // m.getRequestLabel().getCondition().getInsured().setCProvince(insureMap.get("provinceCode"));
- // m.getRequestLabel().getCondition().getInsured().setCCity(insureMap.get("cityCode"));
- // m.getRequestLabel().getCondition().getInsured().setCCounty(insureMap.get("areaCode"));
- // }
- }
- if (null != applicant && CollUtil.isEmpty(applicantProvinceData)) {
- applicantProvinceData = new ArrayList<>();
- //处理地区 投保人
- applicantMap = gainRegionCode(applicant.getAddr(), "投保人");
- // if(CollUtil.isNotEmpty(applicantMap)){
- // m.getRequestLabel().getCondition().getApplicant().setCProvince(applicantMap.get("provinceCode"));
- // m.getRequestLabel().getCondition().getApplicant().setCCity(applicantMap.get("cityCode"));
- // m.getRequestLabel().getCondition().getApplicant().setCCounty(applicantMap.get("areaCode"));
- // }
- }
- StringBuffer sb = new StringBuffer();
- if (null == ownerMap && CollUtil.isEmpty(ownerProvinceData)) {
- sb.append("|永诚 - 车主地区自动解析失败,请手动填写。");
- }
- if (null == insureMap && CollUtil.isEmpty(insuredProvinceData)) {
- sb.append("|永诚 - 被保人地区自动解析失败,请手动填写。");
- }
- if (null == applicantMap && CollUtil.isEmpty(applicantProvinceData)) {
- sb.append("|永诚 - 投保人地区自动解析失败,请手动填写。");
- }
- if (StringUtils.isNotEmpty(sb)) throw new SystemException(sb.toString());
- if (CollUtil.isNotEmpty(ownerMap)) {
- ownerProvinceData.add(ownerMap.get("provinceCode"));
- ownerProvinceData.add(ownerMap.get("cityCode"));
- ownerProvinceData.add(ownerMap.get("areaCode"));
- }
- if (CollUtil.isNotEmpty(insureMap)) {
- insuredProvinceData.add(insureMap.get("provinceCode"));
- insuredProvinceData.add(insureMap.get("cityCode"));
- insuredProvinceData.add(insureMap.get("areaCode"));
- }
- if (CollUtil.isNotEmpty(applicantMap)) {
- applicantProvinceData.add(applicantMap.get("provinceCode"));
- applicantProvinceData.add(applicantMap.get("cityCode"));
- applicantProvinceData.add(applicantMap.get("areaCode"));
- }
- //构造参数
- buildRegionParam(m, yaQuoteInfoVo, ownerProvinceData, insuredProvinceData, applicantProvinceData);
- }
- // private InsAlltrustRegion findRegion(CustomerInfoVo info) {
- // String province = info.getProvince();
- // String city = info.getCity();
- // String area = info.getCounty();
- //
- // //lig 2023-09-21 临时解决 页面解决后可删除。
- // if (StringUtils.isEmpty(province) && StringUtils.isEmpty(city) && StringUtils.isEmpty(area)) {
- // throw new SystemException("永诚报价需要录入省市县");
- // }
- //
- // if (info.getAddr().indexOf("湖北省仙桃市") == 0) {
- // InsAlltrustRegion r = new InsAlltrustRegion();
- // r.setProvinceCode("420000");
- // r.setProvince("湖北省");
- // r.setCityCode("429004");
- // r.setCity("仙桃市");
- // r.setArea("");
- // r.setAreaCode("");
- // return r;
- // }
- //
- // LambdaQueryWrapper<InsAlltrustRegion> lqw = new LambdaQueryWrapper<>();
- // lqw.eq(StringUtils.isNotEmpty(province), InsAlltrustRegion::getProvince, province);
- // lqw.eq(StringUtils.isNotEmpty(city), InsAlltrustRegion::getCity, city);
- // lqw.eq(StringUtils.isNotEmpty(area), InsAlltrustRegion::getArea, area);
- // try {
- // return insAlltrustRegionMapper.selectOne(lqw);
- // } catch (Exception e) {
- // throw new SystemException("永诚 - 省市县校验失败," + province + city + area);
- // }
- // }
- // private void buildRegion(Ruote m) {
- // //车主
- // Vhlowner owner = m.getRequestLabel().getCondition().getVhlowner();
- // //被保人
- // Insured i = m.getRequestLabel().getCondition().getInsured();
- // //投保人
- // Applicant a = m.getRequestLabel().getCondition().getApplicant();
- //
- //
- // String provinceCode = "provinceCode";
- // String cityCode = "cityCode";
- // String areaCode = "areaCode";
- //// owner.getCAreaCde()
- //
- // Map<String, String> ownerMap = gainRegionCode(owner.getCWaddress());
- // if (null != ownerMap && ownerMap.size() > 0) {
- // owner.setCProvince(ownerMap.get(provinceCode));
- // owner.setCCity(ownerMap.get(cityCode));
- // owner.setCCounty(ownerMap.get(areaCode));
- // //清空格式化 自建数据
- // owner.setCWaddress(null);
- // } else {
- // throw new SystemException("永诚 - 车主地区获取失败,请联系管理员");
- // }
- //
- // Map<String, String> iMap = gainRegionCode(i.getCClntAddr());
- // if (null != iMap && iMap.size() > 0) {
- // i.setCProvince(iMap.get(provinceCode));
- // i.setCCity(iMap.get(cityCode));
- // i.setCCounty(iMap.get(areaCode));
- // } else {
- // throw new SystemException("永诚 - 被保人地区获取失败,请联系管理员");
- // }
- //
- // Map<String, String> aMap = gainRegionCode(a.getCClntAddr());
- // if (null != aMap && aMap.size() > 0) {
- // a.setCProvince(aMap.get(provinceCode));
- // a.setCCity(aMap.get(cityCode));
- // a.setCCounty(aMap.get(areaCode));
- // } else {
- // throw new SystemException("永诚 - 投保人地区获取失败,请联系管理员");
- // }
- // }
- /**
- * 构造回调
- * 依赖 buildCallBack
- *
- * @author: lig
- * @date: 2023-05-06
- */
- private InsAreaCompany buildCallBack(InsAreaCompany iac, CallBackRequest param) {
- //正常回调 与 补传回调
- if (StringUtils.isNotEmpty(param.getStatus())) {
- iac = buildCallBackStatus(iac, param.getStatus());
- } else {
- if (StringUtils.isNotEmpty(param.getJqstatus())) {
- iac = buildCallBackStatus(iac, param.getJqstatus());
- }
- if (StringUtils.isNotEmpty(param.getSystatus())) {
- iac = buildCallBackStatus(iac, param.getSystatus());
- }
- }
- return iac;
- }
- /**
- * 构造回调状态
- *
- * @author: lig
- * @date: 2023-05-06
- */
- private InsAreaCompany buildCallBackStatus(InsAreaCompany iac, String status) {
- if (status.equals("9")) {
- iac.setOrderstatus(InsOrderStatusEnum.WAIT_PAY.getCode());
- //更新支付连接
- log.debug("准备进入获取支付连接######################");
- iac = getPayUrlApi(iac);
- log.debug("结束 - 准备进入获取支付连接######################");
- }
- if (status.equals("3")) {
- iac.setOrderstatus(InsOrderStatusEnum.TO_BACK.getCode());
- }
- if (status.equals("1")) {
- iac.setOrderstatus(InsOrderStatusEnum.ACCEPT_INSURANCE.getCode());
- }
- return iac;
- }
- // /**
- // * 通过修改参数后 报价
- // *
- // * @author: lig
- // * @date: 2023年05月17日 0017
- // */
- // private RuoteResponse quoteApiByEdit(Ruote m) {
- //
- // RuoteResponse rd = null;
- //
- // log.debug("=========永诚API方式 - xml请求 - (修改参数后)报价开始======");
- // InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_QUOTE);
- // log.debug("=========永诚API方式 - xml请求 - (修改参数后)报价结束!======");
- // verifyRequest(apiLog, null, InsQuoteFlow.Q_S_0);
- //
- // String responseData = apiLog.getResponseData();
- //
- // try {
- // String cleanStr = YcBuildData.cleanResponseStr(responseData);
- // rd = xmlMapper.readValue(cleanStr, RuoteResponse.class);
- //
- //
- // } catch (IOException e) {
- // log.error("=========永诚API方式 - xml请求 - (修改参数后)报价 错误:" + e.getMessage());
- // throw new RuntimeException(e);
- // }
- // return rd;
- //
- // }
- /**
- * 请求API接口,返回对象
- *
- * @author: lig
- * @date: 2023年05月18日 0018
- */
- private <T> T requestApi(Object m, T response, InsAreaCompany iac, String reqUrl, InsQuoteFlow iqf, String textHead) {
- String responseData = httpPostResultLog(m, reqUrl, textHead);
- if (responseData.contains("报价返回信息异常")) {
- throw new SystemException("永诚报价请求负荷,永诚建议请稍后重试。");
- }
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- try {
- response = (T) gainXmlMapper().readValue(cleanStr, response.getClass());
- return response;
- } catch (JsonProcessingException e) {
- log.debug("=========永诚API方式 - xml请求 - {}解析报错:{}", iqf.getDesc(), e.getMessage());
- throw new SystemException("请求接口失败,对象转换错误,请联系管理员。");
- }
- }
- // private boolean gainResultFlag(RuoteResponse rd,Ruote m){
- // boolean flag = false;
- // if (null == rd) {
- // throw new SystemException("远程请求报价失败");
- // }
- //
- // if (rd.getHead().getErrorCode().equals("000000")) {
- // //获取失败
- // boolean fail = !(StringUtils.isNotEmpty(rd.getVhl().getCQryCdeJQ()) || StringUtils.isNotEmpty(rd.getVhl().getCQryCdeSY()));
- // if (fail) {
- // //如果类型错误,修改类型后,继续报价
- // if (StringUtils.isNotEmpty(rd.getVhl().getCBusType())) {
- // //修改类型继续报价
- // m.getRequestLabel().getCondition().getVhl().setCBusType(rd.getVhl().getCBusType());
- // rd = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
- // if (null == rd) return HttpResult.error("远程请求报价失败");
- // if (fail) {
- // throw new SystemException(rd.getHead().getErrorMessage());
- // }
- // }
- // throw new SystemException(rd.getHead().getErrorMessage());
- // }
- // } else {
- // throw new SystemException(rd.getHead().getErrorMessage());
- // }
- //
- // }
- private YcConfigureParameters gainYcConfigParams(String agreementId) {
- YcConfigureParameters ycConfigureParameters = new YcConfigureParameters();
- configureParametersComponents.toEntity(ycConfigureParameters, agreementId);
- return ycConfigureParameters;
- }
- /**
- * 获取车险保单
- *
- * @author: lig
- * @date: 2023年09月21日 0021
- */
- public String gainCarInsPolicy(String url, String fileName, String licensePlate) {
- String dir = "carInsPolicy/" + licensePlate + "/";
- return FileUtil.netUrlToFile(url, dir, fileName, uploadFilePath, apiUrl + showFileUrl);
- }
- /**
- * 获取《存在》的保单地址
- *
- * @author: lig
- * @date: 2023年09月21日 0021
- */
- public String gainExistCarInsPolicy(String fileName, String licensePlate) {
- String dir = SysConstants.CAR_INS_POLICY + "/" + licensePlate + "/";
- return FileUtil.fileExist(dir, fileName, uploadFilePath, apiUrl + showFileUrl);
- }
- private void buildOrderStatus(InsOrders order, InsAreaCompany iac) {
- //订单状态不为已承包的处理
- if (!order.getOrderstatus().equals(InsOrderStatusEnum.ACCEPT_INSURANCE.getCode())) {
- //订单状态 报价中,状态覆盖
- if (order.getOrderstatus().equals(InsOrderStatusEnum.QUOTE_ING.getCode())) {
- order.setOrderstatus(iac.getOrderstatus());
- }
- //订单状态 待核保
- if (order.getOrderstatus().equals(InsOrderStatusEnum.WAIT_AUDIT.getCode())) {
- if (StringUtils.toInt(iac.getOrderstatus()) > StringUtils.toInt(order.getOrderstatus())) {
- order.setOrderstatus(iac.getOrderstatus());
- }
- }
- //订单状态 已核保待缴费 不处理
- // if (order.getOrderstatus().equals(InsOrderStatusEnum.WAIT_PAY.getCode())) {
- // order.setOrderstatus(iac.getOrderstatus());
- // }
- //订单状态 核保退回 不处理
- if (order.getOrderstatus().equals(InsOrderStatusEnum.TO_BACK.getCode())) {
- if (!iac.getOrderstatus().equals(InsOrderStatusEnum.WAIT_PAY.getCode())) {
- order.setOrderstatus(iac.getOrderstatus());
- }
- }
- }
- }
- private void buildCarInfo(CarInfoVo carInfo, ModelsQueryResponse.VehicleInfo vehicleInfo) {
- carInfo.setModelCode(vehicleInfo.getVehicleId());
- carInfo.setCiCarName(vehicleInfo.getVehicleName());
- carInfo.setModelcname(vehicleInfo.getVehicleName());
- // carInfo.setSeatCount(vehicleInfo.getVehicleSeat());
- }
- private void buildRegionParam(Ruote m,BaseQuoteInfoVo yaQuoteInfoVo,List<String> ownerProvinceData,List<String> insuredProvinceData,List<String> applicantProvinceData) {
- yaQuoteInfoVo.getOwnerInfo().setProvinceData(ownerProvinceData);
- m.getRequestLabel().getCondition().getVhlowner().setCProvince(ownerProvinceData.get(0));
- m.getRequestLabel().getCondition().getVhlowner().setCCity(ownerProvinceData.get(1));
- m.getRequestLabel().getCondition().getVhlowner().setCCounty(ownerProvinceData.get(2));
- yaQuoteInfoVo.getInsuredPersonInfo().setProvinceData(insuredProvinceData);
- m.getRequestLabel().getCondition().getInsured().setCProvince(insuredProvinceData.get(0));
- m.getRequestLabel().getCondition().getInsured().setCCity(insuredProvinceData.get(1));
- m.getRequestLabel().getCondition().getInsured().setCCounty(insuredProvinceData.get(2));
- yaQuoteInfoVo.getPolicyHolderInfo().setProvinceData(applicantProvinceData);
- m.getRequestLabel().getCondition().getApplicant().setCProvince(applicantProvinceData.get(0));
- m.getRequestLabel().getCondition().getApplicant().setCCity(applicantProvinceData.get(1));
- m.getRequestLabel().getCondition().getApplicant().setCCounty(applicantProvinceData.get(2));
- }
- }
|