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.DbrwclBPO;
import com.zjrs.zwnw.dbgl.bpo.DbrwglBPO;
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;

@Api("督办任务处理")
@RestController
@RequestMapping("/api/dbrwgl/dbrwcl")
public class DbrwclController {

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

    @Resource
    private DbrwclBPO dbrwclBPO;
    @Resource
    private CommonBPO commBPO;
    @Resource
    private DbrwglBPO dbrwglBPO;
    @Resource
    private GzqdglBPO gzqdglBPO;
/*
工作清单分配列表	getGzqdffList
督办任务列表根据项目ID  getDbrwListByXmid
项目信息获取    getXmxxById
工作清单信息列表根据项目ID	getGzqdListByXmid
分配工作清单    updateFfgzdq
工作清单信息删除	delGzqd
工作清单选择列表	getGzqdxzList
工作清单选择	updateGzqdXz
工作进展审核列表	getGzjzshList
工作进展审核信息获取  getGzjzshxxByQdid
工作进展审核批量审核并评价	updateGzqdshBatch
工作进展审核并评价	updateGzqdsh
*/
    /**
     * 工作清单分配列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "工作清单分配列表", notes = "工作清单分配列表")
    @PostMapping(value = "/getGzqdffList")
    public AjaxResponse getGzqdffList(@RequestBody @Valid DbrwglDbrwclQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwclBPO.getGzqdffList(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }

    /**
     * 督办任务列表根据项目ID
     * @param dto
     * @return
     */
    @ApiOperation(value = "督办任务列表根据项目ID", notes = "督办任务列表根据项目ID")
    @PostMapping(value = "/getDbrwListByXmid")
    public AjaxResponse getDbrwListByXmid(@RequestBody @Valid DbrwglCommQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwclBPO.getDbrwListByXmid(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        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;
    }
    /**
     * 工作清单信息列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "工作清单信息列表", notes = "工作清单信息列表")
    @PostMapping(value = "/getGzqdListByXmid")
    public AjaxResponse getGzqdListByXmid(@RequestBody @Valid DbrwglCommQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwclBPO.getGzqdListByXmid(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }

    /**
     * 分配工作清单
     */
    @ApiOperation(value = "分配工作清单", notes = "分配工作清单")
    @PostMapping("/updateFfgzdq")
    public AjaxResponse updateFfgzdq(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwclBPO.updateFfgzdq(dto);
        return ajaxResponse;
    }

    /**
     * 工作清单信息删除
     */
    @ApiOperation(value = "工作清单信息删除", notes = "工作清单信息删除")
    @PostMapping("/delGzqd")
    public AjaxResponse delGzqd(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwclBPO.delGzqd(dto);
        return ajaxResponse;
    }

    /**
     * 工作清单选择列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "工作清单选择列表", notes = "工作清单选择列表")
    @PostMapping(value = "/getGzqdxzList")
    public AjaxResponse getGzqdxzList(@RequestBody @Valid DbrwglGzqdglQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = gzqdglBPO.getGzqdglList(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }

    /**
     * 工作清单选择
     */
    @ApiOperation(value = "工作清单选择", notes = "工作清单选择")
    @PostMapping("/updateGzqdXz")
    public AjaxResponse updateGzqdXz(@RequestBody @Valid DbrwglDbrwclGzqdxzDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwclBPO.updateGzqdXz(dto);
        return ajaxResponse;
    }
    /**
     * 工作进展审核列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "工作进展审核列表", notes = "工作进展审核列表")
    @PostMapping(value = "/getGzjzshList")
    public AjaxResponse getGzjzshList(@RequestBody @Valid DbrwglDbrwclGzjzshQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();

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

    /**
     * 工作进展审核批量审核并评价
     */
    @ApiOperation(value = "工作进展审核批量审核并评价", notes = "工作进展审核批量审核并评价")
    @PostMapping("/updateGzqdshBatch")
    public AjaxResponse updateGzqdshBatch(@RequestBody @Valid DbrwglGzqdBatchShDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwclBPO.updateGzqdshBatch(dto);
        return ajaxResponse;
    }

    /**
     * 工作进展审核并评价
     */
    @ApiOperation(value = "工作进展审核并评价", notes = "工作进展审核并评价")
    @PostMapping("/updateGzqdsh")
    public AjaxResponse updateGzqdsh(@RequestBody @Valid DbrwglGzqdShDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwclBPO.updateGzqdsh(dto);
        return ajaxResponse;
    }
    /**
     * 工作进展审核信息获取
     */
    @ApiOperation(value = "工作进展审核信息获取", notes = "工作进展审核信息获取")
    @PostMapping("/getGzjzshxxByQdid")
    public AjaxResponse getGzjzshxxByQdid(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", gzqdglBPO.getGzqdById(dto));
        return ajaxResponse;
    }


}
