package com.zjrs.zwnw.dbgl.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.dbgl.bpo.DbrwglBPO;
import com.zjrs.zwnw.dbgl.bpo.DbrwglCommBPO;
import com.zjrs.zwnw.dbgl.bpo.GzqdglBPO;
import com.zjrs.zwnw.dbgl.dto.*;
import com.zjrs.zwnw.portal.bpo.CommonBPO;
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 jakarta.validation.Valid;
import java.util.List;

@Api("督办管理公共")
@RestController
@RequestMapping("/api/dbrwgl/comm")
public class DbrwglCommController {

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

    @Resource
    private DbrwglCommBPO dbrwglCommBPO;
    @Resource
    private CommonBPO commBPO;
    @Resource
    private DbrwglBPO dbrwglBPO;
    @Resource
    private GzqdglBPO gzqdglBPO;

/*
获取动态字典机构      getOrgs
获取动态字典用户      getUsers
督办任务信息获取	getDbrwxxById
工作清单信息保存 saveGzqd
项目信息列表	getXmxxList
督办任务信息列表   getDbrwListByGzqdid
工作清单进展情况列表	getGzqdjzqkList
审核历史列表	getShlsListByQdid
分管领导批示记录列表	getPsjlLstByQdid
分管领导批示记录删除	delPsjlById
分管领导批示记录保存  savePsjl
工作清单进展情况获取	getGzqdjzqk
首页督办提醒 getDbtxList

*/

    @ApiOperation(value = "获取动态字典机构", notes = "获取动态字典机构")
    @PostMapping("/getOrgs")
    public AjaxResponse getOrgs(@RequestBody DictGetDTO dto) {
        logger.info("获取动态字典机构开始");
        AjaxResponse ajaxResponse = new AjaxResponse();
        List<DictDTO> result = this.dbrwglCommBPO.getOrgs(dto);
        ajaxResponse.setData("data", result);
        logger.info("获取动态字典机构结束");
        return ajaxResponse;
    }
    @ApiOperation(value = "获取动态字典用户", notes = "获取动态字典用户")
    @PostMapping("/getUsers")
    public AjaxResponse getUsers(@RequestBody DictGetDTO dto) {
        logger.info("获取动态字典用户开始");
        AjaxResponse ajaxResponse = new AjaxResponse();
        List<DictDTO> result = this.dbrwglCommBPO.getUsers(dto);
        ajaxResponse.setData("data", result);
        logger.info("获取动态字典用户结束");
        return ajaxResponse;
    }

    /**
     * 督办任务信息获取
     */
    @ApiOperation(value = "督办任务信息获取", notes = "督办任务信息获取")
    @PostMapping("/getDbrwxxById")
    public AjaxResponse getDbrwxxById(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", dbrwglBPO.getDbrwxxById(dto));
        return ajaxResponse;
    }

    /**
     * 项目信息列表
     */
    @ApiOperation(value = "项目信息列表", notes = "项目信息列表")
    @PostMapping(value = "/getXmxxList")
    public AjaxResponse getXmxxList(@RequestBody @Valid DbrwglXmxxQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();

        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwglBPO.getXmxxList(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }


    /**
     * 工作清单信息保存
     */
    @ApiOperation(value = "工作清单信息保存", notes = "工作清单信息保存")
    @PostMapping("/saveGzqd")
    public AjaxResponse saveGzqd(@RequestBody @Valid DbrwglGzqdUDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("rsdbglgzqdlsh", gzqdglBPO.saveGzqd(dto));        ;
        return ajaxResponse;
    }

    /**
     * 督办任务信息列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "督办任务信息列表", notes = "督办任务信息列表")
    @PostMapping(value = "/getDbrwListByGzqdid")
    public AjaxResponse getDbrwListByGzqdid(@RequestBody @Valid DbrwglCommQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = gzqdglBPO.getDbrwListByGzqdid(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }
    /**
     * 工作清单进展情况列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "工作清单进展情况列表", notes = "工作清单进展情况列表")
    @PostMapping(value = "/getGzqdjzqkList")
    public AjaxResponse getGzqdjzqkList(@RequestBody @Valid DbrwglCommQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwglCommBPO.getGzqdjzqkList(dto);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }
    /**
     * 审核历史列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "审核历史列表", notes = "审核历史列表")
    @PostMapping(value = "/getShlsListByQdid")
    public AjaxResponse getShlsListByQdid(@RequestBody @Valid DbrwglCommQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwglCommBPO.getShlsListByQdid(dto);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }
    /**
     * 分管领导批示记录列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "分管领导批示记录列表", notes = "分管领导批示记录列表")
    @PostMapping(value = "/getPsjlLstByQdid")
    public AjaxResponse getPsjlLstByQdid(@RequestBody @Valid DbrwglCommQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwglCommBPO.getPsjlLstByQdid(dto);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }

    /**
     * 分管领导批示记录删除
     */
    @ApiOperation(value = "分管领导批示记录删除", notes = "分管领导批示记录删除")
    @PostMapping("/delPsjlById")
    public AjaxResponse delPsjlById(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglCommBPO.delPsjlById(dto);
        return ajaxResponse;
    }

    /**
     * 分管领导批示记录保存
     */
    @ApiOperation(value = "分管领导批示记录保存", notes = "分管领导批示记录保存")
    @PostMapping("/savePsjl")
    public AjaxResponse savePsjl(@RequestBody @Valid DbrwglPsjlUDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglCommBPO.savePsjl(dto);
        return ajaxResponse;
    }
    /**
     * 工作清单进展情况获取
     */
    @ApiOperation(value = "工作清单进展情况获取", notes = "工作清单进展情况获取")
    @PostMapping("/getGzqdjzqk")
    public AjaxResponse getGzqdjzqk(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", dbrwglCommBPO.getGzqdjzqk(dto));
        return ajaxResponse;
    }

    /**
     * 首页督办提醒
     * @param dto
     * @return
     */
    @ApiOperation(value = "首页督办提醒", notes = "首页督办提醒")
    @PostMapping(value = "/getDbtxList")
    public AjaxResponse getDbtxList(@RequestBody @Valid DbrwglDbrwclGzjzshQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwglCommBPO.getDbtxList(dto);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }

    /**
     * 督办评价协办评价信息获取
     */
    @ApiOperation(value = "督办评价协办评价信息获取", notes = "督办评价协办评价信息获取")
    @PostMapping("/getDbxbPjxx")
    public AjaxResponse getDbxbPjxx(@RequestBody @Valid DbrwglCommPjxxQueryDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", dbrwglCommBPO.getPjxx(dto.getRsdbgldbxmzrbmlsh()));
        return ajaxResponse;
    }

    /**
     * 督办评价协办评价信息保存
     */
    @ApiOperation(value = "督办评价协办评价信息保存", notes = "督办评价协办评价信息保存")
    @PostMapping("/saveDbxbPjxx")
    public AjaxResponse saveDbxbPjxx(@RequestBody @Valid DbrwglCommPjxxSaveDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglCommBPO.savePjxx(dto);
        return ajaxResponse;
    }
}
