package com.shining.cloud.serviceImpl.AdminStatistic;

import com.shining.cloud.mapper.AdminStatistic.StaticMapper;
import com.shining.cloud.pojo.AdminStatistic.DevStatic;
import com.shining.cloud.pojo.AdminStatistic.StaticInfo;
import com.shining.cloud.service.AdminStatistic.StaticService;
import org.springframework.stereotype.Service;

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

/**
 * @description: StaticServiceImpl
 * @author: denghuajun
 * @time: 2020-01-02 10:07:27
 **/
@Service
public class StaticServiceImpl implements StaticService {
    @Resource
    StaticMapper staticMapper;
    @Override
    public StaticInfo getStatic(List<Integer> devIndex) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.DAY_OF_MONTH,1);
        calendar.add(Calendar.MONTH,0);
        //将小时至0
        calendar.set(Calendar.HOUR_OF_DAY, 0);
//将分钟至0
        calendar.set(Calendar.MINUTE, 0);
//将秒至0
        calendar.set(Calendar.SECOND,0);
//将毫秒至0
        calendar.set(Calendar.MILLISECOND, 0);
        StaticInfo staticInfo = new StaticInfo();
        staticInfo = staticMapper.getStatic(devIndex,calendar.getTime(),new Date());
        staticInfo.setComError(staticMapper.getComError(devIndex));
        return staticInfo;
    }

    @Override
    public List<DevStatic> getDevStatic(List<Integer> devIndex) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.DAY_OF_MONTH,1);
        calendar.add(Calendar.MONTH,0);
        //将小时至0
        calendar.set(Calendar.HOUR_OF_DAY, 0);
//将分钟至0
        calendar.set(Calendar.MINUTE, 0);
//将秒至0
        calendar.set(Calendar.SECOND,0);
//将毫秒至0
        calendar.set(Calendar.MILLISECOND, 0);
        return staticMapper.getDevStatic(devIndex,calendar.getTime(),new Date());
    }
}