chenxiaofei 1 ماه پیش
والد
کامیت
a28d4f5a30

+ 70 - 0
iot-platform-manager/src/main/java/com/platform/api/controller/KwsPrinterController.java

@@ -0,0 +1,70 @@
+package com.platform.api.controller;
+
+import com.platform.api.manager.KwsPrinterManageService;
+import com.platform.api.request.PrinterPageReqVo;
+import com.platform.api.request.PrinterSaveReqVo;
+import com.platform.api.request.PrinterStatusReqVo;
+import com.platform.result.HttpV1Result;
+import com.platform.result.HttpV1Status;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 打印机管理控制器。
+ */
+@RestController
+@RequestMapping("/kwsPrinter")
+@Tag(name = "打印机管理")
+@RequiredArgsConstructor
+public class KwsPrinterController {
+
+    private final KwsPrinterManageService kwsPrinterManageService;
+
+    @PostMapping("/page")
+    @Operation(summary = "打印机分页查询")
+    public HttpV1Result page(@RequestBody PrinterPageReqVo reqVo) {
+        return HttpV1Result.ok(kwsPrinterManageService.page(reqVo));
+    }
+
+    @GetMapping("/detail")
+    @Operation(summary = "打印机详情")
+    public HttpV1Result detail(@RequestParam Long id) {
+        return HttpV1Result.ok(kwsPrinterManageService.detail(id));
+    }
+
+    @PostMapping("/add")
+    @Operation(summary = "新增打印机")
+    public HttpV1Result add(@RequestBody PrinterSaveReqVo reqVo) {
+        kwsPrinterManageService.add(reqVo);
+        return HttpV1Result.ok(HttpV1Status.MSG_003);
+    }
+
+    @PostMapping("/update")
+    @Operation(summary = "编辑打印机")
+    public HttpV1Result update(@RequestBody PrinterSaveReqVo reqVo) {
+        kwsPrinterManageService.update(reqVo);
+        return HttpV1Result.ok(HttpV1Status.MSG_005);
+    }
+
+    @PostMapping("/updateStatus")
+    @Operation(summary = "启用停用打印机")
+    public HttpV1Result updateStatus(@RequestBody PrinterStatusReqVo reqVo) {
+        kwsPrinterManageService.updateStatus(reqVo);
+        return HttpV1Result.ok(HttpV1Status.MSG_005);
+    }
+
+//    @GetMapping("/enterpriseOptions")
+//    @Operation(summary = "企业模糊搜索")
+//    public HttpV1Result enterpriseOptions(@RequestParam(required = false) String keyword) {
+//        return HttpV1Result.ok(kwsPrinterManageService.enterpriseOptions(keyword));
+//    }
+
+//    @GetMapping("/optionsByEntId")
+//    @Operation(summary = "按企业查询打印机下拉")
+//    public HttpV1Result optionsByEntId(@RequestParam Long entId) {
+//        return HttpV1Result.ok(kwsPrinterManageService.optionByEntId(entId));
+//    }
+}

+ 381 - 0
iot-platform-manager/src/main/java/com/platform/api/manager/KwsPrinterManageService.java

