作者 朱兆平

回执解析优化

@@ -137,6 +137,7 @@ custom: @@ -137,6 +137,7 @@ custom:
137 receptBakDir: ./success 137 receptBakDir: ./success
138 #解析错误报文的备份目录 138 #解析错误报文的备份目录
139 errBakDir: ./error 139 errBakDir: ./error
  140 + transmitDir: ./transmit
140 devops: 141 devops:
141 dir: 142 dir:
142 singlewindow-tcs-recept: D:\TCSSingleWindow\recive 143 singlewindow-tcs-recept: D:\TCSSingleWindow\recive
@@ -40,6 +40,10 @@ public class CustomXmlHandleThread implements Runnable{ @@ -40,6 +40,10 @@ public class CustomXmlHandleThread implements Runnable{
40 @Value("${custom.errBakDir}") 40 @Value("${custom.errBakDir}")
41 private String errBakDir; 41 private String errBakDir;
42 42
  43 + //回执转发目录
  44 + @Value("${custom.transmit}")
  45 + private String transmitDir;
  46 +
43 private File xmlfile; 47 private File xmlfile;
44 private static CustomXmlHandleThread customXmlHandle; 48 private static CustomXmlHandleThread customXmlHandle;
45 //海关新舱单回执报头 49 //海关新舱单回执报头
@@ -101,6 +105,8 @@ public class CustomXmlHandleThread implements Runnable{ @@ -101,6 +105,8 @@ public class CustomXmlHandleThread implements Runnable{
101 customXmlHandle.bakupDir = this.bakupDir; 105 customXmlHandle.bakupDir = this.bakupDir;
102 106
103 customXmlHandle.errBakDir = this.errBakDir; 107 customXmlHandle.errBakDir = this.errBakDir;
  108 +
  109 + customXmlHandle.transmitDir = this.transmitDir;
104 // 初使化时将已静态化的testService实例化 110 // 初使化时将已静态化的testService实例化
105 } 111 }
106 112
@@ -108,12 +114,15 @@ public class CustomXmlHandleThread implements Runnable{ @@ -108,12 +114,15 @@ public class CustomXmlHandleThread implements Runnable{
108 public void run() { 114 public void run() {
109 115
110 try{ 116 try{
  117 + FileUtils.copyFileToDirectory(xmlfile,new File(customXmlHandle.transmitDir));
111 int i =handelXmlDocument(); 118 int i =handelXmlDocument();
112 String today = DateUtil.getTodayBy_yyyyMMdd(); 119 String today = DateUtil.getTodayBy_yyyyMMdd();
113 String backdireByDay = customXmlHandle.bakupDir + "/" + today; 120 String backdireByDay = customXmlHandle.bakupDir + "/" + today;
114 //操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份 121 //操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份
115 if(i>0){ 122 if(i>0){
116 File bakupDirectory = new File(backdireByDay); 123 File bakupDirectory = new File(backdireByDay);
  124 + //复制一份到转发目录
  125 + //解析成功备份一份到备份目录
117 FileUtils.moveFileToDirectory(xmlfile,bakupDirectory,true); 126 FileUtils.moveFileToDirectory(xmlfile,bakupDirectory,true);
118 }else { 127 }else {
119 errBak(xmlfile); 128 errBak(xmlfile);
@@ -57,7 +57,7 @@ public class NmmsBaseService { @@ -57,7 +57,7 @@ public class NmmsBaseService {
57 return shareServiceImp.share(customReception.getMessageType(), customReception); 57 return shareServiceImp.share(customReception.getMessageType(), customReception);
58 } 58 }
59 } 59 }
60 - //未进入主分单解析 返回0 失败 60 +
61 return 0; 61 return 0;
62 62
63 } 63 }
@@ -4,6 +4,8 @@ import com.tianbo.analysis.dao.ALLOCATEARRIVALMapper; @@ -4,6 +4,8 @@ import com.tianbo.analysis.dao.ALLOCATEARRIVALMapper;
4 import com.tianbo.analysis.model.ALLOCATEARRIVAL; 4 import com.tianbo.analysis.model.ALLOCATEARRIVAL;
5 import com.tianbo.analysis.model.CustomReception; 5 import com.tianbo.analysis.model.CustomReception;
6 import com.tianbo.analysis.service.ALLOCATEARRIVALService; 6 import com.tianbo.analysis.service.ALLOCATEARRIVALService;
  7 +import com.tianbo.analysis.service.NmmsBaseService;
  8 +import com.tianbo.analysis.tools.AWBTools;
7 import com.tianbo.util.Date.DateUtil; 9 import com.tianbo.util.Date.DateUtil;
8 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
9 import org.apache.commons.lang.StringUtils; 11 import org.apache.commons.lang.StringUtils;
@@ -19,7 +21,7 @@ import java.util.List; @@ -19,7 +21,7 @@ import java.util.List;
19 */ 21 */
20 @Service 22 @Service
21 @Slf4j 23 @Slf4j
22 -public class ALLOCATEARRIVALServiceImp implements ALLOCATEARRIVALService { 24 +public class ALLOCATEARRIVALServiceImp extends NmmsBaseService implements ALLOCATEARRIVALService {
23 25
24 @Autowired 26 @Autowired
25 ALLOCATEARRIVALMapper allocatearrivalMapper; 27 ALLOCATEARRIVALMapper allocatearrivalMapper;
@@ -39,19 +41,14 @@ public class ALLOCATEARRIVALServiceImp implements ALLOCATEARRIVALService { @@ -39,19 +41,14 @@ public class ALLOCATEARRIVALServiceImp implements ALLOCATEARRIVALService {
39 String flightDateStr = customReception.getFlightDate(); 41 String flightDateStr = customReception.getFlightDate();
40 if (!StringUtils.isEmpty(flightDateStr)) { 42 if (!StringUtils.isEmpty(flightDateStr)) {
41 Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr); 43 Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
42 - //设置主单回执、航班号、航班日期  
43 - ALLOCATEARRIVAL allocatearrival = new ALLOCATEARRIVAL();  
44 - allocatearrival.setReceiptinformation(reception);  
45 - allocatearrival.setFlightno(customReception.getFlightNo().substring(2));  
46 - allocatearrival.setFlightdate(flightDate); 44 +
47 45
48 if (awbA!=null && awbA.length()>0){ 46 if (awbA!=null && awbA.length()>0){
49 StringBuffer stringBuffer = new StringBuffer(awbA); 47 StringBuffer stringBuffer = new StringBuffer(awbA);
50 stringBuffer.insert(3,"-"); 48 stringBuffer.insert(3,"-");
51 awbA = stringBuffer.toString(); 49 awbA = stringBuffer.toString();
52 50
53 - //设置主分单的 主单号  
54 - allocatearrival.setWaybillno(awbA); 51 +
55 } 52 }
56 53
57 54
@@ -59,24 +56,7 @@ public class ALLOCATEARRIVALServiceImp implements ALLOCATEARRIVALService { @@ -59,24 +56,7 @@ public class ALLOCATEARRIVALServiceImp implements ALLOCATEARRIVALService {
59 if (flightDate != null && customReception.getFlightNo() != null){ 56 if (flightDate != null && customReception.getFlightNo() != null){
60 //处理主单格式,将海关回执的主单号58019316861,变为580-19316861 57 //处理主单格式,将海关回执的主单号58019316861,变为580-19316861
61 if (awbA!=null && awbA.length()>0){ 58 if (awbA!=null && awbA.length()>0){
62 - //更新主单回执  
63 - int i = allocatearrivalMapper.updateRECEIPTION(allocatearrival);  
64 - //获取分单autoid  
65 - List<ALLOCATEARRIVAL> arrivedmasterList = allocatearrivalMapper.selectAutoIdByAwb(allocatearrival);  
66 - if(!arrivedmasterList.isEmpty()){  
67 - ALLOCATEARRIVAL departuresloading1 = arrivedmasterList.get(0);  
68 - String autoId = departuresloading1.getId();  
69 -  
70 - //插入sendlog记录表  
71 - log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);  
72 - int ii =coustomAnalysisServiceImp.insertSendlog("MT3202",reception,autoId);  
73 -  
74 - int iii = shareServiceImp.updateMessages(customReception);  
75 - if (i>0 && ii>0 && iii > 0){  
76 - return 1;  
77 - }  
78 - }  
79 - return 0; 59 +
80 } 60 }
81 }else { 61 }else {
82 62
@@ -88,4 +68,36 @@ public class ALLOCATEARRIVALServiceImp implements ALLOCATEARRIVALService { @@ -88,4 +68,36 @@ public class ALLOCATEARRIVALServiceImp implements ALLOCATEARRIVALService {
88 //未进入主分单解析 返回0 失败 68 //未进入主分单解析 返回0 失败
89 return 0; 69 return 0;
90 } 70 }
  71 +
  72 + @Override
  73 + public int master() {
  74 + //设置主单回执、航班号、航班日期
  75 + ALLOCATEARRIVAL allocatearrival = new ALLOCATEARRIVAL();
  76 + allocatearrival.setReceiptinformation(reception);
  77 + String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());
  78 + allocatearrival.setFlightno(flightInfo[1]);
  79 + allocatearrival.setCarrier(flightInfo[0]);
  80 + allocatearrival.setFlightdate(flightDate);
  81 + //设置主分单的 主单号
  82 + allocatearrival.setWaybillno(awbA);
  83 + allocatearrival.setStatus(nmsStatusCode);
  84 + //更新主单回执
  85 + int i = allocatearrivalMapper.updateRECEIPTION(allocatearrival);
  86 + //获取分单autoid
  87 + List<ALLOCATEARRIVAL> arrivedmasterList = allocatearrivalMapper.selectAutoIdByAwb(allocatearrival);
  88 + if(!arrivedmasterList.isEmpty()){
  89 + ALLOCATEARRIVAL departuresloading1 = arrivedmasterList.get(0);
  90 + String autoId = departuresloading1.getId();
  91 +
  92 + //插入sendlog记录表
  93 + log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
  94 + int ii =coustomAnalysisServiceImp.insertSendlog("MT3202",reception,autoId);
  95 +
  96 + int iii = shareServiceImp.updateMessages(customReception);
  97 + if (i>0 && ii>0 && iii > 0){
  98 + return 1;
  99 + }
  100 + }
  101 + return 0;
  102 + }
91 } 103 }
@@ -9,6 +9,7 @@ import com.tianbo.analysis.model.ORIGINMANIFESTMASTER; @@ -9,6 +9,7 @@ import com.tianbo.analysis.model.ORIGINMANIFESTMASTER;
9 import com.tianbo.analysis.model.Originmanifestsecondary; 9 import com.tianbo.analysis.model.Originmanifestsecondary;
10 import com.tianbo.analysis.model.SENDLOG; 10 import com.tianbo.analysis.model.SENDLOG;
11 import com.tianbo.analysis.service.CoustomAnalysisService; 11 import com.tianbo.analysis.service.CoustomAnalysisService;
  12 +import com.tianbo.analysis.service.NmmsBaseService;
12 import com.tianbo.util.Date.DateUtil; 13 import com.tianbo.util.Date.DateUtil;
13 import com.tianbo.util.Helper; 14 import com.tianbo.util.Helper;
14 import lombok.extern.slf4j.Slf4j; 15 import lombok.extern.slf4j.Slf4j;
@@ -20,9 +21,13 @@ import java.math.BigDecimal; @@ -20,9 +21,13 @@ import java.math.BigDecimal;
20 import java.util.Date; 21 import java.util.Date;
21 import java.util.List; 22 import java.util.List;
22 23
  24 +/**
  25 + * @author mrz
  26 + * 原始回执解析
  27 + */
23 @Service 28 @Service
24 @Slf4j 29 @Slf4j
25 -public class CoustomAnalysisServiceImp implements CoustomAnalysisService { 30 +public class CoustomAnalysisServiceImp extends NmmsBaseService implements CoustomAnalysisService {
26 31
27 @Autowired 32 @Autowired
28 SENDLOGMapper sendlogMapper; 33 SENDLOGMapper sendlogMapper;
@@ -38,99 +43,80 @@ public class CoustomAnalysisServiceImp implements CoustomAnalysisService { @@ -38,99 +43,80 @@ public class CoustomAnalysisServiceImp implements CoustomAnalysisService {
38 } 43 }
39 } 44 }
40 45
  46 +
  47 +
41 @Override 48 @Override
42 public int insertRecept(CustomReception customReception){ 49 public int insertRecept(CustomReception customReception){
  50 + return super.insertRecept(customReception);
  51 + }
43 52
44 - ShareServiceImp shareServiceImp = new ShareServiceImp();  
45 -  
46 -  
47 - String awbA = customReception.getWayBillMaster();  
48 - String awbH = customReception.getWayBillSecond();  
49 - // 回执内容  
50 - String reception = customReception.getResponseText();  
51 - String flightDateStr = customReception.getFlightDate();  
52 -  
53 -// Date flightDate = new Date();  
54 - if (!StringUtils.isEmpty(flightDateStr)){  
55 - Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);  
56 -  
57 - // 设置分单回执  
58 - Originmanifestsecondary originmanifestsecondary = new Originmanifestsecondary();  
59 - originmanifestsecondary.setReceiption(reception);  
60 -  
61 - // 设置主单回执、航班号、航班日期  
62 - ORIGINMANIFESTMASTER originmanifestmaster = new ORIGINMANIFESTMASTER();  
63 - originmanifestmaster.setReceiptinformation(reception);  
64 - originmanifestmaster.setFlightno(customReception.getFlightNo());  
65 - originmanifestmaster.setFlightDate(flightDate);  
66 -  
67 - // 判断航班号 航班日期 是否为空  
68 - if (flightDate != null && customReception.getFlightNo() != null){  
69 - if (awbA!=null && awbA.length()>0){  
70 - StringBuffer stringBuffer = new StringBuffer(awbA);  
71 - stringBuffer.insert(3,"-");  
72 - awbA = stringBuffer.toString();  
73 -  
74 - //设置主分单的 主单号  
75 - originmanifestsecondary.setWaybillnomaster(awbA);  
76 - originmanifestmaster.setWaybillnomaster(awbA);  
77 - }  
78 -  
79 - //有分单号 更新分单  
80 - if(awbA!=null && awbA.length()>0 && awbH!=null && awbH.length()> 0){  
81 - //取分单号  
82 - String[] awbhArr = awbH.split("_");  
83 - String awbh = awbhArr[1];  
84 - originmanifestsecondary.setWaybillnosecondary(awbh);  
85 - //更新分单回执  
86 - int i = originmanifestsecondaryMapper.updateRECEIPTION(originmanifestsecondary);  
87 - //获取分单autoid  
88 - List<Originmanifestsecondary> originmanifestsecondaryList = originmanifestsecondaryMapper.selectAutoIdByawbAawbH(originmanifestsecondary);  
89 - if(!originmanifestsecondaryList.isEmpty()){  
90 - Originmanifestsecondary originSecond = originmanifestsecondaryList.get(0);  
91 - String autoId = originSecond.getAutoid();  
92 - //插入sendlog记录表  
93 - log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);  
94 - int ii = insertSendlog("MT1201",reception,autoId);  
95 -  
96 - int iii = shareServiceImp.updateMessages(customReception);  
97 - if (i>0 && ii>0 && iii > 0){  
98 - return 1;  
99 - }  
100 - }  
101 - return 0;  
102 - }  
103 -  
104 - //处理主单格式,将海关回执的主单号58019316861,变为580-19316861  
105 - if (awbA!=null && awbA.length()>0){  
106 - //更新主单回执  
107 - int i = originmanifestmasterMapper.updateRECEIPTION(originmanifestmaster);  
108 - //获取分单autoid  
109 - List<ORIGINMANIFESTMASTER> originmanifestmasterList = originmanifestmasterMapper.selectAutoIdByAwb(originmanifestmaster);  
110 - if(!originmanifestmasterList.isEmpty()){  
111 - ORIGINMANIFESTMASTER originMaster = originmanifestmasterList.get(0);  
112 - String autoId = originMaster.getAutoid();  
113 -  
114 - //插入sendlog记录表  
115 - log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);  
116 - int ii =insertSendlog("MT1201",reception,autoId);  
117 -  
118 - int iii = shareServiceImp.updateMessages(customReception);  
119 - if (i>0 && ii>0 && iii > 0){  
120 - return 1;  
121 - }  
122 - }  
123 - return 0;  
124 - }  
125 - }else {  
126 - return shareServiceImp.share("MT1201", customReception); 53 + @Override
  54 + public int second() {
  55 + // 设置分单回执
  56 + Originmanifestsecondary originmanifestsecondary = new Originmanifestsecondary();
  57 + originmanifestsecondary.setReceiption(reception);
  58 + //设置主分单的 主单号
  59 + originmanifestsecondary.setWaybillnomaster(awbA);
  60 + //取分单号
  61 + String[] awbhArr = awbH.split("_");
  62 + String awbh = awbhArr[1];
  63 + originmanifestsecondary.setWaybillnosecondary(awbh);
  64 + originmanifestsecondary.setStatus(nmsStatusCode);
  65 + //更新分单回执
  66 + int i = originmanifestsecondaryMapper.updateRECEIPTION(originmanifestsecondary);
  67 + //获取分单autoid
  68 + List<Originmanifestsecondary> originmanifestsecondaryList = originmanifestsecondaryMapper.selectAutoIdByawbAawbH(originmanifestsecondary);
  69 + if(!originmanifestsecondaryList.isEmpty()){
  70 + Originmanifestsecondary originSecond = originmanifestsecondaryList.get(0);
  71 + String autoId = originSecond.getAutoid();
  72 + //插入sendlog记录表
  73 + log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);
  74 + int ii = insertSendlog("MT1201",reception,autoId);
  75 +
  76 + int iii = shareServiceImp.updateMessages(customReception);
  77 + if (i>0 && ii>0){
  78 + log.info("运单号 {} 原始回执更新成功",awbA);
  79 + return 1;
  80 + }
  81 + if (iii > 0){
  82 + return 1;
127 } 83 }
128 } 84 }
129 -  
130 - //未进入主分单解析 返回0 失败  
131 return 0; 85 return 0;
132 } 86 }
133 87
  88 + @Override
  89 + public int master() {
  90 + // 设置主单回执、航班号、航班日期
  91 + ORIGINMANIFESTMASTER originmanifestmaster = new ORIGINMANIFESTMASTER();
  92 + originmanifestmaster.setReceiptinformation(reception);
  93 + originmanifestmaster.setFlightno(customReception.getFlightNo());
  94 + originmanifestmaster.setFlightDate(flightDate);
  95 + originmanifestmaster.setWaybillnomaster(awbA);
  96 + originmanifestmaster.setStatus(nmsStatusCode);
  97 + //更新主单回执
  98 + int i = originmanifestmasterMapper.updateRECEIPTION(originmanifestmaster);
  99 + //获取分单autoid
  100 + List<ORIGINMANIFESTMASTER> originmanifestmasterList = originmanifestmasterMapper.selectAutoIdByAwb(originmanifestmaster);
  101 + if(!originmanifestmasterList.isEmpty()){
  102 + ORIGINMANIFESTMASTER originMaster = originmanifestmasterList.get(0);
  103 + String autoId = originMaster.getAutoid();
  104 +
  105 + //插入sendlog记录表
  106 + log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
  107 + int ii =insertSendlog("MT1201",reception,autoId);
  108 +
  109 + int iii = shareServiceImp.updateMessages(customReception);
  110 + if (i>0 && ii>0){
  111 + log.info("运单号 {} 原始回执更新成功",awbA);
  112 + return 1;
  113 + }
  114 + if (iii > 0){
  115 + return 1;
  116 + }
  117 + }
  118 + return 0;
  119 + }
134 120
135 public int insertSendlog(String type,String reception,String autoId){ 121 public int insertSendlog(String type,String reception,String autoId){
136 SENDLOG sendlog = new SENDLOG(); 122 SENDLOG sendlog = new SENDLOG();
@@ -5,6 +5,8 @@ import com.tianbo.analysis.dao.INPORTALLOCATEMapper; @@ -5,6 +5,8 @@ import com.tianbo.analysis.dao.INPORTALLOCATEMapper;
5 import com.tianbo.analysis.model.CustomReception; 5 import com.tianbo.analysis.model.CustomReception;
6 import com.tianbo.analysis.model.INPORTALLOCATE; 6 import com.tianbo.analysis.model.INPORTALLOCATE;
7 import com.tianbo.analysis.service.INPORTALLOCATEService; 7 import com.tianbo.analysis.service.INPORTALLOCATEService;
  8 +import com.tianbo.analysis.service.NmmsBaseService;
  9 +import com.tianbo.analysis.tools.AWBTools;
8 import com.tianbo.util.Date.DateUtil; 10 import com.tianbo.util.Date.DateUtil;
9 import lombok.extern.slf4j.Slf4j; 11 import lombok.extern.slf4j.Slf4j;
10 import org.apache.commons.lang.StringUtils; 12 import org.apache.commons.lang.StringUtils;
@@ -21,7 +23,7 @@ import java.util.List; @@ -21,7 +23,7 @@ import java.util.List;
21 23
22 @Service 24 @Service
23 @Slf4j 25 @Slf4j
24 -public class INPORTALLOCATEServiceImp implements INPORTALLOCATEService{ 26 +public class INPORTALLOCATEServiceImp extends NmmsBaseService implements INPORTALLOCATEService{
25 27
26 @Autowired 28 @Autowired
27 INPORTALLOCATEMapper inportallocateMapper; 29 INPORTALLOCATEMapper inportallocateMapper;
@@ -29,65 +31,41 @@ public class INPORTALLOCATEServiceImp implements INPORTALLOCATEService{ @@ -29,65 +31,41 @@ public class INPORTALLOCATEServiceImp implements INPORTALLOCATEService{
29 31
30 @Override 32 @Override
31 public int insertRecept(CustomReception customReception) { 33 public int insertRecept(CustomReception customReception) {
32 - ShareServiceImp shareServiceImp = new ShareServiceImp();  
33 -  
34 - // 发送日志 插入  
35 - CoustomAnalysisServiceImp coustomAnalysisServiceImp = new CoustomAnalysisServiceImp();  
36 -  
37 - // 主单号  
38 - String awbA = customReception.getWayBillMaster();  
39 - //回执内容  
40 - String reception = customReception.getResponseText();  
41 - String flightDateStr = customReception.getFlightDate();  
42 - if (!StringUtils.isEmpty(flightDateStr)) {  
43 - Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);  
44 - //设置主单回执、航班号、航班日期  
45 - INPORTALLOCATE inportallocate = new INPORTALLOCATE();  
46 - inportallocate.setReceiptinformation(reception);  
47 - inportallocate.setFlightno(customReception.getFlightNo().substring(2));  
48 - inportallocate.setFlightdate(flightDate);  
49 -  
50 - if (awbA!=null && awbA.length()>0){  
51 - StringBuffer stringBuffer = new StringBuffer(awbA);  
52 - stringBuffer.insert(3,"-");  
53 - awbA = stringBuffer.toString(); 34 + return super.insertRecept(customReception);
  35 + }
54 36
55 - //设置主分单的 主单号  
56 - inportallocate.setWaybillno(awbA); 37 + @Override
  38 + public int master() {
  39 + INPORTALLOCATE inportallocate = new INPORTALLOCATE();
  40 + inportallocate.setReceiptinformation(reception);
  41 + String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());
  42 + inportallocate.setFlightno(flightInfo[1]);
  43 + inportallocate.setCarrier(flightInfo[0]);
  44 + inportallocate.setFlightdate(flightDate);
  45 + //设置主分单的 主单号
  46 + inportallocate.setWaybillno(awbA);
  47 + inportallocate.setStatus(nmsStatusCode);
  48 + //更新主单回执
  49 + int i = inportallocateMapper.updateRECEIPTION(inportallocate);
  50 + //获取分单autoid
  51 + List<INPORTALLOCATE> arrivedmasterList = inportallocateMapper.selectAutoIdByAwb(inportallocate);
  52 + if(!arrivedmasterList.isEmpty()){
  53 + INPORTALLOCATE departuresloading1 = arrivedmasterList.get(0);
  54 + String autoId = departuresloading1.getId();
  55 +
  56 + //插入sendlog记录表
  57 + log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
  58 + int ii =coustomAnalysisServiceImp.insertSendlog("MT6202",reception,autoId);
  59 +
  60 + int iii = shareServiceImp.updateMessages(customReception);
  61 + if (i>0 && ii>0 ){
  62 + log.info("运单号 {} 分拨申请回执更新成功",awbA);
  63 + return 1;
57 } 64 }
58 -  
59 -  
60 - // 判断航班号 航班日期 是否为空  
61 - if (flightDate != null && customReception.getFlightNo() != null){  
62 - //处理主单格式,将海关回执的主单号58019316861,变为580-19316861  
63 - if (awbA!=null && awbA.length()>0){  
64 - //更新主单回执  
65 - int i = inportallocateMapper.updateRECEIPTION(inportallocate);  
66 - //获取分单autoid  
67 - List<INPORTALLOCATE> arrivedmasterList = inportallocateMapper.selectAutoIdByAwb(inportallocate);  
68 - if(!arrivedmasterList.isEmpty()){  
69 - INPORTALLOCATE departuresloading1 = arrivedmasterList.get(0);  
70 - String autoId = departuresloading1.getId();  
71 -  
72 - //插入sendlog记录表  
73 - log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);  
74 - int ii =coustomAnalysisServiceImp.insertSendlog("MT6202",reception,autoId);  
75 -  
76 - int iii = shareServiceImp.updateMessages(customReception);  
77 - if (i>0 && ii>0 && iii > 0){  
78 - return 1;  
79 - }  
80 - }  
81 - return 0;  
82 - }  
83 - }else {  
84 -  
85 - return shareServiceImp.share("MT6202", customReception); 65 + if (iii > 0){
  66 + return 1;
86 } 67 }
87 -  
88 } 68 }
89 -  
90 - //未进入主分单解析 返回0 失败  
91 return 0; 69 return 0;
92 } 70 }
93 } 71 }
@@ -5,10 +5,10 @@ import com.tianbo.analysis.dao.PREPARESECONDARYMapper; @@ -5,10 +5,10 @@ import com.tianbo.analysis.dao.PREPARESECONDARYMapper;
5 import com.tianbo.analysis.model.CustomReception; 5 import com.tianbo.analysis.model.CustomReception;
6 import com.tianbo.analysis.model.PREPAREMASTER; 6 import com.tianbo.analysis.model.PREPAREMASTER;
7 import com.tianbo.analysis.model.PREPARESECONDARY; 7 import com.tianbo.analysis.model.PREPARESECONDARY;
  8 +import com.tianbo.analysis.service.NmmsBaseService;
8 import com.tianbo.analysis.service.PREPAREMASTERService; 9 import com.tianbo.analysis.service.PREPAREMASTERService;
9 -import com.tianbo.util.Date.DateUtil; 10 +import com.tianbo.analysis.tools.AWBTools;
10 import lombok.extern.slf4j.Slf4j; 11 import lombok.extern.slf4j.Slf4j;
11 -import org.apache.commons.lang.StringUtils;  
12 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
14 14
@@ -21,7 +21,7 @@ import java.util.List; @@ -21,7 +21,7 @@ import java.util.List;
21 */ 21 */
22 @Service 22 @Service
23 @Slf4j 23 @Slf4j
24 -public class PREPAREMASTERServiceImp implements PREPAREMASTERService { 24 +public class PREPAREMASTERServiceImp extends NmmsBaseService implements PREPAREMASTERService {
25 25
26 @Autowired 26 @Autowired
27 PREPAREMASTERMapper preparemasterMapper; 27 PREPAREMASTERMapper preparemasterMapper;
@@ -33,98 +33,85 @@ public class PREPAREMASTERServiceImp implements PREPAREMASTERService { @@ -33,98 +33,85 @@ public class PREPAREMASTERServiceImp implements PREPAREMASTERService {
33 // 货物接收运抵主分单 33 // 货物接收运抵主分单
34 public int insertRecept(CustomReception customReception) { 34 public int insertRecept(CustomReception customReception) {
35 35
  36 + return super.insertRecept(customReception);
  37 + }
36 38
37 - ShareServiceImp shareServiceImp = new ShareServiceImp();  
38 - // 发送日志 插入  
39 - CoustomAnalysisServiceImp coustomAnalysisServiceImp = new CoustomAnalysisServiceImp();  
40 -  
41 - // 主单号  
42 - String awbA = customReception.getWayBillMaster();  
43 - String awbH = customReception.getWayBillSecond();  
44 - //回执内容  
45 - String reception = customReception.getResponseText();  
46 - String flightDateStr = customReception.getFlightDate();  
47 - if (!StringUtils.isEmpty(flightDateStr)) {  
48 - Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);  
49 -  
50 - // 设置 接收运抵分单 回执  
51 - PREPARESECONDARY preparesecondary = new PREPARESECONDARY();  
52 - preparesecondary.setReceiptinformation(reception);  
53 -  
54 - //设置主单回执、航班号、航班日期  
55 - PREPAREMASTER preparemaster = new PREPAREMASTER();  
56 - preparemaster.setReceiptinformation(reception);  
57 - preparemaster.setFlightno(customReception.getFlightNo());  
58 - preparemaster.setFlightdate(flightDate);  
59 -  
60 - if (awbA!=null && awbA.length()>0){  
61 - StringBuffer stringBuffer = new StringBuffer(awbA);  
62 - stringBuffer.insert(3,"-");  
63 - awbA = stringBuffer.toString();  
64 -  
65 - //设置主分单的 主单号  
66 - preparesecondary.setWaybillnomaster(awbA);  
67 - preparemaster.setWaybillnomaster(awbA); 39 + /**
  40 + * 入库分单回执信息
  41 + * @return 成功返回1,失败返回0。
  42 + */
  43 + @Override
  44 + public int second() {
  45 + // 设置 接收运抵分单 回执
  46 + PREPARESECONDARY preparesecondary = new PREPARESECONDARY();
  47 + preparesecondary.setReceiptinformation(reception);
  48 + //设置主分单的 主单号
  49 + preparesecondary.setWaybillnomaster(awbA);
  50 +//取分单号
  51 + String[] awbhArr = awbH.split("_");
  52 + String awbh = awbhArr[1];
  53 + preparesecondary.setWaybillnosecondary(awbh);
  54 + preparesecondary.setStatus(nmsStatusCode);
  55 + //更新分单回执
  56 + int i = preparesecondaryMapper.updateRECEIPTION(preparesecondary);
  57 + //获取分单autoid
  58 + List<PREPARESECONDARY> arrivedsecondaryList = preparesecondaryMapper.selectAutoIdByawbAawbH(preparesecondary);
  59 + if(!arrivedsecondaryList.isEmpty()){
  60 + PREPARESECONDARY preparesecondary1 = arrivedsecondaryList.get(0);
  61 + String autoId = preparesecondary1.getAutoid();
  62 + //插入sendlog记录表
  63 + log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);
  64 + int ii = coustomAnalysisServiceImp.insertSendlog(customReception.getMessageType(),reception,autoId);
  65 +
  66 + int iii = shareServiceImp.updateMessages(customReception);
  67 + if (i>0 && ii>0){
  68 + log.info("运单号 {} 原始回执更新成功",awbH);
  69 + return 1;
68 } 70 }
  71 + if (iii > 0){
  72 + return 1;
  73 + }
  74 + }
  75 + return 0;
69 76
  77 + }
70 78
71 - // 判断航班号 航班日期 是否为空  
72 - if (flightDate != null && customReception.getFlightNo() != null){  
73 - //有分单号 更新分单  
74 - if(awbA!=null && awbA.length()>0 && awbH!=null && awbH.length()> 0){  
75 - //取分单号  
76 - String[] awbhArr = awbH.split("_");  
77 - String awbh = awbhArr[1];  
78 - preparesecondary.setWaybillnosecondary(awbh);  
79 - //更新分单回执  
80 - int i = preparesecondaryMapper.updateRECEIPTION(preparesecondary);  
81 - //获取分单autoid  
82 - List<PREPARESECONDARY> arrivedsecondaryList = preparesecondaryMapper.selectAutoIdByawbAawbH(preparesecondary);  
83 - if(!arrivedsecondaryList.isEmpty()){  
84 - PREPARESECONDARY preparesecondary1 = arrivedsecondaryList.get(0);  
85 - String autoId = preparesecondary1.getAutoid();  
86 - //插入sendlog记录表  
87 - log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);  
88 - int ii = coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);  
89 -  
90 - int iii = shareServiceImp.updateMessages(customReception);  
91 - if (i>0 && ii>0 && iii > 0){  
92 - return 1;  
93 - }  
94 - }  
95 - return 0;  
96 - }  
97 -  
98 - //处理主单格式,将海关回执的主单号58019316861,变为580-19316861  
99 - if (awbA!=null && awbA.length()>0){  
100 - //更新主单回执  
101 - int i = preparemasterMapper.updateRECEIPTION(preparemaster);  
102 - //获取分单autoid  
103 - List<PREPAREMASTER> arrivedmasterList = preparemasterMapper.selectAutoIdByAwb(preparemaster);  
104 - if(!arrivedmasterList.isEmpty()){  
105 - PREPAREMASTER originMaster = arrivedmasterList.get(0);  
106 - String autoId = originMaster.getAutoid();  
107 -  
108 - //插入sendlog记录表  
109 - log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);  
110 - int ii =coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);  
111 -  
112 - int iii = shareServiceImp.updateMessages(customReception);  
113 - if (i>0 && ii>0 && iii > 0){  
114 - return 1;  
115 - }  
116 - }  
117 - return 0;  
118 - }  
119 - }else {  
120 -  
121 -  
122 - return shareServiceImp.share("MT2201", customReception); 79 + /**
  80 + * 入库分单回执信息
  81 + * @return 成功返回1,失败返回0。
  82 + */
  83 + @Override
  84 + public int master() {
  85 + //设置主单回执、航班号、航班日期
  86 + PREPAREMASTER preparemaster = new PREPAREMASTER();
  87 + preparemaster.setReceiptinformation(reception);
  88 + String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());
  89 + preparemaster.setFlightno(flightInfo[1]);
  90 + preparemaster.setCarrier(flightInfo[0]);
  91 + preparemaster.setFlightdate(flightDate);
  92 + preparemaster.setWaybillnomaster(awbA);
  93 + preparemaster.setStatus(nmsStatusCode);
  94 + //更新主单回执
  95 + int i = preparemasterMapper.updateRECEIPTION(preparemaster);
  96 + //获取分单autoid
  97 + List<PREPAREMASTER> arrivedmasterList = preparemasterMapper.selectAutoIdByAwb(preparemaster);
  98 + if(!arrivedmasterList.isEmpty()){
  99 + PREPAREMASTER originMaster = arrivedmasterList.get(0);
  100 + String autoId = originMaster.getAutoid();
  101 +
  102 + //插入sendlog记录表
  103 + log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
  104 + int ii =coustomAnalysisServiceImp.insertSendlog(customReception.getMessageType(),reception,autoId);
  105 +
  106 + int iii = shareServiceImp.updateMessages(customReception);
  107 + if (i>0 && ii>0){
  108 + log.info("运单号 {} 原始回执更新成功",awbA);
  109 + return 1;
  110 + }
  111 + if (iii > 0){
  112 + return 1;
123 } 113 }
124 -  
125 } 114 }
126 -  
127 - //未进入主分单解析 返回0 失败  
128 return 0; 115 return 0;
129 } 116 }
130 } 117 }
@@ -15,9 +15,11 @@ public class AWBTools { @@ -15,9 +15,11 @@ public class AWBTools {
15 } 15 }
16 16
17 public static String[] splitFlight(String flightNo){ 17 public static String[] splitFlight(String flightNo){
18 - String[] flight = {"1","2"};  
19 - flight[0] = flightNo.substring(0,2);  
20 - flight[1] = flightNo.substring(2); 18 + String[] flight = {"UNKONW","UNKONW"};
  19 + if (!StringUtils.isEmpty(flightNo) && flightNo.length()>2){
  20 + flight[0] = flightNo.substring(0,2);
  21 + flight[1] = flightNo.substring(2);
  22 + }
21 return flight; 23 return flight;
22 } 24 }
23 25
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <result column="WAYBILLNO" property="waybillno" jdbcType="VARCHAR" /> 7 <result column="WAYBILLNO" property="waybillno" jdbcType="VARCHAR" />
8 <result column="CARRIER" property="carrier" jdbcType="VARCHAR" /> 8 <result column="CARRIER" property="carrier" jdbcType="VARCHAR" />
9 <result column="FLIGHTNO" property="flightno" jdbcType="VARCHAR" /> 9 <result column="FLIGHTNO" property="flightno" jdbcType="VARCHAR" />
10 - <result column="FLIGHTDATE" property="flightdate" jdbcType="TIMESTAMP" /> 10 + <result column="FLIGHTDATE" property="flightdate" jdbcType="DATE" />
11 <result column="CUSTOMOS" property="customos" jdbcType="VARCHAR" /> 11 <result column="CUSTOMOS" property="customos" jdbcType="VARCHAR" />
12 <result column="ARRIVALPIECES" property="arrivalpieces" jdbcType="VARCHAR" /> 12 <result column="ARRIVALPIECES" property="arrivalpieces" jdbcType="VARCHAR" />
13 <result column="ARRIVALWEIGHT" property="arrivalweight" jdbcType="VARCHAR" /> 13 <result column="ARRIVALWEIGHT" property="arrivalweight" jdbcType="VARCHAR" />
@@ -117,10 +117,14 @@ @@ -117,10 +117,14 @@
117 117
118 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.ALLOCATEARRIVAL" > 118 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.ALLOCATEARRIVAL" >
119 UPDATE ALLOCATEARRIVAL 119 UPDATE ALLOCATEARRIVAL
120 - SET RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR}  
121 - WHERE FLIGHTNO = #{flightno,jdbcType=VARCHAR} 120 + SET RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR},
  121 + STATUS = #{status,jdbcType=VARCHAR}
  122 + WHERE
  123 + CARRIER = #{carrier,jdbcType=VARCHAR}
  124 + AND
  125 + FLIGHTNO = #{flightno,jdbcType=VARCHAR}
122 AND 126 AND
123 - FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP} 127 + FLIGHTDATE= #{flightDate,jdbcType=DATE}
124 AND 128 AND
125 WAYBILLNO = #{waybillno,jdbcType=VARCHAR} 129 WAYBILLNO = #{waybillno,jdbcType=VARCHAR}
126 </update> 130 </update>
@@ -131,7 +135,7 @@ @@ -131,7 +135,7 @@
131 WHERE 135 WHERE
132 FLIGHTNO= #{flightno,jdbcType=VARCHAR} 136 FLIGHTNO= #{flightno,jdbcType=VARCHAR}
133 AND 137 AND
134 - FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP} 138 + FLIGHTDATE= #{flightDate,jdbcType=DATE}
135 AND 139 AND
136 WAYBILLNO = #{waybillno,jdbcType=VARCHAR} 140 WAYBILLNO = #{waybillno,jdbcType=VARCHAR}
137 </select> 141 </select>
@@ -132,9 +132,13 @@ @@ -132,9 +132,13 @@
132 132
133 133
134 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.INPORTALLOCATE" > 134 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.INPORTALLOCATE" >
135 - UPDATE ALLOCATEARRIVAL  
136 - SET RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR}  
137 - WHERE FLIGHTNO = #{flightno,jdbcType=VARCHAR} 135 + UPDATE INPORTALLOCATE
  136 + SET RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR},
  137 + STATUS = #{status,jdbcType=VARCHAR}
  138 + WHERE
  139 + CARRIER = #{carrier,jdbcType=VARCHAR}
  140 + AND
  141 + FLIGHTNO = #{flightno,jdbcType=VARCHAR}
