Просмотр исходного кода

Merge branch 'wrdp' into 'develop'

Wrdp

See merge request o2oa/o2oa!3074
o2null 4 лет назад
Родитель
Сommit
7afd285a08

+ 5 - 4
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_query_assemble_surface.java

@@ -20,9 +20,10 @@ import com.x.base.core.project.annotation.ModuleType;
 		"com.x.processplatform.core.entity.content.Attachment", "com.x.cms.core.entity.Document",
 		"com.x.cms.core.entity.Review", "com.x.cms.core.entity.AppInfo", "com.x.cms.core.entity.CategoryInfo",
 		"com.x.organization.core.entity.Person", "com.x.organization.core.entity.Unit", "com.x.organization.core.entity.Group",
-		"com.x.query.dynamic.entity.*" }, storageTypes = { StorageType.processPlatform, StorageType.cms }, storeJars = {
-				"x_query_core_entity", "x_organization_core_entity", "x_organization_core_express",
-				"x_processplatform_core_entity", "x_cms_core_entity",
-				"x_query_core_express" }, dynamicJars = { "x_query_dynamic_entity" })
+		"com.x.query.dynamic.entity.*", "com.x.general.core.entity.GeneralFile"},
+		storageTypes = { StorageType.processPlatform, StorageType.cms, StorageType.general}, storeJars = {
+		"x_query_core_entity", "x_organization_core_entity", "x_organization_core_express",
+		"x_processplatform_core_entity", "x_cms_core_entity",
+		"x_query_core_express", "x_general_core_entity" }, dynamicJars = { "x_query_dynamic_entity" })
 public class x_query_assemble_surface extends Deployable {
 }

+ 219 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/ActionFileUploadWithUrl.java

