zss
2023-09-24 7930d685829d7cc1e743e9a4cd9bd3924ad953fb
inventory-server/src/main/java/com/yuanchu/mom/Task/SyncOrder.java
@@ -17,28 +17,34 @@
 */
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 String IFS_URL="http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_POL_RECEIPT_STD&userId=mes_user&inAttr={\"ORDER_NO\":\"-2050314\"}";
    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)//表单内容
@@ -47,26 +53,53 @@
        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;
    }
    /**
     * ifs
     * @return
     */
    public static List<Map<String, Object>>ifsInterfaces(){
        String result = HttpRequest.get(IFS_URL)
                .header("Authorization", "Bearer " + getToken())
                .execute().body();
        Map<String, Object>map=JsonUtil.jsonToPojo(result,Map.class);
        return JsonUtil.jsonToPojo(JsonUtil.jsonToString(map.get("LIST_INFO")),List.class);
    }
}