前后置流程功能开发

This commit is contained in:
446052889@qq.com 2022-10-24 17:40:36 +08:00
parent 4e0971d550
commit bee7166d5b
11 changed files with 951 additions and 13 deletions

View File

@ -3495,4 +3495,42 @@ public class CoEPALController {
return web.refreshDesignerNo(uuid);
}
/**
* 前后置流程界面操作查询关联的模型的信息
* @param uc
* @param oldFileIds
* @param newFileIds
* @return
*/
@Mapping("com.actionsoft.apps.coe.pal_pl_repository_designer_relation_info_query")
public String queryRelationInfo(UserContext uc, String oldFileIds, String newFileIds) {
CoeProcessLevelWeb web = new CoeProcessLevelWeb(uc);
return web.queryRelationInfo(oldFileIds, newFileIds);
}
@Mapping("com.actionsoft.apps.coe.pal_pl_repository_designer_shape_relation_rear_lead_save")
public String saveRearLeadProcessRelationData(UserContext uc, String uuid, String relationFileId, String relationShapeText, String type) {
DesignerRelationShapeWeb web = new DesignerRelationShapeWeb(uc);
return web.saveRearLeadProcessRelationData(uuid, relationFileId, relationShapeText, type);
}
/**
* 校验是否有前后置流程属性
* @param me
* @param removeProcedureShapes
* @param fileId
* @return
*/
@Mapping("com.actionsoft.apps.coe.pal_pl_repository_designer_lead_rear_relation_search")
public String searchLeadRearRelationData(UserContext me, String removeProcedureShapes, String fileId) {
DesignerRelationShapeWeb web = new DesignerRelationShapeWeb(me);
return web.searchLeadRearRelationData(fileId, removeProcedureShapes);
}
@Mapping("com.actionsoft.apps.coe.pal_repository_designer_lead_rear_relation_delete")
public String deleteLeadRearRelationData(UserContext me, String uuid, String data) {
DesignerRelationShapeWeb web = new DesignerRelationShapeWeb(me);
return web.deleteLeadRearRelationData(uuid, data);
}
}

View File

