From 1702878f2bf5043a0afb01c8e3c48057fb641e3c Mon Sep 17 00:00:00 2001
From: cheng <1821349743@qq.com>
Date: 星期二, 18 二月 2025 00:32:22 +0800
Subject: [PATCH] change

---
 src/main/java/com/product/file/service/DocumentDirectoryService.java | 1193 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 619 insertions(+), 574 deletions(-)

diff --git a/src/main/java/com/product/file/service/DocumentDirectoryService.java b/src/main/java/com/product/file/service/DocumentDirectoryService.java
index d0fc329..500400f 100644
--- a/src/main/java/com/product/file/service/DocumentDirectoryService.java
+++ b/src/main/java/com/product/file/service/DocumentDirectoryService.java
@@ -1,8 +1,10 @@
 package com.product.file.service;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.beust.jcommander.internal.Lists;
+import com.beust.jcommander.internal.Sets;
 import com.product.common.collect.ListUtils;
 import com.product.core.cache.DataPoolCacheImpl;
 import com.product.core.config.CoreConst;
@@ -22,6 +24,7 @@
 import com.product.quartz.service.impl.SysJobService;
 import com.product.tool.table.enums.FieldType;
 import com.product.util.BaseUtil;
+import com.product.util.SystemParamReplace;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -40,609 +43,651 @@
 @Component
 public class DocumentDirectoryService extends AbstractBaseService implements IDocumentDirectoryService {
 
-	@Autowired
-	public BaseDao baseDao;
-	@Autowired
-	public DocumentDirectoryService documentDirectoryService;
-	@Autowired
-	SysJobService sysJobService;
+    @Autowired
+    public BaseDao baseDao;
+    @Autowired
+    public DocumentDirectoryService documentDirectoryService;
+    @Autowired
+    SysJobService sysJobService;
 
-	/**
-	 * 鍗曚綅鏂囦欢澶规爲
-	 *
-	 * @return
-	 */
-	public DataTableEntity allDirectoryTree() {
-		DataTableEntity dtTree = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, "directory_type = 1");
-		if (!BaseUtil.dataTableIsEmpty(dtTree)) {
-			return BaseUtil.dataTableToTreeTable(dtTree, CmnConst.TRICODE, CmnConst.TRICODE_PARENT, null);
-		}
-		return dtTree;
-	}
+    /**
+     * 鍗曚綅鏂囦欢澶规爲
+     *
+     * @return
+     */
+    public DataTableEntity allDirectoryTree() {
+        DataTableEntity dtTree = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, "directory_type = 1");
+        if (!BaseUtil.dataTableIsEmpty(dtTree)) {
+            return BaseUtil.dataTableToTreeTable(dtTree, CmnConst.TRICODE, CmnConst.TRICODE_PARENT, null);
+        }
+        return dtTree;
+    }
 
-	/**
-	 * 鏂囨。鐩綍淇濆瓨
-	 *
-	 * @param fse
-	 * @return
-	 */
-	@Transactional
-	public boolean saveDocumentDireactory(FieldSetEntity fse) {
-		BaseUtil.createCreatorAndCreationTime(fse);
-		String tricode = null;
-		String tricodeParent = BaseUtil.strIsNull(fse.getString(CmnConst.TRICODE_PARENT)) ? "" : fse.getString(CmnConst.TRICODE_PARENT);
-		if (BaseUtil.strIsNull(fse.getUUID())) {
-			tricode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, tricodeParent);
-		} else {
-			FieldSetEntity fseOrigin = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, fse.getUUID(), false);
-			if (fseOrigin == null) {
-				fse.remove(CoreConst.UUID);
-			}
-			String originParent = BaseUtil.strIsNull(fseOrigin.getString(CmnConst.TRICODE_PARENT)) ? "" : fseOrigin.getString(CmnConst.TRICODE_PARENT);
-			if (!originParent.equals(tricodeParent)) {
-				String originTricode = BaseUtil.strIsNull(fseOrigin.getString(CmnConst.TRICODE)) ? "" : fseOrigin.getString(CmnConst.TRICODE);
-				tricode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, tricodeParent);
-				// 鍒锋柊code
-				StringBuilder sql = new StringBuilder();
-				sql.append("update product_oa_directory ");
-				sql.append("set tricode=concat(replace(substring(tricode,1,locate(?,tricode)+length(?)),?,?),substring(tricode,locate(?,tricode)+length(?)+1)), ");
-				sql.append("tricode_parent=concat(replace(substring(tricode_parent,1,locate(?,tricode_parent)+length(?)),?,?),substring(tricode_parent,locate(?,tricode_parent)+length(?)+1)) ");
-				sql.append("where tricode like ? ");
-				baseDao.executeUpdate(sql.toString(), new Object[]{originTricode, originTricode, originTricode, tricode, originTricode, originTricode,
-						originTricode, originTricode, originTricode, tricode, originTricode, originTricode, originTricode + "-%"});
-				// 鍒锋柊灞傜骇
-				StringBuilder sb = new StringBuilder();
-				sb.append("UPDATE product_oa_directory \n");
-				sb.append("SET directory_tier = ( \n");
-				sb.append("    (LENGTH(tricode) - LENGTH(REPLACE(tricode, '-', '')) + 1) \n");
-				sb.append(") \n");
-				sb.append("WHERE tricode LIKE ? \n");
-				baseDao.executeUpdate(sb.toString(), new Object[]{tricode + "%"});
-			} else {
-				tricode = fseOrigin.getString(CmnConst.TRICODE);
-			}
-		}
-		fse.setValue(CmnConst.TRICODE, tricode);
-		fse.setValue(CmnConst.DIRECTORY_TIER, tricode.split("-").length);
-		return baseDao.saveFieldSetEntity(fse);
-	}
+    /**
+     * 鏂囨。鐩綍淇濆瓨
+     *
+     * @param fse
+     * @return
+     */
+    @Transactional
+    public boolean saveDocumentDireactory(FieldSetEntity fse) {
+        BaseUtil.createCreatorAndCreationTime(fse);
+        String tricode = null;
+        String tricodeParent = BaseUtil.strIsNull(fse.getString(CmnConst.TRICODE_PARENT)) ? "" : fse.getString(CmnConst.TRICODE_PARENT);
+        if (BaseUtil.strIsNull(fse.getUUID())) {
+            tricode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, tricodeParent);
+        } else {
+            FieldSetEntity fseOrigin = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, fse.getUUID(), false);
+            if (fseOrigin == null) {
+                fse.remove(CoreConst.UUID);
+            }
+            String originParent = BaseUtil.strIsNull(fseOrigin.getString(CmnConst.TRICODE_PARENT)) ? "" : fseOrigin.getString(CmnConst.TRICODE_PARENT);
+            if (!originParent.equals(tricodeParent)) {
+                String originTricode = BaseUtil.strIsNull(fseOrigin.getString(CmnConst.TRICODE)) ? "" : fseOrigin.getString(CmnConst.TRICODE);
+                tricode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, tricodeParent);
+                // 鍒锋柊code
+                StringBuilder sql = new StringBuilder();
+                sql.append("update product_oa_directory ");
+                sql.append("set tricode=concat(replace(substring(tricode,1,locate(?,tricode)+length(?)),?,?),substring(tricode,locate(?,tricode)+length(?)+1)), ");
+                sql.append("tricode_parent=concat(replace(substring(tricode_parent,1,locate(?,tricode_parent)+length(?)),?,?),substring(tricode_parent,locate(?,tricode_parent)+length(?)+1)) ");
+                sql.append("where tricode like ? ");
+                baseDao.executeUpdate(sql.toString(), new Object[]{originTricode, originTricode, originTricode, tricode, originTricode, originTricode,
+                        originTricode, originTricode, originTricode, tricode, originTricode, originTricode, originTricode + "-%"});
+                // 鍒锋柊灞傜骇
+                StringBuilder sb = new StringBuilder();
+                sb.append("UPDATE product_oa_directory \n");
+                sb.append("SET directory_tier = ( \n");
+                sb.append("    (LENGTH(tricode) - LENGTH(REPLACE(tricode, '-', '')) + 1) \n");
+                sb.append(") \n");
+                sb.append("WHERE tricode LIKE ? \n");
+                baseDao.executeUpdate(sb.toString(), new Object[]{tricode + "%"});
+            } else {
+                tricode = fseOrigin.getString(CmnConst.TRICODE);
+            }
+        }
+        fse.setValue(CmnConst.TRICODE, tricode);
+        fse.setValue(CmnConst.DIRECTORY_TIER, tricode.split("-").length);
+        return baseDao.saveFieldSetEntity(fse);
+    }
 
