This commit is contained in:
caozehui
2025-07-25 09:31:46 +08:00
parent 56477157aa
commit 910069a463

View File

@@ -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<PqReportMapper, PqReport> 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<PqReportMapper, PqReport> i
@Override
public void uploadReportToCloud(List<String> deviceIds) {
log.info("开始批量上传检测报告到云端设备ID列表{}", deviceIds);
// 查询条件:报告状态为已生成(1)的设备
LambdaQueryWrapper<PqDev> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PqDev::getReportState, DevReportStateEnum.GENERATED.getValue());
// 如果指定了设备ID列表则只查询这些设备
if (CollUtil.isNotEmpty(deviceIds)) {
wrapper.in(PqDev::getId, deviceIds);
}
List<PqDev> 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<PqReportMapper, PqReport> 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<PqReportMapper, PqReport> i
} else {
log.error("设备{}报告上传失败HTTP状态码{}", device.getId(), responseEntity.getStatusCode());
}
} catch (Exception e) {
log.error("设备{}报告上传异常", device.getId(), e);
}