@@ -0,0 +1,219 @@
+package com.x.cms.assemble.control.jaxrs.fileinfo;
+
+import com.google.gson.JsonElement;
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.annotation.AuditLog;
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.CacheManager;
+import com.x.base.core.project.config.Config;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.base.core.project.connection.CipherConnectionAction;
+import com.x.base.core.project.exception.ExceptionEntityFieldEmpty;
+import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+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.organization.Person;
+import com.x.base.core.project.tools.ExtractTextTools;
+import com.x.cms.assemble.control.Business;
+import com.x.cms.assemble.control.ThisApplication;
+import com.x.cms.core.entity.Document;
+import com.x.cms.core.entity.FileInfo;
+import com.x.processplatform.core.entity.content.Attachment;
+import com.x.processplatform.core.entity.content.Work;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.tika.Tika;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class ActionFileUploadWithUrl extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ActionFileUploadWithUrl.class);
+
+	@AuditLog(operation = "上传附件")
+	protected ActionResult<Wo> execute(EffectivePerson effectivePerson,
+										JsonElement jsonElement) throws Exception {
+		logger.debug("ActionFileUploadWithUrl receive:{}.", jsonElement.toString());
+		ActionResult<Wo> result = new ActionResult<>();
+
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+		if(StringUtils.isEmpty(wi.getDocId())){
+			throw new ExceptionEntityFieldEmpty(Work.class, wi.getDocId());
+		}
+		if(StringUtils.isEmpty(wi.getFileName())){
+			throw new ExceptionEntityFieldEmpty(Attachment.class, wi.getFileName());
+		}
+		if(StringUtils.isEmpty(wi.getFileUrl())){
+			throw new ExceptionEntityFieldEmpty(Attachment.class, wi.getFileUrl());
+		}
+		if(StringUtils.isEmpty(wi.getSite())){
+			throw new ExceptionEntityFieldEmpty(Attachment.class, wi.getSite());
+		}
+		String person = effectivePerson.getDistinguishedName();
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			if(StringUtils.isNotEmpty(wi.getPerson()) && business.isManager(effectivePerson)){
+				Person p = business.organization().person().getObject(wi.getPerson());
+				if(p!=null){
+					person = p.getDistinguishedName();
+				}
+			}
+		}
+
+		Document document = documentQueryService.get( wi.getDocId() );
+		if (null == document) {
+			throw new ExceptionDocumentNotExists(wi.getDocId());
+		}
+
+		StorageMapping mapping = ThisApplication.context().storageMappings().random( FileInfo.class );
+		FileInfo attachment = this.concreteAttachment( mapping, document, wi.getFileName(), person, wi.getSite() );
+		byte[] bytes = CipherConnectionAction.getBinary(false, wi.getFileUrl());
+		if(bytes==null || bytes.length==0){
+			throw new Exception("can not down file from url!");
+		}
+
+		attachment.setType((new Tika()).detect(bytes, wi.getFileName()));
+		logger.debug("filename:{}, file type:{}.", attachment.getName(), attachment.getType());
+		if (Config.query().getExtractImage() && ExtractTextTools.supportImage(attachment.getName()) && ExtractTextTools.available(bytes)) {
+			attachment.setText(ExtractTextTools.image(bytes));
+			logger.debug("filename:{}, file type:{}, text:{}.", attachment.getName(), attachment.getType(),
+					attachment.getText());
+		}
+
+		attachment.saveContent(mapping, bytes, wi.getFileName());
+		attachment = fileInfoServiceAdv.saveAttachment( wi.getDocId(), attachment );
+
+		CacheManager.notify( FileInfo.class );
+		CacheManager.notify( Document.class );
+
+		Wo wo = new Wo();
+		wo.setId( attachment.getId() );
+		result.setData(wo);
+
+		return result;
+	}
+
+	private FileInfo concreteAttachment(StorageMapping mapping, Document document, String name, String person, String site) throws Exception {
+		FileInfo attachment = new FileInfo();
+		String fileName = UUID.randomUUID().toString();
+		String extension = FilenameUtils.getExtension( name );
+		if ( StringUtils.isNotEmpty(extension)) {
+			fileName = fileName + "." + extension;
+		}else{
+			throw new ExceptionEmptyExtension(name);
+		}
+		if( name.indexOf( "\\" ) >0 ){
+			name = StringUtils.substringAfterLast( name, "\\");
+		}
+		if( name.indexOf( "/" ) >0 ){
+			name = StringUtils.substringAfterLast( name, "/");
+		}
+		attachment.setCreateTime( new Date() );
+		attachment.setLastUpdateTime( new Date() );
+		attachment.setExtension( extension );
+		attachment.setName( name );
+		attachment.setFileName( fileName );
+		attachment.setStorage( mapping.getName() );
+		attachment.setAppId( document.getAppId() );
+		attachment.setCategoryId( document.getCategoryId() );
+		attachment.setDocumentId( document.getId() );
+		attachment.setCreatorUid(person);
+		attachment.setSite( site );
+		attachment.setFileHost( "" );
+		attachment.setFileType("ATTACHMENT");
+		attachment.setFileExtType( getExtType( extension ) );
+		attachment.setFilePath( "" );
+		return attachment;
+	}
+
+	private String getExtType( String ext ){
+		String type = "OTHER";
+		if( "jpg".equalsIgnoreCase( ext ) ){ type = "PICTURE";
+		} else if("jpeg".equalsIgnoreCase( ext ) ){ type = "PICTURE";
+		} else if("png".equalsIgnoreCase( ext ) ){ type = "PICTURE";
+		} else if("tif".equalsIgnoreCase( ext ) ){ type = "PICTURE";
+		} else if("bmp".equalsIgnoreCase( ext ) ){ type = "PICTURE";
+		} else if("gif".equalsIgnoreCase( ext ) ){ type = "PICTURE";
+		} else if("xls".equalsIgnoreCase( ext ) ){ type = "EXCLE";
+		} else if("xlsx".equalsIgnoreCase( ext ) ){ type = "EXCLE";
+		} else if("doc".equalsIgnoreCase( ext ) ){ type = "WORD";
+		} else if("docx".equalsIgnoreCase( ext ) ){ type = "WORD";
+		} else if("ppt".equalsIgnoreCase( ext ) ){ type = "PPT";
+		} else if("pptx".equalsIgnoreCase( ext ) ){ type = "PPT";
+		} else if("zip".equalsIgnoreCase( ext ) ){ type = "ZIP";
+		} else if("rar".equalsIgnoreCase( ext ) ){ type = "ZIP";
+		} else if("txt".equalsIgnoreCase( ext ) ){ type = "TXT";
+		} else if("pdf".equalsIgnoreCase( ext ) ){ type = "PDF";
+		}
+		return type;
+	}
+
+	public static class Wi extends GsonPropertyObject {
+
+		private static final long serialVersionUID = 5113558862906097036L;
+
+		@FieldDescribe("*内容管理文档id.")
+		private String docId;
+
+		@FieldDescribe("*文件名称,带扩展名的文件名.")
+		private String fileName;
+
+		@FieldDescribe("*附件来源url地址.")
+		private String fileUrl;
+
+		@FieldDescribe("*附件分类.")
+		private String site;
+
+		@FieldDescribe("上传人员(仅对管理员生效).")
+		private String person;
+
+		public String getDocId() {
+			return docId;
+		}
+
+		public void setDocId(String docId) {
+			this.docId = docId;
+		}
+
+		public String getFileName() {
+			return fileName;
+		}
+
+		public void setFileName(String fileName) {
+			this.fileName = fileName;
+		}
+
+		public String getFileUrl() {
+			return fileUrl;
+		}
+
+		public void setFileUrl(String fileUrl) {
+			this.fileUrl = fileUrl;
+		}
+
+		public String getPerson() {
+			return person;
+		}
+
+		public void setPerson(String person) {
+			this.person = person;
+		}
+
+		public String getSite() {
+			return site;
+		}
+
+		public void setSite(String site) {
+			this.site = site;
+		}
+	}
+
+	public static class Wo extends WoId {
+
+	}
+}