@ -123,6 +123,17 @@ public class CoeDesignerDefaultDao {
return null;
}
model.setDefinition(define);
try {
JSONObject definition = JSONObject.parseObject(define);
} catch (Exception e) {
e.printStackTrace();
System.out.println("-----------错误信息输出Start-----------");
SDK.getLogAPI().consoleErr(define);
System.out.println("-----------错误信息输出End-----------");
}
model.setUpdateTime(CoeDesignerUtil.getUpdateTime(model.getDefinition()));
if (draw != null && !"".equals(draw)) {
model.setDraw(draw);

View File

@ -1230,6 +1230,8 @@ public class DesignerRelationShapeWeb extends ActionWeb {
CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean();
bean.setName(palModel.getName());
bean.setType(palModel.getMethodId());
bean.setExt1(palModel.getId());
bean.setExt2(palModel.getVersionId());
StringBuilder sBuilder = new StringBuilder();// 名称组合
StringBuilder idBuilder = new StringBuilder();// Id组合
Set<String> idSets = new HashSet<>();// id记录校验防止递归死循环
@ -3810,5 +3812,163 @@ public class DesignerRelationShapeWeb extends ActionWeb {
ro.put("shapeRefObj", refMap);
return ro.toString();
}
public String saveRearLeadProcessRelationData(String uuid, String relationFileId, String relationShapeText, String type) {
String attrId = null;
if ("lead".equals(type)) {// 前置流程
attrId = "lead_process";
} else if ("rear".equals(type)) {// 后置流程
attrId = "rear_process";
} else {
return ResponseObject.newErrResponse("保存错误").toString();
}
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getByFileId(uuid, attrId);
boolean exist = false;
for (DesignerShapeRelationModel model : list) {
if (UtilString.isEmpty(model.getShapeId())) {
if (relationFileId.equals(model.getRelationFileId())) {
exist = true;
}
}
}
if (!exist) {
DesignerShapeRelationModel model = new DesignerShapeRelationModel();
model.setId(UUIDGener.getUUID());
model.setFileId(uuid);
model.setShapeId("");
model.setAttrId(attrId);
model.setRelationFileId(relationFileId);
model.setRelationShapeId("");
model.setRelationShapeText(relationShapeText);
new DesignerShapeRelationDao().insert(model);
}
return ResponseObject.newOkResponse().toString();
}
public String searchLeadRearRelationData(String fileId, String removeProcedureShapes) {
JSONArray result = new JSONArray();
JSONArray removeShapeArr = JSONArray.parseArray(removeProcedureShapes);
if (removeShapeArr.size() > 0) {
// 获取前置和后置数据
String attrId = "lead_process";// 前置流程
Map<String, String> leadMap = new HashMap<>();
Map<String, String> leadRelationIdMap = new HashMap<>();
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getByFileId(fileId, attrId);
for (DesignerShapeRelationModel model : list) {
if (UtilString.isEmpty(model.getShapeId())) {
String versionId = model.getRelationFileId();
List<PALRepositoryModel> tmpList = PALRepositoryCache.getByVersionId(versionId);
if (tmpList != null) {
for (PALRepositoryModel plModel : tmpList) {
if (plModel.isUse()) {
leadMap.put(model.getId(), plModel.getName());
leadRelationIdMap.put(plModel.getVersionId(), model.getId());
}
}
}
}
}
attrId = "rear_process";// 后置流程
Map<String, String> rearMap = new HashMap<>();
Map<String, String> rearRelationIdMap = new HashMap<>();
List<DesignerShapeRelationModel> list2 = DesignerShapeRelationCache.getByFileId(fileId, attrId);
for (DesignerShapeRelationModel model : list2) {
if (UtilString.isEmpty(model.getShapeId())) {
String versionId = model.getRelationFileId();
List<PALRepositoryModel> tmpList = PALRepositoryCache.getByVersionId(versionId);
if (tmpList != null) {
for (PALRepositoryModel plModel : tmpList) {
if (plModel.isUse()) {
rearMap.put(model.getId(), plModel.getName());
rearRelationIdMap.put(plModel.getVersionId(), model.getId());
}
}
}
}
}
for (int i = 0; i < removeShapeArr.size(); i++) {
JSONObject removeShape = removeShapeArr.getJSONObject(i);
String shapeId = removeShape.getString("id");
String shapeText = removeShape.getString("text");
JSONArray fromLinkerArr = removeShape.getJSONArray("fromLinkerArr");
JSONArray toLinkerArr = removeShape.getJSONArray("toLinkerArr");
JSONObject attrMark = removeShape.getJSONObject("attrMark");
boolean leadExist = false;
String leadRelationId = "";
boolean rearExist = false;
String rearRelationId = "";
if (attrMark == null) {// 根据出入线匹配
// 前置查询
if (fromLinkerArr.size() > 0 && toLinkerArr.size() == 0 && leadMap.containsValue(shapeText)) {// 多出线零入线且名称存在匹配
for (Map.Entry<String, String> entry : leadMap.entrySet()) {
if (entry.getValue().equals(shapeText)) {
leadExist = true;
leadRelationId = entry.getKey();
}
}
}
// 后置查询
if (toLinkerArr.size() > 0 && fromLinkerArr.size() == 0 && rearMap.containsValue(shapeText)) {// 多入线零出线且名称匹配
for (Map.Entry<String, String> entry : rearMap.entrySet()) {
if (entry.getValue().equals(shapeText)) {
rearExist = true;
rearRelationId = entry.getKey();
}
}
}
} else {
String versionId = attrMark.getString("versionId");
if (leadRelationIdMap.containsKey(versionId)) {
leadExist = true;
leadRelationId = leadRelationIdMap.get(versionId);
}
if (rearRelationIdMap.containsKey(versionId)) {
rearExist = true;
rearRelationId = rearRelationIdMap.get(versionId);
}
}
JSONObject obj = new JSONObject();
obj.put("shapeId", shapeId);
obj.put("shapeText", shapeText);
obj.put("leadExist", leadExist);
obj.put("leadRelationId", leadRelationId);
obj.put("rearExist", rearExist);
obj.put("rearRelationId", rearRelationId);
result.add(obj);
}
}
ResponseObject ro = ResponseObject.newOkResponse();
ro.setData(result);
return ro.toString();
}
public String deleteLeadRearRelationData(String uuid, String data) {
ResponseObject ro = ResponseObject.newOkResponse();
JSONArray dataArr = JSON.parseArray(data);
DesignerShapeRelationDao dao = new DesignerShapeRelationDao();
for (int i = 0; i < dataArr.size(); i++) {
JSONObject obj = dataArr.getJSONObject(i);
String shapeText = obj.getString("shapeText");
boolean leadExist = obj.getBooleanValue("leadExist");
if (leadExist) {
int r = dao.deleteById(obj.getString("leadRelationId"));
if (r > 0) {
SDK.getLogAPI().consoleInfo("[成功]PAL通过设计器删除形状的方式删除前置流程[" + shapeText + "]");
}
}
boolean rearExist = obj.getBooleanValue("rearExist");
if (rearExist) {
int r = dao.deleteById(obj.getString("rearRelationId"));
if (r > 0) {
SDK.getLogAPI().consoleInfo("[成功]PAL通过设计器删除形状的方式删除后置流程[" + shapeText + "]");
}
}
}
return ro.toString();
}
}

View File

@ -9,6 +9,10 @@ public class CoeProcessLevelAutoBean {
private String value;
private String name;
private String type; //add by zhangming 2014-3-17
private String ext1;
private String ext2;
private String ext3;
private String ext4;
public String getUi() {
return ui;
}
@ -33,5 +37,36 @@ public class CoeProcessLevelAutoBean {
public void setType(String type) {
this.type = type;
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2;
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3;
}
public String getExt4() {
return ext4;
}
public void setExt4(String ext4) {
this.ext4 = ext4;
}
}

View File

@ -12249,4 +12249,81 @@ public String deleteReply(String replyid, String messageid) {
ro.put("historyCondition",historyCondition);
return ro.toString();
}
public String queryRelationInfo(String oldFileIds, String newFileIds) {
JSONArray oldIds = JSONArray.parseArray(oldFileIds);
JSONArray newIds = JSONArray.parseArray(newFileIds);
JSONObject result = new JSONObject();
JSONObject oldObj = new JSONObject();
for (int i = 0; i < oldIds.size(); i++) {
String id = oldIds.getString(i);
String versionId = "";
String name = "";
if (UtilString.isNotEmpty(id)) {
PALRepositoryModel validModel = null;
PALRepositoryModel model = PALRepositoryCache.getCache().get(id);
if (model == null) {
List<PALRepositoryModel> models = PALRepositoryCache.getByVersionId(id);
if (models != null && models.size() > 0) {
for (PALRepositoryModel tmpModel : models) {
if (tmpModel.isUse()) {
validModel = tmpModel;
}
}
}
} else {
validModel = model;
}
if (validModel != null) {
versionId = validModel.getVersionId();
name = validModel.getName();
id = validModel.getId();
}
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("name", name);
tmp.put("versionId", versionId);
oldObj.put(id, tmp);
}
}
result.put("old", oldObj);
JSONObject newObj = new JSONObject();
for (int i = 0; i < newIds.size(); i++) {
String id = newIds.getString(i);
String versionId = "";
String name = "";
if (UtilString.isNotEmpty(id)) {
PALRepositoryModel validModel = null;
PALRepositoryModel model = PALRepositoryCache.getCache().get(id);
if (model == null) {
List<PALRepositoryModel> models = PALRepositoryCache.getByVersionId(id);
if (models != null && models.size() > 0) {
for (PALRepositoryModel tmpModel : models) {
if (tmpModel.isUse()) {
validModel = tmpModel;
}
}
}
} else {
validModel = model;
}
if (validModel != null) {
versionId = validModel.getVersionId();
name = validModel.getName();
id = validModel.getId();
}
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("name", name);
tmp.put("versionId", versionId);
newObj.put(id, tmp);
}
}
result.put("new", newObj);
ResponseObject ro = ResponseObject.newOkResponse();
ro.setData(result);
return ro.toString();
}
}

View File

@ -239,6 +239,8 @@
var installBatch = <#installBatch>;
var attrDefineObj = <#attrDefineObj>;
var pid = "<#parentChartId>";
</script>
<!--工具js-->
<script type='text/javascript' charset='UTF-8' src='../apps/com.actionsoft.apps.coe.pal/lib/designer/extend/js/util/map.js'></script>
@ -884,6 +886,14 @@
<li ac="duplicate">复用
<div class="extend">Ctrl+D</div>
</li>
<li ac="addLeadProcess">
添加到前置流程
<div class="extend"></div>
</li>
<li ac="addRearProcess">
添加到后置流程
<div class="extend"></div>
</li>
<li class="devider devi_clip"></li>
<li ac="front">
<div class="ico ico_front"></div>置于顶层
@ -1310,7 +1320,8 @@
</div>
<ul id="attr_no_more_attribute_id">
<li class="attr_no_more_attribute">
<iframe id="file_attribute" frameborder="0" width="100%" style="width:100%;height:380px" src="./w?sid=<#sid>&cmd=com.actionsoft.apps.coe.pal_processlevel_create&wsid=<#wsId>&pid=<#parentChartId>&id=<#uuid>&editable=<#editable>"></iframe>
<!-- <iframe id="file_attribute" frameborder="0" width="100%" style="width:100%;height:380px" src="./w?sid=<#sid>&cmd=com.actionsoft.apps.coe.pal_processlevel_create&wsid=<#wsId>&pid=<#parentChartId>&id=<#uuid>&editable=<#editable>"></iframe>-->
<iframe id="file_attribute" frameborder="0" width="100%" style="width:100%;height:380px" src=""></iframe>
</li>
</ul>
</div>
@ -2905,7 +2916,29 @@
</font>,点击此处<a style="text-decoration: none;" href="#" onclick="BPMNBiz.getCheckoutRight();return false;">强行获取编辑权</a>
</div>
</div>
<div title="添加到前后置流程" class="awsui-size-x-large awsui-hide" id="addLeadAndRearProcessDlg">
<div style="height: 30px;">
<span class="awsui-input-wrapper">
<input type="text" id="leadAndRearProcessSearchKey" class="awsui-input" placeholder="输入名称查询" value=""/>
<span class="awsui-input-suffix" style="cursor: pointer;" onclick="queryLeadAndRearProcessData">
<i class="awsui-iconfont">&#59113;</i>
</span>
</span>
<input type="hidden" id="attrMark"/>
</div>
<div style="height:290px;overflow-y: auto;">
<!-- <div class="awsui-code-demo awsui-align-center" style="display: none;position: relative; top: 100px;" id="leadAndRearProcessDataLoading"></div>-->
<table id="leadAndRearProcessDataTable" class="awsui-table awsui-table-striped">
<thead>
<tr>
<th width="20">选择</th>
<th>名称</th>
</tr>
</thead>
<tbody id="leadAndRearProcessDataTableTbody"></tbody>
</table>
</div>
</div>
<!-- 不支持HTML5的页面显示图片 -->
<div id="mainDiv" style="display: none;">
<div class="view_box">

View File

@ -1779,4 +1779,22 @@
<param name="repositoryIds"/>
<param name="targetMethod"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal_pl_repository_designer_relation_info_query">
<param name="oldFileIds"/>
<param name="newFileIds"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal_pl_repository_designer_shape_relation_rear_lead_save">
<param name="uuid"/>
<param name="relationFileId"/>
<param name="relationShapeText"/>
<param name="type"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal_pl_repository_designer_lead_rear_relation_search">
<param name="removeProcedureShapes"/>
<param name="fileId"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal_repository_designer_lead_rear_relation_delete">
<param name="uuid"/>
<param name="data"/>
</cmd-bean>
</aws-actions>

View File

@ -1330,7 +1330,13 @@ function openRelationDialog(obj, callback) {
buttons: [
{text:'确定',cls:"blue",handler:function(){
var attrId = obj.attr("id");
// epc流程的文件属性前后置流程特殊处理
var oldFileIds = obj.attr('relationFileId');
var oldFileNames = obj.attr("value");
var newFileIds = [];
var newFileNames = [];
var attrId = obj.attr("id");
var relationFileId = "";
var relationShapeId = "";
var relationShapeText = "";
@ -1355,6 +1361,8 @@ function openRelationDialog(obj, callback) {
relationShapeId += relationShape.relationShapeId + ",";
relationShapeText += relationShape.relationShapeText + ",";
}
newFileIds.push(relationShape.relationFileId);
newFileNames.push(relationShape.relationShapeText);
}
}
obj.attr("attrId", attrId);
@ -1364,6 +1372,10 @@ function openRelationDialog(obj, callback) {
if (callback && callback == "saveContent") {
saveContent(obj);
}
// 针对EPC流程的前后置流程属性同步更新画布形状处理
if (attrId == 'lead_process' || attrId == 'rear_process') {
handleLeadAndRearProcessArrShape(attrId, oldFileIds, oldFileNames, newFileIds, newFileNames);
}
parent.FrmDialog.close("relationDialog");
}},
{text:'取消',handler:function(){
@ -1375,6 +1387,18 @@ function openRelationDialog(obj, callback) {
}
/**
* 处理前后置流程的形状
* @param attrId
* @param oldFileIds
* @param newFileIds
* @param newFileNames
*/
function handleLeadAndRearProcessArrShape(attrId, oldFileIds, oldFileNames, newFileIds, newFileNames) {
// 需要调用画布方法进行形状处理
parent.handleLeadAndRearProcessShapeDesigner(attrId, oldFileIds, oldFileNames, newFileIds, newFileNames);
}
function selectAttrTabTag(showContent, selfObj) {
// 操作标签
var tag = $("#tabUlContainer li");

View File

@ -85,7 +85,11 @@ Designer.contextMenu.show = function(x, y) {
menu.children("li[ac=customdefine]").show();
}
}
// 一键关联前后置流程
if (methodId == 'process.epc' && shape.name == 'procedure') {
menu.children('li[ac=addLeadProcess]').show();
menu.children('li[ac=addRearProcess]').show();
}
}
if (Designer.status == "running") {
menu.children("li[ac=cut]").hide();
@ -171,6 +175,10 @@ Designer.contextMenu.execAction = function(item) {
Designer.selectVertical();
} else if (action == 'selectHorizontal') {
Designer.selectHorizontal();
} else if (action == 'addLeadProcess') {// 关联至前置流程
showLeadAndRearProcessDlg('lead');
} else if (action == 'addRearProcess') {// 关联至后置流程
showLeadAndRearProcessDlg('rear');
}
};
@ -2244,6 +2252,94 @@ Designer.op.removeShape = function() {
shapeIds.push(d[index].id)
}
}
// 伊利前后置流程校验 by sunlh 20221024
if (shapeIds.length > 0) {
var removeProcedureShapes = [];
var interfaceObj = getInterfaceShape();
for (var i = 0; i < shapeIds.length; i++) {
var shapeId = shapeIds[i];
if (interfaceObj[shapeId]) {
removeProcedureShapes.push(interfaceObj[shapeId]);
}
}
$.ajax({
url: "./jd?sid=" + $("#sid").val() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_lead_rear_relation_search",
async: false,
data: {
removeProcedureShapes: JSON.stringify(removeProcedureShapes),
fileId: ruuid
},
success: function(r) {
var data = r.data;
var msg = '';
for (var i = 0; i < data.length; i++) {
var obj = data[i];
var shapeText = obj.shapeText;
var leadExist = obj.leadExist;
var rearExist = obj.rearExist;
var msg1 = '';
if (leadExist && rearExist) {
msg1 = '存在关联的前置和后置流程';
} else if (leadExist) {
msg1 = '存在关联的前置流程';
} else if (rearExist) {
msg1 = '存在关联的后置流程';
}
msg += (leadExist || rearExist) ? ('流程接口[' + shapeText + ']' + msg1 + '<br/>') : '';
}
if (msg != '') {
msg += '<br/>确定删除关联的文件属性中相应的前后置流程吗?<br/><span style=\'color: red;\'>注:关联关系删除不可撤销,请谨慎操作</span>';
var options = {
title: "提示",
content: msg,
onConfirm: function() {
$.ajax({
type: "POST",
url: "./jd",
async: false,
data: {
sid: CLB.sid,
cmd: "com.actionsoft.apps.coe.pal_repository_designer_lead_rear_relation_delete",
uuid: ruuid,
data: JSON.stringify(data)
}
});
Model.remove(d);
},
onCancel : function(){
Model.remove(d);
}
};
$.confirm(options)
}
}
})
} else {
//拼接日志内容
var delnode = "";
for (var index = 0; index < d.length; index++) {
var delnodeid = d[index].id;
var delnodetext = d[index].text;
delnode = delnode + delnodetext + "[" + delnodeid + "]; ";
}
//发送删除日志
awsui.ajax.request({
type: "POST",
url: "./jd",
data: {
sid: CLB.sid,
cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_shape_log_record_noop_delete",
uuid: ruuid,
delnode: delnode,
delnum: d.length
}
});
Model.remove(d);
}
if (shapeIds.length > 0 && isAutoSave != "0") {
$.ajax({
url: "./jd?sid=" + $("#sid").val() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_search",

View File

@ -2790,14 +2790,18 @@ function setDivHeight() {/*
function changeArributeByShape() {
if (Utils.getSelected()[0] == null) {
$("#dock_content_attribute").hide();
// 重新请求
$('#file_attribute').attr('src', './w?sid='+ sid +'&cmd=com.actionsoft.apps.coe.pal_processlevel_create&wsid='+ $('#wsId').val() +'&pid='+ pid +'&id='+ ruuid +'&editable='+ editable + '&number=' + Math.random());
$("#attr_no_more_attribute_id").show();
var iframeDocument=$("#file_attribute")[0].contentWindow.document;
var body = $(iframeDocument).find('body')
var pickerNum = $(body).find('input[name="dateTimePicker"]').length
if (pickerNum > 0) {
var height = $(body).find('#frmMain').height() + 300
$("#file_attribute").height(height)
}
setTimeout(function() {
var iframeDocument=$("#file_attribute")[0].contentWindow.document;
var body = $(iframeDocument).find('body')
var pickerNum = $(body).find('input[name="dateTimePicker"]').length
if (pickerNum > 0) {
var height = $(body).find('#frmMain').height() + 300
$("#file_attribute").height(height)
}
}, 500);
} else {
// 属性弹出层显示的内容
var shape = Utils.getSelected()[0];
@ -4534,4 +4538,446 @@ function addPolicyFile() {
}
}
});
}
/************************处理前后置流程***************************/
/**
* 处理前后置流程
* @param attrId 属性key 上游流程lead_process下游流程rear_process
* @param oldFileIds 原有的属性ID
* @param newFileIds 更新后的属性ID
* @param newFileNames 更新后的属性名称
*/
function handleLeadAndRearProcessShapeDesigner(attrId, oldFileIds, oldFileNames, newFileIds, newFileNames) {
// EPC限定处理
if (!methodId == 'process.epc') {
return;
}
// 前后置流程限定
if (attrId != 'lead_process' && attrId != 'rear_process') {
return;
}
var position = 'top';// 前置
if (attrId == 'rear_process') {
position = 'bottom';// 后置
}
/*
1.获取所有流程接口形状
2.获取新增修改删除的流程接口
3.根据新增修改删除的进行画布形状匹配
新增根据出入线形状类型名称组合进行匹配若匹配成功则不用新增
修改根据唯一关联标识或出入线形状类型名称组合进行匹配
删除根据唯一关联标识或出入线形状类型名称组合进行匹配
4.匹配结果处理
新增若匹配成功建立唯一关联标识更新匹配的形状名称不进行形状和画布调整若无匹配成功新增对应的形状修改名称移动画布若需要给到合适位置
修改建立唯一关联标识修改名称
删除删除匹配形状及对应的所有出入线
*/
// 获取所有流程接口形状
var interfaceObj = getInterfaceShape();
// 将结果按照新增的、修改的、删除的进行分类
// console.log(interfaceObj);
var updateInterface = {};
var addInterface = {};
var delInterface = {};
// console.log(addInterface);
// console.log(updateInterface);
// console.log(delInterface);
handleRelationData(addInterface, updateInterface, delInterface, oldFileIds, oldFileNames, newFileIds, newFileNames);
// 根据匹配规则进行匹配
// 匹配修改的
var updateShapes = getUpdateShapes(interfaceObj, updateInterface, position, addInterface);
// 匹配需要删除的
var delShapes = getRemoveShapes(interfaceObj, delInterface, position);
// 执行修改
if (updateShapes.length > 0) {
Model.updateMulti(updateShapes);
}
// 执行删除
if (delShapes.length > 0) {
Model.remove(delShapes);
}
// 创建新增形状
var addShapes = getAddShapes(addInterface);
if (addShapes.length > 0) {
// 移动画布所有内容(若需要)(泳池泳道不处理,只处理形状)
if (position == 'top') {
moveDownAllShape();
}
// 将新增形状放入合适位置
moveAddShapeToElements(addShapes, position);
// 执行画布自适应刷新
$('#bar_resize').click();
}
}
// 将新加的形状放入到合适位置
function moveAddShapeToElements(addShapes, position) {
if (position == 'top') {// 顶端
for (var i = 0; i < addShapes.length; i++) {
addShapes[i].props.y = 100;
Designer.painter.renderShape(addShapes[i]);
}
Model.addMulti(addShapes);
} else {
// 底端
var maxY = -99999;
var elements = Model.define.elements;
for (var shapeId in elements) {
var shape = elements[shapeId];
if (shape.category != 'lane' && shape.name != 'linker') {
maxY = (shape.props.y + shape.props.h) < maxY ? maxY : (shape.props.y + shape.props.h);
}
}
if (maxY == -99999) {
maxY = 100;
} else {
maxY = maxY + 40;
}
for (var i = 0; i < addShapes.length; i++) {
addShapes[i].props.y = maxY;
Designer.painter.renderShape(addShapes[i]);
}
Model.addMulti(addShapes);
}
}
// 所有形状向下偏移
function moveDownAllShape() {
// 获取最上方的形状y
var minY = 99999;
var elements = Model.define.elements;
for (var shapeId in elements) {
var shape = elements[shapeId];
if (shape.category != 'lane' && shape.name != 'linker') {
minY = shape.props.y > minY ? minY : shape.props.y;
}
}
var result = [];
if (minY < (60 + 40 + 66 + 40)) {// 60:上方空白边距40余留空白66接口高度40余留空白
// 高度不够添加一行的,进行移动
var offset = 208 - minY;
for (var shapeId in elements) {
var shape = elements[shapeId];
if (shape.name == 'linker') {
shape.from.y += offset;
shape.to.y += offset;
var points = shape.points;
for (var i = 0; i < points.length; i++) {
points[i].y += offset;
}
shape.points = points;
} else {// 形状
shape.props.y += offset;
}
result.push(shape);
Designer.painter.renderShape(shape);
}
}
if (result.length > 0) {
Model.updateMulti(result);
}
}
// 创建新增的形状定义,默认坐标为(0,0)开始,一字排列
function getAddShapes(addInterface) {
var result = [];
var x = 100;// 距离画布左侧默认100
for (var markId in addInterface) {
var newShape = Model.create('procedure', x, 0);
x += (150 + 80);
newShape.attrMark = addInterface[markId];
newShape.text = addInterface[markId].name;
result.push(newShape);
}
return result;
}
// 处理删除的形状
function getRemoveShapes(interfaceObj, delInterface, position) {
var result = [];
var elements = Model.define.elements;
for (var markId in delInterface) {
var shapeId = getMatchInterfaceObj(interfaceObj, delInterface[markId], position);
if (shapeId != '') {
// 增加到删除的形状中
result.push(elements[shapeId]);
// 相关的连线也增加到删除的形状中
var obj = interfaceObj[shapeId];
for (var i = 0; i < obj.fromLinkerArr.length; i++) {
result.push(elements[obj.fromLinkerArr[i]]);
}
for (var i = 0; i < obj.toLinkerArr.length; i++) {
result.push(elements[obj.toLinkerArr[i]]);
}
}
}
return result;
}
// 处理需要新增的匹配
function getUpdateShapes(interfaceObj, updateInterface, position, addInterface) {
var result = [];
for (var markId in updateInterface) {
var shapeId = getMatchInterfaceObj(interfaceObj, updateInterface[markId], position);
if (shapeId == '') {// 未找到,从属性上来说属于更新,但是画布上未找到,从新设置归属于新增一类
addInterface[markId] = updateInterface[markId];
continue;
}
var shape = Model.define.elements[shapeId];
shape.attrMark = updateInterface[markId];
shape.text = updateInterface[markId].name;
result.push(shape);
}
return result;
}
// 根据匹配规则进行匹配返回匹配的shapeId
function getMatchInterfaceObj(interfaceObj, markObj, markName, position) {
var matchShapeId = '';
// 根据标识匹配
for (var shapeId in interfaceObj) {
var obj = interfaceObj[shapeId];
var attrMark = obj.attrMark;
if (attrMark != undefined && attrMark.versionId == markObj.versionId) {
matchShapeId = shapeId;
break;
}
}
// 没匹配上,根据出入线+名称匹配
if (matchShapeId == '') {
for (var shapeId in interfaceObj) {
var obj = interfaceObj[shapeId];
if (position == 'top') {// 前置
if (obj.fromLinkerArr.length > 0 && obj.toLinkerArr.length == 0 && obj.text == markName) {// 多出线,零入线且名称匹配
matchShapeId = shapeId;
break;
}
} else {// 后置
if (obj.toLinkerArr.length > 0 && obj.fromLinkerArr.length == 0 && obj.text == markName) {// 多入线,零出线且名称匹配
matchShapeId = shapeId;
break;
}
}
}
}
return matchShapeId;
}
// 处理关联的结果数据,按照新增的、修改的、删除的进行分类
function handleRelationData(addInterface, updateInterface, delInterface, oldFileIds, oldFileNames, newFileIds, newFileNames) {
// 查询关联结果相关的version信息
// 统计新增、修改、删除的流程接口
$.ajax({
type : 'POST',
url:"./jd",
async:false,
data:{
sid : CLB.sid,
cmd : "com.actionsoft.apps.coe.pal_pl_repository_designer_relation_info_query",
oldFileIds: JSON.stringify(oldFileIds.split(",")),
newFileIds: JSON.stringify(newFileIds)
},
success : function(ro) {
var data = ro.data;
var oldFiles = data.old;
var newFiles = data.new;
// 找到新增的 oldFiles没有newFiles有
for (var id in newFiles) {
if (oldFiles[id] == undefined) {
addInterface[id] = newFiles[id];
}
}
// 找到修改的 oldFiles有newFiles有
for (var id in newFiles) {
if (oldFiles[id] != undefined) {
updateInterface[id] = newFiles[id];
}
}
// 找到删除的 oldFiles有newFiles没有
for (var id in oldFiles) {
if (newFiles[id] == undefined) {
delInterface[id] = oldFiles[id];
}
}
}
});
}
// 获取接口形状s
function getInterfaceShape() {
var result = {};
var elements = Model.define.elements;
for (var shapeId in elements) {
var shape = elements[shapeId];
var name = shape.name;
if (name == 'procedure') {
var obj = {};
obj.id = shapeId;
obj.text = shape.text;
obj.fromLinkerArr = [];
obj.toLinkerArr = [];
obj.attrMark = shape.attrMark;
getInterfaceShapeLink(obj, elements);
result[shapeId] = obj;
}
}
return result;
}
// 获取接口的入线与出线
function getInterfaceShapeLink(obj, elements) {
for (var shapeId in elements) {
var shape = elements[shapeId];
var name = shape.name;
if (name == 'linker') {
// 出线
var from = shape.from;
var fromId = from.id;
if (obj.id == fromId) {
obj.fromLinkerArr.push(shapeId);
}
// 入线
var to = shape.to;
var toId = to.id;
if (obj.id == toId) {
obj.toLinkerArr.push(shapeId);
}
}
}
}
var checkObj = undefined;
// 画布鼠标右键-添加至前置流程、后置流程功能
function showLeadAndRearProcessDlg(type) {
checkObj = undefined;
$('#leadAndRearProcessSearchKey').unbind('keydown').bind('keydown',function(event){
if(event.keyCode == "13") {
queryLeadAndRearProcessData();
}
});
var shape = Designer.contextMenu.menuPos.shape;
var title = '匹配前置流程';
if (type == 'rear') {
title = '匹配后置流程';
}
$('#leadAndRearProcessSearchKey').val(shape.text);
$('#attrMark').val(JSON.stringify(shape.attrMark));
$("#addLeadAndRearProcessDlg").dialog({
height:400,
width: 700,
title: title,
buttons:[
{
text:'确定',cls:"blue",handler:function(){
// todo 验证
// 获取选中
if (checkObj == undefined) {
alert('请选择');
} else {
// 形状名称和关联关系更新
shape.text = checkObj.name;
shape.attrMark = checkObj;
Model.update(shape);
// 关联关系db存储
$.ajax({
type : 'POST',
url:"./jd",
async:false,
data:{
sid : CLB.sid,
cmd : "com.actionsoft.apps.coe.pal_pl_repository_designer_shape_relation_rear_lead_save",
uuid: ruuid,
relationFileId: checkObj.versionId,
relationShapeText: checkObj.name,
type: type
},
success : function(ro) {
}
});
}
$("#addLeadAndRearProcessDlg").dialog("close");
}
},
{
text:'取消',handler:function(){
//alert('取消');
this.disabled = true;
$("#addLeadAndRearProcessDlg").dialog("close");
}
}
]
});
// 执行查询
queryLeadAndRearProcessData();
// alert(Designer.contextMenu.menuPos.shape.text)
}
function queryLeadAndRearProcessData() {
var inputKey = $('#leadAndRearProcessSearchKey').val().trim();
if (inputKey == '') {
alert('请输入流程名称之后查询')
return;
}
// 开始查询
// 隐藏表格
$('#leadAndRearProcessDataTableTbody').empty();
// $('#leadAndRearProcessDataTable').hide();
// 开启loading
// $("#leadAndRearProcessDataLoading").loading({
// description:"正在查询",
// color:'#3983de'
// });
$.ajax({
type : 'POST',
url:"./jd",
async:false,
data:{
sid : CLB.sid,
cmd : "com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_tree_query",
wsId: $('#wsId').val(),
category: 'process',
autoContent: inputKey
},
success : function(ro) {
// 关闭loading提示
// $("#leadAndRearProcessDataLoading").loading({
// hidden:true
// });
// $('#leadAndRearProcessDataTable').show();
var msg = ro.data.result;
if (msg == ""){
return;
}
var tHtml = '';
var uuidArr = [];
for(var i = 0; i < msg.length; i++) {
var uuid = msg[i].ext1;
var versionId = msg[i].ext2;
uuidArr.push(uuid);
tHtml += '<tr>';
tHtml += '<td><input class="awsui-radio" id="data_' + versionId + '" data-id="'+ uuid +'" data-versionId="'+ versionId +'" value="' + msg[i].value + '" data-name="' + msg[i].name + '" type="radio" name="fileRadio"></td>';
tHtml += '<td style="cursor:pointer;" data-value="' + msg[i].value + '">' + msg[i].ui + '</td>';
tHtml += '</tr>';
}
$('#leadAndRearProcessDataTableTbody').html(tHtml);
$("#leadAndRearProcessDataTableTbody .awsui-radio").check();// 初始化单选框样式
$("#leadAndRearProcessDataTableTbody input[name='fileRadio']").on("ifChanged",function(){
var id = $(this).attr("data-id");
var name = $(this).attr("data-name");
var versionId = $(this).attr("data-versionId");
checkObj = {id: id, name: name, versionId: versionId};
});
// 设置选中状态
var obj = $('#attrMark').val();
if (obj != '') {
$('#data_' + JSON.parse(obj).versionId).check("check");
}
}
});
}