|
|
package com.sunyo.wlpt.base.model.efreight.fwb;
|
|
|
|
|
|
import com.sunyo.wlpt.base.model.efreight.fwb.exception.FWBException;
|
|
|
import com.sunyo.wlpt.base.model.efreight.fwb.exception.FWBExceptionType;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* REF
|
|
|
* Sender Reference
|
|
|
* 发送者参考信息
|
|
|
* M 必填节点
|
|
|
*
|
|
|
* DEMO:(括号里面的是可选项)
|
|
|
* REF/CGOFD1E/EC1A2C4CBC3D/AGT/MECCGO01/CGO
|
|
|
* CRLF
|
|
|
*/
|
|
|
public class FWB_REF implements FWB_BASE{
|
|
|
|
|
|
/**
|
|
|
* NODE:REF
|
|
|
* Sender Office Message Address
|
|
|
* 发送人办公室电报地址
|
|
|
* Air Port Code And Office Function Designator And Company Designator
|
|
|
* [A-Z]{3}[0-9A-Z]{2}[0-9A-Z]{2}
|
|
|
* M (必填节点)
|
|
|
* DEMO:
|
|
|
* CGOFD1E
|
|
|
*/
|
|
|
private String ref_address = "";
|
|
|
|
|
|
/**
|
|
|
* NODE:REF
|
|
|
* Sender Office File Reference
|
|
|
* 发件人办公室文件参考
|
|
|
* File Reference
|
|
|
* [A-Z0-9-<=/\s\.]{0,15}
|
|
|
* O (可选节点)
|
|
|
* DEMO:
|
|
|
* EC1A2C4CBC3D
|
|
|
*/
|
|
|
private String ref_file_reference ="";
|
|
|
|
|
|
/**
|
|
|
* NODE:REF
|
|
|
* Sender Participan Identification
|
|
|
* 发送方参与者身份
|
|
|
* Participan Identification
|
|
|
* [A-Z0-9]{0,3}
|
|
|
* O (可选节点)
|
|
|
* DEMO:
|
|
|
* EC1
|
|
|
*/
|
|
|
private String ref_participant_id = "";
|
|
|
|
|
|
/**
|
|
|
* NODE:REF
|
|
|
* Sender Participan Identification
|
|
|
* 发送方参与者身份
|
|
|
* Participan Code
|
|
|
* [A-Z0-9]{0,17}
|
|
|
* O (可选节点)
|
|
|
* DEMO:
|
|
|
* EC1A2C4CBC3D
|
|
|
*/
|
|
|
private String ref_participant_code="";
|
|
|
|
|
|
/**
|
|
|
* NODE:REF
|
|
|
* Sender Participan Identification
|
|
|
* 发送方参与者身份
|
|
|
* Airport/City Code
|
|
|
* [A-Z]{0,3}
|
|
|
* O (可选节点)
|
|
|
* DEMO:
|
|
|
* CGO OR BJS
|
|
|
*/
|
|
|
private String ref_participant_airport="";
|
|
|
|
|
|
public String getRef_address() throws FWBException {
|
|
|
if (!StringUtils.hasText(ref_address)){
|
|
|
throw new FWBException(FWBExceptionType.REF_ERROR);
|
|
|
}
|
|
|
String patternStr = "^[A-Z]{3}[0-9A-Z]{2}[0-9A-Z]{2}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(ref_address);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.REF_SOMA_REGEX_FAILD);
|
|
|
}
|
|
|
return ref_address;
|
|
|
}
|
|
|
|
|
|
public void setRef_address(String ref_address) {
|
|
|
this.ref_address = ref_address;
|
|
|
}
|
|
|
|
|
|
public String getRef_file_reference() {
|
|
|
String patternStr = "^[A-Z0-9-<=/\\s\\.]{0,15}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(ref_file_reference);
|
|
|
if (!matcher.find()){
|
|
|
System.out.println("[REF-WARN]-缺少file_reference,或未通过规则校验");
|
|
|
}
|
|
|
return ref_file_reference;
|
|
|
}
|
|
|
|
|
|
public void setRef_file_reference(String ref_file_reference) {
|
|
|
this.ref_file_reference = ref_file_reference;
|
|
|
}
|
|
|
|
|
|
public String getRef_participant_id() throws FWBException {
|
|
|
if (StringUtils.hasText(ref_participant_id) || StringUtils.hasText(ref_participant_code) || StringUtils.hasText(ref_participant_airport)){
|
|
|
if (!StringUtils.hasText(ref_participant_id) || !StringUtils.hasText(ref_participant_code) || !StringUtils.hasText(ref_participant_airport)){{
|
|
|
throw new FWBException(FWBExceptionType.REF_SPID_REGEX_FAILD);
|
|
|
}}
|
|
|
}
|
|
|
String patternStr = "^[A-Z0-9]{0,3}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(ref_participant_id);
|
|
|
if (!matcher.find()){
|
|
|
System.out.println("[REF-WARN]-participant_id 未通过规则校验");
|
|
|
}
|
|
|
return ref_participant_id;
|
|
|
}
|
|
|
|
|
|
public void setRef_participant_id(String ref_participant_id) {
|
|
|
this.ref_participant_id = ref_participant_id;
|
|
|
}
|
|
|
|
|
|
public String getRef_participant_code() {
|
|
|
|
|
|
String patternStr = "^[A-Z0-9]{0,17}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(ref_participant_code);
|
|
|
if (!matcher.find()){
|
|
|
System.out.println("[REF-WARN]-participant_code 未通过规则校验");
|
|
|
}
|
|
|
|
|
|
return ref_participant_code;
|
|
|
}
|
|
|
|
|
|
public void setRef_participant_code(String ref_participant_code) {
|
|
|
this.ref_participant_code = ref_participant_code;
|
|
|
}
|
|
|
|
|
|
public String getRef_participant_airport() {
|
|
|
|
|
|
String patternStr = "^[A-Z]{0,3}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(ref_participant_airport);
|
|
|
if (!matcher.find()){
|
|
|
System.out.println("[REF-WARN]- participant_airport 未通过规则校验");
|
|
|
}
|
|
|
|
|
|
return ref_participant_airport;
|
|
|
}
|
|
|
|
|
|
public void setRef_participant_airport(String ref_participant_airport) {
|
|
|
this.ref_participant_airport = ref_participant_airport;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getFWBNodeText() throws FWBException {
|
|
|
String SPLIT_CODE = "/";
|
|
|
String CRLF = "\n";
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
|
|
|
try {
|
|
|
sb.append(SPLIT_CODE)
|
|
|
.append(getRef_address());
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasLength(getRef_file_reference())){
|
|
|
sb.append(SPLIT_CODE)
|
|
|
.append(getRef_file_reference());
|
|
|
}else {
|
|
|
sb.append(SPLIT_CODE);
|
|
|
}
|
|
|
|
|
|
if (StringUtils.hasLength(getRef_participant_id())
|
|
|
&& StringUtils.hasLength(getRef_participant_code())
|
|
|
&& StringUtils.hasLength(getRef_participant_airport())
|
|
|
){
|
|
|
sb.append(SPLIT_CODE)
|
|
|
.append(getRef_participant_id());
|
|
|
sb.append(SPLIT_CODE)
|
|
|
.append(getRef_participant_code());
|
|
|
sb.append(SPLIT_CODE)
|
|
|
.append(getRef_participant_airport());
|
|
|
}
|
|
|
|
|
|
sb.append(CRLF);
|
|
|
|
|
|
} catch (FWBException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getNodeName() {
|
|
|
return "REF";
|
|
|
}
|
|
|
} |
...
|
...
|
|