|
|
package com.tianbo.analysis.task;
|
|
|
|
|
|
import com.netflix.discovery.converters.Auto;
|
|
|
import com.tianbo.analysis.dao.FWBINFOMapper;
|
|
|
import com.tianbo.analysis.dao.ORIGINMANIFESTMASTERMapper;
|
|
|
import com.tianbo.analysis.dao.OriginmanifestsecondaryMapper;
|
|
|
import com.tianbo.analysis.model.FFMInfo;
|
|
|
import com.tianbo.analysis.model.FWBINFO;
|
|
|
import com.tianbo.analysis.model.ORIGINMANIFESTMASTER;
|
|
|
import com.tianbo.analysis.model.Originmanifestsecondary;
|
|
|
import com.tianbo.analysis.service.FFMInfoService;
|
|
|
import com.tianbo.analysis.service.FWBInfoService;
|
|
|
import com.tianbo.analysis.service.ManifestMasterService;
|
|
|
import com.tianbo.analysis.service.ManifestSecondService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* ffm临时业务表处理入业务库
|
|
|
*
|
|
|
* 舱单 = 航班号+航班日期+运单号
|
|
|
* 运单 = 运单号
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
public class FFMInfoHandle {
|
|
|
|
|
|
@Autowired
|
|
|
FFMInfoService ffmInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
ORIGINMANIFESTMASTERMapper originmanifestmasterMapper;
|
|
|
|
|
|
@Autowired
|
|
|
ManifestMasterService manifestMasterService;
|
...
|
...
|
@@ -38,21 +32,43 @@ public class FFMInfoHandle { |
|
|
@Autowired
|
|
|
FWBInfoService fwbInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
OriginmanifestsecondaryMapper originmanifestsecondaryMapper;
|
|
|
|
|
|
@Autowired
|
|
|
ManifestSecondService secondService;
|
|
|
|
|
|
public boolean dealFFMInfo(){
|
|
|
private static FFMInfoHandle ffmInfoHandle;
|
|
|
|
|
|
//通过@PostConstruct实现初始化bean之前进行的操作,解决service调用空指针问题
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
ffmInfoHandle = this;
|
|
|
ffmInfoHandle.ffmInfoService = this.ffmInfoService;
|
|
|
ffmInfoHandle.manifestMasterService = this.manifestMasterService;
|
|
|
ffmInfoHandle.fwbInfoService = this.fwbInfoService;
|
|
|
ffmInfoHandle.secondService = this.secondService;
|
|
|
// 初使化时将已静态化的testService实例化
|
|
|
}
|
|
|
/**
|
|
|
* 处理板箱非空的舱单数据入业务库
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean dealFFMInfoWithPallet(){
|
|
|
boolean result =false;
|
|
|
try {
|
|
|
//1.处理板箱非空的数据
|
|
|
List<FFMInfo> ffmInfoList = ffmInfoService.getDistinctFlightWithPallet(false);
|
|
|
//1.取航班非空的板箱的运单列表数据,并且报文接收标识last存在。
|
|
|
List<FFMInfo> ffmInfoList = ffmInfoHandle.ffmInfoService.getDistinctFlightWithPallet(false);
|
|
|
if (ffmInfoList!=null && !ffmInfoList.isEmpty()){
|
|
|
for (FFMInfo item_f:ffmInfoList) {
|
|
|
|
|
|
String flightDate = item_f.getFlightdate().toString();
|
|
|
String flghtNo = item_f.getFlightno();
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
log.info(sb.append("开始处理航班:").append(flghtNo).append("/").append(flightDate).toString());
|
|
|
|
|
|
//针对补发报文处理,补发的报文: FFM_INFOB表数据,存储的报文批次01对应标识是LAST
|
|
|
List<FFMInfo> ffmlist_reportorder_1 = ffmInfoService.getFFMLastReportOrderByPallet(item_f,false);
|
|
|
List<FFMInfo> ffmlist_reportorder_1 = ffmInfoHandle.ffmInfoService.getFFMLastReportOrderByPallet(item_f,false);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 判断列表是否为空
|
...
|
...
|
@@ -61,23 +77,8 @@ public class FFMInfoHandle { |
|
|
if (ffmlist_reportorder_1 !=null && !ffmlist_reportorder_1.isEmpty()){
|
|
|
for (FFMInfo item:ffmlist_reportorder_1) {
|
|
|
|
|
|
//1.1 查看舱单运单业务表是否已存在运单数据,不存在则插入业务表,存在则更新临时表的数据为已处理
|
|
|
int Flag = 0;
|
|
|
|
|
|
Flag = manifestMasterService.insertManifestWithMaster(item);
|
|
|
|
|
|
if (Flag>0){
|
|
|
result = true;
|
|
|
//业务数据入库成功后,更新舱单待处理表的数据状态为 1,根据航班号+航班日期+主单号
|
|
|
ffmInfoService.setDealstatusSuccess(item);
|
|
|
|
|
|
//舱单报文入库后, 更新FWB信息,将FWB临时表的信息更新到 舱单业务表
|
|
|
fwbInfoService.updateFwbToManifest(item.getWaybillnomaster());
|
|
|
|
|
|
//分单挂主单
|
|
|
int i = secondService.setManifestMaster(item);
|
|
|
|
|
|
}
|
|
|
result = updateFFM2Manifest(item);
|
|
|
log.info(new StringBuilder("开始入库").append(item.getFlightno()).append("/").append(item.getFlightdate()).append(":").append(item.getWaybillnomaster()).toString());
|
|
|
}
|
|
|
}
|
|
|
/**
|
...
|
...
|
@@ -87,43 +88,132 @@ public class FFMInfoHandle { |
|
|
{
|
|
|
//首先确定带有LAST的ffm的最批次大序号
|
|
|
//根据航班号+航班日期 判断LAST报对应的报文批次
|
|
|
List<FFMInfo> _last = ffmInfoService.getLastReportOrder(item_f,false);
|
|
|
List<FFMInfo> _last_count = ffmInfoService.getLastCountByPallet(item_f,false);
|
|
|
List<FFMInfo> _last = ffmInfoHandle.ffmInfoService.getLastReportOrder(item_f,false);
|
|
|
List<FFMInfo> _last_count = ffmInfoHandle.ffmInfoService.getLastCountByPallet(item_f,false);
|
|
|
if (_last != null && _last.size() > 0 && _last_count != null && _last_count.size() > 0){
|
|
|
int mm = Integer.parseInt(_last.get(0).getReportorder());
|
|
|
int nn = Integer.parseInt(_last_count.get(0).getReportorder());
|
|
|
if (mm > 0 && nn > 0 && mm == nn){
|
|
|
// 业务数据 开始入库
|
|
|
|
|
|
List<FFMInfo> ffmlist = ffmInfoService.getFFMinfoByPallet(item_f,false);
|
|
|
List<FFMInfo> ffmlist = ffmInfoHandle.ffmInfoService.getFFMinfoByPallet(item_f,false);
|
|
|
if (ffmlist != null && ffmlist.size() > 0){
|
|
|
|
|
|
for (FFMInfo item:ffmlist) {
|
|
|
int Flag = 0;
|
|
|
Flag = manifestMasterService.insertManifestWithMaster(item);
|
|
|
result = updateFFM2Manifest(item);
|
|
|
log.info(new StringBuilder("开始入库").append(item.getFlightno()).append("/").append(item.getFlightdate()).append(":").append(item.getWaybillnomaster()).toString());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看舱单运单业务表是否已存在运单数据,不存在则插入业务表,存在则更新临时表的数据为已处理
|
|
|
* 将舱单临时表的数据 写入舱单业务表,并挂载主分单关系
|
|
|
* @param item 临时表业务数据
|
|
|
* @return 成功或者失败
|
|
|
*/
|
|
|
private boolean updateFFM2Manifest(FFMInfo item) {
|
|
|
int Flag = 0;
|
|
|
/**
|
|
|
* 舱单业务表插入数据服务,
|
|
|
* 插入前判定是否有此航班的运单数据,插入语成功返回 1
|
|
|
* 业务库存在此航班的运单数据则不会插入,并更新ffminfo临时表的此舱单的数据状态为已处理 返回 0
|
|
|
* @return 0 or 1
|
|
|
*/
|
|
|
Flag = ffmInfoHandle.manifestMasterService.insertManifestWithMaster(item);
|
|
|
log.info(new StringBuilder("运单号:").append(item.getWaybillnomaster()).append("入库数量为:").append(Flag).toString());
|
|
|
|
|
|
if (Flag > 0) {
|
|
|
|
|
|
|
|
|
//业务数据入库成功后,更新舱单待处理表的数据状态为 1,根据航班号+航班日期+主单号
|
|
|
int ffm_i = ffmInfoHandle.ffmInfoService.setDealstatusSuccess(item);
|
|
|
log.info(new StringBuilder("更新运单:").append(item.getWaybillnomaster()).append("舱单临时表状态为:").append("已处理:").append(ffm_i).toString());
|
|
|
|
|
|
//舱单报文入库后, 更新FWB信息,将FWB临时表的信息更新到 舱单业务表
|
|
|
int fwb_i=ffmInfoHandle.fwbInfoService.updateFwbToManifest(item.getWaybillnomaster());
|
|
|
log.info(new StringBuilder("更新运单:").append(item.getWaybillnomaster()).append("运单FWB数据到业务库:").append(fwb_i).toString());
|
|
|
|
|
|
//分单挂主单
|
|
|
int fhl_i = ffmInfoHandle.secondService.setManifestMaster(item);
|
|
|
log.info("挂载分单成功->挂载数量:"+fhl_i);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (Flag>0){
|
|
|
result = true;
|
|
|
/**
|
|
|
* 处理板箱为空的舱单数据入业务库
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean dealFFMInfoWithNullPallet(){
|
|
|
boolean result = false;
|
|
|
try{
|
|
|
//1.取航班非空的板箱的运单列表数据,并且报文接收标识last存在。
|
|
|
List<FFMInfo> listflightno0 = ffmInfoHandle.ffmInfoService.getDistinctFlightWithPallet(true);
|
|
|
if (listflightno0!=null && listflightno0.size()>0){
|
|
|
|
|
|
for (FFMInfo item_f:listflightno0) {
|
|
|
// CustomsCargoSystem.Helper.Log.ffminfo_log("舱单数据入业务库调试信息", "舱单数据入业务库调试信息(板号空).txt",
|
|
|
//string.Format(@"{0}入业务库开始航班号:{1},航班日期:{2}" + Environment.NewLine, DateTime.Now, item_f.flightno, item_f.flightdate));
|
|
|
//针对补发报文处理
|
|
|
List<FFMInfo> ffmlist_reportorder_1 = ffmInfoHandle.ffmInfoService.getFFMLastReportOrderByPallet(item_f,true);
|
|
|
|
|
|
//业务数据入库成功后,更新舱单待处理表的数据状态为 1,根据航班号+航班日期+主单号
|
|
|
ffmInfoService.setDealstatusSuccess(item);
|
|
|
/**
|
|
|
* 判断列表是否为空
|
|
|
* 不为空则说明 FFM只有一份,第一份报文包含LAST标识
|
|
|
*/
|
|
|
if (ffmlist_reportorder_1 !=null && !ffmlist_reportorder_1.isEmpty()){
|
|
|
for (FFMInfo item:ffmlist_reportorder_1) {
|
|
|
result = updateFFM2Manifest(item);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* FFM文件多份处理
|
|
|
*/
|
|
|
else
|
|
|
{
|
|
|
//写判断逻辑 根据航班号+航班日期 判断LAST报对应的报文批次
|
|
|
//首先确定带有LAST的ffm的最批次大序号
|
|
|
//根据航班号+航班日期 判断LAST报对应的报文批次
|
|
|
List<FFMInfo> _last = ffmInfoHandle.ffmInfoService.getLastReportOrder(item_f,true);
|
|
|
List<FFMInfo> _last_count = ffmInfoHandle.ffmInfoService.getLastCountByPallet(item_f,true);
|
|
|
if (_last != null && _last.size() > 0 && _last_count != null && _last_count.size() > 0){
|
|
|
int mm = Integer.parseInt(_last.get(0).getReportorder());
|
|
|
int nn = Integer.parseInt(_last_count.get(0).getReportorder());
|
|
|
if (mm > 0 && nn > 0 && mm == nn){
|
|
|
// 业务数据 开始入库
|
|
|
|
|
|
//舱单报文入库后, 更新FWB信息,将FWB临时表的信息更新到 舱单业务表
|
|
|
fwbInfoService.updateFwbToManifest(item.getWaybillnomaster());
|
|
|
List<FFMInfo> ffmlist = ffmInfoHandle.ffmInfoService.getFFMinfoByPallet(item_f,true);
|
|
|
if (ffmlist != null && ffmlist.size() > 0){
|
|
|
|
|
|
//分单挂主单
|
|
|
int i = secondService.setManifestMaster(item);
|
|
|
}
|
|
|
for (FFMInfo item:ffmlist) {
|
|
|
result = updateFFM2Manifest(item);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|