BeihuoTests.java 5.2 KB
package com.sy;

import com.sy.bwAnalysis.AnalysisRoute;
import com.sy.logic.LiftBar;
import com.sy.utils.XMLThreadPoolFactory;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@RunWith(SpringRunner.class)
@SpringBootTest
public class BeihuoTests {


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

    private static ThreadPoolExecutor threadPoolEs = XMLThreadPoolFactory.instance("kakou");
    private AnalysisRoute analysisRoute=new AnalysisRoute();

    //车牌号
    private String voNo = "豫A61CR7";
    //备案重量
    private String vo_weight = "2000";
    //过卡重量
    private String cross_weight= "2324";
    //场站编号
    private String areaID = "4604600000";
    //通道编号
    private String chnlNo = "4604601010";
    //进出场类型I/E
    private String ie = "I";
    //二维码
    private String barcode = "613f5c";



    //进通道报文
    private static String IMPORT_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<MSG>\n" +
            "\t<META>\n" +
            "\t\t<SNDR>KAO</SNDR>\n" +
            "\t\t<RCVR/>\n" +
            "\t\t<SEQN>20220624063157</SEQN>\n" +
            "\t\t<DDTM>20220624063157</DDTM>\n" +
            "\t\t<TYPE>KAKO</TYPE>\n" +
            "\t\t<STYP>CARM</STYP>\n" +
            "\t</META>\n" +
            "\t<GATHER_INFO AREA_ID=\"${areaID}\" CHNL_NO=\"${chnlNo}\" I_E_TYPE=\"${IETYPE}\" SEQ_NO=\"20220624063118000004\">\n" +
            "\t\t<IC>\n" +
            "\t\t\t<DR_IC_NO/>\n" +
            "\t\t\t<IC_DR_CUSTOMS_NO/>\n" +
            "\t\t\t<IC_CO_CUSTOMS_NO/>\n" +
            "\t\t\t<IC_BILL_NO/>\n" +
            "\t\t\t<IC_FORM_TYPE/>\n" +
            "\t\t\t<IC_GROSS_WT/>\n" +
            "\t\t\t<IC_VE_CUSTOMS_NO/>\n" +
            "\t\t\t<IC_VE_NAME/>\n" +
            "\t\t\t<IC_CONTA_ID/>\n" +
            "\t\t\t<IC_ESEAL_ID/>\n" +
            "\t\t\t<IC_REG_DATETIME/>\n" +
            "\t\t\t<IC_PER_DAY_DUE/>\n" +
            "\t\t\t<GPS_ID/>\n" +
            "\t\t</IC>\n" +
            "\t\t<WEIGHT>\n" +
            "\t\t\t<GROSS_WT>${cross_weight}</GROSS_WT>\n" +
            "\t\t</WEIGHT>\n" +
            "\t\t<CAR>\n" +
            "\t\t\t<VE_NAME>${car}</VE_NAME>\n" +
            "\t\t\t<CAR_EC_NO/>\n" +
            "\t\t\t<CAR_EC_NO2/>\n" +
            "\t\t\t<VE_CUSTOMS_NO/>\n" +
            "\t\t\t<VE_WT/>\n" +
            "\t\t</CAR>\n" +
            "\t\t<CONTA>\n" +
            "\t\t\t<CONTA_NUM/>\n" +
            "\t\t\t<CONTA_RECO>1</CONTA_RECO>\n" +
            "\t\t\t<CONTA_ID_F/>\n" +
            "\t\t\t<CONTA_ID_B/>\n" +
            "\t\t\t<CONTA_MODEL_F/>\n" +
            "\t\t\t<CONTA_MODEL_B/>\n" +
            "\t\t</CONTA>\n" +
            "\t\t<ORDER_NUM/>\n" +
            "\t\t<BAR_CODE>${barcode}</BAR_CODE>\n" +
            "\t\t<SEAL>\n" +
            "\t\t\t<ESEAL_ID/>\n" +
            "\t\t\t<SEAL_KEY/>\n" +
            "\t\t</SEAL>\n" +
            "\t</GATHER_INFO>\n" +
            "</MSG>";

    /**
     * 出口送货_进场测试
     */
    @Test
    public void exportDownload_I(){
        logger.error("开始进场测试");
        IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
                .replace("${cross_weight}",cross_weight)
                .replace("${areaID}",areaID)
                .replace("${chnlNo}",chnlNo)
                .replace("${IETYPE}",ie)
                .replace("${barcode}",barcode);
        //进港提货测试

        analysisRoute.setMessage(IMPORT_XML);

    }

    /**
     * 出口送货_出场测试
     */
    @Test
    public void exportDownload_E(){

        //车牌号
         String voNo = "豫A61CR7";
        //备案重量
         String vo_weight = "2000";
        //过卡重量
         String cross_weight= "2324";
        //场站编号
         String areaID = "4604600000";
        //通道编号
         String chnlNo = "4604600011";
        //进出场类型I/E
         String ie = "E";
        //二维码
         String barcode = "613f5c";
        logger.error("开始出口送货离场测试");
        IMPORT_XML= IMPORT_XML.replace("${car}",voNo)
                .replace("${cross_weight}",cross_weight)
                .replace("${areaID}",areaID)
                .replace("${chnlNo}",chnlNo)
                .replace("${IETYPE}",ie)
                .replace("${barcode}",barcode);
        //进港提货测试
        analysisRoute.setMessage(IMPORT_XML);
        threadPoolEs.execute(analysisRoute);

        System.out.println("[THREAD-INFI]-线程运行线程总数量 = " + threadPoolEs.getActiveCount());
        System.out.println("[THREAD-INFI]-线程队列数量 = " + threadPoolEs.getQueue().size());
        System.out.println("threadPoolEs.getCompletedTaskCount() = " + threadPoolEs.getCompletedTaskCount());
        System.out.println("threadPoolEs.getKeepAliveTime(TimeUnit.SECONDS) = " + threadPoolEs.getKeepAliveTime(TimeUnit.SECONDS));
        System.out.println("threadPoolEs.getTaskCount() = " + threadPoolEs.getTaskCount());
    }


}