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

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sg.advence.activiti.entity.Advance;
import com.jeeplus.modules.sg.advence.activiti.mapper.AdvanceMapper;
import com.jeeplus.modules.sg.managementcenter.constructionProject.entity.ConstructionProject;
import com.jeeplus.modules.sg.materialmodule.activiti.entity.MaterialModule;
import com.jeeplus.modules.sg.materialmodule.activiti.mapper.MaterialModuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

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

    public MaterialModule get(String id) {
        MaterialModule materialModule = super.get(id);
        return materialModule;
    }

    //查询项目信息
    public String findProjectName(String procInsId) {
        return materialModuleMapper.findProjectName(procInsId);
    }

    //根据项目名称查询，项目计划开工时间
    public Date findSpecificTime(String projectName) {
        return materialModuleMapper.findSpecificTime(projectName);
    }

    //根据角色名查找用户id
    public List<String> findUserId(List<String> list) {
        return materialModuleMapper.findUserId(list);
    }

    //根据项目名称获取项目计划数据
    public ConstructionProject findProject(String projectName) {
        return materialModuleMapper.findProject(projectName);
    }

    //插入对应的计划信息
    @Transactional(readOnly = false)
    public void conProject(ConstructionProject constructionProject) {
        materialModuleMapper.conProject(constructionProject);
    }

    //查询当月所有的计划项目信息
    public List<ConstructionProject> findMonthProject() {
        return materialModuleMapper.findMonthProject();
    }

    //根据list<项目名>查询所有的流程项目信息
    public List<MaterialModule> findMaterialProject(List<ConstructionProject> list) {
        return materialModuleMapper.findMaterialProject(list);
    }

    //修改计划项目的是否竣工状态
    @Transactional(readOnly = false)
    public void updateEndFlag(String projectName) {
        materialModuleMapper.updateEndFlag(projectName);
    }

    //根据流程是列id获取流程信息
    public MaterialModule getModuleById(String procInsId) {
        return materialModuleMapper.getModuleById(procInsId);
    }

    //根据流程实列id修改项目记录领料次数信息
    @Transactional(readOnly = false)
    public void updateModuleById(MaterialModule module) {
        materialModuleMapper.updateModuleById(module);
    }

    @Transactional(readOnly = false)
    @Override
    public void save(MaterialModule entity) {
        materialModuleMapper.updateConstructionStatus(entity);
        super.save(entity);
    }

    @Transactional(readOnly = false)
    public void updateNonPower(String procInsId) {
		materialModuleMapper.updateNonPower(procInsId);
    }

    @Transactional(readOnly = false)
    public void updateElectrical(String procInsId) {
		materialModuleMapper.updateElectrical(procInsId);
    }

    @Transactional(readOnly = false)
    public void updatePower(String procInsId) {
		materialModuleMapper.updatePower(procInsId);
    }

    public MaterialModule findByProcInsId(String procInsId) {
        return materialModuleMapper.findByProcInsId(procInsId);
    }
}