package com.zjrs.zwnw.bsdb.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mohrss.leaf.core.framework.persistens.PageResult;
import org.mohrss.leaf.core.framework.web.controller.AjaxResponse;
import com.zjrs.zwnw.bsdb.bpo.DbsxBPO;
import com.zjrs.zwnw.bsdb.dto.DbglPageQueryDTO;
import com.zjrs.zwnw.bsdb.dto.DbglReportFormsQueryDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RestController;

import jakarta.annotation.Resource;
import java.util.Map;

@Api("督办报表管理")
@RestController
@RequestMapping("/api/dbgl/reportforms")
public class DbglReportController {

    private static final Logger logger = LoggerFactory.getLogger(DbglReportController.class);

    @Resource
    DbsxBPO dbsxBPO;

    /**
     * 督办事项统计看板
     *
     * @param dto 查询条件
     * @return
     */
    @ApiOperation(value = "督办事项统计看板查询", notes = "督办事项统计看板查询")
    @PostMapping("/list")
    public AjaxResponse list(@RequestBody DbglPageQueryDTO dto) {
        logger.info("督办事项统计看板查询");
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = dto.getPagenum();
        Integer pagesize = dto.getPagesize();

        try {
            PageResult pageResult = dbsxBPO.queryReportformsList(dto);
            ajaxResponse.setData("data", pageResult);
            ajaxResponse.setData("pagesize", pagesize);
            ajaxResponse.setData("pagenum", pagenum);
        } catch (Exception e) {
            logger.error(e.getMessage());
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }


    /**
     * 督办事项统计看板
     *
     * @param dto 查询条件
     * @return
     */
    @ApiOperation(value = "督办事项统计看板查询", notes = "督办事项统计看板查询")
    @PostMapping("/query")
    public AjaxResponse query(@RequestBody DbglReportFormsQueryDTO dto) {
        logger.info("督办事项统计看板查询");
        AjaxResponse ajaxResponse = new AjaxResponse();

        try {
            Map<String, Object> result = dbsxBPO.queryReportforms(dto);
            ajaxResponse.setData("data", result);
        } catch (Exception e) {
            logger.error(e.getMessage());
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    /**
     * 督办事项统计看板
     *
     * @param dto 查询条件
     * @return
     */
    @ApiOperation(value = "督办事项统计看板查询", notes = "督办事项统计看板查询")
    @PostMapping("/fzdwsxtj/list")
    public AjaxResponse queryStatisForFzdwsxtj(@RequestBody DbglReportFormsQueryDTO dto) {
        logger.info("督办事项统计看板查询");
        AjaxResponse ajaxResponse = new AjaxResponse();

        try {
            Map<String, Object> result = dbsxBPO.queryStatisForFzdwsxtj(dto);
            ajaxResponse.setData("data", result);
        } catch (Exception e) {
            logger.error(e.getMessage());
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

}
