package com.bonus.hn.bearing.capacity.backstage.select.controller;

import com.bonus.hn.bearing.capacity.backstage.companypro.entity.ProjectManagerBean;
import com.bonus.hn.bearing.capacity.backstage.companypro.entity.TreeBean;
import com.bonus.hn.bearing.capacity.backstage.companypro.service.ProjectManagerService;
import com.bonus.hn.bearing.capacity.backstage.manager.annotation.LogAnnotation;
import com.bonus.hn.bearing.capacity.backstage.manager.utils.R;
import com.bonus.hn.bearing.capacity.backstage.select.entity.DataDictBean;
import com.bonus.hn.bearing.capacity.backstage.select.entity.SelectBean;
import com.bonus.hn.bearing.capacity.backstage.select.service.SelectService;
import com.bonus.hn.bearing.capacity.backstage.subteam.entity.SubTeamBean;
import com.bonus.hn.bearing.capacity.backstage.teamset.entity.ResourceSetBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author xliu
 * @date 2023/11/6 15:07  项目团队
 */
@Api(tags = "下拉框")
@RestController
@RequestMapping("/selectUtil")
public class SelectController {
    @Resource
    private ProjectManagerService service;

    @Resource
    private SelectService selectService;

    @LogAnnotation
    @PostMapping("getBranchName")
    @ApiOperation(value = "查询分公司")
    public List<SelectBean> getBranchName(SelectBean o) {
        List<SelectBean> list = service.getBranchName(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getAnnouncementType")
    @ApiOperation(value = "查询公告类型")
    public List<SelectBean> getAnnouncementType(SelectBean o) {
        List<SelectBean> list = selectService.getAnnouncementType(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getProjectName")
    @ApiOperation(value = "查询分公司")
    public List<SelectBean> getProjectName(SelectBean o) {
        List<SelectBean> list = service.getProjectName(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }

    @LogAnnotation
    @PostMapping("getVoltageLevel")
    @ApiOperation(value = "查询电压等级")
    public List<SelectBean> getVoltageLevel(SelectBean o) {
        List<SelectBean> list = service.getVoltageLevel(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getReleaseData")
    @ApiOperation(value = "查询预释放日期")
    public List<SelectBean> getReleaseData(SelectBean o) {
        List<SelectBean> list = selectService.getReleaseData(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }

    @LogAnnotation
    @PostMapping("getEngineerLevel")
    @ApiOperation(value = "查询工程名称")
    public List<SelectBean> getEngineerLevel(SelectBean o) {
        List<SelectBean> list = service.getEngineerLevel(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }

    @LogAnnotation
    @PostMapping("getBearingCapacity")
    @ApiOperation(value = "实名制工程绑定-查询承载力工程名称")
    public List<SelectBean> getBearingCapacity(SelectBean o) {
        List<SelectBean> list = service.getBearingCapacity(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }

    @LogAnnotation
    @PostMapping("getRealNameSystem")
    @ApiOperation(value = "实名制工程绑定-查询实名制工程名称")
    public List<SelectBean> getRealNameSystem(SelectBean o) {
        List<SelectBean> list = service.getRealNameSystem(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }

    @LogAnnotation
    @PostMapping("getStandardTeamTypeForSubTeamId")
    @ApiOperation(value = "根据班组类别查询标准班组类型")
    public List<SelectBean> getStandardTeamTypeForSubTeamId(SelectBean o) {
        List<SelectBean> list = selectService.getStandardTeamTypeForSubTeamId(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getSub")
    @ApiOperation(value = "查询分包商")
    public List<SelectBean> getSub(SelectBean o) {
        List<SelectBean> list = selectService.getSub(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getStrandTeamType")
    @ApiOperation(value = "查询自有班组标准类型")
    public List<SelectBean> getStrandTeamType(SelectBean o) {
        List<SelectBean> list = selectService.getStrandTeamType(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getStandardTeamType")
    @ApiOperation(value = "查询标准班组类型")
    public List<SelectBean> getStandardTeamType(SelectBean o) {
        List<SelectBean> list = selectService.getStandardTeamType(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getTeamType")
    @ApiOperation(value = "查询团队类型")
    public List<SelectBean> getTeamType(SelectBean o) {
        List<SelectBean> list = service.getTeamType(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getProName")
    @ApiOperation(value = "查询项目部")
    public List<SelectBean> getProName(SelectBean o) {
        List<SelectBean> list = service.getProName(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getDataDictByDickVal")
    @ApiOperation(value = "根据类型查询数据字典")
    public List<DataDictBean> getDataDictByDickVal(DataDictBean o) {
        System.err.println("DataDictBean="+o);
        List<DataDictBean> list = selectService.getDataDictByDickVal(o);
        System.err.println("list="+list);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }

    @LogAnnotation
    @PostMapping("getDataDictByDickVal_2")
    @ApiOperation(value = "根据类型查找分公司设置")
    public R getDataDictByDickVal_2(DataDictBean bean){
        List<DataDictBean> list = selectService.getDataDictByDickVal(bean);
        return list.size() > 0 ? R.okTable(list, list.size()):R.failTable("暂无数据");
    }

    @LogAnnotation
    @PostMapping("getProcessEquipment")
    @ApiOperation(value = "查询设备工机具")
    public List<SelectBean> getProcessEquipment(SelectBean o) {
        List<SelectBean> list = selectService.getProcessEquipment(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }
    @LogAnnotation
    @PostMapping("getProcessEquipments")
    @ApiOperation(value = "查询工序")
    public List<SelectBean> getProcessEquipments(SelectBean o) {
        List<SelectBean> list = selectService.getProcessEquipments(o);
        if (list.size() <= 0) {
            list = new ArrayList<>();
        }
        return list;
    }

}
