From 6868110d546c0f1b9c73b344173ab75d348001b4 Mon Sep 17 00:00:00 2001 From: lym <1994302445@qq.com> Date: Thu, 9 Jan 2025 14:54:02 +0800 Subject: [PATCH] =?UTF-8?q?api=E5=AF=BC=E5=85=A5=E6=94=B9=E5=96=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/enums/ErrorCodeConstants.java | 2 +- .../admin/order/OrderController.java | 5 ++- .../admin/api/webcad/ApiTypeRealize.java | 44 +++++++++++++------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java index 17ed7e017..9d4a34ea8 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java +++ b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java @@ -57,7 +57,7 @@ public class ErrorCodeConstants { public static final ErrorCode ORDER_STATUS_CONFLICT = new ErrorCode(1_002_029_006, "生产单状态冲突,禁止投入生产"); public static final ErrorCode ORDER_READ_ERR = new ErrorCode(1_002_029_006, "订单列表获取失败,请刷新重试"); public static final ErrorCode ORDER_DATE_ERR = new ErrorCode(1_002_029_006, "获取订单列表,时间超出范围,请在30天范围内选择"); - public static final ErrorCode ORDER_DETAIL_DATE_ERR = new ErrorCode(1_002_029_006, "板件造型数据对应有无,请重新上传"); + public static final ErrorCode ORDER_DETAIL_DATE_ERR = new ErrorCode(1_002_029_006, "板件生产数据缺失,请确认数据源中是否存在相关数据"); public static final ErrorCode SOURCE_NOT_EXITS_ERROR = new ErrorCode(1_002_029_013, "源数据查询失败"); public static final ErrorCode ORDER_DELETED_ERR = new ErrorCode(1_002_029_006, "生产单删除失败"); 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 033b2c160..881179291 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 @@ -50,6 +50,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.cf.imes.framework.common.pojo.CommonResult.error; import static com.cf.imes.framework.common.pojo.CommonResult.success; import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.IMPORT; @@ -231,7 +232,9 @@ public class OrderController { orderInputProcessor.deleteByOrderId(orderId, ORDER_PLATE_MODEL_COMPRESS); } log.error(errKey, e); - return success(e.getMessage()); + + return error(500 , e.getMessage()); + } finally { redisLockUtil.unlock(lockKey); } 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/ApiTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java index 7b7086ae2..096f1e4d7 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java @@ -109,6 +109,11 @@ public class ApiTypeRealize { ApiDataTypeVo platesData = results.get("plate").get(); + // 判断生产数据是否可以为空 + if (!platesData.getMapPlatesInfos().isEmpty() && plateDetailData.getMapPlateDetails().isEmpty() ) { + throw exception(ORDER_DETAIL_DATE_ERR); + } + // 小板数据补充,order_goods_id添加造型相关数据判断获取,以及配件中添加goods_id // 用方法实现,小板中添加其他信息,以及更新goods_id updateSmallBoardInfo(goodsData.getMapGoodsDO(), @@ -198,7 +203,7 @@ public class ApiTypeRealize { Map mapPlatesInfos, Map mapPlateDetailsRemarks) { // 第一步判断是否存在需要进行数据添加的小板 - if (mapPlatesInfos.isEmpty()) { + if (mapPlatesInfos == null || mapPlatesInfos.isEmpty()) { return; } mapPlatesInfos.forEach((k, v) -> { @@ -321,14 +326,16 @@ public class ApiTypeRealize { // System.out.println("开始2: " + System.currentTimeMillis()); JSONObject goodsMessage = apiDataAchieve.getApiGoodsMessage(token, orderNo); // 全部信息 + Map rawGoodsDOS = new HashMap<>(); + Map goodsDOS = new HashMap<>(); + JSONArray goodsLists = goodsMessage.getJSONArray(ProduceApiConstants.LIST); if (goodsLists == null || goodsLists.isEmpty()) { - throw exception(GOODS_DATA_ERROR); + return new ApiDataTypeVo().setMapRawGoodsDO(rawGoodsDOS).setMapGoodsDO(goodsDOS); } // Map map = new HashMap<>(); - Map rawGoodsDOS = new HashMap<>(); - Map goodsDOS = new HashMap<>(); + for (int i = 0; i < goodsLists.size(); i++) { @@ -401,7 +408,7 @@ public class ApiTypeRealize { JSONArray bodyLists = bodyMessage.getJSONArray(ProduceApiConstants.LIST); if (bodyLists == null || bodyLists.isEmpty()) { - return null; + return new ApiDataTypeVo(); } Map bodyInfos = new HashMap<>(); @@ -494,7 +501,7 @@ public class ApiTypeRealize { jsonParts.put(ProduceApiConstants.ORDER_NO_KEY, "N" + orderNo); if (apiDataAchieve.getApiPartsMessage(token, orderNo, jsonParts) == null) { - return null; + return new ApiDataTypeVo(); } Integer pageCount = apiDataAchieve.getApiPartsMessage(token, orderNo, jsonParts).getJSONObject(ProduceApiConstants.VALUE).getInteger(ProduceApiConstants.PAGE_COUNT); // 获取页码总数 @@ -674,19 +681,21 @@ public class ApiTypeRealize { Long organId) { // System.out.println("开始6: " + System.currentTimeMillis()); + Map plateDetails = new HashMap<>(); + JSONObject jsonPlatesDetail = apiDataAchieve.getApiPlateProData(token, orderNo); // 获取板件详情数据 if (jsonPlatesDetail.getJSONObject(ProduceApiConstants.VALUE) == null) { - return null; + return new ApiDataTypeVo().setMapPlateDetails(plateDetails); } - Map plateDetails = new HashMap<>(); + // 获取 Orders 字段对应的数组 JSONArray ordersArray = jsonPlatesDetail.getJSONObject(ProduceApiConstants.VALUE).getJSONArray(ProduceApiConstants.OPD_ORDER); if (ordersArray == null || ordersArray.isEmpty()) { - return null; + return new ApiDataTypeVo().setMapPlateDetails(plateDetails); } for (int i = 0; i < ordersArray.size(); i++) { @@ -778,11 +787,6 @@ public class ApiTypeRealize { jsonPlates.put(ProduceApiConstants.PAGE_COUNT_KEY, PARTS_PAGE_MAX); jsonPlates.put(ProduceApiConstants.ORDER_NO_KEY, "N" + orderNo); - if (apiDataAchieve.getApiPlateDetailMessage(token, orderNo, jsonPlates) == null) { - return null; - } - - Integer pageCount = apiDataAchieve.getApiPlateDetailMessage(token, orderNo, jsonPlates).getJSONObject(ProduceApiConstants.VALUE).getInteger(ProduceApiConstants.PAGE_COUNT); // 获取页码总数 // 根据总页码总数进行多线程循环 Map plateInfos = new HashMap<>(); Map> plateItem = new HashMap<>(); @@ -796,6 +800,18 @@ public class ApiTypeRealize { Map totalPlateCountMapToGroup = new HashMap<>(); Map irregularPlateCountMapToGroup = new HashMap<>(); + if (apiDataAchieve.getApiPlateDetailMessage(token, orderNo, jsonPlates) == null) { + return new ApiDataTypeVo().setMapPlatesInfos(plateInfos).setMapItemByGroup(plateItem) + .setTotalPlateCountMapToBody(totalPlateCountMapToBody) + .setIrregularPlateCountMapToBody(irregularPlateCountMapToBody) + .setTotalPlateCountMapToGroup(totalPlateCountMapToGroup) + .setIrregularPlateCountMapToGroup(irregularPlateCountMapToGroup) + .setMapPlateDetails(plateDetailMap); + } + + Integer pageCount = apiDataAchieve.getApiPlateDetailMessage(token, orderNo, jsonPlates).getJSONObject(ProduceApiConstants.VALUE).getInteger(ProduceApiConstants.PAGE_COUNT); // 获取页码总数 + + List>> futures = new ArrayList<>(); JSONObject blocksValue = apiDataAchieve.getApiBlocksMessage(token, orderNo); for (int i = 1; i <= pageCount; i++) {