QuoteController.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. package com.ydtech.modules.order.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  6. import com.fasterxml.jackson.core.JsonProcessingException;
  7. import com.ydtech.aop.request.RequestSingleParam;
  8. import com.ydtech.constants.enums.InsuranceRisk;
  9. import com.ydtech.constants.enums.dict.agreement.ProductsType;
  10. import com.ydtech.core.page.HttpResult;
  11. import com.ydtech.exception.SystemException;
  12. import com.ydtech.modules.base.controller.BaseController;
  13. import com.ydtech.modules.ins.model.vo.KindInfoVo;
  14. import com.ydtech.modules.ins.model.vo.QuoteRespVo;
  15. import com.ydtech.modules.order.aop.QuoteVerification;
  16. import com.ydtech.modules.order.components.InsOrdersComponents;
  17. import com.ydtech.modules.order.entity.InsAreaCompany;
  18. import com.ydtech.modules.order.entity.InsOrders;
  19. import com.ydtech.modules.order.entity.vo.AccidentalDrivingVo;
  20. import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
  21. import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
  22. import com.ydtech.modules.order.entity.vo.QuoteAccidentalDrivingVo;
  23. import com.ydtech.modules.order.entity.vo.bohai.BoHaiQuoteAccidentVo;
  24. import com.ydtech.modules.order.entity.vo.guoren.GuoRenQuoteVo;
  25. import com.ydtech.modules.order.entity.vo.guoren.GuorenAccidentalDrivingVo;
  26. import com.ydtech.modules.order.entity.vo.zj.ZjQuoteAccidentVo;
  27. import com.ydtech.modules.order.service.*;
  28. import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
  29. import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
  30. import com.ydtech.modules.protocol.entity.constants.PtlApiType;
  31. import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
  32. import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
  33. import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
  34. import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
  35. import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
  36. import com.ydtech.modules.protocol.service.PtlAgreementService;
  37. import com.ydtech.modules.protocol.service.PtlTaxSourceNewService;
  38. import com.ydtech.modules.protocol.service.impl.TaxSourceExcludeServiceImpl;
  39. import com.ydtech.utils.StringUtils;
  40. import io.swagger.annotations.Api;
  41. import org.springframework.beans.BeanUtils;
  42. import org.springframework.beans.factory.annotation.Autowired;
  43. import org.springframework.stereotype.Controller;
  44. import org.springframework.util.ObjectUtils;
  45. import org.springframework.web.bind.annotation.PostMapping;
  46. import org.springframework.web.bind.annotation.RequestBody;
  47. import org.springframework.web.bind.annotation.RequestMapping;
  48. import org.springframework.web.bind.annotation.RestController;
  49. import java.time.LocalDate;
  50. import java.time.format.DateTimeFormatter;
  51. import java.util.ArrayList;
  52. import java.util.List;
  53. import java.util.Objects;
  54. @Api(tags = "报价")
  55. @RestController
  56. @RequestMapping(value = "/quote")
  57. public class QuoteController extends BaseController {
  58. @Autowired
  59. TaxSourceExcludeServiceImpl taxSourceExcludeService;
  60. @Autowired
  61. PtlTaxSourceNewService ptlTaxSourceNewService;
  62. @Autowired
  63. PtlTaxSourceNewMapper ptlTaxSourceNewMapper;
  64. @Autowired
  65. InsOrdersComponents insOrdersComponents;
  66. @Autowired
  67. PtlAgreementAttributionService ptlAgreementAttributionService;
  68. @Autowired
  69. InsCrawlerOrderService insCrawlerOrderService;
  70. @Autowired
  71. ZhongMeiOrderApiService zhongMeiOrderApiService;
  72. @Autowired
  73. ZijinOrderApiService zijinOrderApiService;
  74. @Autowired
  75. YongchengOrderApiService yongchengOrderApiService;
  76. @Autowired
  77. HuaTaiOrderApiService huaTaiOrderApiService;
  78. @Autowired
  79. GuorenOrderApiService guorenOrderApiService;
  80. @Autowired
  81. DaJiaOrderService daJiaOrderService;
  82. @Autowired
  83. BoHaiOrderApiService boHaiOrderApiService;
  84. @Autowired
  85. PingAnOrderApiService pingAnOrderApiService;
  86. @Autowired
  87. InsOrdersService insOrdersService;
  88. @Autowired
  89. InsAreaCompanyService insAreaCompanyService;
  90. @Autowired
  91. YongAnOrderService yongAnOrderService;
  92. @Autowired
  93. PtlAgreementService ptlAgreementService;
  94. @QuoteVerification("报价授权")
  95. @PostMapping(value = "/quote")
  96. public HttpResult<QuoteRespVo> quote(@RequestBody BaseQuoteVo<Object> quoteVo) throws Exception {
  97. //处理商业险 为空的去掉
  98. List<KindInfoVo> kinds = quoteVo.getKinds();
  99. kinds.removeIf(item->Double.compare(item.getAmount(),0) == 0 && Double.compare(item.getUnitAmount(),0) == 0 && item.getServiceTimes() == 0);
  100. BaseQuoteInfoVo quoteInfo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo(), quoteVo.getAgreementId(),quoteVo.getKinds());
  101. quoteInfo.setKindList(kinds);
  102. //设置座位数 驾意险需要传
  103. quoteVo.setSeatNum(quoteInfo.getCarInfo().getSeatCount());
  104. HttpResult<QuoteRespVo> respVo = null;
  105. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  106. HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(quoteVo.getAgreementId());
  107. LocalDate currentDate = LocalDate.now();
  108. if(byAgreementId.getData().getAgreement().getIsValid().equals("0") //是否有效
  109. || byAgreementId.getData().getAgreement().getValidStatus().equals("0") //是否有效
  110. || !(currentDate.isAfter(byAgreementId.getData().getAgreement().getStartDate()) && currentDate.isBefore(byAgreementId.getData().getAgreement().getEndDate()))){
  111. throw new SystemException("协议失效,请检查调度");
  112. }
  113. PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(quoteVo.getAgreementId());
  114. if (PtlApiType.PTL_API_2.getCode() == ptlAgreementAttribution.getApiType()) {
  115. BaseQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
  116. JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
  117. QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
  118. BeanUtils.copyProperties(quoteVo, quoteVo1);
  119. quoteVo1.setAccidentalDrivingVo(javaObject);
  120. quoteVo1.setSeatNum(quoteInfo.getCarInfo().getSeatCount());
  121. BaseQuoteVo baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
  122. respVo = insCrawlerOrderService.quote(quoteInfo, baseQuoteVo);
  123. }
  124. if("ZMBX1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  125. BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
  126. JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
  127. BeanUtils.copyProperties(quoteVo, quoteVo1);
  128. if(jsonObject.size() > 0) {
  129. AccidentalDrivingVo javaObject = jsonObject.toJavaObject(AccidentalDrivingVo.class);
  130. quoteVo1.setAccidentalDrivingVo(javaObject);
  131. }else{
  132. quoteVo1.setAccidentalDrivingVo(null);
  133. }
  134. respVo = zhongMeiOrderApiService.quote(quoteInfo, quoteVo1);
  135. }
  136. if("AICS1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  137. BaseQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
  138. JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
  139. QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
  140. BeanUtils.copyProperties(quoteVo, quoteVo1);
  141. quoteVo1.setAccidentalDrivingVo(javaObject);
  142. //转换类型
  143. BaseQuoteVo<AccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
  144. respVo = yongchengOrderApiService.quoteApi(baseQuoteVo);
  145. }
  146. if("YAIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  147. }
  148. if("ZKIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  149. BaseQuoteVo<List<ZjQuoteAccidentVo>> quoteVo1 = new BaseQuoteVo<>();
  150. JSONArray jsonObject = JSONArray.parseArray(JSONArray.toJSONString(quoteVo.getAccidentalDrivingVo()));
  151. List<ZjQuoteAccidentVo> javaObject = jsonObject.toJavaList(ZjQuoteAccidentVo.class);
  152. BeanUtils.copyProperties(quoteVo, quoteVo1);
  153. quoteVo1.setAccidentalDrivingVo(javaObject);
  154. respVo = zijinOrderApiService.quote(quoteInfo, quoteVo1);
  155. }
  156. if("XDCX1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  157. GuoRenQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new GuoRenQuoteVo<>();
  158. JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
  159. QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
  160. BeanUtils.copyProperties(quoteVo, quoteVo1);
  161. quoteVo1.setAccidentalDrivingVo(javaObject);
  162. // quoteVo1.setSeatNum();
  163. BaseQuoteVo<GuorenAccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
  164. GuoRenQuoteVo guoRenQuoteVo = new GuoRenQuoteVo();
  165. BeanUtils.copyProperties(baseQuoteVo, guoRenQuoteVo);
  166. guoRenQuoteVo.setGuoRenSpecialAgreementVo(baseQuoteVo.getGuoRenSpecialAgreementVo());
  167. respVo = guorenOrderApiService.quoteApi(guoRenQuoteVo);
  168. }
  169. if("HTIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  170. BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
  171. AccidentalDrivingVo javaObject = new AccidentalDrivingVo();
  172. if(!Objects.isNull(quoteVo.getAccidentalDrivingVo())) {
  173. JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
  174. javaObject= jsonObject.toJavaObject(AccidentalDrivingVo.class);
  175. }
  176. BeanUtils.copyProperties(quoteVo,quoteVo1);
  177. quoteVo1.setAccidentalDrivingVo(javaObject);
  178. respVo = huaTaiOrderApiService.quote(quoteInfo, quoteVo1);
  179. }
  180. if("DJPC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  181. respVo = daJiaOrderService.quote(quoteInfo, quoteVo);
  182. }
  183. if("BPIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  184. BaseQuoteVo<List<BoHaiQuoteAccidentVo>> quoteVo1 = new BaseQuoteVo<>();
  185. JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
  186. BeanUtils.copyProperties(quoteVo, quoteVo1);
  187. if(jsonObject.size() > 0) {
  188. BoHaiQuoteAccidentVo javaObject = new BoHaiQuoteAccidentVo();
  189. javaObject.setPackageCode(jsonObject.getString("projectCode"));
  190. javaObject.setProductCode(jsonObject.getString("riskCode"));
  191. javaObject.setCopies(jsonObject.getString("quantity"));
  192. List<BoHaiQuoteAccidentVo> javaObjectList = new ArrayList<>();
  193. javaObjectList.add(javaObject);
  194. quoteVo1.setAccidentalDrivingVo(javaObjectList);
  195. }else{
  196. quoteVo1.setAccidentalDrivingVo(new ArrayList<>());
  197. }
  198. respVo = boHaiOrderApiService.quote(quoteInfo, quoteVo1);
  199. }
  200. if("PAIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
  201. // BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
  202. // JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
  203. // AccidentalDrivingVo javaObject = jsonObject.toJavaObject(AccidentalDrivingVo.class);
  204. // BeanUtils.copyProperties(quoteVo,quoteVo1);
  205. // quoteVo1.setAccidentalDrivingVo(javaObject);
  206. // return pingAnOrderApiService.quote(quoteInfo, quoteVo1);
  207. }
  208. PtlAgreementAttribution byId = ptlAgreementAttributionService.getById(quoteVo.getAgreementId());
  209. if( respVo != null && !ObjectUtils.isEmpty( respVo.getData() )){
  210. respVo.getData().setApiType(byId.getApiType());
  211. }
  212. return respVo;
  213. }
  214. @PostMapping(value = "submitImage")
  215. public HttpResult submitImage(@RequestSingleParam(value = "companyId") String companyId) throws Exception {
  216. InsAreaCompany insAreaCompany = insAreaCompanyService.getById(companyId);
  217. PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
  218. if(Objects.isNull(ptlAgreementAttribution) || Objects.isNull(ptlAgreementAttribution.getApiType())){
  219. throw new SystemException("协议数据出错,请联系管理员");
  220. }
  221. HttpResult httpResult = null;
  222. //判断是否是爬虫
  223. if(ptlAgreementAttribution.getApiType() == 2){
  224. httpResult = insCrawlerOrderService.submitImage(companyId);
  225. }else if(ptlAgreementAttribution.getApiType() == 1){
  226. //渤海
  227. if(insAreaCompany.getCompanyId().equals("BPIC1000000")){
  228. httpResult = boHaiOrderApiService.submitImage(companyId);
  229. }
  230. //大家
  231. if(insAreaCompany.getCompanyId().equals("DJPC1000000")){
  232. httpResult = daJiaOrderService.submitImage(companyId);
  233. }
  234. //国任
  235. if(insAreaCompany.getCompanyId().equals("XDCX1000000")){
  236. httpResult = guorenOrderApiService.uploadImageApi(companyId);
  237. }
  238. //华泰
  239. if(insAreaCompany.getCompanyId().equals("HTIC1000000")){
  240. httpResult = huaTaiOrderApiService.submitImage(companyId);
  241. }
  242. //永安
  243. if(insAreaCompany.getCompanyId().equals("YAIC1000000")){
  244. httpResult = yongAnOrderService.submitImage(companyId);
  245. }
  246. //永诚
  247. if(insAreaCompany.getCompanyId().equals("AICS1000000")){
  248. httpResult = yongchengOrderApiService.uploadImageApi(companyId);
  249. }
  250. //中煤
  251. if(insAreaCompany.getCompanyId().equals("ZMBX1000000")){
  252. httpResult = zhongMeiOrderApiService.submitImage(companyId);
  253. }
  254. //紫金
  255. if(insAreaCompany.getCompanyId().equals("ZKIC1000000")){
  256. httpResult = zijinOrderApiService.submitImage(companyId);
  257. }
  258. }
  259. return httpResult;
  260. }
  261. }