| | |
| | | import com.product.lucene.util.FileUtils; |
| | | import com.product.util.BaseUtil; |
| | | |
| | | import com.product.util.UnifySQLSymbol; |
| | | import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer; |
| | | import org.apache.lucene.document.*; |
| | | import org.apache.lucene.index.IndexWriter; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | jsonFile.put(CmnConst.FILE_UUID, doc.get(CoreConst.UUID)); |
| | | jsonFile.put(CoreConst.FUNCTION_UUID, doc.get(CoreConst.FUNCTION_UUID)); |
| | | |
| | | if (!StringUtils.isEmpty(doc.get(CoreConst.FUNCTION_UUID))) { |
| | | FieldSetEntity fs = BaseUtil.getSingleInfoByCache("所有功能", new String[]{jsonFile.getString(CoreConst.FUNCTION_UUID)}); |
| | | if (FieldSetEntity.isEmpty(fs)) { |
| | | //找不到功能重新根据表名查找 |
| | | //清空 |
| | | jsonFile.remove(CoreConst.FUNCTION_UUID); |
| | | } |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(jsonFile.get(CoreConst.FUNCTION_UUID))) { |
| | | //查询功能信息 |
| | | String sql = "SELECT * FROM product_sys_functions where table_uuid =(select uuid from product_sys_datamodel_table where table_name=?) limit 1"; |
| | | FieldSetEntity fseFunction = baseDao.getFieldSetBySQL(sql, new String[]{doc.get(CmnConst.TABLE_NAME)}, false); |
| | | if (fseFunction != null) { |
| | | jsonFile.put(CoreConst.FUNCTION_UUID, fseFunction.getString(CoreConst.UUID)); |
| | | //回写功能信息到文档信息中 |
| | | doc.add(new StoredField(CoreConst.FUNCTION_UUID, fseFunction.getString(CoreConst.UUID))); |
| | | indexWriter.updateDocument(new Term(CoreConst.UUID, doc.get(CoreConst.UUID)), doc); |
| | | } |
| | | } |
| | | // 文件名增加高亮显示 |
| | | String fileName = doc.get(CmnConst.FILE_NAME); |
| | | String file_name = highlighter.getBestFragment(new SmartChineseAnalyzer(), CmnConst.FILE_NAME, |
| | |
| | | */ |
| | | public void getFileInfo(List<JSONObject> listJsonFile) { |
| | | StringBuilder sql = new StringBuilder(); |
| | | for (int i = 0; i < listJsonFile.size(); i++) { |
| | | JSONObject jsonFile = listJsonFile.get(i); |
| | | if (i > 0) { |
| | | sql.append("UNION ALL \n"); |
| | | } |
| | | Set<String> fileUuids = listJsonFile.stream().map(jsonFile -> jsonFile.getString(CmnConst.FILE_UUID)).collect(Collectors.toSet()); |
| | | |
| | | sql.append("SELECT \n"); |
| | | sql.append(" A.uuid,A.attachment_data_table,A.attachment_data_field,DATE_FORMAT(A.created_utc_datetime,'%Y-%m-%d') AS upload_date, \n"); |
| | | sql.append(" B.org_fields,B.user_fields,B.title_field,B.time_field, \n"); |
| | | sql.append(" C.uuid AS function_uuid,C.function_name,D.user_name AS upload_user "); |
| | | sql.append("FROM product_sys_attachments A \n"); |
| | | sql.append("LEFT JOIN product_sys_document_search B ON B.table_name = A.attachment_data_table \n"); |
| | | sql.append(" JOIN product_sys_datamodel_table as " + UnifySQLSymbol.getSymbol("table") + " on A.attachment_data_table=" + UnifySQLSymbol.getSymbol("table") + ".table_name \n"); |
| | | sql.append("LEFT JOIN product_sys_document_search B ON B.table_name = " + UnifySQLSymbol.getSymbol("table") + ".uuid \n"); |
| | | sql.append("LEFT JOIN product_sys_functions C ON C.uuid = B.function_uuid \n"); |
| | | sql.append("LEFT JOIN product_sys_users D ON D.user_id = A.created_by \n"); |
| | | sql.append("WHERE A.uuid = '").append(jsonFile.get("file_uuid")).append("' \n"); |
| | | } |
| | | sql.append("WHERE ").append(BaseUtil.buildQuestionMarkFilter("A.uuid", fileUuids.size(), true)); |
| | | // 获取文档附件、配置信息 |
| | | DataTableEntity dtConfig = baseDao.listTable(sql.toString(), new Object[] {}); |
| | | DataTableEntity dtConfig = baseDao.listTable(sql.toString(), fileUuids.toArray()); |
| | | if (!BaseUtil.dataTableIsEmpty(dtConfig)) { |
| | | StringBuilder sqlService = new StringBuilder(); |
| | | for (int i = 0; i < dtConfig.getRows(); i++) { |