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

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sg.managementcenter.activiti.entity.Construction;
import com.jeeplus.modules.sg.managementcenter.activiti.mapper.ConstructionMapper;
import com.jeeplus.modules.sg.managementcenter.project.entity.Project;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.test.activiti.entity.OALeave;
import com.jeeplus.modules.test.activiti.mapper.OALeaveMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 施工交底Service
 * @author
 * @version 2019-11-08
 */
@Service
@Transactional(readOnly = true)
public class ConstructionService extends CrudService<ConstructionMapper, Construction> {

	@Autowired
	private ConstructionMapper constructionMapper;

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

	@Transactional(readOnly = false)
	public void newUpdate(Construction construction){
		constructionMapper.newUpdate(construction);
	}

	public User queryPerson(String loginName) {
		return constructionMapper.queryPerson(loginName);
	}

	/**
	 * 根据登陆名查询角色
	 * */
	public String nameFindOffice(String loginName) {
		return constructionMapper.nameFindOffice(loginName);
	}

	@Transactional(readOnly = false)
	public void newSave(Construction construction) {
		construction.preInsert();
		constructionMapper.newSave(construction);
	}

	@Transactional(readOnly = false)
	public void updateExamine(Construction construction) {
		constructionMapper.updateExamine(construction);
	}

	//根据流程id查询项目的需求提出单位
	public String demandUnit(String procInsId) {
		return constructionMapper.demandUnit(procInsId);
	}

	//根据流程定义号查询项目需求名称
	public String idProjectName(String procInsId) {
		String s = constructionMapper.idProjectName(procInsId);
		return s;
	}

	/**
	 * 根据流程定义号查询提前物料申请流程的项目名称
	 * */
	public Project findNameByInsID(String procInsId) {
		return constructionMapper.findNameByInsID(procInsId);
	}

}