Jelajahi Sumber

Merge branch 'wrdp' into 'develop'

Wrdp

See merge request o2oa/o2oa!1806
o2null 5 tahun lalu
induk
melakukan
20fc023631
30 mengubah file dengan 537 tambahan dan 140 penghapusan
  1. 4 0
      o2server/x_attendance_assemble_control/pom.xml
  2. 1 1
      o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageType.java
  3. 2 2
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_general_assemble_control.java
  4. 4 2
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_processplatform_assemble_surface.java
  5. 4 0
      o2server/x_bbs_assemble_control/pom.xml
  6. 4 0
      o2server/x_cms_assemble_control/pom.xml
  7. 4 0
      o2server/x_file_assemble_control/pom.xml
  8. 3 0
      o2server/x_general_assemble_control/src/main/java/com/x/general/assemble/control/ThisApplication.java
  9. 79 0
      o2server/x_general_assemble_control/src/main/java/com/x/general/assemble/control/schedule/Clean.java
  10. 8 0
      o2server/x_general_core_entity/src/main/java/com/x/general/core/entity/PersistenceProperties.java
  11. 207 0
      o2server/x_general_core_entity/src/main/java/com/x/general/core/entity/file/GeneralFile.java
  12. 4 0
      o2server/x_hotpic_assemble_control/pom.xml
  13. 4 0
      o2server/x_meeting_assemble_control/pom.xml
  14. 4 0
      o2server/x_mind_assemble_control/pom.xml
  15. 4 0
      o2server/x_organization_assemble_control/pom.xml
  16. 4 0
      o2server/x_portal_assemble_surface/pom.xml
  17. 4 0
      o2server/x_processplatform_assemble_designer/pom.xml
  18. 4 0
      o2server/x_processplatform_assemble_surface/pom.xml
  19. 13 10
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompleted.java
  20. 13 10
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompletedStream.java
  21. 15 12
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadTransfer.java
  22. 15 12
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadWorkInfo.java
  23. 21 17
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToPdf.java
  24. 16 13
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImage.java
  25. 24 17
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImageResult.java
  26. 16 11
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdf.java
  27. 24 17
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdfResult.java
  28. 24 16
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
  29. 4 0
      o2server/x_query_assemble_designer/pom.xml
  30. 4 0
      o2server/x_query_assemble_surface/pom.xml

+ 4 - 0
o2server/x_attendance_assemble_control/pom.xml

@@ -28,6 +28,10 @@
             <groupId>o2oa</groupId>
             <artifactId>x_processplatform_core_entity</artifactId>
         </dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
     </dependencies>
 	<build>
 		<plugins>

+ 1 - 1
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageType.java

@@ -1,6 +1,6 @@
 package com.x.base.core.entity;
 
 public enum StorageType {
-	file, processPlatform, mind, meeting, calendar, okr, cms, bbs, report, strategyDeploy, teamwork, structure, im;
+	file, processPlatform, mind, meeting, calendar, okr, cms, bbs, report, strategyDeploy, teamwork, structure, im, general;
 	public static final int length = JpaObject.length_32B;
 }

+ 2 - 2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_general_assemble_control.java

@@ -6,7 +6,7 @@ import com.x.base.core.project.annotation.ModuleCategory;
 import com.x.base.core.project.annotation.ModuleType;
 
 @Module(type = ModuleType.ASSEMBLE, category = ModuleCategory.OFFICIAL, name = "公共模块", packageName = "com.x.general.assemble.control", containerEntities = {
-		"com.x.general.core.entity.area.District" }, storageTypes = {
-				StorageType.file }, storeJars = { "x_general_core_entity" })
+		"com.x.general.core.entity.area.District", "com.x.general.core.entity.file.GeneralFile" }, storageTypes = {
+				StorageType.file, StorageType.general }, storeJars = { "x_general_core_entity" })
 public class x_general_assemble_control extends Deployable {
 }

+ 4 - 2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_processplatform_assemble_surface.java

@@ -30,8 +30,10 @@ import com.x.base.core.project.annotation.ModuleType;
 		"com.x.processplatform.core.entity.element.Split", "com.x.processplatform.core.entity.element.QueryView",
 		"com.x.processplatform.core.entity.element.QueryStat", "com.x.processplatform.core.entity.element.Mapping",
 		"com.x.query.core.entity.Item", "com.x.cms.core.entity.element.Script",
