tao.mo

API代码提交

mt
2021年8月4日17:32:04
......@@ -32,4 +32,11 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo
@Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE = ?1 and CREATE_TIME>= ?2" )
public ChmConsignment findChmConsignmentByConsignmentCode(String consignmentCode,Date startDate);
/**
* 根据运单ID查运单
* @param id
* @return
*/
@Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where ID = ?1 " )
public ChmConsignment findChmConsignmentById(Long id);
}
......
package com.erry.iclear.dateInterface.repository;
import com.erry.iclear.dateInterface.entity.DeclearTask;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author Administrator
*/
@Repository
public interface DeclearTaskRepository extends JpaSpecificationExecutor<DeclearTask>, JpaRepository<DeclearTask, Long> {
/**
* 根据运单号集合+创建时间 运单
* @return
*/
@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" )
public List<DeclearTask> findDeclearTask();
}
......@@ -26,7 +26,7 @@ public interface ReceiptMessageRepository extends JpaSpecificationExecutor<Recei
* @param
* @return
*/
@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")
@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")
public List<ReceiptMessage> findReceiptMessageList();
@Modifying(clearAutomatically = false)
......
......@@ -7,6 +7,8 @@ import com.erry.iclear.dateInterface.api.request.ReceiptMessage;
import com.erry.iclear.dateInterface.api.response.TokenResult;
import com.erry.iclear.dateInterface.common.Constants;
import com.erry.iclear.dateInterface.entity.DeclearTask;
import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
import com.erry.iclear.dateInterface.repository.DeclearTaskRepository;
import com.erry.iclear.dateInterface.repository.ReceiptMessageRepository;
import com.erry.iclear.dateInterface.util.JsonToJava;
import lombok.extern.slf4j.Slf4j;
......@@ -44,6 +46,12 @@ public class ApiService {
@Autowired
ReceiptMessageRepository receiptMessageRepository;
@Autowired
DeclearTaskRepository declearTaskRepository;
@Autowired
ChmConsignmentRepository consignmentRepository;
/**
* 获取token信息
* @return
......@@ -83,12 +91,21 @@ public class ApiService {
* @throws Exception
*/
public void pushCustoms(String token){
//获取海关回执数据
List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageList();
this.sendCustoms(token,receiptMessageList);
}
/**
* 将海关回执数据发送至西门子
* @param token
* @param receiptMessageList
*/
public void sendCustoms(String token ,List<ReceiptMessage> receiptMessageList){
Header[] headers = HttpHeader.custom()
.other("Content-Type", "application/json")
.other("Authorization", token)
.build();
//获取海关回执数据
List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageList();
List<DeclearTask> declearTaskList = new ArrayList<DeclearTask>();
receiptMessageList.forEach(d->{
DeclearTask declearTask = new DeclearTask();
......@@ -153,6 +170,14 @@ public class ApiService {
.other("Authorization", token)
.build();
//获取海关回执数据
try{
List<DeclearTask> declearTaskList = declearTaskRepository.findDeclearTask();
declearTaskList.forEach(declearTask -> {
Long consignmentId = declearTask.getChmsignmentId().longValue();
consignmentRepository.findChmConsignmentById(consignmentId);
});
}catch(Exception ex){
ex.printStackTrace();
}
}
}
......