package com.jpsoft.ehome.xml;

public class InputXmlSection {
    public static String getCardConfigXml(String cardNo){
        String inputXML = "<Params>\n" +
                "<ConfigCmd>GetCardCfg</ConfigCmd>\n" +
                "<ConfigParam1>" + cardNo + "</ConfigParam1>\n" +
                "<ConfigParam2>1</ConfigParam2>\n" +
                "<ConfigParam2>0</ConfigParam2>\n" +
                "<ConfigParam2>0</ConfigParam2>\n" +
                "</Params>";

        return inputXML;
    }

    /**
     * 设置卡参数
     * @param cardNo 卡号(32位)
     * @param valid  是否有效(1-有效，2-无效删除)
     * @param employeeNo 工号
     * @param name 姓名
     * @return
     */
    public static String setCardConfigXml(String cardNo,int valid,String employeeNo,String name){
        String inputXML = "<Params>\n" +
                "<ConfigCmd>SetCardCfg</ConfigCmd>\n" +
                "<ConfigParam1>"+ cardNo + "</ConfigParam1>\n" +
                "<ConfigParam2>1</ConfigParam2>\n" +
                "<ConfigParam3>0</ConfigParam3>\n" +
                "<ConfigParam4>0</ConfigParam4>\n" +
                "<ConfigXML>\n" +
                "<CardCfg>\n" +
                "<valid>"+ valid + "</valid>\n" +
                "<cardType>6</cardType>\n" +
                "<leaderCardEnabled>0</leaderCardEnabled>\n" +
                "<validTimeEnabled>1</validTimeEnabled>\n" +
                "<ValidTime>\n" +
                "<startTime>2000-01-01 00-00-00</startTime>\n" +
                "<endTime>2037-12-31 00-00-00</endTime>\n" +
                "</ValidTime>\n" +
                "<password>MTIzNDU2</password>\n" +
                "<maxSwipeTime>0</maxSwipeTime>\n" +
                "<swipeTime>0</swipeTime>\n" +
                "<groupNo></groupNo>\n" +
                "<roomNumber>0</roomNumber>\n" +
                "<name>" + name + "</name>\n" +
                "<SIMNum></SIMNum>\n" +
                "<employeeNo>"+ employeeNo + "</employeeNo>\n" +
                "<departmentNo>0</departmentNo>\n" +
                "<floorNumber>0</floorNumber>\n" +
                "</CardCfg>\n" +
                "</ConfigXML>\n" +
                "</Params>";

        return inputXML;
    }

    /**
     * 设置卡权限
     * @param cardNo 卡号
     * @return
     */
    public static String cardRightConfigXml(String cardNo){
        String inputXML = "<Params>\n" +
                "<ConfigCmd>SetCardRightCfg</ConfigCmd>\n" +
                "<ConfigParam1>" + cardNo + "</ConfigParam1>\n" +
                "<ConfigParam2>1</ConfigParam2>\n" +
                "<ConfigParam3>0</ConfigParam3>\n" +
                "<ConfigParam4>0</ConfigParam4>\n" +
                "<ConfigXML>\n" +
                "<CardRight>\n" +
                "<DoorRightList>\n" +
                "<DoorRight>\n" +
                "<doorNo>1</doorNo>\n" +
                "<planNo>1</planNo>\n" +
                "</DoorRight>\n" +
                "</DoorRightList>\n" +
                "</CardRight>\n" +
                "</ConfigXML>\n" +
                "</Params>";

        return inputXML;
    }

    /**
     * 设置人脸参数
     * @param cardNo
     * @param facePicUrl
     * @return
     */
    public static String faceParamCfgXml(String cardNo,String facePicUrl){
        String inputXML = "<SetFaceParamCfg version=\"2.0\" xmlns=\"http://www.isapi.org/ver20/XMLSchema\">\n" +
                "<cardNo>" +cardNo + "</cardNo>\n" +
                "<cardReaderNo>1</cardReaderNo>\n" +
                "<facePicUrl>" + facePicUrl + "</facePicUrl>\n" +
                "<faceID>1</faceID>\n" +
                "<faceDataType>1</faceDataType>\n" +
                "</SetFaceParamCfg>";

        return inputXML;
    }

    /**
     * 远程开门xml
     * @param doorNo
     * @param cmd 控制命令， Cmd 可以取值 OPEN,CLOSE,ALWAYSOPEN,ALWAYSCLOSE
     * @return
     */
    public static String remoteControlXml(String doorNo,String cmd){
        String inputXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<PPVSPMessage>\n" +
                "<Version>4.0</Version>\n" +
                "<Sequence>1</Sequence>\n" +
                "<CommandType>REQUEST</CommandType>\n" +
                "<Command>GATECONTROL</Command>\n" +
                "<Params>\n" +
                "<DoorNo>" + doorNo + "</DoorNo>\n" +
                "<Cmd>" + cmd + "</Cmd>\n" +
                "</Params>\n" +
                "</PPVSPMessage>";

        return inputXML;
    }

    /**
     * 获取设备网络配置
     * @return
     */
    public static String getNetParam(){
        String inputXML = "<Params>\n" +
                "<ConfigCmd>GetNetPara</ConfigCmd>\n" +
                "</Params>";

        return inputXML;
    }

    public static String rebootXml(){
        String inputXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<PPVSPMessage>\n" +
                "<Version>4.0</Version>\n" +
                "<Sequence>1</Sequence>\n" +
                "<CommandType>REQUEST</CommandType>\n" +
                "<Command>REBOOT</Command>\n" +
                "<Params>\n" +
                "</Params>\n" +
                "</PPVSPMessage>";

        return inputXML;
    }

    public static String updateServerConfigXml(String deviceNo,String ip,String port) {
        String inputXML = "<Params>\n" +
                "<ConfigCmd>SetCMSInfoPara</ConfigCmd>\n" +
                "<ConfigXML>\n" +
                "<CMSINFOPARA>\n" +
                "<CMSIP>" + ip + "</CMSIP>\n" +
                "<CMSPort>" + port + "</CMSPort>\n" +
                "<DeviceID>" + deviceNo + "</DeviceID>\n" +
                "</CMSINFOPARA>\n" +
                "</ConfigXML>\n" +
                "</Params>";

        return inputXML;
    }

    public static String getFaceParamConfigXml(String cardNo) {
        String inputXML = "<GetFaceParamCfgCond version=\"2.0\"\n" +
                "xmlns=\"http://www.isapi.org/ver20/XMLSchema\">\n" +
                "<cardNo>" + cardNo + "</cardNo>\n" +
                "<cardReaderNo>1</cardReaderNo>\n" +
                "<faceID>1</faceID >\n" +
                "</GetFaceParamCfgCond>";

        return inputXML;
    }
}
