#
Administrator
2026-03-29 95a5e803d2bb18f9b07df40e85e523693e28f2ac
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -23,10 +23,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 javax.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
@@ -51,6 +60,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() {
@@ -102,6 +189,10 @@
                continue;
            }
            if(Cools.isEmpty(wcsStationDto.getTaskNo())){
                continue;
            }
            String errorMsg = "";
            if (!Cools.isEmpty(wcsStationDto.getErrorMsg())) {
                errorMsg +=  wcsStationDto.getErrorMsg();
@@ -123,6 +214,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 +228,7 @@
        map.put("data", list);
        System.out.println(map);
        return R.ok().add(map);
    }
@@ -260,7 +353,6 @@
        if(o == null){
            return R.error();
        }
        return R.ok().add(JSON.parseObject(o.toString()));
    }