package thyyxxk.webserver.controller.targetmanagement;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.highreport.HighReportDto;
import thyyxxk.webserver.entity.highreport.ReportBaseInfo;
import thyyxxk.webserver.entity.highreport.TableDisplayInfo;
import thyyxxk.webserver.entity.highreport.TableGroupInfo;
import thyyxxk.webserver.entity.highreport.ZbReportCycle;
import thyyxxk.webserver.entity.highreport.ZbReportCycleScore;
import thyyxxk.webserver.entity.highreport.ZbReportMonthScore;
import thyyxxk.webserver.entity.highreport.ZbReportResult;
import thyyxxk.webserver.entity.highreport.ZbReportScoreDto;
import thyyxxk.webserver.entity.highreport.ZdReportType;
import thyyxxk.webserver.entity.targetmanagement.TargetDictTree;
import thyyxxk.webserver.entity.targetmanagement.TargetManagement;
import thyyxxk.webserver.entity.targetmanagement.ZbZdBaseInfo;
import thyyxxk.webserver.service.targetmanagement.TargetManagementService;

import java.util.List;
import java.util.Map;

/**
 * @Description: 指标管理
 * @Author: hsh
 * @CreateTime: 2023-05-30  16:49
 * @Version: 1.0
 */
@RestController
@RequestMapping("/targetManagement")
public class TargetManagementController {

    private final TargetManagementService service;

    @Autowired
    public TargetManagementController(TargetManagementService service) {
        this.service = service;
    }

    @PostMapping("/selectTargetDictTree")
    public ResultVo<List<TargetDictTree>> selectTargetDictTree(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetDictTree(dto);
    }

    @PostMapping("/selectTargetDict")
    public ResultVo<List<ZbZdBaseInfo>> selectTargetDict(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetDict(dto);
    }

    @PostMapping("/selectTargetDictById")
    public ResultVo<ZbZdBaseInfo> selectTargetDictById(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetDictById(dto);
    }

    @PostMapping("/saveTargetDict")
    public ResultVo<Map<String, Object>> saveTargetDict(@RequestBody @Validated ZbZdBaseInfo dto){
        return service.saveTargetDict(dto);
    }

    @PostMapping("/deleteTargetDictById")
    public ResultVo<Map<String, Object>> deleteTargetDictById(@RequestBody @Validated TargetManagement dto){
        return service.deleteTargetDictById(dto);
    }

    @PostMapping("/updateTargetDict")
    public ResultVo<Map<String, Object>> updateTargetDict(@RequestBody @Validated ZbZdBaseInfo dto){
        return service.updateTargetDict(dto);
    }

    @PostMapping("/targetSqlExecute")
    public ResultVo<Map<String, Object>> targetSqlExecute(@RequestBody @Validated TargetManagement dto){
        return service.targetSqlExecute(dto);
    }

    @PostMapping("/targetSqlExecuteById")
    public ResultVo<List<Map<String, Object>>> targetSqlExecuteById(@RequestBody @Validated TargetManagement dto){
        return service.targetSqlExecuteById(dto);
    }

    @PostMapping("/targetSqlSave")
    public ResultVo<Map<String, Object>> targetSqlSave(@RequestBody @Validated TargetManagement dto){
        return service.targetSqlSave(dto);
    }

    @PostMapping("/selectTargetSql")
    public ResultVo<Map<String, Object>> selectTargetSql(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetSql(dto);
    }

    @PostMapping("/selectTargetSqlDetail")
    public ResultVo<Map<String, Object>> selectTargetSqlDetail(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetSqlDetail(dto);
    }

    @PostMapping("/selectReportDictTree")
    public ResultVo<List<Map<String, Object>>> selectReportDictTree(@RequestBody @Validated HighReportDto dto){
        return service.selectReportDictTree(dto);
    }

    @PostMapping("/deleteReportDictById")
    public ResultVo<Map<String, Object>> deleteReportDictById(@RequestBody @Validated TargetManagement dto){
        return service.deleteReportDictById(dto);
    }


    @PostMapping("/selectReportDict")
    public ResultVo<List<ReportBaseInfo>> selectReportDict(@RequestBody @Validated HighReportDto dto){
        return service.selectReportDict(dto);
    }

    @GetMapping("/selectReportType")
    public ResultVo<List<ZdReportType>> selectReportType() {
        return service.selectReportType();
    }

    @PostMapping("/reportSqlExecute")
    public ResultVo<Map<String, Object>> reportSqlExecute(@RequestBody @Validated TargetManagement dto){
        return service.reportSqlExecute(dto);
    }

    @PostMapping("/selectReportLevel")
    public ResultVo<TableGroupInfo> selectReportLevel(@RequestBody @Validated HighReportDto dto){
        return service.selectReportLevel(dto);
    }

    @PostMapping("/saveTargetReportResult")
    public ResultVo<Map<String, Object>> saveTargetReportResult(@RequestBody List<ZbReportResult> list){
        return service.saveTargetReportResult(list);
    }

    @PostMapping("/saveTargetReportResultSinge")
    public ResultVo<Map<String, Object>> saveTargetReportResultSinge(@RequestBody ZbReportResult result){
        return service.saveTargetReportResultSinge(result);
    }

    @PostMapping("/delTargetReportResultByYear")
    public ResultVo<Map<String, Object>> delTargetReportResultByYear(@RequestBody ZbReportResult result){
        return service.delTargetReportResultByYear(result);
    }

    @PostMapping("/selectTargetReportResult")
    public ResultVo<List<ZbReportResult>> selectTargetReportResult(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetReportResult(dto);
    }

    @PostMapping("/saveReportBaseInfo")
    public ResultVo<Map<String, Object>> saveReportBaseInfo(@RequestBody @Validated ReportBaseInfo info){
        return service.saveReportBaseInfo(info);
    }

