From bb9d5847bf783842f689dcf644be31de1ba6480f Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Sun, 9 Oct 2022 17:20:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=9A=E8=A5=BF=E6=B5=B7?= =?UTF-8?q?=E5=B2=B8=E7=94=B3=E8=B4=AD=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/monitor/entity/CameraChannel.java | 4 ++++ .../controller/ResourceCarController.java | 9 +++++++- .../resourceCar/dao/ResourceCarDao.java | 4 ++-- .../service/ResourceCarService.java | 2 +- .../service/impl/ResourceCarServiceImpl.java | 6 ++--- .../resources/db/V6.1__notice_add_col.sql | 3 +++ .../mapper/resourceCar/ResourceCarDao.xml | 23 +++++++++---------- 7 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 renren-admin/src/main/resources/db/V6.1__notice_add_col.sql diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/entity/CameraChannel.java b/renren-admin/src/main/java/io/renren/modules/monitor/entity/CameraChannel.java index 69fc6d7b..c08adee7 100644 --- a/renren-admin/src/main/java/io/renren/modules/monitor/entity/CameraChannel.java +++ b/renren-admin/src/main/java/io/renren/modules/monitor/entity/CameraChannel.java @@ -1,5 +1,6 @@ package io.renren.modules.monitor.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -29,4 +30,7 @@ public class CameraChannel { private String parentId; + @TableField(exist = false) + private String managementUnitName; + } diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java index d442b436..ea98c184 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java @@ -110,7 +110,14 @@ public class ResourceCarController { @ApiOperation("根据部门查询申购车资源列表") @LogOperation("根据部门查询申购车资源列表") public Result selectResourceListByDept(String name, @RequestParam Long deptId, @RequestParam Integer pageNum, @RequestParam Integer pageSize) { - return new Result().ok(resourceCarService.selectResourceListByDept(name, deptId, pageNum, pageSize)); + return new Result().ok(resourceCarService.selectResourceListByDept(name, deptId, null, pageNum, pageSize)); + } + + @GetMapping("/selectResourceListByDeptName") + @ApiOperation("根据部门名称查询申购车资源列表") + @LogOperation("根据部门名称查询申购车资源列表") + public Result selectResourceListByDeptName(String name, @RequestParam String deptName, @RequestParam Integer pageNum, @RequestParam Integer pageSize) { + return new Result().ok(resourceCarService.selectResourceListByDept(name, null, deptName, pageNum, pageSize)); } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java index 811c0237..4bef40d1 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java @@ -44,9 +44,9 @@ public interface ResourceCarDao extends BaseDao { @Param("pageSize") Integer pageSize, @Param("name") String name); - List selectInfrastructureListByDept(@Param("name") String name, + List selectInfrastructureListByDeptName(@Param("name") String name, @Param("userId") Long userId, - @Param("deptId") Long deptId, + @Param("deptName") String deptName, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java index e173ec02..0ade9a3c 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java @@ -26,5 +26,5 @@ public interface ResourceCarService extends CrudService maps = resourceCarDao.selectInfrastructureCarGroupByDept(userId, (pageNum - 1) * pageSize, pageSize, name); resultMap.put("list", maps); - resultMap.put("deptCount", maps.stream().collect(Collectors.groupingBy(it -> it.get("deptId"))).size()); + resultMap.put("deptCount", maps.stream().collect(Collectors.groupingBy(it->it.get("deptName"))).size()); } break; } @@ -127,7 +127,7 @@ public class ResourceCarServiceImpl extends CrudServiceImpl result = new ArrayList<>(); switch (Constant.ProjectPlace.getByFlag(projectPlace)) { @@ -136,7 +136,7 @@ public class ResourceCarServiceImpl extends CrudServiceImpl SELECT - dept.id AS "deptId", - dept.name AS "deptName", + IFNULL(dept.id, -1) AS "deptId", + car.dept_name AS "deptName", COUNT(car.id) AS "count" FROM - (select del_flag, user_id, json_extract(note1, '$[0].idtCameraChannel') as id, TRIM(BOTH '"' FROM - json_extract(note1, '$[0].managementUnitName')) as dept_name, json_extract(note1, '$[0].channelName') as name - from tb_resource_car where note1 IS NOT NULL) car, - sys_dept dept + (select del_flag, user_id, json_extract(note1, '$[0].idtCameraChannel') as id, TRIM(BOTH '"' FROM json_extract(note1, '$[0].managementUnitName')) as dept_name, json_extract(note1, '$[0].channelName') as name + from tb_resource_car where note1 IS NOT NULL) car + left join sys_dept dept on car.dept_name=dept.name WHERE car.user_id = #{userId} - AND car.dept_name=dept.name AND car.del_flag = 0 AND car.name LIKE CONCAT('%',#{name},'%') @@ -155,22 +153,23 @@ LIMIT ${pageNum}, ${pageSize} - SELECT car.id AS "id", car.resource_id AS "resourceId", car.name AS "resourceName", car.note1, - car.create_date AS "time" + car.create_date AS "time", + car.del_flag AS delFlag, + car.idtCameraChannel FROM - (select del_flag, user_id, note1, create_date, resource_id, json_extract(note1, '$[0].idtCameraChannel') as id, + (select del_flag, id, user_id, note1, create_date, resource_id, json_extract(note1, '$[0].idtCameraChannel') as idtCameraChannel, TRIM(BOTH '"' FROM json_extract(note1, '$[0].managementUnitName')) as dept_name, json_extract(note1, '$[0].channelName') as name from tb_resource_car where note1 IS NOT NULL) car - left join sys_dept dept on car.dept_name=dept.name WHERE 1 = 1 AND car.user_id = #{userId} - AND dept.id = #{deptId} + AND car.dept_name = #{deptName} AND car.del_flag = 0 AND car.name LIKE CONCAT('%',#{name},'%')