From 14f2c4fce50c871d84f89d2dca2298e0892b4672 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期二, 05 五月 2026 08:25:26 +0800
Subject: [PATCH] Merge branch 'rcs_master_1.0' into rcs_master_all

---
 zy-acs-cv/src/main/java/com/zy/asrs/service/impl/CtuMainServiceImpl.java |  123 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 123 insertions(+), 0 deletions(-)

diff --git a/zy-acs-cv/src/main/java/com/zy/asrs/service/impl/CtuMainServiceImpl.java b/zy-acs-cv/src/main/java/com/zy/asrs/service/impl/CtuMainServiceImpl.java
new file mode 100644
index 0000000..05171db
--- /dev/null
+++ b/zy-acs-cv/src/main/java/com/zy/asrs/service/impl/CtuMainServiceImpl.java
@@ -0,0 +1,123 @@
+package com.zy.asrs.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.zy.acs.framework.exception.CoolException;
+import com.zy.asrs.controller.requestParam.StationRequestParam;
+import com.zy.asrs.controller.vo.OpenBusSubmitParam;
+import com.zy.asrs.controller.vo.StationStatus;
+import com.zy.asrs.service.CtuMainService;
+import com.zy.common.utils.HttpHandler;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 绔嬩綋浠撳簱WCS绯荤粺涓绘祦绋嬩笟鍔�
+ * Created by vincent on 2020/8/6
+ */
+@Slf4j
+@Service
+@Transactional
+@Data
+public class CtuMainServiceImpl implements CtuMainService {
+
+
+    @Value("${ctu.url}")
+    private String ctuUrl;
+
+    @Value("${ctu.station}")
+    private String station;
+
+    @Value("${ctu.sendTask}")
+    private String sendTask;
+
+    private String code = "code";
+
+    private String dataCode = "data";
+
+    private Integer codeValue = 200;
+
+    private Integer timeout = 1200;
+
+
+    @Transactional
+    public boolean sendTask(OpenBusSubmitParam openBusSubmitParam) {
+        String response = "";
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(ctuUrl)
+                    .setPath(sendTask)
+                    .setTimeout(timeout, TimeUnit.SECONDS)
+                    .setJson(JSON.toJSONString(openBusSubmitParam))
+                    .build()
+                    .doPost();
+            JSONObject jsonObject = JSON.parseObject(response);
+            if (jsonObject.getInteger(code).equals(codeValue)) {
+                log.info("涓嬪彂浠诲姟杩斿洖鏁版嵁锛歿}", response);
+                return true;
+            }
+        } catch (Exception e) {
+            log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", ctuUrl + sendTask, JSON.toJSONString(openBusSubmitParam), response);
+        }
+        return false;
+    }
+
+    /**
+     * 妫�鏌ョ珯鐐圭姸鎬�
+     *
+     * @param staNo 绔欑偣缂栧彿
+     * @return 绔欑偣鏄惁鍙�氳
+     */
+    public String checkStationStatus(Integer staNo) {
+        StationRequestParam stationRequestParam = new StationRequestParam();
+        List<String> staNos = new ArrayList<>();
+        staNos.add(staNo + "");
+        stationRequestParam.setStaNos(staNos);
+        String response = "";
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(ctuUrl)
+                    .setPath(station)
+                    .setTimeout(timeout, TimeUnit.SECONDS)
+                    .setJson(JSON.toJSONString(stationRequestParam))
+                    .build()
+                    .doPost();
+            JSONObject jsonObject = JSON.parseObject(response);
+            if (jsonObject.getInteger(code).equals(codeValue)) {
+                log.info("RCS杩斿洖鏁版嵁锛歿}", response);
+                JSONArray data = jsonObject.getJSONArray(dataCode);
+                List<StationStatus> stationStatuses = JSONArray.parseArray(data.toString(), StationStatus.class);
+                for (StationStatus object : stationStatuses) {
+                    if (object.getStaNo().equals(staNo + "")) {
+                        if (object.getConveyable()) {
+                            return object.getTaskNo();
+                        } else {
+                            log.info("绔欑偣锛歿}鐘舵�佷笉瀵�", staNo);
+                            return null;
+                        }
+                    }
+                }
+                log.info("鏈繑鍥炵珯鐐圭姸鎬侊細{}", staNo);
+            } else {
+                log.error("璋冪敤涓嬪彂浠诲姟鎺ュ彛鎶ラ敊锛屽搷搴旂爜锛歿}锛屽搷搴斿唴瀹癸細{}", jsonObject.getInteger(code), response);
+                throw new CoolException("璋冪敤涓嬪彂浠诲姟鎺ュ彛鎶ラ敊锛屽搷搴旂爜锛�" + jsonObject.getInteger(code));
+            }
+        } catch (CoolException e) {
+            log.error("璋冪敤绔欑偣鐘舵�佹帴鍙e紓甯�", e);
+            throw e;
+        } catch (Exception e) {
+            log.error("妫�鏌ョ珯鐐圭姸鎬佸け璐ワ紝绔欑偣缂栧彿锛歿}", staNo, e);
+        }
+        return null;
+    }
+
+
+}

--
Gitblit v1.9.1