1
|
package com.sunyo.wlpt.base.model.efreight.fwb;
|
1
|
package com.sunyo.wlpt.base.model.efreight.fwb;
|
2
|
|
2
|
|
3
|
|
3
|
|
|
|
4
|
+import com.sunyo.wlpt.base.model.efreight.BASE;
|
|
|
5
|
+import com.sunyo.wlpt.base.model.efreight.fwb.exception.FWBException;
|
|
|
6
|
+import com.sunyo.wlpt.base.model.efreight.fwb.exception.FWBExceptionType;
|
|
|
7
|
+
|
|
|
8
|
+import java.util.List;
|
|
|
9
|
+import java.util.regex.Matcher;
|
|
|
10
|
+import java.util.regex.Pattern;
|
|
|
11
|
+
|
4
|
/**
|
12
|
/**
|
5
|
* SPH
|
13
|
* SPH
|
6
|
* Special Handing Details
|
14
|
* Special Handing Details
|
|
@@ -11,7 +19,7 @@ package com.sunyo.wlpt.base.model.efreight.fwb; |
|
@@ -11,7 +19,7 @@ package com.sunyo.wlpt.base.model.efreight.fwb; |
11
|
* SPH/ECC/ELI
|
19
|
* SPH/ECC/ELI
|
12
|
* CRLF
|
20
|
* CRLF
|
13
|
*/
|
21
|
*/
|
14
|
-public class FWB_SPH {
|
22
|
+public class FWB_SPH extends BASE implements FWB_BASE {
|
15
|
|
23
|
|
16
|
/**
|
24
|
/**
|
17
|
* NODE:SPH
|
25
|
* NODE:SPH
|
|
@@ -23,5 +31,47 @@ public class FWB_SPH { |
|
@@ -23,5 +31,47 @@ public class FWB_SPH { |
23
|
* DEMO:
|
31
|
* DEMO:
|
24
|
* /ELI
|
32
|
* /ELI
|
25
|
*/
|
33
|
*/
|
26
|
- private String sph_code;
|
34
|
+ private List<String> sph_code;
|
|
|
35
|
+
|
|
|
36
|
+ public List<String> getSph_code() {
|
|
|
37
|
+ return sph_code;
|
|
|
38
|
+ }
|
|
|
39
|
+
|
|
|
40
|
+ public void setSph_code(List<String> sph_code) {
|
|
|
41
|
+ this.sph_code = sph_code;
|
|
|
42
|
+ }
|
|
|
43
|
+
|
|
|
44
|
+ public boolean codeCheck(String code) throws FWBException {
|
|
|
45
|
+ String patternStr = "^[A-Z]{3}$";
|
|
|
46
|
+ Pattern pattern = Pattern.compile(patternStr);
|
|
|
47
|
+ Matcher matcher = pattern.matcher(code);
|
|
|
48
|
+ if (!matcher.find()){
|
|
|
49
|
+ throw new FWBException(FWBExceptionType.SPH_CODE_FAILD);
|
|
|
50
|
+ }
|
|
|
51
|
+ return true;
|
|
|
52
|
+ }
|
|
|
53
|
+
|
|
|
54
|
+ @Override
|
|
|
55
|
+ public String getFWBNodeText() throws FWBException {
|
|
|
56
|
+ StringBuilder sb = new StringBuilder("");
|
|
|
57
|
+ if (sph_code!=null && !sph_code.isEmpty()){
|
|
|
58
|
+ if (sph_code.size()>9){
|
|
|
59
|
+ throw new FWBException(FWBExceptionType.SPH_LENGTH_FAILD);
|
|
|
60
|
+ }
|
|
|
61
|
+ sb.append(getNodeName());
|
|
|
62
|
+ for (String code : sph_code) {
|
|
|
63
|
+ if(codeCheck(code)){
|
|
|
64
|
+ sb.append(SPLIT_CODE).append(code);
|
|
|
65
|
+ }
|
|
|
66
|
+ }
|
|
|
67
|
+ sb.append(CRLF);
|
|
|
68
|
+ }
|
|
|
69
|
+
|
|
|
70
|
+ return sb.toString();
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ @Override
|
|
|
74
|
+ public String getNodeName() {
|
|
|
75
|
+ return "SPH";
|
|
|
76
|
+ }
|
27
|
} |
77
|
} |