You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
199 lines
8.1 KiB
C#
199 lines
8.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using DSWeb.Areas.Account.Models.Chfee_payapplication;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using System.Data;
|
|
|
|
namespace DSWeb.Areas.Account.DAL.Chfee_payapplication
|
|
{
|
|
public class FlowMapDal
|
|
{
|
|
|
|
public static List<FlowMapModel> GetMap ( string bsno,string name="")
|
|
{
|
|
|
|
string namestr = "";
|
|
if (name != "" && name !="null" && name!="NULL" && name != "Null")
|
|
{
|
|
namestr = "and wt.NAME = '"+name+"'";
|
|
}
|
|
//获取已完成流程步骤
|
|
string sqlDo = @" select
|
|
wu.BSNO AS BSNO
|
|
,ws.GID AS STEPID
|
|
,w.NAME AS FNAME
|
|
,ws.NAME AS SNAME
|
|
,u.SHOWNAME AS OPER
|
|
,wd.AUDITTIME AS OPTIME
|
|
,ws.GROUPID
|
|
,uc.SHOWNAME AS CREATOR
|
|
from workflow_do wd
|
|
left join workflow_using wu on wd.BILLNO = wu.BSNO
|
|
left join workflow w on w.GID = wu.WORKFLOWID
|
|
left join workflow_step ws on ws.WORKFLOWID = w.GID and ws.GID = wd.STEPID
|
|
left join [user] u on u.GID = ws.AUDITOR
|
|
left join [user] uc on uc.GID = wu.OP
|
|
left join workflow_type wt on w.TYPE = wt.TYPENO
|
|
where isnull(wd.ISDELETE,0)=0 and wd.BILLNO = '" + bsno + "' and wd.audittime>=(select max(audittime) from workflow_do where GROUPID=1 and STEPNO=1 and isnull(ISDELETE,0)=0 and BILLNO = '" + bsno + "') ";
|
|
sqlDo = sqlDo + namestr + " order by wd.AUDITTIME,w.NAME,ws.NAME,ws.GROUPID,u.SHOWNAME";
|
|
|
|
//获取所有的流程步骤
|
|
string sqlStep = @" select
|
|
wu.BSNO AS BSNO
|
|
,ws.GID AS STEPID
|
|
,w.NAME AS FNAME
|
|
,ws.NAME AS SNAME
|
|
,u.SHOWNAME AS OPER
|
|
,u.GID AS OPERID
|
|
,u.OPENID
|
|
,ws.GROUPID
|
|
,uc.SHOWNAME AS CREATOR
|
|
,wu.CREATETIME AS CREATETIME
|
|
from workflow_step ws
|
|
left join workflow w on ws.WORKFLOWID = w.GID
|
|
left join workflow_using wu on wu.WORKFLOWID = w.GID
|
|
left join [user] u on ws.AUDITOR = u.GID
|
|
left join [user] uc on uc.GID = wu.OP
|
|
left join workflow_type wt on w.TYPE = wt.TYPENO
|
|
where wu.BSNO = '" + bsno + "' ";
|
|
|
|
sqlStep = sqlStep + namestr + " order by ws.GROUPID";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
List<FlowStep> listStep = new List<FlowStep>();
|
|
try
|
|
{
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sqlStep))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
FlowStep fs = new FlowStep();
|
|
fs.BSNO = reader["BSNO"].ToString();
|
|
fs.STEPID = reader["STEPID"].ToString();
|
|
fs.FNAME = reader["FNAME"].ToString();
|
|
fs.SNAME = reader["SNAME"].ToString();
|
|
fs.OPER = reader["OPER"].ToString();
|
|
fs.OPERID = reader["OPERID"].ToString();
|
|
fs.OPEROPENID = reader["OPENID"].ToString();
|
|
fs.GROUPID = reader["GROUPID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["GROUPID"]);
|
|
fs.CREATOR = reader["CREATOR"].ToString();
|
|
fs.CREATETIME = reader["CREATETIME"] == DBNull.Value ? "----" : reader["CREATETIME"].ToString();
|
|
listStep.Add(fs);
|
|
}
|
|
|
|
}
|
|
|
|
List<FlowDo> listdo = new List<FlowDo>();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sqlDo))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
FlowDo fs = new FlowDo();
|
|
fs.BSNO = reader["BSNO"].ToString();
|
|
fs.STEPID = reader["STEPID"].ToString();
|
|
fs.FNAME = reader["FNAME"].ToString();
|
|
fs.SNAME = reader["SNAME"].ToString();
|
|
fs.OPER = reader["OPER"].ToString();
|
|
fs.OPTIME = reader["OPTIME"].ToString();
|
|
fs.GROUPID = reader["GROUPID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["GROUPID"]);
|
|
fs.CREATOR = reader["CREATOR"].ToString();
|
|
listdo.Add(fs);
|
|
}
|
|
|
|
}
|
|
|
|
List<FlowMapModel> listMap = new List<FlowMapModel>();
|
|
|
|
int groupTemp = 0;
|
|
|
|
//获取listdo中最大的groupid
|
|
int maxGroupId = listdo.Count > 0 ? listdo.Max(d => d.GROUPID) : 0;
|
|
|
|
#region 创建开始申请的数据
|
|
|
|
FlowMapModel fmStart = new FlowMapModel();
|
|
|
|
fmStart.GroupID = 0;
|
|
|
|
fmStart.FlowName = "申请";
|
|
|
|
fmStart.CreateTime = listStep[0].CREATETIME;
|
|
|
|
List<FlowMapActionModel> listActStart = new List<FlowMapActionModel>();
|
|
|
|
FlowMapActionModel maStart = new FlowMapActionModel();
|
|
|
|
maStart.Name = "发起申请";
|
|
|
|
maStart.IsCurr = 0;
|
|
|
|
maStart.OpState = 1;
|
|
|
|
maStart.Oper = listStep[0].CREATOR;
|
|
|
|
maStart.OpTime = listStep[0].CREATETIME;
|
|
|
|
listActStart.Add(maStart);
|
|
|
|
fmStart.Acts = listActStart;
|
|
|
|
listMap.Add(fmStart);
|
|
|
|
#endregion
|
|
|
|
foreach (var s in listStep)
|
|
{
|
|
if (groupTemp < s.GROUPID)
|
|
{
|
|
groupTemp = s.GROUPID;
|
|
FlowMapModel fm = new FlowMapModel();
|
|
fm.BSNO = s.BSNO;
|
|
fm.FlowName = s.FNAME;
|
|
fm.GroupID = s.GROUPID;
|
|
fm.CreateTime = s.CREATETIME;
|
|
List<FlowMapActionModel> listAct = new List<FlowMapActionModel>();
|
|
foreach (var ss in listStep)
|
|
{
|
|
FlowMapActionModel ma = new FlowMapActionModel();
|
|
ma.Name = ss.SNAME;
|
|
ma.Oper = ss.OPER;
|
|
ma.OpState = 0;
|
|
ma.IsCurr = 0;
|
|
ma.UserID = ss.OPERID;
|
|
ma.OperOpenId = ss.OPEROPENID;
|
|
if (ss.GROUPID == s.GROUPID)
|
|
{
|
|
//判断审批状态
|
|
foreach (var d in listdo)
|
|
{
|
|
if (d.STEPID == ss.STEPID)
|
|
{
|
|
ma.OpState = 1;
|
|
ma.OpTime = d.OPTIME;
|
|
}
|
|
}
|
|
if (ss.GROUPID == maxGroupId + 1)
|
|
{
|
|
ma.IsCurr = 1;
|
|
}
|
|
listAct.Add(ma);
|
|
}
|
|
}
|
|
fm.Acts = listAct;
|
|
listMap.Add(fm);
|
|
}
|
|
|
|
}
|
|
return listMap;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
} |