package com.diagbot.web;

import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.DataImportFacade;
import com.diagbot.vo.DataImportVO;
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 zhoutg
 * @time: 2024-04-27
 */
@RestController
@RequestMapping("/qc/dataimport")
@SuppressWarnings("unchecked")
@Api(value = "数据导入API", tags = { "数据导入API" })
public class DataImportController {

    @Autowired
    DataImportFacade dataImportFacade;

    @ApiOperation(value = "导入数据【全部删除，全部新增，效率高】[by:zhoutg]",
            notes = "// 医院ID\n" +
                    " Long hospitalId;\n" +
                    "// 病历信息\n" +
                    "List<BehospitalInfo> behospitalInfoList;\n" +
                    "// 危急值信息\n" +
                    "List<MedCrisisInfo> medCrisisInfoList;\n" +
                    "// 病人医嘱\n" +
                    "List<DoctorAdvice> doctorAdviceList;\n" +
                    "// 病案首页诊断\n" +
                    "List<HomeDiagnoseInfo> homeDiagnoseInfoList;\n" +
                    "// 病案首页\n" +
                    "List<HomePage> homePageList;\n" +
                    "// 病案首页手术信息\n" +
                    "List<HomeOperationInfo> homeOperationInfoList;\n" +
                    "// 文书信息\n" +
                    "List<MedicalRecord> medicalRecordList;\n" +
                    "// 文书明细信息\n" +
                    "List<MedicalRecordContent> medicalRecordContentList;")
    @PostMapping("/import")
    @SysLogger("import")
    @Transactional
    public RespDTO<Boolean> dataimport(@RequestBody @Valid DataImportVO dataImportVO) {
        Boolean data = dataImportFacade.dataImportFacade(dataImportVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "导入数据【更新数据，单条执行，效率低，备用】[by:zhoutg]",
            notes = "// 医院ID\n" +
                    " Long hospitalId;\n" +
                    "// 病历信息\n" +
                    "List<BehospitalInfo> behospitalInfoList;\n" +
                    "// 危急值信息\n" +
                    "List<MedCrisisInfo> medCrisisInfoList;\n" +
                    "// 病人医嘱\n" +
                    "List<DoctorAdvice> doctorAdviceList;\n" +
                    "// 病案首页诊断\n" +
                    "List<HomeDiagnoseInfo> homeDiagnoseInfoList;\n" +
                    "// 病案首页\n" +
                    "List<HomePage> homePageList;\n" +
                    "// 病案首页手术信息\n" +
                    "List<HomeOperationInfo> homeOperationInfoList;\n" +
                    "// 文书信息\n" +
                    "List<MedicalRecord> medicalRecordList;\n" +
                    "// 文书明细信息\n" +
                    "List<MedicalRecordContent> medicalRecordContentList;")
    @PostMapping("/dataimportPrepare")
    @SysLogger("dataimportPrepare")
    @Transactional
    public RespDTO<Boolean> dataimportPrepare(@RequestBody @Valid DataImportVO dataImportVO) {
        Boolean data = dataImportFacade.dataImportPrepareFacade(dataImportVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "模拟测试数据[by:zhoutg]",
            notes = "")
    @PostMapping("/test")
    @SysLogger("test")
    @Transactional
    public RespDTO<Boolean> test() {
        Boolean data = dataImportFacade.test();
        return RespDTO.onSuc(data);
    }

}
