作者 朱兆平

整体处理舱单临时表如业务库处理完毕

@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 web: 2 web:
3 upload-path: upload/ 3 upload-path: upload/
4 server: 4 server:
5 - port: 10002 5 + port: 10003
6 servlet: 6 servlet:
7 context-path: ${SERVER_CONTEXTPATH:} 7 context-path: ${SERVER_CONTEXTPATH:}
8 spring: 8 spring:
@@ -16,7 +16,7 @@ spring: @@ -16,7 +16,7 @@ spring:
16 static-locations: classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,file:${web.upload-path} 16 static-locations: classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,file:${web.upload-path}
17 17
18 application: 18 application:
19 - name: customAnalysisReception 19 + name: ffmInfoAnalysisService
20 20
21 jackson: 21 jackson:
22 serialization: 22 serialization:
@@ -32,18 +32,18 @@ spring: @@ -32,18 +32,18 @@ spring:
32 #eureka主机名,会在控制页面中显示 32 #eureka主机名,会在控制页面中显示
33 #DEV环境关闭注册。 33 #DEV环境关闭注册。
34 features: 34 features:
35 - enabled: true 35 + enabled: false
36 discovery: 36 discovery:
37 - enabled: true 37 + enabled: false
38 service-registry: 38 service-registry:
39 auto-registration: 39 auto-registration:
40 - enabled: true 40 + enabled: false
41 41
42 datasource: 42 datasource:
43 type: com.alibaba.druid.pool.DruidDataSource 43 type: com.alibaba.druid.pool.DruidDataSource
44 #oracle 44 #oracle
45 driver-class-name: oracle.jdbc.OracleDriver 45 driver-class-name: oracle.jdbc.OracleDriver
46 - url: jdbc:oracle:thin:@10.50.3.69:1521:CGODB 46 + url: jdbc:oracle:thin:@218.28.199.134:8004:CGODB
47 username: CGONMS 47 username: CGONMS
48 password: 1q2w3e4r 48 password: 1q2w3e4r
49 #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 49 #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 */ 4 */
5 package com.tianbo.analysis; 5 package com.tianbo.analysis;
6 6
  7 +import com.tianbo.analysis.task.FFMInfoHandle;
