作者 朱兆平

优化合并

... ... @@ -4,8 +4,13 @@ import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.service.imp.CoustomAnalysisServiceImp;
import com.tianbo.analysis.service.imp.ShareServiceImp;
import com.tianbo.analysis.tools.AWBTools;
import com.tianbo.util.Date.DateUtil;
import org.apache.commons.lang.StringUtils;
import java.util.Date;
public class NmmsBaseService {
public ShareServiceImp shareServiceImp;
public CoustomAnalysisServiceImp coustomAnalysisServiceImp;
public String awbA ;
... ... @@ -15,6 +20,7 @@ public class NmmsBaseService {
public String reception;
public String flightDateStr;
public CustomReception customReception;
public Date flightDate;
public int insertRecept(CustomReception customReception){
this.shareServiceImp = new ShareServiceImp();
... ... @@ -30,7 +36,43 @@ public class NmmsBaseService {
this.reception = customReception.getResponseText();
this.flightDateStr = customReception.getFlightDate();
if (!StringUtils.isEmpty(flightDateStr)) {
this.flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
// 判断航班号 航班日期 是否为空
if (flightDate != null && customReception.getFlightNo() != null){
//有分单号 更新分单回执
if(!StringUtils.isEmpty(awbH)){
return second();
}
if (!StringUtils.isEmpty(awbA)){
return master();
}
}else {
//从发送日志表查找发送MESSAGEID进行二次入库
return shareServiceImp.share(customReception.getMessageType(), customReception);
}
}
//未进入主分单解析 返回0 失败
return 0;
}
/**
* 入库分单回执信息
* @return 成功返回1,失败返回0。
*/
public int second() {
return 0;
}
/**
* 入库分单回执信息
* @return 成功返回1,失败返回0。
*/
public int master() {
return 0;
}
}
... ...
... ... @@ -2,9 +2,7 @@ package com.tianbo.analysis.service.imp;
import com.tianbo.analysis.dao.ARRIVEDMASTERMapper;
import com.tianbo.analysis.dao.ARRIVEDSECONDARYMapper;
import com.tianbo.analysis.model.ARRIVEDMASTER;
import com.tianbo.analysis.model.ARRIVEDSECONDARY;
import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.model.*;
import com.tianbo.analysis.service.ARRIVEDMASTERService;
import com.tianbo.analysis.service.NmmsBaseService;
import com.tianbo.analysis.tools.AWBTools;
... ... @@ -37,95 +35,88 @@ public class ARRIVEDMASTERServiceImp extends NmmsBaseService implements ARRIVEDM
// 货物接收运抵主分单
public int insertRecept(CustomReception customReception) {
if (!StringUtils.isEmpty(flightDateStr)) {
Date flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
// 设置 接收运抵分单 回执
ARRIVEDSECONDARY arrivedsecondary = new ARRIVEDSECONDARY();
arrivedsecondary.setReceiption(reception);
//设置主单回执、航班号、航班日期
ARRIVEDMASTER arrivedmaster = new ARRIVEDMASTER();
arrivedmaster.setReceiptinformation(reception);
//拆分航班号和承运人
String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());
arrivedmaster.setFlightno(flightInfo[1]);
arrivedmaster.setCarrier(flightInfo[0]);
arrivedmaster.setFlightDate(flightDate);
// 判断航班号 航班日期 是否为空
if (flightDate != null && customReception.getFlightNo() != null){
//处理主单格式,将海关回执的主单号58019316861,变为580-19316861
awbA = AWBTools.awbFormat(awbA);
//设置主分单的 主单号
arrivedsecondary.setWaybillnomaster(awbA);
arrivedmaster.setWaybillnomaster(awbA);
//有分单号 更新分单回执
if(awbA!=null && !awbA.isEmpty() && awbH!=null && !awbH.isEmpty()){
//取分单号
String[] awbhArr = awbH.split("_");
String awbh = awbhArr[1];
arrivedsecondary.setWaybillnosecondary(awbh);
//更新分单回执
int i = arrivedsecondaryMapper.updateRECEIPTION(arrivedsecondary);
//获取分单autoid
List<ARRIVEDSECONDARY> arrivedsecondaryList = arrivedsecondaryMapper.selectAutoIdByawbAawbH(arrivedsecondary);
if(!arrivedsecondaryList.isEmpty()){
ARRIVEDSECONDARY arrivedSecond = arrivedsecondaryList.get(0);
String autoId = arrivedSecond.getAutoid();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);
int ii = coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0 ){
return 1;
}
if ( iii > 0){
return 1;
}
}
return 0;
}
if (awbA!=null && awbA.length()>0){
//更新主单回执
int i = arrivedmasterMapper.updateRECEIPTION(arrivedmaster);
//获取分单autoid
List<ARRIVEDMASTER> arrivedmasterList = arrivedmasterMapper.selectAutoIdByAwb(arrivedmaster);
if(!arrivedmasterList.isEmpty()){
ARRIVEDMASTER originMaster = arrivedmasterList.get(0);
String autoId = originMaster.getAutoid();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
int ii =coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0){
return 1;
}
if ( iii > 0){
return 1;
}
}
return 0;
}
}else {
//从发送日志表查找发送MESSAGEID进行二次入库
return shareServiceImp.share("MT3201", customReception);
return super.insertRecept(customReception);
}
/**
* 入库主单回执信息
* @return 成功返回1,失败返回0。
*/
@Override
public int master(){
//设置主单回执、航班号、航班日期
ARRIVEDMASTER arrivedmaster = new ARRIVEDMASTER();
arrivedmaster.setReceiptinformation(reception);
arrivedmaster.setWaybillnomaster(awbA);
//拆分航班号和承运人
String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());
arrivedmaster.setFlightno(flightInfo[1]);
arrivedmaster.setCarrier(flightInfo[0]);
arrivedmaster.setFlightDate(flightDate);
//更新主单回执
int i = arrivedmasterMapper.updateRECEIPTION(arrivedmaster);
//获取分单autoid
List<ARRIVEDMASTER> arrivedmasterList = arrivedmasterMapper.selectAutoIdByAwb(arrivedmaster);
if(!arrivedmasterList.isEmpty()){
ARRIVEDMASTER originMaster = arrivedmasterList.get(0);
String autoId = originMaster.getAutoid();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
int ii =coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0){
log.info("运单号 {} 理货回执更新成功",awbA);
return 1;
}
if ( iii > 0){
return 1;
}
}
//未进入主分单解析 返回0 失败
}
return 0;
}
/**
* 入库分单回执信息
* @return 成功返回1,失败返回0。
*/
@Override
public int second(){
// 设置 接收运抵分单 回执
ARRIVEDSECONDARY arrivedsecondary = new ARRIVEDSECONDARY();
arrivedsecondary.setReceiption(reception);
//设置主分单的 主单号
arrivedsecondary.setWaybillnomaster(awbA);
//取分单号
String[] awbhArr = awbH.split("_");
String awbh = awbhArr[1];
arrivedsecondary.setWaybillnosecondary(awbh);
//更新分单回执
int i = arrivedsecondaryMapper.updateRECEIPTION(arrivedsecondary);
//获取分单autoid
List<ARRIVEDSECONDARY> arrivedsecondaryList = arrivedsecondaryMapper.selectAutoIdByawbAawbH(arrivedsecondary);
if(!arrivedsecondaryList.isEmpty()){
ARRIVEDSECONDARY arrivedSecond = arrivedsecondaryList.get(0);
String autoId = arrivedSecond.getAutoid();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbH+"->autoid="+autoId);
int ii = coustomAnalysisServiceImp.insertSendlog("MT3201",reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0 ){
log.info("运单号 {} 理货回执更新成功",awbA);
return 1;
}
if ( iii > 0){
return 1;
}
}
return 0;
}
}
... ...
... ... @@ -32,42 +32,17 @@ public class TALLYMASTERServiceImp extends NmmsBaseService implements TALLYMASTE
@Autowired
TALLYSECONDARYMapper tallysecondaryMapper;
private Date flightDate;
@Override
// 进出港理货
public int insertRecept(CustomReception customReception) {
super.insertRecept(customReception);
if (!StringUtils.isEmpty(flightDateStr)) {
flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
// 判断航班号 航班日期 是否为空
if (flightDate != null && customReception.getFlightNo() != null){
//有分单号 更新分单
if(!StringUtils.isEmpty(awbH)){
second();
}
if (!StringUtils.isEmpty(awbA)){
master();
}
}else {
return shareServiceImp.share(customReception.getMessageType(), customReception);
}
}
//未进入主分单解析 返回0 失败
return 0;
return super.insertRecept(customReception);
}
/**
* 入库主单回执信息
* @return 成功返回1,失败返回0。
*/
@Override
public int master(){
String mt = customReception.getMessageType();
//设置进出港理货回执、航班号、航班日期
... ... @@ -102,8 +77,9 @@ public class TALLYMASTERServiceImp extends NmmsBaseService implements TALLYMASTE
/**
* 入库分单回执信息
* @return
* @return 成功返回1,失败返回0。
*/
@Override
public int second(){
TALLYSECONDARY tallysecondary = new TALLYSECONDARY();
tallysecondary.setReceiptinformation(reception);
... ...