package com.tofly.watermeter.custom.controller.meterBusiness;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.watermeter.custom.entity.Statistic;
import com.tofly.watermeter.custom.service.SbPlanService;
import com.tofly.watermeter.em.Constant;
import com.tofly.watermeter.em.ExcelExportFileTypeEnum;
import com.tofly.watermeter.entity.Bwkjzjpz;
import com.tofly.watermeter.entity.Qfkhjbxx;
import com.tofly.watermeter.strategy.ExcelStrategyContext;
import com.tofly.watermeter.util.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author FlashWJL
 * @date 2021/3/24 10:52
 */
@RestController
//@AllArgsConstructor
@RequestMapping("/sbPlan")
@Api(tags = "表务--水表周期计划")
public class SbPlanController {
    @Autowired
    private SbPlanService sbPlanService;


    @ApiOperation(value = "周期配置")
    @PostMapping("/sbzqConfig")
    public ResultRespone sbzqConfig(@RequestBody Bwkjzjpz bwkjzjpz) {
        return ResultRespone.success(sbPlanService.sbzqConfig(bwkjzjpz));
    }

    @ApiOperation(value = "获取周期配置")
    @GetMapping("/sbzqQuery")
    public ResultRespone sbzqQuery(Page<Bwkjzjpz> page) {
        return ResultRespone.success(sbPlanService.sbzqQuery(page));
    }


    @ApiOperation(value = "获取周期计划年月份")
    @GetMapping("/getYearMonth")
    public ResultRespone getYearMonth() {
        return ResultRespone.success(sbPlanService.getYearMonth());
    }


    @ApiOperation(value = "获取水表周期检查")
    @GetMapping("/getPlan")
    public ResultRespone getPlan(Page<Qfkhjbxx> page , Statistic statistic , HttpServletResponse response) {
        return ResultRespone.success(sbPlanService.getPlan(page, statistic , response));
    }

//    @ApiOperation(value = "周期检查计划详情")
//    @GetMapping("/getPlanInfo")
//    public ResultRespone getPlanInfo(Page page, String month , String sbcj , String sblx , String sbkj) {
//        return ResultRespone.success(sbPlanService.getPlanInfo(page, month,sbcj,sblx,sbkj));
//    }


    /**
     * 以下这里是需要调用计时器，任务调动，在每个月月初执行一次
     * 每月推算周检客户水表
     * @return
     */
    @ApiOperation(value = "推算周检水表")
    @PostMapping("/generateReckonZj")
    public ResultRespone generateReckonZj() {
        return ResultRespone.success(sbPlanService.generateReckonZj());
    }


}
