From f03d761f318fd9c0a2ee5036a7bcce1c29cfd5c5 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 21 一月 2026 10:29:57 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/OpenController.java |   78 +++++++++++++++++++++++++++++++++-----
 1 files changed, 67 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index a806d1c..83f5d5c 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,17 +1,36 @@
 package com.zy.asrs.controller;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.Cools;
 import com.core.common.R;
+import com.zy.asrs.entity.BasStation;
+import com.zy.asrs.entity.BasStationTv;
+import com.zy.asrs.entity.TvDevice;
+
+import com.zy.asrs.utils.Utils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
+
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Slf4j
 @RestController
 @RequestMapping("/openapi")
 public class OpenController {
+
+    private static final String[] WEEK = {"鏄熸湡鏃�","鏄熸湡涓�","鏄熸湡浜�","鏄熸湡涓�","鏄熸湡鍥�","鏄熸湡浜�","鏄熸湡鍏�"};
+
+    @Autowired
+    private com.zy.asrs.service.TvDeviceService tvDeviceService;
+    @Autowired
+    private com.zy.asrs.service.BasStationTvService basStationTvService;
+    @Autowired
+    private com.zy.asrs.service.BasStationService basStationService;
 
     @Value("${app.version:1.0.0}")
     private String appVersion;
@@ -31,15 +50,52 @@
         return R.ok().add(map);
     }
 
-//    @GetMapping("/getLedInfos")
-//    public R getLedInfos(HttpServletRequest request) {
-//        String remoteAddr = request.getRemoteAddr();
-//        for (LedSlave slave : slaveProperties.getLed()) {
-//            if (slave.getIp().equals(remoteAddr)) {
-//                return R.ok().add(slave);
-//            }
-//        }
-//        return R.ok();
-//    }
+    @GetMapping("/getLedInfos")
+    public R getLedInfos(HttpServletRequest request) {
+        String remoteAddr = request.getRemoteAddr();
+        // 1. 鏍规嵁IP鏌ヨ鐢佃鏈�
+        TvDevice tvDevice = tvDeviceService.selectOne(
+                new EntityWrapper<TvDevice>().eq("ip", remoteAddr));
+        if (tvDevice == null) {
+            return R.error("鏈壘鍒癐P瀵瑰簲鐨勭數瑙嗘満璁惧: " + remoteAddr);
+        }
+
+        // 2. 鏌ヨ缁戝畾鐨勭珯鍙癐D
+        List<BasStationTv> relations = basStationTvService
+                .selectList(new EntityWrapper<BasStationTv>().eq("tv_id", tvDevice.getId()));
+        if (relations == null || relations.isEmpty()) {
+            R r = R.ok();
+            r.put("data", new ArrayList<>());
+            return r;
+        }
+
+        // 3. 鑾峰彇绔欏彴璇︽儏
+        List<Integer> stationIds = relations.stream().map(BasStationTv::getStationId)
+                .collect(Collectors.toList());
+        List<BasStation> stations = basStationService.selectBatchIds(stationIds);
+
+        R r = R.ok();
+        r.put("data", stations);
+        return r;
+    }
+
+    /**
+     * 鑾峰彇褰撳墠鏃堕棿
+     */
+    @GetMapping("/monitor/date")
+    public R monitorDate() {
+        Date now = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(now);
+        return R.ok(
+                Cools.add("year", calendar.get(Calendar.YEAR))
+                        .add("month", Utils.zerofill(String.valueOf(calendar.get(Calendar.MONTH)+1), 2))
+                        .add("day", Utils.zerofill(String.valueOf(calendar.get(Calendar.DATE)), 2))
+                        .add("hour", Utils.zerofill(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)), 2))
+                        .add("minute", Utils.zerofill(String.valueOf(calendar.get(Calendar.MINUTE)), 2))
+                        .add("second", Utils.zerofill(String.valueOf(calendar.get(Calendar.SECOND)) , 2))
+                        .add("week", WEEK[calendar.get(Calendar.DAY_OF_WEEK)-1])
+        );
+    }
 
 }

--
Gitblit v1.9.1