|
|
@@ -27,12 +27,12 @@ public class ProductCc {
|
|
|
@Autowired
|
|
|
private MesProductCcdXzService mesProductCcdXzService;
|
|
|
|
|
|
- private static final String ROOT_DIR = "D:\\mescloud\\userfiles\\ccd";
|
|
|
+ private static final String ROOT_DIR = "D:\\mescloud\\userfiles\\ccd60";
|
|
|
|
|
|
/**
|
|
|
* 定时任务:每 300 秒执行一次
|
|
|
*/
|
|
|
-// @Scheduled(fixedRate = 300000)
|
|
|
+ @Scheduled(fixedRate = 300000)
|
|
|
private void configureTasks() {
|
|
|
try {
|
|
|
// 1. 获取数据库中最新的测试时间作为基准
|
|
|
@@ -40,7 +40,7 @@ public class ProductCc {
|
|
|
|
|
|
if (lastMaxTime == null) {
|
|
|
// 设置为当天的 00:00:00,确保当天的所有文件都能被扫描到
|
|
|
- lastMaxTime = DateUtils.parseDate("2026-01-24 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
|
|
+ lastMaxTime = DateUtils.parseDate("2026-10-24 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
|
|
}
|
|
|
|
|
|
File rootDir = new File(ROOT_DIR);
|
|
|
@@ -56,21 +56,30 @@ public class ProductCc {
|
|
|
// 获取基准日期字符串 (yyyyMMdd)
|
|
|
String lastDateStr = DateUtils.formatDate(lastMaxTime, "yyyyMMdd");
|
|
|
|
|
|
- for (File dateDir : dateDirs) {
|
|
|
- // 简单校验文件夹名是否为8位数字日期
|
|
|
- if (dateDir.isDirectory() && dateDir.getName().matches("\\d{8}")) {
|
|
|
- String dirDateStr = dateDir.getName();
|
|
|
-
|
|
|
- // 日期文件夹过滤
|
|
|
- // 如果文件夹日期 < 基准日期,直接跳过 (例如库里是26号,就不扫24号的文件夹了)
|
|
|
- if (dirDateStr.compareTo(lastDateStr) < 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ String cate = "";
|
|
|
+ for (File dateSubDir : dateDirs) {
|
|
|
+ cate = dateSubDir.getName();
|
|
|
+ File[] dateSubDirs = dateSubDir.listFiles();
|
|
|
+ for (File dateDir : dateSubDirs) {
|
|
|
+ // 简单校验文件夹名是否为8位数字日期
|
|
|
+ if (dateDir.isDirectory() && dateDir.getName().matches("\\d{8}")) {
|
|
|
+ String dirDateStr = dateDir.getName();
|
|
|
+
|
|
|
+ // 日期文件夹过滤
|
|
|
+ // 如果文件夹日期 < 基准日期,直接跳过 (例如库里是26号,就不扫24号的文件夹了)
|
|
|
+ if (dirDateStr.compareTo(lastDateStr) < 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- processDateFolder(dateDir, lastMaxTime);
|
|
|
+ processDateFolder(dateDir, lastMaxTime,cate);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ for (File dateDir : dateDirs) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
logger.error("CCD采集任务异常", e);
|
|
|
}
|
|
|
@@ -83,7 +92,7 @@ public class ProductCc {
|
|
|
return mesProductCcdXzService.findLastMaxTestTime();
|
|
|
}
|
|
|
|
|
|
- private void processDateFolder(File dateDir, Date lastMaxTime) {
|
|
|
+ private void processDateFolder(File dateDir, Date lastMaxTime,String cate) {
|
|
|
File[] recordDirs = dateDir.listFiles();
|
|
|
if (recordDirs == null) return;
|
|
|
|
|
|
@@ -109,7 +118,7 @@ public class ProductCc {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- saveToDb(sn, currentRecordTime);
|
|
|
+ saveToDb(sn, currentRecordTime,cate);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -121,7 +130,7 @@ public class ProductCc {
|
|
|
/**
|
|
|
* 保存数据
|
|
|
*/
|
|
|
- private void saveToDb(String sn, Date testTime) {
|
|
|
+ private void saveToDb(String sn, Date testTime, String cate) {
|
|
|
if (StringUtils.isBlank(sn) || testTime == null) return;
|
|
|
|
|
|
// 查重逻辑必须包含时间!
|
|
|
@@ -135,9 +144,9 @@ public class ProductCc {
|
|
|
if (count == 0) {
|
|
|
MesProductCcdXz newRecord = new MesProductCcdXz();
|
|
|
newRecord.setSn(sn);
|
|
|
+ newRecord.setCate(cate);
|
|
|
newRecord.setTestTime(testTime);
|
|
|
mesProductCcdXzService.save(newRecord);
|
|
|
- // logger.info("入库: " + sn);
|
|
|
}
|
|
|
}
|
|
|
}
|