-		"com.x.portal.core.entity.Script" }, storageTypes = { StorageType.processPlatform }, storeJars = {
+		"com.x.portal.core.entity.Script", "com.x.general.core.entity.file.GeneralFile" },
+		storageTypes = { StorageType.processPlatform, StorageType.general}, storeJars = {
 				"x_organization_core_entity", "x_organization_core_express", "x_processplatform_core_entity",
-				"x_processplatform_core_express", "x_query_core_entity", "x_cms_core_entity", "x_portal_core_entity" })
+				"x_processplatform_core_express", "x_query_core_entity", "x_cms_core_entity", "x_portal_core_entity",
+		"x_general_core_entity" })
 public class x_processplatform_assemble_surface extends Deployable {
 }

+ 4 - 0
o2server/x_bbs_assemble_control/pom.xml

@@ -24,6 +24,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_organization_core_express</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_cms_assemble_control/pom.xml

@@ -44,6 +44,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_processplatform_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_file_assemble_control/pom.xml

@@ -28,6 +28,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_file_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 3 - 0
o2server/x_general_assemble_control/src/main/java/com/x/general/assemble/control/ThisApplication.java

@@ -4,6 +4,7 @@ import com.x.base.core.project.Context;
 import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.logger.LoggerFactory;
+import com.x.general.assemble.control.schedule.Clean;
 
 public class ThisApplication {
 
@@ -21,6 +22,8 @@ public class ThisApplication {
 		try {
 			CacheManager.init(context.clazz().getSimpleName());
 			LoggerFactory.setLevel(Config.logLevel().x_general_assemble_control());
+
+			context().schedule(Clean.class, "0 0 2 * * ?");
 		} catch (Exception e) {
 			e.printStackTrace();
 		}

+ 79 - 0
o2server/x_general_assemble_control/src/main/java/com/x/general/assemble/control/schedule/Clean.java

@@ -0,0 +1,79 @@
+package com.x.general.assemble.control.schedule;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.schedule.AbstractJob;
+import com.x.base.core.project.tools.DateTools;
+import com.x.base.core.project.tools.ListTools;
+import com.x.base.core.project.utils.time.TimeStamp;
+import com.x.general.assemble.control.ThisApplication;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.general.core.entity.file.GeneralFile_;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import javax.persistence.EntityManager;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.Date;
+import java.util.List;
+
+public class Clean extends AbstractJob {
+
+	private static Logger logger = LoggerFactory.getLogger(Clean.class);
+
+	@Override
+	public void schedule(JobExecutionContext jobExecutionContext) throws Exception {
+		try{
+			logger.print("开始定时清理过期的缓存附件!");
+			TimeStamp stamp = new TimeStamp();
+			Long instantCount = this.clearGeneralFile();
+			logger.print("清理过期的缓存附件:{} 条, 耗时: {}.", instantCount,
+					stamp.consumingMilliseconds());
+		} catch (Exception e) {
+			logger.error(e);
+			throw new JobExecutionException(e);
+		}
+	}
+
+	private Long clearGeneralFile() throws Exception {
+		List<GeneralFile> os = null;
+		Long count = 0L;
+
+		do {
+			os = this.listInstant();
+			if (!os.isEmpty()) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					emc.beginTransaction(GeneralFile.class);
+					for (GeneralFile o : os) {
+						StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+								o.getStorage());
+						o.deleteContent(gfMapping);
+						emc.remove(o);
+					}
+					emc.commit();
+					count += os.size();
+				}
+			}
+		} while (ListTools.isNotEmpty(os));
+		return count;
+	}
+
+	private List<GeneralFile> listInstant() throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			EntityManager em = emc.get(GeneralFile.class);
+			CriteriaBuilder cb = em.getCriteriaBuilder();
+			CriteriaQuery<GeneralFile> cq = cb.createQuery(GeneralFile.class);
+			Root<GeneralFile> root = cq.from(GeneralFile.class);
+			Date limit = DateTools.floorDate(new Date(), 0);
+			Predicate p = cb.lessThan(root.get(GeneralFile_.createTime), limit);
+			return em.createQuery(cq.select(root).where(p)).setMaxResults(100).getResultList();
+		}
+	}
+
+}

+ 8 - 0
o2server/x_general_core_entity/src/main/java/com/x/general/core/entity/PersistenceProperties.java

@@ -11,4 +11,12 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
 		}
 
 	}
