微调
This commit is contained in:
@@ -71,7 +71,6 @@ import com.njcn.gather.type.service.IDevTypeService;
|
|||||||
import com.njcn.http.util.RestTemplateUtil;
|
import com.njcn.http.util.RestTemplateUtil;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.net.ftp.FTPClient;
|
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.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -104,6 +102,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -676,12 +675,12 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
|
|
||||||
// 组装业务数据
|
// 组装业务数据
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
if (testFTPConnection(cloudUrl, devPort, devName, devPsd)) {
|
if (testFTPConnection(devIp, devPort, devName, devPsd)) {
|
||||||
data.set("name", devName);
|
data.set("name", devName);
|
||||||
data.set("password", devPsd);
|
data.set("password", devPsd);
|
||||||
data.set("port", devPort);
|
data.set("port", devPort);
|
||||||
data.set("path", "ftp://" + devIp + devPath);
|
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("name", gcDevName);
|
||||||
data.set("password", gcDevPsd);
|
data.set("password", gcDevPsd);
|
||||||
data.set("port", gcDevPort);
|
data.set("port", gcDevPort);
|
||||||
@@ -1751,23 +1750,23 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
@Override
|
@Override
|
||||||
public void uploadReportToCloud(List<String> deviceIds) {
|
public void uploadReportToCloud(List<String> deviceIds) {
|
||||||
log.info("开始批量上传检测报告到云端,设备ID列表:{}", deviceIds);
|
log.info("开始批量上传检测报告到云端,设备ID列表:{}", deviceIds);
|
||||||
|
|
||||||
// 查询条件:报告状态为已生成(1)的设备
|
// 查询条件:报告状态为已生成(1)的设备
|
||||||
LambdaQueryWrapper<PqDev> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PqDev> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(PqDev::getReportState, DevReportStateEnum.GENERATED.getValue());
|
wrapper.eq(PqDev::getReportState, DevReportStateEnum.GENERATED.getValue());
|
||||||
|
|
||||||
// 如果指定了设备ID列表,则只查询这些设备
|
// 如果指定了设备ID列表,则只查询这些设备
|
||||||
if (CollUtil.isNotEmpty(deviceIds)) {
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
||||||
wrapper.in(PqDev::getId, deviceIds);
|
wrapper.in(PqDev::getId, deviceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PqDev> devices = iPqDevService.list(wrapper);
|
List<PqDev> devices = iPqDevService.list(wrapper);
|
||||||
|
|
||||||
if (CollUtil.isEmpty(devices)) {
|
if (CollUtil.isEmpty(devices)) {
|
||||||
log.warn("未找到符合条件的设备,无需上传");
|
log.warn("未找到符合条件的设备,无需上传");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("找到{}台设备需要上传报告", devices.size());
|
log.info("找到{}台设备需要上传报告", devices.size());
|
||||||
String dirPath = reportPath;
|
String dirPath = reportPath;
|
||||||
// 确保目录存在
|
// 确保目录存在
|
||||||
@@ -1780,7 +1779,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
String fileName = device.getCreateId() + ".docx";
|
String fileName = device.getCreateId() + ".docx";
|
||||||
String reportFullPath = dirPath.concat(File.separator).concat(device.getCreateId()).concat(".docx");
|
String reportFullPath = dirPath.concat(File.separator).concat(device.getCreateId()).concat(".docx");
|
||||||
File reportFile = new File(reportFullPath);
|
File reportFile = new File(reportFullPath);
|
||||||
|
|
||||||
if (!reportFile.exists()) {
|
if (!reportFile.exists()) {
|
||||||
log.warn("设备{}的报告文件不存在:{}", device.getId(), fileName);
|
log.warn("设备{}的报告文件不存在:{}", device.getId(), fileName);
|
||||||
continue;
|
continue;
|
||||||
@@ -1796,7 +1795,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
} else {
|
} else {
|
||||||
log.error("设备{}报告上传失败,HTTP状态码:{}", device.getId(), responseEntity.getStatusCode());
|
log.error("设备{}报告上传失败,HTTP状态码:{}", device.getId(), responseEntity.getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("设备{}报告上传异常", device.getId(), e);
|
log.error("设备{}报告上传异常", device.getId(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user