|
@@ -103,7 +103,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
@Override
|
|
@Override
|
|
|
public boolean saveWithCheck(EquipmentBase entity) {
|
|
public boolean saveWithCheck(EquipmentBase entity) {
|
|
|
String equipmentTypeId = entity.getEquipmentTypeId();
|
|
String equipmentTypeId = entity.getEquipmentTypeId();
|
|
|
- EquipmentType equipmentType = getEquipmentTypeById(equipmentTypeId);
|
|
|
|
|
|
|
+ EquipmentType equipmentType = getEquipmentTypeByTypeId(equipmentTypeId);
|
|
|
if (equipmentType == null) {
|
|
if (equipmentType == null) {
|
|
|
throw new ServiceException("设备类型不存在,请检查equipment_type_id:" + equipmentTypeId);
|
|
throw new ServiceException("设备类型不存在,请检查equipment_type_id:" + equipmentTypeId);
|
|
|
}
|
|
}
|
|
@@ -135,7 +135,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (EquipmentBase entity : entityList) {
|
|
for (EquipmentBase entity : entityList) {
|
|
|
- if (getEquipmentTypeById(entity.getEquipmentTypeId()) == null) {
|
|
|
|
|
|
|
+ if (getEquipmentTypeByTypeId(entity.getEquipmentTypeId()) == null) {
|
|
|
throw new ServiceException("设备类型不存在:" + entity.getEquipmentTypeId());
|
|
throw new ServiceException("设备类型不存在:" + entity.getEquipmentTypeId());
|
|
|
}
|
|
}
|
|
|
LambdaQueryWrapper<EquipmentBase> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<EquipmentBase> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -834,7 +834,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
result.put("equipmentInfo", equipment);
|
|
result.put("equipmentInfo", equipment);
|
|
|
|
|
|
|
|
if (equipment.getEquipmentTypeId() != null) {
|
|
if (equipment.getEquipmentTypeId() != null) {
|
|
|
- EquipmentType type = getEquipmentTypeById(equipment.getEquipmentTypeId());
|
|
|
|
|
|
|
+ EquipmentType type = getEquipmentTypeByTypeId(equipment.getEquipmentTypeId());
|
|
|
result.put("typeInfo", type);
|
|
result.put("typeInfo", type);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1081,7 +1081,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 无子类别:直接统计该类别的设备数量
|
|
// 无子类别:直接统计该类别的设备数量
|
|
|
- EquipmentType equipmentType = getEquipmentTypeById(equipmentTypeId);
|
|
|
|
|
|
|
+ EquipmentType equipmentType = getEquipmentTypeByTypeId(equipmentTypeId);
|
|
|
long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
|
|
long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
|
|
|
.eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId));
|
|
.eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId));
|
|
|
EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
|
|
EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
|
|
@@ -1168,21 +1168,6 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
return CollUtil.isNotEmpty(list) ? list.get(0) : null;
|
|
return CollUtil.isNotEmpty(list) ? list.get(0) : null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据 id 查询设备类型(按数据库主键id查询)
|
|
|
|
|
- * @return 找到的第一条记录,或 null
|
|
|
|
|
- */
|
|
|
|
|
- private EquipmentType getEquipmentTypeById(String id) {
|
|
|
|
|
- if (id == null || id.isEmpty()) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
- LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.eq(EquipmentType::getId, id);
|
|
|
|
|
- wrapper.last("LIMIT 1");
|
|
|
|
|
- List<EquipmentType> list = equipmentTypeMapper.selectList(wrapper);
|
|
|
|
|
- return CollUtil.isNotEmpty(list) ? list.get(0) : null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<EquipmentBase> findByTopLevelType(String typeName) {
|
|
public List<EquipmentBase> findByTopLevelType(String typeName) {
|
|
|
EquipmentType topType = equipmentTypeMapper.selectOne(
|
|
EquipmentType topType = equipmentTypeMapper.selectOne(
|