package com.docus.server.archive.rpc.impl;

import com.alibaba.fastjson.JSONObject;
import com.docus.infrastructure.core.utils.TableJsonRead;
import com.docus.server.archive.rpc.GzZxyJhBasicDataService;
import com.docus.server.archive.rpc.dto.HisSqlInPatient01Dto;
import com.docus.server.archive.utils.JaxWsDynamicClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author YongBin Wen
 * @date 2024/8/23 13:58
 */
@Component
@Slf4j
public class GzZxyJhBasicDataServiceImpl implements GzZxyJhBasicDataService {

    @Override
    public String getHisSqlInPatient01(HisSqlInPatient01Dto hisSqlInPatient01Dto) {
        String jobConfigPath = "data-config\\job-config";
        String jobConfigName = "GzZxyJhQcPatientInfoSyncJob.json";
        TableJsonRead jsonReader = new TableJsonRead();
        JSONObject syncJobConfig = jsonReader.Read(jobConfigPath, jobConfigName, JSONObject.class);
        String url = syncJobConfig.getString("url");
        String namespaceUri = syncJobConfig.getString("namespaceUri");
        String operationName = syncJobConfig.getString("operationName");
        String param1 = syncJobConfig.getString("param");
        String param2 = JSONObject.toJSONString(hisSqlInPatient01Dto);
        String[] params = {param1, param2};
        String result = JaxWsDynamicClientUtil.send(url, namespaceUri, operationName, params);
        log.info("广州中西医结合查询基础数据参数 {} 获取数据：{}", param2, result);
        return result;
    }
}
