diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/ActionGetWithWorkOrWorkCompleted.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/ActionGetWithWorkOrWorkCompleted.java index 1786b395c09ca40248e04519ce22c1c3587386d5..28e882b94b1f1b4d53c44e530d3d01bcc4257ca5 100644 --- a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/ActionGetWithWorkOrWorkCompleted.java +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/ActionGetWithWorkOrWorkCompleted.java @@ -1,28 +1,28 @@ package com.x.processplatform.assemble.surface.jaxrs.form; -import com.x.base.core.project.logger.Audit; +import java.util.HashMap; +import java.util.Map; + import org.apache.commons.lang3.StringUtils; 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.JpaObject; -import com.x.base.core.project.bean.WrapCopier; -import com.x.base.core.project.bean.WrapCopierFactory; 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.logger.Audit; import com.x.base.core.project.logger.Logger; import com.x.base.core.project.logger.LoggerFactory; -import com.x.base.core.project.tools.ListTools; import com.x.base.core.project.tools.PropertyTools; import com.x.processplatform.assemble.surface.Business; import com.x.processplatform.core.entity.content.Work; import com.x.processplatform.core.entity.content.WorkCompleted; import com.x.processplatform.core.entity.element.Activity; import com.x.processplatform.core.entity.element.Form; +import com.x.processplatform.core.entity.element.Script; class ActionGetWithWorkOrWorkCompleted extends BaseAction { @@ -55,8 +55,8 @@ class ActionGetWithWorkOrWorkCompleted extends BaseAction { } } - private WoWorkForm work(Business business, Work work) throws Exception { - WoWorkForm wo = new WoWorkForm(); + private Wo work(Business business, Work work) throws Exception { + Wo wo = new Wo(); String id = work.getForm(); if (StringUtils.isEmpty(id)) { Activity activity = business.getActivity(work); @@ -65,50 +65,123 @@ class ActionGetWithWorkOrWorkCompleted extends BaseAction { if (StringUtils.isNotEmpty(id)) { Form form = business.form().pick(id); if (null != form) { - wo = WoWorkForm.copier.copy(form); - if (StringUtils.isEmpty(wo.getData()) && StringUtils.isNotEmpty(wo.getMobileData())) { - wo.setData(wo.getMobileData()); - } - /* 清空移动端表单,减少传输量 */ - wo.setMobileData(""); + wo.setForm(toWoForm(form)); + related(business, wo, form); } } return wo; } - private WoWorkCompletedForm workCompleted(Business business, WorkCompleted workCompleted) throws Exception { - WoWorkCompletedForm wo = new WoWorkCompletedForm(); - /* 先使用当前库的表单,如果不存在使用储存的表单. */ + private void related(Business business, Wo wo, Form form) throws Exception { + if (StringUtils.isNotBlank(form.getData())) { + for (String relatedFormId : form.getRelatedFormList()) { + Form relatedForm = business.form().pick(relatedFormId); + if (null != relatedForm) { + wo.getRelatedFormMap().put(relatedFormId, toWoForm(relatedForm)); + } + } + } else { + for (String relatedFormId : form.getMobileRelatedFormList()) { + Form relatedForm = business.form().pick(relatedFormId); + if (null != relatedForm) { + wo.getRelatedFormMap().put(relatedFormId, toWoMobileForm(relatedForm)); + } + } + } + for (String relatedScriptId : form.getRelatedScriptList()) { + Script relatedScript = business.script().pick(relatedScriptId); + if (null != relatedScript) { + wo.getRelatedScriptMap().put(relatedScriptId, toWoScript(relatedScript)); + } + } + } + + private Wo workCompleted(Business business, WorkCompleted workCompleted) throws Exception { + Wo wo = new Wo(); + // 先使用当前库的表单,如果不存在使用储存的表单. if (StringUtils.isNotEmpty(workCompleted.getForm())) { Form form = business.form().pick(workCompleted.getForm()); if (null != form) { - if (StringUtils.isNotEmpty(form.getData())) { - wo.setData(form.getData()); - } else if (StringUtils.isNotEmpty(form.getMobileData())) { - wo.setData(workCompleted.getFormMobileData()); + wo.setForm(toWoForm(form)); + related(business, wo, form); + } + } else { + if (null != workCompleted.getProperties().getForm()) { + wo.form = toWoForm(workCompleted.getProperties().getForm()); + } + if (StringUtils.isNotBlank(workCompleted.getProperties().getForm().getData())) { + for (Form f : workCompleted.getProperties().getRelatedFormList()) { + wo.getRelatedFormMap().put(f.getId(), toWoForm(f)); + } + } else { + for (Form f : workCompleted.getProperties().getRelatedFormList()) { + wo.getRelatedFormMap().put(f.getId(), toWoMobileForm(f)); } } - } else if (StringUtils.isNotEmpty(workCompleted.getFormData())) { - wo.setData(workCompleted.getFormData()); - } else if (StringUtils.isNotEmpty(workCompleted.getFormMobileData())) { - wo.setData(workCompleted.getFormMobileData()); + for (Script s : workCompleted.getProperties().getRelatedScriptList()) { + wo.getRelatedScriptMap().put(s.getId(), toWoScript(s)); + } } return wo; } - public static class WoWorkForm extends Form { - - private static final long serialVersionUID = 1303951663975390089L; - - static WrapCopier