-	@Transactional
-	@Override
-	public boolean saveFileConfig(FieldSetEntity fse) {
-		//鑾峰彇鍔熻兘琛ㄥ悕
-		FieldSetEntity functionUuid = baseDao.getFieldSet(CmnConst.PRODUCT_SYS_FUNCTIONS, fse.getString("function_uuid"), false);
+    @Transactional
+    @Override
+    public boolean saveFileConfig(FieldSetEntity fse) {
+        //鑾峰彇鍔熻兘琛ㄥ悕
+        FieldSetEntity functionUuid = baseDao.getFieldSet(CmnConst.PRODUCT_SYS_FUNCTIONS, fse.getString("function_uuid"), false);
 
-		DataTableEntity field = baseDao.listTable(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD, "table_uuid=? and field_type='archive-sign'", new String[]{functionUuid.getString("table_uuid")});
-		if (field.getRows() == 0) {
-			String fieldName = "archive_flag";
-			FieldSetEntity fieldInfo = null;
-			int i = 0;
-			do {
-				if (i > 0) {
-					fieldName = "archive_flag_" + i;
-				}
-				fieldInfo = BaseUtil.getSingleInfoByCache("琛ㄥ瓧娈典俊鎭�", new String[]{functionUuid.getString("table_uuid"), fieldName});
-				i++;
-			} while (!FieldSetEntity.isEmpty(fieldInfo));
-			FieldSetEntity fs = new FieldSetEntity();
-			fs.setTableName(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD);
-			fs.setValue("table_uuid", functionUuid.getString("table_uuid"));
-			fs.setValue("field_name", fieldName);
-			fs.setValue("field_type", FieldType.ARCHIVE_SIGN.getDictValue());
-			fs.setValue("field_show_name", "褰掓。鏍囪瘑");
-			fs.setValue("field_description", "褰掓。鏍囪瘑");
-			fs.setValue("field_length", 4);
-			fs.setValue("field_unit", 0);
-			fs.setValue("is_required", 0);
-			fs.setValue("is_unique", 0);
-			fs.setValue("is_filter", 0);
-			fs.setValue("field_sequence", 0);
-			fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
-			fs.setValue("created_utc_datetime", new Date());
-			baseDao.saveFieldSetEntity(fs);
-			FieldSetEntity table = baseDao.getFieldSet(CmnConst.PRODUCT_SYS_DATAMODEL_TABLE, functionUuid.getString("table_uuid"), false);
-			baseDao.executeUpdate("ALTER TABLE " + table.getString("table_name") + " ADD COLUMN " + fieldName + " varchar(10) COMMENT '褰掓。鏍囪瘑';");
-		}
+        DataTableEntity field = baseDao.listTable(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD, "table_uuid=? and field_type='archive-sign'", new String[]{functionUuid.getString("table_uuid")});
+        if (field.getRows() == 0) {
+            String fieldName = "archive_flag";
+            FieldSetEntity fieldInfo = null;
+            int i = 0;
+            do {
+                if (i > 0) {
+                    fieldName = "archive_flag_" + i;
+                }
+                fieldInfo = BaseUtil.getSingleInfoByCache("琛ㄥ瓧娈典俊鎭�", new String[]{functionUuid.getString("table_uuid"), fieldName});
+                i++;
+            } while (!FieldSetEntity.isEmpty(fieldInfo));
+            FieldSetEntity fs = new FieldSetEntity();
+            fs.setTableName(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD);
+            fs.setValue("table_uuid", functionUuid.getString("table_uuid"));
+            fs.setValue("field_name", fieldName);
+            fs.setValue("field_type", FieldType.ARCHIVE_SIGN.getDictValue());
+            fs.setValue("field_show_name", "褰掓。鏍囪瘑");
+            fs.setValue("field_description", "褰掓。鏍囪瘑");
+            fs.setValue("field_length", 4);
+            fs.setValue("field_unit", 0);
+            fs.setValue("is_required", 0);
+            fs.setValue("is_unique", 0);
+            fs.setValue("is_filter", 0);
+            fs.setValue("field_sequence", 0);
+            fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+            fs.setValue("created_utc_datetime", new Date());
+            baseDao.saveFieldSetEntity(fs);
+            FieldSetEntity table = baseDao.getFieldSet(CmnConst.PRODUCT_SYS_DATAMODEL_TABLE, functionUuid.getString("table_uuid"), false);
+            baseDao.executeUpdate("ALTER TABLE " + table.getString("table_name") + " ADD COLUMN " + fieldName + " varchar(10) COMMENT '褰掓。鏍囪瘑';");
+        }
 
 
-		FieldSetEntity timedTask = baseDao.getFieldSetByFilter("product_sys_timed_task", "job_name=? and invoke_target like concat('%',?,'%') ", new String[]{fse.getString("filing_name") + "瀹氭椂", fse.getString("uuid")}, false);
-		String timeTaskUuid = null;
-		if (!FieldSetEntity.isEmpty(timedTask)) {
-			timeTaskUuid = timedTask.getUUID();
-		}
-		boolean re = baseDao.saveFieldSetEntity(fse);
-		createdTimeTask(fse.getString("filing_name"), fse.getString("cron"), fse.getUUID(), timeTaskUuid);
-		return re;
-	}
+        FieldSetEntity timedTask = baseDao.getFieldSetByFilter("product_sys_timed_task", "job_name=? and invoke_target like concat('%',?,'%') ", new String[]{fse.getString("filing_name") + "瀹氭椂", fse.getString("uuid")}, false);
+        String timeTaskUuid = null;
+        if (!FieldSetEntity.isEmpty(timedTask)) {
+            timeTaskUuid = timedTask.getUUID();
+        }
+        boolean re = baseDao.saveFieldSetEntity(fse);
+        createdTimeTask(fse.getString("filing_name"), fse.getString("cron"), fse.getUUID(), timeTaskUuid);
+        return re;
+    }
 
-	private FieldSetEntity createdTimeTask(String target_table, String execute_time, String task_uuid, String timeTaskUuid) throws BaseException {
-		//
-		FieldSetEntity fse = new FieldSetEntity();
-		try {
-			fse.setTableName("product_sys_timed_task");
-			fse.setValue("uuid", timeTaskUuid);
-			fse.setValue("job_name", target_table + "瀹氭椂");//浠诲姟鍚嶇О
-			fse.setValue("job_group", "system");//鍒嗙粍
-			fse.setValue("invoke_target", "documentDirectoryService.fileTime('" + task_uuid + "')");//璋冪敤鐩爣瀛楃涓�
-			fse.setValue("cron_expression", execute_time);//cron琛ㄨ揪寮�
-			fse.setValue("misfire_policy", "3");//閿欒鎵ц绛栫暐  鍙墽琛屼竴娆�
-			fse.setValue("concurrent", 0);//涓嶅厑璁稿苟鍙戞墽琛�
-			fse.setValue("remark", target_table + "瀹氭椂");
-			fse.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
-			fse.setValue("created_utc_datetime", new Date());
-			fse.setValue("status", 1);
-			fse.setValue("is_conceal", 1);
-			if (!com.product.common.lang.StringUtils.isEmpty(timeTaskUuid)) {
-				sysJobService.updateJob(fse);
-			} else {
-				sysJobService.insertJob(fse);
-			}
-			return fse;
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw new BaseException(DocumentCode.CRATED_TIMED_TASK_FAIL);
-		}
+    private FieldSetEntity createdTimeTask(String target_table, String execute_time, String task_uuid, String timeTaskUuid) throws BaseException {
+        //
+        FieldSetEntity fse = new FieldSetEntity();
+        try {
+            fse.setTableName("product_sys_timed_task");
+            fse.setValue("uuid", timeTaskUuid);
+            fse.setValue("job_name", target_table + "瀹氭椂");//浠诲姟鍚嶇О
+            fse.setValue("job_group", "system");//鍒嗙粍
+            fse.setValue("invoke_target", "documentDirectoryService.fileTime('" + task_uuid + "')");//璋冪敤鐩爣瀛楃涓�
+            fse.setValue("cron_expression", execute_time);//cron琛ㄨ揪寮�
+            fse.setValue("misfire_policy", "3");//閿欒鎵ц绛栫暐  鍙墽琛屼竴娆�
+            fse.setValue("concurrent", 0);//涓嶅厑璁稿苟鍙戞墽琛�
+            fse.setValue("remark", target_table + "瀹氭椂");
+            fse.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+            fse.setValue("created_utc_datetime", new Date());
+            fse.setValue("status", 1);
+            fse.setValue("is_conceal", 1);
+            fse.setValue("open_transaction", 1);
+            if (!com.product.common.lang.StringUtils.isEmpty(timeTaskUuid)) {
+                sysJobService.updateJob(fse);
+            } else {
+                sysJobService.insertJob(fse);
+            }
+            return fse;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BaseException(DocumentCode.CRATED_TIMED_TASK_FAIL);
+        }
 //
-	}
+    }
 
