From 910069a463e1efaefcece1c4f42b47b20b1924e8 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Fri, 25 Jul 2025 09:31:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PqReportServiceImpl.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java index 16dfc373..c6db00f0 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java @@ -71,7 +71,6 @@ import com.njcn.gather.type.service.IDevTypeService; import com.njcn.http.util.RestTemplateUtil; import com.njcn.web.factory.PageFactory; import io.netty.channel.Channel; -import java.util.concurrent.CompletableFuture; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.net.ftp.FTPClient; @@ -85,7 +84,6 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -104,6 +102,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -676,12 +675,12 @@ public class PqReportServiceImpl extends ServiceImpl i // 组装业务数据 JSONObject data = new JSONObject(); - if (testFTPConnection(cloudUrl, devPort, devName, devPsd)) { + if (testFTPConnection(devIp, devPort, devName, devPsd)) { data.set("name", devName); data.set("password", devPsd); data.set("port", devPort); data.set("path", "ftp://" + devIp + devPath); - } else if (testFTPConnection(cloudUrl, gcDevPort, gcDevName, gcDevPsd)) { + } else if (testFTPConnection(devIp, gcDevPort, gcDevName, gcDevPsd)) { data.set("name", gcDevName); data.set("password", gcDevPsd); data.set("port", gcDevPort); @@ -1751,23 +1750,23 @@ public class PqReportServiceImpl extends ServiceImpl i @Override public void uploadReportToCloud(List deviceIds) { log.info("开始批量上传检测报告到云端,设备ID列表:{}", deviceIds); - + // 查询条件:报告状态为已生成(1)的设备 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(PqDev::getReportState, DevReportStateEnum.GENERATED.getValue()); - + // 如果指定了设备ID列表,则只查询这些设备 if (CollUtil.isNotEmpty(deviceIds)) { wrapper.in(PqDev::getId, deviceIds); } - + List devices = iPqDevService.list(wrapper); - + if (CollUtil.isEmpty(devices)) { log.warn("未找到符合条件的设备,无需上传"); return; } - + log.info("找到{}台设备需要上传报告", devices.size()); String dirPath = reportPath; // 确保目录存在 @@ -1780,7 +1779,7 @@ public class PqReportServiceImpl extends ServiceImpl i String fileName = device.getCreateId() + ".docx"; String reportFullPath = dirPath.concat(File.separator).concat(device.getCreateId()).concat(".docx"); File reportFile = new File(reportFullPath); - + if (!reportFile.exists()) { log.warn("设备{}的报告文件不存在:{}", device.getId(), fileName); continue; @@ -1796,7 +1795,7 @@ public class PqReportServiceImpl extends ServiceImpl i } else { log.error("设备{}报告上传失败,HTTP状态码:{}", device.getId(), responseEntity.getStatusCode()); } - + } catch (Exception e) { log.error("设备{}报告上传异常", device.getId(), e); }