DS7_JinGang
hanxuntao 2 years ago
commit 8a2f50c5f7

@ -2257,6 +2257,93 @@ namespace DSWeb.Common.DB
public string GOODSNAME_OUT { get; set; } public string GOODSNAME_OUT { get; set; }
} }
[Table("workflow_type")]
public class workflow_type_md
{
[Key]
public string GID { get; set; }
/// <summary>
/// 英文名
/// </summary>
public string NAME { get; set; }
public string DESCRIPTION { get; set; }
/// <summary>
/// 类型序列号 数字
/// </summary>
public int? TYPENO { get; set; }
public string CREATEUSER { get; set; }
public DateTime? CREATETIME { get; set; }
public string MODIFIEDUSER { get; set; }
public DateTime? MODIFIEDTIME { get; set; }
}
[Table("workflow")]
public partial class workflow_md
{
[Key]
public string GID { get; set; }
public string NAME { get; set; }
public string DESCRIPTION { get; set; }
public string MODULEID { get; set; }
public int? TYPE { get; set; }
public string CREATEUSER { get; set; }
public DateTime? CREATETIME { get; set; }
public string MODIFIEDUSER { get; set; }
public DateTime? MODIFIEDTIME { get; set; }
public int? STATE { get; set; }
public int? SORT { get; set; }
public int? ISDELETE { get; set; }
public string COMPANYID { get; set; }
public string DEPTGID { get; set; }
public string TASKURL { get; set; }
public Byte ISDEFAULT { get; set; }
public bool ISCONDITION { get; set; }
public string CONDITIONSQL { get; set; }
public Byte? SORTNO { get; set; }
}
[Table("workflow_step")]
public partial class workflow_step_md
{
[Key]
public string GID { get; set; }
public string NAME { get; set; }
public string DESCRIPTION { get; set; }
public string WORKFLOWID { get; set; }
public int? STEPNO { get; set; }
public string DEFAULTAUDITOR { get; set; }
public string AUDITOR { get; set; }
public string CONDITIONID { get; set; }
public bool? NEEDALLPASS { get; set; }
public bool? ISMUST { get; set; }
public bool? ISLAST { get; set; }
public string GROUPID { get; set; }
public string NextGROUP { get; set; }
public string NextSTEPNO { get; set; }
public string CREATEUSER { get; set; }
public DateTime? CREATETIME { get; set; }
public string MODIFIEDUSER { get; set; }
public DateTime? MODIFIEDTIME { get; set; }
public string REMARK { get; set; }
public bool? ISPARALLEL { get; set; }
public bool? ISDEPARTMENT { get; set; }
public string DEPARTMENTID { get; set; }
public string TASKURL { get; set; }
}
[Table("workflow_UserPath")]
public partial class workflow_UserPath_md
{
[Key]
public Int32 id { get; set; }
public string USERID { get; set; }
public string workflowTypeNO { get; set; }
public string workflowID { get; set; }
}
public static class StrHelper public static class StrHelper
{ {
#region 将一个dictionary转化为用;;和::隔开的文本 #region 将一个dictionary转化为用;;和::隔开的文本

@ -74,6 +74,12 @@ namespace DSWeb.Common.DB
public DbSet<wms_out_md> wms_out { get; set; } public DbSet<wms_out_md> wms_out { get; set; }
public DbSet<wms_out_detail_md> wms_out_detail { get; set; } public DbSet<wms_out_detail_md> wms_out_detail { get; set; }
public DbSet<VW_WMS_OUT_DETAIL_md> VW_WMS_OUT_DETAIL { get; set; } public DbSet<VW_WMS_OUT_DETAIL_md> VW_WMS_OUT_DETAIL { get; set; }
public DbSet<workflow_type_md> workflow_type { get; set; }
public DbSet<workflow_md> workflow { get; set; }
public DbSet<workflow_step_md> workflow_step { get; set; }
public DbSet<workflow_UserPath_md> workflow_UserPath { get; set; }
} }

@ -22,6 +22,7 @@
using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.Areas.MvcShipping.Helper; using DSWeb.Areas.MvcShipping.Helper;
using DSWeb.Areas.SysMng.DAL.SysTask; using DSWeb.Areas.SysMng.DAL.SysTask;
using DSWeb.Common.DB;
namespace DSWeb.Areas.CommMng.DAL namespace DSWeb.Areas.CommMng.DAL
{ {
@ -407,6 +408,193 @@ namespace DSWeb.Areas.CommMng.DAL
return result; 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 #endregion
#region [查询]通过WORKFLOWID查找workflow_step的内容 #region [查询]通过WORKFLOWID查找workflow_step的内容

@ -60,11 +60,19 @@ namespace HcUtility.Comm
OK(""); OK("");
return this; return this;
} }
public DBResult OK( string _message) public void OK(string _message)
{ {
success = true; success = true;
message += _message + ";"; if (!string.IsNullOrWhiteSpace(message) && !string.IsNullOrWhiteSpace(_message))
return this; {
message += ";";
}
message += _message;
}
public void OK(string _message, object data = null)
{
OK(_message);
Data = data;
} }
public DBResult SetErrorInfo(string message, bool success = false, object data = null) public DBResult SetErrorInfo(string message, bool success = false, object data = null)

Loading…
Cancel
Save