作者 Promise

生成抬杆报文及IMF报文

正在显示 44 个修改的文件 包含 2914 行增加76 行删除
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport;
import com.airport.core.AgentSender;
import com.airport.core.IMFNoDelaySender;
import com.airport.core.IMFReader;
import com.airport.core.ZYFNoDelaySender;
import com.airport.util.ConfigUtils;
import com.airport.util.SystemBean;
import com.caac.imf.api.IMFClient;
import com.caac.imf.api.IMFClientFactory;
import java.util.Timer;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import sun.management.Agent;
public class Main {
private static final Logger logger = Logger.getLogger(Main.class);
public static boolean LOGIN_OK = false;
public static boolean isSuc = true;
public static IMFClient client = null;
public Main() {
}
private static void start() throws Exception {
PropertyConfigurator.configure("config/log4j.properties");
SystemBean.createInstance("config/ApplicationContext.xml");
ConfigUtils conf = new ConfigUtils();
conf.Initialize();
client = IMFClientFactory.createInstance();
if ("R".equalsIgnoreCase(ConfigUtils.ROLE)) {
if (client != null) {
IMFReader reader = new IMFReader(client);
reader.start();
}
loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties");
} else if ("S".equalsIgnoreCase(ConfigUtils.ROLE)) {
loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties");
if (LOGIN_OK && client != null) {
logger.info("start run Timer,client hasocde=" + client.hashCode());
while (true){
if(!AgentSender.isrunning){
AgentSender send = new AgentSender(client);
send.start();
}
try {
Thread.sleep(50000);
} catch (Exception e) {
e.printStackTrace();
logger.info(e.getMessage());
}
}
//代理人发送程序
//数据仓库给九州的发送程序
// Timer timer = new Timer();
// //从配置文件读取sql语句,发送货运数据
// String sql_select=ConfigUtils.SQl;
// String sqlmax = ConfigUtils.SQlMax;
// ZYFNoDelaySender CangKu2Jiuzhou = new ZYFNoDelaySender(client,"data/fid_index.txt",sql_select,sqlmax);
// CangKu2Jiuzhou.start();
// timer.schedule(CangKu2Jiuzhou, 10000L, 1200000L);
}
}
}
private static void loginIMF(IMFClient client, String userName, String password, String confFileName) {
if (client.initial(confFileName)) {
String message = client.login(userName, password);
logger.info("message=" + message);
if (message.indexOf("<CODE>1</CODE>") > 0) {
logger.info("登陆成功");
LOGIN_OK = true;
} else {
int times = 0;
while(times <= 3) {
logger.info("try connection...");
++times;
logger.info("message.=" + message);
if (message.indexOf("<CODE>1</CODE>") > 0) {
logger.info("登陆成功");
LOGIN_OK = true;
break;
}
logger.info("登录失败~~~~");
message = client.login(userName, password);
try {
Thread.sleep(4000L);
} catch (InterruptedException var7) {
var7.printStackTrace();
}
}
if (!LOGIN_OK) {
logger.info("多次尝试登录失败,退出登陆");
client.disconnect();
isSuc =false;
System.exit(-1);
}
}
}
}
public static void main(String[] args) throws Exception {
start();
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.bean;
public class MessageBak {
private int fid;
private String content;
private int rownum_;
public MessageBak(int fid, String content) {
this.fid = fid;
this.content = content;
}
public MessageBak(int fid, String content,int rownum_) {
this.fid = fid;
this.content = content;
this.rownum_ = rownum_;
}
public String toString() {
return this.fid + " " + this.content;
}
public int getFid() {
return this.fid;
}
public void setFid(int fid) {
this.fid = fid;
}
public String getContent() {
return this.content;
}
public void setContent(String content) {
this.content = content;
}
public int getRownum_() {
return rownum_;
}
public void setRownum_(int rownum_) {
this.rownum_ = rownum_;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.bean;
public class XMLHeader {
private String sndr;
private String rcvr;
private String type;
private String stype;
public XMLHeader() {
}
public String toString() {
return "sndr=[" + this.sndr + "]\t rcvr=[" + this.rcvr + "]\t type=[" + this.type + "]\t stype=[" + this.stype + "]";
}
public String getSndr() {
return this.sndr;
}
public void setSndr(String sndr) {
this.sndr = sndr;
}
public String getRcvr() {
return this.rcvr;
}
public void setRcvr(String rcvr) {
this.rcvr = rcvr;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getStype() {
return this.stype;
}
public void setStype(String stype) {
this.stype = stype;
}
}
... ...
package com.airport.core;
import com.airport.Main;
import org.apache.log4j.Logger;
import com.caac.imf.api.IMFClient;
import redis.clients.jedis.Jedis;
public class AgentSender extends Thread{
private static final Logger logger = Logger.getLogger(AgentSender.class);
public static boolean isrunning;
Jedis jedis = new Jedis("10.50.3.73", 6379);
private IMFClient client;
public AgentSender(IMFClient client){
this.client = client;
}
public void run(){
logger.info(jedis);
try {
if (this.client == null) {
logger.info("IMFClient has been closed");
return;
}
isrunning=true;
if(Main.isSuc){
logger.info("《《《主线程初始化成功。。。。》》》");
if(Main.LOGIN_OK){
logger.info("《《《登录成功开始轮询500mm一次。。。。》》》");
while(true){
String SendMsg = jedis.rpoplpush("task-queue", "tmp-queue"); //取队列消息
//队列消息不为NULL开始发送
if(SendMsg !=null && SendMsg.length() != 0){
String returnMsg = this.client.sendMSG(SendMsg);
logger.debug("<<发送返回的信息:"+returnMsg+">>");
//9是发送成功
if(returnMsg.indexOf("<CODE>9</CODE>")>=0){
try {
jedis.rpop("tmp-queue");
logger.debug("<<移除队列>>");
} catch (Exception e) {
e.printStackTrace();
logger.info(e.getMessage());
logger.info("!!移除队列失败!!");
}
}else{
//如果发送不成功继续发送
try{
jedis.rpoplpush("tmp-queue", "task-queue");
logger.info("!!<<执行未成功发送的消息返回到发送消息队列>>!!");
}catch (Exception e){
e.printStackTrace();
logger.info(e.getMessage());
logger.info("!!回写TMP到TASK队列失败!!");
}
}
}
//发送延迟
try {
Thread.sleep(500);
} catch (Exception e) {
e.printStackTrace();
logger.info(e.getMessage());
}
}
}else{
logger.info("---------登陆中");
}
}
}catch (Exception var14) {
var14.printStackTrace();
logger.info(var14.getMessage());
}
isrunning=false;
logger.info("---------线程不在了");
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.core;
import com.airport.bean.MessageBak;
import com.airport.bean.XMLHeader;
import com.airport.dao.Dao;
import com.airport.dao.impl.DaoImpl;
import com.airport.util.ConfigUtils;
import com.airport.util.SystemBean;
import com.airport.util.Utils;
import com.airport.util.parse.IMFXMLMaker;
import com.airport.util.parse.XMPParse;
import com.caac.imf.api.IMFClient;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimerTask;
public class IMFNoDelaySender extends Thread{
private static final Logger logger = Logger.getLogger(IMFNoDelaySender.class);
private Dao dao = (DaoImpl)SystemBean.getBean("dao");
private IMFClient client;
private String indexFileName; //记录发送数据的节点
private String sql;
private String sqlMax;
public IMFNoDelaySender(IMFClient client, String fileName,String sql,String sqlMax) {
this.indexFileName = fileName;
this.client = client;
this.sql=sql;
this.sqlMax=sqlMax;
}
public synchronized void run() {
try {
if (this.client == null) {
logger.info("IMFClient has been closed");
return;
}
while(true) {
//初始化读取
logger.info("job start,发送线程开始["+Thread.currentThread().getName()+"]");
int lastFID = Utils.readFIDIndex(this.indexFileName);
int maxFID = this.dao.getMaxFID(sqlMax);
logger.info("lastROW=" + lastFID + " maxCount=" + maxFID);
int is_ok = 0;
if (maxFID > lastFID) {
//这里修改从FID_INDEX文件读取的FID ,改为取搜索结果的rownum,此处FID代表ROWNUM
String sqlformat = String.format(sql, lastFID, lastFID, ConfigUtils.RECORD_COUNT);
logger.info(sqlformat);
List<MessageBak> list = this.dao.getRecordByFID(lastFID,sqlformat); //查询大于[FID]350的报文
//如果两个发送者,要用到这里
Map<Integer, XMLHeader> map = ConfigUtils.XML_HEADER_MAP;
Iterator var7 = list.iterator();
while(var7.hasNext()) {
MessageBak m = (MessageBak)var7.next();
if (is_ok != 0) {
logger.error("记录FID时发生异常,发送消息任务被迫中断");
return;
}
if (m.getContent() != null) {
int times = 0;
//配置文件里面有几个sender 这里循环几次
for(Iterator var10 = map.keySet().iterator(); var10.hasNext(); times++) {
Integer key = (Integer)var10.next();
XMLHeader header = (XMLHeader)map.get(key);
logger.info("key=" + key + " value=" + ((XMLHeader)map.get(key)).toString());
logger.info("准备发送数据 FID:" + m.getFid() + " XML.length=:" + m.getContent().length());
//初始化最终发布报文内容的存储器
String sendMsg = "";
String xmlStr = m.getContent();
//_____________________________________解析华东的报文给九州-------------------------------------------------------------------------------------------
if (xmlStr.contains("<MessageType>IS1</MessageType>")){
IMFXMLMaker haiguanXml = new IMFXMLMaker(header.getSndr(),Integer.toString(m.getFid()),"DFME","IS1");
haiguanXml.setIMFContent(m.getContent());
sendMsg = haiguanXml.finalXmlStr();
}else if(xmlStr.contains("<MessageType>ES1</MessageType>") ){
IMFXMLMaker haiguanXml = new IMFXMLMaker(header.getSndr(),Integer.toString(m.getFid()),"DFME","ES1");
haiguanXml.setIMFContent(m.getContent());
sendMsg = haiguanXml.finalXmlStr();
}else if(xmlStr.contains("<MessageType>CLR</MessageType>")){
IMFXMLMaker haiguanXml = new IMFXMLMaker(header.getSndr(),Integer.toString(m.getFid()),"DFME","CLR");
haiguanXml.setIMFContent(m.getContent());
sendMsg = haiguanXml.finalXmlStr();
}else if(xmlStr.contains("<MessageType>RSC</MessageType>")){
IMFXMLMaker haiguanXml = new IMFXMLMaker(header.getSndr(),Integer.toString(m.getFid()),"DFME","RSC");
haiguanXml.setIMFContent(m.getContent());
sendMsg = haiguanXml.finalXmlStr();
} else {
//_____________________________________解析天信达的报文,读取配置文件,替换相关参数给九州-------------------------------------------------------------------------------------------
sendMsg= Utils.searchReplace(m.getContent(), header.getSndr(), "SNDR");
sendMsg = Utils.searchReplace(sendMsg, header.getType(), "TYPE"); //替换报文主类型
String stype = tranlateXML(m.getContent());
sendMsg = Utils.searchReplace(sendMsg, stype, "STYP");
sendMsg = Utils.searchReplaceSingle(sendMsg, header.getRcvr(), "RCVR");
}
//_____________________________________给多式联运的航空报文,读取配置文件,生成新的META,并把最原始的报文封装到新报文的content里面--------------------------------------------------------------------
// String sndr = header.getSndr();
// String type = header.getType();
// String styp = header.getStype();
//
// IMFXMLMaker newXml = new IMFXMLMaker(sndr,Integer.toString(m.getFid()),type,styp);
// newXml.setIMFContent(m.getContent());
// sendMsg = newXml.finalXmlStr();
if (!"".equals(sendMsg)) {
sendXml(sendMsg);
is_ok = Utils.writeFIDIndex(this.indexFileName, m.getRownum_()); //发送成功写入节点文件
logger.debug("FID:" + m.getFid() + " 缓存成功");
++times;
} else {
logger.error("查找替换节点数据出现异常,可能找不到这个节点,原始XML=" + m.getContent());
}
}
// this.dao.update(m.getFid(), times);
} else {
logger.info("FID=" + m.getFid() + "XML is null ");
}
}
}else {
try {
Thread.sleep(100000L);
logger.info("发送线程》》》"+Thread.currentThread().getName()+"休眠");
} catch (InterruptedException var3) {
var3.printStackTrace();
}
}
}
}catch (Exception var14) {
var14.printStackTrace();
logger.info(var14.getMessage());
}
}
public synchronized void sendXml(String msg){
logger.info("线程:::"+Thread.currentThread().getName()+"开始发送数据 XML:" + msg);
String is_send_ok = this.client.sendMSG(msg);
logger.info("发送回执=" + is_send_ok);
}
private static String tranlateXML(String xml) throws Exception {
String stype = XMPParse.getNodeValueFromXmlString(xml, "/MSG/META/STYP");
if (!StringUtils.isBlank(stype)) {
if (ConfigUtils.XTYPE_MAP.containsKey(stype)) {
stype = (String)ConfigUtils.XTYPE_MAP.get(stype);
} else {
logger.info("stype=" + stype + " 在对应关系里找不到这个KEY");
}
} else {
logger.info(" 在XML找不到STYPE这个节点");
stype = "";
}
return stype;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.core;
import com.airport.Main;
import com.airport.dao.impl.DaoImpl;
import com.airport.util.SystemBean;
import com.airport.util.Utils;
import com.airport.util.parse.XMPParse;
import com.caac.imf.api.IMFClient;
import java.util.Date;
import org.apache.log4j.Logger;
public class IMFReader extends Thread {
private static final Logger logger = Logger.getLogger(IMFReader.class);
private static final String stype = "/MSG/META/STYP";
private IMFClient client;
public IMFReader(IMFClient client) {
this.client = client;
}
public void run() {
while(true) {
if (Main.LOGIN_OK) {
synchronized(this) {
String message = this.client.getMSG();
if (message != null) {
this.save(message);
}
}
} else {
//logger.info("***");
}
try {
Thread.sleep(100L);
} catch (InterruptedException var3) {
var3.printStackTrace();
}
}
}
private void save(String message) {
Date dt = new Date();
DaoImpl dao = (DaoImpl)SystemBean.getBean("dao");
String path = "data/" + Utils.dateToStr(dt, "yyyy-MM-dd") + "/";
if (Utils.createDir(path)) {
String fileName = "";
try {
String stype_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/STYP");
String type_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/TYPE");
String sender_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/SNDR");
String sntm_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/DDTM");
String seqn_value = XMPParse.getNodeValueFromXmlString(message, "/MSG/META/SEQN");
// fileName = path + stype_value + "_" + Utils.dateToStr(dt, "yyyyMMddhhmmssSSS") + ".xml";
// Utils.saveFile(fileName, message);
dao.saveRecord("ALL", sender_value,sntm_value, message,type_value,stype_value,seqn_value);
// logger.info("created " + fileName + " ok");
} catch (Exception var7) {
//出错的报文存储到报文目录
fileName = path + Utils.dateToStr(dt, "yyyyMMddhhmmssSSS") + ".txt";
Utils.saveFile(fileName, message);
logger.warn("报文入库失败已存储成备份文件:created " + fileName + " ok");
logger.error(var7);
logger.warn(var7);
}
} else {
logger.warn("创建目录失败.");
logger.warn(message);
}
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.dao;
import com.airport.bean.MessageBak;
import java.util.List;
public interface Dao {
int insertRecord(String var1, String var2,String var3,String var4,String var5,String var6);
void saveRecord(String var1, String var2, String var3,String var4,String var5,String var6,String var7) throws Exception;
void delete(int var1);
List<MessageBak> getRecordByFID(int var1,String var2);
int getRecordCount();
int getMaxFID(String var1);
void update(int var1, int var2);
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.dao.impl;
import com.airport.bean.MessageBak;
import com.airport.dao.Dao;
import com.airport.util.ConfigUtils;
import java.io.IOException;
import java.io.Writer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import oracle.sql.CLOB;
import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.support.AbstractLobStreamingResultSetExtractor;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.jdbc.support.lob.DefaultLobHandler;
import org.springframework.jdbc.support.lob.LobHandler;
public class DaoImpl implements Dao {
private static final Logger logger = Logger.getLogger(DaoImpl.class);
private JdbcTemplate jdbcTemplate;
public DaoImpl() {
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public int insertRecord(final String oper, final String sndr,final String sntm,final String type,final String styp,final String seqn) {
KeyHolder keyHolder = new GeneratedKeyHolder();
this.jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
DaoImpl.logger.info("oper=" + oper + " sndr=" + sndr+" type="+type+" styp="+styp);
String sql = "insert into T_ETL_MESSAGE(OPER,SNDR,SNTM,content,TYPE,STYP,SEQN) values(?,?,to_timestamp(?,'yyyyMMddHH24MIssff'),empty_clob(),?,?,?)";
PreparedStatement ps = connection.prepareStatement(sql, new String[]{"FID"});
ps.setString(1, oper);
ps.setString(2, sndr);
ps.setString(3, sntm);
ps.setString(4, type);
ps.setString(5, styp);
ps.setString(6,seqn);
return ps;
}
}, keyHolder);
int generatedId = keyHolder.getKey().intValue();
return generatedId;
}
public void saveRecord(String messaegType, String sndr,String sntm, String xmlContent,String type,String styp,String seqn) throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
int fid = -100;
try {
fid = this.insertRecord(messaegType, sndr,sntm,type,styp,seqn);
conn = this.jdbcTemplate.getDataSource().getConnection();
conn.setAutoCommit(false);
stmt = conn.createStatement();
String SQL = "select CONTENT from T_ETL_MESSAGE where FID=" + fid + " for update";
rs = stmt.executeQuery(SQL);
while(rs.next()) {
CLOB clob = (CLOB)rs.getClob(1);
Writer os = clob.getCharacterOutputStream();
os.write(xmlContent);
os.flush();
os.close();
}
conn.commit();
} catch (SQLException var14) {
if (fid > 0) {
this.delete(fid);
}
var14.printStackTrace();
conn.rollback();
} finally {
if (conn != null) {
conn.setAutoCommit(true);
}
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
}
}
public void delete(int fid) {
this.jdbcTemplate.update("delete from T_ETL_MESSAGE where fid=" + fid);
}
public int getMaxFID(String sqlmax) {
// String sqlmax = "select max(fid) from MESSAGE_BAK WHERE (FID>%s and FID<%s+%s) AND (TYPE='CLR' OR TYPE='ES1' OR TYPE='IS1' OR STYP = 'BSTA' OR STYP = 'FZE_RCF' OR STYP = 'FSU_FOH' OR STYP = 'FSU_DEP' OR STYP = 'COST' OR STYP = 'ABME' OR STYP = 'FZE_DEP' OR STYP = 'FSU_RCF') ORDER BY FID\n";
// sqlmax = ConfigUtils.SQlMax;
return this.jdbcTemplate.queryForInt(sqlmax);
}
public List<MessageBak> getRecordByFID(int fid,String sql) {
final LobHandler lobHandler = new DefaultLobHandler();
final ArrayList xmlList = new ArrayList();
try {
this.jdbcTemplate.query(sql, new AbstractLobStreamingResultSetExtractor() {
protected void streamData(ResultSet rs) throws SQLException, IOException, DataAccessException {
String content = "";
while(rs.next()) {
int fid = rs.getInt(1);
content = lobHandler.getClobAsString(rs, "CONTENT");
int rownum = rs.getInt("rownum_");
if (content != null) {
MessageBak obj = new MessageBak(fid, content,rownum);
xmlList.add(obj);
} else {
DaoImpl.logger.error("FID=" + fid + " content is NULL");
}
}
}
});
} catch (EmptyResultDataAccessException var7) {
var7.printStackTrace();
}
return xmlList;
}
public int getRecordCount() {
return this.jdbcTemplate.queryForInt("select count(*) from T_ETL_MESSAGE where SNDR='FIMS' ");
}
public void update(int fid, int times) {
String sql = String.format("update T_ETL_MESSAGE set OUTFLAG=%s ,OUTTM=sysdate where FID=%s", times, fid);
logger.info("sql=" + sql);
this.jdbcTemplate.update(sql);
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import com.airport.bean.XMLHeader;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
public class ConfigUtils {
private static final Logger logger = Logger.getLogger(ConfigUtils.class);
public static String ROLE;
public static String IMF_USERNAME;
public static String IMF_PASSWORD;
public static final String IFM_CONSUMER = "config/imf_config.properties";
public static final String IMF_PRUDUCER = "config/imf_config.properties";
public static final String INDEX_FILE_NAME = "data/fid_index.txt";
public static int SEND_MESSAGE_INTERVAL = 1;
public static int RECORD_COUNT = 1000;
public static String XML_HEADER_SNDR = "";
public static String XML_HEADER_TYPE = "";
public static String XML_HEADER_STYPE = "";
public static String XML_HEADER_RCVR = "";
public static Map<Integer, XMLHeader> XML_HEADER_MAP = new HashMap();
public static String RCVR = "";
public static String APPID = "";
public static String SNDR = "";
public static String SQl="";
public static String SQlMax="";
public static String SQl1="";
public static String SQlMax1="";
public static Map<String, String> XTYPE_MAP = new HashMap();
public ConfigUtils() {
}
private void initMap() {
XTYPE_MAP.put("FSU_DEP", "UDEP");
XTYPE_MAP.put("FSU_RCF", "URCF");
XTYPE_MAP.put("FSU_FOH", "UFOH");
XTYPE_MAP.put("FZE_DEP", "EDEP");
XTYPE_MAP.put("FZE_RCF", "ERCF");
XTYPE_MAP.put("FZE_FOH", "EFOH");
XTYPE_MAP.put("CARGO_SERV", "CARG");
}
public void Initialize() throws LteException {
logger.debug("Loading all the config parameters...");
this.loadParameter();
this.initMap();
}
private final void loadParameter() throws LteException {
boolean ok = false;
logger.info("================Initialize system parameter =================");
Configuration config = (Configuration)SystemBean.getBean("configurationBean");
ROLE = config.getProperty("role").trim();
IMF_USERNAME = config.getProperty("imf_username").trim();
IMF_PASSWORD = config.getProperty("imf_password").trim();
SQl = config.getProperty("sql");
SQlMax = config.getProperty("sqlmax");
SQl1 = config.getProperty("sql1");
SQlMax1 = config.getProperty("sqlmax1");
String interval = config.getProperty("interval").trim();
String record_count = config.getProperty("record_count").trim();
logger.info(String.format("role=%s", ROLE));
logger.info(String.format("imf_username=%s", IMF_USERNAME));
logger.info(String.format("imf_password=%s", IMF_PASSWORD));
logger.info(String.format("interval=%s", interval));
if (StringUtils.isBlank(ROLE)) {
logger.error("role 参数错误");
ok = true;
} else if ("R".equalsIgnoreCase(ROLE)) {
if (!isFileExists("config/imf_config.properties")) {
logger.error("如果要从IMF接收数据,需要在config/imf_config.properties 配置IMF参数");
ok = true;
}
} else if ("S".equalsIgnoreCase(ROLE)) {
if (!isFileExists("config/imf_config.properties")) {
logger.error("如果向IMF发送数据,需要在config/imf_config.properties 配置IMF参数");
ok = true;
}
} else {
logger.error("role 参数错误,必须是S(从IMF接收消息) 或者 R(发送消息到IMF)");
}
int int_total_group;
if ("S".equalsIgnoreCase(ROLE)) {
String total_group = config.getProperty("total_group").trim();
int_total_group = 0;
logger.info(String.format("record_count=%s", record_count));
logger.info(String.format("total_group=%s", total_group));
if (StringUtils.isBlank(total_group)) {
logger.error("total_group 参数错误");
ok = true;
} else {
int_total_group = Integer.parseInt(total_group);
if (int_total_group <= 10 && int_total_group >= 1) {
this.loadXMLHeaderParameter(config, int_total_group);
} else {
logger.error("total_group 参数设置错误,范围在1--10之间");
ok = true;
}
}
int x;
if (StringUtils.isBlank(record_count)) {
logger.error("record_count 参数错误");
ok = true;
} else {
x = Integer.parseInt(record_count);
if (x <= 10000 && x >= 100) {
RECORD_COUNT = x;
} else {
logger.error("record_count 参数设置错误,范围在100--10000之间");
ok = true;
}
}
if (StringUtils.isBlank(interval)) {
logger.error("interval 参数错误");
ok = true;
} else {
x = Integer.parseInt(interval);
if (x <= 60 && x >= 1) {
SEND_MESSAGE_INTERVAL = x * 1000;
} else {
logger.error("interval 参数设置错误,范围在1---60之间");
ok = true;
}
}
}
if (!isFileExists("data/")) {
File f = new File("data");
f.mkdir();
Utils.writeFIDIndex("data/fid_index.txt", 0);
int_total_group = Utils.readFIDIndex("data/fid_index.txt");
logger.info("FID=" + int_total_group);
} else {
logger.info("data/fid_index.txt exists");
}
boolean hasError = false;
hasError = this.validate(IMF_USERNAME, "imf_username 参数错误");
hasError = this.validate(IMF_PASSWORD, "imf_password 参数错误");
if (ok && !hasError) {
logger.error("参数错误 启动程序失败。");
System.exit(-1);
}
}
private void loadXMLHeaderParameter(Configuration config, int total) throws LteException {
String sndr = "";
String rcvr = "";
String type = "";
String stype = "";
for(int i = 1; i <= total; ++i) {
logger.info(String.format("group %d--------------------------", i));
sndr = config.getProperty("sndr_" + i).trim();
rcvr = config.getProperty("rcvr_" + i).trim();
type = config.getProperty("type_" + i).trim();
stype = config.getProperty("stype_" + i).trim();
logger.info(String.format("SNDR_%d=%s", i, sndr));
logger.info(String.format("RCVR_%d=%s", i, rcvr));
logger.info(String.format("TYPE_%d=%s", i, type));
logger.info(String.format("STYPE_%d=%s", i, stype));
XMLHeader header = new XMLHeader();
header.setSndr(sndr);
header.setRcvr(rcvr);
header.setType(type);
header.setStype(stype);
logger.info("group[" + i + "]\t" + header.toString());
XML_HEADER_MAP.put(i, header);
}
}
private boolean validate(String paraValue, String tipText) {
if (StringUtils.isBlank(paraValue)) {
logger.error(tipText);
return false;
} else {
return true;
}
}
private static boolean isFileExists(String filename) {
File f = new File(filename);
return f.exists();
}
public static void main(String[] argc) {
File f = new File("config/producer_imf_config.properties");
if (f.exists()) {
System.out.println("file exists");
} else {
System.out.println("file not exists");
}
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.Resource;
import org.springframework.util.DefaultPropertiesPersister;
import org.springframework.util.PropertiesPersister;
public class Configuration extends PropertyPlaceholderConfigurer {
private static final Logger logger = Logger.getLogger(Configuration.class);
private static final Map<String, String> parameterMap = new HashMap();
private Resource location;
public void setLocation(Resource location) {
this.location = location;
}
public void loadProperties(Properties props) throws IOException {
PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
InputStream is = null;
try {
Resource location = this.location;
is = location.getInputStream();
propertiesPersister.load(props, is);
Iterator var6 = props.keySet().iterator();
while(var6.hasNext()) {
Object key = var6.next();
String code = props.getProperty((String)key).trim();
parameterMap.put((String)key, code);
}
} catch (Exception var11) {
logger.error("initialization error", var11);
var11.printStackTrace();
} finally {
if (is != null) {
is.close();
}
}
}
public Configuration() {
logger.setLevel(Level.INFO);
}
public String getProperty(String name) throws LteException {
String str = (String)parameterMap.get(name);
if (str == null) {
String errMsg = String.format("config.properties key Error, can not find key [%s]", name);
logger.error(errMsg);
throw new LteException(errMsg);
} else {
return str.trim();
}
}
public String getPropertyMaybeNull(String name) throws LteException {
String str = (String)parameterMap.get(name);
if (StringUtils.isBlank(str)) {
str = "";
}
return str.trim();
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import java.io.PrintWriter;
import java.io.StringWriter;
public class ExceptionUtils {
public ExceptionUtils() {
}
public static String outputExceptionDetailsInfo(String label, String msg, Throwable t) {
StringBuffer sb = new StringBuffer();
StackTraceElement[] messages = t.getStackTrace();
int length = messages.length;
sb.append("\n");
sb.append("\n");
sb.append("\t");
sb.append("[");
sb.append(label + " component exception super class name");
sb.append(":");
sb.append(msg);
sb.append("]");
sb.append("\n");
sb.append("\t********Exception Detail List Begin********");
sb.append("\n\t" + t + "\n");
for(int i = 0; i < length; ++i) {
sb.append("\t" + messages[i].toString() + "\n");
}
sb.append("\t********Exception Detail List End********");
return sb.toString();
}
public static String getStackTrace(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String var4;
try {
t.printStackTrace(pw);
var4 = sw.toString();
} finally {
pw.close();
}
return var4;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import org.apache.log4j.Logger;
public class LteException extends Exception {
private static final Logger logger = Logger.getLogger(LteException.class);
private static final long serialVersionUID = -3047721096749400047L;
private int errorCode = -1;
public LteException() {
}
public LteException(String s) {
super(s);
}
public LteException(int errorCode, String errmsg) {
super(errmsg);
this.errorCode = errorCode;
if (errorCode > 0) {
logger.debug("ErrorCode: " + errorCode + " " + errmsg);
}
}
public int getErrorCode() {
return this.errorCode;
}
public LteException(String s, Throwable cause) {
super(s, cause);
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class SystemBean {
private static Logger logger = Logger.getLogger(SystemBean.class);
private static SystemBean inistance;
private static FileSystemXmlApplicationContext fileSystemXmlApplicationContext;
private static Object lock = new Object();
public SystemBean() {
}
public static final synchronized void createInstance(String path) throws LteException {
if (inistance == null) {
Object var1 = lock;
synchronized(lock) {
if (inistance == null) {
inistance = new SystemBean();
String err;
try {
logger.info("Initialization ApplicationContext ");
fileSystemXmlApplicationContext = new FileSystemXmlApplicationContext(path);
fileSystemXmlApplicationContext.registerShutdownHook();
} catch (BeansException var4) {
err = ExceptionUtils.getStackTrace(var4);
throw new LteException("Initialization ApplicationContext error:" + err);
} catch (Exception var5) {
err = ExceptionUtils.getStackTrace(var5);
throw new LteException("Initialization ApplicationContext error:" + err);
}
}
}
}
}
public static final Object getBean(String beanName) {
return fileSystemXmlApplicationContext.getBean(beanName);
}
public static final void destroy() {
fileSystemXmlApplicationContext.getBeanFactory().destroySingletons();
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
//读取写入已发送的FID
public class Utils {
private static Logger logger = Logger.getLogger(SystemBean.class);
public Utils() {
}
public static final Date iso8601DateStrToDate(String dateStr) {
Date dt = null;
String str_ = dateStr.replace("T", " ");
str_ = str_.substring(0, 19);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
dt = format.parse(str_);
} catch (ParseException var5) {
var5.printStackTrace();
}
return dt;
}
public static String dateToStr(Date date) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = format.format(date);
return str;
}
public static String dateToStr(Date date, String dateFmt) {
SimpleDateFormat format = new SimpleDateFormat(dateFmt);
String str = format.format(date);
return str;
}
public static boolean createDir(String destDirName) {
File dir = new File(destDirName);
if (dir.exists()) {
return true;
} else {
if (!destDirName.endsWith(File.separator)) {
destDirName = destDirName + File.separator;
}
if (dir.mkdirs()) {
return true;
} else {
logger.info("创建目录失败! 目录名称:" + destDirName);
return false;
}
}
}
public static void saveFile(String fileName, String content) {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8")));
out.write(content);
out.flush();
out.close();
} catch (IOException var3) {
var3.printStackTrace();
logger.error(var3.getMessage());
}
}
public static int writeFIDIndex(String fileName, int fid) {
PrintStream ps = null;
byte is_ok = 1;
try {
File file = new File(fileName);
ps = new PrintStream(new FileOutputStream(file));
ps.println(fid);
is_ok = 0;
} catch (IOException var8) {
var8.printStackTrace();
logger.error(var8.getMessage());
} finally {
ps.close();
}
return is_ok;
}
public static int readFIDIndex(String fileName) {
FileReader reader = null;
BufferedReader br = null;
int index = 0;
try {
reader = new FileReader(fileName);
br = new BufferedReader(reader);
String str = br.readLine();
index = Integer.parseInt(str);
} catch (FileNotFoundException var15) {
var15.printStackTrace();
} catch (IOException var16) {
var16.printStackTrace();
} finally {
try {
br.close();
reader.close();
} catch (IOException var14) {
var14.printStackTrace();
}
}
return index;
}
public static String searchReplace(String xml, String replacement, String nodeName) {
String pStr = String.format("(?<=<%s>).*(?=</%s>)", nodeName, nodeName);
Pattern pat = Pattern.compile(pStr);
Matcher matcher = pat.matcher(xml);
if (matcher.find()) {
if (!StringUtils.isBlank(replacement)) {
return xml.replace(matcher.group(), replacement);
}
} else {
logger.error("can not find " + nodeName + " in " + xml);
}
return xml;
}
public static String searchReplaceSingle(String xml, String replacement, String nodeName) {
String pStr = String.format("(<%s/>)", nodeName);
String rep = String.format("<%s>%s</%s>", nodeName, replacement, nodeName);
Pattern pat = Pattern.compile(pStr);
Matcher mat = pat.matcher(xml);
return mat.find() && !StringUtils.isBlank(replacement) ? xml.replace(mat.group(), rep) : xml;
}
}
... ...
package com.airport.util.parse;
import org.apache.log4j.Logger;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class IMFXMLMaker {
private static final Logger logger = Logger.getLogger(IMFXMLMaker.class);
private Document XmlDocument;
private Element RootElement;
private Element SndrElement;
private Element RcvrElement;
private Element SEQNElement;
private Element TYPEElement;
private Element STYPElement;
private Element originalELEMENT;
private String XmlStr;
private String SNDR;
private String RCVR;
private String SEQN;
private String TYPE;
private String STYP;
private String IMFContent;
private String IMFXml;
public String getXmlStr() {
return XmlStr;
}
public void setXmlStr(String xmlStr) {
XmlStr = xmlStr;
}
public String getSNDR() {
return SNDR;
}
public void setSNDR(String SNDR) {
this.SNDR = SNDR;
}
public String getRCVR() {
return RCVR;
}
public void setRCVR(String RCVR) {
this.RCVR = RCVR;
}
public String getSEQN() {
return SEQN;
}
public void setSEQN(String SEQN) {
this.SEQN = SEQN;
}
public String getTYPE() {
return TYPE;
}
public void setTYPE(String TYPE) {
this.TYPE = TYPE;
}
public String getSTYP() {
return STYP;
}
public void setSTYP(String STYP) {
this.STYP = STYP;
}
public String getIMFContent() {
return IMFContent;
}
public void setIMFContent(String IMFContent) {
this.IMFContent = IMFContent;
}
public String getIMFXml() {
return IMFXml;
}
public void setIMFXml(String IMFXml) {
this.IMFXml = IMFXml;
}
//初始化报文头部节点
public IMFXMLMaker(String sndr,String seqn,String type,String styp){
this.SNDR = sndr;
this.SEQN = seqn;
this.TYPE = type;
this.STYP = styp;
this.XmlDocument = new Document();
//跟节点
this.RootElement = new Element("MSG");
this.XmlDocument.addContent(this.RootElement);
//meta节点
Element MetaElement = new Element("META");
this.RootElement.addContent(0,MetaElement);
//原始内容节点,储存最原始报文内容的节点
this.originalELEMENT = new Element("original");
this.RootElement.addContent(1,this.originalELEMENT);
//meta下的子节点们
SndrElement = new Element("SNDR");
RcvrElement = new Element("RCVR");
SEQNElement = new Element("SEQN");
Element DDTMElement = new Element("DDTM");
TYPEElement = new Element("TYPE");
STYPElement = new Element("STYP");
MetaElement.addContent(0,SndrElement);
MetaElement.addContent(1,RcvrElement);
MetaElement.addContent(2,SEQNElement);
MetaElement.addContent(3,DDTMElement);
MetaElement.addContent(4,TYPEElement);
MetaElement.addContent(5,STYPElement);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String dateString = simpleDateFormat.format(new Date());
DDTMElement.setText(dateString);
SndrElement.setText(this.SNDR);
SEQNElement.setText(this.SEQN);
TYPEElement.setText(this.TYPE);
STYPElement.setText(this.STYP);
}
public String finalXmlStr(){
try{
Document contentDocument = string2Doc(this.IMFContent);
this.originalELEMENT.addContent(0,contentDocument.detachRootElement());
String backXml = doc2String(this.XmlDocument);
return backXml;
}catch (Exception e){
e.printStackTrace();
return this.SEQN+"error";
}
}
/**
* 字符串转换为DOCUMENT
*
* @param xmlStr 字符串
* @return doc JDOM的Document
* @throws Exception
*/
public static Document string2Doc(String xmlStr) throws Exception {
java.io.Reader in = new StringReader(xmlStr);
Document doc = (new SAXBuilder()).build(in);
return doc;
}
/**
* Document转换为字符串
*
* @param doc DOCUMENT对象
* @return xmlStr 字符串
* @throws Exception
*/
public String doc2String(Document doc) throws Exception {
Format format = Format.getPrettyFormat();
format.setEncoding("UTF-8");// 设置xml文件的字符为UTF-8,解决中文问题
XMLOutputter xmlout = new XMLOutputter(format);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
xmlout.output(doc, bo);
return bo.toString();
}
/**
* XML转换为Document
*
* @param xmlFilePath XML文件路径
* @return doc Document对象
* @throws Exception
*/
public static Document xml2Doc(String xmlFilePath) throws Exception {
File file = new File(xmlFilePath);
return (new SAXBuilder()).build(file);
}
public void main(String[] args) throws Exception{
finalXmlStr();
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util.parse;
import org.jdom.Element;
public class SubNode {
private Element element;
public SubNode(Element element) {
this.element = element;
}
public Element getElement() {
return this.element;
}
public void setElement(Element element) {
this.element = element;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util.parse;
import com.airport.util.Utils;
import java.io.IOException;
import java.io.StringReader;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.xml.sax.InputSource;
public class XMPParse {
public XMPParse() {
}
public static final Date nodeValue2Date(String xmlFile, String xmlNodePath) {
String str = getNodeValue(xmlFile, xmlNodePath);
return !"".equals(str) ? Utils.iso8601DateStrToDate(str) : null;
}
public static final Date nodeValue2Date(String xmlFile, String xmlNodePath, Date date) {
String str = getNodeValue(xmlFile, xmlNodePath);
return !"".equals(str) ? Utils.iso8601DateStrToDate(str) : date;
}
public static final Date nodeAttribute2Date(String xmlFile, String xmlNodePath, String attributeName, Date date) {
String str = getNodeAttribute(xmlFile, xmlNodePath, attributeName, "");
return !"".equals(str) ? Utils.iso8601DateStrToDate(str) : date;
}
public static final String getNodeValue(String xmlFile, String xmlNodePath) {
String[] nodes = xmlNodePath.split("/");
new Document();
SAXBuilder builder = new SAXBuilder();
Element root = null;
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
Document document;
try {
document = builder.build(xmlFile);
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
root = document.getRootElement();
snode = new SubNode(root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getText();
n = null;
} catch (Exception var15) {
var15.printStackTrace();
} finally {
listNode.clear();
document = null;
root = null;
builder = null;
nodes = null;
}
System.out.println("key=" + xmlNodePath + " value=" + value);
return value;
}
public static final String getNodeValueFromXmlString(String xmlString, String xmlNodePath) throws Exception {
String[] nodes = xmlNodePath.split("/");
new Document();
SAXBuilder builder = new SAXBuilder();
Element root = null;
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
Document document;
try {
StringReader xmlReader = new StringReader(xmlString);
InputSource xmlSource = new InputSource(xmlReader);
document = builder.build(xmlSource);
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
root = document.getRootElement();
snode = new SubNode(root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getText();
n = null;
return value;
} catch (Exception var17) {
var17.printStackTrace();
throw var17;
} finally {
listNode.clear();
document = null;
root = null;
builder = null;
nodes = null;
}
}
public static final String getNodeAttribute(String xmlFile, String xmlNodePath, String attributeName, String defaultValue) {
String[] nodes = xmlNodePath.split("/");
new Document();
SAXBuilder builder = new SAXBuilder();
Element root = null;
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
Document document;
try {
document = builder.build(xmlFile);
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
root = document.getRootElement();
snode = new SubNode(root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getAttributeValue(attributeName, defaultValue);
n = null;
} catch (JDOMException var18) {
var18.printStackTrace();
} catch (IOException var19) {
var19.printStackTrace();
} finally {
listNode.clear();
document = null;
root = null;
builder = null;
nodes = null;
}
System.out.println("key=" + xmlNodePath + " node attrivte value=" + value);
return value;
}
}
... ...
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util.parse;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class XmlDocument {
private Document document = null;
private SAXBuilder builder = null;
private Element root = null;
private String xmlFile;
public XmlDocument(String xmlFileName) {
this.xmlFile = xmlFileName;
try {
this.builder = new SAXBuilder();
this.document = new Document();
this.document = this.builder.build(this.xmlFile);
} catch (JDOMException var3) {
var3.printStackTrace();
} catch (IOException var4) {
var4.printStackTrace();
}
}
public void destory() {
this.document = null;
this.root = null;
this.builder = null;
}
public String getStringFromInnerText(String xmlNodePath) {
String[] nodes = xmlNodePath.split("/");
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
try {
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
this.root = this.document.getRootElement();
snode = new SubNode(this.root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getText();
n = null;
} catch (Exception var12) {
var12.printStackTrace();
} finally {
listNode.clear();
}
return value;
}
public String getStringFromXmlNodeAttribute(String xmlNodePath, String attributeName, String defaultValue) {
String[] nodes = xmlNodePath.split("/");
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
try {
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
this.root = this.document.getRootElement();
snode = new SubNode(this.root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getAttributeValue(attributeName, defaultValue);
n = null;
} catch (Exception var14) {
var14.printStackTrace();
} finally {
listNode.clear();
}
return value;
}
}
... ...
package com.thinkgem.jeesite.common.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
public class NullConverter implements Converter {
private Map<Class<?>, List<String>> attributes = null;
public void regAttribute(Class<?> type, String attribute)
{
if (null == attributes)
{
attributes = new HashMap<Class<?>, List<String>>();
}
List value = attributes.get(type);
if (null == value)
{
value = new ArrayList<String>();
attributes.put(type, value);
}
value.add(attribute);
}
/**
* 是否是属性(是属性的不用以单独标签实现)
* @param type
* @param attribute
* @return
*/
public boolean isClassAttribute(Class<?> type,String attribute) {
List<String> value = getAttributes(type);
if (type.equals(Integer.class) || type.equals(Double.class)
|| type.equals(Long.class) || type.equals(Short.class)
|| type.equals(Float.class) || type.equals(BigDecimal.class)
|| type.equals(int.class) || type.equals(float.class)
|| type.equals(long.class) || type.equals(double.class)
|| type.equals(short.class)) {
return true;
}
return false;
}
/**
* 获取注册的属性
* @param type
* @return
*/
public List<String> getAttributes(Class<?> type) {
if (null != attributes){
return attributes.get(type);
}
return null;
}
/**
* 输出对象的属性标签
* @param source
* @param writer
*/
public void writerAttribute (Object source, HierarchicalStreamWriter writer) {
Class cType = source.getClass();
List<String> value = getAttributes(cType);
if ((null != value) && (value.size() > 0)){
Method[] methods = cType.getMethods();
for (Method method : methods){
String methodName = method.getName();
if (methodName.indexOf("get") != -1 && methodName != "getClass") {
String name = methodName.substring(3);
name = name.toLowerCase();
if (value.contains(name)){
Object o = null;
try {
o = method.invoke(source, null);
} catch (Exception e) {
e.printStackTrace();
}
writer.addAttribute(name, o==null?"":o.toString());
}
}
}
}
}
@SuppressWarnings("unchecked")
public void marshal(Object source, HierarchicalStreamWriter writer,
MarshallingContext context) {
if (null == source)
return;
Class cType = source.getClass();
Field[] fields = cType.getDeclaredFields();
if (source instanceof List) {
List list = (List) source;
for (Object obj : list) {
XStreamAlias alias = obj.getClass().getAnnotation(XStreamAlias.class);
if (alias != null) {
writer.startNode(alias.value());
marshal(obj, writer, context);
writer.endNode();
}else {
marshal(obj, writer, context);
}
}
} else {
for (Field field : fields) {
//获得get方法
String temp1 = "get"
+ field.getName().substring(0, 1).toUpperCase()
+ field.getName().substring(1);
Method m = null;
try {
m = cType.getMethod(temp1, null);
} catch (SecurityException e1) {
e1.printStackTrace();
} catch (NoSuchMethodException e1) {
e1.printStackTrace();
}
String methodName = m.getName();
if (methodName.indexOf("get") != -1 && methodName != "getClass") {
boolean isBaseType = isBaseType(m.getReturnType());
String name = methodName.substring(3);
Object o = null;
try {
o = m.invoke(source, null);
} catch (Exception e) {
e.printStackTrace();
}
//递归打出基础类型值
if (isBaseType) {
if(getAliasByNameAndType(name, cType)!=null){
writer.startNode(getAliasByNameAndType(name, cType).value());
writeData(o, m.getReturnType(), writer);
writer.endNode();
}
} else {
XStreamAlias alias = getAliasByNameAndType(name, cType);
if (alias == null) {
marshal(o, writer, context);
} else {
writer.startNode(alias.value());
marshal(o, writer, context);
writer.endNode();
}
}
}
}
}
}
/**
* 根据Name和类获得Xstream注解
* @param name
* Name
* @param cType
* 类
* @return
* XStreamAlias
*/
private XStreamAlias getAliasByNameAndType(String name,Class<?> cType){
String temp = name.substring(0, 1).toLowerCase()
+ name.substring(1);
Field f = null;
try {
f = cType.getDeclaredField(temp);
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
XStreamAlias alias = f.getAnnotation(XStreamAlias.class);
return alias;
}
/**
* 改写输出XML
* @param o
* @param ReturnType
* @param writer
*/
private void writeData(Object o,Class<?> ReturnType,HierarchicalStreamWriter writer) {
//如果是数字类型的话就要预设为0而不能为空
if (isNumValueType(ReturnType)) {
if (o == null) {
writer.setValue("0");
}else if (ReturnType.equals(Double.class)||ReturnType.equals(double.class)||ReturnType.equals(BigDecimal.class)) {
DecimalFormat df = new DecimalFormat("#.##");
writer.setValue(df.format(o));
}else {
writer.setValue(o.toString());
}
} else {
writer.setValue(o == null ? "" : o.toString());
}
}
public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
return null;
}
public boolean canConvert(Class type) {
return true;
}
/**
* 判断是否为基本类型
* @param type
* @return
* boolean
*/
private boolean isBaseType(Class<?> type) {
if (type.equals(Integer.class) || type.equals(Double.class)
|| type.equals(String.class) || type.equals(Boolean.class)
|| type.equals(Long.class) || type.equals(Short.class)
|| type.equals(Byte.class) || type.equals(Float.class)
|| type.equals(BigDecimal.class) || type.equals(int.class)
|| type.equals(float.class) || type.equals(long.class)
|| type.equals(double.class) || type.equals(short.class)
|| type.equals(boolean.class) || type.equals(byte.class)
|| type.equals(Timestamp.class)) {
return true;
}
return false;
}
/**
* 判断是否为数字类型
* @param type
* @return
* boolean
*/
public boolean isNumValueType(Class<?> type) {
if (type.equals(Integer.class) || type.equals(Double.class)
|| type.equals(Long.class) || type.equals(Short.class)
|| type.equals(Float.class) || type.equals(BigDecimal.class)
|| type.equals(int.class) || type.equals(float.class)
|| type.equals(long.class) || type.equals(double.class)
|| type.equals(short.class)) {
return true;
}
return false;
}
}
\ No newline at end of file
... ...
package com.thinkgem.jeesite.common.utils;
import org.springframework.stereotype.Component;
import com.thinkgem.jeesite.modules.xml.CommandXmlEntity;
import com.thinkgem.jeesite.modules.xml.MsgXmlEntity;
import com.thoughtworks.xstream.XStream;
@Component
public class XmlGen {
/**
* 生成抬杆xml报文
* @param entity
*/
public static String genControlCommandXml(CommandXmlEntity xmlVO){
XStream xstream = new XStream();
xstream.autodetectAnnotations(true);
//xstream.registerConverter(new NullConverter());
String xml = xstream.toXML(xmlVO);
xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+xml;
xml=xml.replace("__", "_");
System.out.println(xml);
return xml;
}
/**
* 生成IMF报文
* @param entity
*/
public static String genIMFXml(MsgXmlEntity msgXmlEntity){
XStream xstream = new XStream();
xstream.autodetectAnnotations(true);
xstream.registerConverter(new NullConverter());
String xml = xstream.toXML(msgXmlEntity);
xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+xml;
xml=xml.replace("__", "_");
System.out.println(xml);
return xml;
}
}
\ No newline at end of file
... ...
package com.thinkgem.jeesite.modules.xml;
import com.thinkgem.jeesite.common.utils.XmlGen;
/**
* 设备控制命令报文
*/
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
@XStreamAlias("COMMAND_INFO")
public class CommandXmlEntity {
@XStreamAsAttribute
@XStreamAlias("AREA_ID")
private String areaId; // 场站编号(10位)
@XStreamAsAttribute
@XStreamAlias("CHNL_NO")
private String chnlNo; //通道编号(10位)
@XStreamAsAttribute
@XStreamAlias("I_E_TYPE")
private String ieType; //进出卡口标志 I表示进卡口,E(字母)表示出卡口
@XStreamAsAttribute
@XStreamAlias("SEQ_NO")
private String seqNo; //20位的字符串。表示报文的序列号
@XStreamAlias("EXCUTE_COMMAND")
private String excuteCommand; //服务器返回指令定义
@XStreamAlias("GPS")
private GpsXmlEntity gps; //GPS信息部分
@XStreamAlias("SEAL")
private SealXmlEntity seal; //电子关锁信息部分
@XStreamAlias("ContaNum")
private String contaNum; //箱数
@XStreamAlias("OP_TYPE")
private String opType; //0:抬杠放行 1:待处理 2:退回
@XStreamAlias("OP_REASON")
private String opReason; //抬杠原因
@XStreamAlias("OP_ID")
private String opId; //操作人
public String getAreaId() {
return areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getChnlNo() {
return chnlNo;
}
public void setChnlNo(String chnlNo) {
this.chnlNo = chnlNo;
}
public String getIeType() {
return ieType;
}
public void setIeType(String ieType) {
this.ieType = ieType;
}
public String getSeqNo() {
return seqNo;
}
public void setSeqNo(String seqNo) {
this.seqNo = seqNo;
}
public String getExcuteCommand() {
return excuteCommand;
}
public void setExcuteCommand(String excuteCommand) {
this.excuteCommand = excuteCommand;
}
public GpsXmlEntity getGps() {
return gps;
}
public void setGps(GpsXmlEntity gps) {
this.gps = gps;
}
public SealXmlEntity getSeal() {
return seal;
}
public void setSeal(SealXmlEntity seal) {
this.seal = seal;
}
public String getContaNum() {
return contaNum;
}
public void setContaNum(String contaNum) {
this.contaNum = contaNum;
}
public String getOpType() {
return opType;
}
public void setOpType(String opType) {
this.opType = opType;
}
public String getOpReason() {
return opReason;
}
public void setOpReason(String opReason) {
this.opReason = opReason;
}
public String getOpId() {
return opId;
}
public void setOpId(String opId) {
this.opId = opId;
}
public static void main(String[] args) {
CommandXmlEntity xmlVO = new CommandXmlEntity();
GpsXmlEntity gps = new GpsXmlEntity();
SealXmlEntity seal = new SealXmlEntity();
xmlVO.setGps(gps);
xmlVO.setSeal(seal);
xmlVO.setAreaId("1");
xmlVO.setChnlNo("1");
xmlVO.setIeType("1");
xmlVO.setSeqNo("1");
xmlVO.setOpId("20181026");
String xml = XmlGen.genControlCommandXml(xmlVO);
}
}
... ...
package com.thinkgem.jeesite.modules.xml;
/**
* GPS信息
*/
import com.thoughtworks.xstream.annotations.XStreamAlias;
public class GpsXmlEntity {
@XStreamAlias("VE_NAME")
private String veName; // 海关车辆编号(值可以为空)
@XStreamAlias("GPS_ID")
private String gpsId; //GPS ID号
@XStreamAlias("ORIGIN_CUSTOMS")
private String originCustom; //源关区号
@XStreamAlias("DEST_CUSTOMS")
private String destCustoms; //目的关区号
public String getVeName() {
return veName;
}
public void setVeName(String veName) {
this.veName = veName;
}
public String getGpsId() {
return gpsId;
}
public void setGpsId(String gpsId) {
this.gpsId = gpsId;
}
public String getOriginCustom() {
return originCustom;
}
public void setOriginCustom(String originCustom) {
this.originCustom = originCustom;
}
public String getDestCustoms() {
return destCustoms;
}
public void setDestCustoms(String destCustoms) {
this.destCustoms = destCustoms;
}
}
... ...
package com.thinkgem.jeesite.modules.xml;
import com.thoughtworks.xstream.annotations.XStreamAlias;
public class MessageBodyXmlEntity {
@XStreamAlias("COMMAND_INFO")
private CommandXmlEntity commandXmlEntity;
public CommandXmlEntity getCommandXmlEntity() {
return commandXmlEntity;
}
public void setCommandXmlEntity(CommandXmlEntity commandXmlEntity) {
this.commandXmlEntity = commandXmlEntity;
}
}
... ...
package com.thinkgem.jeesite.modules.xml;
import java.util.Date;
import com.thinkgem.jeesite.common.utils.DateUtils;
/**
* MSG消息根标签
*/
import com.thoughtworks.xstream.annotations.XStreamAlias;
public class MetaXmlEntity {
@XStreamAlias("SNDR")
private String sndr; //消息发送者为FIMS
@XStreamAlias("RCVR")
private String rcvr; //消息接收者为空 代表发送给所有IMF预定义的接收者
@XStreamAlias("SEQN")
private String seqn; //本消息序号,消息唯一标识
@XStreamAlias("DDTM")
private String ddtm = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss"); //发送时间,格式为yyyyMMddHHmmss
@XStreamAlias("TYPE")
private String type; //消息大类型; DFOE
@XStreamAlias("STYP")
private String styp; //消息子类型; DFDL(整表消息)
public String getSndr() {
return sndr;
}
public void setSndr(String sndr) {
this.sndr = sndr;
}
public String getRcvr() {
return rcvr;
}
public void setRcvr(String rcvr) {
this.rcvr = rcvr;
}
public String getSeqn() {
return seqn;
}
public void setSeqn(String seqn) {
this.seqn = seqn;
}
public String getDdtm() {
return ddtm;
}
public void setDdtm(String ddtm) {
this.ddtm = ddtm;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getStyp() {
return styp;
}
public void setStyp(String styp) {
this.styp = styp;
}
}
... ...
package com.thinkgem.jeesite.modules.xml;
import com.thinkgem.jeesite.common.utils.XmlGen;
/**
* MSG消息根标签
*/
import com.thoughtworks.xstream.annotations.XStreamAlias;
@XStreamAlias("MSG")
public class MsgXmlEntity {
@XStreamAlias("META")
private MetaXmlEntity metaXmlEntity;
@XStreamAlias("MESSAGE_BODY")
private MessageBodyXmlEntity messageBody;
public MetaXmlEntity getMetaXmlEntity() {
return metaXmlEntity;
}
public void setMetaXmlEntity(MetaXmlEntity metaXmlEntity) {
this.metaXmlEntity = metaXmlEntity;
}
public MessageBodyXmlEntity getMessageBody() {
return messageBody;
}
public void setMessageBody(MessageBodyXmlEntity messageBody) {
this.messageBody = messageBody;
}
public static void main(String[] args) {
CommandXmlEntity commandXmlEntity = new CommandXmlEntity();
GpsXmlEntity gps = new GpsXmlEntity();
SealXmlEntity seal = new SealXmlEntity();
MsgXmlEntity msgXmlEntity = new MsgXmlEntity();
MetaXmlEntity metaXmlEntity = new MetaXmlEntity();
MessageBodyXmlEntity messageBody = new MessageBodyXmlEntity();
messageBody.setCommandXmlEntity(commandXmlEntity);
commandXmlEntity.setGps(gps);
commandXmlEntity.setSeal(seal);
msgXmlEntity.setMetaXmlEntity(metaXmlEntity);
msgXmlEntity.setMessageBody(messageBody);
String xml = XmlGen.genIMFXml(msgXmlEntity);
}
}
... ...
package com.thinkgem.jeesite.modules.xml;
/**
* 电子关锁信息部分
*/
import com.thoughtworks.xstream.annotations.XStreamAlias;
public class SealXmlEntity {
@XStreamAlias("ESEAL_ID")
private String esealId; // 关锁号码
@XStreamAlias("SEAL_KEY")
private String sealKey; //关锁密钥
@XStreamAlias("OPEN_TIMES")
private String openTimes; //电子关锁开启次数,当解封的时候下发
public String getEsealId() {
return esealId;
}
public void setEsealId(String esealId) {
this.esealId = esealId;
}
public String getSealKey() {
return sealKey;
}
public void setSealKey(String sealKey) {
this.sealKey = sealKey;
}
public String getOpenTimes() {
return openTimes;
}
public void setOpenTimes(String openTimes) {
this.openTimes = openTimes;
}
}
... ...
... ... @@ -17,11 +17,13 @@ import com.thinkgem.jeesite.common.persistence.DataEntity;
public class Bayonet extends DataEntity<Bayonet> {
private static final long serialVersionUID = 1L;
private Yard yard; //父表
private String yardId; // 场站
private String name; // 卡口名称
private String channel; // 通道编号
private String yardName; //场站名称
public Bayonet() {
super();
... ... @@ -31,7 +33,6 @@ public class Bayonet extends DataEntity<Bayonet> {
super(id);
}
@NotNull(message="场站名称不能为空")
@Length(min=0, max=64, message="场站长度必须介于 0 和 64 之间")
public String getYardId() {
return yardId;
... ... @@ -61,13 +62,12 @@ public class Bayonet extends DataEntity<Bayonet> {
this.channel = channel;
}
public String getYardName() {
return yardName;
public Yard getYard() {
return yard;
}
public void setYardName(String yardName) {
this.yardName = yardName;
public void setYard(Yard yard) {
this.yard = yard;
}
}
\ No newline at end of file
... ...
... ... @@ -20,7 +20,7 @@ public class Warehouse extends DataEntity<Warehouse> {
private String yardId; // 场站ID_父ID
private String name; // 仓库名称
private String yardName; //场站名称
private Yard yard; //父表
public Warehouse() {
super();
... ... @@ -48,14 +48,15 @@ public class Warehouse extends DataEntity<Warehouse> {
public void setName(String name) {
this.name = name;
}
public String getYardName() {
return yardName;
public Yard getYard() {
return yard;
}
public void setYardName(String yardName) {
this.yardName = yardName;
public void setYard(Yard yard) {
this.yard = yard;
}
}
\ No newline at end of file
... ...
... ... @@ -20,7 +20,7 @@ public class Wharf extends DataEntity<Wharf> {
private String yardId; // 场站ID_父ID
private String name; // 码头名称
private String yardName; //场站名称
private Yard yard; //父表
public Wharf() {
super();
... ... @@ -50,12 +50,13 @@ public class Wharf extends DataEntity<Wharf> {
}
public String getYardName() {
return yardName;
public Yard getYard() {
return yard;
}
public void setYardName(String yardName) {
this.yardName = yardName;
public void setYard(Yard yard) {
this.yard = yard;
}
}
\ No newline at end of file
... ...
... ... @@ -3,10 +3,13 @@
*/
package com.thinkgem.jeesite.modules.yard.entity;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.persistence.DataEntity;
/**
... ... @@ -20,6 +23,12 @@ public class Yard extends DataEntity<Yard> {
private String name; // 场站名称
private String customsCode; // 关区代码
private List<Bayonet> bayonetList = Lists.newArrayList(); // 卡口
private List<Wharf> WarfList = Lists.newArrayList(); // 码头
private List<Warehouse> warehouseList = Lists.newArrayList(); // 仓库
public Yard() {
super();
}
... ... @@ -46,5 +55,29 @@ public class Yard extends DataEntity<Yard> {
public void setCustomsCode(String customsCode) {
this.customsCode = customsCode;
}
public List<Bayonet> getBayonetList() {
return bayonetList;
}
public void setBayonetList(List<Bayonet> bayonetList) {
this.bayonetList = bayonetList;
}
public List<Warehouse> getWarehouseList() {
return warehouseList;
}
public void setWarehouseList(List<Warehouse> warehouseList) {
this.warehouseList = warehouseList;
}
public List<Wharf> getWarfList() {
return WarfList;
}
public void setWarfList(List<Wharf> warfList) {
WarfList = warfList;
}
}
\ No newline at end of file
... ...
... ... @@ -46,6 +46,13 @@ public class YardController extends BaseController {
return entity;
}
@RequestMapping(value = {"regist"})
public String regist() {
return "modules/yard/regist";
}
@RequiresPermissions("yard:yard:view")
@RequestMapping(value = {"list", ""})
public String list(Yard yard, HttpServletRequest request, HttpServletResponse response, Model model) {
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.thinkgem.jeesite.modules.yard.dao.BayonetDao">
<sql id="bayonetColumns">
p.name AS "yardName",
a.id AS "id",
a.yard_id AS "yardId",
a.name AS "name",
a.channel AS "channel",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
</sql>
<sql id="bayonetJoins">
LEFT JOIN yard p ON p.id = a.yard_id
</sql>
<select id="get" resultType="Bayonet">
SELECT
<include refid="bayonetColumns"/>
FROM bayonet a
<include refid="bayonetJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Bayonet">
SELECT
<include refid="bayonetColumns"/>
FROM bayonet a
<include refid="bayonetJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
<if test="yardName != null and yardName != ''">
AND p.name LIKE
<if test="dbName == 'oracle'">'%'||#{yardName}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{yardName}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{yardName},'%')</if>
</if>
<if test="name != null and name != ''">
AND a.name LIKE
<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
</if>
<if test="channel != null and channel != ''">
AND a.channel = #{channel}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="Bayonet">
SELECT
<include refid="bayonetColumns"/>
FROM bayonet a
<include refid="bayonetJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO bayonet(
id,
yard_id,
name,
channel,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{yardId},
#{name},
#{channel},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE bayonet SET
yard_id = #{yardId},
name = #{name},
channel = #{channel},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<update id="delete">
UPDATE bayonet SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -3,21 +3,14 @@
<mapper namespace="com.thinkgem.jeesite.modules.yard.dao.BayonetDao">
<sql id="bayonetColumns">
p.name AS "yardName",
a.id AS "id",
a.yard_id AS "yardId",
a.name AS "name",
a.channel AS "channel",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
a.*,
b.id AS "yard.id",
b.name AS "yard.name",
b.customs_code AS "yard.customsCode"
</sql>
<sql id="bayonetJoins">
LEFT JOIN yard p ON p.id = a.yard_id
JOIN yard b ON b.id = a.yard_id
</sql>
<select id="get" resultType="Bayonet">
... ... @@ -35,11 +28,11 @@
<include refid="bayonetJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
<if test="yardName != null and yardName != ''">
AND p.name LIKE
<if test="dbName == 'oracle'">'%'||#{yardName}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{yardName}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{yardName},'%')</if>
<if test="yard != null and yard != ''">
AND b.name LIKE
<if test="dbName == 'oracle'">'%'||#{yard.name}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{yard.name}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{yard.name},'%')</if>
</if>
<if test="name != null and name != ''">
AND a.name LIKE
... ... @@ -107,7 +100,7 @@
<update id="update">
UPDATE bayonet SET
yard_id = #{yardId},
yard_id = #{yard.id},
name = #{name},
channel = #{channel},
update_by = #{updateBy.id},
... ...
... ... @@ -3,20 +3,14 @@
<mapper namespace="com.thinkgem.jeesite.modules.yard.dao.WarehouseDao">
<sql id="warehouseColumns">
p.name AS "yardName",
a.id AS "id",
a.yard_id AS "yardId",
a.name AS "name",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
a.*,
b.id AS "yard.id",
b.name AS "yard.name",
b.customs_code AS "yard.customsCode"
</sql>
<sql id="warehouseJoins">
LEFT JOIN yard p ON p.id = a.yard_id
JOIN yard b ON b.id = a.yard_id
</sql>
<select id="get" resultType="Warehouse">
... ... @@ -34,11 +28,11 @@
<include refid="warehouseJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
<if test="yardName != null and yardName != ''">
AND p.name LIKE
<if test="dbName == 'oracle'">'%'||#{yardName}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{yardName}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{yardName},'%')</if>
<if test="yard != null and yard != ''">
AND b.name LIKE
<if test="dbName == 'oracle'">'%'||#{yard.name}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{yard.name}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{yard.name},'%')</if>
</if>
<if test="name != null and name != ''">
AND a.name LIKE
... ...
... ... @@ -3,20 +3,14 @@
<mapper namespace="com.thinkgem.jeesite.modules.yard.dao.WharfDao">
<sql id="wharfColumns">
p.name AS "yardName",
a.id AS "id",
a.yard_id AS "yardId",
a.name AS "name",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
a.*,
b.id AS "yard.id",
b.name AS "yard.name",
b.customs_code AS "yard.customsCode"
</sql>
<sql id="wharfJoins">
LEFT JOIN yard p ON p.id = a.yard_id
JOIN yard b ON b.id = a.yard_id
</sql>
<select id="get" resultType="Wharf">
... ... @@ -34,11 +28,11 @@
<include refid="wharfJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
<if test="yardName != null and yardName != ''">
AND p.name LIKE
<if test="dbName == 'oracle'">'%'||#{yardName}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{yardName}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{yardName},'%')</if>
<if test="yard != null and yard != ''">
AND b.name LIKE
<if test="dbName == 'oracle'">'%'||#{yard.name}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{yard.name}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{yard.name},'%')</if>
</if>
<if test="name != null and name != ''">
AND a.name LIKE
... ...
... ... @@ -26,7 +26,7 @@
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<ul class="ul-form">
<li><label>场站名称:</label>
<form:input path="yardName" htmlEscape="false" maxlength="64" class="input-medium"/>
<form:input path="yard.name" htmlEscape="false" maxlength="64" class="input-medium"/>
</li>
<li><label>卡口名称:</label>
<form:input path="name" htmlEscape="false" maxlength="100" class="input-medium"/>
... ... @@ -53,7 +53,7 @@
<c:forEach items="${page.list}" var="bayonet">
<tr>
<td><a href="${ctx}/yard/bayonet/form?id=${bayonet.id}">
${bayonet.yardName}
${bayonet.yard.name}
</a></td>
<td>
${bayonet.name}
... ...
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<script language="javascript" type="text/javascript" src="http://59.110.221.138/cargosys/LoginAuthen.aspx
" ></script>
<script language="javascript">
registAoerLoginInfo('09239216-517b-4149-9f67-8eae0f6e7aec');
</script>
</html>
\ No newline at end of file
... ...
... ... @@ -26,7 +26,7 @@
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<ul class="ul-form">
<li><label>场站名称:</label>
<form:input path="yardName" htmlEscape="false" class="input-medium"/>
<form:input path="yard.name" htmlEscape="false" class="input-medium"/>
</li>
<li><label>仓库名称:</label>
<form:input path="name" htmlEscape="false" maxlength="100" class="input-medium"/>
... ... @@ -49,7 +49,7 @@
<c:forEach items="${page.list}" var="warehouse">
<tr>
<td><a href="${ctx}/yard/warehouse/form?id=${warehouse.id}">
${warehouse.yardName}
${warehouse.yard.name}
</a></td>
<td>
${warehouse.name}
... ...
... ... @@ -26,7 +26,7 @@
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<ul class="ul-form">
<li><label>场站名称:</label>
<form:input path="yardName" htmlEscape="false" class="input-medium"/>
<form:input path="yard.name" htmlEscape="false" class="input-medium"/>
</li>
<li><label>码头名称:</label>
<form:input path="name" htmlEscape="false" maxlength="100" class="input-medium"/>
... ... @@ -49,7 +49,7 @@
<c:forEach items="${page.list}" var="wharf">
<tr>
<td><a href="${ctx}/yard/wharf/form?id=${wharf.id}">
${wharf.yardName}
${wharf.yard.name}
</a></td>
<td>
${wharf.name}
... ...
... ... @@ -43,7 +43,13 @@
<div class="control-group">
<label class="control-label">关区代码:</label>
<div class="controls">
<form:input path="customsCode" htmlEscape="false" maxlength="10" class="input-xlarge required"/>
<%-- <form:input path="customsCode" htmlEscape="false" maxlength="10" class="input-xlarge required"/>
<span class="help-inline"><font color="red">*</font> </span> --%>
<form:select path="customsCode" class="input-medium required">
<form:option value="" label="请选择关区"/>
<form:option value="4604" >4604</form:option>
<form:option value="4620" >4620</form:option>
</form:select>
<span class="help-inline"><font color="red">*</font> </span>
</div>
</div>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"
default-lazy-init="false">
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${db_driver}" />
<property name="jdbcUrl" value="${db_url}" />
<property name="user" value="${db_user}" />
<property name="password" value="${db_pass}" />
<property name="minPoolSize" value="1" />
<property name="maxPoolSize" value="1" />
<property name="initialPoolSize" value="1" />
<property name="maxIdleTime" value="1800" />
<property name="acquireIncrement" value="1" />
<property name="idleConnectionTestPeriod" value="10000" />
<property name="acquireRetryAttempts" value="30" />
<property name="testConnectionOnCheckin" value="true" />
<property name="acquireRetryDelay" value="1000"/>
<property name="automaticTestTable" value="c3p0TestTable_jwe"/>
<property name="checkoutTimeout" value="60000"/>
<property name="numHelperThreads" value="5"/>
</bean>
<bean id='configurationBean' class="com.airport.util.Configuration" >
<property name="location" value="file:config/config.properties"/>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="dao" class="com.airport.dao.impl.DaoImpl">
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
</beans>
\ No newline at end of file
... ...
#########################################################
db_driver=oracle.jdbc.driver.OracleDriver
db_url=jdbc:oracle:thin:@10.50.3.68:1521:CGODW
db_user=cgoetl
db_pass=1q2w3e4r
#########################################################
#R:receiver S:sender,
role=S
imf_username=DLCF
imf_password=DLCF_P
#########################################################
interval=5
record_count=350
total_group=1
#########################################################
sndr_1=DLCF
rcvr_1=
type_1=HYXX
stype_1=DLCF
#########################################################
sndr_2=SJCK
rcvr_2=
type_2=HYXX
stype_2=CKSY
... ...
#log4j=/home/imf/log_api.xml
isneedlog=N
psip=10.50.3.74
psport=7484
encoding=UTF-8
... ...
########Log4j configuration#####################################
log4j.rootLogger=INFO, stdout, fileout
log4j.logger.com.fiscal = INFO
#*******************************
log4j.logger.com.system = INFO
#*******************************
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{MM-dd HH:mm:ss,SSSS}[%p] %m%n
#yyyy-MM-dd HH:mm:ss
log4j.appender.fileout=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=logs/imf.log
log4j.appender.fileout.MaxFileSize=50MB
log4j.appender.fileout.MaxBackupIndex=10
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=%d{MM-dd HH:mm:ss,SSSS}[%p] %m%n
... ...