package cn.cecep.talroad.task;

import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.data.analyse.task.execute.report.specifications.PollutionPreventionAndControlFacilitiesService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "污染防治设施")
@RestController
@RequestMapping("/pollutant/prevention")
@Slf4j
@AllArgsConstructor
public class PollutionPreventionAndControlFacilitiesController {

    private final PollutionPreventionAndControlFacilitiesService pollutionPreventionAndControlFacilitiesService;

    /**
     * 定时更新 污染防治设施正常情况汇总表--废水污染防治设施
     */
    @GetMapping("/normal/sewage/process")
    public AjaxResults<Void> normalSewageProcess() {
        try {
            pollutionPreventionAndControlFacilitiesService.normalSewageProcess();
            return AjaxResults.success();
        } catch (Exception e) {
            log.error("定时执行污染防治设施正常情况汇总表--废水污染防治设施任务失败. 原因:{}", e.getMessage(), e);
            return AjaxResults.error();
        }
    }

    /**
     * 定时更新 污染防治设施异常情况汇总表
     */
    @GetMapping("/abnormal/circumstance/process")
    public AjaxResults<Void> abnormalCircumstanceProcess() {
        try {
            pollutionPreventionAndControlFacilitiesService.abnormalCircumstanceProcess();
            return AjaxResults.success();
        } catch (Exception e) {
            log.error("定时执行污染防治设施异常情况汇总 任务失败. 原因:{}", e.getMessage(), e);
            return AjaxResults.error();
        }
    }

}