-	/**
-	 * 褰掓。瀹氭椂浠诲姟
-	 */
-	@Transactional
-	public void fileTime(String uuid) {
-		FieldSetEntity fs = baseDao.getFieldSet(CmnConst.PRODUCT_AO_FILING_CONFIG, uuid, false);
-		FieldSetEntity function = BaseUtil.getSingleInfoByCache("鎵�鏈夊姛鑳�", new String[]{fs.getString("function_uuid"), fs.getString(CmnConst.FUNCTION_UUID)});
+    /**
+     * 褰掓。瀹氭椂浠诲姟
+     */
+    @Transactional
+    public void fileTime(String uuid) {
+        try {
+            FieldSetEntity fs = baseDao.getFieldSet(CmnConst.PRODUCT_AO_FILING_CONFIG, uuid, false);
+            FieldSetEntity function = BaseUtil.getSingleInfoByCache("鎵�鏈夊姛鑳�", new String[]{fs.getString(CmnConst.FUNCTION_UUID)});
 
-		DataTableEntity tableFields = DataPoolCacheImpl.getInstance().getCacheData("鎵�鏈夊瓧娈典俊鎭苟鎸夎〃鍒嗙粍", new String[]{function.getString("table_uuid")});
-		if (DataTableEntity.isEmpty(tableFields)) {
-			return;
-		}
-		String flowSignField = null;
-		String archiveFlagField = null;
+            DataTableEntity tableFields = DataPoolCacheImpl.getInstance().getCacheData("鎵�鏈夊瓧娈典俊鎭苟鎸夎〃鍒嗙粍", new String[]{function.getString("table_uuid")});
+            if (DataTableEntity.isEmpty(tableFields)) {
+                return;
+            }
+            String flowSignField = null;
+            String archiveFlagField = null;
 
 
-		Set<String> fileField = new HashSet<>();
-		Map<String, String> map = new HashMap<>();
-		for (int i = 0; i < tableFields.getRows(); i++) {
-			String fieldType = tableFields.getString(i, "field_type");
-			if (FieldType.FILE.getDictValue().equals(fieldType)) {
-				fileField.add(tableFields.getString(i, "field_name"));
-			} else if (FieldType.FLOWSIGN.getDictValue().equals(fieldType)) {
-				flowSignField = tableFields.getString(i, "field_name");
-			} else if (FieldType.ARCHIVE_SIGN.getDictValue().equals(fieldType)) {
-				archiveFlagField = tableFields.getString(i, "field_name");
-			}
-			map.put(tableFields.getString(i, "field_name"), "");
-		}
-		if (StringUtils.isEmpty(flowSignField) || StringUtils.isEmpty(archiveFlagField) || fileField.isEmpty()) {
-			return;
-		}
-		FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅(uuid)", new String[]{function.getString("table_uuid")});
-		if (FieldSetEntity.isEmpty(tableInfo)) {
-			return;
-		}
-		StringBuilder sql = new StringBuilder();
-		int pageSize = 1000;
-		String sub_folder = fs.getString("sub_folder");
-		List<String> businessValueField = Lists.newArrayList();
-		if (!map.containsKey(fs.getString("field_title"))) {
-			throw new BaseException(FileCode.ARCHIVE_FILE_TITLE_FIELD_NO_EXIST);
-		}
-		businessValueField.add(fs.getString("field_title"));
-		if (!StringUtils.isEmpty(sub_folder)) {
-			String[] split = sub_folder.split("/");
-			for (int i = 0; i < split.length; i++) {
-				String name = split[i];
-				if (StringUtils.startsWith(name, "{#") && StringUtils.endsWith(name, "#}")) {
-					name = split[i].replace("{#", "").replace("#}", "");
-					if (map.containsKey(name)) {
-						businessValueField.add(name);
-					}
-				}
-			}
-		} else {
-			sub_folder = "{#" + fs.getString("field_title") + "#}";
-		}
-		//鏌ヨ涓氬姟鏁版嵁
-		sql.append("SELECT\n");
+            Set<String> fileField = new HashSet<>();
+            Map<String, String> map = new HashMap<>();
+            for (int i = 0; i < tableFields.getRows(); i++) {
+                String fieldType = tableFields.getString(i, "field_type");
+                if (FieldType.FILE.getDictValue().equals(fieldType)) {
+                    fileField.add(tableFields.getString(i, "field_name"));
+                } else if (FieldType.FLOWSIGN.getDictValue().equals(fieldType)) {
+                    flowSignField = tableFields.getString(i, "field_name");
+                } else if (FieldType.ARCHIVE_SIGN.getDictValue().equals(fieldType)) {
+                    archiveFlagField = tableFields.getString(i, "field_name");
+                }
+                map.put(tableFields.getString(i, "field_name"), "");
+            }
+            if (StringUtils.isEmpty(flowSignField) || StringUtils.isEmpty(archiveFlagField) || fileField.isEmpty()) {
+                return;
+            }
+            FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅(uuid)", new String[]{function.getString("table_uuid")});
+            if (FieldSetEntity.isEmpty(tableInfo)) {
+                return;
+            }
+            StringBuilder sql = new StringBuilder();
+            int pageSize = 1000;
+            if (!map.containsKey(fs.getString("field_title"))) {
+                throw new BaseException(FileCode.ARCHIVE_FILE_TITLE_FIELD_NO_EXIST);
+            }
+
+            //鏌ヨ涓氬姟鏁版嵁
+            sql.append("SELECT\n");
 //		sql.append("\tT1.").append(fs.getString("field_title")).append(" as title");
-		for (int i = 0; i < businessValueField.size(); i++) {
-			sql.append("\tT1." + businessValueField.get(i) + " as val_").append(i).append("\n,");
-		}
-		sql.append("\tT2.uuid,T2.attachment_size,T2.file_name,T3.dict_label file_type,T4.record_uuid\n");
-		sql.append("FROM\n");
-		sql.append("\t").append(tableInfo.getString(CoreConst.FIELD_TABLE_NAME)).append(" T1\n");
-		sql.append("\tJOIN product_sys_flow_detail T4 ON T1.uuid=T4.record_uuid\n");
-		sql.append("\tJOIN product_sys_attachments T2 ON T1.attachment = T2.uuid or T1.attachment_meeting=T2.uuid\n");
-		sql.append("\tJOIN product_sys_dict T3 ON T2.attachment_type_uuid=T3.uuid\n");
-		sql.append("WHERE\n");
-		sql.append("\tT1.flow_flag =2\n");
-		sql.append("\tAND T1.").append(archiveFlagField).append(" is null or ").append(archiveFlagField).append("!=1\n");
-		sql.append("\tAND T4.table_name='").append(tableInfo.getString(CoreConst.FIELD_TABLE_NAME)).append("'\n");
-		sql.append("\tGROUP BY 1,2,3,4,5 limit ").append(pageSize);
+//        for (int i = 0; i < businessValueField.size(); i++) {
+//            sql.append("\tT1." + businessValueField.get(i) + " as val_").append(i).append("\n,");
+//        }
+            sql.append("\tT4.record_uuid,T4.title flow_title,\n");
+            for (String field : fileField) {
+                sql.append("\tT1.").append(field).append(",");
+            }
+            sql.append("\tGROUP_CONCAT(flow_attachment) flow_attachments\n");
+            sql.append("\t\nFROM\n");
+            sql.append("\t").append(tableInfo.getString(CoreConst.FIELD_TABLE_NAME)).append(" T1\n");
+            sql.append("\tJOIN product_sys_flow_detail T4 ON T1.uuid=T4.record_uuid\n");
+//        sql.append("\tJOIN product_sys_attachments T2 ON T1.attachment = T2.uuid or T1.attachment_meeting=T2.uuid\n");
+//        sql.append("\tJOIN product_sys_dict T3 ON T2.attachment_type_uuid=T3.uuid\n");
+            sql.append("WHERE\n");
+            sql.append("\tT1.").append(flowSignField).append("=2\n");
+            sql.append("\tAND (T1.").append(archiveFlagField).append(" is null or T1.").append(archiveFlagField).append("!=1)\n");
+            sql.append("\tAND T4.table_name='").append(tableInfo.getString(CoreConst.FIELD_TABLE_NAME)).append("'\n");
+            sql.append("\t GROUP BY 1");
+            for (int i = 0; i < fileField.size(); i++) {
+                sql.append(",").append(i + 2);
+            }
+            sql.append(" limit ").append(pageSize);
 
-		DataTableEntity files = null;
-		String filing_catalog = fs.getString("filing_catalog");
-		FieldSetEntity parentDir = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY, "tricode=?", new String[]{filing_catalog}, false);
-		if (FieldSetEntity.isEmpty(parentDir)) {
-			throw new BaseException(FileCode.ARCHIVE_FILE_PARENT_DIRECTORY_NO_EXIST);
-		}
-		do {
+            DataTableEntity files;
+            String filing_catalog = fs.getString("filing_catalog");
+            FieldSetEntity parentDir = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY, "tricode=?", new String[]{filing_catalog}, false);
+            if (FieldSetEntity.isEmpty(parentDir)) {
+                throw new BaseException(FileCode.ARCHIVE_FILE_PARENT_DIRECTORY_NO_EXIST);
+            }
+//        baseDao.listTable(CmnConst.PRODUCT_SYS_ATTACHMENTS,BaseUtil.buildQuestionMarkFilter("uuid",),)
+            do {
 
-			files = baseDao.listTable(sql.toString(), new Object[]{});
-			if (DataTableEntity.isEmpty(files)) {
-				break;
-			}
-			for (int i = 0; i < files.getRows(); i++) {
-				FieldSetEntity file = files.getFieldSetEntity(i);
-				for (int i1 = 0; i1 < businessValueField.size(); i1++) {
-					String value = file.getString("val_" + i1);
-					if (StringUtils.isEmpty(value)) {
-						continue;
-					}
-					sub_folder = sub_folder.replace("{#" + businessValueField.get(i1) + "#}", value);
-				}
-				String[] dirs = sub_folder.split("/");
-				//閫掑綊鏌ヨ鐖剁骇鐩綍
-				FieldSetEntity parent = parentDir;
-				for (int j = 0; j < dirs.length; j++) {
-					String dir = dirs[j];
-					FieldSetEntity temp = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY, "tricode_parent=? and directory_name=", new String[]{parent.getString("tricode"), dir}, false);
-					if (FieldSetEntity.isEmpty(temp)) {
-						//鍒涘缓鏂囦欢澶�
-						parent = addDirectory(dir, BaseUtil.createCode(CmnConst.PRODUCT_OA_DIRECTORY,
-								CmnConst.TRICODE,
-								parent.getString("tricode")), parent.getString(CmnConst.TRICODE), parent.getInteger("directory_tier") + 1, fs.getUUID(), tableInfo.getString(CoreConst.FIELD_TABLE_NAME));
-					}
-				}
-				FieldSetEntity document = new FieldSetEntity();
-				document.setTableName(CmnConst.PRODUCT_OA_DOCUMENT);
-				document.setValue("directory_uuid", parent.getUUID());
-				document.setValue("file_name", file.getString("file_name"));
-				document.setValue("attachments_uuid", file.getUUID());
-				document.setValue("file_type", file.getString("file_type"));
-				document.setValue("created_by", 1);
-				document.setValue("created_utc_datetime", new Date());
-				document.setValue("file_size", file.getString("attachment_size"));
-				baseDao.saveFieldSetEntity(document);
-				baseDao.executeUpdate(" update " + tableInfo.getString("table_name") + " set " + archiveFlagField + "= '1' where uuid=?", new Object[]{file.getString("record_uuid")});
-			}
-		} while (!DataTableEntity.isEmpty(files));
+                files = baseDao.listTable(sql.toString(), new Object[]{});
+                if (DataTableEntity.isEmpty(files)) {
+                    break;
+                }
+                for (int i = 0; i < files.getRows(); i++) {
+                    String sub_folder = fs.getString("sub_folder");
+                    if (StringUtils.isEmpty(sub_folder)) {
+                        sub_folder = "{#" + fs.getString("field_title") + "#}";
+                    }
+                    FieldSetEntity file = files.getFieldSetEntity(i);
+//                鏌ヨ璁板綍
+                    FieldSetEntity record = baseDao.getFieldSet(tableInfo.getString(CoreConst.FIELD_TABLE_NAME), file.getString("record_uuid"), false);
+                    baseDao.loadPromptData(record);
+                    sub_folder = SystemParamReplace.formParamsReplace(sub_folder, record);
+                    Set<String> attachments = Sets.newHashSet();
+                    for (String field : fileField) {
+                        if (StringUtils.isEmpty(files.getString(i, field))) {
+                            continue;
+                        }
+                        attachments.addAll(Arrays.asList(files.getString(i, field).split(",")));
+                    }
+                    String flowAttachments = files.getString(i, "flow_attachments");
+                    if (!StringUtils.isEmpty(flowAttachments)) {
+                        attachments.addAll(Arrays.asList(flowAttachments.split(",")));
+                    }
+                    if (attachments.isEmpty()) {
+                        baseDao.executeUpdate(" update " + tableInfo.getString("table_name") + " set " + archiveFlagField + "= '1' where uuid=?", new Object[]{file.getString("record_uuid")});
+                        continue;
+                    }
+                    String[] dirs = sub_folder.split("/");
+                    //閫掑綊鏌ヨ鐖剁骇鐩綍
+                    FieldSetEntity parent = parentDir;
+                    for (int j = 0; j < dirs.length; j++) {
+                        String dir = dirs[j];
+                        FieldSetEntity temp = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY, "tricode_parent=? and directory_name=?", new String[]{parent.getString("tricode"), dir}, false);
+                        if (FieldSetEntity.isEmpty(temp)) {
+                            //鍒涘缓鏂囦欢澶�
+                            parent = addDirectory(dir, BaseUtil.createCode(CmnConst.PRODUCT_OA_DIRECTORY,
+                                    CmnConst.TRICODE,
+                                    parent.getString("tricode")), parent.getString(CmnConst.TRICODE), parent.getInteger("directory_tier") + 1, fs.getUUID(), tableInfo.getString(CoreConst.FIELD_TABLE_NAME));
+                        } else {
+                            parent = temp;
+                        }
+                    }
+
+                    DataTableEntity documents = new DataTableEntity();
+                    Set<String> uuids = attachments;
+                    DataTableEntity attachmentInfos = baseDao.listTable(CmnConst.PRODUCT_SYS_ATTACHMENTS, BaseUtil.buildQuestionMarkFilter("uuid", uuids.size(), true), uuids.toArray());
+                    DataTableEntity types = DataPoolCacheImpl.getInstance().getCacheData("鏁版嵁瀛楀吀閰嶇疆淇℃伅", new String[]{"upload_file_format"});
+                    if (!DataTableEntity.isEmpty(attachmentInfos)) {
+                        for (int k = 0; k < attachmentInfos.getRows(); k++) {
+                            FieldSetEntity document = new FieldSetEntity();
+                            FieldSetEntity attachment = attachmentInfos.getFieldSetEntity(k);
+                            document.setTableName(CmnConst.PRODUCT_OA_DOCUMENT);
+                            document.setValue("directory_uuid", parent.getUUID());
+                            document.setValue("file_name", attachment.getString("file_name"));
+                            document.setValue("attachments_uuid", attachment.getUUID());
+                            if (CollectionUtil.isEmpty(types.getFieldSetEntity(attachment.getString(CmnConst.ATTACHMENT_TYPE_UUID)))) {
+                                document.setValue("file_type", attachment.getString("attachment_type_uuid"));
+                            } else {
+                                document.setValue("file_type", types.getFieldSetEntity(attachment.getString(CmnConst.ATTACHMENT_TYPE_UUID)).get(0).getString("dict_label"));
+                            }
+
+                            document.setValue("created_by", 1);
+                            document.setValue("created_utc_datetime", new Date());
+                            document.setValue("file_size", attachment.getString("attachment_size"));
+                            document.setValue("turn_button", null);
+                            documents.addFieldSetEntity(document);
+                        }
+                    }
+                    FieldSetEntity document = new FieldSetEntity();
+                    document.setTableName(CmnConst.PRODUCT_OA_DOCUMENT);
+                    document.setValue("directory_uuid", parent.getUUID());
+                    document.setValue("file_name", file.getString("flow_title"));
+                    document.setValue("created_by", 1);
+                    document.setValue("created_utc_datetime", new Date());
+                    document.setValue("turn_button", fs.getString("turn_button"));
+                    document.setValue("file_size", 0);
+                    document.setValue("file_type", "铏氭嫙鏂囨。");
+                    documents.addFieldSetEntity(document);
+                    baseDao.add(documents);
+                    baseDao.executeUpdate(" update " + tableInfo.getString("table_name") + " set " + archiveFlagField + "= '1' where uuid=?", new Object[]{file.getString("record_uuid")});
+                }
+            } while (!DataTableEntity.isEmpty(files) && files.getRows() == pageSize);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+
+    }
+
+    /**
+     * @param sql
+     * @param field_title    鏍囬瀛楁
+     * @param filing_catalog 鐖剁骇褰掓。鐩綍
+     */
+    private void fieldLimit(String sql, String nodeSal, String field_title, String sub_folder, String filing_catalog, String turn_button, String table) {
+
+        //鑾峰彇鐖剁被鏂囨。淇℃伅
+        FieldSetEntity parentDirectory = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY, "tricode=?", new String[]{filing_catalog}, false);
+        DataTableEntity fieldDt = baseDao.listTable(sql, new String[]{table});
+        //鑾峰彇娴佺▼闄勪欢骞跺姞鍏ュ埌file閲�
+        DataTableEntity nodeDt = baseDao.listTable(nodeSal, new String[]{});
+        for (int i = 0; i < nodeDt.getRows(); i++) {
+            FieldSetEntity fieldfs = fieldDt.getFieldSetEntity(nodeDt.getString(i, "uuid")).get(0);
+            if (!FieldSetEntity.isEmpty(fieldfs)) {
+                if (StringUtils.isEmpty(fieldfs.getString("file"))) {
+                    fieldfs.setValue("file", nodeDt.getString(i, "flow_attachment"));
+                } else {
+                    fieldfs.setValue("file", fieldfs.getString("file") + "," + nodeDt.getString(i, "flow_attachment"));
+                }
+            }
+        }
+
+        ArrayList<String> fileList = new ArrayList<>();
+        for (int i = 0; i < fieldDt.getRows(); i++) {
+            String file = fieldDt.getString(i, "file");
+            if (!StringUtils.isEmpty(file)) {
+                for (int j = 0; j < file.split(",").length; j++) {
+                    fileList.add(file.split(",")[j]);
+                }
+            }
+        }
+        DataTableEntity attachments = baseDao.listTable(CmnConst.PRODUCT_SYS_ATTACHMENTS, BaseUtil.buildQuestionMarkFilter("uuid", fileList.size(), true), fileList.toArray(new String[0]));
+        if (fieldDt.getRows() > 0) {
+            for (int i = 0; i < fieldDt.getRows(); i++) {
+                FieldSetEntity fs = fieldDt.getFieldSetEntity(i);
+                String directoryUUID = null;
+                if (StringUtils.isEmpty(fs.getString("directory_uuid"))) {
+                    //鏍规嵁涓婄骇鐩綍鑾峰彇鐩綍缂栧彿
+                    String tricode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, filing_catalog);
+                    //鑾峰彇鐩綍鍚嶇О
+                    String title = fs.getString(field_title);
+                    directoryUUID = addDirectory(title, tricode, filing_catalog, parentDirectory.getInteger("directory_tier") + 1, fs.getUUID(), table).getUUID();
+
+                } else {
+                    directoryUUID = fs.getString("directory_uuid");
+                }
+                String file = fs.getString("file");
+                if (!StringUtils.isEmpty(file)) {
+                    for (int j = 0; j < file.split(",").length; j++) {
+                        //鍒涘缓鏂囦欢
+                        String f = file.split(",")[j];
+                        if (StringUtils.isEmpty(file.split(",")[j]) || DataTableEntity.isEmpty(attachments)) {
+                            continue;
+                        }
+                        FieldSetEntity attachmentsFs = attachments.getFieldSetEntity(f).get(0);
+                        FieldSetEntity document = new FieldSetEntity();
+                        document.setTableName(CmnConst.PRODUCT_OA_DOCUMENT);
+                        document.setValue("directory_uuid", directoryUUID);
+                        document.setValue("file_name", attachmentsFs.getString("file_name"));
+                        document.setValue("attachments_uuid", f);
+                        String[] type = f.split("\\.");
+                        document.setValue("file_type", type[type.length - 1]);
+                        document.setValue("created_by", 1);
+                        document.setValue("created_utc_datetime", new Date());
+                        document.setValue("file_size", attachmentsFs.getString("attachment_size"));
+                        baseDao.saveFieldSetEntity(document);
+                    }
+                }
+                FieldSetEntity document = new FieldSetEntity();
+                document.setTableName(CmnConst.PRODUCT_OA_DOCUMENT);
+                document.setValue("directory_uuid", directoryUUID);
+                document.setValue("file_name", fs.getString(field_title) + " " + fs.getString("user_name") + " " + fs.getString("send_time"));
+                document.setValue("created_by", 1);
+                document.setValue("created_utc_datetime", new Date());
+                document.setValue("turn_button", turn_button);
+                document.setValue("file_size", 0);
+                document.setValue("file_type", "铏氭嫙鏂囨。");
+
+                baseDao.saveFieldSetEntity(document);
+                baseDao.executeUpdate("UPDATE " + table + " set archive_flag =1 where uuid=?", new String[]{fs.getUUID()});
+            }
+            fieldLimit(sql, nodeSal, field_title, sub_folder, filing_catalog, turn_button, table);
+        }
+    }
+
+    /**
+     * @param field_title    鐩綍鏍囬
+     * @param tricode        缂栧彿
+     * @param tricode_parent 鐖剁骇缂栧彿
+     * @param directory_tier 鐩綍灞傜骇
+     */
+
+    private FieldSetEntity addDirectory(String field_title, String tricode, String tricode_parent, Integer directory_tier, String filing_config_field_uuid, String table) {
+        //鏂板缓鐩綍
+        FieldSetEntity fsDirectory = new FieldSetEntity();
+        fsDirectory.setTableName(CmnConst.PRODUCT_OA_DIRECTORY);
+        fsDirectory.setValue("created_by", 1);
+        fsDirectory.setValue("created_utc_datetime", new Date());
+        fsDirectory.setValue("org_level_uuid", "00000000-0000-0000-0000-000000000000");
+        fsDirectory.setValue("directory_name", field_title);
+        fsDirectory.setValue("directory_tier", directory_tier);
+        fsDirectory.setValue("directory_type", 1);
+        fsDirectory.setValue("tricode", tricode);
+        fsDirectory.setValue("tricode_parent", tricode_parent);
+        fsDirectory.setValue("filing_config_field_uuid", filing_config_field_uuid);
+        fsDirectory.setValue("filing_config_table", table);
+
+        baseDao.saveFieldSetEntity(fsDirectory);
+        return fsDirectory;
+    }
 
 
-	}
+    @Override
+    @Transactional
+    public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException {
+        String uuid = fieldSetEntity.getString(CmnConst.UUID);
+        String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE);
+        String filter = "";
+        if ("2".equals(directory_type)) {
+            filter = " AND " + "created_by = " + SpringMVCContextHolder.getCurrentUserId();
+        }
+        DataTableEntity dataTableEntity = baseDao.listTable(
+                "SELECT * FROM PRODUCT_OA_directory WHERE directory_type = ? AND tricode_parent = (SELECT tricode FROM PRODUCT_OA_directory where uuid = ?)"
+                        + filter,
+                new String[]{directory_type, uuid});
+        if (BaseUtil.dataTableIsEmpty(dataTableEntity)) {
+            baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT, "directory_uuid = ?", new String[]{uuid});
+            return baseDao.delete(CmnConst.PRODUCT_OA_DIRECTORY, new String[]{uuid});
+        } else {
+            throw new BaseException(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(),
+                    DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText(), this.getClass(),
+                    "public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException");
+        }
+    }
 