+
+	public static class General {
+
+		public static class File {
+			public static final String table = "GENERAL_FILE";
+		}
+
+	}
 }

+ 207 - 0
o2server/x_general_core_entity/src/main/java/com/x/general/core/entity/file/GeneralFile.java

@@ -0,0 +1,207 @@
+package com.x.general.core.entity.file;
+
+import com.x.base.core.entity.JpaObject;
+import com.x.base.core.entity.Storage;
+import com.x.base.core.entity.StorageObject;
+import com.x.base.core.entity.StorageType;
+import com.x.base.core.entity.annotation.CheckPersist;
+import com.x.base.core.entity.annotation.ContainerEntity;
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.tools.DateTools;
+import com.x.general.core.entity.PersistenceProperties;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.openjpa.persistence.jdbc.Index;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@ContainerEntity(dumpSize = 10, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
+@Entity
+@Table(name = PersistenceProperties.General.File.table, uniqueConstraints = {
+		@UniqueConstraint(name = PersistenceProperties.General.File.table + JpaObject.IndexNameMiddle
+				+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
+						JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Storage(type = StorageType.general)
+public class GeneralFile extends StorageObject {
+
+	private static final long serialVersionUID = -8883987079043800355L;
+
+	private static final String TABLE = PersistenceProperties.General.File.table;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	@FieldDescribe("数据库主键,自动生成.")
+	@Id
+	@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
+	private String id = createId();
+
+	/* 以上为 JpaObject 默认字段 */
+
+	public void onPersist() throws Exception {
+		this.lastUpdateTime = new Date();
+		/* 如果扩展名为空去掉null */
+		this.extension = StringUtils.trimToEmpty(extension);
+	}
+
+	/* 更新运行方法 */
+
+	public GeneralFile() {
+
+	}
+
+	public GeneralFile(String storage, String name, String person) throws Exception {
+		if (StringUtils.isEmpty(storage)) {
+			throw new Exception("storage can not be empty.");
+		}
+		if (StringUtils.isEmpty(name)) {
+			throw new Exception("name can not be empty.");
+		}
+		if (StringUtils.isEmpty(person)) {
+			throw new Exception("person can not be empty.");
+		}
+		this.storage = storage;
+		Date now = new Date();
+		this.setCreateTime(now);
+		this.lastUpdateTime = now;
+		this.name = name;
+		this.extension = StringUtils.lowerCase(FilenameUtils.getExtension(name));
+		this.person = person;
+		if (null == this.extension) {
+			throw new Exception("extension can not be null.");
+		}
+	}
+
+	@Override
+	public String path() throws Exception {
+		if (StringUtils.isEmpty(id)) {
+			throw new Exception("id can not be empty.");
+		}
+		String str = DateTools.compactDate(this.getCreateTime());
+		str += PATHSEPARATOR;
+		str += this.id;
+		str += StringUtils.isEmpty(this.extension) ? "" : ("." + this.extension);
+		return str;
+	}
+
+	@Override
+	public String getStorage() {
+		return storage;
+	}
+
+	@Override
+	public void setStorage(String storage) {
+		this.storage = storage;
+	}
+
+	@Override
+	public Long getLength() {
+		return length;
+	}
+
+	@Override
+	public void setLength(Long length) {
+		this.length = length;
+	}
+
+	@Override
+	public String getName() {
+		return name;
+	}
+
+	@Override
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	@Override
+	public String getExtension() {
+		return extension;
+	}
+
+	@Override
+	public void setExtension(String extension) {
+		this.extension = extension;
+	}
+
+	@Override
+	public Date getLastUpdateTime() {
+		return lastUpdateTime;
+	}
+
+	@Override
+	public void setLastUpdateTime(Date lastUpdateTime) {
+		this.lastUpdateTime = lastUpdateTime;
+	}
+
+	@Override
+	public Boolean getDeepPath() {
+		return BooleanUtils.isTrue(this.deepPath);
+	}
+
+	@Override
+	public void setDeepPath(Boolean deepPath) {
+		this.deepPath = deepPath;
+	}
+
+	public static final String person_FIELDNAME = "person";
+	@FieldDescribe("上传用户.")
+	@Column(length = length_255B, name = ColumnNamePrefix + person_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + person_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private String person;
+
+	public static final String name_FIELDNAME = "name";
+	@FieldDescribe("文件名称.")
+	@Column(length = length_255B, name = ColumnNamePrefix + name_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + name_FIELDNAME)
+	@CheckPersist(allowEmpty = false, fileNameString = true)
+	private String name;
+
+	public static final String extension_FIELDNAME = "extension";
+	@FieldDescribe("扩展名,必须要有扩展名的文件才允许上传.")
+	@Column(length = JpaObject.length_64B, name = ColumnNamePrefix + extension_FIELDNAME)
+	@CheckPersist(allowEmpty = false, fileNameString = true)
+	private String extension;
+
+	public static final String storage_FIELDNAME = "storage";
+	@FieldDescribe("存储器的名称,也就是多个存放节点的名字.")
+	@Column(length = JpaObject.length_64B, name = ColumnNamePrefix + storage_FIELDNAME)
+	@CheckPersist(allowEmpty = false, simplyString = true)
+	private String storage;
+
+	public static final String length_FIELDNAME = "length";
+	@FieldDescribe("文件大小.")
+	@Column(name = ColumnNamePrefix + length_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private Long length;
+
+	public static final String lastUpdateTime_FIELDNAME = "lastUpdateTime";
+	@FieldDescribe("最后更新时间")
+	@Column(name = ColumnNamePrefix + lastUpdateTime_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + lastUpdateTime_FIELDNAME)
+	@CheckPersist(allowEmpty = false)
+	private Date lastUpdateTime;
+
+	public static final String deepPath_FIELDNAME = "deepPath";
+	@FieldDescribe("是否使用更深的路径.")
+	@CheckPersist(allowEmpty = true)
+	@Column(name = ColumnNamePrefix + deepPath_FIELDNAME)
+	private Boolean deepPath;
+
+	public String getPerson() {
+		return person;
+	}
+
+	public void setPerson(String person) {
+		this.person = person;
+	}
+}

+ 4 - 0
o2server/x_hotpic_assemble_control/pom.xml

@@ -36,6 +36,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_cms_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_meeting_assemble_control/pom.xml

@@ -28,6 +28,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_meeting_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_mind_assemble_control/pom.xml

@@ -24,6 +24,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_mind_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_organization_assemble_control/pom.xml

@@ -20,6 +20,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_organization_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 		<dependency>
 			<groupId>com.google.zxing</groupId>
 			<artifactId>core</artifactId>

+ 4 - 0
o2server/x_portal_assemble_surface/pom.xml

@@ -24,6 +24,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_organization_core_express</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_processplatform_assemble_designer/pom.xml

@@ -32,6 +32,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_processplatform_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_processplatform_assemble_surface/pom.xml

@@ -44,6 +44,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_portal_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 13 - 10
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompleted.java

@@ -7,16 +7,15 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -89,12 +88,16 @@ class ActionBatchDownloadWithWorkOrWorkCompleted extends BaseAction {
 
 			Map<String, byte[]> map = new HashMap<>();
 			if (StringUtils.isNotEmpty(flag)) {
-				CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
-				CacheKey cacheKey = new CacheKey(flag);
-				Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
-				if (optional.isPresent()) {
-					CacheResultObject ro = (CacheResultObject) optional.get();
-					map.put(ro.getName(), ro.getBytes());
+				GeneralFile generalFile = emc.find(flag, GeneralFile.class);
+				if(generalFile!=null){
+					StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+							generalFile.getStorage());
+					map.put(generalFile.getName(), generalFile.readContent(gfMapping));
+
+					generalFile.deleteContent(gfMapping);
+					emc.beginTransaction(GeneralFile.class);
+					emc.delete(GeneralFile.class, generalFile.getId());
+					emc.commit();
 				}
 			}
 

+ 13 - 10
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompletedStream.java

@@ -7,16 +7,15 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -89,12 +88,16 @@ class ActionBatchDownloadWithWorkOrWorkCompletedStream extends BaseAction {
 
 			Map<String, byte[]> map = new HashMap<>();
 			if (StringUtils.isNotEmpty(flag)) {
-				CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
-				CacheKey cacheKey = new CacheKey(flag);
-				Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
-				if (optional.isPresent()) {
-					CacheResultObject ro = (CacheResultObject) optional.get();
-					map.put(ro.getName(), ro.getBytes());
+				GeneralFile generalFile = emc.find(flag, GeneralFile.class);
+				if(generalFile!=null){
+					StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+							generalFile.getStorage());
+					map.put(generalFile.getName(), generalFile.readContent(gfMapping));
+
+					generalFile.deleteContent(gfMapping);
+					emc.beginTransaction(GeneralFile.class);
+					emc.delete(GeneralFile.class, generalFile.getId());
+					emc.commit();
 				}
 			}
 

+ 15 - 12
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadTransfer.java

@@ -1,17 +1,15 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
-import java.util.Optional;
-
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
+import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoFile;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 
 class ActionDownloadTransfer extends BaseAction {
 
@@ -21,13 +19,18 @@ class ActionDownloadTransfer extends BaseAction {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
-			CacheKey cacheKey = new CacheKey(flag);
-			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
-			if (optional.isPresent()) {
-				CacheResultObject ro = (CacheResultObject) optional.get();
-				wo = new Wo(ro.getBytes(), this.contentType(false, ro.getName()),
-						this.contentDisposition(false, ro.getName()));
+
+			GeneralFile generalFile = emc.find(flag, GeneralFile.class);
+			if(generalFile!=null){
+				StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+						generalFile.getStorage());
+				wo = new Wo(generalFile.readContent(gfMapping), this.contentType(false, generalFile.getName()),
+						this.contentDisposition(false, generalFile.getName()));
+
+				generalFile.deleteContent(gfMapping);
+				emc.beginTransaction(GeneralFile.class);
+				emc.delete(GeneralFile.class, generalFile.getId());
+				emc.commit();
 			}
 			result.setData(wo);
 			return result;

+ 15 - 12
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadWorkInfo.java

@@ -1,19 +1,17 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
-import java.util.Optional;
-
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
+import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoFile;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
+import com.x.general.core.entity.file.GeneralFile;
 import com.x.processplatform.assemble.surface.Business;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
 
@@ -41,13 +39,18 @@ class ActionDownloadWorkInfo extends BaseAction {
 				}
 			}
 			Wo wo = null;
-			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
-			CacheKey cacheKey = new CacheKey(flag);
-			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
-			if (optional.isPresent()) {
-				CacheResultObject ro = (CacheResultObject) optional.get();
-				wo = new Wo(ro.getBytes(), this.contentType(false, ro.getName()),
-						this.contentDisposition(false, ro.getName()));
+
+			GeneralFile generalFile = emc.find(flag, GeneralFile.class);
+			if(generalFile!=null){
+				StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+						generalFile.getStorage());
+				wo = new Wo(generalFile.readContent(gfMapping), this.contentType(false, generalFile.getName()),
+						this.contentDisposition(false, generalFile.getName()));
+
+				generalFile.deleteContent(gfMapping);
+				emc.beginTransaction(GeneralFile.class);
+				emc.delete(GeneralFile.class, generalFile.getId());
+				emc.commit();
 			}
 			result.setData(wo);
 			return result;

+ 21 - 17
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToPdf.java

@@ -2,6 +2,11 @@ package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
 import java.io.ByteArrayOutputStream;
 
+import com.x.base.core.entity.annotation.CheckPersistType;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.Business;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.commons.lang3.StringUtils;
 
 import com.google.gson.JsonElement;
@@ -14,9 +19,6 @@ import com.itextpdf.kernel.pdf.PdfWriter;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.FieldDescribe;
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
@@ -25,7 +27,6 @@ import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DateTools;
-import com.x.base.core.project.tools.StringTools;
 
 class ActionHtmlToPdf extends BaseAction {
 
@@ -34,9 +35,10 @@ class ActionHtmlToPdf extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
+			Business business = new Business(emc);
 			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			Wo wo = new Wo();
-			String id = savePdf(wi, effectivePerson.getDistinguishedName());
+			String id = savePdf(wi, effectivePerson.getDistinguishedName(), business);
 			wo.setId(id);
 			result.setData(wo);
 			return result;
@@ -47,11 +49,8 @@ class ActionHtmlToPdf extends BaseAction {
 
 	}
 
-	private String savePdf(Wi wi, String person) {
+	private String savePdf(Wi wi, String person, Business business) {
 		try {
-			CacheResultObject ro = new CacheResultObject();
-			ro.setPerson(person);
-
 			String workHtml = wi.getWorkHtml();
 			if (StringUtils.isEmpty(workHtml)) {
 				workHtml = "无内容";
@@ -59,10 +58,11 @@ class ActionHtmlToPdf extends BaseAction {
 			if (workHtml.toLowerCase().indexOf("<html") == -1) {
 				workHtml = "<html><head></head><body>" + workHtml + "</body></html>";
 			}
-			String title = person + DateTools.now() + ".pdf";
+			String name = person + DateTools.now() + ".pdf";
 			if (StringUtils.isNotEmpty(wi.getTitle())) {
-				title = wi.getTitle() + ".pdf";
+				name = wi.getTitle() + ".pdf";
 			}
+			byte[] bytes;
 			try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
 				ConverterProperties props = new ConverterProperties();
 				DefaultFontProvider dfp = new DefaultFontProvider(false, false, false);
@@ -77,13 +77,17 @@ class ActionHtmlToPdf extends BaseAction {
 				}
 				pdf.setDefaultPageSize(new PageSize(width, PageSize.A4.getHeight()));
 				HtmlConverter.convertToPdf(workHtml, pdf, props);
-				ro.setBytes(out.toByteArray());
-				ro.setName(title + ".pdf");
+				bytes = out.toByteArray();
 			}
-			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
-			String key = StringTools.uniqueToken();
-			CacheKey cacheKey = new CacheKey(key);
-			CacheManager.put(cacheCategory, cacheKey, ro);
+			StorageMapping gfMapping = ThisApplication.context().storageMappings().random(GeneralFile.class);
+			GeneralFile generalFile = new GeneralFile(gfMapping.getName(), name, person);
+			generalFile.saveContent(gfMapping, bytes, name);
+			EntityManagerContainer emc = business.entityManagerContainer();
+			emc.beginTransaction(GeneralFile.class);
+			emc.persist(generalFile, CheckPersistType.all);
+			emc.commit();
+
+			String key = generalFile.getId();
 			return key;
 		} catch (Exception e) {
 			logger.warn("写work信息异常" + e.getMessage());

+ 16 - 13
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImage.java

@@ -1,13 +1,14 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import com.x.base.core.entity.annotation.CheckPersistType;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.commons.io.FilenameUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.ActionLogger;
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
@@ -16,7 +17,6 @@ import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DocumentTools;
-import com.x.base.core.project.tools.StringTools;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.content.Attachment;
 
@@ -39,17 +39,20 @@ class ActionPreviewImage extends BaseAction {
 				throw new ExceptionAccessDenied(effectivePerson);
 			}
 		}
+		String key = "";
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			byte[] bytes = DocumentTools.toImage(attachment.getName(), attachment.getBytes(), "", page);
+			String name = FilenameUtils.getBaseName(attachment.getName()) + ".png";
+			StorageMapping gfMapping = ThisApplication.context().storageMappings().random(GeneralFile.class);
+			GeneralFile generalFile = new GeneralFile(gfMapping.getName(), name, effectivePerson.getDistinguishedName());
+			generalFile.saveContent(gfMapping, bytes, name);
+			emc.beginTransaction(GeneralFile.class);
+			emc.persist(generalFile, CheckPersistType.all);
+			emc.commit();
 
-		byte[] bytes = DocumentTools.toImage(attachment.getName(), attachment.getBytes(), "", page);
-		PreviewImageResultObject obj = new PreviewImageResultObject();
-		obj.setPerson(effectivePerson.getDistinguishedName());
-		obj.setBytes(bytes);
-		obj.setName(FilenameUtils.getBaseName(attachment.getName()) + ".png");
+			key = generalFile.getId();
+		}
 
-		String key = StringTools.uniqueToken();
-		CacheCategory cacheCategory = new CacheCategory(PreviewImageResultObject.class);
-		CacheKey cacheKey = new CacheKey(key);
-		CacheManager.put(cacheCategory, cacheKey, obj);
 		Wo wo = new Wo();
 		wo.setId(key);
 		result.setData(wo);

+ 24 - 17
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImageResult.java

@@ -1,12 +1,12 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
-import java.util.Optional;
-
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.commons.lang3.StringUtils;
 
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -20,20 +20,27 @@ class ActionPreviewImageResult extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
 		ActionResult<Wo> result = new ActionResult<>();
-		CacheCategory cacheCategory = new CacheCategory(PreviewImageResultObject.class);
-		CacheKey cacheKey = new CacheKey(flag);
-		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
 		Wo wo = null;
-		if (optional.isPresent()) {
-			PreviewImageResultObject obj = (PreviewImageResultObject) optional.get();
-			if (!StringUtils.equals(effectivePerson.getDistinguishedName(), obj.getPerson())) {
-				throw new ExceptionAccessDenied(effectivePerson);
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			GeneralFile generalFile = emc.find(flag, GeneralFile.class);
+			if(generalFile!=null){
+				if (!StringUtils.equals(effectivePerson.getDistinguishedName(), generalFile.getPerson())) {
+					throw new ExceptionAccessDenied(effectivePerson);
+				}
+				StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+						generalFile.getStorage());
+				wo = new Wo(generalFile.readContent(gfMapping), this.contentType(true, generalFile.getName()),
+						this.contentDisposition(true, generalFile.getName()));
+				result.setData(wo);
+
+				generalFile.deleteContent(gfMapping);
+				emc.beginTransaction(GeneralFile.class);
+				emc.delete(GeneralFile.class, generalFile.getId());
+				emc.commit();
+			} else {
+				throw new ExceptionPreviewImageResultObject(flag);
 			}
-			wo = new Wo(obj.getBytes(), this.contentType(true, obj.getName()),
-					this.contentDisposition(true, obj.getName()));
-			result.setData(wo);
-		} else {
-			throw new ExceptionPreviewImageResultObject(flag);
+
 		}
 		result.setData(wo);
 		return result;

+ 16 - 11
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdf.java

@@ -1,5 +1,9 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import com.x.base.core.entity.annotation.CheckPersistType;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.commons.io.FilenameUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
@@ -38,18 +42,19 @@ class ActionPreviewPdf extends BaseAction {
 				throw new ExceptionAccessDenied(effectivePerson);
 			}
 		}
+		String key = "";
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			byte[] bytes = DocumentTools.toPdf(attachment.getName(), attachment.getBytes(), "");
+			String name = FilenameUtils.getBaseName(attachment.getName()) + ".pdf";
+			StorageMapping gfMapping = ThisApplication.context().storageMappings().random(GeneralFile.class);
+			GeneralFile generalFile = new GeneralFile(gfMapping.getName(), name, effectivePerson.getDistinguishedName());
+			generalFile.saveContent(gfMapping, bytes, name);
+			emc.beginTransaction(GeneralFile.class);
+			emc.persist(generalFile, CheckPersistType.all);
+			emc.commit();
 
-		byte[] bytes = DocumentTools.toPdf(attachment.getName(), attachment.getBytes(), "");
-
-		PreviewPdfResultObject obj = new PreviewPdfResultObject();
-		obj.setPerson(effectivePerson.getDistinguishedName());
-		obj.setBytes(bytes);
-		obj.setName(FilenameUtils.getBaseName(attachment.getName()) + ".pdf");
-
-		String key = StringTools.uniqueToken();
-		CacheCategory cacheCategory = new CacheCategory(PreviewPdfResultObject.class);
-		CacheKey cacheKey = new CacheKey(key);
-		CacheManager.put(cacheCategory, cacheKey, obj);
+			key = generalFile.getId();
+		}
 		Wo wo = new Wo();
 		wo.setId(key);
 		result.setData(wo);

+ 24 - 17
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdfResult.java

@@ -1,13 +1,13 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
-import java.util.Optional;
-
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.project.annotation.ActionLogger;
-import com.x.base.core.project.cache.Cache.CacheCategory;
-import com.x.base.core.project.cache.Cache.CacheKey;
-import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -23,19 +23,26 @@ class ActionPreviewPdfResult extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
 		ActionResult<Wo> result = new ActionResult<>();
 		Wo wo = null;
-		CacheCategory cacheCategory = new CacheCategory(PreviewPdfResultObject.class);
-		CacheKey cacheKey = new CacheKey(flag);
-		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
-		if (optional.isPresent()) {
-			PreviewPdfResultObject obj = (PreviewPdfResultObject) optional.get();
-			if (!StringUtils.equals(effectivePerson.getDistinguishedName(), obj.getPerson())) {
-				throw new ExceptionAccessDenied(effectivePerson);
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			GeneralFile generalFile = emc.find(flag, GeneralFile.class);
+			if(generalFile!=null){
+				if (!StringUtils.equals(effectivePerson.getDistinguishedName(), generalFile.getPerson())) {
+					throw new ExceptionAccessDenied(effectivePerson);
+				}
+				StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+						generalFile.getStorage());
+				wo = new Wo(generalFile.readContent(gfMapping), this.contentType(true, generalFile.getName()),
+						this.contentDisposition(true, generalFile.getName()));
+				result.setData(wo);
+
+				generalFile.deleteContent(gfMapping);
+				emc.beginTransaction(GeneralFile.class);
+				emc.delete(GeneralFile.class, generalFile.getId());
+				emc.commit();
+			} else {
+				throw new ExceptionPreviewImageResultObject(flag);
 			}
-			wo = new Wo(obj.getBytes(), this.contentType(true, obj.getName()),
-					this.contentDisposition(true, obj.getName()));
-			result.setData(wo);
-		} else {
-			throw new ExceptionPreviewPdfResultObject(flag);
+
 		}
 		result.setData(wo);
 		return result;

+ 24 - 16
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java

@@ -7,6 +7,10 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 
+import com.x.base.core.entity.annotation.CheckPersistType;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.file.GeneralFile;
+import com.x.processplatform.assemble.surface.ThisApplication;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 import com.google.gson.JsonElement;
@@ -69,7 +73,7 @@ class ActionUploadWorkInfo extends BaseAction {
 				workHtml = "<html><head></head><body>" + workHtml + "</body></html>";
 			}
 			String id = saveHtml(workId, flag, workHtml, effectivePerson.getDistinguishedName(), title,
-					wi.getPageWidth());
+					wi.getPageWidth(), business);
 			Wo wo = new Wo();
 			wo.setId(id);
 			result.setData(wo);
@@ -80,18 +84,19 @@ class ActionUploadWorkInfo extends BaseAction {
 	public static class Wo extends WoId {
 	}
 
-	private String saveHtml(String workId, String flag, String workHtml, String person, String title, Float pageWidth) {
+	private String saveHtml(String workId, String flag, String workHtml, String person, String title,
+							Float pageWidth, Business business) {
 		try {
-			CacheResultObject ro = new CacheResultObject();
-			ro.setPerson(person);
+			String name = "";
+			byte[] bytes;
 			if ("word".equals(flag)) {
 				try (POIFSFileSystem fs = new POIFSFileSystem();
 						InputStream is = new ByteArrayInputStream(workHtml.getBytes("UTF-8"));
 						ByteArrayOutputStream out = new ByteArrayOutputStream()) {
 					fs.createDocument(is, "WordDocument");
 					fs.writeFilesystem(out);
-					ro.setBytes(out.toByteArray());
-					ro.setName(title + "-处理单.doc");
+					bytes = out.toByteArray();
+					name = title + "-处理单.doc";
 				}
 			} else if ("pdf".equals(flag)) {
 				try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
@@ -108,19 +113,22 @@ class ActionUploadWorkInfo extends BaseAction {
 					}
 					pdf.setDefaultPageSize(new PageSize(width, PageSize.A4.getHeight()));
 					HtmlConverter.convertToPdf(workHtml, pdf, props);
-					ro.setBytes(out.toByteArray());
-					ro.setName(title + "-处理单.pdf");
+					bytes = out.toByteArray();
+					name = title + "-处理单.pdf";
 				}
 			} else {
-				ro.setBytes(workHtml.getBytes(DefaultCharset.charset));
-				ro.setName(title + "-处理单.html");
+				bytes = workHtml.getBytes(DefaultCharset.charset);
+				name = title + "-处理单.html";
 			}
-			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
-			String key = StringTools.uniqueToken();
-			CacheKey cacheKey = new CacheKey(key);
-			// String cacheKey = ApplicationCache.concreteCacheKey(workId,
-			// UUID.randomUUID().toString());
-			CacheManager.put(cacheCategory, cacheKey, ro);
+			StorageMapping gfMapping = ThisApplication.context().storageMappings().random(GeneralFile.class);
+			GeneralFile generalFile = new GeneralFile(gfMapping.getName(), name, person);
+			generalFile.saveContent(gfMapping, bytes, name);
+			EntityManagerContainer emc = business.entityManagerContainer();
+			emc.beginTransaction(GeneralFile.class);
+			emc.persist(generalFile, CheckPersistType.all);
+			emc.commit();
+
+			String key = generalFile.getId();
 			return key;
 		} catch (Exception e) {
 			logger.warn("写work信息异常" + e.getMessage());

+ 4 - 0
o2server/x_query_assemble_designer/pom.xml

@@ -44,6 +44,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_cms_core_express</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 4 - 0
o2server/x_query_assemble_surface/pom.xml

@@ -43,6 +43,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_cms_core_express</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_general_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>