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

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

import com.jeeplus.common.utils.MenuStatusEnum;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.work.entity.report.WorkReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;
import com.jeeplus.modules.workoutsignin.entity.WorkOutSignIn;
import com.jeeplus.modules.workoutsignin.dao.WorkOutSignInDao;

/**
 * 外勤签到Service
 * @author 李韵轩
 * @version 2017-04-20
 */
@Service
@Transactional(readOnly = true)
public class WorkOutSignInService extends CrudService<WorkOutSignInDao, WorkOutSignIn> {

	@Autowired
	private WorkOutSignInDao workOutSignInDao;
	public WorkOutSignIn get(String id) {
		return super.get(id);
	}
	
	public List<WorkOutSignIn> findList(WorkOutSignIn workOutSignIn) {
		return super.findList(workOutSignIn);
	}

	public Page<WorkOutSignIn> findPage(Page<WorkOutSignIn> page, WorkOutSignIn workOutSignIn) {
		return super.findPage(page, workOutSignIn);
	}
	
	@Transactional(readOnly = false)
	public void save(WorkOutSignIn workOutSignIn) {
		super.save(workOutSignIn);
	}
	
	@Transactional(readOnly = false)
	public void delete(WorkOutSignIn workOutSignIn) {
		super.delete(workOutSignIn);
	}


	public List<WorkOutSignIn> findByCompany(WorkOutSignIn workOutSignIn) {
		return dao.findByCompany(workOutSignIn);
	}

	public Page<WorkOutSignIn> findPageByUser(Page<WorkOutSignIn> page, WorkOutSignIn workOutSignIn) {
		workOutSignIn.setPage(page);
		page.setList(dao.findListByUser(workOutSignIn));
		return page ;
	}

    public List getCreateDateList(String companyId, String date) {
		Map<String,String> map = new HashMap<>();
		map.put("companyId",companyId);
		map.put("date",date);
		return workOutSignInDao.getCreateDateList(map);
    }
	public List getCreateDateList1(String time) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("userId",UserUtils.getUser().getId());
		map.put("time",time);
		return workOutSignInDao.getCreateDateList1(map);
	}
	public List<WorkOutSignIn> findByCompany1(String time){
		Map<String,String> map = new HashMap<String,String>();
		map.put("userId",UserUtils.getUser().getId());
		map.put("time",time);
		return workOutSignInDao.findByCompany1(map);
	}

	public List getCreateDateListAll(String time) {
		WorkOutSignIn w=new WorkOutSignIn();
		Map<String,String> map = new HashMap<String,String>();
		map.put("sqlStr",dataScopeFilter(w.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_OUT_SIGNIN.getValue()));
		map.put("time",time);
		return workOutSignInDao.getCreateDateListAll(map);
	}
	public List<WorkOutSignIn> findByCompanyAll(String time){
		WorkOutSignIn w=new WorkOutSignIn();
		Map<String,String> map = new HashMap<String,String>();
		map.put("sqlStr",dataScopeFilter(w.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_OUT_SIGNIN.getValue()));
		map.put("time",time);
		return workOutSignInDao.findByCompanyAll(map);
	}
    public List<WorkOutSignIn> findByCompany2(WorkOutSignIn workOutSignIn, String date) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("sign",workOutSignIn);
		map.put("date",date);
		return  workOutSignInDao.findByCompany2(map);
    }
	public List<WorkOutSignIn> findByManage(Map<String,Object> map) {
		return workOutSignInDao.findByManage(map);
	}
	public List<WorkOutSignIn> findByCompanySelf(Map<String,Object> map) {
		return workOutSignInDao.findByCompanySelf(map);
	}
}