作者 朱兆平

优化合并

@@ -4,8 +4,13 @@ import com.tianbo.analysis.model.CustomReception; @@ -4,8 +4,13 @@ import com.tianbo.analysis.model.CustomReception;
4 import com.tianbo.analysis.service.imp.CoustomAnalysisServiceImp; 4 import com.tianbo.analysis.service.imp.CoustomAnalysisServiceImp;
5 import com.tianbo.analysis.service.imp.ShareServiceImp; 5 import com.tianbo.analysis.service.imp.ShareServiceImp;
6 import com.tianbo.analysis.tools.AWBTools; 6 import com.tianbo.analysis.tools.AWBTools;
  7 +import com.tianbo.util.Date.DateUtil;
  8 +import org.apache.commons.lang.StringUtils;
  9 +
  10 +import java.util.Date;
7 11
8 public class NmmsBaseService { 12 public class NmmsBaseService {
  13 +
9 public ShareServiceImp shareServiceImp; 14 public ShareServiceImp shareServiceImp;
10 public CoustomAnalysisServiceImp coustomAnalysisServiceImp; 15 public CoustomAnalysisServiceImp coustomAnalysisServiceImp;
11 public String awbA ; 16 public String awbA ;
@@ -15,6 +20,7 @@ public class NmmsBaseService { @@ -15,6 +20,7 @@ public class NmmsBaseService {
15 public String reception; 20 public String reception;
16 public String flightDateStr; 21 public String flightDateStr;
17 public CustomReception customReception; 22 public CustomReception customReception;
  23 + public Date flightDate;
18 24
19 public int insertRecept(CustomReception customReception){ 25 public int insertRecept(CustomReception customReception){
20 this.shareServiceImp = new ShareServiceImp(); 26 this.shareServiceImp = new ShareServiceImp();
@@ -30,7 +36,43 @@ public class NmmsBaseService { @@ -30,7 +36,43 @@ public class NmmsBaseService {
30 36
31 this.reception = customReception.getResponseText(); 37 this.reception = customReception.getResponseText();
32 this.flightDateStr = customReception.getFlightDate(); 38 this.flightDateStr = customReception.getFlightDate();
  39 +
  40 + if (!StringUtils.isEmpty(flightDateStr)) {
  41 + this.flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
  42 +
  43 + // 判断航班号 航班日期 是否为空
  44 + if (flightDate != null && customReception.getFlightNo() != null){
  45 + //有分单号 更新分单回执
  46 + if(!StringUtils.isEmpty(awbH)){
  47 + return second();
  48 + }
  49 +
  50 + if (!StringUtils.isEmpty(awbA)){
  51 + return master();
  52 + }
  53 + }else {
  54 + //从发送日志表查找发送MESSAGEID进行二次入库
  55 + return shareServiceImp.share(customReception.getMessageType(), customReception);
  56 + }
  57 + }
  58 + //未进入主分单解析 返回0 失败
33 return 0; 59 return 0;
34 60
35 } 61 }
  62 +
  63 + /**
  64 + * 入库分单回执信息
  65 + * @return 成功返回1,失败返回0。
  66 + */
  67 + public int second() {
  68 + return 0;
  69 + }
  70 +
  71 + /**
  72 + * 入库分单回执信息
  73 + * @return 成功返回1,失败返回0。
  74 + */
  75 + public int master() {
  76 + return 0;
  77 + }
36 } 78 }
@@ -2,9 +2,7 @@ package com.tianbo.analysis.service.imp; @@ -2,9 +2,7 @@ package com.tianbo.analysis.service.imp;
2 2
3 import com.tianbo.analysis.dao.ARRIVEDMASTERMapper; 3 import com.tianbo.analysis.dao.ARRIVEDMASTERMapper;
4 import com.tianbo.analysis.dao.ARRIVEDSECONDARYMapper; 4 import com.tianbo.analysis.dao.ARRIVEDSECONDARYMapper;
5 -import com.tianbo.analysis.model.ARRIVEDMASTER;  
6 -import com.tianbo.analysis.model.ARRIVEDSECONDARY;  
7 -import com.tianbo.analysis.model.CustomReception; 5 +import com.tianbo.analysis.model.*;
8 import com.tianbo.analysis.service.ARRIVEDMASTERService; 6 import com.tianbo.analysis.service.ARRIVEDMASTERService;
9 import com.tianbo.analysis.service.NmmsBaseService; 7 import com.tianbo.analysis.service.NmmsBaseService;
10 import com.tianbo.analysis.tools.AWBTools; 8 import com.tianbo.analysis.tools.AWBTools;
@@ -37,95 +35,88 @@ public class ARRIVEDMASTERServiceImp extends NmmsBaseService implements ARRIVEDM @@ -37,95 +35,88 @@ public class ARRIVEDMASTERServiceImp extends NmmsBaseService implements ARRIVEDM
37 // 货物接收运抵主分单 35 // 货物接收运抵主分单
38 public int insertRecept(CustomReception customReception) { 36 public int insertRecept(CustomReception customReception) {
39 37
40 - if (!StringUtils.isEmpty(flightDateStr)) {  
41 - Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);  
42 -  
43 - // 设置 接收运抵分单 回执  
44 - ARRIVEDSECONDARY arrivedsecondary = new ARRIVEDSECONDARY();  
45 - arrivedsecondary.setReceiption(reception);  
46 -  
47 - //设置主单回执、航班号、航班日期  
48 - ARRIVEDMASTER arrivedmaster = new ARRIVEDMASTER();  
49 - arrivedmaster.setReceiptinformation(reception);  
50 - //拆分航班号和承运人  
51 - String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());  
52 - arrivedmaster.setFlightno(flightInfo[1]);  
53 - arrivedmaster.setCarrier(flightInfo[0]);  
54 - arrivedmaster.setFlightDate(flightDate);  
55 -  
56 - // 判断航班号 航班日期 是否为空  
57 - if (flightDate != null && customReception.getFlightNo() != null){  
58 - //处理主单格式,将海关回执的主单号58019316861,变为580-19316861  
59 - awbA = AWBTools.awbFormat(awbA);  
60 -  
61 - //设置主分单的 主单号  
62 - arrivedsecondary.setWaybillnomaster(awbA);  
63 - arrivedmaster.setWaybillnomaster(awbA);  
64 -  
65 -  
66 - //有分单号 更新分单回执  
67 - if(awbA!=null && !awbA.isEmpty() && awbH!=null && !awbH.isEmpty()){  
68 - //取分单号  
69 - String[] awbhArr = awbH.split("_");  
70 - String awbh = awbhArr[1];  
71 - arrivedsecondary.setWaybillnosecondary(awbh);  
72 - //更新分单回执  
73 - int i = arrivedsecondaryMapper.updateRECEIPTION(arrivedsecondary);  
74 - //获取分单autoid  
75 - List<ARRIVEDSECONDARY> arrivedsecondaryList = arrivedsecondaryMapper.selectAutoIdByawbAawbH(arrivedsecondary);  
76 - if(!arrivedsecondaryList.isEmpty()){  
77 - ARRIVEDSECONDARY arrivedSecond = arrivedsecondaryList.get(0);  
78 - String autoId = arrivedSecond.getAutoid();  
79 - //插入sendlog记录表  
80 - log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);  
81 - int ii = coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);  
82 -  
83 - int iii = shareServiceImp.updateMessages(customReception);  
84 - if (i>0 && ii>0 ){  
85 - return 1;  
86 - }  
87 - if ( iii > 0){  
88 - return 1;  
89 - }  
90 - }  
91 - return 0;  
92 - }  
93 -  
94 -  
95 - if (awbA!=null && awbA.length()>0){  
96 - //更新主单回执  
97 - int i = arrivedmasterMapper.updateRECEIPTION(arrivedmaster);  
98 - //获取分单autoid  
99 - List<ARRIVEDMASTER> arrivedmasterList = arrivedmasterMapper.selectAutoIdByAwb(arrivedmaster);  
100 - if(!arrivedmasterList.isEmpty()){  
101 - ARRIVEDMASTER originMaster = arrivedmasterList.get(0);  
102 - String autoId = originMaster.getAutoid();  
103 -  
104 - //插入sendlog记录表  
105 - log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);  
106 - int ii =coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);  
107 -  
108 - int iii = shareServiceImp.updateMessages(customReception);  
109 -  
110 - if (i>0 && ii>0){  
111 - return 1;  
112 - }  
113 - if ( iii > 0){  
114 - return 1;  
115 - }  
116 -  
117 - }  
118 - return 0;  
119 - }  
120 - }else {  
121 - //从发送日志表查找发送MESSAGEID进行二次入库  
122 - return shareServiceImp.share("MT3201", customReception); 38 + return super.insertRecept(customReception);
  39 +
  40 + }
  41 +
  42 +
  43 + /**
  44 + * 入库主单回执信息
  45 + * @return 成功返回1,失败返回0。
  46 + */
  47 + @Override
  48 + public int master(){
  49 + //设置主单回执、航班号、航班日期
  50 + ARRIVEDMASTER arrivedmaster = new ARRIVEDMASTER();
  51 + arrivedmaster.setReceiptinformation(reception);
  52 + arrivedmaster.setWaybillnomaster(awbA);
  53 + //拆分航班号和承运人
  54 + String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());
  55 + arrivedmaster.setFlightno(flightInfo[1]);
  56 + arrivedmaster.setCarrier(flightInfo[0]);
  57 + arrivedmaster.setFlightDate(flightDate);
  58 + //更新主单回执
  59 + int i = arrivedmasterMapper.updateRECEIPTION(arrivedmaster);
  60 + //获取分单autoid
  61 + List<ARRIVEDMASTER> arrivedmasterList = arrivedmasterMapper.selectAutoIdByAwb(arrivedmaster);
  62 + if(!arrivedmasterList.isEmpty()){
  63 + ARRIVEDMASTER originMaster = arrivedmasterList.get(0);
  64 + String autoId = originMaster.getAutoid();
  65 +
  66 + //插入sendlog记录表
  67 + log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
  68 + int ii =coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);
  69 +
  70 + int iii = shareServiceImp.updateMessages(customReception);
  71 +
  72 + if (i>0 && ii>0){
  73 + log.info("运单号 {} 理货回执更新成功",awbA);
  74 + return 1;
  75 + }
  76 + if ( iii > 0){
  77 + return 1;
123 } 78 }
124 - }  
125 79
126 - //未进入主分单解析 返回0 失败 80 + }
127 return 0; 81 return 0;
128 } 82 }
129 83
  84 + /**
  85 + * 入库分单回执信息
  86 + * @return 成功返回1,失败返回0。
  87 + */
  88 + @Override
  89 + public int second(){
  90 + // 设置 接收运抵分单 回执
  91 + ARRIVEDSECONDARY arrivedsecondary = new ARRIVEDSECONDARY();
  92 + arrivedsecondary.setReceiption(reception);
  93 + //设置主分单的 主单号
  94 + arrivedsecondary.setWaybillnomaster(awbA);
  95 + //取分单号
  96 + String[] awbhArr = awbH.split("_");
  97 + String awbh = awbhArr[1];
  98 + arrivedsecondary.setWaybillnosecondary(awbh);
  99 + //更新分单回执
  100 + int i = arrivedsecondaryMapper.updateRECEIPTION(arrivedsecondary);
  101 + //获取分单autoid
  102 + List<ARRIVEDSECONDARY> arrivedsecondaryList = arrivedsecondaryMapper.selectAutoIdByawbAawbH(arrivedsecondary);
  103 + if(!arrivedsecondaryList.isEmpty()){
  104 + ARRIVEDSECONDARY arrivedSecond = arrivedsecondaryList.get(0);
  105 + String autoId = arrivedSecond.getAutoid();
  106 + //插入sendlog记录表
  107 + log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);
  108 + int ii = coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);
  109 +
  110 + int iii = shareServiceImp.updateMessages(customReception);
  111 + if (i>0 && ii>0 ){
  112 + log.info("运单号 {} 理货回执更新成功",awbA);
  113 + return 1;
  114 + }
  115 + if ( iii > 0){
  116 + return 1;
  117 + }
  118 + }
  119 + return 0;
  120 + }
