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

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sg.managementcenter.project.entity.PickingRequisition;
import com.jeeplus.modules.sg.managementcenter.project.entity.Project1;
import com.jeeplus.modules.sg.managementcenter.project.mapper.PickingRequisitionMapper;
import com.jeeplus.modules.sg.picking.activiti.entity.Acquisition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 请假表单Service
 * @author lgf
 * @version 2018-06-12
 */
@Service
@Transactional(readOnly = true)
public class PickingRequisitionService extends CrudService<PickingRequisitionMapper, PickingRequisition> {
    @Autowired
	private PickingRequisitionMapper pickingRequisitionMapper;

	public PickingRequisition get(String id) {
		PickingRequisition pickingRequisition = super.get(id);
		return pickingRequisition;
	}
	
	public List<PickingRequisition> findList(PickingRequisition pickingRequisition) {
		return super.findList(pickingRequisition);
	}
	
	public Page<PickingRequisition> findPage(Page<PickingRequisition> page, PickingRequisition pickingRequisition) {
		return super.findPage(page, pickingRequisition);
	}
	
	@Transactional(readOnly = false)
	public void save(PickingRequisition pickingRequisition) {
		super.save(pickingRequisition);
	}
	
	@Transactional(readOnly = false)
	public void delete(PickingRequisition pickingRequisition) {
		super.delete(pickingRequisition);
	}

	@Transactional(readOnly = false)
	public void saveList(List<PickingRequisition> pickingRequisitions) {
		for (PickingRequisition pickingRequisition:pickingRequisitions){
			pickingRequisition.preInsert();
		}
		pickingRequisitionMapper.insertList(pickingRequisitions);
	}
	//根据项目定义号查询相同的项目定义
	public List<PickingRequisition> pickingRequisitions(List<PickingRequisition> pickingRequisitions){
		return pickingRequisitionMapper.findListPicking(pickingRequisitions);
	}
	//根据角色名查找用户id
	public List<String> findUserId(List<String> list){
		return pickingRequisitionMapper.findUserId(list);
	}

	//根据项目id去查找项目领导时间
	public List<Acquisition> getFindListDate(List<Project1> projects){
		return pickingRequisitionMapper.findListAcquisition(projects);
	}
}