作者 xudada

Merge remote-tracking branch 'origin/forWechatService' into forWechatService

... ... @@ -24,7 +24,7 @@ public class FHLController {
public ResultJson resolve(@RequestParam String ffm){
Originmanifestsecondary fhlInfo = new Originmanifestsecondary();
fhlInfo.text = ffm;
boolean result = resolve.resolve(fhlInfo);
return result? new ResultJson("200","success"):new ResultJson("400","解析失败");
ResultJson result = resolve.resolve(fhlInfo);
return result;
}
}
... ...
... ... @@ -459,7 +459,7 @@ public class FFMInfo implements Serializable {
private FFMInfo WayBillParse(String line,String uld) throws FFMResolveException {
//运单格式适配,这里注意空格字符 与连字符"-"
String pattern = "^(\\d{3}-\\d{8})([A-Z]{3})([A-Z]{3})/(T|P|S|M|D)(\\d+)(K)([0-9\\.]+)(MC)?([0-9\\.]+)?(DG)?([0-9\\.]+)?(T)?([0-9]+)?/";
String pattern = "^(\\d{3}-\\d{8})([A-Z]{3})([A-Z]{3})/(T|P|S|M|D)(\\d+)(K)([0-9\\.]+)(MC)?([0-9\\.]+)?(DG)?([0-9\\.]+)?(T)?([0-9]+)?/.{1,15}";
// 创建 Pattern 对象
Pattern r = Pattern.compile(pattern);
// 现在创建 matcher 对象
... ... @@ -542,6 +542,9 @@ public class FFMInfo implements Serializable {
waybillTotalPiece,
"0");
}
// else {
// throw new FFMResolveException(line+"-的运单节点格式错误,无法适配正则-"+pattern);
// }
return null;
}
... ... @@ -593,6 +596,7 @@ public class FFMInfo implements Serializable {
/**
* 进来这个方法的,处理完毕后行,都不再是运单行
* 解析完毕,缓存重置
* todo:这里有BUG
*/
temp.put("ISAWB","no");
... ...
... ... @@ -976,7 +976,7 @@ public class Originmanifestsecondary {
* CVD 计费声明节点解析
* @param line
*/
public void cvdParse(String line){
public void cvdParse(String line) throws FFMResolveException {
String keyword = "^CVD/([A-Z]{3})/([PC]{2})/([0-9\\.]{1,12}|NVD)/(NCV|[0-9\\.]{1,12})/(XXX|[0-9\\.]{1,11})";
// 创建 Pattern 对象
Pattern r = Pattern.compile(keyword);
... ... @@ -990,6 +990,8 @@ public class Originmanifestsecondary {
String Declared_Value_for_Insurance = m.group(5);
log.info("[CVD]-计费声明:货币代码[{}]-付费模式[{}]-运输申报价值[{}]-海关申报价值[{}]-保险申报价值[{}]",
ISO_Currency_Code,paymode,Declared_Value_for_Carriage,Declared_Value_for_Customs,Declared_Value_for_Insurance);
}else{
throw new FFMResolveException("CVD节点格式校验错误");
}
}
... ...
... ... @@ -2,7 +2,8 @@ package com.tianbo.analysis.service;
import com.tianbo.analysis.model.FFMInfo;
import com.tianbo.analysis.model.Originmanifestsecondary;
import com.tianbo.analysis.model.ResultJson;
public interface FHLResolve {
boolean resolve(Originmanifestsecondary var1);
ResultJson resolve(Originmanifestsecondary var1);
}
... ...
... ... @@ -3,6 +3,7 @@ package com.tianbo.analysis.service.imp;
import com.tianbo.analysis.dao.OriginmanifestsecondaryMapper;
import com.tianbo.analysis.dao.TBBaseAirportInfoDao;
import com.tianbo.analysis.model.Originmanifestsecondary;
import com.tianbo.analysis.model.ResultJson;
import com.tianbo.analysis.service.FHLResolve;
import org.springframework.stereotype.Service;
... ... @@ -18,14 +19,21 @@ public class FHLResolveImpl implements FHLResolve {
OriginmanifestsecondaryMapper mapper;
@Override
public boolean resolve(Originmanifestsecondary fhl) {
public ResultJson resolve(Originmanifestsecondary fhl) {
ResultJson resultJson = new ResultJson();
try{
fhl.textToStringList();
fhl.startParse();
if(fhl.startParse()){
resultJson.setMsg("解析报文成功");
resultJson.setCode("200");
}
}catch (Exception e){
e.printStackTrace();
resultJson.setMsg("解析报文失败");
resultJson.setCode("400");
resultJson.setError(e.toString());
}
return false;
return resultJson;
}
... ...