|
|
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.List;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* SPH
|
|
|
* Special Handing Details
|
...
|
...
|
@@ -11,7 +19,7 @@ package com.sunyo.wlpt.base.model.efreight.fwb; |
|
|
* SPH/ECC/ELI
|
|
|
* CRLF
|
|
|
*/
|
|
|
public class FWB_SPH {
|
|
|
public class FWB_SPH extends BASE implements FWB_BASE {
|
|
|
|
|
|
/**
|
|
|
* NODE:SPH
|
...
|
...
|
@@ -23,5 +31,47 @@ public class FWB_SPH { |
|
|
* DEMO:
|
|
|
* /ELI
|
|
|
*/
|
|
|
private String sph_code;
|
|
|
private List<String> sph_code;
|
|
|
|
|
|
public List<String> getSph_code() {
|
|
|
return sph_code;
|
|
|
}
|
|
|
|
|
|
public void setSph_code(List<String> sph_code) {
|
|
|
this.sph_code = sph_code;
|
|
|
}
|
|
|
|
|
|
public boolean codeCheck(String code) throws FWBException {
|
|
|
String patternStr = "^[A-Z]{3}$";
|
|
|
Pattern pattern = Pattern.compile(patternStr);
|
|
|
Matcher matcher = pattern.matcher(code);
|
|
|
if (!matcher.find()){
|
|
|
throw new FWBException(FWBExceptionType.SPH_CODE_FAILD);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getFWBNodeText() throws FWBException {
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
if (sph_code!=null && !sph_code.isEmpty()){
|
|
|
if (sph_code.size()>9){
|
|
|
throw new FWBException(FWBExceptionType.SPH_LENGTH_FAILD);
|
|
|
}
|
|
|
sb.append(getNodeName());
|
|
|
for (String code : sph_code) {
|
|
|
if(codeCheck(code)){
|
|
|
sb.append(SPLIT_CODE).append(code);
|
|
|
}
|
|
|
}
|
|
|
sb.append(CRLF);
|
|
|
}
|
|
|
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getNodeName() {
|
|
|
return "SPH";
|
|
|
}
|
|
|
} |
...
|
...
|
|