7 import org.mybatis.spring.annotation.MapperScan; 8 import org.mybatis.spring.annotation.MapperScan;
8 import org.springframework.boot.SpringApplication; 9 import org.springframework.boot.SpringApplication;
9 import org.springframework.boot.autoconfigure.SpringBootApplication; 10 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -26,6 +27,9 @@ public class BootApplication { @@ -26,6 +27,9 @@ public class BootApplication {
26 27
27 public static void main(String[] args) { 28 public static void main(String[] args) {
28 SpringApplication.run(BootApplication.class, args); 29 SpringApplication.run(BootApplication.class, args);
  30 +
  31 + FFMInfoHandle ffmInfoHandle = new FFMInfoHandle();
  32 + ffmInfoHandle.dealFFMInfoWithPallet();
29 } 33 }
30 34
31 @Bean 35 @Bean
@@ -5,6 +5,7 @@ import com.tianbo.analysis.model.Originmanifestsecondary; @@ -5,6 +5,7 @@ import com.tianbo.analysis.model.Originmanifestsecondary;
5 import java.util.List; 5 import java.util.List;
6 6
7 public interface OriginmanifestsecondaryMapper { 7 public interface OriginmanifestsecondaryMapper {
  8 +
8 int insert(Originmanifestsecondary record); 9 int insert(Originmanifestsecondary record);
9 10
10 int insertSelective(Originmanifestsecondary record); 11 int insertSelective(Originmanifestsecondary record);
@@ -4,11 +4,13 @@ import com.tianbo.analysis.dao.FWBINFOMapper; @@ -4,11 +4,13 @@ import com.tianbo.analysis.dao.FWBINFOMapper;
4 import com.tianbo.analysis.dao.ORIGINMANIFESTMASTERMapper; 4 import com.tianbo.analysis.dao.ORIGINMANIFESTMASTERMapper;
5 import com.tianbo.analysis.model.FWBINFO; 5 import com.tianbo.analysis.model.FWBINFO;
6 import com.tianbo.analysis.service.FWBInfoService; 6 import com.tianbo.analysis.service.FWBInfoService;
  7 +import lombok.extern.slf4j.Slf4j;
7 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Service; 9 import org.springframework.stereotype.Service;
9 10
10 import java.util.List; 11 import java.util.List;
11 12
  13 +@Slf4j
12 @Service 14 @Service
13 public class FWBInfoServiceImp implements FWBInfoService { 15 public class FWBInfoServiceImp implements FWBInfoService {
14 16
@@ -25,6 +27,8 @@ public class FWBInfoServiceImp implements FWBInfoService { @@ -25,6 +27,8 @@ public class FWBInfoServiceImp implements FWBInfoService {
25 if (fwbinfos!=null && !fwbinfos.isEmpty()){ 27 if (fwbinfos!=null && !fwbinfos.isEmpty()){
26 FWBINFO _model_fwb = fwbinfos.get(0); 28 FWBINFO _model_fwb = fwbinfos.get(0);
27 return originmanifestmasterMapper.updateFWBByFWBInfoAndStatus(_model_fwb); 29 return originmanifestmasterMapper.updateFWBByFWBInfoAndStatus(_model_fwb);
  30 + }else {
  31 + log.info("未找到FWBINFO主单信息");
28 } 32 }
29 return 0; 33 return 0;
30 } 34 }
@@ -6,12 +6,14 @@ import com.tianbo.analysis.model.ORIGINMANIFESTMASTER; @@ -6,12 +6,14 @@ import com.tianbo.analysis.model.ORIGINMANIFESTMASTER;
6 import com.tianbo.analysis.service.FFMInfoService; 6 import com.tianbo.analysis.service.FFMInfoService;
7 import com.tianbo.analysis.service.ManifestMasterService; 7 import com.tianbo.analysis.service.ManifestMasterService;
8 import com.tianbo.analysis.service.ManifestSecondService; 8 import com.tianbo.analysis.service.ManifestSecondService;
  9 +import lombok.extern.slf4j.Slf4j;
9 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
11 12
12 import java.util.Date; 13 import java.util.Date;
13 import java.util.List; 14 import java.util.List;
14 15
  16 +@Slf4j
15 @Service 17 @Service
16 public class ManifestMasterServiceImp implements ManifestMasterService{ 18 public class ManifestMasterServiceImp implements ManifestMasterService{
17 19
@@ -24,6 +26,14 @@ public class ManifestMasterServiceImp implements ManifestMasterService{ @@ -24,6 +26,14 @@ public class ManifestMasterServiceImp implements ManifestMasterService{
24 @Override 26 @Override
25 public int insertManifestWithMaster(FFMInfo item){ 27 public int insertManifestWithMaster(FFMInfo item){
26 ORIGINMANIFESTMASTER master = new ORIGINMANIFESTMASTER(); 28 ORIGINMANIFESTMASTER master = new ORIGINMANIFESTMASTER();
  29 +
  30 + String flightDate = item.getFlightdate().toString();
  31 + String flightNo = item.getFlightno();
  32 + String weibillMaster = item.getWaybillnomaster();
  33 + String weight = item.getManifesttotalweight();
  34 + String piece = item.getManifesttotalpiece();
  35 + String destnation = item.getDestinationstation();
  36 +
27 master.setWaybillnomaster(item.getWaybillnomaster()); 37 master.setWaybillnomaster(item.getWaybillnomaster());
28 master.setFlightDate(item.getFlightdate()); 38 master.setFlightDate(item.getFlightdate());
29 master.setFlightno(item.getFlightno()); 39 master.setFlightno(item.getFlightno());
@@ -51,11 +61,19 @@ public class ManifestMasterServiceImp implements ManifestMasterService{ @@ -51,11 +61,19 @@ public class ManifestMasterServiceImp implements ManifestMasterService{
51 master.setIslast(""); 61 master.setIslast("");
52 master.setCreatedate(new Date()); 62 master.setCreatedate(new Date());
53 63
  64 + log.warn(new StringBuilder("开始插入舱单数据到业务库:\n")
  65 + .append("航班号:").append(flightNo).append("/").append(flightDate)
  66 + .append("\n运单号:").append(weibillMaster)
  67 + .append("\n件/重:").append(piece).append("/").append(weight)
  68 + .append("\n目的地:").append(destnation)
  69 + .toString());
  70 +
54 return originmanifestmasterMapper.insertSelective(master); 71 return originmanifestmasterMapper.insertSelective(master);
55 //写入完毕 72 //写入完毕
56 }else { 73 }else {
57 //重复数据不操作,直接更新掉临时表数据状态 74 //重复数据不操作,直接更新掉临时表数据状态
58 ffmInfoService.setDealstatusSuccess(item); 75 ffmInfoService.setDealstatusSuccess(item);
  76 + log.info("运单号:"+item.getWaybillnomaster()+"数据已存在与业务库不更新,更新此运单舱单临时表业务数据为已处理");
59 } 77 }
60 return 0; 78 return 0;
61 } 79 }
@@ -18,29 +18,49 @@ public class ManifestSecondServiceImp implements ManifestSecondService { @@ -18,29 +18,49 @@ public class ManifestSecondServiceImp implements ManifestSecondService {
18 @Override 18 @Override
19 public int setManifestMaster(FFMInfo ffm){ 19 public int setManifestMaster(FFMInfo ffm){
20 20
  21 + int i =0;
21 String isBatch = ffm.getIsbatch(); 22 String isBatch = ffm.getIsbatch();
22 isBatch = (isBatch == null) ? "" : isBatch; 23 isBatch = (isBatch == null) ? "" : isBatch;
23 - //未分批的分单 如果已经挂载到主单上就不挂载了  
24 - if (isBatch.equals("T") || isBatch.equals("S") || isBatch.equals("D") || isBatch.equals("P") || isBatch.equals("M")){  
25 - }  
26 - //否则是分批标识的 要挂载到最新的航班的主单下 Todo: 这里后面判断是否需要做分批和非分批的挂载方式判定  
27 24
28 - //从分单表取属于此主单下的分单列表,更新主分单关系  
29 - List<Originmanifestsecondary> list_seondary = originmanifestsecondaryMapper.selectByFWb(ffm.getWaybillnomaster());  
30 - if (list_seondary != null && !list_seondary.isEmpty()){  
31 - for (Originmanifestsecondary manifestsecondary : list_seondary) { 25 + //未分批的分单 如果已经挂载到主单上就不挂载了,减少数据库操作压力
  26 + if (isBatch.equals("T") || isBatch.equals("S")){
  27 +
  28 + //从分单表取属于此主单下的分单列表,更新主分单关系
  29 + List<Originmanifestsecondary> list_seondary = originmanifestsecondaryMapper.selectByFWb(ffm.getWaybillnomaster());
  30 + if (list_seondary != null && !list_seondary.isEmpty()){
  31 + for (Originmanifestsecondary manifestsecondary : list_seondary) {
32 32
  33 + //分单的主单autoid
  34 + String masterAutoId = manifestsecondary.getOriginmanifestmasterautoid();
  35 + masterAutoId = (masterAutoId == null)? "" : masterAutoId ;
33 36
34 - Originmanifestsecondary secondary = new Originmanifestsecondary();  
35 - secondary.setAutoid(manifestsecondary.getAutoid());  
36 - secondary.setOriginmanifestmasterautoid(ffm.getAutoid());  
37 - secondary.setCustomsstatus(ffm.getCustomsstatus());  
38 - int i =originmanifestsecondaryMapper.updateMasterAutoId(secondary);  
39 - return i; 37 + //如果分单没挂过主单 开始挂
  38 + if(masterAutoId.equals("0") || masterAutoId.equals("")){
  39 + i += setManifestSecondMasterAutoId(ffm,manifestsecondary);
  40 + }
  41 + }
  42 + }
  43 + }
  44 + //否则是分批标识的 要挂载到最新的航班的主单下
  45 + if (isBatch.equals("D") || isBatch.equals("P") || isBatch.equals("M")){
  46 + List<Originmanifestsecondary> list_seondary = originmanifestsecondaryMapper.selectByFWb(ffm.getWaybillnomaster());
  47 + if (list_seondary != null && !list_seondary.isEmpty()){
  48 + for (Originmanifestsecondary manifestsecondary : list_seondary) {
  49 + i += setManifestSecondMasterAutoId(ffm,manifestsecondary);
  50 + }
40 } 51 }
41 } 52 }
42 53
  54 + return i;
  55 + }
  56 +
  57 + private int setManifestSecondMasterAutoId(FFMInfo ffm,Originmanifestsecondary manifestsecondary){
43 58
44 - return 0; 59 + Originmanifestsecondary secondary = new Originmanifestsecondary();
  60 + secondary.setAutoid(manifestsecondary.getAutoid());
  61 + secondary.setOriginmanifestmasterautoid(ffm.getAutoid());
  62 + secondary.setCustomsstatus(ffm.getCustomsstatus());
  63 + int i =originmanifestsecondaryMapper.updateMasterAutoId(secondary);
  64 + return i;
45 } 65 }
46 } 66 }
1 package com.tianbo.analysis.task; 1 package com.tianbo.analysis.task;
2 2
3 -import com.netflix.discovery.converters.Auto;  
4 -import com.tianbo.analysis.dao.FWBINFOMapper;  
5 -import com.tianbo.analysis.dao.ORIGINMANIFESTMASTERMapper;  
6 -import com.tianbo.analysis.dao.OriginmanifestsecondaryMapper;  
7 import com.tianbo.analysis.model.FFMInfo; 3 import com.tianbo.analysis.model.FFMInfo;
8 -import com.tianbo.analysis.model.FWBINFO;  
9 -import com.tianbo.analysis.model.ORIGINMANIFESTMASTER;  
10 -import com.tianbo.analysis.model.Originmanifestsecondary;  
11 import com.tianbo.analysis.service.FFMInfoService; 4 import com.tianbo.analysis.service.FFMInfoService;
12 import com.tianbo.analysis.service.FWBInfoService; 5 import com.tianbo.analysis.service.FWBInfoService;
13 import com.tianbo.analysis.service.ManifestMasterService; 6 import com.tianbo.analysis.service.ManifestMasterService;
14 import com.tianbo.analysis.service.ManifestSecondService; 7 import com.tianbo.analysis.service.ManifestSecondService;
  8 +import lombok.extern.slf4j.Slf4j;
15 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Component; 10 import org.springframework.stereotype.Component;
17 11
18 -import java.util.Date; 12 +import javax.annotation.PostConstruct;
19 import java.util.List; 13 import java.util.List;
20 14
21 /** 15 /**
22 * ffm临时业务表处理入业务库 16 * ffm临时业务表处理入业务库
23 - * 17 + * 舱单 = 航班号+航班日期+运单号
  18 + * 运单 = 运单号
24 */ 19 */
  20 +@Slf4j
25 @Component 21 @Component
26 public class FFMInfoHandle { 22 public class FFMInfoHandle {
27 23
28 @Autowired 24 @Autowired
29 FFMInfoService ffmInfoService; 25 FFMInfoService ffmInfoService;
30 26
31 - @Autowired  
32 - ORIGINMANIFESTMASTERMapper originmanifestmasterMapper;  
33 27
34 @Autowired 28 @Autowired
35 ManifestMasterService manifestMasterService; 29 ManifestMasterService manifestMasterService;
@@ -38,21 +32,43 @@ public class FFMInfoHandle { @@ -38,21 +32,43 @@ public class FFMInfoHandle {
38 @Autowired 32 @Autowired
39 FWBInfoService fwbInfoService; 33 FWBInfoService fwbInfoService;
40 34
41 - @Autowired  
42 - OriginmanifestsecondaryMapper originmanifestsecondaryMapper;  
43 35
44 @Autowired 36 @Autowired
45 ManifestSecondService secondService; 37 ManifestSecondService secondService;
46 38
47 - public boolean dealFFMInfo(){ 39 + private static FFMInfoHandle ffmInfoHandle;
  40 +
  41 + //通过@PostConstruct实现初始化bean之前进行的操作,解决service调用空指针问题
  42 + @PostConstruct
  43 + public void init() {
  44 + ffmInfoHandle = this;
  45 + ffmInfoHandle.ffmInfoService = this.ffmInfoService;
  46 + ffmInfoHandle.manifestMasterService = this.manifestMasterService;
  47 + ffmInfoHandle.fwbInfoService = this.fwbInfoService;
  48 + ffmInfoHandle.secondService = this.secondService;
  49 + // 初使化时将已静态化的testService实例化
  50 + }
  51 + /**
  52 + * 处理板箱非空的舱单数据入业务库
  53 + * @return
  54 + */
  55 + public boolean dealFFMInfoWithPallet(){
48 boolean result =false; 56 boolean result =false;
49 try { 57 try {
50 - //1.处理板箱非空的数据  
51 - List<FFMInfo> ffmInfoList = ffmInfoService.getDistinctFlightWithPallet(false); 58 + //1.取航班非空的板箱的运单列表数据,并且报文接收标识last存在。
  59 + List<FFMInfo> ffmInfoList = ffmInfoHandle.ffmInfoService.getDistinctFlightWithPallet(false);
52 if (ffmInfoList!=null && !ffmInfoList.isEmpty()){ 60 if (ffmInfoList!=null && !ffmInfoList.isEmpty()){
53 for (FFMInfo item_f:ffmInfoList) { 61 for (FFMInfo item_f:ffmInfoList) {
  62 +
  63 + String flightDate = item_f.getFlightdate().toString();
  64 + String flghtNo = item_f.getFlightno();
  65 + StringBuilder sb = new StringBuilder();
  66 + log.info(sb.append("开始处理航班:").append(flghtNo).append("/").append(flightDate).toString());
  67 +
54 //针对补发报文处理,补发的报文: FFM_INFOB表数据,存储的报文批次01对应标识是LAST 68 //针对补发报文处理,补发的报文: FFM_INFOB表数据,存储的报文批次01对应标识是LAST
55 - List<FFMInfo> ffmlist_reportorder_1 = ffmInfoService.getFFMLastReportOrderByPallet(item_f,false); 69 + List<FFMInfo> ffmlist_reportorder_1 = ffmInfoHandle.ffmInfoService.getFFMLastReportOrderByPallet(item_f,false);
  70 +
  71 +
56 72
57 /** 73 /**
58 * 判断列表是否为空 74 * 判断列表是否为空
@@ -61,23 +77,8 @@ public class FFMInfoHandle { @@ -61,23 +77,8 @@ public class FFMInfoHandle {
61 if (ffmlist_reportorder_1 !=null && !ffmlist_reportorder_1.isEmpty()){ 77 if (ffmlist_reportorder_1 !=null && !ffmlist_reportorder_1.isEmpty()){
62 for (FFMInfo item:ffmlist_reportorder_1) { 78 for (FFMInfo item:ffmlist_reportorder_1) {
63 79
64 - //1.1 查看舱单运单业务表是否已存在运单数据,不存在则插入业务表,存在则更新临时表的数据为已处理  
65 - int Flag = 0;  
66 -  
67 - Flag = manifestMasterService.insertManifestWithMaster(item);  
68 -  
69 - if (Flag>0){  
70 - result = true;  
71 - //业务数据入库成功后,更新舱单待处理表的数据状态为 1,根据航班号+航班日期+主单号  
72 - ffmInfoService.setDealstatusSuccess(item);  
73 -  
74 - //舱单报文入库后, 更新FWB信息,将FWB临时表的信息更新到 舱单业务表  
75 - fwbInfoService.updateFwbToManifest(item.getWaybillnomaster());  
76 -  
77 - //分单挂主单  
78 - int i = secondService.setManifestMaster(item);  
79 -  
80 - } 80 + result = updateFFM2Manifest(item);
  81 + log.info(new StringBuilder("开始入库").append(item.getFlightno()).append("/").append(item.getFlightdate()).append(":").append(item.getWaybillnomaster()).toString());
81 } 82 }
82 } 83 }
83 /** 84 /**
@@ -87,43 +88,132 @@ public class FFMInfoHandle { @@ -87,43 +88,132 @@ public class FFMInfoHandle {
87 { 88 {
88 //首先确定带有LAST的ffm的最批次大序号 89 //首先确定带有LAST的ffm的最批次大序号
89 //根据航班号+航班日期 判断LAST报对应的报文批次 90 //根据航班号+航班日期 判断LAST报对应的报文批次
90 - List<FFMInfo> _last = ffmInfoService.getLastReportOrder(item_f,false);  
91 - List<FFMInfo> _last_count = ffmInfoService.getLastCountByPallet(item_f,false); 91 + List<FFMInfo> _last = ffmInfoHandle.ffmInfoService.getLastReportOrder(item_f,false);
  92 + List<FFMInfo> _last_count = ffmInfoHandle.ffmInfoService.getLastCountByPallet(item_f,false);
92 if (_last != null && _last.size() > 0 && _last_count != null && _last_count.size() > 0){ 93 if (_last != null && _last.size() > 0 && _last_count != null && _last_count.size() > 0){
93 int mm = Integer.parseInt(_last.get(0).getReportorder()); 94 int mm = Integer.parseInt(_last.get(0).getReportorder());
94 int nn = Integer.parseInt(_last_count.get(0).getReportorder()); 95 int nn = Integer.parseInt(_last_count.get(0).getReportorder());
95 if (mm > 0 && nn > 0 && mm == nn){ 96 if (mm > 0 && nn > 0 && mm == nn){
96 // 业务数据 开始入库 97 // 业务数据 开始入库
97 98
98 - List<FFMInfo> ffmlist = ffmInfoService.getFFMinfoByPallet(item_f,false); 99 + List<FFMInfo> ffmlist = ffmInfoHandle.ffmInfoService.getFFMinfoByPallet(item_f,false);
99 if (ffmlist != null && ffmlist.size() > 0){ 100 if (ffmlist != null && ffmlist.size() > 0){
100 101
101 for (FFMInfo item:ffmlist) { 102 for (FFMInfo item:ffmlist) {
102 - int Flag = 0;  
103 - Flag = manifestMasterService.insertManifestWithMaster(item); 103 + result = updateFFM2Manifest(item);
  104 + log.info(new StringBuilder("开始入库").append(item.getFlightno()).append("/").append(item.getFlightdate()).append(":").append(item.getWaybillnomaster()).toString());
  105 + }
  106 +
  107 + }
  108 + }
  109 + }
  110 + }
  111 + }
  112 + }
  113 + }catch (Exception e){
  114 + e.printStackTrace();
  115 + }
  116 + return true;
  117 + }
  118 +
  119 + /**
  120 + * 查看舱单运单业务表是否已存在运单数据,不存在则插入业务表,存在则更新临时表的数据为已处理
  121 + * 将舱单临时表的数据 写入舱单业务表,并挂载主分单关系
  122 + * @param item 临时表业务数据
  123 + * @return 成功或者失败
  124 + */
  125 + private boolean updateFFM2Manifest(FFMInfo item) {
  126 + int Flag = 0;
  127 + /**
  128 + * 舱单业务表插入数据服务,
  129 + * 插入前判定是否有此航班的运单数据,插入语成功返回 1
  130 + * 业务库存在此航班的运单数据则不会插入,并更新ffminfo临时表的此舱单的数据状态为已处理 返回 0
  131 + * @return 0 or 1
  132 + */
  133 + Flag = ffmInfoHandle.manifestMasterService.insertManifestWithMaster(item);
  134 + log.info(new StringBuilder("运单号:").append(item.getWaybillnomaster()).append("入库数量为:").append(Flag).toString());
  135 +
  136 + if (Flag > 0) {
  137 +
  138 +
  139 + //业务数据入库成功后,更新舱单待处理表的数据状态为 1,根据航班号+航班日期+主单号
  140 + int ffm_i = ffmInfoHandle.ffmInfoService.setDealstatusSuccess(item);
  141 + log.info(new StringBuilder("更新运单:").append(item.getWaybillnomaster()).append("舱单临时表状态为:").append("已处理:").append(ffm_i).toString());
  142 +
  143 + //舱单报文入库后, 更新FWB信息,将FWB临时表的信息更新到 舱单业务表
  144 + int fwb_i=ffmInfoHandle.fwbInfoService.updateFwbToManifest(item.getWaybillnomaster());
  145 + log.info(new StringBuilder("更新运单:").append(item.getWaybillnomaster()).append("运单FWB数据到业务库:").append(fwb_i).toString());
  146 +
  147 + //分单挂主单
  148 + int fhl_i = ffmInfoHandle.secondService.setManifestMaster(item);
  149 + log.info("挂载分单成功->挂载数量:"+fhl_i);
  150 + return true;
  151 + }
  152 + return false;
  153 + }
104 154
105 - if (Flag>0){  
106 - result = true; 155 + /**
  156 + * 处理板箱为空的舱单数据入业务库
  157 + * @return
  158 + */
  159 + public boolean dealFFMInfoWithNullPallet(){
  160 + boolean result = false;
  161 + try{
  162 + //1.取航班非空的板箱的运单列表数据,并且报文接收标识last存在。
  163 + List<FFMInfo> listflightno0 = ffmInfoHandle.ffmInfoService.getDistinctFlightWithPallet(true);
  164 + if (listflightno0!=null && listflightno0.size()>0){
  165 +
  166 + for (FFMInfo item_f:listflightno0) {
  167 + // CustomsCargoSystem.Helper.Log.ffminfo_log("舱单数据入业务库调试信息", "舱单数据入业务库调试信息(板号空).txt",
  168 + //string.Format(@"{0}入业务库开始航班号:{1},航班日期:{2}" + Environment.NewLine, DateTime.Now, item_f.flightno, item_f.flightdate));
  169 + //针对补发报文处理
  170 + List<FFMInfo> ffmlist_reportorder_1 = ffmInfoHandle.ffmInfoService.getFFMLastReportOrderByPallet(item_f,true);
107 171
108 - //业务数据入库成功后,更新舱单待处理表的数据状态为 1,根据航班号+航班日期+主单号  
109 - ffmInfoService.setDealstatusSuccess(item); 172 + /**
  173 + * 判断列表是否为空
  174 + * 不为空则说明 FFM只有一份,第一份报文包含LAST标识
  175 + */
  176 + if (ffmlist_reportorder_1 !=null && !ffmlist_reportorder_1.isEmpty()){
  177 + for (FFMInfo item:ffmlist_reportorder_1) {
  178 + result = updateFFM2Manifest(item);
  179 + }
  180 + }
  181 + /**
  182 + * FFM文件多份处理
  183 + */
  184 + else
  185 + {
  186 + //写判断逻辑 根据航班号+航班日期 判断LAST报对应的报文批次
  187 + //首先确定带有LAST的ffm的最批次大序号
  188 + //根据航班号+航班日期 判断LAST报对应的报文批次
  189 + List<FFMInfo> _last = ffmInfoHandle.ffmInfoService.getLastReportOrder(item_f,true);
  190 + List<FFMInfo> _last_count = ffmInfoHandle.ffmInfoService.getLastCountByPallet(item_f,true);
  191 + if (_last != null && _last.size() > 0 && _last_count != null && _last_count.size() > 0){
  192 + int mm = Integer.parseInt(_last.get(0).getReportorder());
  193 + int nn = Integer.parseInt(_last_count.get(0).getReportorder());
  194 + if (mm > 0 && nn > 0 && mm == nn){
  195 + // 业务数据 开始入库
110 196
111 - //舱单报文入库后, 更新FWB信息,将FWB临时表的信息更新到 舱单业务表  
112 - fwbInfoService.updateFwbToManifest(item.getWaybillnomaster()); 197 + List<FFMInfo> ffmlist = ffmInfoHandle.ffmInfoService.getFFMinfoByPallet(item_f,true);
  198 + if (ffmlist != null && ffmlist.size() > 0){
113 199
114 - //分单挂主单  
115 - int i = secondService.setManifestMaster(item);  
116 - } 200 + for (FFMInfo item:ffmlist) {
  201 + result = updateFFM2Manifest(item);
117 } 202 }
  203 +
118 } 204 }
119 } 205 }
120 } 206 }
121 } 207 }
  208 +
122 } 209 }
123 } 210 }
124 }catch (Exception e){ 211 }catch (Exception e){
125 e.printStackTrace(); 212 e.printStackTrace();
  213 + return false;
126 } 214 }
  215 +
127 return true; 216 return true;
128 } 217 }
  218 +
129 } 219 }
@@ -34,7 +34,7 @@ public class TaskAnalysis { @@ -34,7 +34,7 @@ public class TaskAnalysis {
34 34
35 35
36 36
37 - @Scheduled(fixedDelay = 5000) 37 +// @Scheduled(fixedDelay = 5000)
38 public void startTask(){ 38 public void startTask(){
39 String readDir = receptDir + "/" + today; 39 String readDir = receptDir + "/" + today;
40 String backdireByDay = bakupDir + "/" + today; 40 String backdireByDay = bakupDir + "/" + today;