|
@@ -6,6 +6,7 @@ import com.nokia.common.gpload.GploadUtil;
|
|
import com.nokia.common.gpload.entity.GploadResult;
|
|
import com.nokia.common.gpload.entity.GploadResult;
|
|
import com.nokia.common.ssh.SSHUtil;
|
|
import com.nokia.common.ssh.SSHUtil;
|
|
import com.nokia.common.ssh.exception.SSHUtilException;
|
|
import com.nokia.common.ssh.exception.SSHUtilException;
|
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.csv.CSVFormat;
|
|
import org.apache.commons.csv.CSVFormat;
|
|
@@ -55,23 +56,17 @@ public class LtePmTask {
|
|
|
|
|
|
@XxlJob("execHandlerPm4G")
|
|
@XxlJob("execHandlerPm4G")
|
|
public void cronTask() throws JSchException, SSHUtilException, IOException, SftpException {
|
|
public void cronTask() throws JSchException, SSHUtilException, IOException, SftpException {
|
|
- System.out.println("已触发pm4G");
|
|
|
|
- log.info("1");
|
|
|
|
// 创建文件夹
|
|
// 创建文件夹
|
|
Files.createDirectories(Paths.get(downloadTargetDir));
|
|
Files.createDirectories(Paths.get(downloadTargetDir));
|
|
- log.info("2");
|
|
|
|
Files.createDirectories(Paths.get(distinctTargetDir));
|
|
Files.createDirectories(Paths.get(distinctTargetDir));
|
|
- log.info("3");
|
|
|
|
SSHUtil sshUtil = new SSHUtil(host, port, username, password);
|
|
SSHUtil sshUtil = new SSHUtil(host, port, username, password);
|
|
- log.info("4");
|
|
|
|
// 获取文件列表
|
|
// 获取文件列表
|
|
List<String> list = sshUtil.ls(sourceDir);
|
|
List<String> list = sshUtil.ls(sourceDir);
|
|
- log.info("5");
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
- log.info("6");
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
log.debug("扫描到的文件: {}", list);
|
|
log.debug("扫描到的文件: {}", list);
|
|
|
|
+ XxlJobHelper.log("扫描到的文件: {}",list);
|
|
for (String s : list) {
|
|
for (String s : list) {
|
|
String[] s1 = s.split("_");
|
|
String[] s1 = s.split("_");
|
|
String[] split = s1[3].split("\\.");
|
|
String[] split = s1[3].split("\\.");
|
|
@@ -96,7 +91,6 @@ public class LtePmTask {
|
|
}
|
|
}
|
|
|
|
|
|
public void download(String hourString) throws JSchException, SSHUtilException, IOException, SftpException {
|
|
public void download(String hourString) throws JSchException, SSHUtilException, IOException, SftpException {
|
|
- log.info("hourString: {}", hourString);
|
|
|
|
SSHUtil sshUtil = new SSHUtil(host, port, username, password);
|
|
SSHUtil sshUtil = new SSHUtil(host, port, username, password);
|
|
String downloadFileName = filePrefix + hourString + ".csv";
|
|
String downloadFileName = filePrefix + hourString + ".csv";
|
|
String sourceFilePath = sourceDir + "/" + downloadFileName;
|
|
String sourceFilePath = sourceDir + "/" + downloadFileName;
|
|
@@ -108,7 +102,8 @@ public class LtePmTask {
|
|
boolean b = sshUtil.scpFrom(sourceFilePath, targetPath);
|
|
boolean b = sshUtil.scpFrom(sourceFilePath, targetPath);
|
|
if (b) {
|
|
if (b) {
|
|
log.debug("文件 {} 下载成功...", targetPath);
|
|
log.debug("文件 {} 下载成功...", targetPath);
|
|
-// sshUtil.delete(sourceFilePath);
|
|
|
|
|
|
+ XxlJobHelper.log("文件 {} 下载成功...",targetPath);
|
|
|
|
+ sshUtil.delete(sourceFilePath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -131,15 +126,18 @@ public class LtePmTask {
|
|
printer.flush();
|
|
printer.flush();
|
|
printer.close();
|
|
printer.close();
|
|
log.debug("去重完成,原文件{}条数据,去重后{}条数据", count, recordMap.size());
|
|
log.debug("去重完成,原文件{}条数据,去重后{}条数据", count, recordMap.size());
|
|
|
|
+ XxlJobHelper.log("去重完成,原文件{}条数据,去重后{}条数据",count, recordMap.size());
|
|
}
|
|
}
|
|
|
|
|
|
public void gpload(String hourString) {
|
|
public void gpload(String hourString) {
|
|
String gploadCommand = "sh /data1/pm/pm_4g/pm_lte_gpload.sh " + hourString;
|
|
String gploadCommand = "sh /data1/pm/pm_4g/pm_lte_gpload.sh " + hourString;
|
|
GploadResult gpload = GploadUtil.gpload(gploadCommand);
|
|
GploadResult gpload = GploadUtil.gpload(gploadCommand);
|
|
if (Boolean.TRUE.equals(gpload.getTaskStatus())) {
|
|
if (Boolean.TRUE.equals(gpload.getTaskStatus())) {
|
|
- log.debug("gpload完成: {}", gpload);
|
|
|
|
|
|
+ log.debug("gpload 完成: {}", gpload);
|
|
|
|
+ XxlJobHelper.log("gpload 完成: {}", gpload);
|
|
} else {
|
|
} else {
|
|
log.error("gpload 失败: {}", gpload.getMessage());
|
|
log.error("gpload 失败: {}", gpload.getMessage());
|
|
|
|
+ XxlJobHelper.log("gpload 失败: {}", gpload);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|