| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- package com.ydtech.modules.order.controller;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.ydtech.aop.request.RequestSingleParam;
- import com.ydtech.constants.enums.InsuranceRisk;
- import com.ydtech.constants.enums.dict.agreement.ProductsType;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.base.controller.BaseController;
- import com.ydtech.modules.ins.model.vo.KindInfoVo;
- import com.ydtech.modules.ins.model.vo.QuoteRespVo;
- import com.ydtech.modules.order.aop.QuoteVerification;
- 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.vo.AccidentalDrivingVo;
- import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
- import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
- import com.ydtech.modules.order.entity.vo.QuoteAccidentalDrivingVo;
- import com.ydtech.modules.order.entity.vo.bohai.BoHaiQuoteAccidentVo;
- import com.ydtech.modules.order.entity.vo.guoren.GuoRenQuoteVo;
- import com.ydtech.modules.order.entity.vo.guoren.GuorenAccidentalDrivingVo;
- import com.ydtech.modules.order.entity.vo.zj.ZjQuoteAccidentVo;
- import com.ydtech.modules.order.service.*;
- import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
- import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
- import com.ydtech.modules.protocol.entity.constants.PtlApiType;
- import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
- import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
- import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
- import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
- import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
- import com.ydtech.modules.protocol.service.PtlAgreementService;
- import com.ydtech.modules.protocol.service.PtlTaxSourceNewService;
- import com.ydtech.modules.protocol.service.impl.TaxSourceExcludeServiceImpl;
- import com.ydtech.utils.StringUtils;
- import io.swagger.annotations.Api;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.util.ObjectUtils;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.time.LocalDate;
- import java.time.format.DateTimeFormatter;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Objects;
- @Api(tags = "报价")
- @RestController
- @RequestMapping(value = "/quote")
- public class QuoteController extends BaseController {
- @Autowired
- TaxSourceExcludeServiceImpl taxSourceExcludeService;
- @Autowired
- PtlTaxSourceNewService ptlTaxSourceNewService;
- @Autowired
- PtlTaxSourceNewMapper ptlTaxSourceNewMapper;
- @Autowired
- InsOrdersComponents insOrdersComponents;
- @Autowired
- PtlAgreementAttributionService ptlAgreementAttributionService;
- @Autowired
- InsCrawlerOrderService insCrawlerOrderService;
- @Autowired
- ZhongMeiOrderApiService zhongMeiOrderApiService;
- @Autowired
- ZijinOrderApiService zijinOrderApiService;
- @Autowired
- YongchengOrderApiService yongchengOrderApiService;
- @Autowired
- HuaTaiOrderApiService huaTaiOrderApiService;
- @Autowired
- GuorenOrderApiService guorenOrderApiService;
- @Autowired
- DaJiaOrderService daJiaOrderService;
- @Autowired
- BoHaiOrderApiService boHaiOrderApiService;
- @Autowired
- PingAnOrderApiService pingAnOrderApiService;
- @Autowired
- InsOrdersService insOrdersService;
- @Autowired
- InsAreaCompanyService insAreaCompanyService;
- @Autowired
- YongAnOrderService yongAnOrderService;
- @Autowired
- PtlAgreementService ptlAgreementService;
- @QuoteVerification("报价授权")
- @PostMapping(value = "/quote")
- public HttpResult<QuoteRespVo> quote(@RequestBody BaseQuoteVo<Object> quoteVo) throws Exception {
- //处理商业险 为空的去掉
- List<KindInfoVo> kinds = quoteVo.getKinds();
- kinds.removeIf(item->Double.compare(item.getAmount(),0) == 0 && Double.compare(item.getUnitAmount(),0) == 0 && item.getServiceTimes() == 0);
- BaseQuoteInfoVo quoteInfo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo(), quoteVo.getAgreementId(),quoteVo.getKinds());
- quoteInfo.setKindList(kinds);
- //设置座位数 驾意险需要传
- quoteVo.setSeatNum(quoteInfo.getCarInfo().getSeatCount());
- HttpResult<QuoteRespVo> respVo = null;
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(quoteVo.getAgreementId());
- LocalDate currentDate = LocalDate.now();
- if(byAgreementId.getData().getAgreement().getIsValid().equals("0") //是否有效
- || byAgreementId.getData().getAgreement().getValidStatus().equals("0") //是否有效
- || !(currentDate.isAfter(byAgreementId.getData().getAgreement().getStartDate()) && currentDate.isBefore(byAgreementId.getData().getAgreement().getEndDate()))){
- throw new SystemException("协议失效,请检查调度");
- }
- PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(quoteVo.getAgreementId());
- if (PtlApiType.PTL_API_2.getCode() == ptlAgreementAttribution.getApiType()) {
- BaseQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- quoteVo1.setSeatNum(quoteInfo.getCarInfo().getSeatCount());
- BaseQuoteVo baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
- respVo = insCrawlerOrderService.quote(quoteInfo, baseQuoteVo);
- }
- if("ZMBX1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- if(jsonObject.size() > 0) {
- AccidentalDrivingVo javaObject = jsonObject.toJavaObject(AccidentalDrivingVo.class);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- }else{
- quoteVo1.setAccidentalDrivingVo(null);
- }
- respVo = zhongMeiOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("AICS1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- //转换类型
- BaseQuoteVo<AccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
- respVo = yongchengOrderApiService.quoteApi(baseQuoteVo);
- }
- if("YAIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- }
- if("ZKIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<List<ZjQuoteAccidentVo>> quoteVo1 = new BaseQuoteVo<>();
- JSONArray jsonObject = JSONArray.parseArray(JSONArray.toJSONString(quoteVo.getAccidentalDrivingVo()));
- List<ZjQuoteAccidentVo> javaObject = jsonObject.toJavaList(ZjQuoteAccidentVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- respVo = zijinOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("XDCX1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- GuoRenQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new GuoRenQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- // quoteVo1.setSeatNum();
- BaseQuoteVo<GuorenAccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
- GuoRenQuoteVo guoRenQuoteVo = new GuoRenQuoteVo();
- BeanUtils.copyProperties(baseQuoteVo, guoRenQuoteVo);
- guoRenQuoteVo.setGuoRenSpecialAgreementVo(baseQuoteVo.getGuoRenSpecialAgreementVo());
- respVo = guorenOrderApiService.quoteApi(guoRenQuoteVo);
- }
- if("HTIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- AccidentalDrivingVo javaObject = new AccidentalDrivingVo();
- if(!Objects.isNull(quoteVo.getAccidentalDrivingVo())) {
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- javaObject= jsonObject.toJavaObject(AccidentalDrivingVo.class);
- }
- BeanUtils.copyProperties(quoteVo,quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- respVo = huaTaiOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("DJPC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- respVo = daJiaOrderService.quote(quoteInfo, quoteVo);
- }
- if("BPIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<List<BoHaiQuoteAccidentVo>> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- if(jsonObject.size() > 0) {
- BoHaiQuoteAccidentVo javaObject = new BoHaiQuoteAccidentVo();
- javaObject.setPackageCode(jsonObject.getString("projectCode"));
- javaObject.setProductCode(jsonObject.getString("riskCode"));
- javaObject.setCopies(jsonObject.getString("quantity"));
- List<BoHaiQuoteAccidentVo> javaObjectList = new ArrayList<>();
- javaObjectList.add(javaObject);
- quoteVo1.setAccidentalDrivingVo(javaObjectList);
- }else{
- quoteVo1.setAccidentalDrivingVo(new ArrayList<>());
- }
- respVo = boHaiOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("PAIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- // BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- // JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- // AccidentalDrivingVo javaObject = jsonObject.toJavaObject(AccidentalDrivingVo.class);
- // BeanUtils.copyProperties(quoteVo,quoteVo1);
- // quoteVo1.setAccidentalDrivingVo(javaObject);
- // return pingAnOrderApiService.quote(quoteInfo, quoteVo1);
- }
- PtlAgreementAttribution byId = ptlAgreementAttributionService.getById(quoteVo.getAgreementId());
- if( respVo != null && !ObjectUtils.isEmpty( respVo.getData() )){
- respVo.getData().setApiType(byId.getApiType());
- }
- return respVo;
- }
- @PostMapping(value = "submitImage")
- public HttpResult submitImage(@RequestSingleParam(value = "companyId") String companyId) throws Exception {
- InsAreaCompany insAreaCompany = insAreaCompanyService.getById(companyId);
- PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
- if(Objects.isNull(ptlAgreementAttribution) || Objects.isNull(ptlAgreementAttribution.getApiType())){
- throw new SystemException("协议数据出错,请联系管理员");
- }
- HttpResult httpResult = null;
- //判断是否是爬虫
- if(ptlAgreementAttribution.getApiType() == 2){
- httpResult = insCrawlerOrderService.submitImage(companyId);
- }else if(ptlAgreementAttribution.getApiType() == 1){
- //渤海
- if(insAreaCompany.getCompanyId().equals("BPIC1000000")){
- httpResult = boHaiOrderApiService.submitImage(companyId);
- }
- //大家
- if(insAreaCompany.getCompanyId().equals("DJPC1000000")){
- httpResult = daJiaOrderService.submitImage(companyId);
- }
- //国任
- if(insAreaCompany.getCompanyId().equals("XDCX1000000")){
- httpResult = guorenOrderApiService.uploadImageApi(companyId);
- }
- //华泰
- if(insAreaCompany.getCompanyId().equals("HTIC1000000")){
- httpResult = huaTaiOrderApiService.submitImage(companyId);
- }
- //永安
- if(insAreaCompany.getCompanyId().equals("YAIC1000000")){
- httpResult = yongAnOrderService.submitImage(companyId);
- }
- //永诚
- if(insAreaCompany.getCompanyId().equals("AICS1000000")){
- httpResult = yongchengOrderApiService.uploadImageApi(companyId);
- }
- //中煤
- if(insAreaCompany.getCompanyId().equals("ZMBX1000000")){
- httpResult = zhongMeiOrderApiService.submitImage(companyId);
- }
- //紫金
- if(insAreaCompany.getCompanyId().equals("ZKIC1000000")){
- httpResult = zijinOrderApiService.submitImage(companyId);
- }
- }
- return httpResult;
- }
- }
|