-	/**
-	 *
-	 * @param sql
-	 * @param field_title 鏍囬瀛楁
-	 * @param filing_catalog 鐖剁骇褰掓。鐩綍
-	 */
-	private void fieldLimit(String sql, String nodeSal, String field_title, String sub_folder, String filing_catalog, String turn_button, String table) {
+    /**
+     * 鑾峰彇褰撳墠鏂囦欢璺緞
+     *
+     * @param fieldSetEntity
+     * @return
+     * @throws BaseException
+     */
+    @Override
+    public DataTableEntity getDirectoryStructure(FieldSetEntity fieldSetEntity) throws BaseException {
+        String uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID);
+        fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false);
+        String triCode = fieldSetEntity.getString(CmnConst.TRICODE);
+        String type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE);
+        List<String> codeList = ListUtils.newArrayList();
+        // 鎷嗗垎涓轰笂绾х洰褰�
+        if (triCode.indexOf('-') != -1) {
+            do {
+                codeList.add(0, triCode);
+                triCode = triCode.substring(0, triCode.lastIndexOf('-'));
+            } while (triCode.indexOf('-') != -1);
+            codeList.add(0, triCode);
+        } else {
+            codeList.add(triCode);
+        }
+        SystemUser user = SpringMVCContextHolder.getCurrentUser();
+        DataTableEntity dataTableEntity;
+        // 鍗曚綅鏂囦欢澶�
+        if ("1".equals(type)) {
+            codeList.add(0, user.getOrg_level_uuid());
+            dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY,
+                    "directory_type = 1 AND org_level_uuid = ? AND "
+                            + BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE, codeList.size() - 1, true),
+                    codeList.toArray(), "tricode");
+            // 涓汉鏂囦欢澶�
+        } else {
+            codeList.add(0, String.valueOf(user.getUser_id()));
+            dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY,
+                    "directory_type = 2 AND created_by = ? AND "
+                            + BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE, codeList.size() - 1, true),
+                    codeList.toArray(), "tricode");
+        }
+        baseDao.listInternationDataTable(dataTableEntity, null);
+        return dataTableEntity;
+    }
 
