Browse Source

合同管理接口优化

fuyuchuan 3 days ago
parent
commit
8a608578c8

+ 7 - 1
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/controller/web/ContractController.java

@@ -112,6 +112,9 @@ public class ContractController {
      * templateId     模板ID
      * contractType   合同类型
      * customerId     客户ID
+     * customerName   客户名称 模糊匹配
+     * signDateStart  签订时间起始
+     * signDateEnd    签订时间截止
      * contractStatus 合同状态 0草稿 1审核中 2待生效 3已生效 4已驳回 5已到期 6已终止 7即将到期(三月内过期)
      * current        页码
      * size           页大小
@@ -124,11 +127,14 @@ public class ContractController {
             @RequestParam(value = "templateId", required = false) Long templateId,
             @RequestParam(value = "contractType", required = false) Integer contractType,
             @RequestParam(value = "customerId", required = false) Long customerId,
+            @RequestParam(value = "customerName", required = false) String customerName,
+            @RequestParam(value = "signDateStart", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate signDateStart,
+            @RequestParam(value = "signDateEnd", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate signDateEnd,
             @RequestParam(value = "contractStatus", required = false) Integer contractStatus,
             @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
             @RequestParam(value = "size", required = false, defaultValue = "20") Integer size) {
         return ApiResult.success(vppContractService.page(id, startDate, endDate,
-                templateId, contractType, customerId, contractStatus, current, size));
+                templateId, contractType, customerId, customerName, signDateStart, signDateEnd, contractStatus, current, size));
     }
 
     /**

+ 4 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/VppContractService.java

@@ -36,12 +36,16 @@ public interface VppContractService {
      * @param templateId     模板ID
      * @param contractType   合同类型
      * @param customerId     客户ID
+     * @param customerName   客户名称(模糊匹配)
+     * @param signDateStart  签订时间起始
+     * @param signDateEnd    签订时间截止
      * @param contractStatus 合同状态
      * @param pageNum        页码
      * @param pageSize       页大小
      */
     CommonPage<VppContractResponseVO> page(Long id, LocalDate signDateStart, LocalDate signDateEnd,
                                            Long templateId, Integer contractType, Long customerId,
+                                           String customerName, LocalDate signDateRangeStart, LocalDate signDateRangeEnd,
                                            Integer contractStatus, Integer pageNum, Integer pageSize);
 
     /**

+ 19 - 1
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppContractServiceImpl.java

@@ -163,17 +163,35 @@ public class VppContractServiceImpl implements VppContractService {
     @Override
     public CommonPage<VppContractResponseVO> page(Long id, LocalDate signDateStart, LocalDate signDateEnd,
                                                    Long templateId, Integer contractType, Long customerId,
+                                                   String customerName, LocalDate signDateRangeStart, LocalDate signDateRangeEnd,
                                                    Integer contractStatus, Integer pageNum, Integer pageSize) {
         IPage<VppContract> page = new Page<>(pageNum, pageSize);
 
+        // 客户名称模糊匹配:先反查符合条件的客户ID
+        List<Long> customerIdsByName = null;
+        if (StringUtils.isNotBlank(customerName)) {
+            LambdaQueryWrapper<VppCustomer> customerWrapper = new LambdaQueryWrapper<>();
+            customerWrapper.like(VppCustomer::getCustomerName, customerName)
+                    .eq(VppCustomer::getDeleteFlag, 0)
+                    .select(VppCustomer::getId);
+            List<VppCustomer> matchedCustomers = vppCustomerMapper.selectList(customerWrapper);
+            customerIdsByName = matchedCustomers.stream().map(VppCustomer::getId).collect(Collectors.toList());
+            if (customerIdsByName.isEmpty()) {
+                return new CommonPage<>(Collections.emptyList(), 0L, pageSize, pageNum);
+            }
+        }
+
         LambdaQueryWrapper<VppContract> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(VppContract::getDeleteFlag, 0)
                 .eq(id != null, VppContract::getId, id)
                 .ge(signDateStart != null, VppContract::getSignDate, signDateStart)
                 .le(signDateEnd != null, VppContract::getSignDate, signDateEnd)
+                .ge(signDateRangeStart != null, VppContract::getSignDate, signDateRangeStart)
+                .le(signDateRangeEnd != null, VppContract::getSignDate, signDateRangeEnd)
                 .eq(templateId != null, VppContract::getTemplateId, templateId)
                 .eq(contractType != null, VppContract::getContractType, contractType)
-                .eq(customerId != null, VppContract::getCustomerId, customerId);
+                .eq(customerId != null, VppContract::getCustomerId, customerId)
+                .in(customerIdsByName != null, VppContract::getCustomerId, customerIdsByName);
         VppContractStatusHelper.applyStatusFilter(queryWrapper, contractStatus);
         queryWrapper.orderByDesc(VppContract::getCreateTime);
         page = vppContractMapper.selectPage(page, queryWrapper);