Compare commits
2 Commits
76c11fff15
...
00a4394b43
| Author | SHA1 | Date | |
|---|---|---|---|
| 00a4394b43 | |||
| 2376a3b42a |
@ -137,4 +137,13 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
List<DeviceUsageFrequencyVo> getDeviceUsageFrequency(@Param("days") int days);
|
List<DeviceUsageFrequencyVo> getDeviceUsageFrequency(@Param("days") int days);
|
||||||
|
|
||||||
List<OnlineStatusVo> queryOnlineStatusList();
|
List<OnlineStatusVo> queryOnlineStatusList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备类型ID查询设备数量
|
||||||
|
*
|
||||||
|
* @param deviceTypeId 设备类型ID
|
||||||
|
* @return 设备数量
|
||||||
|
*/
|
||||||
|
int countByDeviceTypeId(@Param("deviceTypeId") Long deviceTypeId);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -192,10 +192,21 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
throw new BadRequestException("设备IMEI已存在!!!");
|
throw new BadRequestException("设备IMEI已存在!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceTypeGrants typeGrants = new DeviceTypeGrants();
|
||||||
|
|
||||||
|
if (deviceForm.getDeviceType() != null) {
|
||||||
|
DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria();
|
||||||
|
queryCriteria.setDeviceTypeId(deviceForm.getDeviceType());
|
||||||
|
typeGrants = deviceTypeGrantsMapper.selectById(queryCriteria.getDeviceTypeId());
|
||||||
|
if (typeGrants == null) {
|
||||||
|
throw new Exception("设备类型不存在!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 检查设备类型是否存在,如果不存在则创建
|
// 检查设备类型是否存在,如果不存在则创建
|
||||||
DeviceType deviceType = null;
|
DeviceType deviceType = null;
|
||||||
if (deviceForm.getDeviceType() != null) {
|
if (deviceForm.getDeviceType() != null) {
|
||||||
deviceType = deviceTypeMapper.selectById(deviceForm.getDeviceType());
|
deviceType = deviceTypeMapper.selectById(typeGrants.getDeviceTypeId());
|
||||||
} else if (deviceForm.getTypeName() != null) {
|
} else if (deviceForm.getTypeName() != null) {
|
||||||
deviceType = deviceTypeMapper.selectOne(new QueryWrapper<DeviceType>().eq("type_name", deviceForm.getTypeName()));
|
deviceType = deviceTypeMapper.selectOne(new QueryWrapper<DeviceType>().eq("type_name", deviceForm.getTypeName()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -224,6 +224,16 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
throw new RuntimeException("设备类型不存在");
|
throw new RuntimeException("设备类型不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!deviceType.getTypeName().equals(resources.getTypeName())) {
|
||||||
|
int count = deviceMapper.countByDeviceTypeId(deviceType.getId());
|
||||||
|
if (count > 0) {
|
||||||
|
throw new RuntimeException("该设备类型下已有绑定设备,无法修改设备类型名称!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
// List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
||||||
// .eq("device_type", deviceTypeGrants.getDeviceTypeId()));
|
// .eq("device_type", deviceTypeGrants.getDeviceTypeId()));
|
||||||
// if (CollectionUtil.isNotEmpty(devices)) {
|
// if (CollectionUtil.isNotEmpty(devices)) {
|
||||||
|
|||||||
@ -497,4 +497,11 @@
|
|||||||
FROM device a left join device_type b on a.device_type = b.id where b.communication_mode in (0, 2) and a.online_status in (1,2)
|
FROM device a left join device_type b on a.device_type = b.id where b.communication_mode in (0, 2) and a.online_status in (1,2)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据设备类型ID查询设备数量 -->
|
||||||
|
<select id="countByDeviceTypeId" resultType="int">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM device
|
||||||
|
WHERE device_type = #{deviceTypeId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user