-		//鑾峰彇鐖剁被鏂囨。淇℃伅
-		FieldSetEntity parentDirectory = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY, "tricode=?", new String[]{filing_catalog}, false);
-		DataTableEntity fieldDt = baseDao.listTable(sql, new String[]{table});
-		//鑾峰彇娴佺▼闄勪欢骞跺姞鍏ュ埌file閲�
-		DataTableEntity nodeDt = baseDao.listTable(nodeSal, new String[]{});
-		for (int i = 0; i < nodeDt.getRows(); i++) {
-			FieldSetEntity fieldfs = fieldDt.getFieldSetEntity(nodeDt.getString(i, "uuid")).get(0);
-			if (!FieldSetEntity.isEmpty(fieldfs)) {
-				if (StringUtils.isEmpty(fieldfs.getString("file"))) {
-					fieldfs.setValue("file", nodeDt.getString(i, "flow_attachment"));
-				} else {
-					fieldfs.setValue("file", fieldfs.getString("file") + "," + nodeDt.getString(i, "flow_attachment"));
-				}
-			}
-		}
+    @Override
+    public JSONArray treeListAll(FieldSetEntity fieldSetEntity) throws BaseException {
+        // 鍏宠仈鍏徃uuid
+        String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE);
+        // 鍏徃鏂囦欢澶�
+        DataTableEntity data;
+        SystemUser user = SpringMVCContextHolder.getCurrentUser();
+        StringBuffer sql = new StringBuffer();
+        sql.append("SELECT a.*,ifnull(b.number,0) number FROM PRODUCT_OA_directory a LEFT JOIN ");
+        sql.append(
+                "(SELECT COUNT(*) number,directory_uuid FROM PRODUCT_OA_document GROUP BY directory_uuid)  b on a.uuid=b.directory_uuid ");
 