@@ -0,0 +1,381 @@
+package com.platform.api.manager;
+
+import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import com.platform.api.request.PrinterPageReqVo;
+import com.platform.api.request.PrinterSaveReqVo;
+import com.platform.api.request.PrinterStatusReqVo;
+import com.platform.api.response.PlatformEnterpriseResVo;
+import com.platform.api.response.PrinterDetailResVo;
+import com.platform.api.response.PrinterPageResVo;
+import com.platform.entity.KwsPrinter;
+import com.platform.exception.IotException;
+import com.platform.result.HttpV1Status;
+import com.platform.result.PageResult;
+import com.platform.service.KwsPrinterRepository;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 打印机管理服务类
+ * 负责打印机的增删改查、状态管理以及与企业信息的关联处理
+ */
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class KwsPrinterManageService {
+
+    private final KwsPrinterRepository kwsPrinterRepository;
+   // private final KwsEnterpriseRepository kwsEnterpriseRepository;
+
+    /**
+     * 分页查询打印机列表
+     *
+     * @param reqVo 分页查询请求参数,包含页码、页大小、打印机名称模糊匹配、企业名称模糊匹配
+     * @return 分页结果集
+     */
+    public PageResult page(PrinterPageReqVo reqVo) {
+        log.info("分页查询打印机列表,参数:{}", JSON.toJSONString(reqVo));
+        // 根据企业名称解析出有权限查看的企业ID集合
+      //  Set<Long> entIds = resolveQueryEntIds(reqVo.getEnterpriseName());
+//        if (entIds.isEmpty()) {
+//            // 如果没有可查询的企业ID,直接返回空结果
+//            return PageResult.build(reqVo.getPageNum(), reqVo.getPageSize(), 0L, Collections.emptyList());
+//        }
+        // 执行数据库分页查询
+        IPage<KwsPrinter> page = kwsPrinterRepository.pageQuery(reqVo.getPageNum(), reqVo.getPageSize(),
+                reqVo.getPrinterName(), reqVo.getEntId());
+        // 构建返回结果,填充企业名称等额外信息
+        return PageResult.of(page, buildPageRes(page.getRecords()));
+    }
+
+    /**
+     * 获取打印机详情
+     *
+     * @param id 打印机ID
+     * @return 打印机详情响应对象
+     */
+    public PrinterDetailResVo detail(Long id) {
+        log.info("获取打印机详情,id:{}", id);
+        // 获取并校验打印机实体,同时检查权限
+        KwsPrinter printer = getAndCheck(id);
+        PrinterDetailResVo resVo = new PrinterDetailResVo();
+        // 填充基本信息及企业名称
+        fillBaseRes(printer, resVo);
+        return resVo;
+    }
+
+    /**
+     * 新增打印机
+     *
+     * @param reqVo 新增请求参数
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void add(PrinterSaveReqVo reqVo) {
+        log.info("新增打印机,参数:{}", JSON.toJSONString(reqVo));
+        // 校验请求参数合法性(非空、重复性、企业有效性等)
+        validateSaveReq(reqVo, null);
+        Date now = new Date();
+        // 构建打印机实体对象
+        KwsPrinter printer = new KwsPrinter()
+                .setEntId(reqVo.getEntId())
+                .setPrinterName(reqVo.getPrinterName())
+                .setPrinterType(reqVo.getPrinterType())
+                .setUsefulLife(reqVo.getUsefulLife())
+                .setOnlineStatus(defaultOnlineStatus(reqVo.getOnlineStatus()))
+                .setStatus(0) // 默认启用
+                .setDelFlag(0) // 未删除
+                .setCreateBy(reqVo.getUserId())
+                .setCreateTime(now)
+                .setUpdateBy(reqVo.getUserId())
+                .setUpdateTime(now);
+        // 保存至数据库,失败则抛出异常
+        if (!kwsPrinterRepository.save(printer)) {
+            throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.INSERT_FAIL);
+        }
+    }
+
+    /**
+     * 更新打印机信息
+     *
+     * @param reqVo 更新请求参数
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void update(PrinterSaveReqVo reqVo) {
+        log.info("更新打印机信息,参数:{}", JSON.toJSONString(reqVo));
+        if (reqVo.getId() == null) {
+            throw new IotException("打印机ID不能为空");
+        }
+        // 获取并校验原打印机数据及权限
+        KwsPrinter printer = getAndCheck(reqVo.getId());
+        // 校验更新参数的合法性
+        validateSaveReq(reqVo, printer.getId());
+        // 更新字段
+        printer.setEntId(reqVo.getEntId());
+        printer.setPrinterName(reqVo.getPrinterName());
+        printer.setPrinterType(reqVo.getPrinterType());
+        printer.setUsefulLife(reqVo.getUsefulLife());
+        printer.setOnlineStatus(defaultOnlineStatus(reqVo.getOnlineStatus()));
+        printer.setUpdateBy(reqVo.getUserId());
+        printer.setUpdateTime(new Date());
+        // 执行更新操作
+        if (!kwsPrinterRepository.updateById(printer)) {
+            throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.UPDATE_FAIL);
+        }
+    }
+
+    /**
+     * 更新打印机状态(启用/停用)
+     *
+     * @param reqVo 状态更新请求参数
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateStatus(PrinterStatusReqVo reqVo) {
+        log.info("更新打印机状态,参数:{}", JSON.toJSONString(reqVo));
+        if (reqVo.getId() == null) {
+            throw new IotException("打印机ID不能为空");
+        }
+        // 校验状态值是否合法(0:启用, 1:停用)
+        if (!Objects.equals(reqVo.getStatus(), 0) && !Objects.equals(reqVo.getStatus(), 1)) {
+            throw new IotException("打印机状态值非法");
+        }
+        // 获取并校验打印机及权限
+        KwsPrinter printer = getAndCheck(reqVo.getId());
+        printer.setStatus(reqVo.getStatus());
+        printer.setUpdateBy(reqVo.getUserId());
+        printer.setUpdateTime(new Date());
+        // 执行更新操作
+        if (!kwsPrinterRepository.updateById(printer)) {
+            throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.UPDATE_FAIL);
+        }
+    }
+
+    /**
+     * 获取企业下拉选项列表
+     * 根据用户权限返回可见的企业列表,支持名称模糊搜索
+     *
+     * @param keyword 企业名称关键字
+     * @return 企业选项列表
+     */
+//    public List<PlatformEnterpriseResVo> enterpriseOptions(String keyword) {
+//        log.info("获取企业下拉选项列表,参数:{}", keyword);
+//        // 获取当前用户有权限访问的企业ID集合
+//        Set<Long> authEntIds = resolveAuthorizedEntIds();
+//        List<KwsEnterprise> enterpriseList;
+//        if (LoginUserHolder.isManager()) {
+//            // 管理员可查看所有企业
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIdAndName(null, keyword);
+//        } else if (authEntIds.isEmpty()) {
+//            // 普通用户若无授权企业,返回空列表
+//            return Collections.emptyList();
+//        } else {
+//            // 普通用户仅查看授权范围内的企业
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIds(authEntIds, keyword);
+//        }
+//        // 转换为响应VO
+//        return enterpriseList.stream().map(item -> {
+//            PlatformEnterpriseResVo resVo = new PlatformEnterpriseResVo();
+//            resVo.setId(item.getId());
+//            resVo.setFirmName(item.getFirmName());
+//            return resVo;
+//        }).toList();
+//    }
+
+    /**
+     * 根据企业ID获取打印机下拉选项列表
+     *
+     * @param entId 企业ID
+     * @return 打印机选项列表
+     */
+//    public List<PrinterOptionResVo> optionByEntId(Long entId) {
+//        log.info("根据企业ID获取打印机下拉选项列表,参数:{}", entId);
+//        // 校验企业是否存在及当前用户是否有该企业权限
+//        checkEnterprise(entId);
+//        // 查询该企业下的所有打印机并转换为VO
+//        return kwsPrinterRepository.listByEntId(entId).stream().map(item -> {
+//            PrinterOptionResVo resVo = new PrinterOptionResVo();
+//            resVo.setId(item.getId());
+//            resVo.setPrinterName(item.getPrinterName());
+//            return resVo;
+//        }).toList();
+//    }
+
+    /**
+     * 构建分页响应数据列表
+     *
+     * @param records 数据库查询出的打印机实体列表
+     * @return 分页响应VO列表
+     */
+    private List<PrinterPageResVo> buildPageRes(List<KwsPrinter> records) {
+        if (records == null || records.isEmpty()) {
+            return Collections.emptyList();
+        }
+        // 批量获取企业名称映射,避免N+1查询问题
+        //Map<Long, String> entNameMap = enterpriseNameMap(records.stream().map(KwsPrinter::getEntId).collect(Collectors.toSet()));
+        List<PrinterPageResVo> result = new ArrayList<>(records.size());
+        for (KwsPrinter record : records) {
+            PrinterPageResVo resVo = new PrinterPageResVo();
+            fillBaseRes(record, resVo);
+            result.add(resVo);
+        }
+        return result;
+    }
+
+    /**
+     * 填充打印机基础响应信息
+     *
+     * @param record     打印机实体
+     * @param resVo      待填充的响应VO
+     */
+    private void fillBaseRes(KwsPrinter record, PrinterPageResVo resVo) {
+        resVo.setId(record.getId());
+        resVo.setEntId(record.getEntId());
+        resVo.setEnterpriseName(record.getEntName());
+        resVo.setPrinterName(record.getPrinterName());
+        resVo.setPrinterType(record.getPrinterType());
+        resVo.setUsefulLife(record.getUsefulLife());
+        resVo.setOnlineStatus(record.getOnlineStatus());
+        // 转换在线状态显示文本
+        resVo.setOnlineStatusName(Objects.equals(record.getOnlineStatus(), 1) ? "在线" : "离线");
+        resVo.setStatus(record.getStatus());
+        // 转换启用状态显示文本
+        resVo.setStatusName(Objects.equals(record.getStatus(), 0) ? "启用" : "停用");
+        resVo.setCreateTime(record.getCreateTime());
+        resVo.setUpdateTime(record.getUpdateTime());
+    }
+
+    /**
+     * 校验保存请求参数
+     *
+     * @param reqVo     请求参数
+     * @param excludeId 排除的ID(用于更新时排除自身)
+     */
+    private void validateSaveReq(PrinterSaveReqVo reqVo, Long excludeId) {
+        if (reqVo.getEntId() == null) {
+            throw new IotException("所属企业不能为空");
+        }
+        if (StringUtils.isBlank(reqVo.getPrinterName())) {
+            throw new IotException("打印机名称不能为空");
+        }
+        // 校验企业有效性及权限
+        //checkEnterprise(reqVo.getEntId());
+        // 检查同一企业下打印机名称是否重复
+        KwsPrinter exists = kwsPrinterRepository.findByEntIdAndName(reqVo.getEntId(), reqVo.getPrinterName().trim());
+        if (exists != null && !Objects.equals(exists.getId(), excludeId)) {
+            throw new IotException("同一企业下打印机名称不能重复");
+        }
+    }
+
+    /**
+     * 校验企业有效性及当前用户操作权限
+     *
+     * @param entId 企业ID
+     */
+//    private void checkEnterprise(Long entId) {
+//        // 判断是否有操作该企业的权限:管理员或授权企业列表中包含该企业
+//        boolean allowed = LoginUserHolder.isManager() || resolveAuthorizedEntIds().contains(entId);
+//        if (!allowed) {
+//            throw new IotException("没有当前企业的操作权限");
+//        }
+//        // 校验企业是否存在、未删除且状态正常
+//        KwsEnterprise enterprise = kwsEnterpriseRepository.getById(entId);
+//        if (enterprise == null || Objects.equals(enterprise.getDelFlag(), 1) || Objects.equals(enterprise.getStatus(), 1)) {
+//            throw new SystemException(HttpStatus.ENT_NOT_EXISTS);
+//        }
+//    }
+
+    /**
+     * 获取打印机实体并校验权限
+     *
+     * @param id 打印机ID
+     * @return 打印机实体
+     */
+    private KwsPrinter getAndCheck(Long id) {
+        // 查询可用的打印机记录
+        KwsPrinter printer = kwsPrinterRepository.findAvailableById(id);
+        if (printer == null) {
+            throw new IotException("打印机不存在");
+        }
+        // 非管理员需校验是否拥有该打印机所属企业的权限
+//        if (!LoginUserHolder.isManager() && !resolveAuthorizedEntIds().contains(printer.getEntId())) {
+//            throw new SystemException("没有当前打印机的操作权限");
+//        }
+        return printer;
+    }
+
+    /**
+     * 获取企业ID到企业名称的映射
+     *
+     * @param entIds 企业ID集合
+     * @return 映射Map
+     */
+//    private Map<Long, String> enterpriseNameMap(Collection<Long> entIds) {
+//        if (entIds == null || entIds.isEmpty()) {
+//            return Collections.emptyMap();
+//        }
+//        return kwsEnterpriseRepository.listByIds(entIds).stream()
+//                .collect(Collectors.toMap(KwsEnterprise::getId, KwsEnterprise::getFirmName, (a, b) -> a));
+//    }
+
+    /**
+     * 解析查询条件中的企业ID集合
+     * 根据用户权限和输入的企业名称关键字,筛选出符合条件的企业ID
+     *
+     * @param enterpriseName 企业名称关键字
+     * @return 企业ID集合
+     */
+//    private Set<Long> resolveQueryEntIds(String enterpriseName) {
+//        Set<Long> authEntIds = resolveAuthorizedEntIds();
+//        List<KwsEnterprise> enterpriseList;
+//        if (LoginUserHolder.isManager()) {
+//            // 管理员可根据名称全局搜索
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIdAndName(null, enterpriseName);
+//        } else if (authEntIds.isEmpty()) {
+//            // 无授权企业则返回空集合
+//            return Collections.emptySet();
+//        } else {
+//            // 普通用户在授权范围内根据名称搜索
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIds(authEntIds, enterpriseName);
+//        }
+//        // 提取ID并保持顺序
+//        return enterpriseList.stream().map(KwsEnterprise::getId).collect(Collectors.toCollection(LinkedHashSet::new));
+//    }
+
+    /**
+     * 解析当前用户有权限访问的企业ID集合
+     * 包括:用户所属企业、授权企业列表、子企业列表
+     * 如果是管理员,返回空集合表示无限制(具体逻辑视业务而定,此处空集合通常代表全选或特殊标记)
+     *
+     * @return 企业ID集合
+     */
+//    private Set<Long> resolveAuthorizedEntIds() {
+//        if (LoginUserHolder.isManager()) {
+//            return Collections.emptySet();
+//        }
+//        Set<Long> result = new LinkedHashSet<>();
+//        if (LoginUserHolder.getEntId() != null) {
+//            result.add(LoginUserHolder.getEntId());
+//        }
+//        result.addAll(LoginUserHolder.getAuthEntIdList());
+//        result.addAll(LoginUserHolder.getChildEntList());
+//        return result;
+//    }
+
+    /**
+     * 获取默认的在线状态
+     * 如果传入为1则在线,否则默认离线(0)
+     *
+     * @param onlineStatus 传入的在线状态
+     * @return 标准化后的在线状态
+     */
+    private Integer defaultOnlineStatus(Integer onlineStatus) {
+        return Objects.equals(onlineStatus, 1) ? 1 : 0;
+    }
+}

