package com.docus.server.ydzyy.controller;


import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.archive.entity.TBasic;
import com.docus.server.archive.mapper.TBasicMapper;
import com.docus.server.rpc.YdZyyPacsService;
import com.docus.server.ydzyy.job.PacsCollectJob;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * api测试类
 */
@RestController
@RequestMapping("/ydzyyApi")
@Api(tags = "英德中医院文件采集接口")
public class ApiController {
    @Autowired
    private YdZyyPacsService pacsService;
    @Autowired
    private PacsCollectJob pacsCollectJob;
    @Autowired
    private TBasicMapper tBasicMapper;

    /**
     * 测试
     */
    @GetMapping("/pacs/xml")
    @ApiOperation("pacs接口测试")
    public CommonResult<String> lisXmlTest(@RequestParam(name = "remark") String remark) {
        String base64 = pacsService.getJpgReportBase64(remark);
        return CommonResult.success(base64);
    }

    /**
     * 补采
     */
    @PostMapping("/pacs/collect")
    @ApiOperation("pacs采集")
    public CommonResult<String> collectPacs(@RequestBody List<String> patientIds) {
        List<TBasic> basics = tBasicMapper.getTbasicByPatientIds(patientIds);
        for (TBasic basic : basics) {
            pacsCollectJob.collectPacs(basic, false);
        }
        return CommonResult.success("采集完成");
    }
}