    @PostMapping("/saveTableGroupInfo")
    public ResultVo<Map<String, Object>> saveTableGroupInfo(@RequestBody @Validated TableGroupInfo info){
        return service.saveTableGroupInfo(info);
    }

    @GetMapping("/selectReportLevelDict")
    public ResultVo<List<Map<String, Object>>> selectReportLevelDict() {
        return service.selectReportLevelDict();
    }

    @GetMapping("/selectTargetZbReportId")
    public ResultVo<List<Map<String, Object>>> selectTargetZbReportId(@RequestParam("reportType") String reportType) {
        return service.selectTargetZbReportId(reportType);
    }

    @PostMapping("/selectTableDisplay")
    public ResultVo<List<TableDisplayInfo>> selectTableDisplay(@RequestBody @Validated ReportBaseInfo info){
        return service.selectTableDisplay(info);
    }

    @PostMapping("/saveTableDisplay")
    public ResultVo<Map<String, Object>> saveTableDisplay(@RequestBody @Validated TableDisplayInfo info){
        return service.saveTableDisplay(info);
    }

    @GetMapping("/delTableDisplayByProp")
    public ResultVo<Map<String, Object>> delTableDisplayByCode(@RequestParam("reportId") String reportId,
                                                               @RequestParam("levelId") String levelId,
                                                               @RequestParam("prop") String prop){
        return service.delTableDisplayByProp(reportId, levelId, prop);
    }

    @GetMapping("/selectScoreCycle")
    public ResultVo<List<ZbReportCycle>> selectScoreCycle(){
        return service.selectScoreCycle();
    }

    @PostMapping("/updateTargetReportScore")
    public ResultVo<Map<String, Object>> updateTargetReportScore(@RequestBody @Validated ZbReportCycleScore score){
        return service.updateTargetReportScore(score);
    }

    @PostMapping("/updateTargetReportScoreByShf")
    public ResultVo<Map<String, Object>> updateTargetReportScoreByShf(@RequestBody @Validated ZbReportCycleScore score){
        return service.updateTargetReportScoreByShf(score);
    }

    @PostMapping("/returnTargetReportScoreByShf")
    public ResultVo<Map<String, Object>> returnTargetReportScoreByShf(@RequestBody @Validated ZbReportCycleScore score){
        return service.returnTargetReportScoreByShf(score);
    }

    @PostMapping("/selectTargetReportScore")
    public ResultVo<ZbReportCycleScore> selectTargetReportScore(@RequestBody @Validated ZbReportCycleScore score){
        return service.selectTargetReportScore(score);
    }

    @GetMapping("/selectScoreCyclePermissions")
    public ResultVo<Map<String, Object>> selectScoreCyclePermissions(){
        return service.selectScoreCyclePermissions();
    }

    @PostMapping("/selectTargetDictScoreById")
    public ResultVo<List<Map<String, Object>>> selectTargetDictScoreById(@RequestBody @Validated ZbReportScoreDto dto){
        return service.selectTargetDictScoreById(dto);
    }

    @PostMapping("/selectTargetTotalScoreInfo")
    public ResultVo<Map<String, Object>> selectTargetTotalScoreInfo(@RequestBody @Validated ZbReportScoreDto dto){
        return service.selectTargetTotalScoreInfo(dto);
    }

    @PostMapping("/targetSqlExecuteMonthById")
    public ResultVo<Map<String, Object>> targetSqlExecuteMonthById(@RequestBody @Validated TargetManagement dto){
        return service.targetSqlExecuteMonthById(dto);
    }

    @PostMapping("/selectTargetReportResultByMonth")
    public ResultVo<ZbReportMonthScore> selectTargetReportResultByMonth(@RequestBody @Validated ZbReportMonthScore dto){
        return service.selectTargetReportResultByMonth(dto);
    }

    @PostMapping("/saveTargetReportMonthResult")
    public ResultVo<Map<String, Object>> saveTargetReportMonthResult(@RequestBody ZbReportMonthScore monthScore){
        return service.saveTargetReportMonthResult(monthScore);
    }

    @PostMapping("/selectTargetReportMonthScore")
    public ResultVo<List<ZbReportMonthScore>> selectTargetReportMonthScore(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetReportMonthScore(dto);
    }

    @PostMapping("/selectTargetYearScoreSummary")
    public ResultVo<List<Map<String, Object>>> selectTargetYearScoreSummary(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetYearScoreSummary(dto);
    }

    @PostMapping("/selectTargetMonthScoreSummary")
    public ResultVo<List<ZbReportMonthScore>> selectTargetMonthScoreSummary(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetMonthScoreSummary(dto);
    }

    @PostMapping("/selectTargetDictConstantData")
    public ResultVo<List<ReportBaseInfo>> selectTargetDictConstantData(@RequestBody @Validated TargetManagement dto){
        return service.selectTargetDictConstantData(dto);
    }

    @PostMapping("/uploadTargetFile")
    public ResultVo<Map<String, Object>> uploadTargetFile(@Validated ZbReportResult result){
        return service.uploadTargetFile(result);
    }

    @PostMapping("/selectTargetFileById")
    public ResultVo<Map<String, Object>> selectTargetFileById(@RequestBody @Validated ZbReportResult result){
        return service.selectTargetFileById(result);
    }

    @GetMapping("/deleteTargetFileByFileId")
    public ResultVo<Map<String, Object>> deleteTargetFileByFileId(@RequestParam("fileId") String fileId, @RequestParam("id") String id,
                                                                  @RequestParam("pid") String pid, @RequestParam("year") String year) {
        return service.deleteTargetFileByFileId(fileId, id, pid, year);
    }

}
