package com.saye.hospitalgd.scheduler.job;

import com.saye.hospitalgd.commons.getBean.GetBeanUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.scheduler.jobMethod.HISGetDataMethodByHY;
import com.saye.hospitalgd.scheduler.jobMethod.HISGetDataMethodByJH;
import com.saye.hospitalgd.scheduler.jobMethod.HISGetDataMethodByWN;
import com.saye.hospitalgd.scheduler.jobMethod.HISGetDataMethodByZL;
import com.saye.hospitalgd.service.system.ServiceParamsService;
import com.saye.hospitalgd.service.system.impl.ServiceParamsServiceImpl;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.HashMap;
import java.util.List;

/**
 * @author thuang
 * @version 1.0
 * @description: HIS系统获取对账数据
 * @date 2021/8/30 15:27
 */
public class HISGetData implements Job {


    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        String id = StringDUtil.changeNullToEmpty(jobDataMap.get("id"));
        String name = StringDUtil.changeNullToEmpty(jobDataMap.get("name"));
        String trade_date="";
        System.out.println("/****************************定时任务["+name+"]开始执行*********************************/");

        ServiceParamsService serviceParamsService= GetBeanUtil.getBean(ServiceParamsServiceImpl.class);

        //先判断使用的是哪家his系统
        //his对应供应商
        List<HashMap<Object, Object>> serviceParams = serviceParamsService.findParamValByParamCode("his_wsdl_id");
        String his_wsdl_id = StringDUtil.changeNullToEmpty(serviceParams.get(0).get("PARAM_VAL"));

        if ("1".equals(his_wsdl_id)){
            new HISGetDataMethodByZL().getDate(id,name,trade_date,his_wsdl_id);
        }else if ("2".equals(his_wsdl_id)){
            new HISGetDataMethodByWN().getDate(id,name,trade_date,his_wsdl_id);
        }else if ("3".equals(his_wsdl_id)) {
            new HISGetDataMethodByHY().getDate(id,name,trade_date,his_wsdl_id);
        }else if ("4".equals(his_wsdl_id)){
            new HISGetDataMethodByJH().getDate(id,name,trade_date,his_wsdl_id);
        }
        System.out.println("/****************************定时任务["+name+"]执行结束*********************************/");
    }
}