-		ArrayList<String> fileList = new ArrayList<>();
-		for (int i = 0; i < fieldDt.getRows(); i++) {
-			String file = fieldDt.getString(i, "file");
-			if (!StringUtils.isEmpty(file)) {
-				for (int j = 0; j < file.split(",").length; j++) {
-					fileList.add(file.split(",")[j]);
-				}
-			}
-		}
-		DataTableEntity attachments = baseDao.listTable(CmnConst.PRODUCT_SYS_ATTACHMENTS, BaseUtil.buildQuestionMarkFilter("uuid", fileList.size(), true), fileList.toArray(new String[0]));
-		if (fieldDt.getRows() > 0) {
-			for (int i = 0; i < fieldDt.getRows(); i++) {
-				FieldSetEntity fs = fieldDt.getFieldSetEntity(i);
-				String directoryUUID = null;
-				if (StringUtils.isEmpty(fs.getString("directory_uuid"))) {
-					//鏍规嵁涓婄骇鐩綍鑾峰彇鐩綍缂栧彿
-					String tricode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, filing_catalog);
-					//鑾峰彇鐩綍鍚嶇О
-					String title = fs.getString(field_title);
-					directoryUUID = addDirectory(title, tricode, filing_catalog, parentDirectory.getInteger("directory_tier") + 1, fs.getUUID(), table).getUUID();
-
-				} else {
-					directoryUUID = fs.getString("directory_uuid");
-				}
-				String file = fs.getString("file");
-				if (!StringUtils.isEmpty(file)) {
-					for (int j = 0; j < file.split(",").length; j++) {
-						//鍒涘缓鏂囦欢
-						String f = file.split(",")[j];
-						if (StringUtils.isEmpty(file.split(",")[j]) || DataTableEntity.isEmpty(attachments)) {
-							continue;
-						}
-						FieldSetEntity attachmentsFs = attachments.getFieldSetEntity(f).get(0);
-						FieldSetEntity document = new FieldSetEntity();
-						document.setTableName(CmnConst.PRODUCT_OA_DOCUMENT);
-						document.setValue("directory_uuid", directoryUUID);
-						document.setValue("file_name", attachmentsFs.getString("file_name"));
-						document.setValue("attachments_uuid", f);
-						String[] type = f.split("\\.");
-						document.setValue("file_type", type[type.length - 1]);
-						document.setValue("created_by", 1);
-						document.setValue("created_utc_datetime", new Date());
-						document.setValue("file_size", attachmentsFs.getString("attachment_size"));
-						baseDao.saveFieldSetEntity(document);
-					}
-				}
-				FieldSetEntity document = new FieldSetEntity();
-				document.setTableName(CmnConst.PRODUCT_OA_DOCUMENT);
-				document.setValue("directory_uuid", directoryUUID);
-				document.setValue("file_name", fs.getString(field_title) + " " + fs.getString("user_name") + " " + fs.getString("send_time"));
-				document.setValue("created_by", 1);
-				document.setValue("created_utc_datetime", new Date());
-				document.setValue("turn_button", turn_button);
-				document.setValue("file_size", 0);
-				document.setValue("file_type", "铏氭嫙鏂囨。");
-
-				baseDao.saveFieldSetEntity(document);
-				baseDao.executeUpdate("UPDATE " + table + " set archive_flag =1 where uuid=?", new String[]{fs.getUUID()});
-			}
-			fieldLimit(sql, nodeSal, field_title, sub_folder, filing_catalog, turn_button, table);
-		}
-	}
-
-	/**
-	 *
-	 * @param field_title 鐩綍鏍囬
-	 * @param tricode  缂栧彿
-	 * @param tricode_parent 鐖剁骇缂栧彿
-	 * @param directory_tier 鐩綍灞傜骇
-	 */
-
-	private FieldSetEntity addDirectory(String field_title, String tricode, String tricode_parent, Integer directory_tier, String filing_config_field_uuid, String table) {
-		//鏂板缓鐩綍
-		FieldSetEntity fsDirectory = new FieldSetEntity();
-		fsDirectory.setTableName(CmnConst.PRODUCT_OA_DIRECTORY);
-		fsDirectory.setValue("created_by", 1);
-		fsDirectory.setValue("created_utc_datetime", new Date());
-		fsDirectory.setValue("org_level_uuid", "00000000-0000-0000-0000-000000000000");
-		fsDirectory.setValue("directory_name", field_title);
-		fsDirectory.setValue("directory_tier", directory_tier);
-		fsDirectory.setValue("directory_type", 1);
-		fsDirectory.setValue("tricode", tricode);
-		fsDirectory.setValue("tricode_parent", tricode_parent);
-		fsDirectory.setValue("filing_config_field_uuid", filing_config_field_uuid);
-		fsDirectory.setValue("filing_config_table", table);
-
-		baseDao.saveFieldSetEntity(fsDirectory);
-		return fsDirectory;
-	}
-
-
-	@Override
-	@Transactional
-	public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException {
-		String uuid = fieldSetEntity.getString(CmnConst.UUID);
-		String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE);
-		String filter = "";
-		if ("2".equals(directory_type)) {
-			filter = " AND " + "created_by = " + SpringMVCContextHolder.getCurrentUserId();
-		}
-		DataTableEntity dataTableEntity = baseDao.listTable(
-				"SELECT * FROM PRODUCT_OA_directory WHERE directory_type = ? AND tricode_parent = (SELECT tricode FROM PRODUCT_OA_directory where uuid = ?)"
-						+ filter,
-				new String[]{directory_type, uuid});
-		if (BaseUtil.dataTableIsEmpty(dataTableEntity)) {
-			baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT, "directory_uuid = ?", new String[]{uuid});
-			return baseDao.delete(CmnConst.PRODUCT_OA_DIRECTORY, new String[]{uuid});
-		} else {
-			throw new BaseException(DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getValue(),
-					DocumentCode.DOCUMENT_CATALOG_DELETE_FAIL.getText(), this.getClass(),
-					"public boolean delDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException");
-		}
-	}
-
-	/**
-	 * 鑾峰彇褰撳墠鏂囦欢璺緞
-	 *
-	 * @param fieldSetEntity
-	 * @return
-	 * @throws BaseException
-	 */
-	@Override
-	public DataTableEntity getDirectoryStructure(FieldSetEntity fieldSetEntity) throws BaseException {
-		String uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID);
-		fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false);
-		String triCode = fieldSetEntity.getString(CmnConst.TRICODE);
-		String type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE);
-		List<String> codeList = ListUtils.newArrayList();
-		// 鎷嗗垎涓轰笂绾х洰褰�
-		if (triCode.indexOf('-') != -1) {
-			do {
-				codeList.add(0, triCode);
-				triCode = triCode.substring(0, triCode.lastIndexOf('-'));
-			} while (triCode.indexOf('-') != -1);
-			codeList.add(0, triCode);
-		} else {
-			codeList.add(triCode);
-		}
-		SystemUser user = SpringMVCContextHolder.getCurrentUser();
-		DataTableEntity dataTableEntity;
-		// 鍗曚綅鏂囦欢澶�
-		if ("1".equals(type)) {
-			codeList.add(0, user.getOrg_level_uuid());
-			dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY,
-					"directory_type = 1 AND org_level_uuid = ? AND "
-							+ BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE, codeList.size() - 1, true),
-					codeList.toArray(), "tricode");
-			// 涓汉鏂囦欢澶�
-		} else {
-			codeList.add(0, String.valueOf(user.getUser_id()));
-			dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY,
-					"directory_type = 2 AND created_by = ? AND "
-							+ BaseUtil.buildQuestionMarkFilter(CmnConst.TRICODE, codeList.size() - 1, true),
-					codeList.toArray(), "tricode");
-		}
-		baseDao.listInternationDataTable(dataTableEntity, null);
-		return dataTableEntity;
-	}
-
-	@Override
-	public JSONArray treeListAll(FieldSetEntity fieldSetEntity) throws BaseException {
-		// 鍏宠仈鍏徃uuid
-		String directory_type = fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE);
-		// 鍏徃鏂囦欢澶�
-		DataTableEntity data;
-		SystemUser user = SpringMVCContextHolder.getCurrentUser();
-		StringBuffer sql = new StringBuffer();
-		sql.append("SELECT a.*,ifnull(b.number,0) number FROM PRODUCT_OA_directory a LEFT JOIN ");
-		sql.append(
-				"(SELECT COUNT(*) number,directory_uuid FROM PRODUCT_OA_document GROUP BY directory_uuid)  b on a.uuid=b.directory_uuid ");
-
-		if ("1".equals(directory_type)) {
-			String org_level_uuid = user.getOrg_level_uuid();
-			sql.append("where directory_type = 1 AND org_level_uuid = ? ");
-			data = baseDao.listTable(sql.toString(), new Object[]{org_level_uuid});
+        if ("1".equals(directory_type)) {
+            String org_level_uuid = user.getOrg_level_uuid();
+            sql.append("where directory_type = 1 AND org_level_uuid = ? ");
+            data = baseDao.listTable(sql.toString(), new Object[]{org_level_uuid});
 //      data = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, " directory_type = 1 AND org_level_uuid = ?", new String[]{org_level_uuid}, "tricode");
-			// 涓汉鏂囦欢澶�
-		} else {
-			Integer userId = user.getUser_id();
-			sql.append("where directory_type = 2 AND created_by = ? ");
-			data = baseDao.listTable(sql.toString(), new Object[]{userId});
+            // 涓汉鏂囦欢澶�
+        } else {
+            Integer userId = user.getUser_id();
+            sql.append("where directory_type = 2 AND created_by = ? ");
+            data = baseDao.listTable(sql.toString(), new Object[]{userId});
 
 //      data = baseDao.listTable(CmnConst.PRODUCT_OA_DIRECTORY, " directory_type = 2 AND created_by = ?", new Object[]{userId}, "tricode");
-		}
+        }
 
 
-		baseDao.listInternationDataTable(data, null);
-		JSONArray menus = this.encapsulationTree(data);
-		// 鑾峰彇褰撳墠鍏徃
-		JSONObject orgLevelInfo = new JSONObject();
-		String orgLevelName = user.getOrg_level_name();
+        baseDao.listInternationDataTable(data, null);
+        JSONArray menus = this.encapsulationTree(data);
+        // 鑾峰彇褰撳墠鍏徃
+        JSONObject orgLevelInfo = new JSONObject();
+        String orgLevelName = user.getOrg_level_name();
 
