| | |
| | | import com.product.common.collect.ListUtils; |
| | | import com.product.common.collect.MapUtils; |
| | | import com.product.common.lang.DateUtils; |
| | | import com.product.core.config.Global; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldMetaEntity; |
| | |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.core.transfer.Transactional; |
| | | import com.product.file.config.CmnConst; |
| | | import com.product.file.config.DocumentCode; |
| | | import com.product.file.service.ide.IDocumentService; |
| | | import com.product.module.sys.entity.SystemUser; |
| | | import com.product.util.BaseUtil; |
| | |
| | | BaseUtil.createCreatorAndCreationTime(fseDocumentHistory); |
| | | fseDocument.setValue("document_uuid", documentUUID); |
| | | fseDocument.setValue("attachment_uuid", attachment.getUUID()); |
| | | fseDocument.setValue("version_number", "v1"); |
| | | baseDao.add(fseDocumentHistory); |
| | | |
| | | uuidList.add(documentUUID); |
| | |
| | | public boolean documentCancelCollection(String documentUUID) { |
| | | return baseDao.delete(CmnConst.PRODUCT_OA_DOCUMENT_COLLECTION, "document_uuid = ? AND document_collector = ?", new Object[] {documentUUID, SpringMVCContextHolder.getCurrentUserId()}); |
| | | } |
| | | |
| | | /** |
| | | * 查询文档历史版本 |
| | | * @param documentUUID |
| | | * @return |
| | | */ |
| | | public DataTableEntity findDocumentHistory(String documentUUID) { |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append("SELECT A.*,B.file_name"); |
| | | sql.append("FROM product_oa_document_history A \n"); |
| | | sql.append("LEFT JOIN product_oa_document_history B ON B.uuid = A.document_uuid \n"); |
| | | sql.append("WHERE A.document_uuid = ?"); |
| | | sql.append("ORDER BY A.version_number"); |
| | | return baseDao.listTable(sql.toString(), new Object[] {documentUUID}); |
| | | } |
| | | |
| | | /** |
| | | * 文档最新版本保存 |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean documentSaveNewVersion(FieldSetEntity fse) { |
| | | // 获取文档数据和最大编号 |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append("SELECT A.*, IFNULL(B.max_version_number, 'v0')AS max_version_number \n"); |
| | | sql.append("FROM product_oa_document A \n"); |
| | | sql.append("LEFT JOIN ( \n"); |
| | | sql.append(" SELECT document_uuid, MAX(version_number) AS max_version_number \n"); |
| | | sql.append(" FROM product_oa_document_history B \n"); |
| | | sql.append(" WHERE document_uuid = ? \n"); |
| | | sql.append(" GROUP BY document_uuid \n"); |
| | | sql.append(") B ON B.document_uuid = A.uuid \n"); |
| | | sql.append("WHERE uuid = ? \n"); |
| | | FieldSetEntity fseDocument = baseDao.getFieldSetEntityBySQL(sql.toString(), new Object[] {fse.getString("document_uuid"),fse.getString("document_uuid")}, false); |
| | | if(fseDocument == null) { |
| | | throw new BaseException(DocumentCode.DOCUMENT_DATA_NO_EXIST.getValue(), DocumentCode.DOCUMENT_DATA_NO_EXIST.getText()); |
| | | } |
| | | fseDocument.setValue("attachments_uuid", fse.getString("attachment_uuid")); |
| | | baseDao.saveFieldSetEntity(fseDocument); |
| | | |
| | | fse.setValue("version_number", versionNUmberAddne(fseDocument.getString("max_version_number"))); |
| | | return baseDao.saveFieldSetEntity(fse); |
| | | } |
| | | |
| | | /** |
| | | * 文档版本+1 |
| | | * @param originNumber |
| | | * @return |
| | | */ |
| | | public String versionNUmberAddne(String originNumber) { |
| | | String numberStr = originNumber.substring(1); // 去掉前缀"v" |
| | | int number = Integer.parseInt(numberStr); // 将字符串转 |
| | | // 数字加一 |
| | | number += 1; |
| | | |
| | | // 重新构建字符串(这里我们假设前缀总是"v") |
| | | return "v" + number; |
| | | } |
| | | |
| | | @Override |
| | | public DataTableEntity getApplyDocument(FieldSetEntity fse) throws BaseException { |