From 250bf364710321e064cbc06e310965a79a619983 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 07 四月 2026 13:17:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master-jxthTV
---
src/main/java/com/zy/asrs/controller/OpenController.java | 143 +++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 131 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 7028f51..ff16ea1 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -2,7 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
@@ -11,10 +11,12 @@
import com.zy.asrs.entity.dto.TvDataDto;
import com.zy.asrs.entity.dto.TvLocDataDto;
+import com.zy.asrs.entity.dto.WcsCrnDto;
import com.zy.asrs.entity.dto.WcsStationDto;
import com.zy.asrs.enums.RedisKeyType;
import com.zy.asrs.service.BasStationTvService;
import com.zy.asrs.service.TvDeviceService;
+import com.zy.asrs.utils.CrnUtils;
import com.zy.asrs.utils.StationUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.utils.RedisUtil;
@@ -23,10 +25,19 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.*;
@Slf4j
@@ -43,6 +54,8 @@
@Autowired
private StationUtils stationUtils;
@Autowired
+ private CrnUtils crnUtils;
+ @Autowired
private RedisUtil redisUtil;
@Autowired
private AnnouncementService announcementService;
@@ -51,6 +64,84 @@
private String appVersion;
@Value("${app.version-type:stable}")
private String appVersionType;
+
+ @Value("${file.upload-path}")
+ private String uploadPath;
+
+ @PostMapping("/uploadLogo")
+ public R uploadLogo(@RequestParam("file") MultipartFile file) {
+ if (file.isEmpty()) {
+ return R.error("涓婁紶鏂囦欢涓嶈兘涓虹┖");
+ }
+ try {
+ File dir = new File(uploadPath);
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+
+ String originalFilename = file.getOriginalFilename();
+ String extension = "";
+ if (originalFilename != null && originalFilename.lastIndexOf(".") > 0) {
+ extension = originalFilename.substring(originalFilename.lastIndexOf("."));
+ }
+
+ // 鍒犻櫎鏃х殑logo鏂囦欢
+ File[] files = dir.listFiles((d, name) -> name.startsWith("logo."));
+ if (files != null) {
+ for (File f : files) {
+ f.delete();
+ }
+ }
+
+ String fileName = "logo" + extension;
+ File dest = new File(dir, fileName);
+ file.transferTo(dest);
+
+ return R.ok();
+ } catch (IOException e) {
+ log.error("涓婁紶Logo澶辫触", e);
+ return R.error("涓婁紶澶辫触: " + e.getMessage());
+ }
+ }
+
+ @GetMapping("/getLogo")
+ public void getLogo(HttpServletResponse response) {
+ try {
+ File dir = new File(uploadPath);
+ if (!dir.exists()) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, "Logo directory not found");
+ return;
+ }
+
+ File[] files = dir.listFiles((d, name) -> name.startsWith("logo."));
+ if (files == null || files.length == 0) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, "Logo not found");
+ return;
+ }
+
+ File logoFile = files[0];
+ String filename = logoFile.getName();
+ String contentType = "image/jpeg";
+ if (filename.toLowerCase().endsWith(".png")) {
+ contentType = "image/png";
+ } else if (filename.toLowerCase().endsWith(".gif")) {
+ contentType = "image/gif";
+ }
+ response.setContentType(contentType);
+
+ try (FileInputStream fis = new FileInputStream(logoFile);
+ OutputStream os = response.getOutputStream()) {
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = fis.read(buffer)) != -1) {
+ os.write(buffer, 0, len);
+ }
+ os.flush();
+ }
+ } catch (Exception e) {
+ log.error("鑾峰彇Logo澶辫触", e);
+ }
+ }
@GetMapping("/systemStatus")
public R systemStatus() {
@@ -69,15 +160,15 @@
public R getLedInfos(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String remoteAddr = request.getRemoteAddr();
- TvDevice tvDevice = tvDeviceService.selectOne(
- new EntityWrapper<TvDevice>().eq("ip", remoteAddr));
+ TvDevice tvDevice = tvDeviceService.getOne(
+ new QueryWrapper<TvDevice>().eq("ip", remoteAddr));
if (tvDevice == null) {
return R.error("鏈壘鍒癐P瀵瑰簲鐨勭數瑙嗘満璁惧: " + remoteAddr);
}
map.put("deviceName", tvDevice.getName());
List<BasStationTv> relations = basStationTvService
- .selectList(new EntityWrapper<BasStationTv>().eq("tv_id", tvDevice.getId()));
+ .list(new QueryWrapper<BasStationTv>().eq("tv_id", tvDevice.getId()));
if (relations == null || relations.isEmpty()) {
map.put("data", new ArrayList<>());
return R.ok().add(map);
@@ -102,6 +193,14 @@
continue;
}
+ if(Cools.isEmpty(wcsStationDto.getTaskNo())||wcsStationDto.getTaskNo().equals("0")) {
+ continue;
+ }
+
+ if (Cools.isEmpty(wcsStationDto.getWrkDetls())) {
+ continue;
+ }
+
String errorMsg = "";
if (!Cools.isEmpty(wcsStationDto.getErrorMsg())) {
errorMsg += wcsStationDto.getErrorMsg();
@@ -123,6 +222,7 @@
tvDataDto.setBarcode(wcsStationDto.getBarcode());
tvDataDto.setErrorMsg(errorMsg);
tvDataDto.setIoType(wcsStationDto.getIoType());
+ tvDataDto.setOrderNo(wcsStationDto.getOrderNo());
tvDataDto.setWrkDetls(wcsStationDto.getWrkDetls());
if (Cools.isEmpty(errorMsg)) {
@@ -136,6 +236,7 @@
map.put("data", list);
+ System.out.println(map);
return R.ok().add(map);
}
@@ -149,11 +250,11 @@
}
String remoteAddr = request.getRemoteAddr();
- TvDevice tvDevice = tvDeviceService.selectOne(
- new EntityWrapper<TvDevice>().eq("ip", remoteAddr));
+ TvDevice tvDevice = tvDeviceService.getOne(
+ new QueryWrapper<TvDevice>().eq("ip", remoteAddr));
if (tvDevice != null) {
List<BasStationTv> relations = basStationTvService
- .selectList(new EntityWrapper<BasStationTv>().eq("tv_id", tvDevice.getId()));
+ .list(new QueryWrapper<BasStationTv>().eq("tv_id", tvDevice.getId()));
if (relations != null && !relations.isEmpty()) {
for (BasStationTv relation : relations) {
WcsStationDto wcsStationDto = stationUtils.stationMap.get(relation.getStationId());
@@ -177,6 +278,25 @@
errors.add(deviceError);
}
}
+ }
+ }
+
+ List<WcsCrnDto> crnList = new ArrayList<>(crnUtils.crnMap.values());
+ crnList.sort(Comparator.comparing(WcsCrnDto::getCrnNo, Comparator.nullsLast(Integer::compareTo)));
+ for (WcsCrnDto wcsCrnDto : crnList) {
+ if (wcsCrnDto == null || wcsCrnDto.getCrnNo() == null) {
+ continue;
+ }
+ if (wcsCrnDto.getOnline() == null || wcsCrnDto.getOnline() != 1) {
+ errors.add("鍫嗗灈鏈�#" + wcsCrnDto.getCrnNo() + "绂荤嚎");
+ continue;
+ }
+ if (wcsCrnDto.getAlarm() != null && wcsCrnDto.getAlarm() != 0) {
+ errors.add("鍫嗗灈鏈�#" + wcsCrnDto.getCrnNo() + "鎶ヨ锛屾姤璀︾爜锛�" + wcsCrnDto.getAlarm());
+ }
+ if (wcsCrnDto.getMode() == null || wcsCrnDto.getMode() != 3) {
+ String modeDesc = Cools.isEmpty(wcsCrnDto.getModeDesc()) ? "鏈煡" : wcsCrnDto.getModeDesc();
+ errors.add("鍫嗗灈鏈�#" + wcsCrnDto.getCrnNo() + "闈炶嚜鍔ㄦā寮忥紝褰撳墠妯″紡锛�" + modeDesc);
}
}
@@ -210,11 +330,11 @@
@GetMapping("/announcement")
public R top5(){
- EntityWrapper<Announcement> wrapper = new EntityWrapper<>();
+ QueryWrapper<Announcement> wrapper = new QueryWrapper<>();
wrapper.eq("status", 1);
- wrapper.orderBy("create_time", false);
+ wrapper.orderBy(true, false, "create_time");
wrapper.last("limit 5");
- return R.ok(announcementService.selectList(wrapper));
+ return R.ok(announcementService.list(wrapper));
}
/**
@@ -260,7 +380,6 @@
if(o == null){
return R.error();
}
-
return R.ok().add(JSON.parseObject(o.toString()));
}
--
Gitblit v1.9.1