package com.jiayue.ipfcst.common.data.repository;

import com.jiayue.ipfcst.common.data.entity.EquipmentAttribute;
import com.jiayue.ipfcst.common.data.entity.FakeDataRecord;
import com.jiayue.ipfcst.common.data.entity.InverterStatusData;
import org.joda.time.DateTime;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 生成假数据的记录的仓储
 *
 * @author 修唯
 * @version 1.0
 * @since 2019/8/6 13:00
 */
public interface FakeDataRecordRepository extends BaseRepository<FakeDataRecord, Integer> {


	/**
	 * 得到的统计结果  返回结果
	 * [{"不合理原因":"LowerMin","设备状态属性ID":1101,"统计个数":129,"设备ID":1}]
	 * [{"irrationalDataType":"LowerMin","equipmentAttributeId":1101,"count":129,"equipmentNo":1}]
	 * @param startTime 开始时间
	 * @param endTime   结束时间
	 * @return {@link List<Map<String, Object>>   List<Map<字段名,值>>}
	 */
	@Query(value="select C_EQUIPMENT_ATTRIBUTE_ID as equipmentAttributeId ,C_IRRATIONAL_DATA_TYPE as irrationalDataType,C_EQUIPMENT_NO as equipmentNo,count(C_ID) as count  from t_fake_data_record where  C_TIME>?1 and C_TIME<?2  GROUP BY C_EQUIPMENT_ATTRIBUTE_ID,C_IRRATIONAL_DATA_TYPE,C_EQUIPMENT_NO", nativeQuery=true)
	List<Map<String,Object>> getStatisticalResults(Date startTime, Date endTime);





}
