785834757 8 месяцев назад
Родитель
Сommit
6b674ce563

+ 30 - 0
tenant/costsorrule/src/main/java/com/jzg/costsorrule/client/QuoteClient.java

@@ -0,0 +1,30 @@
+package com.jzg.costsorrule.client;
+
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.InsFeeOrdersParam;
+import com.jzg.commons.entity.po.InsFeeOrders;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+@FeignClient(name="jzg-insurance",url = "${feign.client.jzg-insurance.url}")
+public interface QuoteClient {
+
+    /**
+     * 新旧车判断
+     * @param registerDate
+     * @param companyId
+     * @param vehicleType
+     * @return
+     */
+    @GetMapping(value = "/newCarJudgeRules/compareNewCar")
+    public HttpResult compareNewCar(@RequestParam("registerDate") String registerDate, @RequestParam("companyId") String companyId, @RequestParam("vehicleType") String vehicleType);
+
+
+
+
+}

+ 50 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/NewCarJudgeRulesController.java

@@ -0,0 +1,50 @@
+package com.jzg.organization.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jzg.commons.constants.OperationTypeEnum;
+import com.jzg.commons.core.base.BaseController;
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.*;
+import com.jzg.commons.entity.enums.YesNoEnum;
+import com.jzg.commons.entity.po.OperatorTrajectory;
+import com.jzg.commons.entity.po.PtlAgreement;
+import com.jzg.commons.entity.vo.AgreementVo;
+import com.jzg.commons.entity.vo.UpAndDownVo;
+import com.jzg.commons.service.OperatorTrajectoryService;
+import com.jzg.commons.util.AssertionUtils;
+import com.jzg.commons.util.spring.SpringUtils;
+import com.jzg.organization.mapper.PtlAgreementMapper;
+import com.jzg.organization.service.NewCarJudgeRulesService;
+import com.jzg.organization.service.PtlAgreementDeptService;
+import com.jzg.organization.service.PtlAgreementService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 协议管理接口
+ *
+ * @author
+ */
+@Tag(name="新旧车管理")
+@RestController
+@RequestMapping("/newCarJudgeRules")
+public class NewCarJudgeRulesController extends BaseController {
+
+    @Autowired
+    NewCarJudgeRulesService newCarJudgeRulesService;
+
+    @Operation(summary = "判断新车")
+    @GetMapping("compareNewCar")
+    public HttpResult compareNewCar(@RequestParam String registerDate,@RequestParam String companyId, @RequestParam String vehicleType){
+        Boolean result = newCarJudgeRulesService.compareRule(registerDate, companyId, vehicleType);
+        return HttpResult.ok(result);
+    }
+}

+ 12 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/NewCarJudgeRulesMapper.java

@@ -0,0 +1,12 @@
+package com.jzg.organization.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jzg.commons.entity.po.PtlAgreementCostRule;
+import com.jzg.commons.entity.po.PtlNewCarJudgeRules;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface NewCarJudgeRulesMapper extends BaseMapper<PtlNewCarJudgeRules> {
+
+}

+ 31 - 0
tenant/organization/src/main/java/com/jzg/organization/service/NewCarJudgeRulesService.java

@@ -0,0 +1,31 @@
+package com.jzg.organization.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.po.PtlNewCarJudgeRules;
+import com.jzg.organization.entity.WechatCustomerService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public interface NewCarJudgeRulesService extends IService<PtlNewCarJudgeRules> {
+
+    /**
+     * 根据保险公司查询新旧车规则
+     * @param companyId
+     * @return
+     */
+    public List<PtlNewCarJudgeRules> getByCompany(String companyId, String vehicleType);
+
+
+    /**
+     * 比较新旧车 true 新车 false 旧车
+     * @param registerDate
+     * @param companyId
+     * @param vehicleType
+     * @return
+     */
+    public Boolean compareRule(String registerDate,String companyId,String vehicleType);
+
+
+}

