package com.docus.server.message.service;

import com.docus.server.message.consts.HospitalWsMethod;
import com.docus.server.message.util.XmlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.w3c.dom.Node;

/**
 * @author WYBDEV
 */
@Service
public class FsSyWebServiceUnifyMessageServiceImpl implements  FsSyWebServiceUnifyMessageService{

    private UnifyMessageService unifyMessageService;

    @Autowired
    public void setUnifyMessageService(UnifyMessageService unifyMessageService) {
        this.unifyMessageService = unifyMessageService;
    }

    @Override
    public String pushInformation(String message) {
        String methodNamePath="/Request/Header/MethodName";
        String methodName;
        try {
            XmlUtil xmlUtil = XmlUtil.of(message);
            Node node = xmlUtil.getNode(methodNamePath);
            methodName = node.getTextContent();
        }catch (Exception ex){
            return "获取方法名出错："+methodNamePath;
        }

        if("AddDepts".equals(methodName)){
            return unifyMessageService.pushInformation(HospitalWsMethod.WS_FSSY_DEPT,message);
        }
        if("AddUsers".equals(methodName)){
            return unifyMessageService.pushInformation(HospitalWsMethod.WS_FSSY_USER,message);
        }
        return "未对接方法"+methodName+"，请联系开发人员！";
    }


}