+ 36 - 0
iot-platform-manager/src/main/java/com/platform/api/request/PrinterPageReqVo.java

@@ -0,0 +1,36 @@
+package com.platform.api.request;
+
+
+import com.platform.request.PageRequest;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 打印机分页查询请求。
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "打印机分页查询请求")
+public class PrinterPageReqVo extends PageRequest implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 企业名称模糊关键字。
+     */
+    @Schema(description = "企业名称模糊关键字")
+    private String enterpriseName;
+
+    /**
+     * 打印机名称模糊关键字。
+     */
+    @Schema(description = "打印机名称模糊关键字")
+    private String printerName;
+    @Schema(description = "企业id")
+    private Long entId;
+}

+ 56 - 0
iot-platform-manager/src/main/java/com/platform/api/request/PrinterSaveReqVo.java

@@ -0,0 +1,56 @@
+package com.platform.api.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 打印机保存请求。
+ */
+@Data
+@Schema(description = "打印机保存请求")
+public class PrinterSaveReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID,编辑时必传。
+     */
+    @Schema(description = "主键ID,编辑时必传")
+    private Long id;
+
+    /**
+     * 企业ID。
+     */
+    @Schema(description = "企业ID")
+    private Long entId;
+
+    /**
+     * 打印机名称。
+     */
+    @Schema(description = "打印机名称")
+    private String printerName;
+
+    /**
+     * 打印机类型。
+     */
+    @Schema(description = "打印机类型")
+    private String printerType;
+
+    /**
+     * 可使用寿命。
+     */
+    @Schema(description = "可使用寿命")
+    private String usefulLife;
+
+    /**
+     * 在线状态,0-离线,1-在线。
+     */
+    @Schema(description = "在线状态,0-离线,1-在线")
+    private Integer onlineStatus;
+    @Schema(description = "用户ID")
+    private Long userId;
+}