+ 101 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/NewCarJudgeRulesServiceImpl.java

@@ -0,0 +1,101 @@
+package com.jzg.organization.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.convert.Convert;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.core.base.BaseController;
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.*;
+import com.jzg.commons.entity.enums.YesNoEnum;
+import com.jzg.commons.entity.po.*;
+import com.jzg.commons.entity.vo.*;
+import com.jzg.commons.exception.SystemException;
+import com.jzg.commons.util.MinioUtils;
+import com.jzg.commons.util.StringUtils;
+import com.jzg.organization.client.EsmInsCompanyClient;
+import com.jzg.organization.mapper.NewCarJudgeRulesMapper;
+import com.jzg.organization.mapper.PtlAgreementMapper;
+import com.jzg.organization.mapper.SysUploadFilesMapper;
+import com.jzg.organization.mapper.SysUserMapper;
+import com.jzg.organization.service.*;
+import org.apache.commons.lang3.ObjectUtils;
+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.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeParseException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+
+@Service
+public class NewCarJudgeRulesServiceImpl extends ServiceImpl<NewCarJudgeRulesMapper, PtlNewCarJudgeRules>
+    implements NewCarJudgeRulesService {
+    /**
+     * 根据保险公司查询新旧车规则
+     * @param companyId
+     * @return
+     */
+    @Override
+    public List<PtlNewCarJudgeRules> getByCompany(String companyId,String vehicleType){
+        LambdaQueryWrapper<PtlNewCarJudgeRules> ptlNewCarJudgeRulesLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        ptlNewCarJudgeRulesLambdaQueryWrapper.eq(PtlNewCarJudgeRules::getCompanyId, companyId);
+        ptlNewCarJudgeRulesLambdaQueryWrapper.eq(PtlNewCarJudgeRules::getIsEffective, 1);
+        if(Objects.nonNull(vehicleType) && !vehicleType.equals("")){
+            ptlNewCarJudgeRulesLambdaQueryWrapper.eq(PtlNewCarJudgeRules::getVehicleType,vehicleType);
+        }
+        List<PtlNewCarJudgeRules> ptlNewCarJudgeRules = baseMapper.selectList(ptlNewCarJudgeRulesLambdaQueryWrapper);
+        return ptlNewCarJudgeRules;
+    }
+
+    /**
+     * 比较新旧车 true 新车 false 旧车
+     * @param registerDate
+     * @param companyId
+     * @param vehicleType
+     * @return
+     */
+    @Override
+    public Boolean compareRule(String registerDate,String companyId,String vehicleType){
+        List<PtlNewCarJudgeRules> byCompany = this.getByCompany(companyId, vehicleType);
+        if(byCompany.isEmpty()){
+            throw new SystemException("不存在新旧车规则");
+        }
+        PtlNewCarJudgeRules ptlNewCarJudgeRules = byCompany.get(0);
+
+        // 注册日期解析
+        LocalDate regDate;
+        try {
+            regDate = LocalDate.parse(registerDate);
+        } catch (DateTimeParseException e) {
+            throw new SystemException("注册日期格式不正确:" + registerDate);
+        }
+        LocalDate now = LocalDate.now();
+        //判断月
+        if(ptlNewCarJudgeRules.getUnitTypeCode().equals("1")){
+            // 月份
+            String unitTypeValue = ptlNewCarJudgeRules.getUnitTypeValue();
+            int months = Integer.parseInt(unitTypeValue);
+            LocalDate targetDate = regDate.plusMonths(months);
+            return !now.isAfter(targetDate);
+        }else if(ptlNewCarJudgeRules.getUnitTypeCode().equals("2")){
+            // 天数
+            String unitTypeValue = ptlNewCarJudgeRules.getUnitTypeValue();
+            int days = Integer.parseInt(unitTypeValue);
+            LocalDate targetDate = regDate.plusDays(days);
+            return !now.isAfter(targetDate);
+        }
+        return false;
+    }
+
+}
+
+
+
+