ard-sample/src/main/java/com/ard/sample/manage/service/impl/DeviceServiceImpl.java
@@ -26,7 +26,7 @@
import com.ard.sample.manage.model.param.DeviceQueryParam;
import com.ard.sample.manage.model.receiver.*;
import com.ard.sample.manage.service.*;
import com.ard.system.service.system.ISysDeptService;
import com.ard.system.service.ISysDeptService;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -636,6 +636,7 @@
                .nickname(entity.getNickname())
                .firmwareVersion(entity.getFirmwareVersion())
                .deptId(entity.getDeptId())
                .workType(entity.getWorkType())
                .workspaceName(entity.getDeptId() != null
                        ? Optional.ofNullable(sysDeptService.selectDeptById(entity.getDeptId()))
                        .map(SysDept::getDeptName)
@@ -671,6 +672,19 @@
    public Boolean updateDevice(DeviceDTO deviceDTO) {
        int update = mapper.update(this.deviceDTO2Entity(deviceDTO),
                new LambdaUpdateWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn, deviceDTO.getDeviceSn()));
        return update > 0;
    }
    @Override
    public Boolean updateWorkType(String sn, Long workType) {
        // 方式1:使用LambdaUpdateWrapper(推荐,类型安全,避免字段名硬编码)
        LambdaUpdateWrapper<DeviceEntity> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        // 设置更新条件:deviceSn = 100
        lambdaUpdateWrapper.eq(DeviceEntity::getDeviceSn, sn)
                // 只更新status字段为"online"
                .set(DeviceEntity::getWorkType, workType);
        // 执行更新(第一个参数传null,因为更新字段已通过wrapper的set指定)
        int update = mapper.update(null, lambdaUpdateWrapper);
        return update > 0;
    }
@@ -809,7 +823,8 @@
        Page<DeviceEntity> pagination = mapper.selectPage(new Page<>(page, pageSize),
                new LambdaQueryWrapper<DeviceEntity>()
                        .eq(DeviceEntity::getDomain, domain)
                        .eq(DeviceEntity::getBoundStatus, true));
                        .isNotNull(DeviceEntity::getDeptId));
//                        .eq(DeviceEntity::getBoundStatus, true));
        List<DeviceDTO> devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO)
                .peek(device -> {
                    device.setStatus(RedisOpsUtils.checkExist(RedisConst.DEVICE_ONLINE_PREFIX + device.getDeviceSn()));
@@ -835,6 +850,7 @@
        DeviceDTO device = DeviceDTO.builder()
                .deviceSn(deviceSn)
                .boundStatus(false)
                .deptId(null)
                .build();
        this.updateDevice(device);
    }
@@ -1009,6 +1025,7 @@
                .childSn(dto.getChildDeviceSn())
                .domain(dto.getDomain())
                .firmwareVersion(dto.getFirmwareVersion())
                .workType(dto.getWorkType())
                .compatibleStatus(dto.getFirmwareStatus() == null ? null :
                        DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != DeviceFirmwareStatusEnum.find(dto.getFirmwareStatus()))
                .build();