绑定设备

This commit is contained in:
Flow 2025-06-13 15:46:37 +08:00
parent b705a1ea2c
commit ccff7b4d04
11 changed files with 76 additions and 0 deletions

View File

@ -107,4 +107,11 @@ public class DeviceController {
return success(true);
}
@GetMapping("/getDeviceNotBind")
@Operation(summary = "获得未绑定的设备分页")
public CommonResult<PageResult<DeviceRespVO>> getDeviceNotBind(@Valid DevicePageReqVO pageReqVO) {
PageResult<DeviceDO> pageResult = deviceService.getDeviceNotBind(pageReqVO);
return success(BeanUtils.toBean(pageResult, DeviceRespVO.class));
}
}

View File

@ -98,4 +98,12 @@ public class DeviceuserController {
return success(BeanUtils.toBean(deviceusers, DeviceuserRespVO.class));
}
@GetMapping("/getDeviceuserByUserId")
@Operation(summary = "根据用户ID获得设备人员关联")
@Parameter(name = "userid", description = "用户编号", required = true)
public CommonResult<List<DeviceuserRespVO>> getDeviceuserByUserId(@RequestParam("userid") Integer userid) {
List<DeviceuserDO> deviceusers = deviceuserService.getDeviceuserByUserId(userid);
return success(BeanUtils.toBean(deviceusers, DeviceuserRespVO.class));
}
}

View File

@ -41,4 +41,7 @@ public class DeviceuserPageReqVO extends PageParam {
@Schema(description = "用户姓名", example = "张三")
private String username;
@Schema(description = "家庭组号", example = "16280")
private Integer familyid;
}

View File

@ -48,4 +48,8 @@ public class DeviceuserRespVO {
@ExcelProperty("用户姓名")
private String username;
@Schema(description = "家庭组号", example = "16280")
@ExcelProperty("家庭组号")
private Integer familyid;
}

View File

@ -41,4 +41,7 @@ public class DeviceuserSaveReqVO {
@Schema(description = "用户姓名", example = "张三")
private String username;
@Schema(description = "家庭组号", example = "16280")
private Integer familyid;
}

View File

@ -66,5 +66,10 @@ public class DeviceuserDO {
*/
@TableField("username")
private String username;
/**
* 家庭组号
*/
@TableField("familyid")
private Integer familyid;
}

View File

@ -36,4 +36,23 @@ public interface DeviceMapper extends BaseMapperX<DeviceDO> {
.orderByDesc(DeviceDO::getId));
}
default PageResult<DeviceDO> selectNotBindPage(DevicePageReqVO reqVO) {
LambdaQueryWrapperX<DeviceDO> wrapper = new LambdaQueryWrapperX<>();
wrapper.notExists("SELECT 1 FROM tb_deviceuser du WHERE du.deviceid = CAST(tb_device.devicecode AS SIGNED)");
wrapper.likeIfPresent(DeviceDO::getDevicename, reqVO.getDevicename());
wrapper.eqIfPresent(DeviceDO::getDevicecode, reqVO.getDevicecode());
wrapper.eqIfPresent(DeviceDO::getDevicetype, reqVO.getDevicetype());
wrapper.eqIfPresent(DeviceDO::getLocation, reqVO.getLocation());
wrapper.eqIfPresent(DeviceDO::getDevicestatus, reqVO.getDevicestatus());
wrapper.eqIfPresent(DeviceDO::getOrgid, reqVO.getOrgid());
wrapper.likeIfPresent(DeviceDO::getOrgname, reqVO.getOrgname());
wrapper.eqIfPresent(DeviceDO::getDescription, reqVO.getDescription());
wrapper.betweenIfPresent(DeviceDO::getCreatetime, reqVO.getCreatetime());
wrapper.betweenIfPresent(DeviceDO::getUpdatetime, reqVO.getUpdatetime());
wrapper.eqIfPresent(DeviceDO::getCreateby, reqVO.getCreateby());
wrapper.eqIfPresent(DeviceDO::getUpdateby, reqVO.getUpdateby());
wrapper.orderByDesc(DeviceDO::getId);
return selectPage(reqVO, wrapper);
}
}

View File

@ -68,4 +68,12 @@ public interface DeviceService {
*/
void updateDeviceStatus(Integer devicecode, Integer devicestatus);
/**
* 获得未绑定的设备分页
*
* @param pageReqVO 分页查询
* @return 设备分页
*/
PageResult<DeviceDO> getDeviceNotBind(DevicePageReqVO pageReqVO);
}

View File

@ -97,4 +97,9 @@ public class DeviceServiceImpl implements DeviceService {
deviceMapper.update(updateObj, wrapper);
}
@Override
public PageResult<DeviceDO> getDeviceNotBind(DevicePageReqVO pageReqVO) {
return deviceMapper.selectNotBindPage(pageReqVO);
}
}

View File

@ -64,4 +64,12 @@ public interface DeviceuserService {
*/
List<DeviceuserDO> getDeviceuserByDeviceId(Integer deviceid);
/**
* 根据用户ID获得设备人员关联列表
*
* @param userid 用户编号
* @return 设备人员关联列表
*/
List<DeviceuserDO> getDeviceuserByUserId(Integer userid);
}

View File

@ -80,4 +80,10 @@ public class DeviceuserServiceImpl implements DeviceuserService {
.eq(DeviceuserDO::getDeviceid, deviceid));
}
@Override
public List<DeviceuserDO> getDeviceuserByUserId(Integer userid) {
return deviceuserMapper.selectList(new LambdaQueryWrapper<DeviceuserDO>()
.eq(DeviceuserDO::getUserid, userid));
}
}