|
|
|
@ -22,6 +22,7 @@
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.Helper;
|
|
|
|
|
using DSWeb.Areas.SysMng.DAL.SysTask;
|
|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.CommMng.DAL
|
|
|
|
|
{
|
|
|
|
@ -407,6 +408,193 @@ namespace DSWeb.Areas.CommMng.DAL
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据工作流名字、用户ID、公司ID 判定该使用哪个或哪些工作流
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="NAME"></param>
|
|
|
|
|
/// <param name="USERID"></param>
|
|
|
|
|
/// <param name="COMPANYID"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
static public DBResult GetWorkFlowmb(string NAME, string BILLNO, string USERID, string COMPANYID = "")
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var vwuser = new VW_user_md();
|
|
|
|
|
var vwuserList = cdc.VW_user.Where(x => x.USERID == USERID).ToList();
|
|
|
|
|
if (vwuserList == null || vwuserList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result.SetErrorInfo($"未找到可用用户ID:{USERID}");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vwuser = vwuserList[0];
|
|
|
|
|
if (string.IsNullOrWhiteSpace(COMPANYID))
|
|
|
|
|
COMPANYID = vwuser.COMPANYID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//1 看该用户是否出现在该种工作流的【管辖范围workflow_UserPath】内
|
|
|
|
|
//1.1 如有 看是否多条 如是多条 分别依据条件判断使用哪一个工作流
|
|
|
|
|
// 如多条符合 或 多条无条件 或 无符合条件 则返回错误
|
|
|
|
|
// 如仅一条符合 返回该工作流
|
|
|
|
|
|
|
|
|
|
//1.2 如无(出现在该种工作流的【管辖范围workflow_UserPath】内)
|
|
|
|
|
// 则根据公司(如公司为空则使用用户所在公司id) 、isdefault 判断是否只有一条工作流
|
|
|
|
|
// 如无,则根据公司(如公司为空则使用用户所在公司id) 判断是否只有一条工作流
|
|
|
|
|
// 如仅一条符合 返回该工作流
|
|
|
|
|
// 否则 返回错误
|
|
|
|
|
|
|
|
|
|
var 工作流type = cdc.workflow_type.Where(x => x.NAME == NAME).ToList();
|
|
|
|
|
|
|
|
|
|
if (工作流type == null || 工作流type.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo($"未找到工作流{NAME}");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (工作流type == null || 工作流type.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo($"未找到工作流{NAME}");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
var typenostr = 工作流type[0].TYPENO.ToString();
|
|
|
|
|
var 受管辖范围List = cdc.workflow_UserPath.Where(x => x.USERID == USERID && x.workflowTypeNO == typenostr).ToList();
|
|
|
|
|
if (!(受管辖范围List == null || 受管辖范围List.Count == 0))
|
|
|
|
|
{ //1.1
|
|
|
|
|
|
|
|
|
|
result = 根据管辖范围获取工作流(受管辖范围List, BILLNO, USERID, COMPANYID);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//1.2
|
|
|
|
|
var typeno = 工作流type[0].TYPENO;
|
|
|
|
|
var workflowidlist = cdc.workflow.Where(x => x.TYPE == typeno).Select(s => s.GID).ToList();
|
|
|
|
|
result = 无管辖范围获取工作流(workflowidlist, BILLNO, USERID, COMPANYID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo(ex.Message);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static DBResult 根据管辖范围获取工作流(List<workflow_UserPath_md> 受管辖范围List, string BILLNO, string USERID, string COMPANYID = "")
|
|
|
|
|
{
|
|
|
|
|
//1 看该用户是否出现在该种工作流的【管辖范围workflow_UserPath】内
|
|
|
|
|
//1.1 如有 看是否多条 如是多条 分别依据条件condition判断使用哪一个工作流
|
|
|
|
|
// 如多条符合 或 多条无条件 或 无符合条件 则返回错误
|
|
|
|
|
// 如仅一条符合 返回该工作流
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
var resultdata = new workflow_md();
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
if (受管辖范围List.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
var workflowid = 受管辖范围List[0].workflowID;
|
|
|
|
|
resultdata = cdc.workflow.FirstOrDefault(x => x.GID == workflowid);
|
|
|
|
|
result.OK("", resultdata);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var workflowidlist = 受管辖范围List.Select(s => s.workflowID).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
result = 无管辖范围获取工作流(workflowidlist, BILLNO, USERID, COMPANYID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static DBResult 无管辖范围获取工作流(List<string> workflowidlist, string BILLNO, string USERID, string COMPANYID = "")
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var workflowlist = cdc.workflow.Where(x => workflowidlist.Contains(x.GID) && x.COMPANYID == COMPANYID).ToList();
|
|
|
|
|
|
|
|
|
|
if (workflowlist.Exists(x => x.ISCONDITION))
|
|
|
|
|
{
|
|
|
|
|
//如果有条件工作流 先看有没有符合条件的
|
|
|
|
|
var 条件工作流List = workflowlist.Where(x => x.ISCONDITION == true).ToList();
|
|
|
|
|
foreach (var 条件工作流 in 条件工作流List)
|
|
|
|
|
{
|
|
|
|
|
var CONDITIONSQL = 条件工作流.CONDITIONSQL.Replace("[业务编号]", "'" + BILLNO + "'");
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
|
|
if (strCOUNT != "0")
|
|
|
|
|
{
|
|
|
|
|
result.OK("", 条件工作流);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//如果 条件工作流中无符合条件的 那就看有没有无条件的
|
|
|
|
|
//如无 返回无符合条件的工作流
|
|
|
|
|
//如有且仅有一个 返回它
|
|
|
|
|
//如有多个且其中有一个isdefault的 返回它
|
|
|
|
|
//如有多个且其中无默认工作流的 返回错误
|
|
|
|
|
var 无条件工作流 = workflowlist.Where(x => x.ISCONDITION != true).ToList();
|
|
|
|
|
if (无条件工作流 == null || 无条件工作流.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo("无符合条件的工作流");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (无条件工作流.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
result.OK("", 无条件工作流[0]);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (无条件工作流.Count > 1 && 无条件工作流.Exists(x => x.ISDEFAULT == 1))
|
|
|
|
|
{
|
|
|
|
|
result.OK("", 无条件工作流.First(x => x.ISDEFAULT == 1));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (无条件工作流.Count > 1 && !无条件工作流.Exists(x => x.ISDEFAULT == 1))
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo("无符合条件的工作流(多条无条件工作流,且其中无默认工作流)");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
result.SetErrorInfo("无符合条件的工作流(其他情况)");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (workflowlist.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
result.OK("", workflowlist[0]);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (workflowlist.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
if (workflowlist.Exists(x => x.ISDEFAULT == 1))
|
|
|
|
|
{
|
|
|
|
|
result.OK("", workflowlist.First(x => x.ISDEFAULT == 1));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo("无符合条件的工作流(多条无条件工作流,且其中无默认工作流)");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region [查询]通过WORKFLOWID查找workflow_step的内容
|
|
|
|
|