package com.rongwei.savecheck.controller;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rongwei.rwcommon.base.R;
import com.rongwei.sfcommon.sys.service.AspSafetyDrillProgrammeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>
 * 安全应急-演练方案 前端控制器
 * </p>
 *
 * @author wm
 * @since 2023-11-13
 */
@RestController
@RequestMapping("/asp/safety/drill")
public class AspSafetyDrillProgrammeController {

    @Autowired
    private AspSafetyDrillProgrammeService aspSafetyDrillProgrammeService;

    /**
     * 发布演练方案
     *
     * @return
     */
    @PostMapping("/publish")
    public R publish() {
        aspSafetyDrillProgrammeService.publish();
        return R.ok();
    }

    /**
     * 发布演练方案
     *
     * @return
     */
    @PostMapping("/notify3DayAndNow")
    public R notify3DayAndNow() {
        aspSafetyDrillProgrammeService.notify3Day();
        return R.ok();
    }

    /**
     * 发布演练方案
     *
     * @return
     */
    @PostMapping("/notify")
    public R notify(@RequestBody Map<String, String> map) {
        aspSafetyDrillProgrammeService.sendMsg(map.get("id"));
        return R.ok();
    }

    /**
     * 发布演练方案
     *
     * @return
     */
    @PostMapping("/notifyNow")
    public R notifyNow() {
        aspSafetyDrillProgrammeService.notifyCurrentDay();
        return R.ok();
    }

    /**
     * 导出综合或专项应急演练计划WORD
     */
    @PostMapping("/exportEmergencyDrillPlanWord")
    public void exportEmergencyDrillPlanWord(@RequestParam String startDate,
                                             @RequestParam String endDate,
                                             HttpServletResponse response) throws Exception {
        aspSafetyDrillProgrammeService.exportEmergencyDrillPlanWord(startDate, endDate, response);
    }

    /**
     * 导出年度演练计划WORD
     */
    @PostMapping("/exportAnnualDrillPlanWord")
    public void exportAnnualDrillPlanWord(@RequestParam String id,
                                          HttpServletResponse response) throws Exception {
        aspSafetyDrillProgrammeService.exportAnnualDrillPlanWord(id, response);
    }

    /**
     * 导出演练方案
     */
    @PostMapping("/exportDrillProgramme")
    public void exportDrillProgramme(@RequestParam String id, HttpServletResponse response) throws Exception {
        aspSafetyDrillProgrammeService.exportDrillProgramme(id, response);
    }
}

