作者 申海龙

正则工具类 添加回执解析入库 字段

... ... @@ -13,7 +13,7 @@ public interface CUSTOM_RESPONSEMapper {
int updateByPrimaryKeySelective(CUSTOM_RESPONSE record);
int updateAwbhReceiption(CUSTOM_RESPONSE record);
int updateByPrimaryKeyWithBLOBs(CUSTOM_RESPONSE record);
int updateAwbReceiption(CUSTOM_RESPONSE record);
int updateByPrimaryKey(CUSTOM_RESPONSE record);
}
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@ package com.tianbo.analysis.handle;
import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.service.*;
import com.tianbo.util.XML.XMLXPath;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
... ... @@ -77,14 +78,18 @@ public class CustomXmlHandle{
//开始解析
String journeyid = XMLXPath.getSingleValueByPath(document,JourneyID);
// if(journeyid != null){
//
// String[] flightList = journeyid.split("/");
// if(flightList.length > 0){
// flightNo = flightList[0];
// flightDate = flightList[1];
// }
// }
if(!StringUtils.isEmpty(journeyid)){
if (journeyid.contains("/")){
String[] flightList = journeyid.split("/");
if(flightList.length > 0){
flightNo = flightList[0];
flightDate = flightList[1];
}
}else {
flightNo = journeyid;
}
}
String functionCode = XMLXPath.getSingleValueByPath(document, FunctionCode);
String senderId = XMLXPath.getSingleValueByPath(document, SenderID);
... ...
... ... @@ -9,6 +9,8 @@ public class CUSTOM_RESPONSE {
private String flightno;
private String carrier;
private String awbano;
private String awbhno;
... ... @@ -71,6 +73,14 @@ public class CUSTOM_RESPONSE {
this.flightno = flightno == null ? null : flightno.trim();
}
public String getCarrier() {
return carrier;
}
public void setCarrier(String carrier) {
this.carrier = carrier == null ? null : carrier.trim();
}
public String getAwbano() {
return awbano;
}
... ...
... ... @@ -5,13 +5,16 @@ import com.tianbo.analysis.model.CUSTOM_RESPONSE;
import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.service.CoustomAnalysisService;
import com.tianbo.util.Date.DateUtil;
import com.tianbo.util.regular.RegularUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.UUID;
@Service
... ... @@ -26,8 +29,52 @@ public class CoustomAnalysisServiceImp implements CoustomAnalysisService {
@Override
public int insertRecept(CustomReception cus, String errorCodes, String errorTexts) throws ParseException {
RegularUtil regularUtil = new RegularUtil();
CUSTOM_RESPONSE custom_response = new CUSTOM_RESPONSE();
custom_response.setId(UUID.randomUUID().toString());
String awb = "";
String awbh = "";
if (cus.getWayBillMaster()!=null && cus.getWayBillMaster().length()>0){
StringBuffer stringBuffer = new StringBuffer(cus.getWayBillMaster());
StringBuffer insert = stringBuffer.insert(3, "-");
String s = insert.toString();
//设置 主单号
awb = s;
}
if (cus.getWayBillSecond()!=null && cus.getWayBillSecond().length()>0){
//取分单号
String[] awbhArr = cus.getWayBillSecond().split("_");
awbh = awbhArr[1];
}
// 主单号
custom_response.setAwbano(awb);
// 分单号
custom_response.setAwbhno(awbh);
// 判断日期是否为空
String flightDate = cus.getFlightDate();
if (!StringUtils.isEmpty(flightDate)){
Date date = DateUtil.formatByyyyyMMdd(flightDate);
// 航班日期
custom_response.setFlightdate(date);
}
String flightNo = cus.getFlightNo();
if (!StringUtils.isEmpty(flightNo)){
// 承运人代码
custom_response.setCarrier(flightNo.substring(0, 2));
// 航班号
custom_response.setFlightno(flightNo.substring(2));
}
// 报文发送序号
custom_response.setCusmsgid(cus.getMessageID());
// 回执发送者id
... ... @@ -38,9 +85,18 @@ public class CoustomAnalysisServiceImp implements CoustomAnalysisService {
custom_response.setCusversion(cus.getVersion());
// 对应海关的functioncode业务代码
custom_response.setCusfunctioncode(cus.getFunctionCode());
// 报文类型
custom_response.setBustype(cus.getMessageType());
// 设置时区
// SimpleDateFormat bjSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// bjSdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
// String format = bjSdf.format(new Date());
// 回执接受时间
custom_response.setCusresrcvtime(new Date());
// 业务发生时间
custom_response.setBusdate(new Date());
// 判断日期是否为空
String sendTime = cus.getSendTime();
if (!StringUtils.isEmpty(sendTime)){
... ... @@ -57,8 +113,8 @@ public class CoustomAnalysisServiceImp implements CoustomAnalysisService {
// 判断是否为空
if (responseText != null && responseCode != null){
// 回执状态
String substring = responseText.substring(0, 5);
custom_response.setCusresstatus(substring);
String cusText = regularUtil.cusText(responseText);
custom_response.setCusresstatus(cusText);
// 回执Code代码
custom_response.setCusrescode(responseCode);
// 回执内容
... ...
... ... @@ -5,6 +5,7 @@
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="flightDate" property="flightdate" jdbcType="DATE" />
<result column="flightNo" property="flightno" jdbcType="VARCHAR" />
<result column="carrier" property="carrier" jdbcType="VARCHAR" />
<result column="awbaNo" property="awbano" jdbcType="VARCHAR" />
<result column="awbhNo" property="awbhno" jdbcType="VARCHAR" />
<result column="busType" property="bustype" jdbcType="VARCHAR" />
... ... @@ -28,7 +29,7 @@
<result column="cusResText" property="cusrestext" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, flightDate, flightNo, awbaNo, awbhNo, busType, busDate, busWeight, busPiece,
id, flightDate, flightNo, carrier, awbaNo, awbhNo, busType, busDate, busWeight, busPiece,
operType, cusMsgId, cusSenderId, cusReciverId, cusVersion, cusFunctionCode, cusResRcvTime,
cusResSendTime, cusResCode, cusResStatus, operUserName, operSystemName
</sql>
... ... @@ -49,21 +50,21 @@
</delete>
<insert id="insert" parameterType="com.tianbo.analysis.model.CUSTOM_RESPONSE" >
insert into CUSTOM_RESPONSE (id, flightDate, flightNo,
awbaNo, awbhNo, busType,
busDate, busWeight, busPiece,
operType, cusMsgId, cusSenderId,
cusReciverId, cusVersion, cusFunctionCode,
cusResRcvTime, cusResSendTime, cusResCode,
cusResStatus, operUserName, operSystemName,
cusResText)
carrier, awbaNo, awbhNo,
busType, busDate, busWeight,
busPiece, operType, cusMsgId,
cusSenderId, cusReciverId, cusVersion,
cusFunctionCode, cusResRcvTime, cusResSendTime,
cusResCode, cusResStatus, operUserName,
operSystemName, cusResText)
values (#{id,jdbcType=VARCHAR}, #{flightdate,jdbcType=DATE}, #{flightno,jdbcType=VARCHAR},
#{awbano,jdbcType=VARCHAR}, #{awbhno,jdbcType=VARCHAR}, #{bustype,jdbcType=VARCHAR},
#{busdate,jdbcType=TIMESTAMP}, #{busweight,jdbcType=DECIMAL}, #{buspiece,jdbcType=INTEGER},
#{opertype,jdbcType=VARCHAR}, #{cusmsgid,jdbcType=VARCHAR}, #{cussenderid,jdbcType=VARCHAR},
#{cusreciverid,jdbcType=VARCHAR}, #{cusversion,jdbcType=VARCHAR}, #{cusfunctioncode,jdbcType=VARCHAR},
#{cusresrcvtime,jdbcType=TIMESTAMP}, #{cusressendtime,jdbcType=TIMESTAMP}, #{cusrescode,jdbcType=VARCHAR},
#{cusresstatus,jdbcType=VARCHAR}, #{operusername,jdbcType=VARCHAR}, #{opersystemname,jdbcType=VARCHAR},
#{cusrestext,jdbcType=LONGVARCHAR})
#{carrier,jdbcType=VARCHAR}, #{awbano,jdbcType=VARCHAR}, #{awbhno,jdbcType=VARCHAR},
#{bustype,jdbcType=VARCHAR}, #{busdate,jdbcType=TIMESTAMP}, #{busweight,jdbcType=DECIMAL},
#{buspiece,jdbcType=INTEGER}, #{opertype,jdbcType=VARCHAR}, #{cusmsgid,jdbcType=VARCHAR},
#{cussenderid,jdbcType=VARCHAR}, #{cusreciverid,jdbcType=VARCHAR}, #{cusversion,jdbcType=VARCHAR},
#{cusfunctioncode,jdbcType=VARCHAR}, #{cusresrcvtime,jdbcType=TIMESTAMP}, #{cusressendtime,jdbcType=TIMESTAMP},
#{cusrescode,jdbcType=VARCHAR}, #{cusresstatus,jdbcType=VARCHAR}, #{operusername,jdbcType=VARCHAR},
#{opersystemname,jdbcType=VARCHAR}, #{cusrestext,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.analysis.model.CUSTOM_RESPONSE" >
insert into CUSTOM_RESPONSE
... ... @@ -77,6 +78,9 @@
<if test="flightno != null" >
flightNo,
</if>
<if test="carrier != null" >
carrier,
</if>
<if test="awbano != null" >
awbaNo,
</if>
... ... @@ -145,6 +149,9 @@
<if test="flightno != null" >
#{flightno,jdbcType=VARCHAR},
</if>
<if test="carrier != null" >
#{carrier,jdbcType=VARCHAR},
</if>
<if test="awbano != null" >
#{awbano,jdbcType=VARCHAR},
</if>
... ... @@ -213,6 +220,9 @@
<if test="flightno != null" >
flightNo = #{flightno,jdbcType=VARCHAR},
</if>
<if test="carrier != null" >
carrier = #{carrier,jdbcType=VARCHAR},
</if>
<if test="awbano != null" >
awbaNo = #{awbano,jdbcType=VARCHAR},
</if>
... ... @@ -273,28 +283,55 @@
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateAwbhReceiption" parameterType="com.tianbo.analysis.model.CUSTOM_RESPONSE" >
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tianbo.analysis.model.CUSTOM_RESPONSE" >
update CUSTOM_RESPONSE
set
set flightDate = #{flightdate,jdbcType=DATE},
flightNo = #{flightno,jdbcType=VARCHAR},
carrier = #{carrier,jdbcType=VARCHAR},
awbaNo = #{awbano,jdbcType=VARCHAR},
awbhNo = #{awbhno,jdbcType=VARCHAR},
busType = #{bustype,jdbcType=VARCHAR},
busDate = #{busdate,jdbcType=TIMESTAMP},
busWeight = #{busweight,jdbcType=DECIMAL},
busPiece = #{buspiece,jdbcType=INTEGER},
operType = #{opertype,jdbcType=VARCHAR},
cusMsgId = #{cusmsgid,jdbcType=VARCHAR},
cusSenderId = #{cussenderid,jdbcType=VARCHAR},
cusReciverId = #{cusreciverid,jdbcType=VARCHAR},
cusVersion = #{cusversion,jdbcType=VARCHAR},
cusFunctionCode = #{cusfunctioncode,jdbcType=VARCHAR},
cusResRcvTime = #{cusresrcvtime,jdbcType=TIMESTAMP},
cusResSendTime = #{cusressendtime,jdbcType=TIMESTAMP},
cusResCode = #{cusrescode,jdbcType=VARCHAR},
cusResStatus = #{cusresstatus,jdbcType=VARCHAR},
operUserName = #{operusername,jdbcType=VARCHAR},
operSystemName = #{opersystemname,jdbcType=VARCHAR},
cusResText = #{cusrestext,jdbcType=LONGVARCHAR}
where
flightDate = #{flightdate,jdbcType=DATE}
and
flightNo = #{flightno,jdbcType=VARCHAR}
and
awbhNo = #{awbhno,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<!--主单 修改-->
<update id="updateAwbReceiption" parameterType="com.tianbo.analysis.model.CUSTOM_RESPONSE" >
<update id="updateByPrimaryKey" parameterType="com.tianbo.analysis.model.CUSTOM_RESPONSE" >
update CUSTOM_RESPONSE
set
cusResText = #{cusrestext,jdbcType=LONGVARCHAR}
where
flightDate = #{flightdate,jdbcType=DATE}
and
flightNo = #{flightno,jdbcType=VARCHAR}
and
awbaNo = #{awbano,jdbcType=VARCHAR}
set flightDate = #{flightdate,jdbcType=DATE},
flightNo = #{flightno,jdbcType=VARCHAR},
carrier = #{carrier,jdbcType=VARCHAR},
awbaNo = #{awbano,jdbcType=VARCHAR},
awbhNo = #{awbhno,jdbcType=VARCHAR},
busType = #{bustype,jdbcType=VARCHAR},
busDate = #{busdate,jdbcType=TIMESTAMP},
busWeight = #{busweight,jdbcType=DECIMAL},
busPiece = #{buspiece,jdbcType=INTEGER},
operType = #{opertype,jdbcType=VARCHAR},
cusMsgId = #{cusmsgid,jdbcType=VARCHAR},
cusSenderId = #{cussenderid,jdbcType=VARCHAR},
cusReciverId = #{cusreciverid,jdbcType=VARCHAR},
cusVersion = #{cusversion,jdbcType=VARCHAR},
cusFunctionCode = #{cusfunctioncode,jdbcType=VARCHAR},
cusResRcvTime = #{cusresrcvtime,jdbcType=TIMESTAMP},
cusResSendTime = #{cusressendtime,jdbcType=TIMESTAMP},
cusResCode = #{cusrescode,jdbcType=VARCHAR},
cusResStatus = #{cusresstatus,jdbcType=VARCHAR},
operUserName = #{operusername,jdbcType=VARCHAR},
operSystemName = #{opersystemname,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...