package com.rongwei.savecheck.controller;


import com.rongwei.rwcommon.base.R;
import com.rongwei.rwcommon.utils.StringUtils;
import com.rongwei.sfcommon.sys.service.AspSafetyProductObjectiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 安全生产目标
 *
 * @author sc
 * @date 2023-12-07
 */
@RestController
@RequestMapping("aspSafetyProductObjective")
@Slf4j
public class AspSafetyProductObjectiveController {
    @Autowired
    private AspSafetyProductObjectiveService aspSafetyProductObjectiveService;

    /**
     * 安全生产目标定时任务（按季度生成指标的考核结果模板）
     *
     * @return
     */
    @PostMapping("/safetyResult")
    public R safetyResult() {
        try {
            aspSafetyProductObjectiveService.safetyResult();
            return R.ok();
        } catch (Exception e) {
            e.printStackTrace();
            log.error(StringUtils.spliceErrorMsg(e), e.fillInStackTrace());
            return R.error();
        }
    }

    /**
     * 安全观察指标提醒
     *
     * @param list 参数:key->id value->userId/安全观察值
     */
    @PostMapping("/reportObservationConfig")
    public void reportObservationConfig(@RequestBody List<String> list) {
        aspSafetyProductObjectiveService.reportObservationConfig(list);
    }
}
