From af5081bc0d0668d526a204076557a171097ddb8d Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 05 二月 2026 14:02:59 +0800
Subject: [PATCH] Merge branch 'refs/heads/rcs_master' into ctu_conveyor
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/conveyor/SiemensConveyorStationService.java | 67 ++++++++++++++++++++++++---------
1 files changed, 49 insertions(+), 18 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/conveyor/SiemensConveyorStationService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/conveyor/SiemensConveyorStationService.java
index 05a08f7..b1c184b 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/conveyor/SiemensConveyorStationService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/conveyor/SiemensConveyorStationService.java
@@ -3,24 +3,28 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zy.acs.framework.common.Cools;
+import com.zy.acs.framework.common.SnowflakeIdWorker;
import com.zy.acs.manager.common.config.ConveyorProperties;
+import com.zy.acs.manager.common.constant.Constants;
import com.zy.acs.manager.common.utils.HttpGo;
+import com.zy.acs.manager.core.domain.type.NamespaceType;
import com.zy.acs.manager.core.integrate.dto.ConveyorStaDto;
import com.zy.acs.manager.core.integrate.dto.HttpResult;
+import com.zy.acs.manager.manager.entity.IntegrationRecord;
import com.zy.acs.manager.manager.entity.Segment;
import com.zy.acs.manager.manager.entity.Sta;
import com.zy.acs.manager.manager.entity.Task;
+import com.zy.acs.manager.manager.enums.IntegrationDirectionType;
import com.zy.acs.manager.manager.enums.StaReserveType;
+import com.zy.acs.manager.manager.enums.StatusType;
+import com.zy.acs.manager.manager.service.IntegrationRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.time.Duration;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Slf4j
@Service
@@ -28,25 +32,32 @@
@Autowired
private ConveyorProperties conveyorProperties;
+ @Autowired
+ private SnowflakeIdWorker snowflakeIdWorker;
+ @Autowired
+ private IntegrationRecordService integrationRecordService;
private HttpGo http;
@PostConstruct
public void init() {
+ int timeoutSeconds = conveyorProperties.getTimeout() / 1000;
this.http = HttpGo.builder()
- .connectTimeout(Duration.ofSeconds(8))
- .readTimeout(Duration.ofSeconds(15))
+ .connectTimeout(Duration.ofSeconds(timeoutSeconds))
+ .readTimeout(Duration.ofSeconds(timeoutSeconds))
// .defaultHeader("User-Agent", "HttpGo/1.0")
- // .trustAllSsl(true) // ONLY if you really need it (self-signed internal)
+// .trustAllSsl(true) // ONLY if you really need it (self-signed internal)
.build();
}
+
@Override
public boolean allowAgvWork(Sta sta, Task task, Segment seg, StaReserveType type) {
final String staNo = sta.getStaNo();
+ Date now = new Date();
// url
- String url = this.buildUrl("/cv/station/query");
+ String url = this.http.buildUrl(conveyorProperties.getHost(), conveyorProperties.getPort(), conveyorProperties.getUrl());
// headers
Map<String, String> headers = new HashMap<>();
// params
@@ -54,10 +65,33 @@
List<String> list = new ArrayList<>();
list.add(staNo);
params.put("staNos", list);
+
+ IntegrationRecord integrationRecord = new IntegrationRecord(
+ String.valueOf(snowflakeIdWorker.nextId()).substring(3), // 缂栧彿
+ NamespaceType.RCS_TASK_REPORT.name, // 鍚嶇О绌洪棿
+ conveyorProperties.getUrl(), // 鎺ュ彛鍦板潃
+ null, // 骞冲彴瀵嗛挜
+ Constants.RCS, // 璋冪敤鏂规爣璇�
+ IntegrationDirectionType.OUTBOUND.value, // 鏂瑰悜[闈炵┖]
+ String.valueOf(now.getTime()), // 鏃堕棿鎴�
+ conveyorProperties.getHost(), // 瀹㈡埛绔疘P
+ JSON.toJSONString(params), // 璇锋眰鍐呭
+ null, // 鍝嶅簲鍐呭
+ null, // 寮傚父鍐呭
+ 0, // 缁撴灉
+ null, // 鑰楁椂
+ StatusType.ENABLE.val, // 鐘舵��
+ now, // 娣诲姞鏃堕棿[闈炵┖]
+ now, // 淇敼鏃堕棿[闈炵┖]
+ null // 澶囨敞
+ );
+
// do request
HttpResult<List<ConveyorStaDto>> result;
try {
result = postForResult(url, headers, params);
+ integrationRecord.setResponse(JSON.toJSONString(result));
+
Integer code = result.getCode();
if (null == code || 200 != code) {
return false;
@@ -94,28 +128,25 @@
return false;
}
}
+
+ integrationRecord.setResult(1);
} catch (Exception e) {
log.error("Conveyor query failed, FAIL-OPEN. staNo={}, taskId={}, type={}",
sta.getStaNo(),
task.getSeqNum(),
type,
e);
+ integrationRecord.setErr(e.getMessage());
return false;
+ } finally {
+ integrationRecord.setCostMs((int) (System.currentTimeMillis() - now.getTime()));
+ integrationRecordService.syncRecord(integrationRecord);
}
// ok
return true;
}
- private String buildUrl(String path) {
- String host = conveyorProperties.getHost();
- Integer port = conveyorProperties.getPort();
-
- String p = (path == null) ? "" : (path.startsWith("/") ? path : ("/" + path));
- return "http://" + host + ":" + port + p;
- }
-
- private HttpResult<List<ConveyorStaDto>> postForResult(String url
- , Map<String, String> headers, Map<String, Object> params) throws Exception {
+ private HttpResult<List<ConveyorStaDto>> postForResult(String url, Map<String, String> headers, Map<String, Object> params) throws Exception {
String json = JSON.toJSONString(params);
HttpGo.HttpResponse response = this.http.postJson(url, headers, json);
--
Gitblit v1.9.1