package com.jiayue.ipfcst.service;

import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
import com.jiayue.ipfcst.common.data.entity.EquipmentAttribute;
import com.jiayue.ipfcst.common.data.service.BaseService;
import com.jiayue.ipfcst.repository.EquipmentAttributeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 接入数据属性获取业务层
 *
 * @author yh
 * @version 1.0
 * @since 2019/8/5 16:02
 */
@Service
public class EquipmentAttributeService extends BaseService {

  private final EquipmentAttributeRepository equipmentAttributeRepository;

  @Autowired
  public EquipmentAttributeService(EquipmentAttributeRepository equipmentAttributeRepository) {
    this.equipmentAttributeRepository = equipmentAttributeRepository;
  }


  public Map<String, String> findByEquipmentTypeforWINDTOWER() {
    Map<String, String> map = new HashMap<>();
    List<EquipmentAttribute> es = equipmentAttributeRepository.findByEquipmentType(EquipmentTypeEnum.WINDTOWER);
    for (EquipmentAttribute e : es) {
      map.put(e.getFieldName(), e.getExplanation() + "(" + e.getMeasurementUnits() + ")");
    }
    return map;
  }


}
