作者 朱兆平

装载回执完成,MAPPER优化

... ... @@ -5,10 +5,12 @@ 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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.util.Date;
@Slf4j
public class NmmsBaseService {
public ShareServiceImp shareServiceImp;
... ... @@ -36,7 +38,7 @@ public class NmmsBaseService {
this.reception = customReception.getResponseText();
this.flightDateStr = customReception.getFlightDate();
log.info("开始解析:运单号 {} 回执类型:{} ",awbA,customReception.getMessageType());
if (!StringUtils.isEmpty(flightDateStr)) {
this.flightDate = DateUtil.formatByyyyyMMdd(flightDateStr);
... ...
... ... @@ -55,6 +55,7 @@ public class ARRIVEDMASTERServiceImp extends NmmsBaseService implements ARRIVEDM
arrivedmaster.setFlightno(flightInfo[1]);
arrivedmaster.setCarrier(flightInfo[0]);
arrivedmaster.setFlightDate(flightDate);
arrivedmaster.setStatus(nmsStatusCode);
//更新主单回执
int i = arrivedmasterMapper.updateRECEIPTION(arrivedmaster);
//获取分单autoid
... ... @@ -70,7 +71,7 @@ public class ARRIVEDMASTERServiceImp extends NmmsBaseService implements ARRIVEDM
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0){
log.info("运单号 {} 理货回执更新成功",awbA);
log.info("运单号 {} 运抵回执更新成功",awbA);
return 1;
}
if ( iii > 0){
... ... @@ -96,6 +97,7 @@ public class ARRIVEDMASTERServiceImp extends NmmsBaseService implements ARRIVEDM
String[] awbhArr = awbH.split("_");
String awbh = awbhArr[1];
arrivedsecondary.setWaybillnosecondary(awbh);
arrivedsecondary.setStatus(nmsStatusCode);
//更新分单回执
int i = arrivedsecondaryMapper.updateRECEIPTION(arrivedsecondary);
//获取分单autoid
... ... @@ -109,7 +111,7 @@ public class ARRIVEDMASTERServiceImp extends NmmsBaseService implements ARRIVEDM
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0 ){
log.info("运单号 {} 理货回执更新成功",awbA);
log.info("运单号 {} 运抵回执更新成功",awbA);
return 1;
}
if ( iii > 0){
... ...
... ... @@ -4,6 +4,7 @@ import com.tianbo.analysis.dao.DEPARTURESLOADINGMapper;
import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.model.DEPARTURESLOADING;
import com.tianbo.analysis.service.DEPARTURESLOADINGService;
import com.tianbo.analysis.service.NmmsBaseService;
import com.tianbo.util.Date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
... ... @@ -19,74 +20,52 @@ import java.util.List;
*/
@Service
@Slf4j
public class DEPARTURESLOADINGServiceImp implements DEPARTURESLOADINGService{
public class DEPARTURESLOADINGServiceImp extends NmmsBaseService implements DEPARTURESLOADINGService{
@Autowired
DEPARTURESLOADINGMapper departuresloadingMapper;
@Override
public int insertRecept(CustomReception customReception) {
return super.insertRecept(customReception);
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);
//设置主单回执、航班号、航班日期
DEPARTURESLOADING departuresloading = new DEPARTURESLOADING();
departuresloading.setReceiption(reception);
departuresloading.setFlightno(customReception.getFlightNo());
departuresloading.setFlightdate(flightDate);
if (awbA!=null && awbA.length()>0){
StringBuffer stringBuffer = new StringBuffer(awbA);
stringBuffer.insert(3,"-");
awbA = stringBuffer.toString();
}
//设置主分单的 主单号
departuresloading.setWaybillno(awbA);
/**
* 入库分单回执信息
* @return 成功返回1,失败返回0。
*/
@Override
public int master() {
//设置主单回执、航班号、航班日期
DEPARTURESLOADING departuresloading = new DEPARTURESLOADING();
departuresloading.setReceiption(reception);
departuresloading.setFlightno(customReception.getFlightNo());
departuresloading.setFlightdate(flightDate);
departuresloading.setStatus(nmsStatusCode);
//设置主分单的 主单号
departuresloading.setWaybillno(awbA);
//更新主单回执
int i = departuresloadingMapper.updateRECEIPTION(departuresloading);
//获取分单autoid
List<DEPARTURESLOADING> arrivedmasterList = departuresloadingMapper.selectAutoIdByAwb(departuresloading);
if(!arrivedmasterList.isEmpty()){
DEPARTURESLOADING departuresloading1 = arrivedmasterList.get(0);
String autoId = departuresloading1.getId();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
int ii =coustomAnalysisServiceImp.insertSendlog("MT4201",reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0){
log.info("运单号 {} 装载回执更新成功",awbA);
return 1;
}
// 判断航班号 航班日期 是否为空
if (flightDate != null && customReception.getFlightNo() != null){
//处理主单格式,将海关回执的主单号58019316861,变为580-19316861
if (awbA!=null && awbA.length()>0){
//更新主单回执
int i = departuresloadingMapper.updateRECEIPTION(departuresloading);
//获取分单autoid
List<DEPARTURESLOADING> arrivedmasterList = departuresloadingMapper.selectAutoIdByAwb(departuresloading);
if(!arrivedmasterList.isEmpty()){
DEPARTURESLOADING departuresloading1 = arrivedmasterList.get(0);
String autoId = departuresloading1.getId();
//插入sendlog记录表
log.info("即将插入日志运单号为:"+awbA+"->autoid="+autoId);
int ii =coustomAnalysisServiceImp.insertSendlog("MT4201",reception,autoId);
int iii = shareServiceImp.updateMessages(customReception);
if (i>0 && ii>0 && iii > 0){
return 1;
}
}
return 0;
}
}else {
return shareServiceImp.share("MT4201", customReception);
if (iii > 0){
return 1;
}
}
//未进入主分单解析 返回0 失败
return 0;
}
}
... ...
... ... @@ -11,7 +11,7 @@ public class AWBTools {
awbNo = stringBuffer.toString();
return awbNo;
}
return null;
return "";
}
public static String[] splitFlight(String flightNo){
... ...
... ... @@ -6,7 +6,7 @@
<result column="CREATEDATE" property="createdate" jdbcType="TIMESTAMP" />
<result column="WAYBILLNO" property="waybillno" jdbcType="VARCHAR" />
<result column="FLIGHTNO" property="flightno" jdbcType="VARCHAR" />
<result column="FLIGHTDATE" property="flightdate" jdbcType="TIMESTAMP" />
<result column="FLIGHTDATE" property="flightdate" jdbcType="DATE" />
<result column="ORIGINATINGSTATION" property="originatingstation" jdbcType="VARCHAR" />
<result column="DESTINATIONSTATION" property="destinationstation" jdbcType="VARCHAR" />
<result column="STOWAGEPIECES" property="stowagepieces" jdbcType="VARCHAR" />
... ... @@ -147,21 +147,21 @@
<update id="updateRECEIPTION" parameterType="com.tianbo.analysis.model.DEPARTURESLOADING" >
UPDATE DEPARTURESLOADING
SET RECEIPTINO= #{receiptino,jdbcType=VARCHAR}
SET RECEIPTION= #{receiption,jdbcType=VARCHAR},STATUS = #{status,jdbcType=VARCHAR}
WHERE FLIGHTNO = #{flightno,jdbcType=VARCHAR}
AND
FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP}
FLIGHTDATE= #{flightdate,jdbcType=DATE}
AND
WAYBILLNO = #{waybillno,jdbcType=VARCHAR}
</update>
<select id="selectAutoIdByAwb" parameterType="com.tianbo.analysis.model.DEPARTURESLOADING" resultType="com.tianbo.analysis.model.DEPARTURESLOADING">
SELECT AUTOID
SELECT ID
FROM DEPARTURESLOADING
WHERE
FLIGHTNO= #{flightno,jdbcType=VARCHAR}
AND
FLIGHTDATE= #{flightDate,jdbcType=TIMESTAMP}
FLIGHTDATE= #{flightdate,jdbcType=DATE}
AND
WAYBILLNO = #{waybillno,jdbcType=VARCHAR}
</select>
... ...
... ... @@ -8,7 +8,7 @@
<result column="TCD_TYPECODE" property="tcdTypecode" jdbcType="VARCHAR" />
<result column="TALLTYPE" property="talltype" jdbcType="VARCHAR" />
<result column="FLIGHTNO" property="flightno" jdbcType="VARCHAR" />
<result column="FLIGHTDATE" property="flightdate" jdbcType="TIMESTAMP" />
<result column="FLIGHTDATE" property="flightdate" jdbcType="DATE" />
<result column="SEGMENT" property="segment" jdbcType="VARCHAR" />
<result column="ORIGINATINGSTATION" property="originatingstation" jdbcType="VARCHAR" />
<result column="O_NAME" property="oName" jdbcType="VARCHAR" />
... ...