wangyi

处理上传失败数据

...@@ -33,5 +33,21 @@ public interface ReceiptMessageRepository extends JpaSpecificationExecutor<Recei ...@@ -33,5 +33,21 @@ public interface ReceiptMessageRepository extends JpaSpecificationExecutor<Recei
33 @Query(nativeQuery = true,value = "UPDATE T_DECLEAR_TASK SET PUSH_TIME = ?1,PUSH_NUMBER = PUSH_NUMBER + 1,RESPONSE_TIME = ?2,RESPONSE_RESULTS = ?3,RESPONSE_CONTENT = ?4 WHERE FILE_TYPE = 2 AND CHMSIGNMENT_ID = ?5") 33 @Query(nativeQuery = true,value = "UPDATE T_DECLEAR_TASK SET PUSH_TIME = ?1,PUSH_NUMBER = PUSH_NUMBER + 1,RESPONSE_TIME = ?2,RESPONSE_RESULTS = ?3,RESPONSE_CONTENT = ?4 WHERE FILE_TYPE = 2 AND CHMSIGNMENT_ID = ?5")
34 void updateDeclearTaskStatus(Date pushTime, Date responseTime, String responseResults, String responseContent, Long chmsignmentId); 34 void updateDeclearTaskStatus(Date pushTime, Date responseTime, String responseResults, String responseContent, Long chmsignmentId);
35 35
36 + /**
37 + * 推送失败回执数据
38 + *
39 + * @param
40 + * @return
41 + */
42 + @Query(nativeQuery = true, value = "SELECT RM.* FROM T_RECEIPT_MESSAGE RM INNER JOIN T_DECLEAR_TASK DT ON(RM.ID = DT.CHMSIGNMENT_ID) WHERE FILE_TYPE = 2 AND PUSH_NUMBER >= 3 AND RESPONSE_RESULTS ='失败' ORDER BY RM.NOTICE_DATE ASC")
43 + public List<ReceiptMessage> findReceiptMessageErrorReturnList();
44 + /**
45 + * 推送失败申报数据
46 + *
47 + * @param
48 + * @return
49 + */
50 + @Query(nativeQuery = true, value = "SELECT RM.* FROM T_RECEIPT_MESSAGE RM INNER JOIN T_DECLEAR_TASK DT ON(RM.ID = DT.CHMSIGNMENT_ID) WHERE FILE_TYPE = 1 AND PUSH_NUMBER >= 3 AND RESPONSE_RESULTS ='失败' ORDER BY RM.NOTICE_DATE ASC")
51 + public List<ReceiptMessage> findReceiptMessageErrorDeclareList();
36 52
37 } 53 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -180,4 +180,28 @@ public class ApiService { ...@@ -180,4 +180,28 @@ public class ApiService {
180 ex.printStackTrace(); 180 ex.printStackTrace();
181 } 181 }
182 } 182 }
183 + /**
184 + * 传输推送失败回执数据
185 + * @param token
186 + * @throws Exception
187 + */
188 + public void pushErrorReturnDate(String token){
189 + //获取海关回执数据
190 + List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageErrorReturnList();
191 + if (receiptMessageList !=null && receiptMessageList.size() > 0){
192 + this.sendCustoms(token,receiptMessageList);
193 + }
194 + }
195 + /**
196 + * 传输推送失败申报数据
197 + * @param token
198 + * @throws Exception
199 + */
200 + public void pushErrorDeclareDate(String token){
201 + //获取海关申报数据
202 + List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageErrorDeclareList();
203 + if (receiptMessageList !=null && receiptMessageList.size() > 0){
204 + this.sendCustoms(token,receiptMessageList);
205 + }
206 + }
183 } 207 }
......
...@@ -75,4 +75,60 @@ public class IClearApiTask { ...@@ -75,4 +75,60 @@ public class IClearApiTask {
75 log.error("pushMawbTask() error:" +e.getMessage()); 75 log.error("pushMawbTask() error:" +e.getMessage());
76 } 76 }
77 } 77 }
78 + /**
79 + * TODO 定时任务:每分钟推送: 推送失败的回执数据,
80 + */
81 + @Scheduled(cron = "${task.pushErrorReturnDate}")
82 + public void pushErrorReturnDate(){
83 + try{
84 + log.info("pushErrorReturnDate start>>>>>>>>>>>>");
85 + if(token == null){
86 + try {
87 + //获取token
88 + TokenResult tokenResult = apiService.getToken();
89 + if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
90 + this.token = tokenResult.getData().getToken();
91 + }
92 + }catch(Exception ex){
93 + ex.printStackTrace();
94 + }
95 + }
96 + if(this.token == null){
97 + throw new Exception("获取token失败!");
98 + }
99 + //获取token成功则进行海关回执推送
100 + apiService.pushErrorReturnDate(this.token);
101 + log.info("pushErrorReturnDate end>>>>>>>>>>>>");
102 + }catch (Exception e){
103 + log.error("pushErrorReturnDate() error:" +e.getMessage());
104 + }
105 + }
106 + /**
107 + * TODO 定时任务:每分钟推送: 推送失败的申报数据,
108 + */
109 + @Scheduled(cron = "${task.pushErrorDeclareDate}")
110 + public void pushErrorData(){
111 + try{
112 + log.info("pushErrorDeclareDate start>>>>>>>>>>>>");
113 + if(token == null){
114 + try {
115 + //获取token
116 + TokenResult tokenResult = apiService.getToken();
117 + if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
118 + this.token = tokenResult.getData().getToken();
119 + }
120 + }catch(Exception ex){
121 + ex.printStackTrace();
122 + }
123 + }
124 + if(this.token == null){
125 + throw new Exception("获取token失败!");
126 + }
127 + //获取token成功则进行海关回执推送
128 + apiService.pushErrorDeclareDate(this.token);
129 + log.info("pushErrorDeclareDate end>>>>>>>>>>>>");
130 + }catch (Exception e){
131 + log.error("pushErrorDeclareDate() error:" +e.getMessage());
132 + }
133 + }
78 } 134 }
......
...@@ -11,6 +11,11 @@ task: ...@@ -11,6 +11,11 @@ task:
11 pushCustomsTask: 0 0/1 * * * ? 11 pushCustomsTask: 0 0/1 * * * ?
12 #推送完整报文 12 #推送完整报文
13 pushMawbTask: 0 0/1 * * * ? 13 pushMawbTask: 0 0/1 * * * ?
14 + #推送失败的回执数据
15 + pushErrorReturnDate: 0 0/1 * * * ?
16 + #推送失败的申报数据
17 + pushErrorDeclareDate: 0 0/1 * * * ?
18 +
14 19
15 #推送地址 20 #推送地址
16 api: 21 api:
......
...@@ -11,6 +11,10 @@ task: ...@@ -11,6 +11,10 @@ task:
11 pushCustomsTask: 0 0/1 * * * ? 11 pushCustomsTask: 0 0/1 * * * ?
12 #推送完整报文 12 #推送完整报文
13 pushMawbTask: 0 0/1 * * * ? 13 pushMawbTask: 0 0/1 * * * ?
14 + #推送失败的回执数据
15 + pushErrorReturnDate: 0 0/1 * * * ?
16 + #推送失败的申报数据
17 + pushErrorDeclareDate: 0 0/1 * * * ?
14 18
15 #推送地址 19 #推送地址
16 api: 20 api:
......
...@@ -11,6 +11,10 @@ task: ...@@ -11,6 +11,10 @@ task:
11 pushCustomsTask: 0 0/1 * * * ? 11 pushCustomsTask: 0 0/1 * * * ?
12 #推送完整报文 12 #推送完整报文
13 pushMawbTask: 0 0/1 * * * ? 13 pushMawbTask: 0 0/1 * * * ?
14 + #推送失败的回执数据
15 + pushErrorReturnDate: 0 0/1 * * * ?
16 + #推送失败的申报数据
17 + pushErrorDeclareDate: 0 0/1 * * * ?
14 18
15 #推送地址 19 #推送地址
16 api: 20 api:
......