From afc1bebb2eafc87ba81fb9fe39ef0386d1fb3d17 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 22 一月 2026 08:43:31 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/OpenController.java | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 100 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..98b40ca 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,17 +1,39 @@
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.BasStationTv;
+import com.zy.asrs.entity.TvDevice;
+
+import com.zy.asrs.entity.dto.TvDataDto;
+import com.zy.asrs.entity.dto.WcsStationDto;
+import com.zy.asrs.service.BasStationTvService;
+import com.zy.asrs.service.TvDeviceService;
+import com.zy.asrs.utils.StationUtils;
+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.*;
@Slf4j
@RestController
@RequestMapping("/openapi")
public class OpenController {
+
+ private static final String[] WEEK = {"鏄熸湡鏃�","鏄熸湡涓�","鏄熸湡浜�","鏄熸湡涓�","鏄熸湡鍥�","鏄熸湡浜�","鏄熸湡鍏�"};
+
+ @Autowired
+ private TvDeviceService tvDeviceService;
+ @Autowired
+ private BasStationTvService basStationTvService;
+ @Autowired
+ private StationUtils stationUtils;
@Value("${app.version:1.0.0}")
private String appVersion;
@@ -31,15 +53,82 @@
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();
+ TvDevice tvDevice = tvDeviceService.selectOne(
+ new EntityWrapper<TvDevice>().eq("ip", remoteAddr));
+ if (tvDevice == null) {
+ return R.error("鏈壘鍒癐P瀵瑰簲鐨勭數瑙嗘満璁惧: " + remoteAddr);
+ }
+
+ 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;
+ }
+
+
+ List<TvDataDto> list = new ArrayList<>();
+ for (BasStationTv relation : relations) {
+ WcsStationDto wcsStationDto = stationUtils.stationMap.get(relation.getStationId());
+
+ if (wcsStationDto == null) {
+ continue;
+ }
+
+ if (wcsStationDto.getLoading() != 1) {
+ continue;
+ }
+
+ String errorMsg = "";
+ if (!Cools.isEmpty(wcsStationDto.getErrorMsg())) {
+ errorMsg += wcsStationDto.getErrorMsg();
+ }
+
+ if (!Cools.isEmpty(wcsStationDto.getSystemWarning())) {
+ errorMsg += wcsStationDto.getSystemWarning();
+ }
+
+ TvDataDto tvDataDto = new TvDataDto();
+ tvDataDto.setStationId(wcsStationDto.getStationId());
+ tvDataDto.setTaskNo(wcsStationDto.getTaskNo());
+ tvDataDto.setBarcode(wcsStationDto.getBarcode());
+ tvDataDto.setErrorMsg(errorMsg);
+ tvDataDto.setIoType(wcsStationDto.getIoType());
+ tvDataDto.setWrkDetls(wcsStationDto.getWrkDetls());
+
+ if (Cools.isEmpty(errorMsg)) {
+ tvDataDto.setErrorCode(0);
+ }else {
+ tvDataDto.setErrorCode(1);
+ }
+
+ list.add(tvDataDto);
+ }
+
+ return R.ok().add(list);
+ }
+
+ /**
+ * 鑾峰彇褰撳墠鏃堕棿
+ */
+ @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