package com.yanzhu.jh.bigscreen.web.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.yanzhu.jh.project.domain.SurProjectWorkSpecial;
import com.yanzhu.jh.project.service.ISurProjectWorkSpecialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目特种作业人员Conller
 */
@RestController
@RequestMapping("/bgscreen/projectspecial")
public class ProjectSpecialController extends BaseController {

    @Autowired
    ISurProjectWorkSpecialService surProjectWorkSpecialService;

    /**
     * 查询特种作业人员统计
     * @param deptId
     * @param projectId
     * @return
     */
    @GetMapping("/getProjectSpecialView")
    public TableDataInfo getProjectSpecialView(String deptId,String projectId){
        SurProjectWorkSpecial surProjectWorkSpecial = new SurProjectWorkSpecial();
        if(deptId!=null && !"0".equals(deptId)){
            surProjectWorkSpecial.setNowDept(deptId);
        }
        if(projectId!=null && !"0".equals(projectId)){
            surProjectWorkSpecial.setProjectId(Convert.toLong(projectId));
        }
        return getDataTable(surProjectWorkSpecialService.selectBgscreenWorkSpecialList(surProjectWorkSpecial));
    }

    /**
     * 查询特种作业人员列表
     * @param projectId
     * @return
     */
    @GetMapping("/getProjectSpecialList")
    public TableDataInfo getProjectSpecialList(String projectId, String activeName, String specialType){
        SurProjectWorkSpecial surProjectWorkSpecial = new SurProjectWorkSpecial();
        if(projectId!=null && !"0".equals(projectId)){
            surProjectWorkSpecial.setProjectId(Convert.toLong(projectId));
        }
        if(StringUtils.isNotBlank(activeName)){
            surProjectWorkSpecial.setActiveName(activeName);
        }
        if(specialType!=null && !"0".equals(specialType)){
            surProjectWorkSpecial.setSpecialType(specialType);
        }
        return getDataTable(surProjectWorkSpecialService.selectSurProjectWorkSpecialList(surProjectWorkSpecial));
    }

    /**
     * 查询项目特种人员数量统计
     */
    @GetMapping("/findWorkSpecialCount")
    public AjaxResult findWorkSpecialCount(String projectId, String specialType)
    {
        SurProjectWorkSpecial surProjectWorkSpecial = new SurProjectWorkSpecial();
        if(projectId!=null && !"0".equals(projectId)){
            surProjectWorkSpecial.setProjectId(Convert.toLong(projectId));
        }
        if(specialType!=null && !"0".equals(specialType)){
            surProjectWorkSpecial.setSpecialType(specialType);
        }
        return success(surProjectWorkSpecialService.findWorkSpecialCount(surProjectWorkSpecial));
    }
}
