/*
 * Copyright (c) 京北方信息技术股份有限公司 Corporation 2021 . All rights reserved.
 *
 */
package net.northking.cctp.dw.db.impl;

import net.northking.cctp.common.db.BasicDao;
import net.northking.cctp.common.db.PaginationService;
import net.northking.cctp.dw.db.dao.MtTestChartDao;
import net.northking.cctp.dw.db.entity.MidProjectInfo;
import net.northking.cctp.dw.db.entity.MtTestChart;
import net.northking.cctp.dw.db.service.MtTestChartService;
import net.northking.cctp.dw.dto.ChartProgressQueryDto;
import net.northking.cctp.dw.dto.MtTestChartDto;
import net.northking.cctp.dw.dto.ProjectDataVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.util.*;


/**
 * 需求分析进度图表
 *
 * <p>文件内容由代码生成器产生，请不要手动修改！ <br>
 * createdate:  2021-12-15 15:38:09  <br>
 *
 * @author: maven-cctp-plugin  <br>
 * @since: 1.0 <br>
 */
@Service
@ConditionalOnMissingBean(name = "MtTestChartServiceImpl")
public class MtTestChartServiceImpl extends PaginationService<MtTestChart> implements MtTestChartService {
    private static final Logger logger = LoggerFactory.getLogger(MtTestChartServiceImpl.class);

    private final MtTestChartDao mtTestChartDao;

    public MtTestChartServiceImpl(MtTestChartDao mtTestChartDao) {
        this.mtTestChartDao = mtTestChartDao;
    }

    public BasicDao<MtTestChart> getDao() {
        return mtTestChartDao;
    }

    public MtTestChart createEntity() {
        return new MtTestChart();
    }

    @Override
    protected void beforeInsert(MtTestChart mtTestChart) {

    }

    @Override
    protected void beforeUpdate(MtTestChart mtTestChart) {

    }

    @Override
    public List<MtTestChartDto> queryChartProgress(ChartProgressQueryDto queryDto) {
        return mtTestChartDao.queryChartProgress(queryDto);
    }

    @Override
    public List<MtTestChart> createOverallTestReportProgress() {
        return mtTestChartDao.createOverallTestReportProgress();
    }

    @Override
    public List<MtTestChart> queryToday(List<MidProjectInfo> midProjectInfos) {
        return mtTestChartDao.queryToday(midProjectInfos);
    }

    @Override
    public void deleteProgress(String tenantId) {
        mtTestChartDao.deleteProgress(tenantId);
    }

    @Override
    public List<MtTestChart> findMaxDateGroupByProId(Integer testType) {
        return mtTestChartDao.findMaxDateGroupByProId(testType);
    }

    @Override
    public Integer queryTodayDeleted(List<MidProjectInfo> dataList) {
        return mtTestChartDao.queryTodayDeleted(dataList);
    }

    @Override
    public List<MtTestChart> getPercentActualAmountByProjectId(String projectId) {
        MtTestChart m=new MtTestChart();
        m.setTestType(4);
        m.setProjectId(projectId);
        List<MtTestChart> query = query(m);
        if (null==query||query.size()==0)return new ArrayList<>();
        for (MtTestChart mtTestChart:query){
            mtTestChart.setProjectId(null);
            mtTestChart.setTotalActual(null);
            mtTestChart.setTotalPlan(null);
            mtTestChart.setTestType(null);
            mtTestChart.setId(null);
            mtTestChart.setTenantId(null);
            mtTestChart.setPercentPlan(null);
        }
        return query;
    }

    @Override
    public List<ProjectDataVo> getProjectIds(String tenantId) {
        return mtTestChartDao.getProjectIds(tenantId);
    }
}

