package com.yuchen.saas.park.service.fault.service.impl;

import cn.hutool.core.date.DateUtil;
import com.yuchen.saas.park.api.entity.fault.EquipmentBreakdownHistory;
import com.yuchen.saas.park.service.fault.mapper.EquipmentBreakdownHistoryMapper;
import com.yuchen.saas.park.service.fault.service.EquipmentBreakdownHistoryService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/10/18 15:40
 * @Description: 设备故障历史
 * @Version: 1.0
 */
@Service
public class EquipmentBreakdownHistoryServiceImpl extends BaseServiceImpl<EquipmentBreakdownHistoryMapper, EquipmentBreakdownHistory> implements EquipmentBreakdownHistoryService {

    @Resource
    private EquipmentBreakdownHistoryMapper historyMapper;

    /**
     * 根据园区id,状态id,统计指定时间内的全部设备发生的故障次数
     *
     * @param parkId    园区id
     * @param startTime 统计开始时间
     * @param endTime   统计结束时间
     * @return
     */
    public List<Map<String, Object>> deviceBreakdownNum(Long parkId, Date startTime, Date endTime) {
        String formatStartTime = DateUtil.formatDateTime(startTime);
        String formatEndTime = DateUtil.formatDateTime(endTime);
        List<Map<String, Object>> integers = historyMapper.deviceBreakdownNum(parkId, formatStartTime, formatEndTime);
        return integers;
    }
}