shicf
2025-04-24 23d0d2bd37cc8789b35f60f2c6d6e0727c284c7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.product.file.controller;
 
 
import java.io.IOException;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.product.common.lang.StringUtils;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.service.support.AbstractBaseService;
import com.product.lucene.service.LuceneService;
import com.product.util.BaseUtil;
 
/**
 *     自动清理附件数据,服务器附件(暂不处理)
 *     文档检索索引,
 *     每天执行
 */
@Service("fileAutoClear")
public class FileAutoClearService extends AbstractBaseService{
 
    @Autowired
    BaseDao baseDao;
    
    @Autowired
    LuceneService luceneService;
 
    
    public void getFileInfo(){
        //获取所有附件信息
        DataTableEntity dtFileInfo=baseDao.listTable("product_sys_attachments");
        if (!BaseUtil.dataTableIsEmpty(dtFileInfo)) {
            //遍历附件信息
            for (int i = 0; i < dtFileInfo.getRows(); i++) {
                FieldSetEntity fseFileInfo=dtFileInfo.getFieldSetEntity(i);
                String table_name=fseFileInfo.getString("attachment_data_table");    //来源表
                String table_filed=fseFileInfo.getString("attachment_data_field");    //来源字段
                String uuid=fseFileInfo.getUUID();
                
                //非空验证
                if (StringUtils.isEmpty(table_name) || StringUtils.isEmpty(table_filed)) {
                    continue;
                }
                //获取原数据
                FieldSetEntity fseService=baseDao.getFieldSetEntityByFilter(table_name, table_filed+"=?", new Object[] {uuid}, false);
                if (fseService==null) {
                    try {
                        //清除索引
                        luceneService.deleteIndexByUUID(uuid);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}