package com.pqs9900.serviceImpl.State;

import com.pqs9900.mapper.State.MonthYearDayFlowMapper;
import com.pqs9900.pojo.State.MonthYearDayFlow;
import com.pqs9900.service.State.MonthYearDayFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

@Service
public class MonthYearDayFlowServiceImpl implements MonthYearDayFlowService{
    @Autowired
    private MonthYearDayFlowMapper monthYearDayFlowMapper;
    @Override
    public List<MonthYearDayFlow> dayByMonth(Long devIndex, String startTime) {
        List<MonthYearDayFlow> monthYearDayFlows = new ArrayList<>();
        try {
            //将时间转化为年月的形式，获取当前年月
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm");
            String format = sdf.format(startTime);
            monthYearDayFlows =monthYearDayFlowMapper.dayByMonth(devIndex,format);
        }catch (Exception e){
            return monthYearDayFlows;
        }
        return monthYearDayFlows;
    }
}
