package com.shining.cloud.serviceImpl.AdminStatistic;

import com.shining.cloud.mapper.AdminStatistic.DataIntegrityMapper;
import com.shining.cloud.pojo.AdminStatistic.DataIntegrity;
import com.shining.cloud.pojo.AdminStatistic.Integrity;
import com.shining.cloud.service.AdminStatistic.DataIntegrityService;
import org.springframework.stereotype.Service;

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

/**
 * @description: DataIntegrityServiceImpl
 * @author: denghuajun
 * @time: 2020-01-02 10:05:11
 **/
@Service
public class DataIntegrityServiceImpl implements DataIntegrityService {

    @Resource
    DataIntegrityMapper dataIntegrityMapper;

    @Override
    public Integrity getIngrity(List<Integer> lineIndex) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.DAY_OF_MONTH,1);
        calendar.add(Calendar.MONTH,0);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
//将小时至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 dataIntegrityMapper.getIngrity(lineIndex,calendar.getTime(),new Date());
    }

    @Override
    public List<DataIntegrity> getDataIntegrity(List<Integer> lineIndex) {
        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 dataIntegrityMapper.getDataIntegrity(lineIndex,calendar.getTime(),new Date());
    }
}