package com.docus.server.report.controller;

import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.report.api.ShunDePeopleService;
import com.docus.server.report.api.TaskDistributeService;
import com.docus.server.report.api.dto.SdNurDocFailRequest;
import com.docus.server.report.api.dto.SdNurseInsertSugarRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "API 测试接口")
@RestController
@RequestMapping("/api/test")
public class ApiTestController {
    @Resource
    private TaskDistributeService taskDistributeService;
    @Resource
    private ShunDePeopleService shunDePeopleService;

    @ApiOperation(value = "获取pacs Pdf")
    @GetMapping("/pacsBase64Test")
    public CommonResult<Object> pacsBase64Test(@Param("examNo") String examNo, @Param("reportNo") String reportNo) {
        return CommonResult.success(shunDePeopleService.getBase64PdfFromPacs(examNo, reportNo));
    }

    @ApiOperation(value = "移动护理报告接口测试")
    @GetMapping("/nurseInsertSugarTest")
    public CommonResult<Object> nurseInsertSugarTest(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") String admissTimes) {
        final String traceCode = "nurse_print_doc";
        SdNurseInsertSugarRequest sdNurseInsertSugarRequest = new SdNurseInsertSugarRequest(inpatientNo, admissTimes, traceCode);
        return CommonResult.success(shunDePeopleService.getNurseInsertSugarReport(sdNurseInsertSugarRequest));
    }
    @ApiOperation(value = "移动护理报告推送错误接口测试")
    @GetMapping("/nisPushErrTest")
    public CommonResult<Object> nisPushErrTest(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") String admissTimes,@Param("errorCode") String errorCode,@Param("errMsg") String errMsg) {
        final String traceCode = "nurse_doc_fail";
        SdNurDocFailRequest failRequest = new SdNurDocFailRequest(inpatientNo,admissTimes,traceCode,errorCode,errMsg);
        return CommonResult.success(shunDePeopleService.pushSdNurDocFail(failRequest));
    }

    @ApiOperation(value = "获取任务测试")
    @PostMapping("/getTaskTest")
    public CommonResult<Object> getTaskTest(@RequestParam("collectorId") String collectorId) {
        return CommonResult.success(taskDistributeService.getNoViewTaskByCollectorId(collectorId));
    }

    @ApiOperation(value = "作废任务测试")
    @PostMapping("/cancelTaskTest")
    public CommonResult<Object> getTaskTest(@RequestParam("taskId") Long taskId) {
        return CommonResult.success(taskDistributeService.cancel(taskId));
    }


}
