package com.joju.datamanager.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.joju.datamanager.service.TriageCallingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @description: 分诊叫号业务实现类
 * @author: Mr.zs
 * @create: 2024-03-29 16:22
 **/
@Service
@Slf4j
public class TriageCallingServiceImpl implements TriageCallingService {

    private static final String DATA_GET_URL = "http://168.168.0.37:5053";


    @Override
    public List<String> getTriageCallingByDate() {
        List<String> patients = null;
        String result = HttpUtil.get(DATA_GET_URL + "/HospitalCallApi/GetDailyPatientName?a=n");
        JSONObject resultJson = JSONUtil.parseObj(result);
        if (Convert.toStr(resultJson.get("State")).equals("True")) {//响应成功
            Object resData = resultJson.get("Result");//字符串
            String str = Convert.toStr(resData);
            String[] split = str.split(",");
            patients = Arrays.asList(split);
        }
        return patients;
    }
}