130 121
131 } 122 }
@@ -32,42 +32,17 @@ public class TALLYMASTERServiceImp extends NmmsBaseService implements TALLYMASTE @@ -32,42 +32,17 @@ public class TALLYMASTERServiceImp extends NmmsBaseService implements TALLYMASTE
32 @Autowired 32 @Autowired
33 TALLYSECONDARYMapper tallysecondaryMapper; 33 TALLYSECONDARYMapper tallysecondaryMapper;
34 34
35 - private Date flightDate;  
36 -  
37 @Override 35 @Override
38 // 进出港理货 36 // 进出港理货
39 public int insertRecept(CustomReception customReception) { 37 public int insertRecept(CustomReception customReception) {
40 - super.insertRecept(customReception);  
41 -  
42 - if (!StringUtils.isEmpty(flightDateStr)) {  
43 - flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);  
44 -  
45 - // 判断航班号 航班日期 是否为空  
46 - if (flightDate != null && customReception.getFlightNo() != null){  
47 -  
48 - //有分单号 更新分单  
49 - if(!StringUtils.isEmpty(awbH)){  
50 - second();  
51 - }  
52 -  
53 -  
54 - if (!StringUtils.isEmpty(awbA)){  
55 - master();  
56 - }  
57 - }else {  
58 -  
59 - return shareServiceImp.share(customReception.getMessageType(), customReception);  
60 - }  
61 - }  
62 -  
63 - //未进入主分单解析 返回0 失败  
64 - return 0; 38 + return super.insertRecept(customReception);
65 } 39 }
66 40
67 /** 41 /**
68 * 入库主单回执信息 42 * 入库主单回执信息
69 * @return 成功返回1,失败返回0。 43 * @return 成功返回1,失败返回0。
70 */ 44 */
  45 + @Override
71 public int master(){ 46 public int master(){
72 String mt = customReception.getMessageType(); 47 String mt = customReception.getMessageType();
73 //设置进出港理货回执、航班号、航班日期 48 //设置进出港理货回执、航班号、航班日期
@@ -102,8 +77,9 @@ public class TALLYMASTERServiceImp extends NmmsBaseService implements TALLYMASTE @@ -102,8 +77,9 @@ public class TALLYMASTERServiceImp extends NmmsBaseService implements TALLYMASTE
102 77
103 /** 78 /**
104 * 入库分单回执信息 79 * 入库分单回执信息
105 - * @return 80 + * @return 成功返回1,失败返回0。
106 */ 81 */
  82 + @Override
107 public int second(){ 83 public int second(){
108 TALLYSECONDARY tallysecondary = new TALLYSECONDARY(); 84 TALLYSECONDARY tallysecondary = new TALLYSECONDARY();
109 tallysecondary.setReceiptinformation(reception); 85 tallysecondary.setReceiptinformation(reception);