+ 18 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/FileInfoAction.java

@@ -312,4 +312,22 @@ public class FileInfoAction extends StandardJaxrsAction{
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
+
+	@JaxrsMethodDescribe(value = "文档上传附件", action = ActionFileUploadWithUrl.class)
+	@POST
+	@Path("upload/with/url")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void uploadWithUrl(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							  JsonElement jsonElement) {
+		ActionResult<ActionFileUploadWithUrl.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionFileUploadWithUrl().execute(effectivePerson, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
 }

+ 19 - 6
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionManageBatchUpload.java

@@ -6,6 +6,7 @@ import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
+import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WrapBoolean;
@@ -19,10 +20,14 @@ import com.x.processplatform.core.entity.content.Attachment;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
 import com.x.processplatform.core.entity.element.ActivityType;
+import com.x.processplatform.core.entity.element.End;
+import com.x.processplatform.core.entity.element.Process;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.tika.Tika;
 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
 
+import java.util.List;
+
 class ActionManageBatchUpload extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionManageBatchUpload.class);
@@ -66,7 +71,15 @@ class ActionManageBatchUpload extends BaseAction {
                     }else{
                         WorkCompleted workCompleted = emc.find(workId, WorkCompleted.class);
                         if (null != workCompleted) {
-                            attachment = this.concreteAttachment(workCompleted, person, site, order);
+							Process process = business.process().pick(workCompleted.getProcess());
+							if (null == process) {
+								throw new ExceptionEntityNotExist(workCompleted.getProcess(), Process.class);
+							}
+							List<End> ends = business.end().listWithProcess(process);
+							if (ends.isEmpty()) {
+								throw new ExceptionEndNotExist(process.getId());
+							}
+							attachment = this.concreteAttachment(workCompleted, person, site, order, ends.get(0));
                         }
                     }
                     if(attachment!=null){
@@ -112,7 +125,7 @@ class ActionManageBatchUpload extends BaseAction {
 		return attachment;
 	}
 
-    private Attachment concreteAttachment(WorkCompleted workCompleted, String person, String site, Integer order) throws Exception {
+    private Attachment concreteAttachment(WorkCompleted workCompleted, String person, String site, Integer order, End end) throws Exception {
         Attachment attachment = new Attachment();
         attachment.setCompleted(true);
         attachment.setPerson(person);
@@ -123,10 +136,10 @@ class ActionManageBatchUpload extends BaseAction {
         attachment.setApplication(workCompleted.getApplication());
         attachment.setProcess(workCompleted.getProcess());
         attachment.setJob(workCompleted.getJob());
-        attachment.setActivity(workCompleted.getActivity());
-        attachment.setActivityName(workCompleted.getActivityName());
-        attachment.setActivityToken(workCompleted.getActivity());
-        attachment.setActivityType(ActivityType.end);
+		attachment.setActivity(end.getId());
+		attachment.setActivityName(end.getName());
+		attachment.setActivityToken(end.getId());
+		attachment.setActivityType(end.getActivityType());
 		if(order!=null){
 			attachment.setOrderNumber(order);
 		}

+ 18 - 6
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithUrl.java

@@ -27,9 +27,13 @@ import com.x.processplatform.core.entity.content.Attachment;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
 import com.x.processplatform.core.entity.element.ActivityType;
+import com.x.processplatform.core.entity.element.End;
+import com.x.processplatform.core.entity.element.Process;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.tika.Tika;
 
+import java.util.List;
+
 class ActionUploadWithUrl extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionUploadWithUrl.class);
@@ -70,7 +74,15 @@ class ActionUploadWithUrl extends BaseAction {
 			if (null == work) {
 				WorkCompleted workCompleted = emc.find(wi.getWorkId(), WorkCompleted.class);
 				if(workCompleted!=null){
-					attachment = this.concreteAttachment(workCompleted, person, wi.getSite());
+					Process process = business.process().pick(workCompleted.getProcess());
+					if (null == process) {
+						throw new ExceptionEntityNotExist(workCompleted.getProcess(), Process.class);
+					}
+					List<End> ends = business.end().listWithProcess(process);
+					if (ends.isEmpty()) {
+						throw new ExceptionEndNotExist(process.getId());
+					}
+					attachment = this.concreteAttachment(workCompleted, person, wi.getSite(), ends.get(0));
 				}
 			}else{
 				attachment = this.concreteAttachment(work, person, wi.getSite());
@@ -121,7 +133,7 @@ class ActionUploadWithUrl extends BaseAction {
 		return attachment;
 	}
 
-	private Attachment concreteAttachment(WorkCompleted workCompleted, String person, String site) throws Exception {
+	private Attachment concreteAttachment(WorkCompleted workCompleted, String person, String site, End end) throws Exception {
 		Attachment attachment = new Attachment();
 		attachment.setCompleted(true);
 		attachment.setPerson(person);
@@ -132,10 +144,10 @@ class ActionUploadWithUrl extends BaseAction {
 		attachment.setApplication(workCompleted.getApplication());
 		attachment.setProcess(workCompleted.getProcess());
 		attachment.setJob(workCompleted.getJob());
-		attachment.setActivity(workCompleted.getActivity());
-		attachment.setActivityName(workCompleted.getActivityName());
-		attachment.setActivityToken(workCompleted.getActivity());
-		attachment.setActivityType(ActivityType.end);
+		attachment.setActivity(end.getId());
+		attachment.setActivityName(end.getName());
+		attachment.setActivityToken(end.getId());
+		attachment.setActivityType(end.getActivityType());
 		return attachment;
 	}
 

+ 13 - 2
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/view/ActionExcel.java

@@ -32,6 +32,7 @@ class ActionExcel extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
 		ActionResult<Wo> result = new ActionResult<>();
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 		View view;
 		Runtime runtime;
 		Business business;
@@ -51,13 +52,12 @@ class ActionExcel extends BaseAction {
 			if (!business.readable(effectivePerson, view)) {
 				throw new ExceptionAccessDenied(effectivePerson, view);
 			}
-			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			runtime = this.runtime(effectivePerson, business, view, wi.getFilterList(), wi.getParameter(),
 					wi.getCount(), false);
 			runtime.bundleList = wi.getBundleList();
 		}
 		Plan plan = this.accessPlan(business, view, runtime);
-		String excelFlag = this.girdWriteToExcel(effectivePerson, business, plan, view);
+		String excelFlag = this.girdWriteToExcel(effectivePerson, business, plan, view, wi.getExcelName());
 		Wo wo = new Wo();
 		wo.setId(excelFlag);
 		result.setData(wo);
@@ -79,6 +79,9 @@ class ActionExcel extends BaseAction {
 		@FieldDescribe("数量")
 		private Integer count = 0;
 
+		@FieldDescribe("excel导出名称,默认为视图名称")
+		private String excelName;
+
 		@FieldDescribe("限定结果集")
 		public List<String> bundleList = new TreeList<>();
 
@@ -113,6 +116,14 @@ class ActionExcel extends BaseAction {
 		public void setBundleList(List<String> bundleList) {
 			this.bundleList = bundleList;
 		}
+
+		public String getExcelName() {
+			return excelName;
+		}
+
+		public void setExcelName(String excelName) {
+			this.excelName = excelName;
+		}
 	}
 
 }

+ 10 - 11
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/view/ActionExcelResult.java

@@ -1,5 +1,8 @@
 package com.x.query.assemble.surface.jaxrs.view;
 
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.GeneralFile;
+import com.x.query.assemble.surface.ThisApplication;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
@@ -23,16 +26,12 @@ class ActionExcelResult extends BaseAction {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			logger.info("{}", flag);
 			ActionResult<Wo> result = new ActionResult<>();
-			Business business = new Business(emc);
-			CacheKey cacheKey = new CacheKey(flag);
-			Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
-			if (optional.isPresent()) {
-				ExcelResultObject obj = (ExcelResultObject) optional.get();
-				if (!StringUtils.equals(effectivePerson.getDistinguishedName(), obj.getPerson())) {
-					throw new ExceptionAccessDenied(effectivePerson);
-				}
-				Wo wo = new Wo(obj.getBytes(), this.contentType(true, obj.getName()),
-						this.contentDisposition(true, obj.getName()));
+			GeneralFile generalFile = emc.find(flag, GeneralFile.class);
+			if(generalFile!=null){
+				StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
+						generalFile.getStorage());
+				Wo wo = new Wo(generalFile.readContent(gfMapping), this.contentType(true, generalFile.getName()),
+						this.contentDisposition(true, generalFile.getName()));
 				result.setData(wo);
 			} else {
 				throw new ExceptionExcelResultObject(flag);
@@ -49,4 +48,4 @@ class ActionExcelResult extends BaseAction {
 
 	}
 
-}
+}

+ 12 - 2
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/view/ActionExcelWithQuery.java

@@ -29,6 +29,7 @@ class ActionExcelWithQuery extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String queryFlag, JsonElement jsonElement)
 			throws Exception {
 		ActionResult<Wo> result = new ActionResult<>();
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 		View view;
 		Runtime runtime;
 		Business business;
@@ -49,13 +50,12 @@ class ActionExcelWithQuery extends BaseAction {
 			if (!business.readable(effectivePerson, view)) {
 				throw new ExceptionAccessDenied(effectivePerson, view);
 			}
-			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			runtime = this.runtime(effectivePerson, business, view, wi.getFilterList(), wi.getParameter(),
 					wi.getCount(), false);
 			runtime.bundleList = wi.getBundleList();
 		}
 		Plan plan = this.accessPlan(business, view, runtime);
-		String excelFlag = this.girdWriteToExcel(effectivePerson, business, plan, view);
+		String excelFlag = this.girdWriteToExcel(effectivePerson, business, plan, view, wi.getExcelName());
 		Wo wo = new Wo();
 		wo.setId(excelFlag);
 		result.setData(wo);
@@ -79,6 +79,9 @@ class ActionExcelWithQuery extends BaseAction {
 		@FieldDescribe("数量")
 		private Integer count = 0;
 
+		@FieldDescribe("excel导出名称,默认为视图名称")
+		private String excelName;
+
 		@FieldDescribe("限定结果集")
 		public List<String> bundleList = new TreeList<>();
 
@@ -114,6 +117,13 @@ class ActionExcelWithQuery extends BaseAction {
 			this.bundleList = bundleList;
 		}
 
+		public String getExcelName() {
+			return excelName;
+		}
+
+		public void setExcelName(String excelName) {
+			this.excelName = excelName;
+		}
 	}
 
 }

+ 21 - 10
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/view/BaseAction.java

@@ -11,7 +11,11 @@ import java.util.Objects;
 import com.google.gson.reflect.TypeToken;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.entity.annotation.CheckPersistType;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.general.core.entity.GeneralFile;
 import com.x.processplatform.core.entity.element.Process;
+import com.x.query.assemble.surface.ThisApplication;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.math.NumberUtils;
@@ -166,7 +170,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 
 	}
 
-	protected String girdWriteToExcel(EffectivePerson effectivePerson, Business business, Plan plan, View view)
+	protected String girdWriteToExcel(EffectivePerson effectivePerson, Business business, Plan plan, View view, String excelName)
 			throws Exception {
 		try (XSSFWorkbook workbook = new XSSFWorkbook(); ByteArrayOutputStream os = new ByteArrayOutputStream()) {
 			XSSFSheet sheet = workbook.createSheet("grid");
@@ -197,16 +201,23 @@ abstract class BaseAction extends StandardJaxrsAction {
 					}
 				}
 			}
-			String name = view.getName() + ".xlsx";
+			if(StringUtils.isEmpty(excelName)) {
+				excelName = view.getName() + ".xlsx";
+			}
+			if(!excelName.toLowerCase().endsWith(".xlsx")){
+				excelName = excelName + ".xlsx";
+			}
 			workbook.write(os);
-			ExcelResultObject obj = new ExcelResultObject();
-			obj.setBytes(os.toByteArray());
-			obj.setName(name);
-			obj.setPerson(effectivePerson.getDistinguishedName());
-			String flag = StringTools.uniqueToken();
-			CacheKey cacheKey = new CacheKey(flag);
-			CacheManager.put(business.cache(), cacheKey, obj);
-			return flag;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				StorageMapping gfMapping = ThisApplication.context().storageMappings().random(GeneralFile.class);
+				GeneralFile generalFile = new GeneralFile(gfMapping.getName(), excelName, effectivePerson.getDistinguishedName());
+				generalFile.saveContent(gfMapping, os.toByteArray(), excelName);
+				emc.beginTransaction(GeneralFile.class);
+				emc.persist(generalFile, CheckPersistType.all);
+				emc.commit();
+				String key = generalFile.getId();
+				return key;
+			}
 		}
 	}