/**
 * 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.activiti.entity.EngineeringAmount;
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.entity.NonPower;
import com.jeeplus.modules.sg.materialmodule.activiti.mapper.MaterialModuleMapper;
import com.jeeplus.modules.sg.picking.activiti.entity.CapitalExport;
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();
    }

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

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

    //根据项目id修改项目施工状态
    @Transactional(readOnly = false)
    public void updateConstructionStatus(String status, String reserveProjectName) {
        materialModuleMapper.updateConstructionStatus(status, reserveProjectName);
    }

    //修改配网电气含涉电报告数据-开工报告
    @Transactional(readOnly = false)
    public void updateElectricalStart(MaterialModule materialModule) {
        materialModuleMapper.updateElectricalStart(materialModule);
    }

    //修改配网电气含涉电报告数据-竣工报告
    @Transactional(readOnly = false)
    public void updateElectricalEnd(MaterialModule materialModule) {
        materialModuleMapper.updateElectricalEnd(materialModule);
    }

    //根据储备项目名称查询项目的作业方式
    public String findPlanDay(String reserveProjectName) {
        return materialModuleMapper.findPlanDay(reserveProjectName);
    }

    // 通过项目需求名称查询项目的进场领料单数据
    public List<EngineeringAmount> findProcessList(String reserveProjectName) {
        return materialModuleMapper.findProcessList(reserveProjectName);
    }

    @Transactional(readOnly = false)
    public void updateSeveralTimes(String procInsId, int number) {
        materialModuleMapper.updateSeveralTimes(procInsId, number);
    }

    public MaterialModule findById(String id){
        return materialModuleMapper.findById(id);
    }

    public Page<MaterialModule> findListPage(Page<MaterialModule> page, MaterialModule materialModule) {
        dataRuleFilter(materialModule);
        materialModule.setPage(page);
        page.setList(materialModuleMapper.findListPage(materialModule));
        return page;
    }
}