From c0fd850e6e76f1f66d9ea10aff91153fb3253e7f Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" <123456> Date: Sun, 1 Oct 2023 22:28:48 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=BF=97=E9=82=A6=E6=8E=A8=E9=80=81=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E7=BB=93=E6=9E=9C=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zb/entity/ZbOrderPackageEntity.java | 3 ++ .../service/impl/AsyncDataServiceImpl.java | 31 +++++++++++++-- .../factory/receiver/OrderStatusHandler.java | 16 ++++---- .../impl/ZbFactoryDataServiceImpl.java | 38 ++++++++++++++++--- 4 files changed, 70 insertions(+), 18 deletions(-) diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/zb/entity/ZbOrderPackageEntity.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/zb/entity/ZbOrderPackageEntity.java index 119ef5958..e126d542b 100644 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/zb/entity/ZbOrderPackageEntity.java +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/zb/entity/ZbOrderPackageEntity.java @@ -189,5 +189,8 @@ public class ZbOrderPackageEntity extends BaseEntity { @ApiModelProperty(name = "预留5", notes = "") private String reserve5; + //2023-09-30 00:20:00 +// @ApiModelProperty(name = "入库扫描状态", notes = "") +// private Integer rukuScanStatus; } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java index 9d1973865..979510dbb 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java @@ -851,6 +851,22 @@ public class AsyncDataServiceImpl implements IAsyncDataService { return advanceEntity; } + /** + * 获取订单对象 加入了缓存 + * + * @param orderSelfNum + * @return + */ + private AdvanceEntity findAdvanceEntityUseCacheByOrderSelfNumAndReceiptId(Long receiptId,String orderSelfNum,String departCode) { + String key = AdvanceEntity.class.getName() + ":"+receiptId + orderSelfNum + ":" + departCode; + AdvanceEntity advanceEntity = bladeRedis.get(key); +// if (ObjectUtils.isNull(advanceEntity)) { +//// advanceEntity = iAdvanceClient.getEntityByMctsTruck(orderSelfNum,departCode); +//// bladeRedis.setEx(key, advanceEntity, 12 * 60 * 60L); +// } + return advanceEntity; + } + private AdvanceEntity saveAdvanceInfor(ZbOrderPackageEntity serviceNumEntity, List zbOrderPackageEntityList) { Long orderId = serviceNumEntity.getId(); log.info("#########handlerDataToHt: 当前处理的订单id={}", orderId); @@ -858,14 +874,15 @@ public class AsyncDataServiceImpl implements IAsyncDataService { // 查询订单对应的发货单 ZbReceiptEntity zbReceiptEntity = findZbReceiptEntityUseCacheById(serviceNumEntity.getReceiptId()); - AdvanceEntity advanceEntity = findAdvanceEntityUseCacheByOrderSelfNum(serviceNumEntity.getRelationOrderCode(),zbReceiptEntity.getDepartCode()); + AdvanceEntity advanceEntity = findAdvanceEntityUseCacheByOrderSelfNumAndReceiptId(serviceNumEntity.getReceiptId(),serviceNumEntity.getRelationOrderCode(),zbReceiptEntity.getDepartCode()); if (ObjectUtils.isNotNull(advanceEntity)) { return advanceEntity; } //添加订单信息 - advanceEntity = new AdvanceEntity(); + advanceEntity = new AdvanceEntity(); + advanceEntity.setOrderSelfNum(StringUtil.isBlank(serviceNumEntity.getRelationOrderCode()) ? "" : serviceNumEntity.getRelationOrderCode()); //订单自编号 advanceEntity.setSiteName(""); // 基地 advanceEntity.setArea(""); // 区域 @@ -889,8 +906,8 @@ public class AsyncDataServiceImpl implements IAsyncDataService { advanceEntity.setCustomerPhone(StringUtil.isBlank(serviceNumEntity.getReceiverMobile()) ? "" : serviceNumEntity.getReceiverMobile()); // 顾客电话 advanceEntity.setCustomerRoad(StringUtil.isBlank(serviceNumEntity.getReceiverAddress()) ? "" : serviceNumEntity.getReceiverAddress());//顾客地址 advanceEntity.setSystemType("线上"); //订单类型 - advanceEntity.setStoreNo(""); //门店编码 - advanceEntity.setStoreName(""); //门店名称 + advanceEntity.setStoreNo(StringUtil.isBlank(serviceNumEntity.getCustomerCode()) ? "" : serviceNumEntity.getCustomerCode()); //门店编码 + advanceEntity.setStoreName(serviceNumEntity.getCustomerName()); //门店名称 advanceEntity.setSerialKey(""); //序列号 advanceEntity.setServiceNum(StringUtil.isBlank(serviceNumEntity.getPlatformOrderCode()) ? "" : serviceNumEntity.getPlatformOrderCode()); //服务号 advanceEntity.setMatingCode("");//齐套模式 可以为空 @@ -915,6 +932,12 @@ public class AsyncDataServiceImpl implements IAsyncDataService { advanceEntity.setDeleteAdministratorsId(0);//删除用户 Integer advanceId = iAdvanceClient.addAdvanceClient(advanceEntity); advanceEntity.setId(advanceId); + + String key = AdvanceEntity.class.getName() + ":"+serviceNumEntity.getReceiptId() + serviceNumEntity.getRelationOrderCode() + ":" + zbReceiptEntity.getDepartCode(); + // 加入缓存 1小时的缓存 + bladeRedis.setEx(key, advanceEntity, 60*60L); + + return advanceEntity; } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java index 4526e28a5..4b95f33f6 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java @@ -96,14 +96,14 @@ public class OrderStatusHandler { } break; case FactoryConstant.ZHIBANG: -// r = zbFactoryDataService.handleStatusData(orderStatusDTO); -// int resultCode = r.getCode(); -// if (resultCode == 400 || resultCode == 200) { -// log.info("##################orderStatusHandler: 该条数据不用处理 orderNo={}", orderSelfNum); -//// channel.basicAck(deliveryTag,true); -// } else { -// throw new CustomerException(resultCode, r.getMsg()); -// } + r = zbFactoryDataService.handleStatusData(orderStatusDTO); + int resultCode = r.getCode(); + if (resultCode == 400 || resultCode == 200) { + log.info("##################orderStatusHandler: 该条数据不用处理 orderNo={}", orderSelfNum); +// channel.basicAck(deliveryTag,true); + } else { + throw new CustomerException(resultCode, r.getMsg()); + } break; default: log.info("##################orderStatusHandler: 未知品牌 type={}", type); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/impl/ZbFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/impl/ZbFactoryDataServiceImpl.java index 49da75500..a4fd0b288 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/impl/ZbFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/zb/service/impl/ZbFactoryDataServiceImpl.java @@ -149,15 +149,35 @@ public class ZbFactoryDataServiceImpl implements IZbFactoryDataService { return Resp.fail(400, "发车单信息不存在"); } + //2023-09-30 00:20:00查询入库单对应的所有包件 +// QueryWrapper queryWrapper1 = new QueryWrapper<>(); +// queryWrapper1.eq("receipt_id",receiptId); +// List details = orderPackageService.list(queryWrapper1); + //查询拼接body + JSONArray detailsArray = new JSONArray(); JSONObject detailObject = new JSONObject(); detailObject.put("lineNo",orderPackageEntity.getLineNo()); detailObject.put("packageCode",orderPackageEntity.getPackageCode()); - detailObject.put("inventoryStatus","已入库"); + detailObject.put("inventoryStatus",orderPackageEntity.getInventoryStatus()); detailObject.put("qty",orderPackageEntity.getPlanQty()); detailObject.put("scanFlag",1); - JSONArray detailsArray = new JSONArray(); detailsArray.add(detailObject); +// for(ZbOrderPackageEntity entity:details){ +// String packageCode = entity.getPackageCode(); +// if(unitNo.equals(packageCode)){ +// entity.setRukuScanStatus(1); +// orderPackageService.updateById(entity); +// } +// JSONObject detailObject = new JSONObject(); +// detailObject.put("lineNo",entity.getLineNo()); +// detailObject.put("packageCode",packageCode); +// detailObject.put("inventoryStatus",entity.getInventoryStatus()); +// detailObject.put("qty",entity.getPlanQty()); +// detailObject.put("scanFlag",entity.getRukuScanStatus()); +// detailsArray.add(detailObject); +// } + JSONObject result = new JSONObject(); result.put("taskCode",receiptEntity.getTaskCode()); result.put("companyCode",receiptEntity.getCompanyCode()); @@ -165,6 +185,7 @@ public class ZbFactoryDataServiceImpl implements IZbFactoryDataService { result.put("inWmsTime",operationTime); result.put("orderType",receiptEntity.getOrderType()); result.put("bizCode",CommonUtil.getUUID()); + result.put("details",detailsArray); Map params = new HashMap<>(); @@ -181,15 +202,18 @@ public class ZbFactoryDataServiceImpl implements IZbFactoryDataService { log.info("################### secretkey={}",zbFactoryProperties.getSecretkey()); log.info("################### signMethod={}","md5"); String body = result.toJSONString(); + log.info(">################### 格式化之前 body={}",body); String s = body.replaceAll("\\s+", ""); + log.info(">################### 格式化之后 body={}",s); String sign = QmSignUntil.signTopRequest(params, zbFactoryProperties.getSecretkey(), "md5", s); String url = getZbUrl(zbFactoryProperties.getUrl()+"/api/edi/ots/in?",params,sign); - R r = sendZbFactoryData(url, s, 1, unitNo); + log.info("################### url={}",url); + R r = sendZbFactoryData(url, body, 1, unitNo); return r; }catch (Exception e){ - log.error("#################handleStatusData: 推送失败",e); + log.error("#################handleStatusData by zb: 推送失败 {}",e.getMessage()); return R.fail(500,"推送失败"); } } @@ -206,7 +230,7 @@ public class ZbFactoryDataServiceImpl implements IZbFactoryDataService { array[0] = key; array[1] = value; if (areNotEmpty(array)) { - stringBuilder.append(key).append("=").append(value); + stringBuilder.append(key).append("=").append(value).append("&"); } } stringBuilder.append("sign=").append(sign); @@ -259,9 +283,11 @@ public class ZbFactoryDataServiceImpl implements IZbFactoryDataService { private R sendZbFactoryData(String url, String data, Integer type,String refCode) throws NoSuchAlgorithmException { - log.info("##############sendZbFactoryData 发送数据: {}", data); //处理逻辑 + log.info("##############sendZbFactoryData url: {}", url); + log.info("##############sendZbFactoryData 发送数据: {}", data); + String result = HttpRequest.post(url) .header("Content-Type", "application/json") .body(data).timeout(5 * 1000)