AnalysisRoute.java 5.1 KB
package com.sy.bwAnalysis;

import com.sy.bwAssist.Message;
import com.sy.logic.LogicOperation;
import com.sy.model.*;
import com.sy.service.*;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;


@Component
public class AnalysisRoute {

    @Autowired
    private aironeExStockService exStockService;

    @Autowired
    private aironeImStockService imStockService;

    @Autowired
    private GATService gatService;

    @Autowired
    private CLRService clrService;

    @Autowired
    private GatherInfoService infoService;

    @Autowired
    private CommandInfoService commandService;

    @Autowired
    private LandBusListService listService;

    @Autowired
    private ResMessageService resMessageService;

    protected static final Logger logger = Logger.getLogger(AnalysisRoute.class);

    private static AnalysisRoute route;

    private static MessageAnalysis analysis = new MessageAnalysis();
    private static CLRAnalysis clrAnalysis = new CLRAnalysis();
    private static ExStockAnalysis exStockAnalysis = new ExStockAnalysis();
    private static ImStockAnalysis imStockAnalysis = new ImStockAnalysis();
    private static GATAnaluysis gatAnaluysis = new GATAnaluysis();
    private static GatherInfoAnalysis gatherInfoAnalysis = new GatherInfoAnalysis();
    private static CommandInfoAnalysis commandInfoAnalysis = new CommandInfoAnalysis();
    private static ResMessageAnalysis resMessageAnalysis = new ResMessageAnalysis();

    @PostConstruct
    public void init(){
        route = this;
        route.clrService = this.clrService;
        route.exStockService = this.exStockService;
        route.imStockService = this.imStockService;
        route.gatService = this.gatService;
        route.infoService = this.infoService;
        route.commandService = this.commandService;
        route.listService = this.listService;
        route.resMessageService = this.resMessageService;
    }

    public static void analysis(String string) {
        PropertyConfigurator.configure("config/log4j.properties");
        string = string.replace("Msg","MSG");
        Message message = analysis.readTicketsXml(string);;
        String stype = message.getMeta().getSmType();
        if (stype.equals("CARM")) {
            if(message.getComInfo() !=null){
                commandInfo info  = commandInfoAnalysis.toJavaBean(message);
                route.commandService.save(info);
            }else{
                GatherInfo info = gatherInfoAnalysis.toJavaBean(message);
                if(info.getBarcode().length()>0){
                    if(LogicOperation.operation(info)){
                        String type = null;
                        if("I".equals(info.getIetype())){
                            type="进入";
                        }else{
                            type="离开";
                        }
                        logger.info("进出站业务申请成功");
                        logger.info("------->>>>>>>"+info.getVename()+"已"+type+info.getAreaid()+"场站<<<<<<<-----");
                    }
                }else{
                    if("4604000000".equals(info.getAreaid())){
                        if("I".equals(info.getIetype())){
                            LogicOperation.sendData("HK05",info.getVename(),false);
                        }else{
                            LogicOperation.sendData("HK06",info.getVename(),false);
                        }
                    }
                }
                route.infoService.save(info);
            }
        } else if (stype.equals("ES1")) {
            airone_ex_stock exStock = exStockAnalysis.toExStock(message);
            route.exStockService.save(exStock);
        } else if (stype.equals("CLR")) {
            v_express_billno billno = clrAnalysis.toBill(message);
            route.clrService.save(billno);
        } else if (stype.equals("IS1")) {
            airone_im_stock imStock = imStockAnalysis.toImStock(message);
            route.imStockService.save(imStock);
        } else if (stype.equals("GAT")) {
            port_manifest_head portHead = gatAnaluysis.toPortHead(message);
            route.gatService.savePortHead(portHead);
            List<port_manifest_body> portBody = gatAnaluysis.toPortBody(message);
            for (int a = 0; a<portBody.size();a++){
                route. gatService.savePortBody(portBody.get(a));
            }
            port_manifest_head_stat portStat = gatAnaluysis.toPortStat(message);
            route.gatService.savePortStat(portStat);
        } else if(stype.equals("CDHZ")){
            if("MT9999".equals(message.getManifest().getHead().getMessageType())){
                RESMESSAGE resmessage = resMessageAnalysis.saveEntry(message.getManifest());
                RESMESSAGE msg =route.resMessageService.selectByManifest(resmessage.getManifest());
                if(msg==null){
                    route.resMessageService.saveEnter(resmessage);
                }
            }
        }
    }

}