package com.diagbot.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.QcAbnormalDTO;
import com.diagbot.dto.QcAbnormalModeDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.QcAbnormalFacade;
import com.diagbot.vo.QcAbnormalDelVO;
import com.diagbot.vo.QcAbnormalModeVO;
import com.diagbot.vo.QcAbnormalSaveVO;
import com.diagbot.vo.QcAbnormalVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 异常数据监控信息 前端控制器
 * </p>
 *
 * @author gaodm
 * @since 2020-05-15
 */
@RequestMapping("/qc/abnormal")
@RestController
@Api(value = "异常数据监控相关API", tags = { "异常数据监控相关API" })
@SuppressWarnings("unchecked")
public class QcAbnormalController {
    @Autowired
    private QcAbnormalFacade qcAbnormalFacade;

    @ApiOperation(value = "查询异常数据监控信息[by:gaodm]",
            notes = "behospitalCode: 病人住院ID<br>" +
                    "type: 异常类型(1:数据模块 2：质控类型 3：XML结构)<br>" +
                    "status: 状态(0:未处理，1：已处理)<br>" +
                    "statisticsType: 统计维度 1-本月，2-本年<br>")
    @PostMapping("/getQcAnnormal")
    @SysLogger("getQcAnnormal")
    public RespDTO<IPage<QcAbnormalDTO>> getQcAnnormal(@RequestBody QcAbnormalVO qcAbnormalVO) {
        return RespDTO.onSuc(qcAbnormalFacade.getQcAnnormalFac(qcAbnormalVO));
    }

    @ApiOperation(value = "更新异常数据监控信息[by:gaodm]",
            notes = "id: 异常数据监控ID<br>" +
                    "status: 状态(0:未处理，1：已处理)<br>" +
                    "remark: 备注<br>")
    @PostMapping("/saveQcAnnormal")
    @SysLogger("saveQcAnnormal")
    @Transactional
    public RespDTO<Boolean> saveQcAnnormal(@RequestBody @Valid QcAbnormalSaveVO qcAbnormalSaveVO) {
        return RespDTO.onSuc(qcAbnormalFacade.saveQcAnnormal(qcAbnormalSaveVO));
    }

    @ApiOperation(value = "删除异常数据监控信息[by:gaodm]",
            notes = "id: 异常数据监控ID<br>")
    @PostMapping("/delQcAnnormal")
    @SysLogger("delQcAnnormal")
    @Transactional
    public RespDTO<Boolean> delQcAnnormal(@RequestBody @Valid QcAbnormalDelVO qcAbnormalDelVO) {
        return RespDTO.onSuc(qcAbnormalFacade.delQcAnnormal(qcAbnormalDelVO));
    }

    @ApiOperation(value = "根据id查询数据模块信息[by:wangfeng]",
            notes = "description: 异常说明"
                    )
    @PostMapping("/getQcAnnormalMode")
    @SysLogger("getQcAnnormalMode")
    public RespDTO<QcAbnormalModeDTO> getQcAnnormalMode(@RequestBody @Valid QcAbnormalModeVO qcAbnormalModeVO) {
        return RespDTO.onSuc(qcAbnormalFacade.getQcAnnormalMode(qcAbnormalModeVO));
    }
}