From 9b1437c9bcec2130ee67e43575fcde517f71f9ce Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期四, 26 三月 2026 10:23:46 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/task/OrderSyncScheduler.java | 87 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java b/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java
index 61004e9..0b1ca17 100644
--- a/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java
+++ b/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java
@@ -1,19 +1,29 @@
package com.zy.asrs.task;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.core.common.Cools;
+import com.core.exception.CoolException;
+import com.zy.asrs.entity.DocType;
import com.zy.asrs.entity.Order;
+import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.service.ApiLogService;
+import com.zy.asrs.service.DocTypeService;
+import com.zy.asrs.service.OrderDetlService;
import com.zy.asrs.service.OrderService;
import com.zy.asrs.task.core.ReturnT;
-import com.zy.asrs.task.handler.OrderSyncHandler;
import com.zy.common.entity.Parameter;
+import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Created by vincent on 2020/7/7
@@ -23,9 +33,11 @@
public class OrderSyncScheduler {
@Autowired
- private OrderSyncHandler orderSyncHandler;
- @Autowired
private OrderService orderService;
+ @Autowired
+ private OrderDetlService orderDetlService;
+ @Autowired
+ private DocTypeService docTypeService;
@Autowired
private ApiLogService apiLogService;
@@ -45,12 +57,77 @@
if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) {
List<Order> orders = orderService.selectComplete();
for (Order order : orders) {
- ReturnT<String> result = orderSyncHandler.start(order);
+ ReturnT<String> result = reportToMesOrderReport(order);
if (!result.isSuccess()) {
- log.error("鍗曟嵁[orderNo={}]涓婃姤erp澶辫触", order.getOrderNo());
+ log.error("鍗曟嵁[orderNo={}]涓婃姤澶辫触锛歿}", order.getOrderNo(), result.getMsg());
}
}
}
}
+ private ReturnT<String> reportToMesOrderReport(Order order) {
+ if (order == null) {
+ return new ReturnT<>(ReturnT.SUCCESS_CODE, "SUCCESS");
+ }
+
+ DocType docType = docTypeService.selectById(order.getDocType());
+ if (docType == null) {
+ return new ReturnT<>(ReturnT.SUCCESS_CODE, "SUCCESS");
+ }
+
+ String wkType = docType.getDocName();
+ List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId());
+
+ String uri = "localhost:8889";
+ String path = "/lfdwms/open/asrs/MES/orderReport";
+ String url = "http://" + uri + path;
+
+ Map<String, Object> payload = new HashMap<>();
+ payload.put("orderNo", order.getOrderNo());
+ payload.put("warehouseId", null);
+ payload.put("wkType", wkType);
+ payload.put("orderDetls", orderDetls);
+ String requestJson = JSON.toJSONString(payload);
+
+ String response = "";
+ boolean success = false;
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(uri)
+ .setPath(path)
+ .setJson(requestJson)
+ .build()
+ .doPost();
+ JSONObject json = JSON.parseObject(response);
+ Integer code = json == null ? null : json.getInteger("code");
+ success = code != null && code == 200;
+ if (!success) {
+ String msg = json == null ? null : json.getString("msg");
+ throw new CoolException(!Cools.isEmpty(msg) ? msg : "鎺ュ彛杩斿洖澶辫触锛�" + response);
+ }
+ if (!orderService.updateSettle(order.getId(), 6L, null)) {
+ throw new CoolException("鏇存柊鍗曟嵁鐘舵�佸け璐�");
+ }
+ return new ReturnT<>(ReturnT.SUCCESS_CODE, "SUCCESS");
+ } catch (IOException e) {
+ return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
+ } catch (Exception e) {
+ return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
+ } finally {
+ try {
+ apiLogService.save(
+ "MES璁㈠崟涓婃姤",
+ url,
+ null,
+ "127.0.0.1",
+ requestJson,
+ response,
+ success
+ );
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ }
+
}
--
Gitblit v1.9.1