+ 33 - 0
iot-platform-manager/src/main/java/com/platform/api/request/PrinterStatusReqVo.java

@@ -0,0 +1,33 @@
+package com.platform.api.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 打印机状态更新请求。
+ */
+@Data
+@Schema(description = "打印机状态更新请求")
+public class PrinterStatusReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 打印机ID。
+     */
+    @Schema(description = "打印机ID")
+    private Long id;
+
+    /**
+     * 启停状态,0-启用,1-停用。
+     */
+    @Schema(description = "启停状态,0-启用,1-停用")
+    private Integer status;
+
+    @Schema(description = "用户ID")
+    private Long userId;
+}

+ 19 - 0
iot-platform-manager/src/main/java/com/platform/api/response/PrinterDetailResVo.java

@@ -0,0 +1,19 @@
+package com.platform.api.response;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+/**
+ * 打印机详情响应。
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "打印机详情响应")
+public class PrinterDetailResVo extends PrinterPageResVo {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+}

+ 94 - 0
iot-platform-manager/src/main/java/com/platform/api/response/PrinterPageResVo.java

@@ -0,0 +1,94 @@
+package com.platform.api.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 打印机分页响应。
+ */
+@Data
+@Schema(description = "打印机分页响应")
+public class PrinterPageResVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID。
+     */
+    @Schema(description = "主键ID")
+    private Long id;
+
+    /**
+     * 企业ID。
+     */
+    @Schema(description = "企业ID")
+    private Long entId;
+
+    /**
+     * 企业名称。
+     */
+    @Schema(description = "企业名称")
+    private String enterpriseName;
+
+    /**
+     * 打印机名称。
+     */
+    @Schema(description = "打印机名称")
+    private String printerName;
+
+    /**
+     * 打印机类型。
+     */
+    @Schema(description = "打印机类型")
+    private String printerType;
+
+    /**
+     * 可使用寿命。
+     */
+    @Schema(description = "可使用寿命")
+    private String usefulLife;
+
+    /**
+     * 在线状态,0-离线,1-在线。
+     */
+    @Schema(description = "在线状态,0-离线,1-在线")
+    private Integer onlineStatus;
+
+    /**
+     * 在线状态名称。
+     */
+    @Schema(description = "在线状态名称")
+    private String onlineStatusName;
+
+    /**
+     * 启停状态,0-启用,1-停用。
+     */
+    @Schema(description = "启停状态,0-启用,1-停用")
+    private Integer status;
+
+    /**
+     * 启停状态名称。
+     */
+    @Schema(description = "启停状态名称")
+    private String statusName;
+
+    /**
+     * 创建时间。
+     */
+    @Schema(description = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 更新时间。
+     */
+    @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+}

