ソースを参照

“车辆分页查询获取公共车辆”

yangjunfeng 1 年間 前
コミット
684aae936c

+ 21 - 1
snws-gps/snws-gps-boot/src/main/java/com/tofly/gpsboot/controller/car/CarBaseinfoController.java

@@ -4,10 +4,13 @@
  */
 package com.tofly.gpsboot.controller.car;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.tofly.api.DepartmentClient;
 import com.tofly.common.core.entity.ResultRespone;
 import com.tofly.gpsboot.service.car.CarBaseinfoService;
+import com.tofly.pojo.Department;
 import com.tofly.pojo.car.CarBaseinfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -16,6 +19,9 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * 车辆基本信息管理
  *
@@ -30,6 +36,8 @@ public class CarBaseinfoController {
 
     private final CarBaseinfoService carBaseinfoService;
 
+    private final DepartmentClient departmentClient;
+
     /**
     * 分页查询
     * @param page 分页对象
@@ -39,7 +47,19 @@ public class CarBaseinfoController {
     @GetMapping("/page" )
     @ApiOperation(value = "分页查询")
     public ResultRespone getCarBaseinfoPage(Page page, @ModelAttribute CarBaseinfo carBaseinfo) {
-      return ResultRespone.success(carBaseinfoService.page(page, Wrappers.query(carBaseinfo)));
+        Long deptId = carBaseinfo.getDepartmentId();
+        List<Long> deptIdList = null;
+        if (deptId != null) {
+            deptIdList = departmentClient.getDepartmentPage(deptId,"1").getResult()
+                    .stream().map(Department::getId).collect(Collectors.toList());
+        }
+        carBaseinfo.setDepartmentId(null);
+        List<String> commonCars = carBaseinfoService.getCommonCarInfo();
+        List<Long> finalDeptIdList = deptIdList;
+        return ResultRespone.success(carBaseinfoService.page(page, Wrappers.query(carBaseinfo).lambda()
+                .and(wrapper-> wrapper.in(CollUtil.isNotEmpty(finalDeptIdList), CarBaseinfo::getDepartmentId, finalDeptIdList)
+                .or()
+                .in(CarBaseinfo::getCarNumber, commonCars))));
     }