|
|
package com.sunyo.wlpt.base.model.efreight.fwb;
|
|
|
|
|
|
import com.sunyo.wlpt.base.model.efreight.BASE;
|
|
|
import com.sunyo.wlpt.base.model.efreight.fwb.exception.FWBException;
|
|
|
import com.sunyo.wlpt.base.model.efreight.fwb.exception.FWBExceptionType;
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 电子运单主运单
|
|
|
* @author mrz
|
|
|
* @date 2023-05-30
|
|
|
*
|
|
|
*/
|
|
|
public class FWB {
|
|
|
public class FWB extends BASE implements FWB_BASE {
|
|
|
/**
|
|
|
* 版本号
|
|
|
* 默认16
|
...
|
...
|
@@ -14,35 +21,36 @@ public class FWB { |
|
|
public String ver = "16";
|
|
|
/**
|
|
|
* 主运单格式
|
|
|
* [0-9]{3}-[0-9]{8}
|
|
|
*/
|
|
|
private String waybillNum;
|
|
|
private String waybillNum = "";
|
|
|
/**
|
|
|
* 运单起始站
|
|
|
*/
|
|
|
private String origin;
|
|
|
private String origin = "";
|
|
|
/**
|
|
|
* 运单目的站
|
|
|
*/
|
|
|
private String destination;
|
|
|
private String destination = "";
|
|
|
/**
|
|
|
* 运单总件数
|
|
|
* number of pieces
|
|
|
*/
|
|
|
private String quantity_picecs;
|
|
|
private String quantity_picecs = "";
|
|
|
/**
|
|
|
* 运单毛重,运单的实际称重
|
|
|
*/
|
|
|
private String quantity_weight;
|
|
|
private String quantity_weight = "";
|
|
|
/**
|
|
|
* 计重单位,
|
|
|
* K 代表KG 公斤
|
|
|
* L 代表公升
|
|
|
*/
|
|
|
private String quantity_weight_code;
|
|
|
private String quantity_weight_code = "";
|
|
|
/**
|
|
|
* 体积
|
|
|
*/
|
|
|
private String quantity_volume;
|
|
|
private String quantity_volume = "";
|
|
|
/**
|
|
|
* 体积单位
|
|
|
* MC 代表 立方米 Cubic Metres
|
...
|
...
|
@@ -50,19 +58,199 @@ public class FWB { |
|
|
* CF 代表 立方英尺 Cubic Feet
|
|
|
* CI 代表 立方英寸 Cubic Inches
|
|
|
*/
|
|
|
private String quantity_volume_code;
|
|
|
private String quantity_volume_code = "";
|
|
|
/**
|
|
|
* 密度
|
|
|
* 可选节点
|
|
|
*/
|
|
|
private String quantity_density ;
|
|
|
private String quantity_density = "";
|
|
|
/**
|
|
|
* 密度
|
|
|
* 可选节点
|
|
|
*/
|
|
|
private String quantity_density_code = "DG";
|
|
|
|
|
|
public String getWaybillNum() throws FWBException {
|
|
|
|
|
|
String patternStr = "^[0-9]{3}-[0-9]{8}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(waybillNum);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_ERR);
|
|
|
}
|
|
|
|
|
|
String serialNumber = waybillNum.split("-")[1];
|
|
|
Integer serialNumber7 = Integer.valueOf(serialNumber.substring(0,7)) ;
|
|
|
Integer serialNumberEnd = Integer.valueOf(serialNumber.substring(7));
|
|
|
|
|
|
//模七校验
|
|
|
if ((serialNumber7%7) != serialNumberEnd){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_REGX_ERR);
|
|
|
}
|
|
|
|
|
|
return waybillNum;
|
|
|
}
|
|
|
|
|
|
public void setWaybillNum(String waybillNum) {
|
|
|
this.waybillNum = waybillNum;
|
|
|
}
|
|
|
|
|
|
public String getOrigin() throws FWBException {
|
|
|
String patternStr = "^[A-Z]{3}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(origin);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_ORGN_ERR);
|
|
|
}
|
|
|
return origin;
|
|
|
}
|
|
|
|
|
|
public void setOrigin(String origin) {
|
|
|
this.origin = origin;
|
|
|
}
|
|
|
|
|
|
public String getDestination() throws FWBException {
|
|
|
String patternStr = "^[A-Z]{3}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(origin);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_DES_ERR);
|
|
|
}
|
|
|
return destination;
|
|
|
}
|
|
|
|
|
|
public void setDestination(String destination) {
|
|
|
this.destination = destination;
|
|
|
}
|
|
|
|
|
|
public String getQuantity_picecs() throws FWBException {
|
|
|
|
|
|
String patternStr = "^[0-9]{1,4}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(quantity_picecs);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_PCE_ERR);
|
|
|
}
|
|
|
return quantity_picecs;
|
|
|
}
|
|
|
|
|
|
public void setQuantity_picecs(String quantity_picecs) {
|
|
|
this.quantity_picecs = quantity_picecs;
|
|
|
}
|
|
|
|
|
|
public String getQuantity_weight() throws FWBException {
|
|
|
|
|
|
String patternStr = "^[1-9][0-9\\.]{1,6}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(quantity_weight);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_WGT_ERR);
|
|
|
}
|
|
|
return quantity_weight;
|
|
|
}
|
|
|
|
|
|
public void setQuantity_weight(String quantity_weight) {
|
|
|
this.quantity_weight = quantity_weight;
|
|
|
}
|
|
|
|
|
|
public String getQuantity_weight_code() throws FWBException {
|
|
|
|
|
|
String patternStr = "^[KL]$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(quantity_weight_code);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_WGT_CODE_ERR);
|
|
|
}
|
|
|
|
|
|
return quantity_weight_code;
|
|
|
}
|
|
|
|
|
|
public void setQuantity_weight_code(String quantity_weight_code) {
|
|
|
this.quantity_weight_code = quantity_weight_code;
|
|
|
}
|
|
|
|
|
|
public String getQuantity_volume() throws FWBException {
|
|
|
|
|
|
if (hasText(quantity_volume)){
|
|
|
String patternStr = "^[1-9][0-9\\.]{0,8}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(quantity_volume);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_VOL_ERR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return quantity_volume;
|
|
|
}
|
|
|
|
|
|
public void setQuantity_volume(String quantity_volume) {
|
|
|
this.quantity_volume = quantity_volume;
|
|
|
}
|
|
|
|
|
|
public String getQuantity_volume_code() throws FWBException {
|
|
|
String patternStr = "^MC|CC|CI|CF$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(quantity_volume_code);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_VOL_CODE_ERR);
|
|
|
}
|
|
|
return quantity_volume_code;
|
|
|
}
|
|
|
|
|
|
public void setQuantity_volume_code(String quantity_volume_code) {
|
|
|
this.quantity_volume_code = quantity_volume_code;
|
|
|
}
|
|
|
|
|
|
public String getQuantity_density() throws FWBException {
|
|
|
String patternStr = "^[1-9]?[0-9]?$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(quantity_density);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.FWB_WAYBILL_DG_ERR);
|
|
|
}
|
|
|
return quantity_density;
|
|
|
}
|
|
|
|
|
|
public void setQuantity_density(String quantity_density) {
|
|
|
this.quantity_density = quantity_density;
|
|
|
}
|
|
|
|
|
|
public String getQuantity_density_code() {
|
|
|
return quantity_density_code;
|
|
|
}
|
|
|
|
|
|
public void setQuantity_density_code(String quantity_density_code) {
|
|
|
this.quantity_density_code = quantity_density_code;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getFWBNodeText() throws FWBException {
|
|
|
|
|
|
String SPLIT_CODE = "/";
|
|
|
String CRLF = "\n";
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
|
|
|
sb.append(getWaybillNum()).append(getOrigin()).append(getDestination())
|
|
|
.append(SPLIT_CODE).append("T").append(getQuantity_picecs())
|
|
|
.append(getQuantity_weight_code()).append(getQuantity_weight());
|
|
|
|
|
|
if (hasText(getQuantity_volume())){
|
|
|
sb.append(getQuantity_volume_code()).append(getQuantity_volume());
|
|
|
}
|
|
|
|
|
|
if (hasText(getQuantity_density())){
|
|
|
sb.append(getQuantity_density_code()).append(getQuantity_density());
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sb.append(CRLF);
|
|
|
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getNodeName() {
|
|
|
return "FWB/"+ver+"\n";
|
|
|
}
|
|
|
} |
...
|
...
|
|