diff --git a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar index 2dac1fb5..5d92abbf 100644 Binary files a/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar and b/com.actionsoft.apps.coe.pal.publisher/lib/com.actionsoft.apps.coe.pal.publisher.jar differ diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/BoCopyUtil.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/BoCopyUtil.java index ed2a575f..3329dd46 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/BoCopyUtil.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/BoCopyUtil.java @@ -6,7 +6,10 @@ import com.actionsoft.bpms.bo.design.model.BOModel; import com.actionsoft.bpms.bo.engine.BO; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; + +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @Author: yujh @@ -28,7 +31,12 @@ public class BoCopyUtil { String itemName = item.getName(); Object fromItem = fromBo.get(itemName); if(null != fromItem) { - toBo.set(itemName, fromItem); + String bodata=toBo.getString(itemName); + if(!fromItem.equals(bodata)){ + if(!itemName.equals("PUBLISHBINDID")){ + toBo.set(itemName, fromItem); + } + } } } } @@ -39,16 +47,26 @@ public class BoCopyUtil { * @param toBo 目标BO * @param fromBoName 源BO表名称 */ - public static void copy(JSONObject fromJson, BO toBo, String fromBoName) { + public static boolean copy(JSONObject fromJson, BO toBo, String fromBoName) { + boolean flag=true; BOModel boModel = BOCache.getInstance().getModelByEntityName(fromBoName); List items = boModel.getBoItems(); for(BOItemModel item : items) { String itemName = item.getName(); Object fromItem = fromJson.get(itemName); if(null != fromItem) { - toBo.set(itemName, fromItem); + String bodata=toBo.getString(itemName); + if(!fromItem.equals(bodata)){ + if(!itemName.equals("PUBLISHBINDID")){ + System.out.println("发布表的值========"+bodata); + System.out.println("itemName========"+itemName); + System.out.println("修改表的值======"+fromItem); + flag=false; + } + } } } + return flag; } /** diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java index 69927eea..b00a01fd 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java @@ -5371,12 +5371,15 @@ public class ProcessPublishWeb extends ActionWeb { ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_e2c34a123cbb413cae82b0ce1e637088", me.getUID(), "发起的发布流程数据修改流程"); SDK.getProcessAPI().start(processInstance); + + BO publishBo=SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).detail(); // 首先查询源表的数据,查询条件请自行定义 BOQueryAPI query = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId); // 指定将要复制到新的bo表以及流程实例ID BOCopyAPI copyAPI = query.copyTo("BO_ACT_PUBLISH_DATA", processInstance.getId()); copyAPI.addNewData("PUBLISHBINDID", processInstId); + copyAPI.addNewData("SOURCEDATA", JSON.toJSONString(publishBo.asMap())); // 执行复制操作 copyAPI.exec(); diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/FormUpdateAfterSaveEvent.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/FormUpdateAfterSaveEvent.java new file mode 100644 index 00000000..f0ec7912 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/FormUpdateAfterSaveEvent.java @@ -0,0 +1,36 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import com.actionsoft.apps.coe.pal.publisher.client.util.BoCopyUtil; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener; +import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface; +import com.actionsoft.exception.BPMNError; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +public class FormUpdateAfterSaveEvent extends ExecuteListener implements ExecuteListenerInterface { + + + @Override + public void execute(ProcessExecutionContext pro) throws Exception { + String bindid=pro.getProcessInstance().getId(); + + BO publishData=pro.getBO("BO_ACT_PUBLISH_DATA"); + + BO publishBo= SDK.getBOAPI().query("BO_ACT_COE_PUBLISH",true).addQuery("BINDID=",publishData.getString("PUBLISHBINDID")).detail(); + + BO publish_data=SDK.getBOAPI().query("BO_ACT_PUBLISH_DATA",true).addQuery("BINDID=",bindid).detail(); + + JSONObject publishJson =JSONObject.parseObject(JSON.toJSONString(publishBo.asMap())); + JSONObject sourceJson=JSONObject.parseObject(publish_data.getString("SOURCEDATA")); + + boolean updateFlag= BoCopyUtil.copy(sourceJson,publishBo,"BO_ACT_COE_PUBLISH"); + + if(!updateFlag){ + throw new BPMNError("0313","系统检测用户对于该单据已修改,需要重新发起修改流程"); + } + + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishUpdateDataProcessAfterCompleteEvent.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishUpdateDataProcessAfterCompleteEvent.java index 1644f986..ef0e94b3 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishUpdateDataProcessAfterCompleteEvent.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishUpdateDataProcessAfterCompleteEvent.java @@ -9,6 +9,14 @@ import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.api.BOCopyAPI; import com.actionsoft.sdk.local.api.BOQueryAPI; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; public class PublishUpdateDataProcessAfterCompleteEvent extends ExecuteListener implements ExecuteListenerInterface { @@ -27,10 +35,24 @@ public class PublishUpdateDataProcessAfterCompleteEvent extends ExecuteListener BO publishBo=SDK.getBOAPI().query("BO_ACT_COE_PUBLISH",true).addQuery("BINDID=",publishData.getString("PUBLISHBINDID")).detail(); + if(publishBo==null){ + throw new Exception("未查到发布流程数据,请检查!"); + } BO publish_data=SDK.getBOAPI().query("BO_ACT_PUBLISH_DATA",true).addQuery("BINDID=",bindid).detail(); + if(publish_data==null){ + throw new Exception("未查到发布修改数据流程数据,请检查!"); + } + JSONObject publishJson =JSONObject.parseObject(JSON.toJSONString(publishBo.asMap())); + JSONObject sourceJson=JSONObject.parseObject(publish_data.getString("SOURCEDATA")); + + BoCopyUtil.copy(publish_data,publishBo,"BO_ACT_PUBLISH_DATA"); - SDK.getBOAPI().update("BO_ACT_COE_PUBLISH",publishBo); + int count=SDK.getBOAPI().update("BO_ACT_COE_PUBLISH",publishBo); } + + + + }