diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java index e79ff7f50..c42bce48a 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java @@ -225,7 +225,7 @@ public class OrderController { throws InterruptedException, ExecutionException { Long organId = SecurityFrameworkUtils.getLoginUser().getOrganId(); - String token = apiDataAchieve.getApiToken(organId); + String token = apiDataAchieve.getApiToken(organId).get().getJSONObject("info").getString("access_token"); JSONObject dataPlates = apiDataAchieve.getApiPlateProData(token, orderNo).get(); if (!dataPlates.getString("err_code").equals("0")) { throw exception(PLATE_PLAN_DATA_ERROR); @@ -348,15 +348,21 @@ public class OrderController { @Operation(summary = "获取api订单接口") @Parameters({ @Parameter(name = "startTime", description = "开始时间", required = false), - @Parameter(name = "endTime", description = "结束时间", required = false) + @Parameter(name = "endTime", description = "结束时间", required = false), + @Parameter(name = "orderNo", description = "订单号", required = false), + @Parameter(name = "customOrderNo", description = "自定义单号", required = false) }) @PreAuthorize("@ss.hasPermission('production:manager-list:detail')") public CommonResult> getApiOrder(@RequestParam(value = "startTime", required = false) String startTime, - @RequestParam(value = "endTime", required = false) String endTime) + @RequestParam(value = "endTime", required = false) String endTime, + @RequestParam(value = "orderNo", required = false) String orderNo, + @RequestParam(value = "customOrderNo", required = false) String customOrderNo) throws ExecutionException, InterruptedException { Long organId = SecurityFrameworkUtils.getLoginUser().getOrganId(); - String token = apiDataAchieve.getApiToken(organId); - JSONObject orderList = apiDataAchieve.getApiOrderList(token,startTime,endTime).get(); + JSONObject oauth = apiDataAchieve.getApiToken(organId).get(); + String token = oauth.getJSONObject("info").getString("access_token"); + String shopId = oauth.getJSONObject("info").getString("shop_id"); + JSONObject orderList = apiDataAchieve.getApiOrderList(token,shopId,startTime,endTime,orderNo,customOrderNo).get(); return success(orderService.getApiOrderList(orderList)); } } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java index 7a3ec48ac..f9d4c8207 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java @@ -550,8 +550,8 @@ public class OrderServiceImpl implements OrderService { @Override public List getApiOrderList(JSONObject orderList) { List apiOrderRespVOS = new ArrayList<>(); - if (orderList != null){ - JSONArray jsonArray = orderList.getJSONArray("data"); + JSONArray jsonArray = orderList.getJSONArray("data"); + if (jsonArray != null && jsonArray.size() > 0){ for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); int index = jsonObject.getString("order_no").indexOf("@N"); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java index d8db2a0fc..0ad27ab88 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java @@ -33,7 +33,7 @@ public class ApiDataAchieve { private static final int PARTS_PAGE_MAX = 100; // 获得token数据 - public String getApiToken(Long organId) { + public Future getApiToken(Long organId) { JSONObject app = applicationApi.getApplicationByOrganId(organId); String appId = app.getString("appId"); String appSecret = app.getString("appSecret"); @@ -42,8 +42,8 @@ public class ApiDataAchieve { if (!json.getString("err_msg").equals("success")) { throw exception(APP_TOKEN_ERROR); } - String token = json.getJSONObject("info").getString("access_token"); - return token; +// String token = json.getJSONObject("info").getString("access_token"); + return new AsyncResult<>(json); } // 获取板件生产数据信息 @@ -168,14 +168,28 @@ public class ApiDataAchieve { } // 订单列表 - public Future getApiOrderList(String token,String create_date_min, String create_date_max) { + public Future getApiOrderList(String token,String shopId,String createDateMin, String createDateMax, String orderNo, String customOrderNo) { JSONObject jsonOrders = new JSONObject(); - jsonOrders.put("create_date_min", create_date_min); - jsonOrders.put("create_date_max", create_date_max); + if (createDateMin != null){ + jsonOrders.put("create_date_min", createDateMin); + } + if (createDateMax != null) { + jsonOrders.put("create_date_max", createDateMax); + } + jsonOrders.put("curr_page", 1); jsonOrders.put("page_count", PARTS_PAGE_MAX); + + if (orderNo != null) { + jsonOrders.put("order_no", shopId + "@N" +orderNo); + } + if (customOrderNo != null){ + jsonOrders.put("custom_order_no", customOrderNo); + } + JSONObject orders = apiDataProduction.getApiOrderList(token, jsonOrders); - System.out.println(); + System.out.println(" jsonOrders " + jsonOrders); + System.out.println(" orders " + orders); if (!orders.getString("err_code").equals("0")) { throw exception(ORDER_READ_ERR); }