Commit c57cf10d0f7db6481ddec74210b93abbded78907
Merge remote-tracking branch 'origin/master' into dev
Showing
4 changed files
with
45 additions
and
10 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/deviceuser/DeviceUserController.java
| @@ -55,7 +55,7 @@ public class DeviceUserController { | @@ -55,7 +55,7 @@ public class DeviceUserController { | ||
| 55 | 55 | ||
| 56 | @GetMapping("/get/device_no") | 56 | @GetMapping("/get/device_no") |
| 57 | @Operation(summary = "通过设备编码获取设备绑定信息") | 57 | @Operation(summary = "通过设备编码获取设备绑定信息") |
| 58 | - public CommonResult<DeviceUserRespVO> getDeviceUserByDeviceNo(@RequestParam("device_no") @NotBlank String deviceNo) { | 58 | + public CommonResult<DeviceUserRespVO> getDeviceUserByDeviceNo(@RequestParam("deviceNo") @NotBlank String deviceNo) { |
| 59 | DeviceUserRespVO deviceUser = deviceUserService.getDeviceUserByDeviceNo(deviceNo); | 59 | DeviceUserRespVO deviceUser = deviceUserService.getDeviceUserByDeviceNo(deviceNo); |
| 60 | return success(deviceUser); | 60 | return success(deviceUser); |
| 61 | } | 61 | } |
| @@ -64,8 +64,8 @@ public class DeviceUserController { | @@ -64,8 +64,8 @@ public class DeviceUserController { | ||
| 64 | @Operation(summary = "删除设备用户关系") | 64 | @Operation(summary = "删除设备用户关系") |
| 65 | @Parameter(name = "id", description = "编号", required = true) | 65 | @Parameter(name = "id", description = "编号", required = true) |
| 66 | @PreAuthorize("@ss.hasPermission('garden:device-user:delete')") | 66 | @PreAuthorize("@ss.hasPermission('garden:device-user:delete')") |
| 67 | - public CommonResult<Boolean> deleteDeviceUser(@RequestParam("user_id") @NotNull Long userId, | ||
| 68 | - @RequestParam("device_no") @NotBlank String deviceNo) { | 67 | + public CommonResult<Boolean> deleteDeviceUser(@RequestParam("userId") @NotNull Long userId, |
| 68 | + @RequestParam("deviceNo") @NotBlank String deviceNo) { | ||
| 69 | deviceUserService.deleteDeviceUser(userId, deviceNo); | 69 | deviceUserService.deleteDeviceUser(userId, deviceNo); |
| 70 | return success(true); | 70 | return success(true); |
| 71 | } | 71 | } |
| @@ -92,8 +92,8 @@ public class DeviceUserController { | @@ -92,8 +92,8 @@ public class DeviceUserController { | ||
| 92 | @Operation(summary = "获得设备用户关系分页") | 92 | @Operation(summary = "获得设备用户关系分页") |
| 93 | //@PreAuthorize("@ss.hasPermission('garden:device-user:query')") | 93 | //@PreAuthorize("@ss.hasPermission('garden:device-user:query')") |
| 94 | public CommonResult<PageResult<DeviceUserRespVO>> getDeviceUserPage(@Valid DeviceUserPageReqVO pageReqVO) { | 94 | public CommonResult<PageResult<DeviceUserRespVO>> getDeviceUserPage(@Valid DeviceUserPageReqVO pageReqVO) { |
| 95 | - PageResult<DeviceUserDO> pageResult = deviceUserService.getDeviceUserPage(pageReqVO); | ||
| 96 | - return success(BeanUtils.toBean(pageResult, DeviceUserRespVO.class)); | 95 | + PageResult<DeviceUserRespVO> pageResult = deviceUserService.getDeviceUserPage(pageReqVO); |
| 96 | + return success(pageResult); | ||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | @GetMapping("/export-excel") | 99 | @GetMapping("/export-excel") |
| @@ -103,10 +103,10 @@ public class DeviceUserController { | @@ -103,10 +103,10 @@ public class DeviceUserController { | ||
| 103 | public void exportDeviceUserExcel(@Valid DeviceUserPageReqVO pageReqVO, | 103 | public void exportDeviceUserExcel(@Valid DeviceUserPageReqVO pageReqVO, |
| 104 | HttpServletResponse response) throws IOException { | 104 | HttpServletResponse response) throws IOException { |
| 105 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | 105 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 106 | - List<DeviceUserDO> list = deviceUserService.getDeviceUserPage(pageReqVO).getList(); | 106 | + List<DeviceUserRespVO> list = deviceUserService.getDeviceUserPage(pageReqVO).getList(); |
| 107 | // 导出 Excel | 107 | // 导出 Excel |
| 108 | ExcelUtils.write(response, "设备用户关系.xls", "数据", DeviceUserRespVO.class, | 108 | ExcelUtils.write(response, "设备用户关系.xls", "数据", DeviceUserRespVO.class, |
| 109 | - BeanUtils.toBean(list, DeviceUserRespVO.class)); | 109 | + list); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | @PostMapping("/findDeviceDeptTree") | 112 | @PostMapping("/findDeviceDeptTree") |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/deviceuser/vo/DeviceUserRespVO.java
| @@ -57,5 +57,12 @@ public class DeviceUserRespVO { | @@ -57,5 +57,12 @@ public class DeviceUserRespVO { | ||
| 57 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 57 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| 58 | private LocalDateTime createTime; | 58 | private LocalDateTime createTime; |
| 59 | 59 | ||
| 60 | + @Schema(description = "归属(一级部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "20800") | ||
| 61 | + @ExcelProperty("归属(一级部门id)") | ||
| 62 | + private String companyName; | ||
| 63 | + | ||
| 64 | + @ExcelProperty("部门(道路负责部门)") | ||
| 65 | + private String deptName; | ||
| 66 | + | ||
| 60 | 67 | ||
| 61 | } | 68 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/deviceuser/DeviceUserService.java
| @@ -56,7 +56,7 @@ public interface DeviceUserService { | @@ -56,7 +56,7 @@ public interface DeviceUserService { | ||
| 56 | * @param pageReqVO 分页查询 | 56 | * @param pageReqVO 分页查询 |
| 57 | * @return 设备用户关系分页 | 57 | * @return 设备用户关系分页 |
| 58 | */ | 58 | */ |
| 59 | - PageResult<DeviceUserDO> getDeviceUserPage(DeviceUserPageReqVO pageReqVO); | 59 | + PageResult<DeviceUserRespVO> getDeviceUserPage(DeviceUserPageReqVO pageReqVO); |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | /** | 62 | /** |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/deviceuser/DeviceUserServiceImpl.java
| @@ -6,8 +6,11 @@ import com.alibaba.fastjson.JSONObject; | @@ -6,8 +6,11 @@ import com.alibaba.fastjson.JSONObject; | ||
| 6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 7 | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 7 | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| 8 | import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; | 8 | import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; |
| 9 | +import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanRespVO; | ||
| 9 | import com.zteits.urbanops.module.garden.util.DeviceDeptTreeUtils; | 10 | import com.zteits.urbanops.module.garden.util.DeviceDeptTreeUtils; |
| 10 | import com.zteits.urbanops.module.garden.util.http.OkHttpClientUtil; | 11 | import com.zteits.urbanops.module.garden.util.http.OkHttpClientUtil; |
| 12 | +import com.zteits.urbanops.module.system.api.dept.DeptApi; | ||
| 13 | +import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; | ||
| 11 | import org.springframework.beans.factory.annotation.Value; | 14 | import org.springframework.beans.factory.annotation.Value; |
| 12 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 13 | import jakarta.annotation.Resource; | 16 | import jakarta.annotation.Resource; |
| @@ -41,6 +44,9 @@ public class DeviceUserServiceImpl implements DeviceUserService { | @@ -41,6 +44,9 @@ public class DeviceUserServiceImpl implements DeviceUserService { | ||
| 41 | @Resource | 44 | @Resource |
| 42 | private DeviceUserMapper deviceUserMapper; | 45 | private DeviceUserMapper deviceUserMapper; |
| 43 | 46 | ||
| 47 | + @Resource | ||
| 48 | + private DeptApi deptApi; | ||
| 49 | + | ||
| 44 | @Override | 50 | @Override |
| 45 | public Long createDeviceUser(DeviceUserSaveReqVO createReqVO) { | 51 | public Long createDeviceUser(DeviceUserSaveReqVO createReqVO) { |
| 46 | LocalDateTime now = LocalDateTime.now(); | 52 | LocalDateTime now = LocalDateTime.now(); |
| @@ -105,8 +111,30 @@ public class DeviceUserServiceImpl implements DeviceUserService { | @@ -105,8 +111,30 @@ public class DeviceUserServiceImpl implements DeviceUserService { | ||
| 105 | } | 111 | } |
| 106 | 112 | ||
| 107 | @Override | 113 | @Override |
| 108 | - public PageResult<DeviceUserDO> getDeviceUserPage(DeviceUserPageReqVO pageReqVO) { | ||
| 109 | - return deviceUserMapper.selectPage(pageReqVO); | 114 | + public PageResult<DeviceUserRespVO> getDeviceUserPage(DeviceUserPageReqVO pageReqVO) { |
| 115 | + PageResult<DeviceUserDO> pageResult = deviceUserMapper.selectPage(pageReqVO); | ||
| 116 | + PageResult<DeviceUserRespVO> pageResultVO = BeanUtils.toBean(pageResult, DeviceUserRespVO.class); | ||
| 117 | + if(CollectionUtil.isEmpty(pageResultVO.getList())){ | ||
| 118 | + return PageResult.empty(); | ||
| 119 | + } | ||
| 120 | + //公司 | ||
| 121 | + Set<Long> companyIds = pageResultVO.getList().stream().map(DeviceUserRespVO::getCompanyId).collect(Collectors.toSet()); | ||
| 122 | + //部门 | ||
| 123 | + Set<Long> deptIds = pageResultVO.getList().stream().map(DeviceUserRespVO::getDeptId).collect(Collectors.toSet()); | ||
| 124 | + deptIds.addAll(companyIds); | ||
| 125 | + /*1.获取部门*/ | ||
| 126 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(deptIds); | ||
| 127 | + pageResultVO.getList().forEach(deviceUserRespVO -> { | ||
| 128 | + DeptRespDTO deptRespDTO = deptMap.get(deviceUserRespVO.getDeptId()); | ||
| 129 | + if(deptRespDTO != null){ | ||
| 130 | + deviceUserRespVO.setDeptName(deptRespDTO.getName()); | ||
| 131 | + } | ||
| 132 | + DeptRespDTO company = deptMap.get(deviceUserRespVO.getCompanyId()); | ||
| 133 | + if(company != null){ | ||
| 134 | + deviceUserRespVO.setCompanyName(company.getName()); | ||
| 135 | + } | ||
| 136 | + }); | ||
| 137 | + return pageResultVO; | ||
| 110 | } | 138 | } |
| 111 | 139 | ||
| 112 | @Override | 140 | @Override |