|
|
@@ -13,6 +13,7 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.factory.domain.ClaimSearchParam;
|
|
|
import org.springblade.factory.domain.ClaimSearchVO;
|
|
|
import org.springblade.factory.entity.PcBladeClaim;
|
|
|
import org.springblade.factory.entity.PcBladeClaimAttachment;
|
|
|
@@ -52,71 +53,14 @@ public class ClaimSearchController {
|
|
|
private final PcBladeClaimAuditService pcBladeClaimAuditService;
|
|
|
|
|
|
/**
|
|
|
- * 理赔申请综合查询(支持多条件组合+分页+数据权限)
|
|
|
- *
|
|
|
- * @param claimNo 理赔单号(精准)
|
|
|
- * @param claimSourceType 来源类型 1经销商 2门店 3终端消费者(精准)
|
|
|
- * @param auditStatus 审核状态 0待审核 1审核中 2已通过 3已拒绝(精准)
|
|
|
- * @param consumerName 消费者姓名(模糊)
|
|
|
- * @param consumerPhone 消费者电话(模糊)
|
|
|
- * @param tyreNo 胎号/轮胎宝编号(模糊)
|
|
|
- * @param tyreSpecs 规格型号(模糊)
|
|
|
- * @param claimAmountMin 索赔金额最小值(数值范围)
|
|
|
- * @param claimAmountMax 索赔金额最大值(数值范围)
|
|
|
- * @param runMileageMin 行驶里程最小值(数值范围)
|
|
|
- * @param runMileageMax 行驶里程最大值(数值范围)
|
|
|
- * @param isSubmitTime 是否已提交 0未提交 1已提交(精准)
|
|
|
- * @param pageNum 页码(默认1)
|
|
|
- * @param pageSize 每页条数(默认10,最大100)
|
|
|
- * @return 分页的理赔综合信息
|
|
|
- */
|
|
|
- /**
|
|
|
- * 理赔申请综合查询(全JDK版本兼容,无任何报错)
|
|
|
+ * 理赔申请综合查询(实体类接收参数 + 新增字段查询 + 门店名称模糊查询)
|
|
|
*/
|
|
|
@ApiOperation(value = "理赔申请综合查询", notes = "支持多条件组合查询,返回包含附件和审核记录的完整信息(带数据权限过滤)")
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "claimNo", value = "理赔单号(精准)", paramType = "query", dataType = "string"),
|
|
|
- @ApiImplicitParam(name = "claimSourceType", value = "来源类型 1经销商 2门店 3终端消费者", paramType = "query", dataType = "int"),
|
|
|
- @ApiImplicitParam(name = "auditStatus", value = "审核状态 0待审核 1审核中 2已通过 3已拒绝", paramType = "query", dataType = "int"),
|
|
|
- @ApiImplicitParam(name = "consumerName", value = "消费者姓名(模糊)", paramType = "query", dataType = "string"),
|
|
|
- @ApiImplicitParam(name = "consumerPhone", value = "消费者电话(模糊)", paramType = "query", dataType = "string"),
|
|
|
- @ApiImplicitParam(name = "tyreNo", value = "胎号/轮胎宝编号(模糊)", paramType = "query", dataType = "string"),
|
|
|
- @ApiImplicitParam(name = "tyreSpecs", value = "规格型号(模糊)", paramType = "query", dataType = "string"),
|
|
|
- // 日期参数改为字符串接收,前端传yyyy-MM-dd HH:mm:ss格式
|
|
|
- @ApiImplicitParam(name = "purchaseDateStartStr", value = "购买日期开始(yyyy-MM-dd HH:mm:ss)", paramType = "query", dataType = "string"),
|
|
|
- @ApiImplicitParam(name = "purchaseDateEndStr", value = "购买日期结束(yyyy-MM-dd HH:mm:ss)", paramType = "query", dataType = "string"),
|
|
|
- @ApiImplicitParam(name = "claimAmountMin", value = "索赔金额最小值", paramType = "query", dataType = "bigdecimal"),
|
|
|
- @ApiImplicitParam(name = "claimAmountMax", value = "索赔金额最大值", paramType = "query", dataType = "bigdecimal"),
|
|
|
- @ApiImplicitParam(name = "runMileageMin", value = "行驶里程最小值(km)", paramType = "query", dataType = "int"),
|
|
|
- @ApiImplicitParam(name = "runMileageMax", value = "行驶里程最大值(km)", paramType = "query", dataType = "int"),
|
|
|
- @ApiImplicitParam(name = "isSubmitTime", value = "是否已提交 0未提交 1已提交", paramType = "query", dataType = "int"),
|
|
|
- @ApiImplicitParam(name = "pageNum", value = "页码(默认1)", paramType = "query", dataType = "int", defaultValue = "1"),
|
|
|
- @ApiImplicitParam(name = "pageSize", value = "每页条数(默认10,最大100)", paramType = "query", dataType = "int", defaultValue = "10")
|
|
|
+ @ApiImplicitParam(name = "claimSearchParam", value = "理赔查询参数", paramType = "query", dataType = "ClaimSearchParam")
|
|
|
})
|
|
|
@GetMapping("/comprehensive")
|
|
|
- public R<IPage<ClaimSearchVO>> comprehensiveSearch(
|
|
|
- // 精准查询参数
|
|
|
- @RequestParam(required = false) String claimNo,
|
|
|
- @RequestParam(required = false) Integer claimSourceType,
|
|
|
- @RequestParam(required = false) Integer auditStatus,
|
|
|
- @RequestParam(required = false) Integer isSubmitTime,
|
|
|
- // 模糊查询参数
|
|
|
- @RequestParam(required = false) String consumerName,
|
|
|
- @RequestParam(required = false) String consumerPhone,
|
|
|
- @RequestParam(required = false) String tyreNo,
|
|
|
- @RequestParam(required = false) String tyreSpecs,
|
|
|
- // 日期参数:字符串接收(核心修复,避免DateTimeFormatter报错)
|
|
|
- @RequestParam(required = false) String purchaseDateStartStr,
|
|
|
- @RequestParam(required = false) String purchaseDateEndStr,
|
|
|
- // 数值范围参数
|
|
|
- @RequestParam(required = false) BigDecimal claimAmountMin,
|
|
|
- @RequestParam(required = false) BigDecimal claimAmountMax,
|
|
|
- @RequestParam(required = false) Integer runMileageMin,
|
|
|
- @RequestParam(required = false) Integer runMileageMax,
|
|
|
- // 分页参数
|
|
|
- @RequestParam(defaultValue = "1") Integer pageNum,
|
|
|
- @RequestParam(defaultValue = "10") Integer pageSize
|
|
|
- ) {
|
|
|
+ public R<IPage<ClaimSearchVO>> comprehensiveSearch(ClaimSearchParam claimSearchParam) {
|
|
|
try {
|
|
|
// ========== 1. 登录校验 ==========
|
|
|
Long userId = AuthUtil.getUserId();
|
|
|
@@ -125,20 +69,18 @@ public class ClaimSearchController {
|
|
|
}
|
|
|
|
|
|
// ========== 2. 分页参数校验 ==========
|
|
|
- pageNum = Math.max(pageNum, 1);
|
|
|
- pageSize = Math.max(Math.min(pageSize, 100), 1);
|
|
|
+ Integer pageNum = claimSearchParam.getPageNum() == null ? 1 : Math.max(claimSearchParam.getPageNum(), 1);
|
|
|
+ Integer pageSize = claimSearchParam.getPageSize() == null ? 10 : Math.max(Math.min(claimSearchParam.getPageSize(), 100), 1);
|
|
|
|
|
|
- // ========== 3. 日期转换(兼容所有JDK版本,核心修复) ==========
|
|
|
+ // ========== 3. 日期转换(兼容所有JDK版本) ==========
|
|
|
LocalDateTime purchaseDateStart = null;
|
|
|
LocalDateTime purchaseDateEnd = null;
|
|
|
- // 使用JDK1.0就支持的SimpleDateFormat,彻底避免版本问题
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
// 转换开始日期
|
|
|
- if (StringUtils.isNotBlank(purchaseDateStartStr)) {
|
|
|
+ if (StringUtils.isNotBlank(claimSearchParam.getPurchaseDateStartStr())) {
|
|
|
try {
|
|
|
- Date startDate = sdf.parse(purchaseDateStartStr);
|
|
|
- // Date转LocalDateTime(兼容JDK8+,如果是JDK7则需调整实体类字段为Date)
|
|
|
+ Date startDate = sdf.parse(claimSearchParam.getPurchaseDateStartStr());
|
|
|
purchaseDateStart = LocalDateTime.ofInstant(startDate.toInstant(), ZoneId.systemDefault());
|
|
|
} catch (ParseException e) {
|
|
|
return R.fail("购买开始日期格式错误,正确格式:yyyy-MM-dd HH:mm:ss,例如:2025-01-01 12:00:00");
|
|
|
@@ -146,9 +88,9 @@ public class ClaimSearchController {
|
|
|
}
|
|
|
|
|
|
// 转换结束日期
|
|
|
- if (StringUtils.isNotBlank(purchaseDateEndStr)) {
|
|
|
+ if (StringUtils.isNotBlank(claimSearchParam.getPurchaseDateEndStr())) {
|
|
|
try {
|
|
|
- Date endDate = sdf.parse(purchaseDateEndStr);
|
|
|
+ Date endDate = sdf.parse(claimSearchParam.getPurchaseDateEndStr());
|
|
|
purchaseDateEnd = LocalDateTime.ofInstant(endDate.toInstant(), ZoneId.systemDefault());
|
|
|
} catch (ParseException e) {
|
|
|
return R.fail("购买结束日期格式错误,正确格式:yyyy-MM-dd HH:mm:ss,例如:2025-01-01 12:00:00");
|
|
|
@@ -161,36 +103,50 @@ public class ClaimSearchController {
|
|
|
return R.fail("购买开始日期不能晚于结束日期");
|
|
|
}
|
|
|
// 金额范围校验
|
|
|
+ BigDecimal claimAmountMin = claimSearchParam.getClaimAmountMin();
|
|
|
+ BigDecimal claimAmountMax = claimSearchParam.getClaimAmountMax();
|
|
|
if (claimAmountMin != null && claimAmountMax != null && claimAmountMin.compareTo(claimAmountMax) > 0) {
|
|
|
return R.fail("索赔金额最小值不能大于最大值");
|
|
|
}
|
|
|
// 里程范围校验
|
|
|
+ Integer runMileageMin = claimSearchParam.getRunMileageMin();
|
|
|
+ Integer runMileageMax = claimSearchParam.getRunMileageMax();
|
|
|
if (runMileageMin != null && runMileageMax != null && runMileageMin > runMileageMax) {
|
|
|
return R.fail("行驶里程最小值不能大于最大值");
|
|
|
}
|
|
|
- // 枚举值校验(兼容JDK8-,替换List.of为Arrays.asList)
|
|
|
+ // 枚举值校验
|
|
|
+ Integer auditStatus = claimSearchParam.getAuditStatus();
|
|
|
if (auditStatus != null && !Arrays.asList(0, 1, 2, 3).contains(auditStatus)) {
|
|
|
return R.fail("审核状态值不合法,可选值:0-待审核 1-审核中 2-已通过 3-已拒绝");
|
|
|
}
|
|
|
+ Integer claimSourceType = claimSearchParam.getClaimSourceType();
|
|
|
if (claimSourceType != null && !Arrays.asList(1, 2, 3).contains(claimSourceType)) {
|
|
|
return R.fail("来源类型值不合法,可选值:1-经销商 2-门店 3-终端消费者");
|
|
|
}
|
|
|
+ Integer isSubmitTime = claimSearchParam.getIsSubmitTime();
|
|
|
if (isSubmitTime != null && !Arrays.asList(0, 1).contains(isSubmitTime)) {
|
|
|
return R.fail("是否已提交值不合法,可选值:0-未提交 1-已提交");
|
|
|
}
|
|
|
|
|
|
// ========== 5. 构建查询条件 ==========
|
|
|
LambdaQueryWrapper<PcBladeClaim> wrapper = new LambdaQueryWrapper<PcBladeClaim>()
|
|
|
- // 精准查询
|
|
|
- .eq(StringUtils.isNotBlank(claimNo), PcBladeClaim::getClaimNo, claimNo)
|
|
|
+ // 原有精准查询
|
|
|
+ .eq(StringUtils.isNotBlank(claimSearchParam.getClaimNo()), PcBladeClaim::getClaimNo, claimSearchParam.getClaimNo())
|
|
|
.eq(claimSourceType != null, PcBladeClaim::getClaimSourceType, claimSourceType)
|
|
|
.eq(auditStatus != null, PcBladeClaim::getAuditStatus, auditStatus)
|
|
|
.eq(isSubmitTime != null, PcBladeClaim::getIsSubmitTime, isSubmitTime)
|
|
|
- // 模糊查询(添加%通配符)
|
|
|
- .like(StringUtils.isNotBlank(consumerName), PcBladeClaim::getConsumerName, "%" + consumerName + "%")
|
|
|
- .like(StringUtils.isNotBlank(consumerPhone), PcBladeClaim::getConsumerPhone, "%" + consumerPhone + "%")
|
|
|
- .like(StringUtils.isNotBlank(tyreNo), PcBladeClaim::getTyreNo, "%" + tyreNo + "%")
|
|
|
- .like(StringUtils.isNotBlank(tyreSpecs), PcBladeClaim::getTyreSpecs, "%" + tyreSpecs + "%")
|
|
|
+ // 原有模糊查询
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getConsumerName()), PcBladeClaim::getConsumerName, "%" + claimSearchParam.getConsumerName() + "%")
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getConsumerPhone()), PcBladeClaim::getConsumerPhone, "%" + claimSearchParam.getConsumerPhone() + "%")
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getTyreNo()), PcBladeClaim::getTyreNo, "%" + claimSearchParam.getTyreNo() + "%")
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getTyreSpecs()), PcBladeClaim::getTyreSpecs, "%" + claimSearchParam.getTyreSpecs() + "%")
|
|
|
+ // 门店名称模糊查询(核心需求)
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getStoreName()), PcBladeClaim::getStoreName, "%" + claimSearchParam.getStoreName() + "%")
|
|
|
+ // 新增字段查询:模糊/精准适配
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getVehicleNumber()), PcBladeClaim::getVehicleNumber, "%" + claimSearchParam.getVehicleNumber() + "%") // 车牌号模糊
|
|
|
+ .eq(claimSearchParam.getTireQuantity() != null, PcBladeClaim::getTireQuantity, claimSearchParam.getTireQuantity()) // 轮胎数量精准
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getBrandItem()), PcBladeClaim::getBrandItem, "%" + claimSearchParam.getBrandItem() + "%") // 花纹模糊
|
|
|
+ .like(StringUtils.isNotBlank(claimSearchParam.getBrandName()), PcBladeClaim::getBrandName, "%" + claimSearchParam.getBrandName() + "%") // 品牌模糊
|
|
|
// 日期范围
|
|
|
.ge(purchaseDateStart != null, PcBladeClaim::getPurchaseDate, purchaseDateStart)
|
|
|
.le(purchaseDateEnd != null, PcBladeClaim::getPurchaseDate, purchaseDateEnd)
|
|
|
@@ -199,7 +155,7 @@ public class ClaimSearchController {
|
|
|
.le(claimAmountMax != null, PcBladeClaim::getClaimAmount, claimAmountMax)
|
|
|
.ge(runMileageMin != null, PcBladeClaim::getRunMileage, runMileageMin)
|
|
|
.le(runMileageMax != null, PcBladeClaim::getRunMileage, runMileageMax)
|
|
|
- // 数据权限(适配实体类BaseEntity的createUser字段)
|
|
|
+ // 数据权限
|
|
|
.eq(PcBladeClaim::getCreateUser, userId)
|
|
|
// 排序
|
|
|
.orderByDesc(PcBladeClaim::getSubmitTime)
|
|
|
@@ -210,8 +166,7 @@ public class ClaimSearchController {
|
|
|
page = pcBladeClaimService.page(page, wrapper);
|
|
|
List<PcBladeClaim> claimList = page.getRecords();
|
|
|
|
|
|
- if (org.springframework.util.CollectionUtils.isEmpty(claimList)) {
|
|
|
- // 返回空分页对象,保持结构统一
|
|
|
+ if (CollectionUtil.isEmpty(claimList)) {
|
|
|
IPage<ClaimSearchVO> emptyPage = new Page<>(pageNum, pageSize, 0);
|
|
|
return R.data(emptyPage);
|
|
|
}
|
|
|
@@ -240,9 +195,7 @@ public class ClaimSearchController {
|
|
|
for (PcBladeClaim claim : claimList) {
|
|
|
ClaimSearchVO vo = new ClaimSearchVO();
|
|
|
vo.setClaimMain(claim);
|
|
|
- // 关联附件(无则返回空列表)
|
|
|
vo.setAttachments(attachmentMap.getOrDefault(claim.getId(), new ArrayList<>()));
|
|
|
- // 关联审核记录
|
|
|
vo.setAuditRecords(auditMap.getOrDefault(claim.getId(), new ArrayList<>()));
|
|
|
resultVOList.add(vo);
|
|
|
}
|
|
|
@@ -260,13 +213,13 @@ public class ClaimSearchController {
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
return R.fail("参数错误:" + e.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
- // 生产环境建议添加日志记录
|
|
|
+ // 生产环境建议添加日志
|
|
|
// log.error("理赔综合查询异常", e);
|
|
|
return R.fail("查询失败,请稍后重试");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 补充:导入StringUtils工具类(避免空值判断报错)
|
|
|
+ // 工具类:空值判断
|
|
|
private static class StringUtils {
|
|
|
public static boolean isNotBlank(String str) {
|
|
|
return str != null && !str.trim().isEmpty();
|