//package com.stylefeng.guns.modular.system.utils;
|
//
|
//import cn.hutool.http.HttpRequest;
|
//import cn.hutool.http.HttpResponse;
|
//import com.alibaba.fastjson.JSONObject;
|
//import com.fasterxml.jackson.databind.JsonNode;
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
//import com.stylefeng.guns.core.util.ToolUtil;
|
//import com.stylefeng.guns.modular.system.warpper.TerminaleDataWarpper;
|
//
|
//import java.io.IOException;
|
//import java.util.ArrayList;
|
//import java.util.Arrays;
|
//import java.util.List;
|
//import java.util.stream.Collectors;
|
//
|
///**
|
// * <p>
|
// * 码头-车场-客户 运输状态 第三方接口获取数据 APM码头——Import Availability
|
// *
|
// * </p>
|
// *
|
// * @Author: lisy
|
// * @date: 2023-05-18 16:52
|
// * @Description:
|
// */
|
//
|
//public class TerminalInterfaceAcquisitionUtil {
|
//
|
// //Sandbox Interface
|
// private static final String url = "https://api-sandbox.apmterminals.com/import-availability";
|
//
|
// //Production Interface
|
// private static final String proUrl = "https://api.apmterminals.com/import-availability";
|
// private static final String auth_url = "https://api.apmterminals.com/oauth/client_credential/accesstoken";
|
//
|
// private static final String KEY = "di3RgCcM9zlgb5BG1UiYSIxwYdmYUxTo";
|
// private static final String SECRET = "AIJczPxBeocsEjtI";
|
// private static String bearerToken = "5dDHq3LwPW3EYZ6rtPGK0zqWsRA5";
|
//
|
//
|
// /**
|
// *
|
// * @param containerId 容器id
|
// * @param enums 设施编码
|
// * @return
|
// */
|
// public static TerminaleDataWarpper getTerminalStatus(String containerId,String enums){
|
// String us = url+ "?assetId="+containerId+"&facilityCode="+enums;
|
// HttpResponse execute = HttpRequest.get(us).header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36")
|
// .header("cookie", "_ga=GA1.2.1226281326.1675309614; _gid=GA1.2.1467106222.1675309614; _ga=GA1.4.1226281326.1675309614; _gid=GA1.4.1467106222.1675309614; AWSALB=1bWqINVI+LJP87FTEXfEw1Ob1nkbr+I4baSbUGUmu5+/LdiqL9ic04Nj7F0Vz3rvharAG7a8dVe3MX6YMNEbUINVr++CCv/UBw6JeCRS0PcbRLxK7wVHb1lPT8Jl; AWSALBCORS=1bWqINVI+LJP87FTEXfEw1Ob1nkbr+I4baSbUGUmu5+/LdiqL9ic04Nj7F0Vz3rvharAG7a8dVe3MX6YMNEbUINVr++CCv/UBw6JeCRS0PcbRLxK7wVHb1lPT8Jl")
|
// .header("path", "?assetId=" + containerId + "&facilityCode=" + enums)
|
// .header("Authorization", "Bearer " + bearerToken)
|
// .execute();
|
// String body = execute.body();
|
// int status = execute.getStatus();
|
// if (status != 200){
|
// getAuth();
|
// getTerminalStatus(containerId,enums);
|
// }
|
// ObjectMapper objectMapper = new ObjectMapper();
|
// JsonNode jsonArray = null;
|
// TerminaleDataWarpper warpper = new TerminaleDataWarpper();
|
// try {
|
// jsonArray = objectMapper.readTree(body);
|
// for (JsonNode jsonNode : jsonArray) {
|
// String appointmentDateTimeLocal = jsonNode.get("appointmentDateTimeLocal").asText();
|
// warpper.setLfd(appointmentDateTimeLocal);
|
// String appointmentNumber = jsonNode.get("containerId").asText();
|
// warpper.setAppointmentNumber(appointmentNumber);
|
// String containerHolds = jsonNode.get("containerHolds").asText();
|
// List<String> collect = new ArrayList<>();
|
// if (ToolUtil.isEmpty(containerHolds)){
|
// return warpper;
|
// }
|
// if (containerHolds.contains(",")){
|
// String[] split = containerHolds.split(",");
|
// collect = Arrays.stream(split).collect(Collectors.toList());
|
// if (collect.contains("LINE")){
|
// warpper.setLineHold(1);
|
// }
|
// if (collect.contains("TMF")){
|
// warpper.setCustomHold(1);
|
// }
|
// if (collect.contains("PIER")){
|
// warpper.setPierpass(1);
|
// }
|
// if (collect.contains("CTF")){
|
// warpper.setCtf(1);
|
// }
|
// if (collect.contains("AREA")){
|
// warpper.setClosedArea(1);
|
// }
|
// }else {
|
// if (containerHolds.equals("LINE")){
|
// warpper.setLineHold(1);
|
// }
|
// if (containerHolds.equals("TMF")){
|
// warpper.setCustomHold(1);
|
// }
|
// if (containerHolds.equals("PIER")){
|
// warpper.setPierpass(1);
|
// }
|
// if (containerHolds.equals("CTF")){
|
// warpper.setCtf(1);
|
// }
|
// if (containerHolds.equals("AREA")){
|
// warpper.setClosedArea(1);
|
// }
|
// }
|
// }
|
//
|
//
|
// } catch (IOException e) {
|
// throw new RuntimeException(e);
|
// }
|
// return warpper;
|
// }
|
//
|
//
|
// public static void getAuth(){
|
// String us = auth_url+ "?grant_type=client_credentials";
|
// String body = HttpRequest.post(us)
|
// .form("client_id", KEY)
|
// .form("client_id", SECRET)
|
// .execute().body();
|
// JSONObject object = JSONObject.parseObject(body);
|
// Object o = object.get("access_token");
|
// if (ToolUtil.isNotEmpty(o)){
|
// bearerToken = (String) o;
|
// }
|
// }
|
//
|
//
|
//}
|