+ 3 - 0
iot-platform-manager/src/main/java/com/platform/entity/KwsPrinter.java

@@ -29,6 +29,9 @@ public class KwsPrinter implements Serializable {
     @TableField("ent_id")
     private Long entId;
 
+    @TableField("ent_name")
+    private String entName;
+
     @TableField("printer_name")
     private String printerName;
 

+ 3 - 2
iot-platform-manager/src/main/java/com/platform/service/KwsPrinterRepository.java

@@ -11,15 +11,16 @@ import org.springframework.stereotype.Repository;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Objects;
 
 @Repository
 public class KwsPrinterRepository extends ServiceImpl<KwsPrinterDao, KwsPrinter> {
 
-    public IPage<KwsPrinter> pageQuery(int pageNum, int pageSize, String printerName, Collection<Long> entIds) {
+    public IPage<KwsPrinter> pageQuery(int pageNum, int pageSize, String printerName, Long entId) {
         return page(new Page<>(pageNum, pageSize), Wrappers.<KwsPrinter>lambdaQuery()
                 .eq(KwsPrinter::getDelFlag, 0)
                 .like(StringUtils.isNotBlank(printerName), KwsPrinter::getPrinterName, printerName)
-                .in(entIds != null && !entIds.isEmpty(), KwsPrinter::getEntId, entIds)
+                .eq(Objects.nonNull(entId), KwsPrinter::getEntId, entId)
                 .orderByDesc(KwsPrinter::getCreateTime)
                 .orderByDesc(KwsPrinter::getId));
     }