/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.sg.progress.service;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sg.progress.entity.PlanningStatistics;
import com.jeeplus.modules.sg.progress.entity.ShowStatistics;
import com.jeeplus.modules.sg.progress.entity.YearProgress;
import com.jeeplus.modules.sg.progress.mapper.YearProgressMapper;
import com.jeeplus.modules.test.treetable.dialog.entity.Car1;
import com.jeeplus.modules.test.treetable.dialog.mapper.Car1Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 车辆Service
 * @author lgf
 * @version 2018-06-12
 */
@Service
@Transactional(readOnly = true)
public class YearProgressService extends CrudService<YearProgressMapper, YearProgress> {

    @Autowired
    private YearProgressMapper yearProgressMapper;

    @Transactional(readOnly = false)
    public void replaceAll(List<YearProgress> yearProgressList) {
        for (YearProgress y:yearProgressList
             ) {
            y.preInsert();
        }
        yearProgressMapper.replaceAll(yearProgressList);
    }

    public List<String> findAllYear() {
        return yearProgressMapper.findAllYear();
    }

    public Page<PlanningStatistics> findStatisticPage(Page<PlanningStatistics> page, PlanningStatistics planningStatistics) {
        dataRuleFilter(planningStatistics);
        planningStatistics.setPage(page);
        page.setList(yearProgressMapper.findStatisticPage(planningStatistics));
        return page;
    }

    public List<PlanningStatistics> findYearStatistic() {
        return yearProgressMapper.findYearStatistic();
    }

    public List<ShowStatistics> showAllYear() {
        return yearProgressMapper.showAllYear();
    }

    public  List<PlanningStatistics> findStatisticPage(PlanningStatistics planningStatistics) {
        return yearProgressMapper.findStatisticPage(planningStatistics);
    }

    @Transactional(readOnly = false)
    public int update(YearProgress entity) {
        return yearProgressMapper.update(entity);
    }

    public YearProgress getByName(String name) {
        return yearProgressMapper.getByName(name);
    }
}