|
@@ -25,86 +25,64 @@ import java.util.List;
|
|
@Service
|
|
@Service
|
|
public class EquipmentAttributeService {
|
|
public class EquipmentAttributeService {
|
|
|
|
|
|
- /**
|
|
|
|
- * 操作仓库
|
|
|
|
- */
|
|
|
|
- @Autowired
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 操作仓库
|
|
|
|
+ */
|
|
|
|
+ @Autowired
|
|
EquipmentAttributeRepository equipmentAttributeRepository;
|
|
EquipmentAttributeRepository equipmentAttributeRepository;
|
|
- @Autowired
|
|
|
|
- ElectricFieldService electricFieldService;
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ ElectricFieldService electricFieldService;
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取某类设备的状态数据描述属性
|
|
|
|
- * 查询设备属性by设备类型
|
|
|
|
- *
|
|
|
|
- * @param dataObjectTypeEnum 设备类型
|
|
|
|
- * @return EquipmentAttribute 设备属性
|
|
|
|
- */
|
|
|
|
- public List<EquipmentAttribute> getByEquipmentType(EquipmentTypeEnum dataObjectTypeEnum) {
|
|
|
|
- EquipmentAttribute equipmentAttribute = new EquipmentAttribute();
|
|
|
|
- equipmentAttribute.setEquipmentType(dataObjectTypeEnum);
|
|
|
|
- return this.equipmentAttributeRepository.findAll(Example.of(equipmentAttribute));
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查找符合条件的设备属性
|
|
|
|
+ *
|
|
|
|
+ * @param equipmentAttribute 设备属性
|
|
|
|
+ * @return EquipmentAttribute 设备属性列表
|
|
|
|
+ */
|
|
|
|
+ public List<EquipmentAttribute> get(EquipmentAttribute equipmentAttribute) {
|
|
|
|
+ return this.equipmentAttributeRepository.findAll(Example.of(equipmentAttribute));
|
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
|
- * 查找符合条件的设备属性
|
|
|
|
- *
|
|
|
|
- * @param equipmentAttribute 设备属性
|
|
|
|
- * @return EquipmentAttribute 设备属性列表
|
|
|
|
- */
|
|
|
|
- public List<EquipmentAttribute> get(EquipmentAttribute equipmentAttribute) {
|
|
|
|
- return this.equipmentAttributeRepository.findAll(Example.of(equipmentAttribute));
|
|
|
|
- }
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查所有的设备属性
|
|
|
|
+ *
|
|
|
|
+ * @return EquipmentAttribute 设备属性列表
|
|
|
|
+ */
|
|
|
|
+ public List<EquipmentAttribute> getAll() {
|
|
|
|
+ return this.equipmentAttributeRepository.findAll();
|
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
|
- * 查所有的设备属性
|
|
|
|
- *
|
|
|
|
- * @return EquipmentAttribute 设备属性列表
|
|
|
|
- */
|
|
|
|
- public List<EquipmentAttribute> getAll() {
|
|
|
|
- return this.equipmentAttributeRepository.findAll();
|
|
|
|
- }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- */
|
|
|
|
- public Page getAllByPage(Integer page, Integer size) {
|
|
|
|
- Pageable pageable = PageRequest.of(page - 1, size);
|
|
|
|
- Page equipmentAttributePage = equipmentAttributeRepository.findAll(pageable);
|
|
|
|
- return equipmentAttributePage;
|
|
|
|
- }
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取某类设备的状态数据描述属性
|
|
|
|
+ * 查询设备属性by设备类型
|
|
|
|
+ * 分页
|
|
|
|
+ *
|
|
|
|
+ * @param equipmentType 设备类型
|
|
|
|
+ * @return EquipmentAttribute 设备属性
|
|
|
|
+ */
|
|
|
|
+ public Page<EquipmentAttribute> findByEquipmentType(String equipmentType, Integer page, Integer size) {
|
|
|
|
+ Pageable pageable = PageRequest.of(page - 1, size);
|
|
|
|
+ EquipmentTypeEnum equipmentTypeEnum = EquipmentTypeEnum.valueOf(equipmentType);
|
|
|
|
+ return equipmentAttributeRepository.findAllByEquipmentType(equipmentTypeEnum, pageable);
|
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取某类设备的状态数据描述属性
|
|
|
|
- * 查询设备属性by设备类型
|
|
|
|
- * 分页
|
|
|
|
- *
|
|
|
|
- * @param equipmentType 设备类型
|
|
|
|
- * @return EquipmentAttribute 设备属性
|
|
|
|
- */
|
|
|
|
- public Page<EquipmentAttribute> findByEquipmentType(String equipmentType, Integer page, Integer size) {
|
|
|
|
- Pageable pageable = PageRequest.of(page - 1, size);
|
|
|
|
- EquipmentTypeEnum equipmentTypeEnum = EquipmentTypeEnum.valueOf(equipmentType);
|
|
|
|
- Page<EquipmentAttribute> equipmentAttributePage = equipmentAttributeRepository.findAllByEquipmentType(equipmentTypeEnum, pageable);
|
|
|
|
- return equipmentAttributePage;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 删除
|
|
|
|
+ */
|
|
|
|
+ public void delete(Integer id) throws BusinessException {
|
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
|
+ throw new BusinessException("设备属性id不能为空!");
|
|
|
|
+ } else {
|
|
|
|
+ equipmentAttributeRepository.deleteById(id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
|
- * 删除
|
|
|
|
- * */
|
|
|
|
- public void delete(Integer id) throws BusinessException {
|
|
|
|
- if (StringUtils.isEmpty(id)) {
|
|
|
|
- throw new BusinessException("设备属性id不能为空!");
|
|
|
|
- } else {
|
|
|
|
- equipmentAttributeRepository.deleteById(id);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
- public void saveCloud(List<EquipmentAttribute> beans) {
|
|
|
|
- equipmentAttributeRepository.deleteAll();
|
|
|
|
- equipmentAttributeRepository.saveAll(beans);
|
|
|
|
- }
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
+ public void saveCloud(List<EquipmentAttribute> beans) {
|
|
|
|
+ equipmentAttributeRepository.deleteAll();
|
|
|
|
+ equipmentAttributeRepository.saveAll(beans);
|
|
|
|
+ }
|
|
}
|
|
}
|