作者 朱兆平

优化国际转运分单回执解析

... ... @@ -59,14 +59,11 @@ spring:
# username: root
# password:
# driver-class-name: com.mysql.jdbc.Driver
max-idle: 20
max-wait: 10000
min-idle: 5
initial-size: 5
#配置初始化大小/最小/最大
druid:
initial-size: 1
min-idle: 1
initial-size: 5
min-idle: 5
#最大并发连接数
max-active: 40
#获取连接等待超时时间
... ... @@ -80,9 +77,38 @@ spring:
#oracle
validation-query: SELECT 'x' FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-borrow: true
test-on-return: false
default-auto-commit: true
query-timeout: 30
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
use-global-data-source-stat: true
filters: stat,wall,slf4j
# 下面3个enabled改为true即开启druid monitor
filter:
config:
enabled: true
# 配置 DruidStatFilter
web-stat-filter:
enabled: true
url-pattern: /*
exclusions: .js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*
# 配置 DruidStatViewServlet
stat-view-servlet:
enabled: true
url-pattern: /druid/*
# IP 白名单,没有配置或者为空,则允许所有访问
allow: 127.0.0.1
# IP 黑名单,若白名单也存在,则优先使用
deny:
# 禁用 HTML 中 Reset All 按钮
reset-enable: false
# # 登录用户名/密码
# login-username: 123
# login-password: 123
eureka:
instance:
... ... @@ -91,13 +117,14 @@ eureka:
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${server.port}
hostname: ${spring.cloud.client.ip-address}
lease-renewal-interval-in-seconds: 15
lease-expiration-duration-in-seconds: 45
client:
#eureka注册中心服务器地址
service-url:
defaultZone: http://192.168.1.53:12345/eureka/
registry-fetch-interval-seconds: 30
lease-renewal-interval-in-seconds: 15
lease-expiration-duration-in-seconds: 45
... ... @@ -184,4 +211,4 @@ mq:
# port: 5672
# vHost: NMMS
# username: mrz
# password: vmvnv1v2
\ No newline at end of file
# password: vmvnv1v2
... ...
... ... @@ -12,7 +12,7 @@
</parent>
<groupId>com.tianbo</groupId>
<artifactId>analysis</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.13-Realese</version>
<name>customAnalysis</name>
<description>Analysis waybill recept</description>
<properties>
... ... @@ -71,9 +71,14 @@
<!--数据库-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>druid</artifactId>-->
<!-- <version>${druid.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
... ... @@ -438,4 +443,4 @@
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
\ No newline at end of file
</project>
... ...
... ... @@ -4,6 +4,8 @@
*/
package com.tianbo.analysis;
import com.tianbo.analysis.bean.SpringBeanUtitl;
import com.tianbo.analysis.bean.WlptBaseModel;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
... ... @@ -23,18 +25,24 @@ import java.time.Duration;
@EnableDiscoveryClient
@EnableTransactionManagement
@MapperScan("com.tianbo.analysis.dao")
public class BootApplication {
public class CustomAnalysisBootApplication {
public static void main(String[] args) {
SpringApplication.run(BootApplication.class, args);
SpringApplication.run(CustomAnalysisBootApplication.class, args);
// initCompent();
}
@Bean
@LoadBalanced
// @LoadBalanced
RestTemplate restTemplate(RestTemplateBuilder builder){
return builder.setConnectTimeout(Duration.ofSeconds(15)).setReadTimeout(Duration.ofSeconds(15))
return builder.setConnectTimeout(Duration.ofSeconds(3)).setReadTimeout(Duration.ofSeconds(3))
.build();
}
public static void initCompent(){
WlptBaseModel wlptBaseModel = (WlptBaseModel) SpringBeanUtitl.getBean("wlptBase");
wlptBaseModel.init();
}
}
... ...
package com.tianbo.analysis.bean;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import javax.servlet.Filter;
import javax.servlet.Servlet;
import javax.sql.DataSource;
@Configuration
public class DruidConfig {
// @Primary
// @Bean
// @ConfigurationProperties(prefix = "spring.datasource")
// public DataSource druidDataSource(){
// return DataSourceBuilder.create().type(DruidDataSource.class).build();
//// return new DruidDataSource();
// }
/**
* 配置druid在线监控的账号密码
* @return
*/
@Bean
public ServletRegistrationBean<Servlet> druidServlet(){
StatViewServlet statViewServlet = new StatViewServlet();
ServletRegistrationBean<Servlet> srb = new ServletRegistrationBean<>(statViewServlet, "/druid/*");
// 白名单
srb.addInitParameter("allow", "127.0.0.1");
// 黑名单
// srb.addInitParameter("deny", "10.*.*.*");
// 用户名
srb.addInitParameter("loginUsername", "tianbo");
// 密码
srb.addInitParameter("loginPassword", "vmvnv1v2VV.");
// 是否可以重置数据源
srb.addInitParameter("resetEnable", "false");
return srb;
}
// @Bean
// public FilterRegistrationBean<Filter> filterRegistrationBean(){
// FilterRegistrationBean<Filter> frb = new FilterRegistrationBean<>();
// WebStatFilter webStatFilter = new WebStatFilter();
// // 所有请求进行监控处理
// frb.setFilter(webStatFilter);
// // 排除名单
// frb.addUrlPatterns("/*");
// frb.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");
// return frb;
// }
// @Bean
// PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor() {
// return new PersistenceExceptionTranslationPostProcessor();
// }
// @Bean
// public SqlSessionFactoryBean sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
// SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
// bean.setDataSource(dataSource);
// PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// bean.setMapperLocations(resolver.getResources("classpath:/mapping/*.xml"));
// return bean;
// }
}
... ...
... ... @@ -7,59 +7,61 @@ import com.tianbo.analysis.service.SendLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class WlptBaseModel {
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
@Component(value = "wlptBase")
public class WlptBaseModel {
@Autowired
@Resource
public ALLOCATEARRIVALMapper allocatearrivalMapper;
@Autowired
public SendLogService sendLogService;
@Autowired
@Resource
public ARRIVEDMASTERMapper arrivedmasterMapper;
@Autowired
@Resource
public ARRIVEDSECONDARYMapper arrivedsecondaryMapper;
@Autowired
@Resource
public DEPARTURESLOADINGMapper departuresloadingMapper;
@Autowired
@Resource
public INPORTALLOCATEMapper inportallocateMapper;
@Autowired
@Resource
public INTERNATIONALTRANSITMapper internationaltransitMapper;
@Autowired
@Resource
public ORIGINMANIFESTMASTERMapper originmanifestmasterMapper;
@Autowired
@Resource
public OriginmanifestsecondaryMapper originmanifestsecondaryMapper;
@Autowired
@Resource
public PREPAREMASTERMapper preparemasterMapper;
@Autowired
@Resource
public PREPARESECONDARYMapper preparesecondaryMapper;
@Autowired
@Resource
public TALLYMASTERMapper tallymasterMapper;
@Autowired
@Resource
public TALLYSECONDARYMapper tallysecondaryMapper;
@Autowired
@Resource
public CUSTOMSMESSAGEMapper customsmessageMapper;
@Autowired
public CustomMessageService customMessageService;
@Autowired
@Resource
public MANIFESTLOADMapper manifestloadMapper;
@Autowired
@Resource
public MANIFESTLOSTCHANGEMapper manifestlostchangeMapper;
... ... @@ -119,8 +121,9 @@ public class WlptBaseModel {
}
public static void init(){
@PostConstruct
public void init(){
System.out.print("\nWlptBaseModel的初始化值为:"+this.originmanifestmasterMapper);
}
public int masterAnalysisReception(){
... ...
package com.tianbo.analysis.controller;
import com.tianbo.analysis.handle.CustomResponseHandleThread;
import com.tianbo.analysis.service.CustomResponseAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/cust")
public class CustomResponseController {
@Autowired
CustomResponseAnalysisService customResponseAnalysisService;
@RequestMapping("analysis")
public boolean analysis(@RequestParam(value = "xml",required = true) String xml){
boolean result = customResponseAnalysisService.xmlAnalysis(xml);
return result;
}
}
... ...
package com.tianbo.analysis.handle;
import com.tianbo.analysis.bean.SpringBeanUtitl;
import com.tianbo.analysis.model.Agent_Notice;
import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.tools.AWBTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
... ... @@ -20,14 +22,20 @@ public class AgentXmlHandle {
private static AgentXmlHandle agentXmlHandle;
@Autowired
RestTemplate restTemplate;
@PostConstruct
public void init() {
agentXmlHandle = this;
agentXmlHandle.restTemplate = this.restTemplate;
// 初使化时将已静态化的testService实例化
}
public void Http_resolver(CustomReception customReception){
try{
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(3000);
requestFactory.setReadTimeout(3000);
RestTemplate restTemplate = new RestTemplate(requestFactory);
String secondSplit = "_";
String waybillnosecondary="";
if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
... ... @@ -36,14 +44,14 @@ public class AgentXmlHandle {
waybillnosecondary = awbhArr[1];
}
Agent_Notice notice = restTemplate.getForObject("http://10.50.3.73:1983/agent/receipt/a0608c4054662dd902e1314f7e450e3eaa81c114?message_type={1}&waybillNo={2}&waybillNoSub={3}&response_code={4}&response_text={5}"
Agent_Notice notice = agentXmlHandle.restTemplate.getForObject("http://10.50.3.73:1983/agent/receipt/a0608c4054662dd902e1314f7e450e3eaa81c114?message_type={1}&waybillNo={2}&waybillNoSub={3}&response_code={4}&response_text={5}"
, Agent_Notice.class,"MT2201", AWBTools.awbFormat(customReception.getWayBillMaster()),waybillnosecondary,customReception.getResponseCode(),customReception.getResponseText());
log.info(notice.toString());
}catch (Exception e){
log.error("链接代理人服务器超时或者接口异常,{}",e);
}
}
}
... ...
... ... @@ -79,8 +79,10 @@ public class CustomXmlHandleThread implements Runnable{
*/
public final static String ImportJourneyID = "//Manifest/Response/ImportInformation/BorderTransportMeans/JourneyID";
public final static String ImportWaybillMaster = "//Manifest/Response/ImportInformation/Consignment/TransportContractDocument/ID";
public final static String ImportWaybillSecond = "//Manifest/Response/ImportInformation/Consignment/AssociatedTransportDocument/ID";
public final static String ExportJourneyID = "//Manifest/Response/ExportInformation/BorderTransportMeans/JourneyID";
public final static String ExportWaybillMaster = "//Manifest/Response/ExportInformation/Consignment/TransportContractDocument/ID";
public final static String ExportWaybillSecond = "//Manifest/Response/ExportInformation/Consignment/AssociatedTransportDocument/ID";
// public final static String TransResponseCode = "//Manifest/Response/ResponseType/Code";
// public final static String TransResponseText = "//Manifest/Response/ResponseType/Text";
public final static String TransResponseCode = "//ResponseType/Code";
... ... @@ -347,12 +349,14 @@ public class CustomXmlHandleThread implements Runnable{
String importWaybillMaster= XMLXPath.getSingleValueByPath(document,ImportWaybillMaster);
String importWaybillSecond= XMLXPath.getSingleValueByPath(document,ImportWaybillSecond);
String transResponseCode=XMLXPath.getSingleValueByPath(document,TransResponseCode);
String transResponseText=XMLXPath.getSingleValueByPath(document,TransResponseText);
CustomReception transCustomReception = new CustomReception( customReception.getMessageType(),
importFlightNo,
importFlightDate,
importWaybillMaster,
importWaybillSecond,
transResponseCode,
transResponseText,
customReception.getMessageID(),
... ...
... ... @@ -55,6 +55,10 @@ public class CustomReception {
this.receiverID = receiverID;
this.version = version;
this.functionCode = functionCode;
this.importFlightNo = flightNo;
this.importFlightDate = flightDate;
this.importWaybillMaster = wayBillMaster;
}
public CustomReception(String messageType,
... ...
... ... @@ -3,8 +3,10 @@ package com.tianbo.analysis.model;
import com.tianbo.analysis.bean.WlptBaseModel;
import com.tianbo.analysis.tools.AWBTools;
import com.tianbo.util.Date.DateUtil;
import com.tianbo.util.String.StringUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.util.Date;
import java.util.List;
... ... @@ -222,8 +224,9 @@ public class INTERNATIONALTRANSIT extends WlptBaseModel {
this.originalFlightdate = DateUtil.formatByyyyyMMdd(customReception.getImportFlightDate());
this.originalBillno = AWBTools.awbFormat(customReception.getImportWaybillMaster());
//TODO:碰见分单回执再解析
this.originalSubNumber = customReception.getWayBillSecond();
if (StringUtils.isNotBlank(customReception.getWayBillSecond())){
this.originalSubNumber = customReception.getWayBillSecond().split("_")[1];
}
this.status = AWBTools.transCusRspCode(customReception.getResponseCode());
this.receiption = customReception.getResponseText();
}
... ... @@ -237,13 +240,13 @@ public class INTERNATIONALTRANSIT extends WlptBaseModel {
String autoId = internationaltransit.getAutoid();
//插入sendlog记录表
log.info("即将插入国际转运日志运单号为:"+originalBillno+"->autoid="+autoId);
log.info("即将插入国际转运日志主运单号为:{},分单:{},->autoid={}",originalBillno,originalSubNumber,autoId);
int ii =sendLogService.insertSendlog("MT8205",receiption,autoId);
if (i>0 && ii>0){
log.info("运单号 {} 国际转运回执更新成功",originalBillno);
log.info("运单号 {}{} 国际转运回执更新成功",originalBillno,originalSubNumber);
return 1;
}
}
return 0;
}
}
\ No newline at end of file
}
... ...
package com.tianbo.analysis.service;
/**
* @author mrz
*/
public interface CustomResponseAnalysisService {
/**
* 解析海关回执xml
* @param var 回执内容
* @return 解析成功或者失败
*/
boolean xmlAnalysis(String var);
/**
* 备份报文报文名称根据uuid生成 扩展名为xml
* @param responseText 报文内容
* @param dir 备份目录
*/
void bakXml(String responseText,String dir);
}
... ...
package com.tianbo.analysis.service.imp;
import com.tianbo.analysis.handle.AgentXmlHandle;
import com.tianbo.analysis.model.*;
import com.tianbo.analysis.service.CustomResponseAnalysisService;
import com.tianbo.analysis.tools.AWBTools;
import com.tianbo.util.Date.DateUtil;
import com.tianbo.util.XML.XMLXPath;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileExistsException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.xml.sax.SAXParseException;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
@Service
@Slf4j
public class CustomResponseAnalysisServiceImp implements CustomResponseAnalysisService {
//解析出错转移目录
@Value("${custom.errBakDir}")
private String errBakDir;
@Value("${custom.receptBakDir}")
private String receptBakDir;
/**
* 单一窗口回执的技术回执
*/
public final static String DONT_NEED = "<Code>0</Code><Text>接收成功</Text>";
//海关新舱单回执报头
public final static String MessageID = "//Manifest/Head/MessageID";
public final static String FunctionCode = "//Manifest/Head/FunctionCode";
public final static String MessageType = "//Manifest/Head/MessageType";
public final static String SenderID = "//Manifest/Head/SenderID";
public final static String ReceiverID = "//Manifest/Head/ReceiverID";
public final static String SendTime = "//Manifest/Head/SendTime";
public final static String Version = "//Manifest/Head/Version";
/**
* 海关普通业务新舱单回执报体
*/
public final static String JourneyID = "//Manifest/Response/BorderTransportMeans/JourneyID";
public final static String WaybillMaster = "//Manifest/Response/Consignment/TransportContractDocument/ID";
public final static String WaybillSecond = "//Manifest/Response/Consignment/AssociatedTransportDocument/ID";
public final static String ResponseCode = "//ResponseType/Code";
public final static String ResponseText = "//ResponseType/Text";
/**
* 海关国际转运业务回执报体
*/
public final static String ImportJourneyID = "//Manifest/Response/ImportInformation/BorderTransportMeans/JourneyID";
public final static String ImportWaybillMaster = "//Manifest/Response/ImportInformation/Consignment/TransportContractDocument/ID";
public final static String ImportWaybillSecond = "//Manifest/Response/ImportInformation/Consignment/AssociatedTransportDocument/ID";
public final static String ExportJourneyID = "//Manifest/Response/ExportInformation/BorderTransportMeans/JourneyID";
public final static String ExportWaybillMaster = "//Manifest/Response/ExportInformation/Consignment/TransportContractDocument/ID";
// public final static String TransResponseCode = "//Manifest/Response/ResponseType/Code";
// public final static String TransResponseText = "//Manifest/Response/ResponseType/Text";
public final static String TransResponseCode = "//ResponseType/Code";
public final static String TransResponseText = "//ResponseType/Text";
@Override
public boolean xmlAnalysis(String xmlStr) {
String today = DateUtil.getTodayBy_yyyyMMdd();
String errDirByDay = errBakDir + "/" + today;
String failDirByDay = errBakDir+ "Fail" + "/" + today;
String successDir = receptBakDir + "/" + today;
if(xmlStr.contains(DONT_NEED)){
// bakXml(xmlStr,errDirByDay);
log.info("报文为技术回执备份成功..开始解析下一文件,当前线程即将结束");
}
else
{
try{
int i =handelXmlDocument(xmlStr);
//操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份
if(i>0){
// bakXml(xmlStr,successDir);
log.info("报文解析入库成功");
return true;
}else {
// bakXml(xmlStr,errDirByDay);
return true;
}
}catch (Exception e){
log.error("报文备份异常",e);
bakXml(xmlStr,failDirByDay);
e.printStackTrace();
return false;
}
}
log.info("线程结束");
return false;
}
private int handelXmlDocument(String xml) throws DocumentException, UnsupportedEncodingException, SAXParseException, FileNotFoundException {
int i = 0;
String secondSplit = "_";
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
Element contentRoot = document.getRootElement();
String flightNo = "UNKONW";
String flightDate = "20101010";
//开始解析
String msgType = XMLXPath.getSingleValueByPath(document,MessageType);
String journeyid = XMLXPath.getSingleValueByPath(document,JourneyID);
// XMLXPath.getSingleValueByPath(document, )
String awbA = XMLXPath.getSingleValueByPath(document,WaybillMaster);
//全格式的分单 如 17212345678_ADBD
String awbH = XMLXPath.getSingleValueByPath(document,WaybillSecond);
String resCode = XMLXPath.getSingleValueByPath(document,ResponseCode);
String resText = XMLXPath.getSingleValueByPath(document,ResponseText);
String messageId = XMLXPath.getSingleValueByPath(document, MessageID);
String sendTime = XMLXPath.getSingleValueByPath(document,SendTime);
String sendId = XMLXPath.getSingleValueByPath(document,SenderID);
String reciveId = XMLXPath.getSingleValueByPath(document,ReceiverID);
String version = XMLXPath.getSingleValueByPath(document,Version);
String functionCode = XMLXPath.getSingleValueByPath(document,FunctionCode);
CustomReception customReception = new CustomReception( msgType,
flightNo,
flightDate,
awbA,
awbH,
resCode,
resText,
messageId,
sendTime,
sendId,
reciveId,
version,
functionCode);
/**
* 如果回执中没有携带航班信息节点,说明是出错报文
* 到发送日志表根据messageid 找到相应的发送日志报文的航班及运单信息,再进行解析
*/
if(!StringUtils.isEmpty(journeyid)){
String[] flightList = journeyid.split("/");
if(flightList.length > 0){
flightNo = flightList[0];
flightDate = flightList[1];
customReception.setFlightNo(flightNo);
customReception.setFlightDate(flightDate);
}
}else {
CUSTOMSMESSAGE customsmessage = new CUSTOMSMESSAGE();
customReception = customsmessage.getWaybillInfoByCutomResponse(customReception);
}
switch (msgType){
case "MT9999":
if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
PREPARESECONDARY preparesecondary = new PREPARESECONDARY(customReception);
int pre_i = preparesecondary.secondAnalysisReception();
if (pre_i>0){
i=1;
}else {
Originmanifestsecondary originmanifestsecondary = new Originmanifestsecondary(customReception);
int org_i=originmanifestsecondary.secondAnalysisReception();
if (org_i>0){
i= 1;
}else {
ARRIVEDSECONDARY arrivedsecondary = new ARRIVEDSECONDARY(customReception);
int arr_i=arrivedsecondary.secondAnalysisReception();
if (arr_i>0){
i=1;
}
}
}
}else{
ORIGINMANIFESTMASTER originmanifestmaster = new ORIGINMANIFESTMASTER(customReception);
PREPAREMASTER preparemaster= new PREPAREMASTER(customReception);
ARRIVEDMASTER arrivedmaster9999 = new ARRIVEDMASTER(customReception);
if(originmanifestmaster.masterAnalysisReception()>0){
i=1;
}else if(preparemaster.masterAnalysisReception()>0){
i=1;
}else {
i=arrivedmaster9999.masterAnalysisReception();
}
}
AgentXmlHandle agentXmlHandle=new AgentXmlHandle();
agentXmlHandle.Http_resolver(customReception);
break;
case "MT3201":
if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
ARRIVEDSECONDARY arrivedsecondary = new ARRIVEDSECONDARY(customReception);
i=arrivedsecondary.secondAnalysisReception();
}else {
ARRIVEDMASTER arrivedmaster = new ARRIVEDMASTER(customReception);
i=arrivedmaster.masterAnalysisReception();
}
break;
case "MT5202":
case "MT5201":
if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
TALLYSECONDARY tallysecondary = new TALLYSECONDARY(customReception);
i=tallysecondary.secondAnalysisReception();
}else {
TALLYMASTER tallymaster= new TALLYMASTER(customReception);
i = tallymaster.masterAnalysisReception();
}
break;
case "MT4201":
DEPARTURESLOADING departuresloading = new DEPARTURESLOADING(customReception);
i=departuresloading.masterAnalysisReception();
break;
case "MT1201":
if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
Originmanifestsecondary originmanifestsecondary = new Originmanifestsecondary(customReception);
i=originmanifestsecondary.secondAnalysisReception();
}else {
ORIGINMANIFESTMASTER originmanifestmaster1201 = new ORIGINMANIFESTMASTER(customReception);
i = originmanifestmaster1201.masterAnalysisReception();
}
break;
case "MT2201":
if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
PREPARESECONDARY preparesecondary = new PREPARESECONDARY(customReception);
i = preparesecondary.secondAnalysisReception();
}else {
PREPAREMASTER preparemaster1201= new PREPAREMASTER(customReception);
i = preparemaster1201.masterAnalysisReception();
}
break;
case "MT6202":
INPORTALLOCATE inportallocate = new INPORTALLOCATE(customReception);
i = inportallocate.masterAnalysisReception();
break;
case "MT3202":
ALLOCATEARRIVAL allocatearrival = new ALLOCATEARRIVAL(customReception);
i= allocatearrival.masterAnalysisReception();
break;
case "MT8205":
i = transXmlHandel(document,customReception);
break;
case "MT8202":
MANIFESTLOAD manifestload = new MANIFESTLOAD(customReception);
i= manifestload.secondAnalysisReception();
break;
case "MT8203":
MANIFESTLOSTCHANGE manifestlostchange = new MANIFESTLOSTCHANGE(customReception);
i= manifestlostchange.secondAnalysisReception();
break;
default:
break;
}
updateCustomMessage(customReception);
return i;
}
/**
* 国际转运回执处理,特殊业务
* @param document
* @param customReception
* @return
*/
private int transXmlHandel(Document document,CustomReception customReception){
String importJourneyID = XMLXPath.getSingleValueByPath(document,ImportJourneyID);
String importFlightNo = "UNKONW";
String importFlightDate = "20101010";
if(!StringUtils.isEmpty(importJourneyID)){
importFlightNo = AWBTools.splitFlightAndDate(importJourneyID)[0];
importFlightDate = AWBTools.splitFlightAndDate(importJourneyID)[1];
}
String importWaybillMaster= XMLXPath.getSingleValueByPath(document,ImportWaybillMaster);
String importWaybillSecond= XMLXPath.getSingleValueByPath(document,ImportWaybillSecond);
String transResponseCode=XMLXPath.getSingleValueByPath(document,TransResponseCode);
String transResponseText=XMLXPath.getSingleValueByPath(document,TransResponseText);
CustomReception transCustomReception = new CustomReception( customReception.getMessageType(),
importFlightNo,
importFlightDate,
importWaybillMaster,
importWaybillSecond,
transResponseCode,
transResponseText,
customReception.getMessageID(),
customReception.getSendTime(),
customReception.getSenderID(),
customReception.getReceiverID(),
customReception.getVersion(),
customReception.getFunctionCode());
INTERNATIONALTRANSIT internationaltransit = new INTERNATIONALTRANSIT(transCustomReception);
int i=internationaltransit.masterAnalysisReception();
return i;
}
public int updateCustomMessage(CustomReception customReception){
CUSTOMSMESSAGE customsmessage = new CUSTOMSMESSAGE(customReception);
return customsmessage.updateMessageByMessageid();
}
@Override
public void bakXml(String responseText, String dir){
try {
File errfile = new File(dir + "/" + UUID.randomUUID().toString()+".xml");
FileUtils.writeStringToFile(errfile,responseText,"UTF-8");
}catch (FileExistsException e){
e.printStackTrace();
log.error("文件重名,备份失败");
}catch (Exception e){
e.printStackTrace();
}
}
}
... ...
... ... @@ -5,9 +5,9 @@ import com.tianbo.analysis.model.SENDLOG;
import com.tianbo.analysis.service.SendLogService;
import com.tianbo.util.Helper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
... ... @@ -15,7 +15,7 @@ import java.util.Date;
@Slf4j
public class SendLogServiceImp implements SendLogService{
@Autowired
@Resource
private SENDLOGMapper sendlogMapper;
@Override
... ...
... ... @@ -30,14 +30,14 @@
<result column="CREATEDATE" property="createdate" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
AUTOID, WAYBILLNOMASTER, TCD_NAME, TCD_TYPECODE, FLIGHTNO, FLIGHTDATE, CARRIER, ORIGINATINGSTATION,
O_NAME, DESTINATIONSTATION, FD_NAME, ARRIVEDTOTALPIECE, TOTALPIECEQUANTITY, ARRIVEDTOTALWEIGHT,
GROSSWEIGHTMEASUREUC, TOTALGROSSWEIGHTMEASURE, TOTALGROSSWEIGHTMEASUREUC, CHARGEABLEWEIGHTMEASURE,
CHARGEABLEWEIGHTMEASUREUC, ARRIVEDDATE, TRANSPORTSPLITDESCRIPTION, CUSTOMSCODE, PRODUCTNAME,
AUTOID, WAYBILLNOMASTER, TCD_NAME, TCD_TYPECODE, FLIGHTNO, FLIGHTDATE, CARRIER, ORIGINATINGSTATION,
O_NAME, DESTINATIONSTATION, FD_NAME, ARRIVEDTOTALPIECE, TOTALPIECEQUANTITY, ARRIVEDTOTALWEIGHT,
GROSSWEIGHTMEASUREUC, TOTALGROSSWEIGHTMEASURE, TOTALGROSSWEIGHTMEASUREUC, CHARGEABLEWEIGHTMEASURE,
CHARGEABLEWEIGHTMEASUREUC, ARRIVEDDATE, TRANSPORTSPLITDESCRIPTION, CUSTOMSCODE, PRODUCTNAME,
STATUS, RECEIPTINFORMATION, CREATEDATE
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
select
<include refid="Base_Column_List" />
from ARRIVEDMASTER
where AUTOID = #{autoid,jdbcType=VARCHAR}
... ... @@ -47,27 +47,27 @@
where AUTOID = #{autoid,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.tianbo.analysis.model.ARRIVEDMASTER" >
insert into ARRIVEDMASTER (AUTOID, WAYBILLNOMASTER, TCD_NAME,
TCD_TYPECODE, FLIGHTNO, FLIGHTDATE,
CARRIER, ORIGINATINGSTATION, O_NAME,
DESTINATIONSTATION, FD_NAME, ARRIVEDTOTALPIECE,
TOTALPIECEQUANTITY, ARRIVEDTOTALWEIGHT,
GROSSWEIGHTMEASUREUC, TOTALGROSSWEIGHTMEASURE,
TOTALGROSSWEIGHTMEASUREUC, CHARGEABLEWEIGHTMEASURE,
CHARGEABLEWEIGHTMEASUREUC, ARRIVEDDATE,
TRANSPORTSPLITDESCRIPTION, CUSTOMSCODE,
PRODUCTNAME, STATUS, RECEIPTINFORMATION,
insert into ARRIVEDMASTER (AUTOID, WAYBILLNOMASTER, TCD_NAME,
TCD_TYPECODE, FLIGHTNO, FLIGHTDATE,
CARRIER, ORIGINATINGSTATION, O_NAME,
DESTINATIONSTATION, FD_NAME, ARRIVEDTOTALPIECE,
TOTALPIECEQUANTITY, ARRIVEDTOTALWEIGHT,
GROSSWEIGHTMEASUREUC, TOTALGROSSWEIGHTMEASURE,
TOTALGROSSWEIGHTMEASUREUC, CHARGEABLEWEIGHTMEASURE,
CHARGEABLEWEIGHTMEASUREUC, ARRIVEDDATE,
TRANSPORTSPLITDESCRIPTION, CUSTOMSCODE,
PRODUCTNAME, STATUS, RECEIPTINFORMATION,
CREATEDATE)
values (#{autoid,jdbcType=VARCHAR}, #{waybillnomaster,jdbcType=VARCHAR}, #{tcdName,jdbcType=VARCHAR},
#{tcdTypecode,jdbcType=VARCHAR}, #{flightno,jdbcType=VARCHAR}, #{flightdate,jdbcType=TIMESTAMP},
#{carrier,jdbcType=VARCHAR}, #{originatingstation,jdbcType=VARCHAR}, #{oName,jdbcType=VARCHAR},
#{destinationstation,jdbcType=VARCHAR}, #{fdName,jdbcType=VARCHAR}, #{arrivedtotalpiece,jdbcType=VARCHAR},
#{totalpiecequantity,jdbcType=VARCHAR}, #{arrivedtotalweight,jdbcType=VARCHAR},
#{grossweightmeasureuc,jdbcType=VARCHAR}, #{totalgrossweightmeasure,jdbcType=VARCHAR},
#{totalgrossweightmeasureuc,jdbcType=VARCHAR}, #{chargeableweightmeasure,jdbcType=VARCHAR},
#{chargeableweightmeasureuc,jdbcType=VARCHAR}, #{arriveddate,jdbcType=TIMESTAMP},
#{transportsplitdescription,jdbcType=VARCHAR}, #{customscode,jdbcType=VARCHAR},
#{productname,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{receiptinformation,jdbcType=VARCHAR},
values (#{autoid,jdbcType=VARCHAR}, #{waybillnomaster,jdbcType=VARCHAR}, #{tcdName,jdbcType=VARCHAR},
#{tcdTypecode,jdbcType=VARCHAR}, #{flightno,jdbcType=VARCHAR}, #{flightdate,jdbcType=TIMESTAMP},
#{carrier,jdbcType=VARCHAR}, #{originatingstation,jdbcType=VARCHAR}, #{oName,jdbcType=VARCHAR},
#{destinationstation,jdbcType=VARCHAR}, #{fdName,jdbcType=VARCHAR}, #{arrivedtotalpiece,jdbcType=VARCHAR},
#{totalpiecequantity,jdbcType=VARCHAR}, #{arrivedtotalweight,jdbcType=VARCHAR},
#{grossweightmeasureuc,jdbcType=VARCHAR}, #{totalgrossweightmeasure,jdbcType=VARCHAR},
#{totalgrossweightmeasureuc,jdbcType=VARCHAR}, #{chargeableweightmeasure,jdbcType=VARCHAR},
#{chargeableweightmeasureuc,jdbcType=VARCHAR}, #{arriveddate,jdbcType=TIMESTAMP},
#{transportsplitdescription,jdbcType=VARCHAR}, #{customscode,jdbcType=VARCHAR},
#{productname,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{receiptinformation,jdbcType=VARCHAR},
#{createdate,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.analysis.model.ARRIVEDMASTER" >
... ... @@ -352,25 +352,26 @@
RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR},
STATUS = #{status,jdbcType=VARCHAR}
WHERE
WAYBILLNOMASTER = #{waybillnomaster,jdbcType=VARCHAR}
AND
FLIGHTNO = #{flightno,jdbcType=VARCHAR}
AND
CARRIER = #{carrier,jdbcType=VARCHAR}
AND
trunc(FLIGHTDATE)= #{flightDate,jdbcType=DATE}
AND
WAYBILLNOMASTER = #{waybillnomaster,jdbcType=VARCHAR}
</update>
<select id="selectAutoIdByAwb" parameterType="com.tianbo.analysis.model.ARRIVEDMASTER" resultType="com.tianbo.analysis.model.ARRIVEDMASTER">
SELECT AUTOID
FROM ARRIVEDMASTER
WHERE
FLIGHTNO= #{flightno,jdbcType=VARCHAR}
AND
trunc(FLIGHTDATE)= #{flightDate,jdbcType=DATE}
AND
WAYBILLNOMASTER = #{waybillnomaster,jdbcType=VARCHAR}
AND
FLIGHTNO= #{flightno,jdbcType=VARCHAR}
AND
CARRIER = #{carrier,jdbcType=VARCHAR}
AND
trunc(FLIGHTDATE)= #{flightDate,jdbcType=DATE}
</select>
</mapper>
\ No newline at end of file
</mapper>
... ...
... ... @@ -24,20 +24,20 @@
<result column="DESTINATIONSTATION_BILL" property="destinationstationBill" jdbcType="VARCHAR" />
</resultMap>
<insert id="insert" parameterType="com.tianbo.analysis.model.INTERNATIONALTRANSIT" >
insert into INTERNATIONALTRANSIT (AUTOID, CREATEDATE, ORIGINAL_CARRIER,
ORIGINAL_FLIGHTNO, ORIGINAL_FLIGHTDATE,
ORIGINAL_BILLNO, ORIGINAL_SUB_NUMBER, PRE_CARRIER,
PRE_FLIGHTNO, PRE_FLIGHTDATE, PRE_BILLNO,
PRE_SUB_NUMBER, BILLPIECE, BILLWEIGHT,
PRODUCT, ORIGINATINGSTATION, PACKAGINGTYPE,
insert into INTERNATIONALTRANSIT (AUTOID, CREATEDATE, ORIGINAL_CARRIER,
ORIGINAL_FLIGHTNO, ORIGINAL_FLIGHTDATE,
ORIGINAL_BILLNO, ORIGINAL_SUB_NUMBER, PRE_CARRIER,
PRE_FLIGHTNO, PRE_FLIGHTDATE, PRE_BILLNO,
PRE_SUB_NUMBER, BILLPIECE, BILLWEIGHT,
PRODUCT, ORIGINATINGSTATION, PACKAGINGTYPE,
STATUS, RECEIPTION, DESTINATIONSTATION_BILL
)
values (#{autoid,jdbcType=VARCHAR}, #{createdate,jdbcType=TIMESTAMP}, #{originalCarrier,jdbcType=VARCHAR},
#{originalFlightno,jdbcType=VARCHAR}, #{originalFlightdate,jdbcType=TIMESTAMP},
#{originalBillno,jdbcType=VARCHAR}, #{originalSubNumber,jdbcType=VARCHAR}, #{preCarrier,jdbcType=VARCHAR},
#{preFlightno,jdbcType=VARCHAR}, #{preFlightdate,jdbcType=TIMESTAMP}, #{preBillno,jdbcType=VARCHAR},
#{preSubNumber,jdbcType=VARCHAR}, #{billpiece,jdbcType=VARCHAR}, #{billweight,jdbcType=VARCHAR},
#{product,jdbcType=VARCHAR}, #{originatingstation,jdbcType=VARCHAR}, #{packagingtype,jdbcType=VARCHAR},
values (#{autoid,jdbcType=VARCHAR}, #{createdate,jdbcType=TIMESTAMP}, #{originalCarrier,jdbcType=VARCHAR},
#{originalFlightno,jdbcType=VARCHAR}, #{originalFlightdate,jdbcType=TIMESTAMP},
#{originalBillno,jdbcType=VARCHAR}, #{originalSubNumber,jdbcType=VARCHAR}, #{preCarrier,jdbcType=VARCHAR},
#{preFlightno,jdbcType=VARCHAR}, #{preFlightdate,jdbcType=TIMESTAMP}, #{preBillno,jdbcType=VARCHAR},
#{preSubNumber,jdbcType=VARCHAR}, #{billpiece,jdbcType=VARCHAR}, #{billweight,jdbcType=VARCHAR},
#{product,jdbcType=VARCHAR}, #{originatingstation,jdbcType=VARCHAR}, #{packagingtype,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{receiption,jdbcType=VARCHAR}, #{destinationstationBill,jdbcType=VARCHAR}
)
</insert>
... ... @@ -182,6 +182,10 @@
trunc(ORIGINAL_FLIGHTDATE)= #{originalFlightdate,jdbcType=DATE}
AND
ORIGINAL_BILLNO = #{originalBillno,jdbcType=VARCHAR}
<if test="originalSubNumber != null and originalSubNumber != ''" >
AND
ORIGINAL_SUB_NUMBER = #{originalSubNumber,jdbcType=VARCHAR}
</if>
</update>
<select id="selectAutoIdByAwb" parameterType="com.tianbo.analysis.model.INTERNATIONALTRANSIT" resultType="com.tianbo.analysis.model.INTERNATIONALTRANSIT">
... ... @@ -195,6 +199,10 @@
trunc(ORIGINAL_FLIGHTDATE)= #{originalFlightdate,jdbcType=DATE}
AND
ORIGINAL_BILLNO = #{originalBillno,jdbcType=VARCHAR}
<if test="originalSubNumber != null and originalSubNumber != ''" >
AND
ORIGINAL_SUB_NUMBER = #{originalSubNumber,jdbcType=VARCHAR}
</if>
</select>
</mapper>
\ No newline at end of file
</mapper>
... ...