|
|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|