
package com.yihu.wlyy.service.app.consult;


import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.Evaluate;
import com.yihu.wlyy.entity.consult.EvaluateLabel;
import com.yihu.wlyy.repository.consult.EvaluateLabelDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.ClazzReflect;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

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


@Component
@Transactional
public class EvaluateLabelService extends BaseService {
	@Autowired
	EvaluateLabelDao evaluateLabelDao;
	@Autowired
	JdbcTemplate jdbcTemplate;

	public void save(List<EvaluateLabel> evaluateLabels){
		evaluateLabelDao.save(evaluateLabels);
	}

	public List<EvaluateLabel> findByDoctor(String doctor){
		return	this.evaluateLabelDao.findByDoctor(doctor);
	}

	public List<EvaluateLabel> findByConsult(String consult){
		return this.evaluateLabelDao.findByConsult(consult);
	}


	public 	List<Map<String, Object>> findDistinctLabelByLaDoctor(String doctor){
		String sql ="select content,count(content) as amount from wlyy_evaluate_label where doctor =? group by content order by amount DESC,id DESC ";
		List<Object> params = new ArrayList<Object>();
		params.add(doctor);
		List<Map<String, Object>> result = this.jdbcTemplate.queryForList(sql,params.toArray());
		return  result;
	}



}
