check bugs

This commit is contained in:
yubao 2018-04-07 22:00:29 +08:00
parent e5f911079f
commit fc5893722c
2 changed files with 141 additions and 190 deletions

View File

@ -24,7 +24,7 @@ namespace OpenAuth.App.Flow
_runtimeModel.frmData = instance.FrmData; _runtimeModel.frmData = instance.FrmData;
_runtimeModel.schemeContentJson = schemeContentJson;//模板流程json对象 _runtimeModel.schemeContentJson = schemeContentJson;//模板流程json对象
_runtimeModel.nodes = GetNodes(schemeContentJson);//节点集合 _runtimeModel.nodes = GetNodes(schemeContentJson);//节点集合
_runtimeModel.lines = GetLineDictionary(schemeContentJson);//线条集合 _runtimeModel.lines = GetFromLines(schemeContentJson);//线条集合
_runtimeModel.currentNodeId = (instance.ActivityId == "" ? _runtimeModel.startNodeId : instance.ActivityId); _runtimeModel.currentNodeId = (instance.ActivityId == "" ? _runtimeModel.startNodeId : instance.ActivityId);
_runtimeModel.currentNodeType = GetNodeType(_runtimeModel.currentNodeId); _runtimeModel.currentNodeType = GetNodeType(_runtimeModel.currentNodeId);
@ -36,7 +36,7 @@ namespace OpenAuth.App.Flow
} }
else else
{ {
_runtimeModel.nextNodeId = GetNextNode(_runtimeModel.frmData);//下一个节点 _runtimeModel.nextNodeId = GetNextNodeId(_runtimeModel.frmData);//下一个节点
_runtimeModel.nextNodeType = GetNodeType(_runtimeModel.nextNodeId); _runtimeModel.nextNodeType = GetNodeType(_runtimeModel.nextNodeId);
} }
@ -69,57 +69,56 @@ namespace OpenAuth.App.Flow
return nodes; return nodes;
} }
/// <summary> /// <summary>
/// 获取工作流线段的字典列表:key开始节点idvalue线条实体列表 /// 获取工作流节点及以节点为出发点的流程
/// </summary> /// </summary>
/// <param name="schemeContentJson"></param> /// <param name="schemeContentJson"></param>
/// <returns></returns> /// <returns></returns>
private Dictionary<string, List<FlowLine>> GetLineDictionary(dynamic schemeContentJson) private Dictionary<string, List<FlowLine>> GetFromLines(dynamic schemeContentJson)
{ {
Dictionary<string, List<FlowLine>> lineDictionary = new Dictionary<string, List<FlowLine>>(); Dictionary<string, List<FlowLine>> lines = new Dictionary<string, List<FlowLine>>();
foreach (JObject item in schemeContentJson.lines) foreach (JObject item in schemeContentJson.lines)
{ {
var line = item.ToObject<FlowLine>(); var line = item.ToObject<FlowLine>();
if (!lineDictionary.ContainsKey(line.from)) if (!lines.ContainsKey(line.from))
{ {
List<FlowLine> d = new List<FlowLine> { line }; List<FlowLine> d = new List<FlowLine> { line };
lineDictionary.Add(line.from, d); lines.Add(line.from, d);
} }
else else
{ {
lineDictionary[line.from].Add(line); lines[line.from].Add(line);
} }
} }
return lineDictionary; return lines;
} }
/// <summary> /// <summary>
/// 获取工作流线段的字典列表:key开始节点idvalue线条实体列表 /// 获取工作流节点的入口流程列表
/// </summary> /// </summary>
/// <param name="schemeContentJson"></param> /// <param name="schemeContentJson"></param>
/// <returns></returns> /// <returns></returns>
private Dictionary<string, List<FlowLine>> GetToLineDictionary(dynamic schemeContentJson) private Dictionary<string, List<FlowLine>> GetToLines(dynamic schemeContentJson)
{ {
Dictionary<string, List<FlowLine>> lineDictionary = new Dictionary<string, List<FlowLine>>(); Dictionary<string, List<FlowLine>> lines = new Dictionary<string, List<FlowLine>>();
foreach (JObject item in schemeContentJson.lines) foreach (JObject item in schemeContentJson.lines)
{ {
var line = item.ToObject<FlowLine>(); var line = item.ToObject<FlowLine>();
if (!lineDictionary.ContainsKey(line.to)) if (!lines.ContainsKey(line.to))
{ {
List<FlowLine> d = new List<FlowLine> { line }; List<FlowLine> d = new List<FlowLine> { line };
lineDictionary.Add(line.to, d); lines.Add(line.to, d);
} }
else else
{ {
lineDictionary[line.to].Add(line); lines[line.to].Add(line);
} }
} }
return lineDictionary; return lines;
} }
/// <summary> /// <summary>
/// 获取下一个节点 /// 获取下一个节点
/// </summary> /// </summary>
/// <param name="frmData">表单数据(用于判断流转条件)</param> private string GetNextNodeId(string frmData, string nodeId=null)
private string GetNextNode(string frmData, string nodeId = null)
{ {
List<FlowLine> LineList = null; List<FlowLine> LineList = null;
if (nodeId == null) if (nodeId == null)
@ -142,15 +141,25 @@ namespace OpenAuth.App.Flow
bool flag = false; bool flag = false;
foreach (var item in LineList)//轮训该节点所有连接的线路 foreach (var item in LineList)//轮训该节点所有连接的线路
{ {
return item.to; return item.to;
} }
} }
return "-1";//表示寻找不到节点 return "-1";//表示寻找不到节点
} }
/// <summary>
/// 通过节点Id获取下一个节点Id
/// </summary>
/// <param name="nodeId"></param>
/// <returns></returns>
public string GetNextNode(string nodeId)
{
string frmData = "";
// frmData = GetNodeFrmData(_getFrmData, nodeId);
return GetNextNodeId(frmData, nodeId);
}
#endregion #endregion
#region API #region API
@ -206,172 +215,117 @@ namespace OpenAuth.App.Flow
/// <summary> /// <summary>
/// 获取会签下面需要审核的ID列表 /// 获取会签下面需要审核的ID列表
/// </summary> /// </summary>
/// <param name="shuntnodeId"></param> /// <param name="forknodeId">会签开始节点</param>
/// <returns></returns> /// <returns></returns>
public List<string> GetCountersigningNodeIdList(string shuntnodeId) public List<string> GetCountersigningNodeIdList(string forknodeId)
{ {
List<string> list = new List<string>(); return _runtimeModel.lines[forknodeId].Select(item => item.to).ToList();
List<FlowLine> listline = _runtimeModel.lines[shuntnodeId];
foreach (var item in listline)
{
list.Add(item.to);
} }
return list;
}
/// <summary>
/// 通过节点Id获取下一个节点Id
/// </summary>
/// <param name="nodeId"></param>
/// <returns></returns>
public string GetNextNodeByNodeId(string nodeId)
{
string frmData = "";
// frmData = GetNodeFrmData(_getFrmData, nodeId);
return GetNextNode(frmData, nodeId);
}
/// <summary> /// <summary>
/// 节点会签审核 /// 节点会签审核
/// </summary> /// </summary>
/// <param name="nodeId"></param> /// <param name="nodeId"></param>
/// <param name="flag"></param> /// <param name="tag"></param>
/// <returns>-1不通过,1等待,其它通过</returns> /// <returns>-1不通过,1等待,其它通过</returns>
public string NodeConfluence(string nodeId, Tag tag) public string NodeConfluence(string nodeId, Tag tag)
{ {
string res = "-1"; string res = "-1";
string nextNodeId = GetNextNodeByNodeId(nodeId);//获取下一个节点 string joinNodeId = GetNextNode(nodeId); //获取回签的合流节点
if (nextNodeId != "-1")
if (joinNodeId == "-1")
{ {
Dictionary<string, List<FlowLine>> toLines = GetToLineDictionary(_runtimeModel.schemeContentJson); throw (new Exception("寻找不到会签下合流节点"));
int allnum = toLines[nextNodeId].Count; }
Dictionary<string, List<FlowLine>> toLines = GetToLines(_runtimeModel.schemeContentJson);
int allnum = toLines[joinNodeId].Count; //总会签数量
int i = 0; int i = 0;
foreach (var item in _runtimeModel.schemeContentJson.nodes) foreach (var item in _runtimeModel.schemeContentJson.nodes)
{ {
if (item.id == nextNodeId) if (item.id != joinNodeId)
{ {
if (string.IsNullOrEmpty(item.setInfo.NodeConfluenceType))//0所有步骤通过 todo:先用空格
{
if (tag.Taged == 1)
{
if (item.setInfo.ConfluenceOk == null)
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk = 1;
res = "1";
}
else if (item.setInfo.ConfluenceOk == (allnum - 1))
{
res = GetNextNodeByNodeId(nextNodeId);
if (res == "-1")
{
throw (new Exception("会签成功寻找不到下一个节点"));
}
}
else
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk++;
res = "1";
}
}
}
else if (item.setInfo.NodeConfluenceType == "1")//1一个步骤通过即可
{
if (tag.Taged ==1)
{
res = GetNextNodeByNodeId(nextNodeId);
if (res == "-1")
{
throw (new Exception("会签成功寻找不到下一个节点"));
}
}
else
{
if (item.setInfo.ConfluenceNo == null)
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo = 1;
res = "1";
}
else if (item.setInfo.ConfluenceNo == (allnum - 1))
{
res = "-1";
}
else
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo++;
res = "1";
}
}
}
else//2按百分比计算
{
if (tag.Taged == 1)
{
if (item.setInfo.ConfluenceOk == null)
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk = 1;
}
else
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk++;
}
}
else
{
if (item.setInfo.ConfluenceNo == null)
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo = 1;
}
else
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo++;
}
}
if ((item.setInfo.ConfluenceNo + item.setInfo.ConfluenceOk) / allnum * 100 > int.Parse(item.setInfo.NodeConfluenceRate))
{
res = GetNextNodeByNodeId(nextNodeId);
if (res == "-1")
{
throw (new Exception("会签成功寻找不到下一个节点"));
}
}
else if ((item.setInfo.ConfluenceNo + item.setInfo.ConfluenceOk) == allnum)
{
res = "-1";
}
else
{
res = "1";
}
}
break;
}
i++; i++;
continue;
} }
if (string.IsNullOrEmpty(item.setInfo.NodeConfluenceType)) //默认所有步骤通过
{
if (tag.Taged == 1)
{
if (item.setInfo.ConfluenceOk == null)
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk = 1;
res = "1";
}
else if (item.setInfo.ConfluenceOk == (allnum - 1)) //会签成功
{
res = GetNextNode(joinNodeId);
if (res == "-1")
{
throw (new Exception("会签成功寻找不到下一个节点"));
}
}
else
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk++;
res = "1";
}
}
}
//else if (item.setInfo.NodeConfluenceType == "1") //1一个步骤通过即可
//{
// if (tag.Taged == 1)
// {
// res = GetNextNodeId(nextNodeId);
// if (res == "-1")
// {
// throw (new Exception("会签成功寻找不到下一个节点"));
// }
// }
// else
// {
// if (item.setInfo.ConfluenceNo == null)
// {
// _runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo = 1;
// res = "1";
// }
// else if (item.setInfo.ConfluenceNo == (allnum - 1))
// {
// res = "-1";
// }
// else
// {
// _runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo++;
// res = "1";
// }
// }
//}
}
if (res == "-1") if (res == "-1")
{ {
tag.Taged = -1; tag.Taged = -1;
MakeTagNode(nextNodeId, tag); MakeTagNode(joinNodeId, tag);
} }
else if (res != "1") //则时res是会签结束节点的ID else if (res != "1") //这时res是会签结束节点后面的一个节点
{ {
tag.Taged = 1; tag.Taged = 1;
MakeTagNode(nextNodeId,tag); MakeTagNode(joinNodeId, tag);
_runtimeModel.nextNodeId = res; _runtimeModel.nextNodeId = res;
_runtimeModel.nextNodeType = GetNodeType(res); _runtimeModel.nextNodeType = GetNodeType(res);
} }
else else
{ {
_runtimeModel.nextNodeId = nextNodeId; _runtimeModel.nextNodeId = joinNodeId;
_runtimeModel.nextNodeType = GetNodeType(nextNodeId); _runtimeModel.nextNodeType = GetNodeType(joinNodeId);
} }
return res; return res;
} }
throw (new Exception("寻找不到会签下合流节点"));
}
/// <summary> /// <summary>
/// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理" /// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
/// </summary> /// </summary>
@ -392,7 +346,7 @@ namespace OpenAuth.App.Flow
} }
if (node.setInfo.NodeRejectType == "1") if (node.setInfo.NodeRejectType == "1")
{ {
return GetNextNodeByNodeId(_runtimeModel.startNodeId); return GetNextNode(_runtimeModel.startNodeId);
} }
if (node.setInfo.NodeRejectType == "2") if (node.setInfo.NodeRejectType == "2")
{ {
@ -423,6 +377,7 @@ namespace OpenAuth.App.Flow
i++; i++;
} }
} }
}
#endregion #endregion
} }
}

