From c61618b8f39554c78c30dddad5de2b641a08d3d1 Mon Sep 17 00:00:00 2001 From: o2null Date: Fri, 10 Jul 2020 06:23:16 +0000 Subject: [PATCH] Merge branch 'fix/docToWordWorkCompleted' into 'develop' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加workOrWorkCompleted转换docToWord See merge request o2oa/o2oa!1086 (cherry picked from commit 3343c34c5862d018b7d97525aa26c2e9fc35b90e) 3b3d9db6 增加workOrWorkCompleted转换docToWord --- .../ActionDocToWordWorkOrWorkCompleted.java | 233 ++++++++++++++++++ .../jaxrs/attachment/AttachmentAction.java | 147 ++++++----- .../core/entity/content/Attachment.java | 4 +- 3 files changed, 324 insertions(+), 60 deletions(-) create mode 100644 o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDocToWordWorkOrWorkCompleted.java diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDocToWordWorkOrWorkCompleted.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDocToWordWorkOrWorkCompleted.java new file mode 100644 index 0000000000..912aa17487 --- /dev/null +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDocToWordWorkOrWorkCompleted.java @@ -0,0 +1,233 @@ +package com.x.processplatform.assemble.surface.jaxrs.attachment; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.util.Date; +import java.util.List; + +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.entity.annotation.CheckPersistType; +import com.x.base.core.project.annotation.FieldDescribe; +import com.x.base.core.project.config.Config; +import com.x.base.core.project.config.ProcessPlatform; +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.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.tools.DefaultCharset; +import com.x.base.core.project.tools.DocumentTools; +import com.x.processplatform.assemble.surface.Business; +import com.x.processplatform.assemble.surface.ThisApplication; +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 org.apache.commons.lang3.StringUtils; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.tika.Tika; + +class ActionDocToWordWorkOrWorkCompleted extends BaseAction { + + ActionResult execute(EffectivePerson effectivePerson, String workOrWorkCompleted, JsonElement jsonElement) + throws Exception { + ActionResult result = new ActionResult<>(); + Wi wi = this.convertToWrapIn(jsonElement, Wi.class); + Work work = null; + WorkCompleted workCompleted = null; + Wo wo = new Wo(); + + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + Business business = new Business(emc); + work = emc.find(workOrWorkCompleted, Work.class); + if (null == work) { + workCompleted = emc.flag(workOrWorkCompleted, WorkCompleted.class); + } + if ((null == work) && (null == workCompleted)) { + throw new ExceptionEntityNotExist(workOrWorkCompleted, Work.class); + } + if (!business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted, + new ExceptionEntityNotExist(workOrWorkCompleted))) { + throw new ExceptionAccessDenied(effectivePerson); + } + } + if (null != work) { + wo = this.work(effectivePerson, wi, work); + } else { + wo = this.workCompleted(effectivePerson, wi, workCompleted); + } + + result.setData(wo); + return result; + + } + + private Wo work(EffectivePerson effectivePerson, Wi wi, Work work) throws Exception { + String person = effectivePerson.isCipher() ? work.getCreatorPerson() : effectivePerson.getDistinguishedName(); + byte[] bytes = null; + + if (StringUtils.equals(ProcessPlatform.DOCTOWORDTYPE_CLOUD, Config.processPlatform().getDocToWordType())) { + bytes = DocumentTools.docToWord(wi.getFileName(), wi.getContent()); + } else { + bytes = this.local(wi); + } + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + List attachments = emc.listEqual(Attachment.class, Attachment.job_FIELDNAME, work.getJob()); + Attachment attachment = null; + for (Attachment o : attachments) { + if (StringUtils.equalsIgnoreCase(wi.getSite(), o.getSite()) + && StringUtils.equalsIgnoreCase(o.getName(), wi.getFileName())) { + attachment = o; + break; + } + } + if (null != attachment) { + StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class, + attachment.getStorage()); + emc.beginTransaction(Attachment.class); + attachment.updateContent(mapping, bytes, wi.getFileName()); + attachment.setType((new Tika()).detect(bytes, wi.getFileName())); + attachment.setLastUpdatePerson(person); + attachment.setLastUpdateTime(new Date()); + emc.check(attachment, CheckPersistType.all); + emc.commit(); + } else { + StorageMapping mapping = ThisApplication.context().storageMappings().random(Attachment.class); + emc.beginTransaction(Attachment.class); + attachment = new Attachment(); + attachment.setCompleted(false); + attachment.setPerson(person); + attachment.setLastUpdatePerson(person); + attachment.setSite(wi.getSite()); + // 用于判断目录的值 + attachment.setWorkCreateTime(work.getCreateTime()); + attachment.setApplication(work.getApplication()); + attachment.setProcess(work.getProcess()); + attachment.setJob(work.getJob()); + attachment.setActivity(work.getActivity()); + attachment.setActivityName(work.getActivityName()); + attachment.setActivityToken(work.getActivityToken()); + attachment.setActivityType(work.getActivityType()); + attachment.saveContent(mapping, bytes, wi.getFileName()); + attachment.setType((new Tika()).detect(bytes, wi.getFileName())); + emc.persist(attachment, CheckPersistType.all); + emc.commit(); + } + Wo wo = new Wo(); + wo.setId(attachment.getId()); + return wo; + } + } + + private Wo workCompleted(EffectivePerson effectivePerson, Wi wi, WorkCompleted workCompleted) throws Exception { + String person = effectivePerson.isCipher() ? workCompleted.getCreatorPerson() + : effectivePerson.getDistinguishedName(); + byte[] bytes = null; + + if (StringUtils.equals(ProcessPlatform.DOCTOWORDTYPE_CLOUD, Config.processPlatform().getDocToWordType())) { + bytes = DocumentTools.docToWord(wi.getFileName(), wi.getContent()); + } else { + bytes = this.local(wi); + } + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + List attachments = emc.listEqual(Attachment.class, Attachment.job_FIELDNAME, + workCompleted.getJob()); + Attachment attachment = null; + for (Attachment o : attachments) { + if (StringUtils.equalsIgnoreCase(wi.getSite(), o.getSite()) + && StringUtils.equalsIgnoreCase(o.getName(), wi.getFileName())) { + attachment = o; + break; + } + } + if (null != attachment) { + StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class, + attachment.getStorage()); + emc.beginTransaction(Attachment.class); + attachment.updateContent(mapping, bytes, wi.getFileName()); + attachment.setType((new Tika()).detect(bytes, wi.getFileName())); + attachment.setLastUpdatePerson(person); + attachment.setLastUpdateTime(new Date()); + emc.check(attachment, CheckPersistType.all); + emc.commit(); + } else { + StorageMapping mapping = ThisApplication.context().storageMappings().random(Attachment.class); + emc.beginTransaction(Attachment.class); + attachment = new Attachment(); + attachment.setCompleted(false); + attachment.setPerson(person); + attachment.setLastUpdatePerson(person); + attachment.setSite(wi.getSite()); + // 用于判断目录的值 + attachment.setWorkCreateTime(workCompleted.getCreateTime()); + attachment.setApplication(workCompleted.getApplication()); + attachment.setProcess(workCompleted.getProcess()); + attachment.setJob(workCompleted.getJob()); + attachment.setActivity(workCompleted.getActivity()); + attachment.setActivityName(workCompleted.getActivityName()); + // attachment.setActivityToken(workCompleted.getActivityToken()); + // attachment.setActivityType(workCompleted.getActivityType()); + attachment.saveContent(mapping, bytes, wi.getFileName()); + attachment.setType((new Tika()).detect(bytes, wi.getFileName())); + emc.persist(attachment, CheckPersistType.all); + emc.commit(); + } + Wo wo = new Wo(); + wo.setId(attachment.getId()); + return wo; + } + } + + private byte[] local(Wi wi) throws Exception { + try (POIFSFileSystem fs = new POIFSFileSystem(); + InputStream is = new ByteArrayInputStream(wi.getContent().getBytes(DefaultCharset.name_iso_utf_8)); + ByteArrayOutputStream out = new ByteArrayOutputStream()) { + fs.createDocument(is, "WordDocument"); + fs.writeFilesystem(out); + return out.toByteArray(); + } + } + + public static class Wo extends WoId { + } + + public static class Wi extends GsonPropertyObject { + + @FieldDescribe("转换文件名.") + private String fileName; + @FieldDescribe("附件site.") + private String site; + @FieldDescribe("内容.") + private String content; + + public String getFileName() throws Exception { + return StringUtils.isEmpty(fileName) ? Config.processPlatform().getDocToWordDefaultFileName() : fileName; + } + + public void setSite(String site) { + this.site = site; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getSite() throws Exception { + return StringUtils.isEmpty(site) ? Config.processPlatform().getDocToWordDefaultSite() : site; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + } +} \ No newline at end of file diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java index e5f6149e9a..a183afe5dd 100644 --- a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java @@ -4,18 +4,20 @@ import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.container.AsyncResponse; import javax.ws.rs.container.Suspended; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; -import org.apache.commons.lang3.StringUtils; -import org.glassfish.jersey.media.multipart.FormDataBodyPart; -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; -import org.glassfish.jersey.media.multipart.FormDataParam; - import com.google.gson.JsonElement; import com.x.base.core.project.annotation.JaxrsDescribe; import com.x.base.core.project.annotation.JaxrsMethodDescribe; @@ -28,6 +30,12 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction; import com.x.base.core.project.logger.Logger; import com.x.base.core.project.logger.LoggerFactory; +import org.apache.commons.lang3.StringUtils; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.glassfish.jersey.media.multipart.FormDataParam; + @Path("attachment") @JaxrsDescribe("附件操作") public class AttachmentAction extends StandardJaxrsAction { @@ -308,7 +316,8 @@ public class AttachmentAction extends StandardJaxrsAction { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - result = new ActionDownloadWithWorkCompletedStream().execute(effectivePerson, id, workCompletedId, fileName); + result = new ActionDownloadWithWorkCompletedStream().execute(effectivePerson, id, workCompletedId, + fileName); } catch (Exception e) { logger.error(e, effectivePerson, request, null); result.error(e); @@ -327,7 +336,8 @@ public class AttachmentAction extends StandardJaxrsAction { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - result = new ActionDownloadWithWorkCompletedStream().execute(effectivePerson, id, workCompletedId, fileName); + result = new ActionDownloadWithWorkCompletedStream().execute(effectivePerson, id, workCompletedId, + fileName); } catch (Exception e) { logger.error(e, effectivePerson, request, null); result.error(e); @@ -340,24 +350,24 @@ public class AttachmentAction extends StandardJaxrsAction { @Path("upload/work/{workId}") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.MULTIPART_FORM_DATA) - public void upload(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, - @JaxrsParameterDescribe("位置") @FormDataParam("site") String site, - @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName, - @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam, - @FormDataParam(FILE_FIELD) byte[] bytes, - @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) { + public void upload(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, + @Context HttpServletRequest request, @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, + @JaxrsParameterDescribe("位置") @FormDataParam("site") String site, + @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName, + @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam, + @FormDataParam(FILE_FIELD) byte[] bytes, + @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - if(StringUtils.isEmpty(extraParam)){ + if (StringUtils.isEmpty(extraParam)) { extraParam = this.request2Json(request); } - if(bytes==null){ + if (bytes == null) { Map> map = form.getFields(); - for(String key: map.keySet()){ + for (String key : map.keySet()) { FormDataBodyPart part = map.get(key).get(0); - if("application".equals(part.getMediaType().getType())){ + if ("application".equals(part.getMediaType().getType())) { bytes = part.getValueAs(byte[].class); break; } @@ -388,14 +398,14 @@ public class AttachmentAction extends StandardJaxrsAction { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - if(StringUtils.isEmpty(extraParam)){ + if (StringUtils.isEmpty(extraParam)) { extraParam = this.request2Json(request); } - if(bytes==null){ + if (bytes == null) { Map> map = form.getFields(); - for(String key: map.keySet()){ + for (String key : map.keySet()) { FormDataBodyPart part = map.get(key).get(0); - if("application".equals(part.getMediaType().getType())){ + if ("application".equals(part.getMediaType().getType())) { bytes = part.getValueAs(byte[].class); break; } @@ -440,8 +450,8 @@ public class AttachmentAction extends StandardJaxrsAction { @Path("update/{id}/work/{workId}") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.MULTIPART_FORM_DATA) - public void update(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("附件标识") @PathParam("id") String id, + public void update(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, + @Context HttpServletRequest request, @JaxrsParameterDescribe("附件标识") @PathParam("id") String id, @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName, @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam, @@ -450,14 +460,14 @@ public class AttachmentAction extends StandardJaxrsAction { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - if(StringUtils.isEmpty(extraParam)){ + if (StringUtils.isEmpty(extraParam)) { extraParam = this.request2Json(request); } - if(bytes==null){ + if (bytes == null) { Map> map = form.getFields(); - for(String key: map.keySet()){ + for (String key : map.keySet()) { FormDataBodyPart part = map.get(key).get(0); - if("application".equals(part.getMediaType().getType())){ + if ("application".equals(part.getMediaType().getType())) { bytes = part.getValueAs(byte[].class); break; } @@ -477,8 +487,8 @@ public class AttachmentAction extends StandardJaxrsAction { @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void updateContent(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("附件标识") @PathParam("id") String id, - @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, JsonElement jsonElement) { + @JaxrsParameterDescribe("附件标识") @PathParam("id") String id, + @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, JsonElement jsonElement) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { @@ -520,8 +530,8 @@ public class AttachmentAction extends StandardJaxrsAction { @Path("update/{id}/work/{workId}") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.MULTIPART_FORM_DATA) - public void updatePost(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("附件标识") @PathParam("id") String id, + public void updatePost(FormDataMultiPart form, @Suspended final AsyncResponse asyncResponse, + @Context HttpServletRequest request, @JaxrsParameterDescribe("附件标识") @PathParam("id") String id, @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName, @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam, @@ -530,14 +540,14 @@ public class AttachmentAction extends StandardJaxrsAction { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - if(StringUtils.isEmpty(extraParam)){ + if (StringUtils.isEmpty(extraParam)) { extraParam = this.request2Json(request); } - if(bytes==null){ + if (bytes == null) { Map> map = form.getFields(); - for(String key: map.keySet()){ + for (String key : map.keySet()) { FormDataBodyPart part = map.get(key).get(0); - if("application".equals(part.getMediaType().getType())){ + if ("application".equals(part.getMediaType().getType())) { bytes = part.getValueAs(byte[].class); break; } @@ -684,6 +694,27 @@ public class AttachmentAction extends StandardJaxrsAction { asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); } + @JaxrsMethodDescribe(value = "将HTML版式公文转换成Word文件并添加在附件中,可以输入WorkId或者WorkCompletedId.", action = ActionDocToWordWorkOrWorkCompleted.class) + @POST + @Path("doc/to/word/workorworkcompleted/{workOrWorkCompleted}") + @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) + @Consumes(MediaType.APPLICATION_JSON) + public void docToWordWorkOrWorkCompleted(@Suspended final AsyncResponse asyncResponse, + @Context HttpServletRequest request, + @JaxrsParameterDescribe("工作已完成工作标识") @PathParam("workOrWorkCompleted") String workOrWorkCompleted, + JsonElement jsonElement) { + ActionResult result = new ActionResult<>(); + EffectivePerson effectivePerson = this.effectivePerson(request); + try { + result = new ActionDocToWordWorkOrWorkCompleted().execute(effectivePerson, workOrWorkCompleted, + jsonElement); + } catch (Exception e) { + logger.error(e, effectivePerson, request, jsonElement); + result.error(e); + } + asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); + } + @JaxrsMethodDescribe(value = "pdf格式预览文件,支持doc,docx.", action = ActionPreviewPdf.class) @GET @Path("{id}/preview/pdf") @@ -770,7 +801,8 @@ public class AttachmentAction extends StandardJaxrsAction { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - result = new ActionBatchDownloadWithWorkOrWorkCompletedStream().execute(effectivePerson, workId, site, fileName, flag); + result = new ActionBatchDownloadWithWorkOrWorkCompletedStream().execute(effectivePerson, workId, site, + fileName, flag); } catch (Exception e) { logger.error(e, effectivePerson, request, null); result.error(e); @@ -791,7 +823,8 @@ public class AttachmentAction extends StandardJaxrsAction { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { - result = new ActionBatchDownloadWithWorkOrWorkCompleted().execute(effectivePerson, workId, site, fileName, flag); + result = new ActionBatchDownloadWithWorkOrWorkCompleted().execute(effectivePerson, workId, site, fileName, + flag); } catch (Exception e) { logger.error(e, effectivePerson, request, null); result.error(e); @@ -805,9 +838,9 @@ public class AttachmentAction extends StandardJaxrsAction { @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void uploadWorkInfo(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("Work或WorkCompleted的工作标识") @PathParam("workId") String workId, - @JaxrsParameterDescribe("另存为格式:(0)表示不转换|pdf表示转为pdf|word表示转为word") @PathParam("flag") String flag, - JsonElement jsonElement) { + @JaxrsParameterDescribe("Work或WorkCompleted的工作标识") @PathParam("workId") String workId, + @JaxrsParameterDescribe("另存为格式:(0)表示不转换|pdf表示转为pdf|word表示转为word") @PathParam("flag") String flag, + JsonElement jsonElement) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { @@ -823,10 +856,9 @@ public class AttachmentAction extends StandardJaxrsAction { @GET @Path("download/work/{workId}/att/{flag}") @Consumes(MediaType.APPLICATION_JSON) - public void downloadWorkInfo(@Suspended final AsyncResponse asyncResponse, - @Context HttpServletRequest request, - @JaxrsParameterDescribe("*Work或WorkCompleted的工作标识") @PathParam("workId") String workId, - @JaxrsParameterDescribe("*通过uploadWorkInfo上传返回的附件id") @PathParam("flag") String flag){ + public void downloadWorkInfo(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, + @JaxrsParameterDescribe("*Work或WorkCompleted的工作标识") @PathParam("workId") String workId, + @JaxrsParameterDescribe("*通过uploadWorkInfo上传返回的附件id") @PathParam("flag") String flag) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { @@ -844,13 +876,13 @@ public class AttachmentAction extends StandardJaxrsAction { @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.MULTIPART_FORM_DATA) public void manageUpload(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, - @JaxrsParameterDescribe("位置") @FormDataParam("site") String site, - @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName, - @JaxrsParameterDescribe("上传到指定用户") @FormDataParam("person") String person, - @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam, - @FormDataParam(FILE_FIELD) final byte[] bytes, - @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) { + @JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId, + @JaxrsParameterDescribe("位置") @FormDataParam("site") String site, + @JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName, + @JaxrsParameterDescribe("上传到指定用户") @FormDataParam("person") String person, + @JaxrsParameterDescribe("天印扩展字段") @FormDataParam("extraParam") String extraParam, + @FormDataParam(FILE_FIELD) final byte[] bytes, + @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { @@ -869,7 +901,7 @@ public class AttachmentAction extends StandardJaxrsAction { @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void htmlToPdf(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - JsonElement jsonElement) { + JsonElement jsonElement) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { @@ -885,9 +917,8 @@ public class AttachmentAction extends StandardJaxrsAction { @GET @Path("download/transfer/flag/{flag}") @Consumes(MediaType.APPLICATION_JSON) - public void downloadTransfer(@Suspended final AsyncResponse asyncResponse, - @Context HttpServletRequest request, - @JaxrsParameterDescribe("*转换后附件id") @PathParam("flag") String flag){ + public void downloadTransfer(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, + @JaxrsParameterDescribe("*转换后附件id") @PathParam("flag") String flag) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { diff --git a/o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Attachment.java b/o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Attachment.java index ce0e39d276..30a8fc5a7d 100644 --- a/o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Attachment.java +++ b/o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Attachment.java @@ -278,14 +278,14 @@ public class Attachment extends StorageObject { @Enumerated(EnumType.STRING) @Column(length = ActivityType.length, name = ColumnNamePrefix + activityType_FIELDNAME) @Index(name = TABLE + IndexNameMiddle + activityType_FIELDNAME) - @CheckPersist(allowEmpty = false) + @CheckPersist(allowEmpty = true) private ActivityType activityType; public static final String activityToken_FIELDNAME = "activityToken"; @FieldDescribe("活动Token.") @Column(length = JpaObject.length_id, name = ColumnNamePrefix + activityToken_FIELDNAME) @Index(name = TABLE + IndexNameMiddle + activityToken_FIELDNAME) - @CheckPersist(allowEmpty = false) + @CheckPersist(allowEmpty = true) private String activityToken; public static final String completed_FIELDNAME = "completed"; -- GitLab