生产单管理-api导入列表修改

This commit is contained in:
lym
2024-07-10 10:00:06 +08:00
parent c1ed17a672
commit efe85a5d86
3 changed files with 34 additions and 14 deletions
@@ -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<List<ApiOrderRespVO>> 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));
}
}
@@ -550,8 +550,8 @@ public class OrderServiceImpl implements OrderService {
@Override
public List<ApiOrderRespVO> getApiOrderList(JSONObject orderList) {
List<ApiOrderRespVO> 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");
@@ -33,7 +33,7 @@ public class ApiDataAchieve {
private static final int PARTS_PAGE_MAX = 100;
// 获得token数据
public String getApiToken(Long organId) {
public Future<JSONObject> 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<JSONObject> getApiOrderList(String token,String create_date_min, String create_date_max) {
public Future<JSONObject> 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);
}