package com.ningdatech.pmapi.safety.controller;

import com.alibaba.fastjson.JSONObject;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.safety.manage.SafetyRiskManage;
import com.ningdatech.pmapi.safety.model.dto.PersonSafetyInfoDTO;
import com.ningdatech.pmapi.safety.model.dto.SupplierSafetyQualificationDTO;
import com.ningdatech.pmapi.safety.model.vo.ProjectMonitorVO;
import com.ningdatech.pmapi.safety.model.vo.SafetyMonitorVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Classname SafetyRiskController
 * @Description
 * @Date 2023/8/2 9:15
 * @Author PoffyZhang
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "安全风险监测")
@RequestMapping("/api/v1/safety-risk")
public class SafetyRiskController {

    private final SafetyRiskManage safetyRiskManage;

    @GetMapping("/person-monitor/list")
    @ApiOperation("安全人员监控列表")
    public PageVo<ProjectMonitorVO> personMonitorList(ProjectListReq req) {
        return safetyRiskManage.personMonitorList(req);
    }

    @PostMapping("/person-monitor/save")
    @ApiOperation("安全人员监控信息保存")
    @WebLog("安全人员监控信息保存")
    public String personMonitorSave(@Valid @RequestBody List<PersonSafetyInfoDTO> dtos) {
        return safetyRiskManage.personMonitorSave(dtos);
    }

    @PostMapping("/supplier-safety-qualification/save")
    @ApiOperation("供应商安全资质保存")
    @WebLog("供应商安全资质保存")
    public String supplierSafetyQualificationSave(@Valid @RequestBody List<SupplierSafetyQualificationDTO> dtos) {
        return safetyRiskManage.supplierSafetyQualificationSave(dtos);
    }

    @GetMapping("/detail/{projectCode}")
    @ApiOperation("安全人员管控详情")
    public SafetyMonitorVO personMonitorDetail(@PathVariable String projectCode) {
        return safetyRiskManage.personMonitorDetail(projectCode);
    }

    @GetMapping("/operation-monitor/search/{projectCode}")
    @ApiOperation("安全运行监控-查询监测(对接外部平台)")
    public JSONObject operationnMonitorList(@PathVariable String projectCode) {
        return safetyRiskManage.operationnMonitorSearch(projectCode);
    }
}
