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

import com.jiayue.ipfcst.common.data.entity.FakeDataRecord;
import com.jiayue.ipfcst.common.data.repository.FakeDataRecordRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * 生成假数据的记录的服务
 *
 * @author: xiuwei
 * @version:
 */
@Service
@Slf4j
public class FakeDataRecordService {

	@Autowired
	FakeDataRecordRepository fakeDataRecordRepository;


	public FakeDataRecord save(FakeDataRecord fakeDataRecord){
		return  fakeDataRecordRepository.save(fakeDataRecord);
	}


	/**
	 * 得到的统计结果  返回结果
	 * [{"不合理原因":"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<字段名,值>>}
	 */
	public List<Map<String,Object>> getStatisticalResults(Date startTime, Date endTime){
		return fakeDataRecordRepository.getStatisticalResults(startTime,endTime);
	};

}