View File

@ -115,27 +115,22 @@ namespace OpenAuth.App
Description = description Description = description
}; };
#region #region
if (flowInstance.ActivityType == 0)//会签 if (flowInstance.ActivityType == 0)//当前节点是会签节点
{ {
tag.Taged = 1; tag.Taged = 1;
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);//标记当前节点通过 wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);//标记会签节点状态
string verificationNodeId = ""; //寻找需要审核的节点Id string verificationNodeId = ""; //寻找当前登陆用户可审核的节点Id
List<string> nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId); List<string> nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId);
foreach (string item in nodelist) foreach (string item in nodelist)
{ {
var makerList = GetMakerList(wfruntime.runtimeModel.nodes[item] var makerList = GetMakerList(wfruntime.runtimeModel.nodes[item]
, wfruntime.runtimeModel.flowInstanceId); , wfruntime.runtimeModel.flowInstanceId);
if (makerList != "-1") if (makerList == "-1") continue;
{
foreach (string one in makerList.Split(',')) if (makerList.Split(',').Any(one => user.Id == one))
{
if (user.Id == one || user.Id.IndexOf(one) != -1)
{ {
verificationNodeId = item; verificationNodeId = item;
break;
}
}
} }
} }
@ -152,13 +147,14 @@ namespace OpenAuth.App
flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.nodes[verificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description; flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.nodes[verificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
} }
wfruntime.MakeTagNode(verificationNodeId, tag);//标记审核节点状态
string confluenceres = wfruntime.NodeConfluence(verificationNodeId, tag); string confluenceres = wfruntime.NodeConfluence(verificationNodeId, tag);
switch (confluenceres) switch (confluenceres)
{ {
case "-1"://不通过 case "-1"://不通过
flowInstance.IsFinish = 3; flowInstance.IsFinish = 3;
break; break;
case "1"://等待 case "1"://等待,当前节点还是会签开始节点,不跳转
break; break;
default://通过 default://通过
flowInstance.PreviousId = flowInstance.ActivityId; flowInstance.PreviousId = flowInstance.ActivityId;