138 AND 142 AND
139 FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP} 143 FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP}
140 AND 144 AND
@@ -143,7 +147,7 @@ @@ -143,7 +147,7 @@
143 147
144 <select id="selectAutoIdByAwb" parameterType="com.tianbo.analysis.model.INPORTALLOCATE" resultType="com.tianbo.analysis.model.INPORTALLOCATE"> 148 <select id="selectAutoIdByAwb" parameterType="com.tianbo.analysis.model.INPORTALLOCATE" resultType="com.tianbo.analysis.model.INPORTALLOCATE">
145 SELECT ID 149 SELECT ID
146 - FROM ALLOCATEARRIVAL 150 + FROM INPORTALLOCATE
147 WHERE 151 WHERE
148 FLIGHTNO= #{flightno,jdbcType=VARCHAR} 152 FLIGHTNO= #{flightno,jdbcType=VARCHAR}
149 AND 153 AND
@@ -355,7 +355,9 @@ @@ -355,7 +355,9 @@
355 355
356 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.ORIGINMANIFESTMASTER" > 356 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.ORIGINMANIFESTMASTER" >
357 UPDATE ORIGINMANIFESTMASTER 357 UPDATE ORIGINMANIFESTMASTER
358 - SET RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR} 358 + SET
  359 + RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR},
  360 + STATUS=#{status,jdbcType=VARCHAR }
