作者 朱兆平

进港model增加了一些校验方法及数据库入库操作

... ... @@ -6,7 +6,7 @@
<packaging>jar</packaging>
<groupId>com.sunyo.wlpt</groupId>
<artifactId>base</artifactId>
<version>1.03-SNAPSHOT</version>
<version>1.05-SNAPSHOT</version>
<name>wlpt-base</name>
<description>物流平台基础实体包</description>
... ...
... ... @@ -11,6 +11,8 @@ public interface AWB_AWBINFOMapper {
AWB_AWBINFO selectByPrimaryKey(String billid);
int hasWaybill(AWB_AWBINFO record);
int updateByPrimaryKeySelective(AWB_AWBINFO record);
int updateByPrimaryKey(AWB_AWBINFO record);
... ...
... ... @@ -11,6 +11,8 @@ public interface NMMS_CUSTOM_MT1201Mapper {
NMMS_CUSTOM_MT1201 selectByPrimaryKey(String uuid);
int hasWaybill(NMMS_CUSTOM_MT1201 record);
int updateByPrimaryKeySelective(NMMS_CUSTOM_MT1201 record);
int updateByPrimaryKey(NMMS_CUSTOM_MT1201 record);
... ...
package com.sunyo.wlpt.base.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sunyo.wlpt.base.model.exception.NMMSException;
import lombok.Data;
import java.math.BigDecimal;
... ... @@ -1313,4 +1314,22 @@ public class AWB_AWBINFO {
public void setCnscomidno(String cnscomidno) {
this.cnscomidno = cnscomidno;
}
/**
* 根据原始舱单主单号,set stockpre and stockno
* 主单通过 "-" 符号进行拆分
* "-"号前的为stockpre
* "-"号后面的为 stockno
* @param mt1201 原始舱单
* @throws NMMSException 的awba 为空 或者 长度>3 不够位数 或者不包含"-"符号会抛出 AWBAFORMAT 自定义异常
*/
public void setStockWithMT1201_AWBA(NMMS_CUSTOM_MT1201 mt1201) throws NMMSException{
if (mt1201.getAwba() != null && mt1201.getAwba().contains("-") && mt1201.getAwba().length()>4) {
String[] awb = mt1201.getAwba().split("-");
this.stockpre = awb[0];
this.stockno = awb[1];
}else {
throw new NMMSException("错误的主运单格式:"+mt1201.getAwba());
}
}
}
... ...
package com.sunyo.wlpt.base.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sunyo.wlpt.base.model.exception.NMMSException;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
... ... @@ -70,4 +71,17 @@ public class NMMS_CUSTOM_MT1201 {
private String customtype;
/**
* 格式化主运单号,插入 "-" 符号,有 "-" 符号则不更改格式
*/
public void formatAwba() {
String spacialCode = "-";
if (awba!=null && awba.length()>3 && !awba.contains(spacialCode)){
StringBuffer stringBuffer = new StringBuffer(awba);
stringBuffer.insert(3, "-");
this.awba = stringBuffer.toString().trim();
}else {
//throw new NMMSException("错误的主运单号,不能为空或者长度未大于4:"+awba);
}
}
}
... ...
... ... @@ -250,4 +250,58 @@ public class NMMS_CUSTOM_MT520X {
public void setExt5(String ext5) {
this.ext5 = ext5 == null ? null : ext5.trim();
}
public String getCarrierno() {
return carrierno;
}
public void setCarrierno(String carrierno) {
this.carrierno = carrierno;
}
public String getSegment() {
return segment;
}
public void setSegment(String segment) {
this.segment = segment;
}
public String getWaybill() {
return waybill;
}
public void setWaybill(String waybill) {
this.waybill = waybill;
}
public String getCustomText() {
return customText;
}
public void setCustomText(String customText) {
this.customText = customText;
}
public AWB_AWBINFO getAwbinfo() {
return awbinfo;
}
public void setAwbinfo(AWB_AWBINFO awbinfo) {
this.awbinfo = awbinfo;
}
public List<NMMS_CUSTOM_MT520X> getChildren() {
return children;
}
public void setChildren(List<NMMS_CUSTOM_MT520X> children) {
this.children = children;
}
@Override
public String toString(){
return "Mt520x class";
}
}
... ...
package com.sunyo.wlpt.base.model.exception;
public class NMMSException extends RuntimeException{
public NMMSException(String message) {
super(message);
}
public NMMSException(String message, Throwable cause) {
super(message, cause);
}
}
... ...
... ... @@ -151,6 +151,21 @@
from T_FIL_AWBINFO
where BILLID = #{billid,jdbcType=VARCHAR}
</select>
<select id="hasWaybill" resultType="java.lang.Integer" parameterType="com.sunyo.wlpt.base.model.AWB_AWBINFO" >
select count(*)
from T_FIL_AWBINFO
<where>
<if test="stockpre != null" >
AND STOCKPRE = #{stockpre,jdbcType=VARCHAR}
</if>
<if test="stockno != null" >
AND STOCKNO = #{stockno,jdbcType=VARCHAR}
</if>
<if test="stocktypeid != null" >
AND STOCKTYPEID = #{stocktypeid,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from T_FIL_AWBINFO
where BILLID = #{billid,jdbcType=VARCHAR}
... ...
... ... @@ -35,6 +35,34 @@
from CUSTOM_MT1201
where uuid = #{uuid,jdbcType=VARCHAR}
</select>
<select id="hasWaybill" resultType="java.lang.Integer" parameterType="com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT1201" >
select count(*) from (
select
count(uuid) as counts
from CUSTOM_MT1201
<where>
<if test="flightdate !=null">
AND flightDate = #{flightdate,jdbcType=DATE}
</if>
<if test="carrier!=null">
AND carrier = #{carrier,jdbcType=VARCHAR}
</if>
<if test="flightno!=null">
AND flightNo = #{flightno,jdbcType=VARCHAR}
</if>
<if test="awba!=null and awba != ''">
AND awba=#{awba,jdbcType=VARCHAR}
</if>
<if test="awbh!=null">
AND awbh=#{awbh,jdbcType=VARCHAR}
</if>
</where>
union
select count(uuid) as counts
from CUSTOM_MT1201
where uuid = #{uuid,jdbcType=VARCHAR}
) t where counts>0
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from CUSTOM_MT1201
where uuid = #{uuid,jdbcType=VARCHAR}
... ...