作者 朱兆平

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

@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <packaging>jar</packaging> 6 <packaging>jar</packaging>
7 <groupId>com.sunyo.wlpt</groupId> 7 <groupId>com.sunyo.wlpt</groupId>
8 <artifactId>base</artifactId> 8 <artifactId>base</artifactId>
9 - <version>1.03-SNAPSHOT</version> 9 + <version>1.05-SNAPSHOT</version>
10 10
11 <name>wlpt-base</name> 11 <name>wlpt-base</name>
12 <description>物流平台基础实体包</description> 12 <description>物流平台基础实体包</description>
@@ -11,6 +11,8 @@ public interface AWB_AWBINFOMapper { @@ -11,6 +11,8 @@ public interface AWB_AWBINFOMapper {
11 11
12 AWB_AWBINFO selectByPrimaryKey(String billid); 12 AWB_AWBINFO selectByPrimaryKey(String billid);
13 13
  14 + int hasWaybill(AWB_AWBINFO record);
  15 +
14 int updateByPrimaryKeySelective(AWB_AWBINFO record); 16 int updateByPrimaryKeySelective(AWB_AWBINFO record);
15 17
16 int updateByPrimaryKey(AWB_AWBINFO record); 18 int updateByPrimaryKey(AWB_AWBINFO record);
@@ -11,6 +11,8 @@ public interface NMMS_CUSTOM_MT1201Mapper { @@ -11,6 +11,8 @@ public interface NMMS_CUSTOM_MT1201Mapper {
11 11
12 NMMS_CUSTOM_MT1201 selectByPrimaryKey(String uuid); 12 NMMS_CUSTOM_MT1201 selectByPrimaryKey(String uuid);
13 13
  14 + int hasWaybill(NMMS_CUSTOM_MT1201 record);
  15 +
14 int updateByPrimaryKeySelective(NMMS_CUSTOM_MT1201 record); 16 int updateByPrimaryKeySelective(NMMS_CUSTOM_MT1201 record);
15 17
16 int updateByPrimaryKey(NMMS_CUSTOM_MT1201 record); 18 int updateByPrimaryKey(NMMS_CUSTOM_MT1201 record);
1 package com.sunyo.wlpt.base.model; 1 package com.sunyo.wlpt.base.model;
2 2
3 import com.fasterxml.jackson.annotation.JsonFormat; 3 import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.sunyo.wlpt.base.model.exception.NMMSException;
4 import lombok.Data; 5 import lombok.Data;
5 6
6 import java.math.BigDecimal; 7 import java.math.BigDecimal;
@@ -1313,4 +1314,22 @@ public class AWB_AWBINFO { @@ -1313,4 +1314,22 @@ public class AWB_AWBINFO {
1313 public void setCnscomidno(String cnscomidno) { 1314 public void setCnscomidno(String cnscomidno) {
1314 this.cnscomidno = cnscomidno; 1315 this.cnscomidno = cnscomidno;
1315 } 1316 }
  1317 +
  1318 + /**
  1319 + * 根据原始舱单主单号,set stockpre and stockno
  1320 + * 主单通过 "-" 符号进行拆分
  1321 + * "-"号前的为stockpre
  1322 + * "-"号后面的为 stockno
  1323 + * @param mt1201 原始舱单
  1324 + * @throws NMMSException 的awba 为空 或者 长度>3 不够位数 或者不包含"-"符号会抛出 AWBAFORMAT 自定义异常
  1325 + */
  1326 + public void setStockWithMT1201_AWBA(NMMS_CUSTOM_MT1201 mt1201) throws NMMSException{
  1327 + if (mt1201.getAwba() != null && mt1201.getAwba().contains("-") && mt1201.getAwba().length()>4) {
  1328 + String[] awb = mt1201.getAwba().split("-");
  1329 + this.stockpre = awb[0];
  1330 + this.stockno = awb[1];
  1331 + }else {
  1332 + throw new NMMSException("错误的主运单格式:"+mt1201.getAwba());
  1333 + }
  1334 + }
1316 } 1335 }
1 package com.sunyo.wlpt.base.model; 1 package com.sunyo.wlpt.base.model;
2 2
3 import com.fasterxml.jackson.annotation.JsonFormat; 3 import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.sunyo.wlpt.base.model.exception.NMMSException;
4 import lombok.Data; 5 import lombok.Data;
5 import org.springframework.format.annotation.DateTimeFormat; 6 import org.springframework.format.annotation.DateTimeFormat;
6 7
@@ -70,4 +71,17 @@ public class NMMS_CUSTOM_MT1201 { @@ -70,4 +71,17 @@ public class NMMS_CUSTOM_MT1201 {
70 71
71 private String customtype; 72 private String customtype;
72 73
  74 + /**
  75 + * 格式化主运单号,插入 "-" 符号,有 "-" 符号则不更改格式
  76 + */
  77 + public void formatAwba() {
  78 + String spacialCode = "-";
  79 + if (awba!=null && awba.length()>3 && !awba.contains(spacialCode)){
  80 + StringBuffer stringBuffer = new StringBuffer(awba);
  81 + stringBuffer.insert(3, "-");
  82 + this.awba = stringBuffer.toString().trim();
  83 + }else {
  84 + //throw new NMMSException("错误的主运单号,不能为空或者长度未大于4:"+awba);
  85 + }
  86 + }
73 } 87 }
@@ -250,4 +250,58 @@ public class NMMS_CUSTOM_MT520X { @@ -250,4 +250,58 @@ public class NMMS_CUSTOM_MT520X {
250 public void setExt5(String ext5) { 250 public void setExt5(String ext5) {
251 this.ext5 = ext5 == null ? null : ext5.trim(); 251 this.ext5 = ext5 == null ? null : ext5.trim();
252 } 252 }
  253 +
  254 + public String getCarrierno() {
  255 + return carrierno;
  256 + }
  257 +
  258 + public void setCarrierno(String carrierno) {
  259 + this.carrierno = carrierno;
  260 + }
  261 +
  262 + public String getSegment() {
  263 + return segment;
  264 + }
  265 +
  266 + public void setSegment(String segment) {
  267 + this.segment = segment;
  268 + }
  269 +
  270 + public String getWaybill() {
  271 + return waybill;
  272 + }
  273 +
  274 + public void setWaybill(String waybill) {
  275 + this.waybill = waybill;
  276 + }
  277 +
  278 + public String getCustomText() {
  279 + return customText;
  280 + }
  281 +
  282 + public void setCustomText(String customText) {
  283 + this.customText = customText;
  284 + }
  285 +
  286 + public AWB_AWBINFO getAwbinfo() {
  287 + return awbinfo;
  288 + }
  289 +
  290 + public void setAwbinfo(AWB_AWBINFO awbinfo) {
  291 + this.awbinfo = awbinfo;
  292 + }
  293 +
  294 + public List<NMMS_CUSTOM_MT520X> getChildren() {
  295 + return children;
  296 + }
  297 +
  298 + public void setChildren(List<NMMS_CUSTOM_MT520X> children) {
  299 + this.children = children;
  300 + }
  301 +
  302 +
  303 + @Override
  304 + public String toString(){
  305 + return "Mt520x class";
  306 + }
253 } 307 }
  1 +package com.sunyo.wlpt.base.model.exception;
  2 +
  3 +public class NMMSException extends RuntimeException{
  4 +
  5 + public NMMSException(String message) {
  6 + super(message);
  7 + }
  8 +
  9 + public NMMSException(String message, Throwable cause) {
  10 + super(message, cause);
  11 + }
  12 +}
@@ -151,6 +151,21 @@ @@ -151,6 +151,21 @@
151 from T_FIL_AWBINFO 151 from T_FIL_AWBINFO
152 where BILLID = #{billid,jdbcType=VARCHAR} 152 where BILLID = #{billid,jdbcType=VARCHAR}
153 </select> 153 </select>
  154 + <select id="hasWaybill" resultType="java.lang.Integer" parameterType="com.sunyo.wlpt.base.model.AWB_AWBINFO" >
  155 + select count(*)
  156 + from T_FIL_AWBINFO
  157 + <where>
  158 + <if test="stockpre != null" >
  159 + AND STOCKPRE = #{stockpre,jdbcType=VARCHAR}
  160 + </if>
  161 + <if test="stockno != null" >
  162 + AND STOCKNO = #{stockno,jdbcType=VARCHAR}
  163 + </if>
  164 + <if test="stocktypeid != null" >
  165 + AND STOCKTYPEID = #{stocktypeid,jdbcType=VARCHAR}
  166 + </if>
  167 + </where>
  168 + </select>
154 <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > 169 <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
155 delete from T_FIL_AWBINFO 170 delete from T_FIL_AWBINFO
156 where BILLID = #{billid,jdbcType=VARCHAR} 171 where BILLID = #{billid,jdbcType=VARCHAR}
@@ -35,6 +35,34 @@ @@ -35,6 +35,34 @@
35 from CUSTOM_MT1201 35 from CUSTOM_MT1201
36 where uuid = #{uuid,jdbcType=VARCHAR} 36 where uuid = #{uuid,jdbcType=VARCHAR}
37 </select> 37 </select>
  38 + <select id="hasWaybill" resultType="java.lang.Integer" parameterType="com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT1201" >
  39 + select count(*) from (
  40 + select
  41 + count(uuid) as counts
  42 + from CUSTOM_MT1201
  43 + <where>
  44 + <if test="flightdate !=null">
  45 + AND flightDate = #{flightdate,jdbcType=DATE}
  46 + </if>
  47 + <if test="carrier!=null">
  48 + AND carrier = #{carrier,jdbcType=VARCHAR}
  49 + </if>
  50 + <if test="flightno!=null">
  51 + AND flightNo = #{flightno,jdbcType=VARCHAR}
  52 + </if>
  53 + <if test="awba!=null and awba != ''">
  54 + AND awba=#{awba,jdbcType=VARCHAR}
  55 + </if>
  56 + <if test="awbh!=null">
  57 + AND awbh=#{awbh,jdbcType=VARCHAR}
  58 + </if>
  59 + </where>
  60 + union
  61 + select count(uuid) as counts
  62 + from CUSTOM_MT1201
  63 + where uuid = #{uuid,jdbcType=VARCHAR}
  64 + ) t where counts>0
  65 + </select>
38 <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > 66 <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
39 delete from CUSTOM_MT1201 67 delete from CUSTOM_MT1201
40 where uuid = #{uuid,jdbcType=VARCHAR} 68 where uuid = #{uuid,jdbcType=VARCHAR}