| | |
| | | import com.product.common.collect.ListUtils; |
| | | import com.product.common.collect.MapUtils; |
| | | import com.product.common.lang.DateUtils; |
| | | import com.product.common.lang.StringUtils; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldMetaEntity; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Copyright lx |
| | |
| | | @Component |
| | | public class DocumentService extends AbstractBaseService implements IDocumentService { |
| | | |
| | | @Autowired |
| | | public BaseDao baseDao; |
| | | @Autowired |
| | | public BaseDao baseDao; |
| | | |
| | | @Autowired |
| | | public DocumentService documentService; |
| | | @Autowired |
| | | public DocumentService documentService; |
| | | |
| | | @Autowired |
| | | QueryFilterService queryFilterService; |
| | | @Autowired |
| | | QueryFilterService queryFilterService; |
| | | |
| | | @Autowired |
| | | DocumentDirectoryService documentDirectoryService; |
| | | @Autowired |
| | | DocumentDirectoryService documentDirectoryService; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public String addDocument(FieldSetEntity fse) throws BaseException { |
| | | //获取附件目录和附件uuid |
| | | String directory_uuid = fse.getString(CmnConst.DIRECTORY_UUID); |
| | | String fileUUIDs = fse.getString(CmnConst.ATTACHMENTS_UUID); |
| | | String[] fileUUIDArray = fileUUIDs.split(","); |
| | | //获取附件信息 |
| | | DataTableEntity attachments = baseDao.listTable(CmnConst.PRODUCT_SYS_ATTACHMENTS, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, fileUUIDArray, true)); |
| | | List<String> uuidList = ListUtils.newArrayList(); |
| | | List<String> fileNameList = ListUtils.newArrayList(); |
| | | //循环附件信息,生成文档信息 |
| | | for (int i = 0, length = attachments.getRows(); i < length; i++) { |
| | | FieldSetEntity attachment = attachments.getFieldSetEntity(i); |
| | | //创建文档数据容器 |
| | | FieldSetEntity fseDocument = new FieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT); |
| | | fseDocument.setValue(CmnConst.ATTACHMENTS_UUID, attachment.getUUID()); |
| | | fseDocument.setValue(CmnConst.DIRECTORY_UUID, directory_uuid); |
| | | fseDocument.setValue(CmnConst.FILE_SIZE, attachment.getString(CmnConst.ATTACHMENT_SIZE)); |
| | | fseDocument.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | fseDocument.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime()); |
| | | //文件名称 |
| | | String file_name = attachment.getString(CmnConst.FILE_NAME); |
| | | fseDocument.setValue(CmnConst.FILE_NAME, file_name); |
| | | //文件类型 |
| | | String file_type = file_name.substring(file_name.lastIndexOf(".") + 1); |
| | | fseDocument.setValue(CmnConst.FILE_TYPE, file_type); |
| | | //保存数据 |
| | | String documentUUID = baseDao.add(fseDocument); |
| | | @Override |
| | | @Transactional |
| | | public String addDocument(FieldSetEntity fse) throws BaseException { |
| | | //获取附件目录和附件uuid |
| | | String directory_uuid = fse.getString(CmnConst.DIRECTORY_UUID); |
| | | String fileUUIDs = fse.getString(CmnConst.ATTACHMENTS_UUID); |
| | | String[] fileUUIDArray = fileUUIDs.split(","); |
| | | //获取附件信息 |
| | | DataTableEntity attachments = baseDao.listTable(CmnConst.PRODUCT_SYS_ATTACHMENTS, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, fileUUIDArray, true)); |
| | | List<String> uuidList = ListUtils.newArrayList(); |
| | | List<String> fileNameList = ListUtils.newArrayList(); |
| | | //循环附件信息,生成文档信息 |
| | | for (int i = 0, length = attachments.getRows(); i < length; i++) { |
| | | FieldSetEntity attachment = attachments.getFieldSetEntity(i); |
| | | //创建文档数据容器 |
| | | FieldSetEntity fseDocument = new FieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT); |
| | | fseDocument.setValue(CmnConst.ATTACHMENTS_UUID, attachment.getUUID()); |
| | | fseDocument.setValue(CmnConst.DIRECTORY_UUID, directory_uuid); |
| | | fseDocument.setValue(CmnConst.FILE_SIZE, attachment.getString(CmnConst.ATTACHMENT_SIZE)); |
| | | fseDocument.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | fseDocument.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime()); |
| | | //文件名称 |
| | | String file_name = attachment.getString(CmnConst.FILE_NAME); |
| | | fseDocument.setValue(CmnConst.FILE_NAME, file_name); |
| | | //文件类型 |
| | | String file_type = file_name.substring(file_name.lastIndexOf(".") + 1); |
| | | fseDocument.setValue(CmnConst.FILE_TYPE, file_type); |
| | | //保存数据 |
| | | String documentUUID = baseDao.add(fseDocument); |
| | | |
| | | //创建文档版本数据容器 |
| | | FieldSetEntity fseDocumentHistory = new FieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT_HISTORY); |
| | | BaseUtil.createCreatorAndCreationTime(fseDocumentHistory); |
| | | fseDocumentHistory.setValue("document_uuid", documentUUID); |
| | | fseDocumentHistory.setValue("attachment_uuid", attachment.getUUID()); |
| | | fseDocumentHistory.setValue("version_number", "v1"); |
| | | baseDao.add(fseDocumentHistory); |
| | | //创建文档版本数据容器 |
| | | FieldSetEntity fseDocumentHistory = new FieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT_HISTORY); |
| | | BaseUtil.createCreatorAndCreationTime(fseDocumentHistory); |
| | | fseDocumentHistory.setValue("document_uuid", documentUUID); |
| | | fseDocumentHistory.setValue("attachment_uuid", attachment.getUUID()); |
| | | fseDocumentHistory.setValue("version_number", "v1"); |
| | | baseDao.add(fseDocumentHistory); |
| | | |
| | | uuidList.add(documentUUID); |
| | | fileNameList.add(file_name); |
| | | } |
| | | this.documentation(uuidList.toArray(), "新增", fileNameList.toArray(), null); |
| | | return uuidList.toString(); |
| | | } |
| | | uuidList.add(documentUUID); |
| | | fileNameList.add(file_name); |
| | | } |
| | | this.documentation(uuidList.toArray(), "新增", fileNameList.toArray(), null); |
| | | return uuidList.toString(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean upDocumentName(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuid = fieldSetEntity.getString(CmnConst.UUID); |
| | | String file_name = fieldSetEntity.getString(CmnConst.FILE_NAME); |
| | | fieldSetEntity.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 修改人 |
| | | fieldSetEntity.setValue(CmnConst.UPDATED_UTC_DATETIME, DateUtils.getDateTime());// 修改时间 |
| | | FieldSetEntity fie = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, false); |
| | | String name = fie.getString(CmnConst.FILE_NAME); |
| | | //每次修改都亲空已读人员 |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, ""); |
| | | boolean flag = baseDao.update(fieldSetEntity); |
| | | this.documentRepeatOrder(new Object[]{uuid}, "重命名", new Object[]{name}, new Object[]{file_name}); |
| | | return flag; |
| | | } |
| | | @Override |
| | | @Transactional |
| | | public boolean upDocumentName(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuid = fieldSetEntity.getString(CmnConst.UUID); |
| | | String file_name = fieldSetEntity.getString(CmnConst.FILE_NAME); |
| | | fieldSetEntity.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());// 修改人 |
| | | fieldSetEntity.setValue(CmnConst.UPDATED_UTC_DATETIME, DateUtils.getDateTime());// 修改时间 |
| | | FieldSetEntity fie = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, false); |
| | | String name = fie.getString(CmnConst.FILE_NAME); |
| | | //每次修改都亲空已读人员 |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, ""); |
| | | boolean flag = baseDao.update(fieldSetEntity); |
| | | this.documentRepeatOrder(new Object[]{uuid}, "重命名", new Object[]{name}, new Object[]{file_name}); |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 需要批量删除 |
| | | * |
| | | * @param fieldSetEntity |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public boolean delDocument(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuids = fieldSetEntity.getString(CmnConst.UUID); |
| | | String file_names = fieldSetEntity.getString(CmnConst.FILE_NAME); |
| | | String[] file_name = file_names.split(","); |
| | | String[] uuid = uuids.split(","); |
| | | boolean flag = baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT, uuid); |
| | | this.documentation(uuid, "删除", file_name, null); |
| | | return flag; |
| | | } |
| | | /** |
| | | * 需要批量删除 |
| | | * |
| | | * @param fieldSetEntity |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public boolean delDocument(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuids = fieldSetEntity.getString(CmnConst.UUID); |
| | | String file_names = fieldSetEntity.getString(CmnConst.FILE_NAME); |
| | | String[] file_name = file_names.split(","); |
| | | String[] uuid = uuids.split(","); |
| | | boolean flag = baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT, uuid); |
| | | this.documentation(uuid, "删除", file_name, null); |
| | | return flag; |
| | | } |
| | | |
| | | @Override |
| | | public DataTableEntity documentAll(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | //文档目录uuid |
| | | String directory_uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID); |
| | | String queryFilter = queryFilterService.getQueryFilter(fieldSetEntity); |
| | | if (!BaseUtil.strIsNull(queryFilter)) { |
| | | queryFilter = " AND " + queryFilter; |
| | | } |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append("SELECT \n"); |
| | | sql.append(" A.*,B.show_name name, \n"); |
| | | sql.append(" CONCAT(CONVERT(a.file_size / 1024, decimal(10,2)), 'KB') file_size_kb, \n"); |
| | | sql.append(" CASE WHEN D.document_uuid IS NOT NULL THEN '1' ELSE '0' END AS is_collection \n"); |
| | | sql.append("FROM( \n"); |
| | | sql.append(" SELECT * FROM product_oa_document \n"); |
| | | sql.append(" WHERE directory_uuid = ? \n"); |
| | | sql.append(queryFilter); |
| | | sql.append(")A \n"); |
| | | sql.append("LEFT JOIN product_sys_staffs B ON B.user_id = A.created_by \n"); |
| | | sql.append("LEFT JOIN product_sys_attachments C ON C.uuid = B.staff_avatar \n"); |
| | | sql.append("LEFT JOIN product_oa_document_collection D ON D.document_uuid = A.uuid AND D.created_by = ?"); |
| | | DataTableEntity documentData = baseDao.listTable(sql.toString(), new String[]{directory_uuid, SpringMVCContextHolder.getCurrentUserId()}, |
| | | fieldSetEntity.getInteger(CmnConst.PAGESIZE), fieldSetEntity.getInteger(CmnConst.CPAGE)); |
| | | baseDao.listInternationDataTable(documentData, null); |
| | | return documentData; |
| | | } |
| | | @Override |
| | | public DataTableEntity documentAll(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | //文档目录uuid |
| | | String directory_uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID); |
| | | String queryFilter = queryFilterService.getQueryFilter(fieldSetEntity); |
| | | if (!BaseUtil.strIsNull(queryFilter)) { |
| | | queryFilter = " AND " + queryFilter; |
| | | } |
| | | // file_name created_by created_utc_datetime |
| | | |
| | | @Override |
| | | public FieldSetEntity documentInfo(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuid = fieldSetEntity.getString(CmnConst.UUID); |
| | | FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, true); |
| | | String file_name = fieldSet.getString(CmnConst.FILE_NAME); |
| | | String user_ids = fieldSetEntity.getString(CmnConst.USER_IDS); |
| | | String read = fieldSetEntity.getString(CmnConst.READ_NUM); |
| | | if (!BaseUtil.strIsNull(user_ids)) { |
| | | fieldSetEntity.setValue(CmnConst.REQUIRED_NUMBER, user_ids.split(",").length); |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, read.split(",").length); |
| | | } |
| | | this.documentation(new Object[]{uuid}, "查看", new Object[]{file_name}, null); |
| | | return fieldSet; |
| | | } |
| | | StringBuffer sql = new StringBuffer(); |
| | | |
| | | @Override |
| | | public void documentation(Object[] uuid, String opetype, Object[] file_name, String file_directory) throws BaseException { |
| | | //获取文件信息存入日志表 |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | DataTableEntity dataTableEntity = new DataTableEntity(); |
| | | FieldMetaEntity fieldMeta = new FieldMetaEntity(); |
| | | fieldMeta.setTableName(new String[]{CmnConst.PRODUCT_OA_DOCUMENT_LOG}); |
| | | dataTableEntity.setMeta(fieldMeta); |
| | | for (int i = 0; i < uuid.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName(CmnConst.PRODUCT_OA_DOCUMENT_LOG); |
| | | fieldSetEntity.setMeta(fieldMeta); |
| | | fieldSetEntity.setValue(CmnConst.DOCUMENT_UUID, uuid[i]); |
| | | //fieldSetEntity.setValue(CmnConst.RECORD,record); |
| | | fieldSetEntity.setValue(CmnConst.OPETYPE, opetype); |
| | | fieldSetEntity.setValue(CmnConst.OPE_DOCUMENT, file_name[i]); |
| | | StringBuffer state = new StringBuffer(); |
| | | state.append(opetype) |
| | | .append("了[") |
| | | .append(file_name[i]) |
| | | .append("]"); |
| | | if (!BaseUtil.strIsNull(file_directory)) { |
| | | state.append("到").append(file_directory).append("目录下"); |
| | | } |
| | | fieldSetEntity.setValue(CmnConst.STATE, state.toString()); //说明 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_BY, user.getUser_id());// 创建人 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 |
| | | dataTableEntity.addFieldSetEntity(fieldSetEntity); |
| | | } |
| | | baseDao.add(dataTableEntity); |
| | | } |
| | | sql.append("SELECT \n"); |
| | | sql.append(" A.*,B.show_name name, \n"); |
| | | sql.append(" CONCAT(CONVERT(a.file_size / 1024, decimal(10,2)), 'KB') file_size_kb, \n"); |
| | | sql.append(" CASE WHEN D.document_uuid IS NOT NULL THEN '1' ELSE '0' END AS is_collection, \n"); |
| | | sql.append(" (SELECT case when COUNT(*)=0 then 1 else COUNT(*) end FROM product_oa_document_history where product_oa_document_history.document_uuid=A.uuid) -1 history_count "); |
| | | sql.append("FROM( \n"); |
| | | if ("!borrow".equals(directory_uuid)) { |
| | | //借阅文件夹查询文件特殊处理 |
| | | sql.append("SELECT\n"); |
| | | sql.append("doc.*\n"); |
| | | sql.append(" FROM\n"); |
| | | sql.append("product_oa_directory dir\n"); |
| | | sql.append("JOIN product_oa_document doc ON dir.uuid = doc.uuid\n"); |
| | | sql.append("WHERE\n"); |
| | | sql.append("dir.directory_type = 1\n"); |
| | | sql.append("AND doc.attachments_uuid IN (\n"); |
| | | sql.append(" SELECT\n"); |
| | | sql.append(" sub_uuid\n"); |
| | | sql.append(" FROM\n"); |
| | | sql.append(" product_oa_document_borrow_sub\n"); |
| | | sql.append(" WHERE\n"); |
| | | sql.append(" borrow_uuid IN ( SELECT uuid FROM product_oa_document_borrow WHERE borrower = ? AND flow_flag=2))\n"); |
| | | directory_uuid = SpringMVCContextHolder.getCurrentUserId(); |
| | | } else if ("!favorite".equals(directory_uuid)) { |
| | | sql.append("SELECT\n"); |
| | | sql.append("doc.*\n"); |
| | | sql.append(" FROM\n"); |
| | | sql.append("product_oa_document_collection collect\n"); |
| | | sql.append("JOIN product_oa_document doc ON collect.document_uuid = doc.uuid\n"); |
| | | sql.append("where document_collector=?\n"); |
| | | directory_uuid = SpringMVCContextHolder.getCurrentUserId(); |
| | | } else { |
| | | |
| | | @Override |
| | | public void documentRepeatOrder(Object[] uuid, String opetype, Object[] file_name, Object[] newFile_name) throws BaseException { |
| | | //获取文件信息存入日志表 |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | DataTableEntity dataTableEntity = new DataTableEntity(); |
| | | FieldMetaEntity fieldMeta = new FieldMetaEntity(); |
| | | fieldMeta.setTableName(new String[]{CmnConst.PRODUCT_OA_DOCUMENT_LOG}); |
| | | dataTableEntity.setMeta(fieldMeta); |
| | | for (int i = 0; i < uuid.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName(CmnConst.PRODUCT_OA_DOCUMENT_LOG); |
| | | fieldSetEntity.setMeta(fieldMeta); |
| | | fieldSetEntity.setValue(CmnConst.DOCUMENT_UUID, uuid[i]); |
| | | //fieldSetEntity.setValue(CmnConst.RECORD,record); |
| | | fieldSetEntity.setValue(CmnConst.OPETYPE, opetype); |
| | | fieldSetEntity.setValue(CmnConst.OPE_DOCUMENT, file_name[i]); |
| | | StringBuffer state = new StringBuffer(); |
| | | state.append("把[") |
| | | .append(file_name[i]) |
| | | .append("]") |
| | | .append(opetype) |
| | | .append("为[") |
| | | .append(newFile_name[i]) |
| | | .append("]"); |
| | | fieldSetEntity.setValue(CmnConst.STATE, state.toString()); //说明 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_BY, user.getUser_id());// 创建人 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 |
| | | dataTableEntity.addFieldSetEntity(fieldSetEntity); |
| | | } |
| | | baseDao.add(dataTableEntity); |
| | | } |
| | | sql.append(" SELECT * FROM product_oa_document \n"); |
| | | sql.append(" WHERE directory_uuid = ? \n"); |
| | | } |
| | | sql.append(queryFilter); |
| | | sql.append(")A \n"); |
| | | sql.append("LEFT JOIN product_sys_staffs B ON B.user_id = A.created_by \n"); |
| | | sql.append("LEFT JOIN product_sys_attachments C ON C.uuid = B.staff_avatar \n"); |
| | | sql.append("LEFT JOIN product_oa_document_collection D ON D.document_uuid = A.uuid AND D.created_by = ?"); |
| | | DataTableEntity documentData = baseDao.listTable(sql.toString(), new String[]{directory_uuid, SpringMVCContextHolder.getCurrentUserId()}, |
| | | fieldSetEntity.getInteger(CmnConst.PAGESIZE), fieldSetEntity.getInteger(CmnConst.CPAGE)); |
| | | baseDao.listInternationDataTable(documentData, null); |
| | | return documentData; |
| | | } |
| | | |
| | | public boolean verifyOrgExist(String org) { |
| | | Integer user_id = SpringMVCContextHolder.getCurrentUser().getUser_id(); |
| | | String code = SpringMVCContextHolder.getCurrentUser().getCurrentStaff().getString("tricode"); |
| | | //获取所有上级编码 |
| | | String[] superior_code = new String[code.split("-").length - 1]; |
| | | for (int i = 0; i < code.split("-").length - 1; i++) { |
| | | superior_code[i] = code.substring(0, code.length() - ((i + 1) * 4)); |
| | | } |
| | | String this_user = String.valueOf(user_id); |
| | | SpringMVCContextHolder.getCurrentUser().getLanguageCode(); |
| | | String[][] orgArr = BaseUtil.decomposesMultipleTypeValues(org); |
| | | String[] user = orgArr[3]; |
| | | if (null != user) { |
| | | for (int i = 0; i < user.length; i++) { |
| | | if (this_user.equals(user[i])) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | String[] level = orgArr[0]; |
| | | String[] dept = orgArr[1]; |
| | | // List<String> list = Arrays.asList(a); --OK |
| | | // List<String> list = Arrays.asList("A","B","C"); --OK |
| | | // list.add("F"); --UnsupportedOperationException |
| | | // list.remove("A"); --UnsupportedOperationException |
| | | // list.set(1,"javaee");--OK (因为是把数组转为集合,其本质还是数组,数组长度固定不变,但内容可以改变) |
| | | // 结论:虽然可以把数组转为集合,但是集合长度不能改变 |
| | | List list = new ArrayList(); |
| | | ; |
| | | if (null != level) { |
| | | list.addAll(Arrays.asList(level)); |
| | | } |
| | | if (null != dept) { |
| | | list.addAll(Arrays.asList(dept)); |
| | | } |
| | | String[] level_dept = new String[list.size()]; |
| | | list.toArray(level_dept); |
| | | @Override |
| | | public FieldSetEntity documentInfo(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuid = fieldSetEntity.getString(CmnConst.UUID); |
| | | FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, true); |
| | | String file_name = fieldSet.getString(CmnConst.FILE_NAME); |
| | | String user_ids = fieldSetEntity.getString(CmnConst.USER_IDS); |
| | | String read = fieldSetEntity.getString(CmnConst.READ_NUM); |
| | | if (!BaseUtil.strIsNull(user_ids)) { |
| | | fieldSetEntity.setValue(CmnConst.REQUIRED_NUMBER, user_ids.split(",").length); |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, read.split(",").length); |
| | | } |
| | | this.documentation(new Object[]{uuid}, "查看", new Object[]{file_name}, null); |
| | | return fieldSet; |
| | | } |
| | | |
| | | @Override |
| | | public void documentation(Object[] uuid, String opetype, Object[] file_name, String file_directory) throws BaseException { |
| | | //获取文件信息存入日志表 |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | DataTableEntity dataTableEntity = new DataTableEntity(); |
| | | FieldMetaEntity fieldMeta = new FieldMetaEntity(); |
| | | fieldMeta.setTableName(new String[]{CmnConst.PRODUCT_OA_DOCUMENT_LOG}); |
| | | dataTableEntity.setMeta(fieldMeta); |
| | | for (int i = 0; i < uuid.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName(CmnConst.PRODUCT_OA_DOCUMENT_LOG); |
| | | fieldSetEntity.setMeta(fieldMeta); |
| | | fieldSetEntity.setValue(CmnConst.DOCUMENT_UUID, uuid[i]); |
| | | //fieldSetEntity.setValue(CmnConst.RECORD,record); |
| | | fieldSetEntity.setValue(CmnConst.OPETYPE, opetype); |
| | | fieldSetEntity.setValue(CmnConst.OPE_DOCUMENT, file_name[i]); |
| | | StringBuffer state = new StringBuffer(); |
| | | state.append(opetype) |
| | | .append("了[") |
| | | .append(file_name[i]) |
| | | .append("]"); |
| | | if (!BaseUtil.strIsNull(file_directory)) { |
| | | state.append("到").append(file_directory).append("目录下"); |
| | | } |
| | | fieldSetEntity.setValue(CmnConst.STATE, state.toString()); //说明 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_BY, user.getUser_id());// 创建人 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 |
| | | dataTableEntity.addFieldSetEntity(fieldSetEntity); |
| | | } |
| | | baseDao.add(dataTableEntity); |
| | | } |
| | | |
| | | @Override |
| | | public void documentRepeatOrder(Object[] uuid, String opetype, Object[] file_name, Object[] newFile_name) throws BaseException { |
| | | //获取文件信息存入日志表 |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | DataTableEntity dataTableEntity = new DataTableEntity(); |
| | | FieldMetaEntity fieldMeta = new FieldMetaEntity(); |
| | | fieldMeta.setTableName(new String[]{CmnConst.PRODUCT_OA_DOCUMENT_LOG}); |
| | | dataTableEntity.setMeta(fieldMeta); |
| | | for (int i = 0; i < uuid.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName(CmnConst.PRODUCT_OA_DOCUMENT_LOG); |
| | | fieldSetEntity.setMeta(fieldMeta); |
| | | fieldSetEntity.setValue(CmnConst.DOCUMENT_UUID, uuid[i]); |
| | | //fieldSetEntity.setValue(CmnConst.RECORD,record); |
| | | fieldSetEntity.setValue(CmnConst.OPETYPE, opetype); |
| | | fieldSetEntity.setValue(CmnConst.OPE_DOCUMENT, file_name[i]); |
| | | StringBuffer state = new StringBuffer(); |
| | | state.append("把[") |
| | | .append(file_name[i]) |
| | | .append("]") |
| | | .append(opetype) |
| | | .append("为[") |
| | | .append(newFile_name[i]) |
| | | .append("]"); |
| | | fieldSetEntity.setValue(CmnConst.STATE, state.toString()); //说明 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_BY, user.getUser_id());// 创建人 |
| | | fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());// 创建时间 |
| | | dataTableEntity.addFieldSetEntity(fieldSetEntity); |
| | | } |
| | | baseDao.add(dataTableEntity); |
| | | } |
| | | |
| | | public boolean verifyOrgExist(String org) { |
| | | Integer user_id = SpringMVCContextHolder.getCurrentUser().getUser_id(); |
| | | String code = SpringMVCContextHolder.getCurrentUser().getCurrentStaff().getString("tricode"); |
| | | //获取所有上级编码 |
| | | String[] superior_code = new String[code.split("-").length - 1]; |
| | | for (int i = 0; i < code.split("-").length - 1; i++) { |
| | | superior_code[i] = code.substring(0, code.length() - ((i + 1) * 4)); |
| | | } |
| | | String this_user = String.valueOf(user_id); |
| | | SpringMVCContextHolder.getCurrentUser().getLanguageCode(); |
| | | String[][] orgArr = BaseUtil.decomposesMultipleTypeValues(org); |
| | | String[] user = orgArr[3]; |
| | | if (null != user) { |
| | | for (int i = 0; i < user.length; i++) { |
| | | if (this_user.equals(user[i])) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | String[] level = orgArr[0]; |
| | | String[] dept = orgArr[1]; |
| | | // List<String> list = Arrays.asList(a); --OK |
| | | // List<String> list = Arrays.asList("A","B","C"); --OK |
| | | // list.add("F"); --UnsupportedOperationException |
| | | // list.remove("A"); --UnsupportedOperationException |
| | | // list.set(1,"javaee");--OK (因为是把数组转为集合,其本质还是数组,数组长度固定不变,但内容可以改变) |
| | | // 结论:虽然可以把数组转为集合,但是集合长度不能改变 |
| | | List list = new ArrayList(); |
| | | ; |
| | | if (null != level) { |
| | | list.addAll(Arrays.asList(level)); |
| | | } |
| | | if (null != dept) { |
| | | list.addAll(Arrays.asList(dept)); |
| | | } |
| | | String[] level_dept = new String[list.size()]; |
| | | list.toArray(level_dept); |
| | | |
| | | |
| | | String[] post = orgArr[2]; |
| | | if (level_dept.length != 0) { |
| | | DataTableEntity org_level_uuid = baseDao.listTable(CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, BaseUtil.buildQuestionMarkFilter("uuid", level_dept, true) + " and " + BaseUtil.buildQuestionMarkFilter("org_level_code", superior_code, true), new String[]{}); |
| | | if (org_level_uuid.getRows() > 0) return true; |
| | | } |
| | | if (null != post) { |
| | | DataTableEntity post_uuid = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFFS, BaseUtil.buildQuestionMarkFilter("job_post_uuid", post, true) + " and user_id=?", new String[]{this_user}); |
| | | if (post_uuid.getRows() > 0) return true; |
| | | } |
| | | return false; |
| | | } |
| | | String[] post = orgArr[2]; |
| | | if (level_dept.length != 0) { |
| | | DataTableEntity org_level_uuid = baseDao.listTable(CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, BaseUtil.buildQuestionMarkFilter("uuid", level_dept, true) + " and " + BaseUtil.buildQuestionMarkFilter("org_level_code", superior_code, true), new String[]{}); |
| | | if (org_level_uuid.getRows() > 0) return true; |
| | | } |
| | | if (null != post) { |
| | | DataTableEntity post_uuid = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFFS, BaseUtil.buildQuestionMarkFilter("job_post_uuid", post, true) + " and user_id=?", new String[]{this_user}); |
| | | if (post_uuid.getRows() > 0) return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public FieldSetEntity getButtonPermissions(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String butt = ""; |
| | | DataTableEntity dataTable = null; |
| | | FieldSetEntity fse = new FieldSetEntity(); |
| | | fse.setTableName(CmnConst.PRODUCT_OA_DOCUMENT); |
| | | if ("1".equals(fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE))) { |
| | | //获取的user_id |
| | | Integer user_id = SpringMVCContextHolder.getCurrentUser().getUser_id(); |
| | | String key = "%," + user_id + ",%"; |
| | | String directory_uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID); |
| | | //String key = "%,140,%"; |
| | | DataTableEntity dataTableEntity = new DataTableEntity(); |
| | | FieldSetEntity org = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY_RIGHTS, "directory_uuid=?", new String[]{directory_uuid}, false); |
| | | if (verifyOrgExist(org.getString("storage_uuid"))) { |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append(" SELECT substring_index(substring_index(a.rigths,',',b.help_topic_id+1),',',-1) fun FROM PRODUCT_OA_directory_rights a ") |
| | | .append(" INNER join mysql.help_topic b on b.help_topic_id < (length(a.rigths) - length(replace(a.rigths,',',''))+1) ") |
| | | .append(" WHERE a.directory_uuid = ? "); |
| | | dataTableEntity = baseDao.listTable(sql.toString(), new String[]{directory_uuid}); |
| | | } |
| | | StringBuffer button = new StringBuffer(); |
| | | if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) { |
| | | for (int i = 0, length = dataTableEntity.getRows(); i < length; i++) { |
| | | FieldSetEntity field = dataTableEntity.getFieldSetEntity(i); |
| | | String fun = field.getString("fun"); |
| | | //权限1(查看),2(下载),3(新增上传),4(修改,重命名),5(删除),6(移动) |
| | | button.append(fun).append(","); |
| | | if ("1".equals(fun)) { |
| | | //有查看权限就加载列表 |
| | | dataTable = this.documentAll(fieldSetEntity); |
| | | } |
| | | } |
| | | } |
| | | if (!BaseUtil.strIsNull(button.toString())) { |
| | | butt = button.substring(0, button.length() - 1); |
| | | } |
| | | } else { |
| | | dataTable = this.documentAll(fieldSetEntity); |
| | | } |
| | | Map<String, DataTableEntity> dataMap = MapUtils.newHashMap(); |
| | | fse.setValue("button", butt); |
| | | //加载文件路径 |
| | | DataTableEntity file_list = documentDirectoryService.getDirectoryStructure(fieldSetEntity); |
| | | dataMap.put("file_list", file_list); |
| | | if (BaseUtil.dataTableIsEmpty(dataTable) || dataTable.getSqle() == null) { |
| | | fse.setValue(CmnConst.PAGESIZE, 0); |
| | | fse.setValue(CmnConst.CPAGE, 0); |
| | | fse.setValue("total", 0); |
| | | } else { |
| | | dataMap.put("dataTable", dataTable); |
| | | fse.setValue(CmnConst.PAGESIZE, dataTable.getSqle().getPsize()); |
| | | fse.setValue(CmnConst.CPAGE, dataTable.getSqle().getPindex()); |
| | | fse.setValue("total", dataTable.getSqle().getTotalCount()); |
| | | } |
| | | fse.setSubData(dataMap); |
| | | @Override |
| | | public FieldSetEntity getButtonPermissions(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String butt = ""; |
| | | DataTableEntity dataTable = null; |
| | | FieldSetEntity fse = new FieldSetEntity(); |
| | | fse.setTableName(CmnConst.PRODUCT_OA_DOCUMENT); |
| | | if (StringUtils.equalsAny(fieldSetEntity.getString(CmnConst.DIRECTORY_UUID), "!borrow", "!favorite")) { |
| | | // 收藏夹和借阅文件夹特殊处理 |
| | | |
| | | return fse; |
| | | } |
| | | dataTable = this.documentAll(fieldSetEntity); |
| | | butt = "1,2"; |
| | | } else if ("1".equals(fieldSetEntity.getString(CmnConst.DIRECTORY_TYPE))) { |
| | | //获取的user_id |
| | | Integer user_id = SpringMVCContextHolder.getCurrentUser().getUser_id(); |
| | | String key = "%," + user_id + ",%"; |
| | | String directory_uuid = fieldSetEntity.getString(CmnConst.DIRECTORY_UUID); |
| | | //String key = "%,140,%"; |
| | | DataTableEntity dataTableEntity = new DataTableEntity(); |
| | | FieldSetEntity org = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_OA_DIRECTORY_RIGHTS, "directory_uuid=?", new String[]{directory_uuid}, false); |
| | | if (verifyOrgExist(org.getString("storage_uuid"))) { |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append(" SELECT substring_index(substring_index(a.rigths,',',b.help_topic_id+1),',',-1) fun FROM PRODUCT_OA_directory_rights a ") |
| | | .append(" INNER join mysql.help_topic b on b.help_topic_id < (length(a.rigths) - length(replace(a.rigths,',',''))+1) ") |
| | | .append(" WHERE a.directory_uuid = ? "); |
| | | dataTableEntity = baseDao.listTable(sql.toString(), new String[]{directory_uuid}); |
| | | } |
| | | StringBuffer button = new StringBuffer(); |
| | | if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) { |
| | | for (int i = 0, length = dataTableEntity.getRows(); i < length; i++) { |
| | | FieldSetEntity field = dataTableEntity.getFieldSetEntity(i); |
| | | String fun = field.getString("fun"); |
| | | //权限1(查看),2(下载),3(新增上传),4(修改,重命名),5(删除),6(移动) |
| | | button.append(fun).append(","); |
| | | if ("1".equals(fun)) { |
| | | //有查看权限就加载列表 |
| | | dataTable = this.documentAll(fieldSetEntity); |
| | | } |
| | | } |
| | | } |
| | | if (!BaseUtil.strIsNull(button.toString())) { |
| | | butt = button.substring(0, button.length() - 1); |
| | | } |
| | | } else { |
| | | dataTable = this.documentAll(fieldSetEntity); |
| | | } |
| | | Map<String, DataTableEntity> dataMap = MapUtils.newHashMap(); |
| | | fse.setValue("button", butt); |
| | | //加载文件路径 |
| | | DataTableEntity file_list; |
| | | if (StringUtils.equalsAny(fieldSetEntity.getString(CmnConst.DIRECTORY_UUID), "!borrow", "!favorite")) { |
| | | file_list = new DataTableEntity(); |
| | | FieldSetEntity ff = new FieldSetEntity("product_oa_directory"); |
| | | ff.setValue("uuid", fieldSetEntity.getString(CmnConst.DIRECTORY_UUID)); |
| | | ff.setValue("directory_name", "!borrow".equals(fieldSetEntity.getString(CmnConst.DIRECTORY_UUID)) ? "借阅文件夹" : "收藏夹"); |
| | | file_list.addFieldSetEntity(ff); |
| | | } else { |
| | | file_list = documentDirectoryService.getDirectoryStructure(fieldSetEntity); |
| | | } |
| | | dataMap.put("file_list", file_list); |
| | | if (BaseUtil.dataTableIsEmpty(dataTable) || dataTable.getSqle() == null) { |
| | | fse.setValue(CmnConst.PAGESIZE, 0); |
| | | fse.setValue(CmnConst.CPAGE, 0); |
| | | fse.setValue("total", 0); |
| | | } else { |
| | | dataMap.put("dataTable", dataTable); |
| | | fse.setValue(CmnConst.PAGESIZE, dataTable.getSqle().getPsize()); |
| | | fse.setValue(CmnConst.CPAGE, dataTable.getSqle().getPindex()); |
| | | fse.setValue("total", dataTable.getSqle().getTotalCount()); |
| | | } |
| | | fse.setSubData(dataMap); |
| | | |
| | | @Override |
| | | public JSONObject popBoxGetFileDirectory(FieldSetEntity fse) throws BaseException { |
| | | //文件目录uuid |
| | | String directory_uuid = fse.getString(CmnConst.DIRECTORY_UUID); |
| | | String type = fse.getString(CmnConst.DIRECTORY_TYPE); |
| | | List<Object> param = ListUtils.newArrayList(); |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | StringBuffer sql = new StringBuffer(); |
| | | //1为公司文件目录 |
| | | if ("1".equals(type)) { |
| | | //String staffId = user.getCurrentStaff().getString("staff_id"); |
| | | sql.append(" select a.* from PRODUCT_OA_directory a ") |
| | | .append(" LEFT JOIN ( SELECT a.directory_uuid FROM PRODUCT_OA_directory_rights a LEFT JOIN product_sys_organizational_structure_storage b ") |
| | | .append(" on a.storage_uuid = b.uuid WHERE a.rigths like '%3%' AND CONCAT(',',b.staff_ids,',') like ? GROUP BY ") |
| | | .append(" a.directory_uuid) b ON a.uuid = b.directory_uuid where a.directory_type = 1 and a.org_level_uuid = ? "); |
| | | String staffId = "%" + user.getCurrentStaff().getString("staff_id") + "%"; |
| | | param.add(staffId); |
| | | param.add(user.getOrg_level_uuid()); |
| | | //param.add("%,140,%"); |
| | | } else { |
| | | sql.append(" select * from PRODUCT_OA_directory where directory_type = 2 AND created_by = ? "); |
| | | param.add(user.getUser_id()); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | //directory_uuid为空就是未选择文件目录 获取当前根目录列表 |
| | | if (BaseUtil.strIsNull(directory_uuid)) { |
| | | sql.append(" and directory_tier = 1 "); |
| | | //不为空就获取选择文件目录 |
| | | } else { |
| | | String triCode = fse.getString(CmnConst.TRICODE); |
| | | param.add(triCode); |
| | | sql.append(" and tricode_parent = ? "); |
| | | //加载文件路径 |
| | | DataTableEntity dataTableEntity = documentDirectoryService.getDirectoryStructure(fse); |
| | | object.put("product_oa_directory_path", BaseUtil.dataTableEntityToJson(dataTableEntity)); |
| | | } |
| | | //sql.append(" GROUP BY tricode,tricode_parent,directory_name"); |
| | | DataTableEntity data = baseDao.listTable(sql.toString(), param.toArray()); |
| | | return fse; |
| | | } |
| | | |
| | | object.put("product_oa_directory_sub", BaseUtil.dataTableEntityToJson(data)); |
| | | baseDao.listInternationDataTable(data, null); |
| | | @Override |
| | | public JSONObject popBoxGetFileDirectory(FieldSetEntity fse) throws BaseException { |
| | | //文件目录uuid |
| | | String directory_uuid = fse.getString(CmnConst.DIRECTORY_UUID); |
| | | String type = fse.getString(CmnConst.DIRECTORY_TYPE); |
| | | List<Object> param = ListUtils.newArrayList(); |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | StringBuffer sql = new StringBuffer(); |
| | | //1为公司文件目录 |
| | | if ("1".equals(type)) { |
| | | //String staffId = user.getCurrentStaff().getString("staff_id"); |
| | | sql.append(" select a.* from PRODUCT_OA_directory a ") |
| | | .append(" LEFT JOIN ( SELECT a.directory_uuid FROM PRODUCT_OA_directory_rights a LEFT JOIN product_sys_organizational_structure_storage b ") |
| | | .append(" on a.storage_uuid = b.uuid WHERE a.rigths like '%3%' AND CONCAT(',',b.staff_ids,',') like ? GROUP BY ") |
| | | .append(" a.directory_uuid) b ON a.uuid = b.directory_uuid where a.directory_type = 1 and a.org_level_uuid = ? "); |
| | | String staffId = "%" + user.getCurrentStaff().getString("staff_id") + "%"; |
| | | param.add(staffId); |
| | | param.add(user.getOrg_level_uuid()); |
| | | //param.add("%,140,%"); |
| | | } else { |
| | | sql.append(" select * from PRODUCT_OA_directory where directory_type = 2 AND created_by = ? "); |
| | | param.add(user.getUser_id()); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | //directory_uuid为空就是未选择文件目录 获取当前根目录列表 |
| | | if (BaseUtil.strIsNull(directory_uuid)) { |
| | | sql.append(" and directory_tier = 1 "); |
| | | //不为空就获取选择文件目录 |
| | | } else { |
| | | String triCode = fse.getString(CmnConst.TRICODE); |
| | | param.add(triCode); |
| | | sql.append(" and tricode_parent = ? "); |
| | | //加载文件路径 |
| | | DataTableEntity dataTableEntity = documentDirectoryService.getDirectoryStructure(fse); |
| | | object.put("product_oa_directory_path", BaseUtil.dataTableEntityToJson(dataTableEntity)); |
| | | } |
| | | //sql.append(" GROUP BY tricode,tricode_parent,directory_name"); |
| | | DataTableEntity data = baseDao.listTable(sql.toString(), param.toArray()); |
| | | |
| | | return object; |
| | | } |
| | | object.put("product_oa_directory_sub", BaseUtil.dataTableEntityToJson(data)); |
| | | baseDao.listInternationDataTable(data, null); |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void downloadFile(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuid = fieldSetEntity.getString(CmnConst.UUID); |
| | | FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, false); |
| | | String file_name = fieldSet.getString(CmnConst.FILE_NAME); |
| | | this.documentation(new String[]{uuid}, "下载", new String[]{file_name}, null); |
| | | this.markRead(fieldSet); |
| | | } |
| | | return object; |
| | | } |
| | | |
| | | @Override |
| | | public void markRead(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | @Override |
| | | @Transactional |
| | | public void downloadFile(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | String uuid = fieldSetEntity.getString(CmnConst.UUID); |
| | | FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT, uuid, false); |
| | | String file_name = fieldSet.getString(CmnConst.FILE_NAME); |
| | | this.documentation(new String[]{uuid}, "下载", new String[]{file_name}, null); |
| | | this.markRead(fieldSet); |
| | | } |
| | | |
| | | //获取必读人员ID集 |
| | | String user_ids = fieldSetEntity.getString(CmnConst.USER_IDS); |
| | | String read = fieldSetEntity.getString(CmnConst.READ_NUM); |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | user_ids = "," + user_ids + ","; |
| | | String rawRead = "," + read + ","; |
| | | String userId = "," + user.getUser_id() + ","; |
| | | //如果包含用户ID |
| | | if (BaseUtil.strIsNull(read)) { |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, user.getUser_id()); |
| | | baseDao.update(fieldSetEntity); |
| | | } else { |
| | | if (user_ids.contains(userId) && !rawRead.contains(userId)) { |
| | | read = read + "," + user.getUser_id(); |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, read); |
| | | baseDao.update(fieldSetEntity); |
| | | } |
| | | } |
| | | } |
| | | @Override |
| | | public void markRead(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | |
| | | /** |
| | | * 移动(文件批量移动)6 |
| | | * |
| | | * @param |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public boolean fileMoveTo(FieldSetEntity fse) throws BaseException { |
| | | String directory_uuid = fse.getString(CmnConst.DIRECTORY_UUID); |
| | | Integer directory_type = fse.getInteger(CmnConst.DIRECTORY_TYPE); |
| | | Integer row = 0; |
| | | //1为公司文件夹 |
| | | if (directory_type == 1) { |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append(" SELECT * FROM PRODUCT_OA_directory_rights ") |
| | | .append(" WHERE directory_uuid = ? ") |
| | | .append(" AND rigths like '%3%' AND concat(',',storage_uuid,',') like ? ");//3为新增 |
| | | String user_id = String.valueOf(SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | user_id = "%," + user_id + ",%"; |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{directory_uuid, user_id}); |
| | | row = dataTableEntity.getRows(); |
| | | } |
| | | //1为个人文件夹 |
| | | if (directory_type == 2 || row > 0) { |
| | | FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, directory_uuid, false); |
| | | //获取移动到的目录名 |
| | | String directory_name = fieldSetEntity.getString(CmnConst.DIRECTORY_NAME); |
| | | String uuids = fse.getString(CmnConst.UUID); |
| | | String[] uuid = uuids.split(","); |
| | | DataTableEntity dataTable = baseDao.listTable(CmnConst.PRODUCT_OA_DOCUMENT, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), uuid); |
| | | List<String> uuidList = ListUtils.newArrayList(); |
| | | List<String> fileNameList = ListUtils.newArrayList(); |
| | | for (int i = 0, length = dataTable.getRows(); i < length; i++) { |
| | | uuidList.add(dataTable.getFieldSetEntity(i).getString(CmnConst.UUID)); |
| | | fileNameList.add(dataTable.getFieldSetEntity(i).getString(CmnConst.FILE_NAME)); |
| | | } |
| | | //获取必读人员ID集 |
| | | String user_ids = fieldSetEntity.getString(CmnConst.USER_IDS); |
| | | String read = fieldSetEntity.getString(CmnConst.READ_NUM); |
| | | SystemUser user = SpringMVCContextHolder.getCurrentUser(); |
| | | user_ids = "," + user_ids + ","; |
| | | String rawRead = "," + read + ","; |
| | | String userId = "," + user.getUser_id() + ","; |
| | | //如果包含用户ID |
| | | if (BaseUtil.strIsNull(read)) { |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, user.getUser_id()); |
| | | baseDao.update(fieldSetEntity); |
| | | } else { |
| | | if (user_ids.contains(userId) && !rawRead.contains(userId)) { |
| | | read = read + "," + user.getUser_id(); |
| | | fieldSetEntity.setValue(CmnConst.READ_NUM, read); |
| | | baseDao.update(fieldSetEntity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | String params = directory_uuid + "," + uuids; |
| | | String[] param = params.split(","); |
| | | boolean flag = baseDao.executeUpdate("UPDATE PRODUCT_OA_document SET directory_uuid = ? WHERE " + BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), param); |
| | | this.documentation(uuidList.toArray(), "移动", fileNameList.toArray(), directory_name); |
| | | return flag; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | /** |
| | | * 移动(文件批量移动)6 |
| | | * |
| | | * @param |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public boolean fileMoveTo(FieldSetEntity fse) throws BaseException { |
| | | String directory_uuid = fse.getString(CmnConst.DIRECTORY_UUID); |
| | | Integer directory_type = fse.getInteger(CmnConst.DIRECTORY_TYPE); |
| | | Integer row = 0; |
| | | //1为公司文件夹 |
| | | if (directory_type == 1) { |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append(" SELECT * FROM PRODUCT_OA_directory_rights ") |
| | | .append(" WHERE directory_uuid = ? ") |
| | | .append(" AND rigths like '%3%' AND concat(',',storage_uuid,',') like ? ");//3为新增 |
| | | String user_id = String.valueOf(SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | user_id = "%," + user_id + ",%"; |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{directory_uuid, user_id}); |
| | | row = dataTableEntity.getRows(); |
| | | } |
| | | //1为个人文件夹 |
| | | if (directory_type == 2 || row > 0) { |
| | | FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_DIRECTORY, directory_uuid, false); |
| | | //获取移动到的目录名 |
| | | String directory_name = fieldSetEntity.getString(CmnConst.DIRECTORY_NAME); |
| | | String uuids = fse.getString(CmnConst.UUID); |
| | | String[] uuid = uuids.split(","); |
| | | DataTableEntity dataTable = baseDao.listTable(CmnConst.PRODUCT_OA_DOCUMENT, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), uuid); |
| | | List<String> uuidList = ListUtils.newArrayList(); |
| | | List<String> fileNameList = ListUtils.newArrayList(); |
| | | for (int i = 0, length = dataTable.getRows(); i < length; i++) { |
| | | uuidList.add(dataTable.getFieldSetEntity(i).getString(CmnConst.UUID)); |
| | | fileNameList.add(dataTable.getFieldSetEntity(i).getString(CmnConst.FILE_NAME)); |
| | | } |
| | | |
| | | @Override |
| | | public DataTableEntity getDocumentLog(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | return baseDao.listTable("SELECT CONCAT(b.show_name, a.state) log,a.created_utc_datetime FROM PRODUCT_OA_document_log a LEFT JOIN product_sys_staffs b on a.created_by = b.user_id WHERE document_uuid = ? ORDER BY a.created_utc_datetime DESC", |
| | | new String[]{fieldSetEntity.getString(CmnConst.DOCUMENT_UUID)}, fieldSetEntity.getInteger(CmnConst.PAGESIZE), fieldSetEntity.getInteger(CmnConst.CPAGE)); |
| | | } |
| | | String params = directory_uuid + "," + uuids; |
| | | String[] param = params.split(","); |
| | | boolean flag = baseDao.executeUpdate("UPDATE PRODUCT_OA_document SET directory_uuid = ? WHERE " + BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuid.length, true), param); |
| | | this.documentation(uuidList.toArray(), "移动", fileNameList.toArray(), directory_name); |
| | | return flag; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 文档收藏 |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public String documentCollection(FieldSetEntity fse) { |
| | | BaseUtil.createCreatorAndCreationTime(fse); |
| | | fse.setValue("document_collector", SpringMVCContextHolder.getCurrentUserId()); |
| | | return baseDao.add(fse); |
| | | } |
| | | @Override |
| | | public DataTableEntity getDocumentLog(FieldSetEntity fieldSetEntity) throws BaseException { |
| | | return baseDao.listTable("SELECT CONCAT(b.show_name, a.state) log,a.created_utc_datetime FROM PRODUCT_OA_document_log a LEFT JOIN product_sys_staffs b on a.created_by = b.user_id WHERE document_uuid = ? ORDER BY a.created_utc_datetime DESC", |
| | | new String[]{fieldSetEntity.getString(CmnConst.DOCUMENT_UUID)}, fieldSetEntity.getInteger(CmnConst.PAGESIZE), fieldSetEntity.getInteger(CmnConst.CPAGE)); |
| | | } |
| | | |
| | | /** |
| | | * 文档取消收藏 |
| | | * @param documentUUID |
| | | * @return |
| | | */ |
| | | public boolean documentCancelCollection(String documentUUID) { |
| | | return baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT_COLLECTION, "document_uuid = ? AND document_collector = ?", new Object[] {documentUUID, SpringMVCContextHolder.getCurrentUserId()}); |
| | | } |
| | | /** |
| | | * 文档收藏 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public String documentCollection(FieldSetEntity fse) { |
| | | BaseUtil.createCreatorAndCreationTime(fse); |
| | | fse.setValue("document_collector", SpringMVCContextHolder.getCurrentUserId()); |
| | | return baseDao.add(fse); |
| | | } |
| | | |
| | | /** |
| | | * 文档取消收藏 |
| | | * |
| | | * @param documentUUID |
| | | * @return |
| | | */ |
| | | public boolean documentCancelCollection(String documentUUID) { |
| | | return baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT_COLLECTION, "document_uuid = ? AND document_collector = ?", new Object[]{documentUUID, SpringMVCContextHolder.getCurrentUserId()}); |
| | | } |
| | | |
| | | /** |
| | | * 查询文档历史版本 |
| | |
| | | fseDocument.setValue("latest_version", fseDocument.getInteger("max_version_number") + 1); |
| | | |
| | | baseDao.saveFieldSetEntity(fseDocument); |
| | | |
| | | |
| | | // 创建文档操作日志信息 |
| | | FieldSetEntity fseDocumentLog = new FieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT_LOG); |
| | | BaseUtil.createCreatorAndCreationTime(fseDocumentLog); |
| | | fseDocumentLog.setValue("document_uuid", documentUuid); |
| | | fseDocumentLog.setValue("opetype", "新增"); |
| | | fseDocumentLog.setValue("ope_document", fieldSetEntity.getString("file_name")); |
| | | fseDocumentLog.setValue("state", "新增了["+ fieldSetEntity.getString("file_name") +"]最新版本"); |
| | | fseDocumentLog.setValue("state", "新增了[" + fieldSetEntity.getString("file_name") + "]最新版本"); |
| | | |
| | | //创建文档版本数据容器 |
| | | FieldSetEntity fseDocumentHistory = new FieldSetEntity(CmnConst.PRODUCT_OA_DOCUMENT_HISTORY); |
| | |
| | | // 数字加一 |
| | | number += 1; |
| | | |
| | | // 重新构建字符串(这里我们假设前缀总是"v") |
| | | return "v" + number; |
| | | } |
| | | // 重新构建字符串(这里我们假设前缀总是"v") |
| | | return "v" + number; |
| | | } |
| | | |
| | | @Override |
| | | public DataTableEntity getApplyDocument(FieldSetEntity fse) throws BaseException { |
| | | @Override |
| | | public DataTableEntity getApplyDocument(FieldSetEntity fse) throws BaseException { |
| | | |
| | | DataTableEntity product_oa_document = new DataTableEntity(); |
| | | StringBuilder sb=new StringBuilder(); |
| | | sb.append(" select d.*,f.show_name "); |
| | | sb.append(" from product_oa_document d "); |
| | | sb.append(" left join product_sys_staffs f "); |
| | | sb.append(" on d.created_by=f.user_id "); |
| | | List<String> param=new ArrayList<>(); |
| | | if(!ObjectUtil.isNotEmpty(fse.getString("document_name"))){ |
| | | product_oa_document = baseDao.listTable(sb.toString(),param.toArray()); |
| | | DataTableEntity product_oa_document = new DataTableEntity(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(" select d.*,f.show_name "); |
| | | sb.append(" from product_oa_document d "); |
| | | sb.append(" left join product_sys_staffs f "); |
| | | sb.append(" on d.created_by=f.user_id "); |
| | | List<String> param = new ArrayList<>(); |
| | | if (!ObjectUtil.isNotEmpty(fse.getString("document_name"))) { |
| | | product_oa_document = baseDao.listTable(sb.toString(), param.toArray()); |
| | | |
| | | }else { |
| | | String document_name = fse.getString("document_name"); |
| | | sb.append(" where d.file_name like '%"+document_name+"%'"); |
| | | product_oa_document = baseDao.listTable(sb.toString(),param.toArray()); |
| | | } else { |
| | | String document_name = fse.getString("document_name"); |
| | | sb.append(" where d.file_name like '%" + document_name + "%'"); |
| | | product_oa_document = baseDao.listTable(sb.toString(), param.toArray()); |
| | | |
| | | |
| | | } |
| | | return product_oa_document; |
| | | } |
| | | } |
| | | return product_oa_document; |
| | | } |
| | | |
| | | @Override |
| | | public void addOrUpdateApplyDocument(FieldSetEntity fse) throws BaseException { |
| | | @Override |
| | | public void addOrUpdateApplyDocument(FieldSetEntity fse) throws BaseException { |
| | | |
| | | String[] attachment = new String[0]; |
| | | if(ObjectUtil.isNotEmpty(fse.getString("uuid"))){ |
| | | UUID uuid = UUID.randomUUID(); |
| | | fse.setValue("uuid",uuid); |
| | | baseDao.add(fse); |
| | | String[] attachment = new String[0]; |
| | | if (ObjectUtil.isNotEmpty(fse.getString("uuid"))) { |
| | | UUID uuid = UUID.randomUUID(); |
| | | fse.setValue("uuid", uuid); |
| | | baseDao.add(fse); |
| | | |
| | | if(ObjectUtil.isNotEmpty(fse.getString("attachment_uuid"))){ |
| | | String attachment_uuid = fse.getString("attachment_uuid"); |
| | | attachment= attachment_uuid.split(","); |
| | | } |
| | | for (int i = 0; i < attachment.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName("product_oa_document_borrow_sub"); |
| | | fieldSetEntity.setValue("borrow_uuid",uuid); |
| | | fieldSetEntity.setValue("sub_uuid",attachment[i]); |
| | | if (ObjectUtil.isNotEmpty(fse.getString("attachment_uuid"))) { |
| | | String attachment_uuid = fse.getString("attachment_uuid"); |
| | | attachment = attachment_uuid.split(","); |
| | | } |
| | | for (int i = 0; i < attachment.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName("product_oa_document_borrow_sub"); |
| | | fieldSetEntity.setValue("borrow_uuid", uuid); |
| | | fieldSetEntity.setValue("sub_uuid", attachment[i]); |
| | | |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | String uuid = fse.getString("uuid"); |
| | | String filter="borrow_uuid='"+uuid+"'"; |
| | | //删除原来附件信息 |
| | | baseDao.delete("product_oa_document_borrow_sub",filter,new Object[]{}); |
| | | baseDao.update(fse); |
| | | if(ObjectUtil.isNotEmpty(fse.getString("attachment_uuid"))){ |
| | | String attachment_uuid = fse.getString("attachment_uuid"); |
| | | attachment= attachment_uuid.split(","); |
| | | } |
| | | } else { |
| | | String uuid = fse.getString("uuid"); |
| | | String filter = "borrow_uuid='" + uuid + "'"; |
| | | //删除原来附件信息 |
| | | baseDao.delete("product_oa_document_borrow_sub", filter, new Object[]{}); |
| | | baseDao.update(fse); |
| | | if (ObjectUtil.isNotEmpty(fse.getString("attachment_uuid"))) { |
| | | String attachment_uuid = fse.getString("attachment_uuid"); |
| | | attachment = attachment_uuid.split(","); |
| | | } |
| | | |
| | | //重新跟新附件信息 |
| | | for (int i = 0; i < attachment.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName("product_oa_document_borrow_sub"); |
| | | fieldSetEntity.setValue("borrow_uuid",uuid); |
| | | fieldSetEntity.setValue("sub_uuid",attachment[i]); |
| | | baseDao.add(fieldSetEntity); |
| | | //重新跟新附件信息 |
| | | for (int i = 0; i < attachment.length; i++) { |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName("product_oa_document_borrow_sub"); |
| | | fieldSetEntity.setValue("borrow_uuid", uuid); |
| | | fieldSetEntity.setValue("sub_uuid", attachment[i]); |
| | | baseDao.add(fieldSetEntity); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public DataTableEntity getApplyFileSort() throws BaseException { |
| | | StringBuilder sb=new StringBuilder(); |
| | | List<String> param=new ArrayList<>(); |
| | | sb.append(" SELECT b.* FROM ("); |
| | | sb.append(" SELECT t.uuid,t.file_name,t.file_size,s.show_name,t.created_utc_datetime,count(t.uuid) as applyCount"); |
| | | sb.append(" FROM product_oa_document_borrow_sub b"); |
| | | sb.append(" JOIN product_oa_document t"); |
| | | sb.append(" on b.sub_uuid=t.uuid"); |
| | | sb.append(" JOIN product_sys_staffs s "); |
| | | sb.append(" on t.created_by=s.user_id"); |
| | | sb.append(" group by t.file_name,t.uuid,s.show_name,t.created_utc_datetime,t.file_size"); |
| | | sb.append(" )b order by b.applyCount asc"); |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sb.toString(),param.toArray()); |
| | | return dataTableEntity; |
| | | } |
| | | @Override |
| | | public DataTableEntity getApplyFileSort() throws BaseException { |
| | | StringBuilder sb = new StringBuilder(); |
| | | List<String> param = new ArrayList<>(); |
| | | sb.append(" SELECT b.* FROM ("); |
| | | sb.append(" SELECT t.uuid,t.file_name,t.file_size,s.show_name,t.created_utc_datetime,count(t.uuid) as applyCount"); |
| | | sb.append(" FROM product_oa_document_borrow_sub b"); |
| | | sb.append(" JOIN product_oa_document t"); |
| | | sb.append(" on b.sub_uuid=t.uuid"); |
| | | sb.append(" JOIN product_sys_staffs s "); |
| | | sb.append(" on t.created_by=s.user_id"); |
| | | sb.append(" group by t.file_name,t.uuid,s.show_name,t.created_utc_datetime,t.file_size"); |
| | | sb.append(" )b order by b.applyCount asc"); |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sb.toString(), param.toArray()); |
| | | return dataTableEntity; |
| | | } |
| | | |
| | | @Override |
| | | public DataTableEntity getApplyUserSort() throws BaseException { |
| | | StringBuilder sb=new StringBuilder(); |
| | | List<String> param=new ArrayList<>(); |
| | | sb.append(" SELECT b.*,a.applayCount "); |
| | | sb.append(" FROM ("); |
| | | sb.append(" SELECT borrower,count(borrower) as applayCount"); |
| | | sb.append(" FROM product_oa_document_borrow "); |
| | | sb.append(" group by borrower"); |
| | | sb.append(" ) a LEFT JOIN "); |
| | | sb.append(" ("); |
| | | sb.append(" SELECT a.borrower,a.show_name,a.applayFileCount "); |
| | | sb.append(" FROM ("); |
| | | sb.append(" SELECT w.borrower,s.show_name,"); |
| | | sb.append(" count( borrower ) AS applayCount,"); |
| | | sb.append(" count(sub_uuid) as applayFileCount "); |
| | | sb.append(" FROM product_oa_document_borrow w "); |
| | | sb.append(" left JOIN product_oa_document_borrow_sub b"); |
| | | sb.append(" on b.borrow_uuid=w.uuid"); |
| | | sb.append(" left JOIN product_oa_document t"); |
| | | sb.append(" on b.sub_uuid=t.uuid"); |
| | | sb.append(" left JOIN product_sys_staffs s"); |
| | | sb.append(" on w.borrower=s.user_id"); |
| | | sb.append(" GROUP BY w.borrower,s.show_name"); |
| | | sb.append(" )a )b"); |
| | | sb.append(" on a.borrower=b.borrower "); |
| | | sb.append(" order by a.applayCount,b.applayFileCount asc"); |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sb.toString(),param.toArray()); |
| | | return dataTableEntity; |
| | | } |
| | | @Override |
| | | public DataTableEntity getApplyUserSort() throws BaseException { |
| | | StringBuilder sb = new StringBuilder(); |
| | | List<String> param = new ArrayList<>(); |
| | | sb.append(" SELECT b.*,a.applayCount "); |
| | | sb.append(" FROM ("); |
| | | sb.append(" SELECT borrower,count(borrower) as applayCount"); |
| | | sb.append(" FROM product_oa_document_borrow "); |
| | | sb.append(" group by borrower"); |
| | | sb.append(" ) a LEFT JOIN "); |
| | | sb.append(" ("); |
| | | sb.append(" SELECT a.borrower,a.show_name,a.applayFileCount "); |
| | | sb.append(" FROM ("); |
| | | sb.append(" SELECT w.borrower,s.show_name,"); |
| | | sb.append(" count( borrower ) AS applayCount,"); |
| | | sb.append(" count(sub_uuid) as applayFileCount "); |
| | | sb.append(" FROM product_oa_document_borrow w "); |
| | | sb.append(" left JOIN product_oa_document_borrow_sub b"); |
| | | sb.append(" on b.borrow_uuid=w.uuid"); |
| | | sb.append(" left JOIN product_oa_document t"); |
| | | sb.append(" on b.sub_uuid=t.uuid"); |
| | | sb.append(" left JOIN product_sys_staffs s"); |
| | | sb.append(" on w.borrower=s.user_id"); |
| | | sb.append(" GROUP BY w.borrower,s.show_name"); |
| | | sb.append(" )a )b"); |
| | | sb.append(" on a.borrower=b.borrower "); |
| | | sb.append(" order by a.applayCount,b.applayFileCount asc"); |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sb.toString(), param.toArray()); |
| | | return dataTableEntity; |
| | | } |
| | | |
| | | @Override |
| | | public FieldSetEntity getApplyInfo(FieldSetEntity fes) throws BaseException { |
| | | String uuid = fes.getString("uuid"); |
| | | FieldSetEntity product_oa_document_borrow = baseDao.getFieldSetEntity("product_oa_document_borrow", uuid, false); |
| | | return product_oa_document_borrow; |
| | | } |
| | | @Override |
| | | public FieldSetEntity getApplyInfo(FieldSetEntity fes) throws BaseException { |
| | | String uuid = fes.getString("uuid"); |
| | | FieldSetEntity product_oa_document_borrow = baseDao.getFieldSetEntity("product_oa_document_borrow", uuid, false); |
| | | return product_oa_document_borrow; |
| | | } |
| | | |
| | | public Map<String, String> isPermission(String documentUuid) { |
| | | // 验证文档权限 |
| | | if (StringUtils.isEmpty(documentUuid)) { |
| | | throw new BaseException(DocumentCode.DOCUMENT_FORM_NODATA); |
| | | } |
| | | |
| | | String[] docuemnts = documentUuid.split(","); |
| | | //查询借阅记录 |
| | | DataTableEntity dt = baseDao.listTable(" SELECT 1 isPermission,sub_uuid document_uuid from product_oa_document_borrow_sub where borrow_uuid in" + |
| | | " (select uuid from product_oa_document_borrow where start_time>=now() and end_time<=now() and borrower=? and flow_flag=2) and " + BaseUtil.buildQuestionMarkFilter("sub_uuid", docuemnts, true), |
| | | new Object[]{SpringMVCContextHolder.getCurrentUserId()}); |
| | | |
| | | Map<String, String> permission = new HashMap<>(); |
| | | if (!DataTableEntity.isEmpty(dt)) { |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | String docUuid = dt.getString(i, "document_uuid"); |
| | | if (dt.getBoolean(i, "isPermission")) { |
| | | permission.put(docUuid, "1"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append("SELECT\n"); |
| | | sql.append("document.uuid document_uuid,\n"); |
| | | sql.append("rights.*\n"); |
| | | sql.append(" FROM\n"); |
| | | sql.append("product_oa_document document\n"); |
| | | sql.append("JOIN product_oa_directory dir ON dir.uuid = document.directory_uuid\n"); |
| | | sql.append("JOIN product_oa_directory_rights rights ON dir.uuid = rights.directory_uuid\n"); |
| | | sql.append("WHERE\n"); |
| | | sql.append("dir.directory_type = 1\n"); |
| | | sql.append("AND rights.rigths LIKE '%1%'\n"); |
| | | sql.append(" and ").append(BaseUtil.buildQuestionMarkFilter("document.uuid", docuemnts.length, true)); |
| | | dt = baseDao.listTable(sql.toString(), docuemnts); |
| | | if (!DataTableEntity.isEmpty(dt)) { |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | String docUuid = dt.getString(i, "document_uuid"); |
| | | String storage_uuid = dt.getString(i, "storage_uuid"); |
| | | if (verifyOrgExist(storage_uuid)) { |
| | | String rights = permission.get(docUuid); |
| | | if (StringUtils.isEmpty(rights)) { |
| | | rights = "1"; |
| | | } |
| | | if (rights.indexOf("2") == -1 && StringUtils.indexOf(dt.getString(i, "rigths"), "2") != -1) { |
| | | rights += ",2"; |
| | | } |
| | | permission.put(docUuid, rights); |
| | | } |
| | | } |
| | | } |
| | | return permission; |
| | | } |
| | | } |