From 241ab413828a3627a123ae001fc05f5c35031861 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期六, 24 一月 2026 14:34:47 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/OpenController.java | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index d53c898..30569f8 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,7 +1,9 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.entity.BasStationTv;
@@ -16,8 +18,9 @@
import com.zy.asrs.utils.StationUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.utils.RedisUtil;
+import com.zy.system.entity.Announcement;
+import com.zy.system.service.AnnouncementService;
import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.ss.usermodel.charts.LineChartData;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +44,8 @@
private StationUtils stationUtils;
@Autowired
private RedisUtil redisUtil;
+ @Autowired
+ private AnnouncementService announcementService;
@Value("${app.version:1.0.0}")
private String appVersion;
@@ -78,6 +83,12 @@
}
+ String manualError = "";
+ Object manualErrorObj = redisUtil.get(RedisKeyType.TV_MANUAL_ERROR_MSG.key);
+ if (manualErrorObj != null) {
+ manualError = String.valueOf(manualErrorObj);
+ }
+
List<TvDataDto> list = new ArrayList<>();
for (BasStationTv relation : relations) {
WcsStationDto wcsStationDto = stationUtils.stationMap.get(relation.getStationId());
@@ -98,6 +109,12 @@
if (!Cools.isEmpty(wcsStationDto.getSystemWarning())) {
errorMsg += wcsStationDto.getSystemWarning();
}
+ if (!Cools.isEmpty(manualError)) {
+ if (!Cools.isEmpty(errorMsg)) {
+ errorMsg += "锛�";
+ }
+ errorMsg += manualError;
+ }
TvDataDto tvDataDto = new TvDataDto();
tvDataDto.setStationId(wcsStationDto.getStationId());
@@ -119,6 +136,84 @@
return R.ok().add(list);
}
+ @GetMapping("/getError")
+ public R getError(HttpServletRequest request) {
+ Set<String> errors = new LinkedHashSet<>();
+ Object manualErrorObj = redisUtil.get(RedisKeyType.TV_MANUAL_ERROR_MSG.key);
+ String manualError = manualErrorObj == null ? "" : String.valueOf(manualErrorObj);
+ if (!Cools.isEmpty(manualError)) {
+ errors.add(manualError);
+ }
+
+ String remoteAddr = request.getRemoteAddr();
+ TvDevice tvDevice = tvDeviceService.selectOne(
+ new EntityWrapper<TvDevice>().eq("ip", remoteAddr));
+ if (tvDevice != null) {
+ List<BasStationTv> relations = basStationTvService
+ .selectList(new EntityWrapper<BasStationTv>().eq("tv_id", tvDevice.getId()));
+ if (relations != null && !relations.isEmpty()) {
+ for (BasStationTv relation : relations) {
+ WcsStationDto wcsStationDto = stationUtils.stationMap.get(relation.getStationId());
+ if (wcsStationDto == null) {
+ continue;
+ }
+ if (wcsStationDto.getLoading() != 1) {
+ continue;
+ }
+ String deviceError = "";
+ if (!Cools.isEmpty(wcsStationDto.getErrorMsg())) {
+ deviceError += wcsStationDto.getErrorMsg();
+ }
+ if (!Cools.isEmpty(wcsStationDto.getSystemWarning())) {
+ if (!Cools.isEmpty(deviceError)) {
+ deviceError += "锛�";
+ }
+ deviceError += wcsStationDto.getSystemWarning();
+ }
+ if (!Cools.isEmpty(deviceError)) {
+ errors.add(deviceError);
+ }
+ }
+ }
+ }
+
+ String errorMsg = String.join("锛�", errors);
+ Map<String, Object> result = new HashMap<>();
+ result.put("errorMsg", errorMsg);
+ return R.ok(result);
+ }
+
+ @GetMapping("/manualError/auth")
+ @ManagerAuth
+ public R getManualErrorAuth() {
+ Object manualErrorObj = redisUtil.get(RedisKeyType.TV_MANUAL_ERROR_MSG.key);
+ String manualError = manualErrorObj == null ? "" : String.valueOf(manualErrorObj);
+ Map<String, Object> result = new HashMap<>();
+ result.put("manualError", manualError);
+ return R.ok(result);
+ }
+
+ @PostMapping("/manualError/auth")
+ @ManagerAuth
+ public R setManualError(@RequestBody JSONObject param) {
+ String manualError = param.getString("manualError");
+ if (Cools.isEmpty(manualError)) {
+ redisUtil.del(RedisKeyType.TV_MANUAL_ERROR_MSG.key);
+ return R.ok();
+ }
+ redisUtil.set(RedisKeyType.TV_MANUAL_ERROR_MSG.key, manualError);
+ return R.ok();
+ }
+
+ @GetMapping("/announcement")
+ public R top5(){
+ EntityWrapper<Announcement> wrapper = new EntityWrapper<>();
+ wrapper.eq("status", 1);
+ wrapper.orderBy("create_time", false);
+ wrapper.last("limit 5");
+ return R.ok(announcementService.selectList(wrapper));
+ }
+
/**
* 鑾峰彇褰撳墠鏃堕棿
*/
--
Gitblit v1.9.1