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.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;

@Api("督办任务管理")
@RestController
@RequestMapping("/api/dbrwgl/dbrwgl")
public class DbrwglController {

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

    @Resource
    private DbrwglBPO dbrwglBPO;
    @Resource
    private CommonBPO commBPO;
/*
督办任务管理列表	getDbrwList
督办任务派发取消派发	updateDbrwPf
督办任务结束	updateDbrwJs
督办任务删除	deleteDbrwById
督办任务保存	saveDbrw
督办任务评价保存	saveDbrwpj
督办任务信息获取	getDbrwxxById    --公共
项目信息列表	getXmxxList          --公共
项目信息保存	saveXmxx
项目信息删除	delXmxx
项目信息牵头部门获取    getXmxxQtbmByXmid
项目信息协办部门获取    getXmxxXbbmByXmid
项目信息牵头部门保存	saveXmxxQtbm
项目信息协办部门保存	saveXmxxXbbm
项目信息获取 getXmxxById
项目信息督办评介信息保存 saveXmxxDbpj  --20230524
*/

    /**
     * 督办任务管理列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "督办任务管理列表", notes = "督办任务管理列表")
    @PostMapping(value = "/getDbrwList")
    public AjaxResponse getDbrwList(@RequestBody @Valid DbrwglDbrwQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwglBPO.getDbrwList(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }

    /**
     * 督办任务保存
     */
    @ApiOperation(value = "督办任务保存", notes = "督办任务保存")
    @PostMapping("/saveDbrw")
    public AjaxResponse saveDbrw(@RequestBody @Valid DbrwglDbrwUDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("rsdbgldbrwlsh", dbrwglBPO.saveDbrw(dto));
        return ajaxResponse;
    }

    /**
     * 督办任务派发取消派发
     */
    @ApiOperation(value = "督办任务派发取消派发", notes = "督办任务派发取消派发")
    @PostMapping("/updateDbrwPf")
    public AjaxResponse updateDbrwPf(@RequestBody @Valid DbrwglDbrwCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.updateDbrwPf(dto);
        return ajaxResponse;
    }

    /**
     * 督办任务结束
     */
    @ApiOperation(value = "督办任务结束", notes = "督办任务结束")
    @PostMapping("/updateDbrwJs")
    public AjaxResponse updateDbrwJs(@RequestBody @Valid DbrwglDbrwCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.updateDbrwJs(dto);
        return ajaxResponse;
    }
    /**
     * 督办任务删除
     */
    @ApiOperation(value = "督办任务删除", notes = "督办任务删除")
    @PostMapping("/deleteDbrwById")
    public AjaxResponse deleteDbrwById(@RequestBody @Valid DbrwglDbrwCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.deleteDbrwById(dto);
        return ajaxResponse;
    }

    /**
     * 督办任务评价保存
     */
    @ApiOperation(value = "督办任务评价保存", notes = "督办任务评价保存")
    @PostMapping("/saveDbrwpj")
    public AjaxResponse saveDbrwpj(@RequestBody @Valid DbrwglDbrwUPjDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.saveDbrwpj(dto);
        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("/saveXmxx")
    public AjaxResponse saveXmxx(@RequestBody @Valid DbrwglXmxxSaveDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.saveXmxx(dto);
        return ajaxResponse;
    }

    /**
     * 项目信息删除
     */
    @ApiOperation(value = "项目信息删除", notes = "项目信息删除")
    @PostMapping("/delXmxx")
    public AjaxResponse delXmxx(@RequestBody @Valid DbrwglXmxxCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.delXmxx(dto);
        return ajaxResponse;
    }

    /**
     * 项目信息牵头部门保存
     */
    @ApiOperation(value = "项目信息牵头部门保存", notes = "项目信息牵头部门保存")
    @PostMapping("/saveXmxxQtbm")
    public AjaxResponse saveXmxxQtbm(@RequestBody @Valid DbrwglXmxxCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.saveXmxxQtbm(dto);
        return ajaxResponse;
    }
    /**
     * 项目信息协办部门保存
     */
    @ApiOperation(value = "项目信息协办部门保存", notes = "项目信息协办部门保存")
    @PostMapping("/saveXmxxXbbm")
    public AjaxResponse saveXmxxXbbm(@RequestBody @Valid DbrwglXmxxCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwglBPO.saveXmxxXbbm(dto);
        return ajaxResponse;
    }

    /**
     * 项目信息获取
     */
    @ApiOperation(value = "项目信息获取", notes = "项目信息获取")
    @PostMapping("/getXmxxById")
    public AjaxResponse getXmxxById(@RequestBody @Valid DbrwglXmxxCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", dbrwglBPO.getXmxxById(dto));
        return ajaxResponse;
    }

    /**
     * 项目信息牵头部门获取
     */
    @ApiOperation(value = "项目信息牵头部门获取", notes = "项目信息牵头部门获取")
    @PostMapping("/getXmxxQtbmByXmid")
    public AjaxResponse getXmxxQtbmByXmid(@RequestBody @Valid DbrwglXmxxCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", dbrwglBPO.getXmxxQtbmByXmid(dto));
        return ajaxResponse;
    }

    /**
     * 项目信息协办部门获取
     */
    @ApiOperation(value = "项目信息协办部门获取", notes = "项目信息协办部门获取")
    @PostMapping("/getXmxxXbbmByXmid")
    public AjaxResponse getXmxxXbbmByXmid(@RequestBody @Valid DbrwglXmxxCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", dbrwglBPO.getXmxxXbbmByXmid(dto));
        return ajaxResponse;
    }

}