359 WHERE FLIGHTNO = #{flightno,jdbcType=VARCHAR} 361 WHERE FLIGHTNO = #{flightno,jdbcType=VARCHAR}
360 AND 362 AND
361 FLIGHT_DATE= #{flightDate,jdbcType=TIMESTAMP} 363 FLIGHT_DATE= #{flightDate,jdbcType=TIMESTAMP}
@@ -308,12 +308,15 @@ @@ -308,12 +308,15 @@
308 </insert> 308 </insert>
309 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.PREPAREMASTER" > 309 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.PREPAREMASTER" >
310 UPDATE PREPAREMASTER 310 UPDATE PREPAREMASTER
311 - SET RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR} 311 + SET RECEIPTINFORMATION= #{receiptinformation,jdbcType=VARCHAR},
  312 + STATUS = #{status,jdbcType=VARCHAR }
312 WHERE FLIGHTNO = #{flightno,jdbcType=VARCHAR} 313 WHERE FLIGHTNO = #{flightno,jdbcType=VARCHAR}
313 AND 314 AND
314 FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP} 315 FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP}
315 AND 316 AND
316 WAYBILLNOMASTER = #{waybillnomaster,jdbcType=VARCHAR} 317 WAYBILLNOMASTER = #{waybillnomaster,jdbcType=VARCHAR}
  318 + AND
  319 + CARRIER = #{carrier,jdbcType=VARCHAR}
