...
|
...
|
@@ -5,6 +5,7 @@ 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.NmmsBaseService;
|
|
|
import com.tianbo.analysis.service.TALLYMASTERService;
|
|
|
import com.tianbo.util.Date.DateUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
...
|
...
|
@@ -16,13 +17,14 @@ import java.util.Date; |
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 进出港理货回执解析入库
|
|
|
* @Auther: shenhl
|
|
|
* @Date: 2019/8/23 17:17
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class TALLYMASTERServiceImp implements TALLYMASTERService{
|
|
|
public class TALLYMASTERServiceImp extends NmmsBaseService implements TALLYMASTERService{
|
|
|
|
|
|
@Autowired
|
|
|
TALLYMASTERMapper tallymasterMapper;
|
...
|
...
|
@@ -30,48 +32,84 @@ public class TALLYMASTERServiceImp implements TALLYMASTERService{ |
|
|
@Autowired
|
|
|
TALLYSECONDARYMapper tallysecondaryMapper;
|
|
|
|
|
|
private Date flightDate;
|
|
|
|
|
|
@Override
|
|
|
// 进出港理货
|
|
|
public int insertRecept(CustomReception customReception, String mt) {
|
|
|
public int insertRecept(CustomReception customReception) {
|
|
|
super.insertRecept(customReception);
|
|
|
|
|
|
if (!StringUtils.isEmpty(flightDateStr)) {
|
|
|
flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
|
|
|
|
|
|
ShareServiceImp shareServiceImp = new ShareServiceImp();
|
|
|
// 判断航班号 航班日期 是否为空
|
|
|
if (flightDate != null && customReception.getFlightNo() != null){
|
|
|
|
|
|
// 发送日志 插入
|
|
|
CoustomAnalysisServiceImp coustomAnalysisServiceImp = new CoustomAnalysisServiceImp();
|
|
|
//有分单号 更新分单
|
|
|
if(!StringUtils.isEmpty(awbH)){
|
|
|
second();
|
|
|
}
|
|
|
|
|
|
// 主单号
|
|
|
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);
|
|
|
if (!StringUtils.isEmpty(awbA)){
|
|
|
master();
|
|
|
}
|
|
|
}else {
|
|
|
|
|
|
return shareServiceImp.share(customReception.getMessageType(), customReception);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//未进入主分单解析 返回0 失败
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 入库主单回执信息
|
|
|
* @return 成功返回1,失败返回0。
|
|
|
*/
|
|
|
public int master(){
|
|
|
String mt = customReception.getMessageType();
|
|
|
//设置进出港理货回执、航班号、航班日期
|
|
|
TALLYMASTER tallymaster = new TALLYMASTER();
|
|
|
tallymaster.setWaybillnomaster(awbA);
|
|
|
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();
|
|
|
tallymaster.setTalltype(mt);
|
|
|
tallymaster.setStatus(nmsStatusCode);
|
|
|
//更新主单回执
|
|
|
int i = tallymasterMapper.updateRECEIPTION(tallymaster);
|
|
|
//获取主单autoid
|
|
|
List<TALLYMASTER> arrivedmasterList = tallymasterMapper.selectAutoIdByAwb(tallymaster);
|
|
|
if(!arrivedmasterList.isEmpty()){
|
|
|
TALLYMASTER originMaster = arrivedmasterList.get(0);
|
|
|
String autoId = originMaster.getAutoid();
|
|
|
|
|
|
//设置主分单的 主单号
|
|
|
tallysecondary.setWaybillnomaster(awbA);
|
|
|
tallymaster.setWaybillnomaster(awbA);
|
|
|
int ii =coustomAnalysisServiceImp.insertSendlog(mt,reception,autoId);
|
|
|
|
|
|
int iii = shareServiceImp.updateMessages(customReception);
|
|
|
if (i>0 && ii>0 ){
|
|
|
log.info("运单号 {} 理货回执更新成功",awbA);
|
|
|
return 1;
|
|
|
}
|
|
|
if (iii > 0){
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
//有分单号 更新分单
|
|
|
if(awbA!=null && awbA.length()>0 && awbH!=null && awbH.length()> 0){
|
|
|
/**
|
|
|
* 入库分单回执信息
|
|
|
* @return
|
|
|
*/
|
|
|
public int second(){
|
|
|
TALLYSECONDARY tallysecondary = new TALLYSECONDARY();
|
|
|
tallysecondary.setReceiptinformation(reception);
|
|
|
tallysecondary.setStatus(nmsStatusCode);
|
|
|
//设置主分单的 主单号
|
|
|
tallysecondary.setWaybillnomaster(awbA);
|
|
|
//取分单号
|
|
|
String[] awbhArr = awbH.split("_");
|
|
|
String awbh = awbhArr[1];
|
...
|
...
|
@@ -80,49 +118,25 @@ public class TALLYMASTERServiceImp implements TALLYMASTERService{ |
|
|
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);
|
|
|
log.info("即将插入理货分单回执,运单号为:{},autoid:{}",awbH,autoId);
|
|
|
int ii = coustomAnalysisServiceImp.insertSendlog(customReception.getMessageType(),reception,autoId);
|
|
|
|
|
|
//通过messageid适配发送日志表并更新
|
|
|
int iii = shareServiceImp.updateMessages(customReception);
|
|
|
if (i>0 && ii>0 && iii > 0){
|
|
|
if (i>0 && ii>0){
|
|
|
log.info("运单号 {} 理货回执更新成功",awbH);
|
|
|
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){
|
|
|
if (iii > 0){
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
}else {
|
|
|
|
|
|
return shareServiceImp.share("MT5202", customReception);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//未进入主分单解析 返回0 失败
|
|
|
return 0;
|
|
|
}
|
|
|
} |
...
|
...
|
|