-		orgLevelInfo.put("directory_name", orgLevelName);
-		orgLevelInfo.put("tricode", "");
-		orgLevelInfo.put("org_level_uuid", user.getOrg_level_uuid());
-		orgLevelInfo.put("children", menus);
-		JSONArray array = new JSONArray();
-		if (!"1".equals(directory_type)) {
+        orgLevelInfo.put("directory_name", orgLevelName);
+        orgLevelInfo.put("tricode", "");
+        orgLevelInfo.put("org_level_uuid", user.getOrg_level_uuid());
+        orgLevelInfo.put("children", menus);
+        JSONArray array = new JSONArray();
+        if (!"1".equals(directory_type)) {
 //		鏌ヨ鏁伴噺
-			sql.setLength(0);
-			sql.append(" SELECT\n");
-			sql.append("		( SELECT count(*) FROM product_oa_document_collection WHERE document_collector = ? ) collection_count,\n");
-			sql.append("		( SELECT count(distinct sub_uuid ) FROM product_oa_document_borrow_sub WHERE borrow_uuid IN ( SELECT uuid FROM product_oa_document_borrow WHERE borrower = ? and flow_flag=2) ) borrow_count\n");
-			sql.append("		FROM\n");
-			sql.append("DUAL\n");
-			FieldSetEntity fieldSetBySQL = baseDao.getFieldSetBySQL(sql.toString(), new Object[]{user.getUser_id(), user.getUser_id()}, false);
-			int collectionCount = 0;
-			int borrowCount = 0;
-			if (fieldSetBySQL != null) {
-				collectionCount = BaseUtil.ifNull(fieldSetBySQL.getInteger("collection_count"), 0);
-				borrowCount = BaseUtil.ifNull(fieldSetBySQL.getInteger("borrow_count"), 0);
-			}
-			//娣诲姞鏀惰棌澶瑰拰鍊熼槄鏂囦欢澶�
-			JSONObject favorite = new JSONObject();
-			favorite.put("directory_name", "鏀惰棌澶�");
-			favorite.put("uuid", "!favorite");
-			favorite.put("number", collectionCount);
-			menus.add(0, favorite);
-			JSONObject borrow = new JSONObject();
-			borrow.put("directory_name", "鍊熼槄鏂囦欢");
-			borrow.put("uuid", "!borrow");
-			borrow.put("number", borrowCount);
-			menus.add(1, borrow);
-		}
-		array.add(orgLevelInfo);
-		return array;
-	}
+            sql.setLength(0);
+            sql.append(" SELECT\n");
+            sql.append("		( SELECT count(*) FROM product_oa_document_collection WHERE document_collector = ? ) collection_count,\n");
+            sql.append("		( SELECT count(distinct sub_uuid ) FROM product_oa_document_borrow_sub WHERE borrow_uuid IN ( SELECT uuid FROM product_oa_document_borrow WHERE borrower = ? and flow_flag=2) ) borrow_count\n");
+            sql.append("		FROM\n");
+            sql.append("DUAL\n");
+            FieldSetEntity fieldSetBySQL = baseDao.getFieldSetBySQL(sql.toString(), new Object[]{user.getUser_id(), user.getUser_id()}, false);
+            int collectionCount = 0;
+            int borrowCount = 0;
+            if (fieldSetBySQL != null) {
+                collectionCount = BaseUtil.ifNull(fieldSetBySQL.getInteger("collection_count"), 0);
+                borrowCount = BaseUtil.ifNull(fieldSetBySQL.getInteger("borrow_count"), 0);
+            }
+            //娣诲姞鏀惰棌澶瑰拰鍊熼槄鏂囦欢澶�
+            JSONObject favorite = new JSONObject();
+            favorite.put("directory_name", "鏀惰棌澶�");
+            favorite.put("uuid", "!favorite");
+            favorite.put("number", collectionCount);
+            menus.add(0, favorite);
+            JSONObject borrow = new JSONObject();
+            borrow.put("directory_name", "鍊熼槄鏂囦欢");
+            borrow.put("uuid", "!borrow");
+            borrow.put("number", borrowCount);
+            menus.add(1, borrow);
+        }
+        array.add(orgLevelInfo);
+        return array;
+    }
 