317 </update> 320 </update>
318 321
319 <select id="selectAutoIdByAwb" parameterType="com.tianbo.analysis.model.PREPAREMASTER" resultType="com.tianbo.analysis.model.PREPAREMASTER"> 322 <select id="selectAutoIdByAwb" parameterType="com.tianbo.analysis.model.PREPAREMASTER" resultType="com.tianbo.analysis.model.PREPAREMASTER">
@@ -263,8 +263,11 @@ @@ -263,8 +263,11 @@
263 263
264 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.Originmanifestsecondary" > 264 <update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.Originmanifestsecondary" >
265 UPDATE ORIGINMANIFESTSECONDARY 265 UPDATE ORIGINMANIFESTSECONDARY
266 - SET RECEIPTION= #{receiption,jdbcType=VARCHAR}  
267 - WHERE WAYBILLNOMASTER = #{waybillnomaster,jdbcType=VARCHAR} 266 + SET
  267 + RECEIPTION= #{receiption,jdbcType=VARCHAR},
  268 + STATUS=#{status,jdbcType=VARCHAR }
  269 + WHERE
  270 + WAYBILLNOMASTER = #{waybillnomaster,jdbcType=VARCHAR}
268 AND WAYBILLNOSECONDARY = #{waybillnosecondary,jdbcType=VARCHAR} 271 AND WAYBILLNOSECONDARY = #{waybillnosecondary,jdbcType=VARCHAR}
269 </update> 272 </update>
270 273