| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.product.common.collect.ListUtils; |
| | | import com.product.common.lang.DateUtils; |
| | | import com.product.core.config.CoreConst; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | |
| | | public BaseDao baseDao; |
| | | @Autowired |
| | | public DocumentDirectoryService documentDirectoryService; |
| | | |
| | | |
| | | /** |
| | | * 单位文件夹树 |
| | | * 单位文件夹树 |
| | | * |
| | | * @return |
| | | */ |
| | | public DataTableEntity allDirectoryTree() { |
| | |
| | | return dtTree; |
| | | } |
| | | |
| | | @Override |
| | | /** |
| | | * 文档目录保存 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public String addDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | |
| | | String triCode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_OA_DIRECTORY, CmnConst.TRICODE, |
| | | !StringUtils.isEmpty(fieldSetEntity.getString(CmnConst.TRICODE_PARENT)) |
| | | ? fieldSetEntity.getString(CmnConst.TRICODE_PARENT) |
| | | : ""); |
| | | fieldSetEntity.setValue(CmnConst.TRICODE, triCode); |
| | | String[] codes = triCode.split("-"); |
| | | String org_level_uuid = SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid(); |
| | | fieldSetEntity.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); |
| | | fieldSetEntity.setValue(CmnConst.DIRECTORY_TIER, codes.length); |
| | | fieldSetEntity.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 获取登录帐号 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 |
| | | return baseDao.add(fieldSetEntity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean upDocumentDirectory(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuid = fieldSetEntity.getString(CmnConst.UUID); |
| | | FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, uuid, false); |
| | | String tricode_parent1 = fieldSetEntity.getString(CmnConst.TRICODE_PARENT); |
| | | String tricode_parent2 = fieldSet.getString(CmnConst.TRICODE_PARENT); |
| | | boolean flag; |
| | | // 上级目录tricode如果不相等 |
| | | if (!StringUtils.isEmpty(tricode_parent1) || !StringUtils.isEmpty(tricode_parent2)) { |
| | | if (!StringUtils.isEmpty(tricode_parent1) && !StringUtils.isEmpty(tricode_parent2) |
| | | && !tricode_parent1.equals(tricode_parent2)) { |
| | | flag = true; |
| | | } else if (!StringUtils.isEmpty(tricode_parent1) && !StringUtils.isEmpty(tricode_parent2) |
| | | && tricode_parent1.equals(tricode_parent2)) { |
| | | flag = false; |
| | | } else if (!StringUtils.isEmpty(tricode_parent1) && StringUtils.isEmpty(tricode_parent2)) { |
| | | tricode_parent2 = ""; |
| | | flag = true; |
| | | } else if (!StringUtils.isEmpty(tricode_parent2) && StringUtils.isEmpty(tricode_parent1)) { |
| | | tricode_parent1 = ""; |
| | | flag = true; |
| | | } else { |
| | | flag = false; |
| | | } |
| | | 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 { |
| | | flag = false; |
| | | 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); |
| | | 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 + "-%"}); |
| | | } else { |
| | | tricode = fseOrigin.getString(CmnConst.TRICODE); |
| | | } |
| | | } |
| | | |
| | | if (flag) { |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append(" update PRODUCT_OA_directory set tricode=replace("); |
| | | sql.append(" tricode,concat(?,'-'),concat(?,'-')),"); |
| | | sql.append(" tricode_parent=(case when tricode_parent=? then replace(tricode_parent,?,?) else "); |
| | | sql.append(" replace (tricode_parent,concat(?,'-'),concat(?,'-')) end )"); |
| | | sql.append(" where tricode like ?"); |
| | | baseDao.executeUpdate(sql.toString(), new String[] { tricode_parent1, tricode_parent2, tricode_parent1, |
| | | tricode_parent1, tricode_parent2, tricode_parent1, tricode_parent2, tricode_parent1 + "-%", }); |
| | | } |
| | | |
| | | fieldSetEntity.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 获取登录帐号 |
| | | fieldSetEntity.setValue(CmnConst.UPDATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 |
| | | return baseDao.update(fieldSetEntity); |
| | | fse.setValue(CmnConst.TRICODE, tricode); |
| | | fse.setValue(CmnConst.DIRECTORY_TIER, tricode.split(",").length); |
| | | return baseDao.saveFieldSetEntity(fse); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | 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 }); |
| | | 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 }); |
| | | 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(), |
| | |
| | | |
| | | /** |
| | | * 获取当前文件路径 |
| | | * |
| | | * |
| | | * @param fieldSetEntity |
| | | * @return |
| | | * @throws BaseException |
| | |
| | | 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(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 }); |
| | | 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"); |
| | | } |
| | |
| | | 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( 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 |
| | |
| | | |
| | | /** |
| | | * 移动到目录列表(根据当前用户过滤展示目录列表) 获取用户有新增(上传)权限的列表 |
| | | * |
| | | * |
| | | * @param |
| | | * @return |
| | | * @throws BaseException |
| | |
| | | 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() }); |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{param.toString()}); |
| | | baseDao.listInternationDataTable(dataTableEntity, null); |
| | | return dataTableEntity; |
| | | } |