TALLYMASTERServiceImp.java
5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.tianbo.analysis.service.imp;
import com.tianbo.analysis.dao.TALLYMASTERMapper;
import com.tianbo.analysis.dao.TALLYSECONDARYMapper;
import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.model.TALLYMASTER;
import com.tianbo.analysis.model.TALLYSECONDARY;
import com.tianbo.analysis.service.TALLYMASTERService;
import com.tianbo.util.Date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @Auther: shenhl
* @Date: 2019/8/23 17:17
*/
@Service
@Slf4j
public class TALLYMASTERServiceImp implements TALLYMASTERService{
@Autowired
TALLYMASTERMapper tallymasterMapper;
@Autowired
TALLYSECONDARYMapper tallysecondaryMapper;
@Override
// 进出港理货
public int insertRecept(CustomReception customReception, String mt) {
ShareServiceImp shareServiceImp = new ShareServiceImp();
// 发送日志 插入
CoustomAnalysisServiceImp coustomAnalysisServiceImp = new CoustomAnalysisServiceImp();
// 主单号
String awbA = customReception.getWayBillMaster();
String awbH = customReception.getWayBillSecond();
//回执内容
String reception = customReception.getResponseText();
String flightDateStr = customReception.getFlightDate();
if (!StringUtils.isEmpty(flightDateStr)) {
Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
// 设置 进出港理货 回执
TALLYSECONDARY tallysecondary = new TALLYSECONDARY();
tallysecondary.setReceiptinformation(reception);
//设置进出港理货回执、航班号、航班日期
TALLYMASTER tallymaster = new TALLYMASTER();
tallymaster.setReceiptinformation(reception);
tallymaster.setFlightno(customReception.getFlightNo());
tallymaster.setFlightdate(flightDate);
// 判断航班号 航班日期 是否为空
if (flightDate != null && customReception.getFlightNo() != null){
if (awbA!=null && awbA.length()>0){
StringBuffer stringBuffer = new StringBuffer(awbA);
stringBuffer.insert(3,"-");
awbA = stringBuffer.toString();
//设置主分单的 主单号
tallysecondary.setWaybillnomaster(awbA);
tallymaster.setWaybillnomaster(awbA);
}
//有分单号 更新分单
if(awbA!=null && awbA.length()>0 && awbH!=null && awbH.length()> 0){
//取分单号
String[] awbhArr = awbH.split("_");
String awbh = awbhArr[1];
tallysecondary.setWaybillnosecondary(awbh);
//更新分单回执
int i = tallysecondaryMapper.updateRECEIPTION(tallysecondary);
//获取分单autoid
List<TALLYSECONDARY> tallysecondaryList = tallysecondaryMapper.selectAutoIdByawbAawbH(tallysecondary);
if(!tallysecondaryList.isEmpty()){
TALLYSECONDARY arrivedSecond = tallysecondaryList.get(0);
String autoId = arrivedSecond.getAutoid();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);
int ii = coustomAnalysisServiceImp.insertSendlog(mt,reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0 && iii > 0){
return 1;
}
}
return 0;
}
//处理主单格式,将海关回执的主单号58019316861,变为580-19316861
if (awbA!=null && awbA.length()>0){
//更新主单回执
int i = tallymasterMapper.updateRECEIPTION(tallymaster);
//获取分单autoid
List<TALLYMASTER> arrivedmasterList = tallymasterMapper.selectAutoIdByAwb(tallymaster);
if(!arrivedmasterList.isEmpty()){
TALLYMASTER originMaster = arrivedmasterList.get(0);
String autoId = originMaster.getAutoid();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
int ii =coustomAnalysisServiceImp.insertSendlog(mt,reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0 && iii > 0){
return 1;
}
}
return 0;
}
}else {
return shareServiceImp.share("MT5202", customReception);
}
}
//未进入主分单解析 返回0 失败
return 0;
}
}