package com.ann.demo.interfaces.impl;

import com.ann.demo.entity.constant.InterfaceName;
import com.ann.demo.entity.constant.WebserviceId;
import com.ann.demo.entity.interfaceEntity.ExamApply;
import com.ann.demo.interfaces.HomepageDictionary;
import com.ann.demo.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.jws.WebService;

/**
 * @Author: LeiJiaXin
 * @Date: 2019/6/11 17:01
 */

@WebService(serviceName = "HomepageDictionary", // 与接口中指定的name一致
        targetNamespace = "http://interfaces.demo.ann.com/", // 与接口中的命名空间一致,一般是接口的包名倒
        endpointInterface = "com.ann.demo.interfaces.HomepageDictionary"// 接口地址
)
public class HomepageDictionaryImpl implements HomepageDictionary {

    private static final Logger logger = LoggerFactory.getLogger(HomepageDictionaryImpl.class);

    @Autowired
    private AnalysisService analysisService;

    @Override
    public String HIPMessageServer(String action, String message) {
        String result = "";
        try {
            if (action != null && message != null && !(message.equals("") && action.equals(""))) {
                switch (action) {
                    case InterfaceName.PARAMETER_REPORT:
                        // 检查报告
                        result = analysisService.getHIPMessageServerResult(message, null, InterfaceName.PARAMETER_REPORT, WebserviceId.PARAMETER_REPORT);
                        break;
                    case InterfaceName.PARAMETER_EXAMAPPLY:
                        // 检查申请单
                        result = analysisService.getHIPMessageServerResult(message, ExamApply.class, InterfaceName.PARAMETER_EXAMAPPLY,WebserviceId.PARAMETER_EXAMAPPLY);
                        break;
                    case InterfaceName.PARAMETER_EXAMAPPLYSTATECHANGE:
                        // 检查申请单 是否开立
                        result = analysisService.getHIPMessageServerResult(message, ExamApply.class, InterfaceName.PARAMETER_EXAMAPPLYSTATECHANGE,WebserviceId.PARAMETER_EXAMAPPLYSTATECHANGE);
                        break;
                    case InterfaceName.PARAMETER_VERIFICATIONEXAMAPPLY:
                        // 检查申请单 是否核收
                        result = analysisService.getHIPMessageServerResult(message, ExamApply.class, InterfaceName.PARAMETER_VERIFICATIONEXAMAPPLY,WebserviceId.PARAMETER_VERIFICATIONEXAMAPPLY);
                        break;
                }
            }
        }catch (Exception e){
            logger.error("出错咯！错误信息为{}，以及错误行数为:{}" ,e,e.getStackTrace()[0]);
        }
        return result;
    }

}
