Explorar o código

设备台账查询,添加commonParam及chargeName

lipenghui hai 1 mes
pai
achega
cc78bd1d52

+ 2 - 0
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java

@@ -33,4 +33,6 @@ public class PageParam implements Serializable {
     @Max(value = 100, message = "每页条数最大值为 100")
     private Integer pageSize = PAGE_SIZE;
 
+    @Schema(description = "通用查询参数")
+    private String commonParam;
 }

+ 17 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotDeviceController.java

@@ -187,6 +187,23 @@ public class IotDeviceController {
                 pageResult.getTotal()));
     }
 
+    @GetMapping("/page/app")
+    @Operation(summary = "获得app端设备台账分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
+    public CommonResult<PageResult<IotDeviceRespVO>> getAppIotDevicePage(@Valid IotDevicePageReqVO pageReqVO, @Valid SortablePageParam pageParam) {
+        if (Objects.nonNull(pageParam)&&CollUtil.isNotEmpty(pageParam.getSortingFields())) {
+            pageParam.getSortingFields().get(0).setField("sortColumn");
+        }
+        PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDevicePageApp(pageReqVO, pageParam);
+        if (CollUtil.isEmpty(pageResult.getList())) {
+            return success(new PageResult<>(pageResult.getTotal()));
+        }
+        Map<Long, DeptDO> deptMap = deptService.getDeptMap(
+                convertList(pageResult.getList(), IotDeviceDO::getDeptId));
+        return success(new PageResult<>(IotDeviceConvert.INSTANCE.convertList(pageResult.getList(), deptMap),
+                pageResult.getTotal()));
+    }
+
     @GetMapping({"/list-all-simple", "/simple-list"})
     @Operation(summary = "获取设备精简信息列表", description = "只包含被开启的设备,主要用于前端的下拉选项")
     public CommonResult<List<IotDeviceSimpleRespVO>> getSimpleDeviceList(@Valid IotDevicePageReqVO reqVO) {

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/IotDeviceDO.java

@@ -162,4 +162,5 @@ public class IotDeviceDO extends BaseDO {
     private Double lng;
     private Double lat;
     private String location;
+    private String chargeName;
 }

+ 13 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -8,7 +8,9 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorder.vo.IotMainW
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
@@ -59,6 +61,17 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
 //                .orderByAsc(IotDeviceDO::getSortColumn));
     }
 
+    default PageResult<IotDeviceDO> selectPageApp(IotDevicePageReqVO reqVO, Collection<Long> deptIds, SortablePageParam sortablePageParam) {
+        LambdaQueryWrapper<IotDeviceDO> wrapper = new LambdaQueryWrapper<>();
+        wrapper.like(StringUtils.isNotBlank(reqVO.getCommonParam()), IotDeviceDO::getDeviceName, reqVO.getCommonParam())
+                .or()
+                .like(StringUtils.isNotBlank(reqVO.getCommonParam()), IotDeviceDO::getDeviceCode, reqVO.getCommonParam())
+                .or()
+                .like(StringUtils.isNotBlank(reqVO.getCommonParam()), IotDeviceDO::getChargeName, reqVO.getCommonParam())
+                ;
+        return selectPage(sortablePageParam, wrapper);
+    }
+
     default List<IotDeviceDO> selectList(IotDevicePageReqVO reqVO) {
         return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
                 .inIfPresent(IotDeviceDO::getDeptId, reqVO.getDeviceIds())

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceService.java

@@ -60,6 +60,7 @@ public interface IotDeviceService {
      * @return 设备台账分页
      */
     PageResult<IotDeviceDO> getIotDevicePage(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam);
+    PageResult<IotDeviceDO> getIotDevicePageApp(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam);
     void updateSort();
     /**
      * 获得设备精简列表

+ 12 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -212,6 +212,18 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         return iotDeviceMapper.selectPage(pageReqVO,ids, sortablePageParam);
     }
 
+    @Override
+    public PageResult<IotDeviceDO> getIotDevicePageApp(IotDevicePageReqVO pageReqVO, SortablePageParam sortablePageParam) {
+        PageUtils.buildDefaultSortingField(sortablePageParam, IotDeviceDO::getSortColumn);
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(pageReqVO.getDeptId())) {
+            ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
+            ids.add(pageReqVO.getDeptId());
+        }
+
+        return iotDeviceMapper.selectPageApp(pageReqVO,ids, sortablePageParam);
+    }
+
     @Override
     public void updateSort() {
         List<IotDeviceDO> deviceDOS = iotDeviceMapper.selectList();