package com.ssj.service.weixin.zuoyb.service.impl;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.weixin.zyb.domain.ZuoybStudentWorkHowDetails;
import com.ssj.dao.weixin.zuoyb.dao.ZuoybQueryDao;
import com.ssj.dao.weixin.zuoyb.dao.ZuoybStudentWorkHowDetailsDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.weixin.zuoyb.service.ZuoybStudentWorkHowDetailsService;


/** 
 * @author  ZhangCaibao 
 * @version 2017年11月1日 下午3:25:50 
 * 类说明 
 */
@Service(version="1.0")
@Transactional
public class ZuoybStudentWorkHowDetailsServiceImpl extends BaseServiceImpl<ZuoybStudentWorkHowDetails, String> implements ZuoybStudentWorkHowDetailsService  {

	@Autowired
	private  ZuoybStudentWorkHowDetailsDao  zuoybStudentWorkHowDetailsDao;

	@Autowired
	private ZuoybQueryDao zuoybQueryDao;
	
	@Override
	public PagingAndSortingRepository<ZuoybStudentWorkHowDetails, String> getDao() {
		return zuoybStudentWorkHowDetailsDao;
	}

	@Override
	public void deleteByStudentWorkId(String studentWorkId) {
		zuoybStudentWorkHowDetailsDao.deleteByStudentWorkId(studentWorkId);
		
	}

	@Override
	public List<ZuoybStudentWorkHowDetails> getStartAndEndWorkHowAndCourse(
			String vipId, String start, String end, String course) {
		return zuoybStudentWorkHowDetailsDao.getStartAndEndWorkHowAndCourse(vipId, start, end, course);
	}

	@Override
	public List<ZuoybStudentWorkHowDetails> findByStudentWorkIdIn(List<String> studentWorkIds) {
		return zuoybStudentWorkHowDetailsDao.findByStudentWorkIdIn(studentWorkIds);
	}

	@Override
	public List<ZuoybStudentWorkHowDetails> findWorkHowDetail4Id(List<String> howDetailIds, int type, String zybWorkId) {
		return zuoybStudentWorkHowDetailsDao.findByStudentWorkIdAndTypeAndHowDetailsIdIn(zybWorkId, type, howDetailIds);
	}

	@Override
	public List<Map<String, String>> findWrongRelateKnow (String studentWorkId){
		List<ZuoybStudentWorkHowDetails> list = zuoybStudentWorkHowDetailsDao.findByStudentWorkIdAndType(studentWorkId, 2);
		List<Map<String, String>> result = new ArrayList<Map<String, String>>();
		Map<String, String> temp = null;
		if (list != null){
			for (ZuoybStudentWorkHowDetails detail : list){
				temp = new HashMap<String, String>();
				temp.put("name", detail.getName());
				temp.put("module", detail.getModule());
				result.add(temp);
			}
		}
		return result;
	}

	@Override
	public List<Map<String, Object>> getHomeworkKnowModuleData(String vipId, String subject, String beginTime, String endTime, int type) {
		return zuoybQueryDao.getHomeworkKnowModuleData(vipId, subject, beginTime, endTime, type);
	}

	@Override
	public List<Map<String, Object>> getHomeworkKnowModuleDataV1(String vipId, String subject, String beginTime, String endTime, int type) {
		return zuoybQueryDao.getHomeworkKnowModuleDataV1(vipId, subject, beginTime, endTime, type);
	}

	@Override
	public List<Map<String, Object>> getHomeworkKnowModuleDataWrongV1(String vipId, String subject, String beginTime, String endTime, int type) {
		return zuoybQueryDao.getHomeworkKnowModuleDataWrongV1(vipId, subject, beginTime, endTime, type);
	}

	@Override
	public List<Map<String, Object>> getKnowPointGrasp(String vipId, String subject, String beginTime, String endTime, int type) {
		return zuoybQueryDao.getKnowPointGrasp(vipId, subject, beginTime, endTime, type);
	}

	@Override
	public List<Map<String, Object>> getWrongKnowPointGrasp(String vipId, String subject, String beginTime, String endTime, int type) {
		return zuoybQueryDao.getWrongKnowPointGrasp(vipId, subject, beginTime, endTime, type);
	}
}
