| | |
| | | */ |
| | | public class SyncOrder { |
| | | |
| | | private static final String TOKEN_URL="http://192.168.18.16:9999/auth/oauth/token"; |
| | | private static final String TOKEN_URL = "http://192.168.18.16:9999/auth/oauth/token"; |
| | | |
| | | private static final String GET_ORDER_MAIN_URL="http://192.168.18.16:9999/order/otcService/getOrderInfoForHyxtMes"; |
| | | private static final String GET_ORDER_MAIN_URL = "http://192.168.18.16:9999/order/otcService/getOrderInfoForHyxtMes"; |
| | | |
| | | private static final String GET_ORDER_INNER_URL="http://192.168.18.16:9999/order/otcService/getOrderLineForHyxtMes"; |
| | | private static final String GET_ORDER_INNER_URL = "http://192.168.18.16:9999/order/otcService/getOrderLineForHyxtMes"; |
| | | |
| | | private static final Map<String, String> GET_TOKEN_HEADER=new HashMap<>(2); |
| | | private static final String GET_ATTACHMENT_BY_ORDERID = "http://192.168.18.16:9999/order/otcService/getAttachmentByOrderId/"; |
| | | |
| | | private static final Map<String, Object>USER_INFO=new HashMap<>(4); |
| | | private static final String DOWN_LOAD = "http://192.168.18.16:9999/order/otcService/download/"; |
| | | |
| | | private static final Map<String, String> GET_TOKEN_HEADER = new HashMap<>(2); |
| | | |
| | | private static final Map<String, Object> USER_INFO = new HashMap<>(4); |
| | | |
| | | static { |
| | | GET_TOKEN_HEADER.put("Authorization","Basic cGlnOnBpZw=="); |
| | | GET_TOKEN_HEADER.put("Content-Type","application/x-www-form-urlencoded"); |
| | | GET_TOKEN_HEADER.put("Authorization", "Basic cGlnOnBpZw=="); |
| | | GET_TOKEN_HEADER.put("Content-Type", "application/x-www-form-urlencoded"); |
| | | |
| | | |
| | | USER_INFO.put("username","external_interface_hyxt_mes"); |
| | | USER_INFO.put("password","uCc+u3iP83WhO2dAU+5HUkCgfINnKfrHXMT/lwI/1f0="); |
| | | USER_INFO.put("scope","server"); |
| | | USER_INFO.put("grant_type","password"); |
| | | USER_INFO.put("username", "external_interface_hyxt_mes"); |
| | | USER_INFO.put("password", "uCc+u3iP83WhO2dAU+5HUkCgfINnKfrHXMT/lwI/1f0="); |
| | | USER_INFO.put("scope", "server"); |
| | | USER_INFO.put("grant_type", "password"); |
| | | } |
| | | |
| | | private static String getToken(){ |
| | | private static String getToken() { |
| | | String body = HttpRequest.post(TOKEN_URL) |
| | | .headerMap(GET_TOKEN_HEADER, true) |
| | | .form(USER_INFO)//表单内容 |
| | |
| | | return String.valueOf(JsonUtil.jsonToPojo(body, Map.class).get("access_token")); |
| | | } |
| | | |
| | | public static List<Map<String, Object>> getMainOrder(String time){ |
| | | Map<String,Object> orderCondition = new HashMap<String,Object>(); |
| | | public static List<Map<String, Object>> getMainOrder(String time) { |
| | | Map<String, Object> orderCondition = new HashMap<String, Object>(); |
| | | orderCondition.put("selectTime", time); |
| | | String result = HttpRequest.get(GET_ORDER_MAIN_URL) |
| | | .header("Authorization", "Bearer " + getToken()) |
| | | .form(orderCondition) |
| | | .execute().body(); |
| | | List<Map<String, Object>>list = JsonUtil.jsonToPojo(JsonUtil.jsonToString(JsonUtil.jsonToPojo(result,Result.class).getData()),List.class); |
| | | return list.stream().filter(l-> Objects.equals(l.get("status"),"已下达")).collect(Collectors.toList()); |
| | | List<Map<String, Object>> list = JsonUtil.jsonToPojo(JsonUtil.jsonToString(JsonUtil.jsonToPojo(result, Result.class).getData()), List.class); |
| | | return list.stream().filter(l -> Objects.equals(l.get("status"), "已下达")).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public static List<Map<String, Object>> getInnerOrder(String time,String orderNo){ |
| | | Map<String,Object> orderCondition = new HashMap<String,Object>(); |
| | | public static List<Map<String, Object>> getInnerOrder(String time, String orderNo) { |
| | | Map<String, Object> orderCondition = new HashMap<String, Object>(); |
| | | orderCondition.put("selectTime", time); |
| | | orderCondition.put("orderNo",orderNo); |
| | | orderCondition.put("orderNo", orderNo); |
| | | String result = HttpRequest.get(GET_ORDER_INNER_URL) |
| | | .header("Authorization", "Bearer " + getToken()) |
| | | .form(orderCondition) |
| | | .execute().body(); |
| | | List<Map<String, Object>>list = JsonUtil.jsonToPojo(JsonUtil.jsonToString(JsonUtil.jsonToPojo(result,Result.class).getData()),List.class); |
| | | List<Map<String, Object>> list = JsonUtil.jsonToPojo(JsonUtil.jsonToString(JsonUtil.jsonToPojo(result, Result.class).getData()), List.class); |
| | | return list; |
| | | } |
| | | |
| | | public static List<Map<String, Object>> getAttachmentByOrderId(Integer orderId) { |
| | | String result = HttpRequest.get(GET_ATTACHMENT_BY_ORDERID + orderId) |
| | | .header("Authorization", "Bearer " + getToken()) |
| | | .execute().body(); |
| | | List<Map<String, Object>> list = JsonUtil.jsonToPojo(JsonUtil.jsonToString(JsonUtil.jsonToPojo(result, Result.class).getData()), List.class); |
| | | return list; |
| | | } |
| | | |
| | | public static String download(Integer id) { |
| | | String result = HttpRequest.get(DOWN_LOAD + id) |
| | | .header("Authorization", "Bearer " + getToken()) |
| | | .execute().body(); |
| | | return result; |
| | | } |
| | | } |