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