-	/**
-	 * 灏佽鏍戞柟娉�
-	 *
-	 * @param
-	 * @return
-	 * @throws BaseException
-	 */
-	@Override
-	public JSONArray encapsulationTree(DataTableEntity data) throws BaseException {
-		JSONArray menus = new JSONArray();
-		JSONObject parent_menu = new JSONObject();
-		if (!BaseUtil.dataTableIsEmpty(data)) {
-			for (int i = 0; i < data.getRows(); i++) {
-				FieldSetEntity fs = data.getFieldSetEntity(i);
-				JSONObject menu = BaseUtil.fieldSetEntityToJson(fs);
-				String tricode = fs.getString(CmnConst.TRICODE_PARENT);
-				if (StringUtils.isEmpty(tricode) || parent_menu.getString(tricode) == null) {
-					menus.add(menu);
-				} else {// 涓婄骇鐩綍
-					JSONObject pm = parent_menu.getJSONObject(tricode);
-					JSONArray subs = pm.getJSONArray(CmnConst.CHILDREN);
-					JSONArray submenus = null;
-					if (subs == null) {
-						submenus = new JSONArray();
-						pm.put(CmnConst.CHILDREN, submenus);
-					} else {
-						submenus = subs;
-					}
-					submenus.add(menu);
-				}
-				parent_menu.put(menu.getString(CmnConst.TRICODE), menu);
-			}
-		}
-		return menus;
-	}
+    /**
+     * 灏佽鏍戞柟娉�
+     *
+     * @param
+     * @return
+     * @throws BaseException
+     */
+    @Override
+    public JSONArray encapsulationTree(DataTableEntity data) throws BaseException {
+        JSONArray menus = new JSONArray();
+        JSONObject parent_menu = new JSONObject();
+        if (!BaseUtil.dataTableIsEmpty(data)) {
+            for (int i = 0; i < data.getRows(); i++) {
+                FieldSetEntity fs = data.getFieldSetEntity(i);
+                JSONObject menu = BaseUtil.fieldSetEntityToJson(fs);
+                String tricode = fs.getString(CmnConst.TRICODE_PARENT);
+                if (StringUtils.isEmpty(tricode) || parent_menu.getString(tricode) == null) {
+                    menus.add(menu);
+                } else {// 涓婄骇鐩綍
+                    JSONObject pm = parent_menu.getJSONObject(tricode);
+                    JSONArray subs = pm.getJSONArray(CmnConst.CHILDREN);
+                    JSONArray submenus = null;
+                    if (subs == null) {
+                        submenus = new JSONArray();
+                        pm.put(CmnConst.CHILDREN, submenus);
+                    } else {
+                        submenus = subs;
+                    }
+                    submenus.add(menu);
+                }
+                parent_menu.put(menu.getString(CmnConst.TRICODE), menu);
+            }
+        }
+        return menus;
+    }
 
-	@Override
-	public FieldSetEntity documentDirectoryInfo(FieldSetEntity fieldSetEntity) throws BaseException {
-		String uuid = fieldSetEntity.getString(CmnConst.UUID);
-		return baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, true);
-	}
+    @Override
+    public FieldSetEntity documentDirectoryInfo(FieldSetEntity fieldSetEntity) throws BaseException {
+        String uuid = fieldSetEntity.getString(CmnConst.UUID);
+        return baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, true);
+    }
 
-	/**
-	 * 绉诲姩鍒扮洰褰曞垪琛紙鏍规嵁褰撳墠鐢ㄦ埛杩囨护灞曠ず鐩綍鍒楄〃锛� 鑾峰彇鐢ㄦ埛鏈夋柊澧烇紙涓婁紶锛夋潈闄愮殑鍒楄〃
-	 *
-	 * @param
-	 * @return
-	 * @throws BaseException
-	 */
-	@Override
-	public DataTableEntity moveToList(FieldSetEntity fse) throws BaseException {
-		String type = fse.getString(CmnConst.DIRECTORY_TYPE);
-		StringBuffer sql = new StringBuffer();
-		Integer userId = SpringMVCContextHolder.getCurrentUser().getUser_id();
-		StringBuffer param = new StringBuffer();
-		// 1涓哄崟浣嶆枃浠跺す
-		if ("1".equals(type)) {
-			param.append("%").append(userId).append("%");
-			sql.append("SELECT a.* FROM " + CmnConst.PRODUCT_OA_DIRECTORY + " a LEFT JOIN ")
-					.append(" PRODUCT_OA_directory_rights b ON a.uuid = b.directory_uuid ")
-					.append(" LEFT JOIN product_sys_organizational_structure_storage c on b.storage_uuid = c.uuid ")
-					.append(" WHERE a.directory_type = 1 AND b.rigths like '%3%' AND c.staff_ids like ? GROUP BY a.tricode ");
-		} else {
-			param.append(userId);
-			sql.append("SELECT * FROM PRODUCT_OA_directory ").append(" WHERE directory_type = 2 AND created_by = ? ");
-		}
-		DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{param.toString()});
-		baseDao.listInternationDataTable(dataTableEntity, null);
-		return dataTableEntity;
-	}
+    /**
+     * 绉诲姩鍒扮洰褰曞垪琛紙鏍规嵁褰撳墠鐢ㄦ埛杩囨护灞曠ず鐩綍鍒楄〃锛� 鑾峰彇鐢ㄦ埛鏈夋柊澧烇紙涓婁紶锛夋潈闄愮殑鍒楄〃
+     *
+     * @param
+     * @return
+     * @throws BaseException
+     */
+    @Override
+    public DataTableEntity moveToList(FieldSetEntity fse) throws BaseException {
+        String type = fse.getString(CmnConst.DIRECTORY_TYPE);
+        StringBuffer sql = new StringBuffer();
+        Integer userId = SpringMVCContextHolder.getCurrentUser().getUser_id();
+        StringBuffer param = new StringBuffer();
+        // 1涓哄崟浣嶆枃浠跺す
+        if ("1".equals(type)) {
+            param.append("%").append(userId).append("%");
+            sql.append("SELECT a.* FROM " + CmnConst.PRODUCT_OA_DIRECTORY + " a LEFT JOIN ")
+                    .append(" PRODUCT_OA_directory_rights b ON a.uuid = b.directory_uuid ")
+                    .append(" LEFT JOIN product_sys_organizational_structure_storage c on b.storage_uuid = c.uuid ")
+                    .append(" WHERE a.directory_type = 1 AND b.rigths like '%3%' AND c.staff_ids like ? GROUP BY a.tricode ");
+        } else {
+            param.append(userId);
+            sql.append("SELECT * FROM PRODUCT_OA_directory ").append(" WHERE directory_type = 2 AND created_by = ? ");
+        }
+        DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{param.toString()});
+        baseDao.listInternationDataTable(dataTableEntity, null);
+        return dataTableEntity;
+    }
 
-	@Override
-	@Transactional
-	public boolean upDocumentDirectoryName(FieldSetEntity fse) throws BaseException {
-		String uuid = fse.getString(CmnConst.UUID);
-		String directoryName = fse.getString(CmnConst.DIRECTORY_NAME);
-		FieldSetEntity docField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false);
-		docField.setValue(CmnConst.DIRECTORY_NAME, directoryName);
-		return baseDao.update(docField);
-	}
+    @Override
+    @Transactional
+    public boolean upDocumentDirectoryName(FieldSetEntity fse) throws BaseException {
+        String uuid = fse.getString(CmnConst.UUID);
+        String directoryName = fse.getString(CmnConst.DIRECTORY_NAME);
+        FieldSetEntity docField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false);
+        docField.setValue(CmnConst.DIRECTORY_NAME, directoryName);
+        return baseDao.update(docField);
+    }
 }

--
Gitblit v1.9.2