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

import java.util.ArrayList;
import java.util.List;

import com.jeeplus.modules.deductiondetails.entity.DynamicHeader;
import com.jeeplus.modules.deductiondetails.entity.EvaluationSummary;
import com.jeeplus.modules.deductiondetails.entity.SelectClass;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.deductiondetails.entity.DeductionDetails;
import com.jeeplus.modules.deductiondetails.mapper.DeductionDetailsMapper;

/**
 * deductionDetailsService
 *
 * @author 邱悦
 * @version 2022-01-01
 */
@Service
@Transactional(readOnly = true)
public class DeductionDetailsService extends CrudService<DeductionDetailsMapper, DeductionDetails> {

	public DeductionDetails get(String id) {
		return super.get(id);
	}

	public List<DeductionDetails> findList(DeductionDetails deductionDetails) {
		return super.findList(deductionDetails);
	}

	public Page<DeductionDetails> findPage(Page<DeductionDetails> page, DeductionDetails deductionDetails) {
		return super.findPage(page, deductionDetails);
	}

	public Page<EvaluationSummary> findSummeryPage(Page<EvaluationSummary> page, EvaluationSummary deductionDetails) {
		dataRuleFilter(deductionDetails);
		deductionDetails.setPage(page);
		page.setList(mapper.findSummaryList(deductionDetails));
		return page;
	}

	public EvaluationSummary getSummary(EvaluationSummary evaluationSummary) {
		return mapper.getSummary(evaluationSummary);
	}

	public List<SelectClass> getBigClass(String id) {
		return mapper.getBigClass(id);
	}

	public List<SelectClass> getSubClass(String id) {
		return mapper.getSubClass(id);
	}

	public String getVeto(String id) {
		return mapper.getVeto(id);
	}

	@Transactional(readOnly = false)
	public void insertDetails(DeductionDetails deductionDetails) {
		deductionDetails.preInsert();
		mapper.insertDetails(deductionDetails);
	}

	@Transactional(readOnly = false)
	public void save(DeductionDetails deductionDetails) {
		super.save(deductionDetails);
	}

	@Transactional(readOnly = false)
	public void delete(DeductionDetails deductionDetails) {
		super.delete(deductionDetails);
	}

	public List<DynamicHeader> returnHeader(String id){
		List<DynamicHeader> returnList = new ArrayList<>();
		DynamicHeader one = new DynamicHeader();
		DynamicHeader two = new DynamicHeader();
		DynamicHeader three = new DynamicHeader();
		one.setId("1");
		one.setTypeName("施工单位年份");
		two.setId("2");
		two.setTypeName("施工单位名称");
		three.setId("3");
		three.setTypeName("基础评分");
		returnList.add(one);
		returnList.add(two);
		returnList.add(three);

		List<String> strings = mapper.returnHeader(id);
		for (int i = 0; i < strings.size(); i++) {
			String s = strings.get(i);
			DynamicHeader d = new DynamicHeader();
			d.setId(String.valueOf(i+4));
			d.setTypeName(s);
			returnList.add(d);
		}
		DynamicHeader four = new DynamicHeader();
		int size = strings.size() + 3;
		four.setId(String.valueOf(size));
		four.setTypeName("汇总评分");
		returnList.add(four);
		return returnList;
	}
}