Showing
4 changed files
with
57 additions
and
4 deletions
| ... | @@ -32,4 +32,11 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo | ... | @@ -32,4 +32,11 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo |
| 32 | @Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE = ?1 and CREATE_TIME>= ?2" ) | 32 | @Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE = ?1 and CREATE_TIME>= ?2" ) |
| 33 | public ChmConsignment findChmConsignmentByConsignmentCode(String consignmentCode,Date startDate); | 33 | public ChmConsignment findChmConsignmentByConsignmentCode(String consignmentCode,Date startDate); |
| 34 | 34 | ||
| 35 | + /** | ||
| 36 | + * 根据运单ID查运单 | ||
| 37 | + * @param id | ||
| 38 | + * @return | ||
| 39 | + */ | ||
| 40 | + @Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where ID = ?1 " ) | ||
| 41 | + public ChmConsignment findChmConsignmentById(Long id); | ||
| 35 | } | 42 | } | ... | ... |
| 1 | +package com.erry.iclear.dateInterface.repository; | ||
| 2 | + | ||
| 3 | +import com.erry.iclear.dateInterface.entity.DeclearTask; | ||
| 4 | +import org.springframework.data.jpa.repository.JpaRepository; | ||
| 5 | +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 6 | +import org.springframework.data.jpa.repository.Query; | ||
| 7 | +import org.springframework.stereotype.Repository; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @author Administrator | ||
| 12 | + */ | ||
| 13 | +@Repository | ||
| 14 | +public interface DeclearTaskRepository extends JpaSpecificationExecutor<DeclearTask>, JpaRepository<DeclearTask, Long> { | ||
| 15 | + /** | ||
| 16 | + * 根据运单号集合+创建时间 运单 | ||
| 17 | + * @return | ||
| 18 | + */ | ||
| 19 | + @Query( nativeQuery = true,value ="SELECT * FROM T_DECLEAR_TASK WHERE FILE_TYPE = 1 AND PUSH_NUMBER < 3 AND (RESPONSE_RESULTS IS NULL OR RESPONSE_RESULTS <> '0') ORDER BY OPERATION_TIME ASC" ) | ||
| 20 | + public List<DeclearTask> findDeclearTask(); | ||
| 21 | +} |
| ... | @@ -26,7 +26,7 @@ public interface ReceiptMessageRepository extends JpaSpecificationExecutor<Recei | ... | @@ -26,7 +26,7 @@ public interface ReceiptMessageRepository extends JpaSpecificationExecutor<Recei |
| 26 | * @param | 26 | * @param |
| 27 | * @return | 27 | * @return |
| 28 | */ | 28 | */ |
| 29 | - @Query(nativeQuery = true, value = "SELECT TOP 1 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 IS NULL OR RESPONSE_RESULTS <> '0') ORDER BY RM.NOTICE_DATE ASC") | 29 | + @Query(nativeQuery = true, value = "SELECT TOP 10 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 IS NULL OR RESPONSE_RESULTS <> '0') ORDER BY RM.NOTICE_DATE ASC") |
| 30 | public List<ReceiptMessage> findReceiptMessageList(); | 30 | public List<ReceiptMessage> findReceiptMessageList(); |
| 31 | 31 | ||
| 32 | @Modifying(clearAutomatically = false) | 32 | @Modifying(clearAutomatically = false) | ... | ... |
| ... | @@ -7,6 +7,8 @@ import com.erry.iclear.dateInterface.api.request.ReceiptMessage; | ... | @@ -7,6 +7,8 @@ import com.erry.iclear.dateInterface.api.request.ReceiptMessage; |
| 7 | import com.erry.iclear.dateInterface.api.response.TokenResult; | 7 | import com.erry.iclear.dateInterface.api.response.TokenResult; |
| 8 | import com.erry.iclear.dateInterface.common.Constants; | 8 | import com.erry.iclear.dateInterface.common.Constants; |
| 9 | import com.erry.iclear.dateInterface.entity.DeclearTask; | 9 | import com.erry.iclear.dateInterface.entity.DeclearTask; |
| 10 | +import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; | ||
| 11 | +import com.erry.iclear.dateInterface.repository.DeclearTaskRepository; | ||
| 10 | import com.erry.iclear.dateInterface.repository.ReceiptMessageRepository; | 12 | import com.erry.iclear.dateInterface.repository.ReceiptMessageRepository; |
| 11 | import com.erry.iclear.dateInterface.util.JsonToJava; | 13 | import com.erry.iclear.dateInterface.util.JsonToJava; |
| 12 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| ... | @@ -44,6 +46,12 @@ public class ApiService { | ... | @@ -44,6 +46,12 @@ public class ApiService { |
| 44 | @Autowired | 46 | @Autowired |
| 45 | ReceiptMessageRepository receiptMessageRepository; | 47 | ReceiptMessageRepository receiptMessageRepository; |
| 46 | 48 | ||
| 49 | + @Autowired | ||
| 50 | + DeclearTaskRepository declearTaskRepository; | ||
| 51 | + | ||
| 52 | + @Autowired | ||
| 53 | + ChmConsignmentRepository consignmentRepository; | ||
| 54 | + | ||
| 47 | /** | 55 | /** |
| 48 | * 获取token信息 | 56 | * 获取token信息 |
| 49 | * @return | 57 | * @return |
| ... | @@ -83,12 +91,21 @@ public class ApiService { | ... | @@ -83,12 +91,21 @@ public class ApiService { |
| 83 | * @throws Exception | 91 | * @throws Exception |
| 84 | */ | 92 | */ |
| 85 | public void pushCustoms(String token){ | 93 | public void pushCustoms(String token){ |
| 94 | + //获取海关回执数据 | ||
| 95 | + List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageList(); | ||
| 96 | + this.sendCustoms(token,receiptMessageList); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * 将海关回执数据发送至西门子 | ||
| 101 | + * @param token | ||
| 102 | + * @param receiptMessageList | ||
| 103 | + */ | ||
| 104 | + public void sendCustoms(String token ,List<ReceiptMessage> receiptMessageList){ | ||
| 86 | Header[] headers = HttpHeader.custom() | 105 | Header[] headers = HttpHeader.custom() |
| 87 | .other("Content-Type", "application/json") | 106 | .other("Content-Type", "application/json") |
| 88 | .other("Authorization", token) | 107 | .other("Authorization", token) |
| 89 | .build(); | 108 | .build(); |
| 90 | - //获取海关回执数据 | ||
| 91 | - List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageList(); | ||
| 92 | List<DeclearTask> declearTaskList = new ArrayList<DeclearTask>(); | 109 | List<DeclearTask> declearTaskList = new ArrayList<DeclearTask>(); |
| 93 | receiptMessageList.forEach(d->{ | 110 | receiptMessageList.forEach(d->{ |
| 94 | DeclearTask declearTask = new DeclearTask(); | 111 | DeclearTask declearTask = new DeclearTask(); |
| ... | @@ -153,6 +170,14 @@ public class ApiService { | ... | @@ -153,6 +170,14 @@ public class ApiService { |
| 153 | .other("Authorization", token) | 170 | .other("Authorization", token) |
| 154 | .build(); | 171 | .build(); |
| 155 | //获取海关回执数据 | 172 | //获取海关回执数据 |
| 156 | - | 173 | + try{ |
| 174 | + List<DeclearTask> declearTaskList = declearTaskRepository.findDeclearTask(); | ||
| 175 | + declearTaskList.forEach(declearTask -> { | ||
| 176 | + Long consignmentId = declearTask.getChmsignmentId().longValue(); | ||
| 177 | + consignmentRepository.findChmConsignmentById(consignmentId); | ||
| 178 | + }); | ||
| 179 | + }catch(Exception ex){ | ||
| 180 | + ex.printStackTrace(); | ||
| 181 | + } | ||
| 157 | } | 182 | } |
| 158 | } | 183 | } | ... | ... |
-
Please register or login to post a comment