hzd vor 1 Tag
Ursprung
Commit
df93353754

+ 57 - 14
src/main/java/com/jeesite/modules/Test.java

@@ -6,8 +6,10 @@ import com.github.s7connector.api.S7Connector;
 import com.github.s7connector.api.S7Serializer;
 import com.github.s7connector.api.factory.S7ConnectorFactory;
 import com.github.s7connector.api.factory.S7SerializerFactory;
+import com.jeesite.common.lang.DateUtils;
 import okhttp3.*;
 
+import java.io.File;
 import java.io.IOException;
 import java.math.BigInteger;
 import java.net.InetSocketAddress;
@@ -61,12 +63,53 @@ public class Test {
             return false;
         }
     }
+    private static final String ROOT_DIR = "D:\\mescloud\\userfiles\\ccd60";
 
     public static void main(String[] args) {
-        String lastSn = "5001040043563110030";
-        System.out.println(lastSn.substring(0,13));
-        System.out.println(lastSn.substring(13,15));
-        System.out.println(lastSn.substring(15,19));
+        Date lastMaxTime = new Date();
+        File rootDir = new File(ROOT_DIR);
+        if (!rootDir.exists() || !rootDir.isDirectory()) {
+//            logger.error("目标根目录不存在: {}", ROOT_DIR);
+            rootDir.mkdirs();
+            return;
+        }
+
+        File[] dateDirs = rootDir.listFiles();
+        if (dateDirs == null) return;
+
+        for (File dateSubDir : dateDirs) {
+            String dirDateStr = dateSubDir.getName();
+            File[] dateSubDirs = dateSubDir.listFiles();
+            System.out.println(dirDateStr);
+            for (File dateDir : dateSubDirs) {
+                System.out.println(dateDir.getName());
+            }
+
+        }
+
+//        // 获取基准日期字符串 (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;
+//                }
+//
+//                processDateFolder(dateDir, lastMaxTime);
+//            }
+//        }
+
+
+//        String lastSn = "5001040043563110030";
+//        System.out.println(lastSn.substring(0,13));
+//        System.out.println(lastSn.substring(13,15));
+//        System.out.println(lastSn.substring(15,19));
 //        String sn = "";
 //
 //
@@ -186,16 +229,16 @@ public class Test {
 //        int month = today.getMonthValue();
 //        System.out.println("当前月份: " + month);
 
-        // 获取当前年份
-        int currentYear = Year.now().getValue();
-
-        // 转换为字符串,然后获取最后一个字符
-        String lastDigit = String.valueOf(currentYear).substring(String.valueOf(currentYear).length() - 1);
-
-        // 将字符串的最后一个数字转换回整数
-        int lastDigitAsInt = Integer.parseInt(lastDigit);
-
-        System.out.println("年份的最后一个数字是: " + lastDigitAsInt);
+//        // 获取当前年份
+//        int currentYear = Year.now().getValue();
+//
+//        // 转换为字符串,然后获取最后一个字符
+//        String lastDigit = String.valueOf(currentYear).substring(String.valueOf(currentYear).length() - 1);
+//
+//        // 将字符串的最后一个数字转换回整数
+//        int lastDigitAsInt = Integer.parseInt(lastDigit);
+//
+//        System.out.println("年份的最后一个数字是: " + lastDigitAsInt);
 
 
 //        initS7();

+ 10 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductCcdXz.java

@@ -16,6 +16,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
 @Table(name="mes_product_ccd_xz", alias="a", label="鑫政CCD检测记录", columns={
         @Column(name="id", attrName="id", label="id", isPK=true),
         @Column(name="sn", attrName="sn", label="产品二维码", queryType=QueryType.LIKE),
+        @Column(name="cate", attrName="cate", label="类型"),
         @Column(name="test_time", attrName="testTime", label="检测时间"),
         @Column(name="create_time", attrName="createDate", label="记录创建时间", isUpdate=false, isQuery=false),
         @Column(name="update_time", attrName="updateDate", label="记录最后更新时间", isQuery=false),
@@ -26,6 +27,7 @@ public class MesProductCcdXz extends DataEntity<MesProductCcdXz> {
     private static final long serialVersionUID = 1L;
     private String sn;		// 产品二维码
     private Date testTime;		// 检测时间/测试时间
+    private String cate;
 
     public MesProductCcdXz() {
         this(null);
@@ -82,4 +84,12 @@ public class MesProductCcdXz extends DataEntity<MesProductCcdXz> {
     public void setTestTime_lte(Date testTime) {
         sqlMap.getWhere().and("test_time", QueryType.LTE, testTime);
     }
+
+    public String getCate() {
+        return cate;
+    }
+
+    public void setCate(String cate) {
+        this.cate = cate;
+    }
 }

+ 5 - 4
src/main/java/com/jeesite/modules/mes/web/MesProductCcdXzController.java

@@ -36,9 +36,9 @@ public class MesProductCcdXzController extends BaseController {
     private MesProductCcdXzService mesProductCcdXzService;
 
 
-    private static final String DISK_BASE_DIR = "D:\\mescloud\\userfiles\\ccd";
+    private static final String DISK_BASE_DIR = "D:\\mescloud\\userfiles\\ccd60";
     // Web 访问路径前缀 (JeeSite 默认通常将 /userfiles 映射到上传目录)
-    private static final String WEB_BASE_URL = "/userfiles/ccd";
+    private static final String WEB_BASE_URL = "/userfiles/ccd60";
 
     /**
      * 获取数据
@@ -88,12 +88,13 @@ public class MesProductCcdXzController extends BaseController {
         // 规则: ROOT / yyyyMMdd / SN_yyyyMMddHHmmss
         Date testTime = ccd.getTestTime();
         String sn = ccd.getSn();
+        String cate = ccd.getCate();
 
         String dateDirName = DateUtils.formatDate(testTime, "yyyyMMdd");
         String recordDirName = sn + "_" + DateUtils.formatDate(testTime, "yyyyMMddHHmmss");
 
         // 相对根目录的路径 (用于拼接 URL 和 磁盘路径)
-        String relativeBase = File.separator + dateDirName + File.separator + recordDirName;
+        String relativeBase = File.separator + cate + File.separator + dateDirName + File.separator + recordDirName;
         logger.info("relativeBase"+ relativeBase);
         // 处理子目录参数 (防止路径穿越攻击)
         if (StringUtils.isBlank(subPath)) {
@@ -139,7 +140,7 @@ public class MesProductCcdXzController extends BaseController {
                             // URL 结构: /userfiles/ccd/20260127/SN_Time/SubPath/file.jpg
                             // 注意:URL 必须使用正斜杠 /
                             String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
-                            String webUrlPath = host+ WEB_BASE_URL + "/" + dateDirName + "/" + recordDirName;
+                            String webUrlPath = host+ WEB_BASE_URL + "/" + cate + "/" + dateDirName + "/" + recordDirName;
                             if (StringUtils.isNotBlank(subPath)) {
                                 webUrlPath += "/" + subPath;
                             }

+ 27 - 18
src/main/java/com/jeesite/modules/scheduling/ProductCc.java

@@ -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);
         }
     }
 }

+ 8 - 0
src/main/resources/views/modules/mes/mesProductCcdXzList.html

@@ -22,6 +22,13 @@
             </div>
 
             <div class="form-group">
+                <label class="control-label">${text('类型')}:</label>
+                <div class="control-inline">
+                    <#form:input path="cate" maxlength="128" class="form-control width-120"/>
+                </div>
+            </div>
+
+            <div class="form-group">
                 <label class="control-label">${text('检测时间')}:</label>
                 <div class="control-inline">
                     <#form:input path="testTime_gte" readonly="true" maxlength="20" class="form-control laydate width-datetime"
@@ -51,6 +58,7 @@
         columnModel: [
             // 列1:产品二维码 (点击可查看详情,如果需要详情页的话)
             {header:'${text("产品二维码")}', name:'sn', index:'a.sn', width:200, align:"center", frozen:true},
+            {header:'${text("类型")}', name:'cate', index:'a.cate', width:150, align:"center"},
             // 列2:检测时间
             {header:'${text("检测时间")}', name:'testTime', index:'a.test_time', width:150, align:"center"},
             // 列3:创建时间 (采集入库时间)