天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

806 lines
32 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.Entity.Sys;
using System.Data;
using QMFrameWork.Common.Task;
namespace QMAPP.DAL.Sys
{
/// <summary>
/// 支持交互DAL
/// 创建者:wangyf
/// 创建日期:2015.3.30
/// </summary>
public class SupportInteractionDAL : BaseDAL
{
#region 获取问题处理方法列表
/// <summary>
/// 获取问题处理方法列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetList(SupportInteraction condition, DataPage page)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = this.GetQuerySql(condition, ref parameters);
//分页关键字段及排序
page.KeyName = "PID";
if (string.IsNullOrEmpty(page.SortExpression))
{
page.SortExpression = "CDATE DESC";
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
page = session.GetDataPage<SupportInteraction>(sql, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题处理方法查询语句
/// <summary>
/// 获取问题处理方法查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetQuerySql(SupportInteraction condition, ref List<DataParameter> parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append(" SELECT DDB.PID,DDB.PSEQU,DDB.PTYPE,DDB.PDESP,DDB.SDEPT,DDB.SUSER,DDB.SOLVE,TYP.PTYPENAME AS PTypeName,CDATE,SHKEY, ");
sqlBuilder.Append(" (SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.SUSER) AS SUserName, ");
sqlBuilder.Append(" (SELECT ORGA.ORGADESC FROM T_QM_ORGANIZATION ORGA WHERE ORGA.ORGAID = DDB.SDEPT) AS SOrgaDesc ");
sqlBuilder.Append(" FROM T_QM_ZPDDB DDB LEFT JOIN T_QM_ZPTYPE TYP ON DDB.PTYPE = TYP.PID ");
sqlBuilder.Append(" WHERE DDB.FLGDEL = 0 AND DDB.ECIND = 1 ");
if (!string.IsNullOrEmpty(condition.Shkey))
{
sqlBuilder.Append(" AND DDB.SHKEY LIKE '%" + condition.Shkey + "%'");
}
if (!string.IsNullOrEmpty(condition.PType))
{
sqlBuilder.Append(" AND DDB.PTYPE = @PTYPE ");
parameters.Add(new DataParameter { ParameterName = "PTYPE", DataType = DbType.String, Value = condition.PType });
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题类型
/// <summary>
/// 获取问题类型
/// </summary>
/// <returns>数据页</returns>
public List<SupportInteraction> GetTypeList()
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
List<SupportInteraction> resultList = null;
try
{
sql = " SELECT TYP.PID,TYP.PTYPENAME FROM T_QM_ZPTYPE TYP WHERE TYP.FLGDEL = 0 ";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
resultList = session.GetList<SupportInteraction>(sql, parameters.ToArray()).ToList<SupportInteraction>();
}
return resultList;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题解决方法导出的数据
/// <summary>
/// 获取问题解决方法导出的数据
/// </summary>
/// <param name="user">查询条件</param>
/// <returns>数据</returns>
public DataTable GetExportData(SupportInteraction entity)
{
DataTable dt = null;
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
dt = new DataTable();
sql = this.GetExportSql(entity, ref parameters);
sql += " ORDER BY CDATE DESC";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
dt = session.GetTable(sql, parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题管理导出的数据
/// <summary>
/// 获取问题管理导出的数据
/// </summary>
/// <param name="user">查询条件</param>
/// <returns>数据</returns>
public DataTable GetProblemManageExportData(SupportInteraction entity, string userId, string OrganID)
{
DataTable dt = null;
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = this.GetProblemManageExportSql(entity, ref parameters, userId, OrganID);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
dt = session.GetTable(sql, parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题解决方法导出查询语句
/// <summary>
/// 获取问题解决方法导出查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetExportSql(SupportInteraction condition, ref List<DataParameter> parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append(" SELECT DDB.PID,DDB.PSEQU,DDB.PTYPE,DDB.PDESP,DDB.SDEPT,DDB.SUSER,DDB.SOLVE,DDB.REFER,TYP.PTYPENAME AS PTypeName,CDATE,SHKEY, ");
sqlBuilder.Append(" (SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.SUSER) AS SUserName, ");
sqlBuilder.Append(" (SELECT ORGA.ORGADESC FROM T_QM_ORGANIZATION ORGA WHERE ORGA.ORGAID = DDB.SDEPT) AS SOrgaDesc ");
sqlBuilder.Append(" FROM T_QM_ZPDDB DDB LEFT JOIN T_QM_ZPTYPE TYP ON DDB.PTYPE = TYP.PID ");
sqlBuilder.Append(" WHERE DDB.ECIND = 1 AND DDB.FLGDEL = 0 ");
if (!string.IsNullOrEmpty(condition.Shkey))
{
sqlBuilder.Append(" AND DDB.SHKEY LIKE '%" + condition.Shkey + "%'");
}
if (!string.IsNullOrEmpty(condition.PType))
{
sqlBuilder.Append(" AND DDB.PTYPE = @PTYPE ");
parameters.Add(new DataParameter { ParameterName = "PTYPE", DataType = DbType.String, Value = condition.PType });
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题管理导出查询语句
/// <summary>
/// 获取问题管理导出查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetProblemManageExportSql(SupportInteraction condition, ref List<DataParameter> parameters, string userId, string OrganID)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append(" SELECT DDB.PID,DDB.PSEQU,DDB.PTYPE,DDB.PDESP,DDB.SDEPT,DDB.SUSER,DDB.SOLVE,DDB.SDAYS,DDB.ECIND,TYP.PTYPENAME AS PTypeName,CDATE,SHKEY,DDB.CREATEDATE, ");
sqlBuilder.Append(" (SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.SUSER) AS SUserName, ");
sqlBuilder.Append(" (SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.CREATEUSER) AS CREATEUSER, ");
sqlBuilder.Append(" (SELECT ORGA.ORGADESC FROM T_QM_ORGANIZATION ORGA WHERE ORGA.ORGAID = DDB.SDEPT) AS SOrgaDesc ");
sqlBuilder.Append(" FROM T_QM_ZPDDB DDB LEFT JOIN T_QM_ZPTYPE TYP ON DDB.PTYPE = TYP.PID ");
sqlBuilder.Append(" WHERE DDB.FLGDEL = 0 ");
//创建人或者处理人等于当前用户
sqlBuilder.Append(" AND (DDB.CREATEUSER = @CREATEUSER OR DDB.SUSER = @CREATEUSER OR (DDB.SUSER IS NULL AND DDB.SDEPT = @SDEPT))");
parameters.Add(new DataParameter { ParameterName = "CREATEUSER", DataType = DbType.String, Value = userId });
parameters.Add(new DataParameter { ParameterName = "SDEPT", DataType = DbType.String, Value = OrganID });
//关键字
if (!string.IsNullOrEmpty(condition.Shkey))
{
sqlBuilder.Append(" AND DDB.SHKEY LIKE '%" + condition.Shkey + "%'");
}
//问题类型
if (!string.IsNullOrEmpty(condition.PType))
{
sqlBuilder.Append(" AND DDB.PTYPE = @PTYPE ");
parameters.Add(new DataParameter { ParameterName = "PTYPE", DataType = DbType.String, Value = condition.PType });
}
//未解决标识
if (!string.IsNullOrEmpty(condition.Ecind))
{
sqlBuilder.Append(" AND DDB.ECIND = @ECIND ");
parameters.Add(new DataParameter { ParameterName = "ECIND", DataType = DbType.String, Value = condition.Ecind });
}
sqlBuilder.Append(" ORDER BY DDB.CREATEDATE DESC ");
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题列表
/// <summary>
/// 获取问题列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetProblemList(SupportInteraction condition, DataPage page, string userId, string OrganID)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = this.GetQueryProblemSql(condition, ref parameters, userId, OrganID);
//分页关键字段及排序
page.KeyName = "PID";
if (string.IsNullOrEmpty(page.SortExpression))
{
page.SortExpression = "CREATEDATE DESC";
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
page = session.GetDataPage<SupportInteraction>(sql, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题列表查询语句
/// <summary>
/// 获取问题列表查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetQueryProblemSql(SupportInteraction condition, ref List<DataParameter> parameters, string userId, string OrganID)
{
StringBuilder sqlBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append(" SELECT DDB.PID,DDB.PSEQU,DDB.PTYPE,DDB.PDESP,DDB.SDEPT,DDB.SUSER,DDB.SOLVE,DDB.SDAYS,DDB.ECIND,TYP.PTYPENAME AS PTypeName,CDATE,SHKEY,DDB.CREATEDATE, ");
sqlBuilder.Append(" (SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.CREATEUSER) AS CUserName, ");
sqlBuilder.Append(" (SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.SUSER) AS SUserName, ");
sqlBuilder.Append(" (SELECT ORGA.ORGADESC FROM T_QM_ORGANIZATION ORGA WHERE ORGA.ORGAID = DDB.SDEPT) AS SOrgaDesc ");
sqlBuilder.Append(" FROM T_QM_ZPDDB DDB LEFT JOIN T_QM_ZPTYPE TYP ON DDB.PTYPE = TYP.PID ");
sqlBuilder.Append(" WHERE DDB.FLGDEL = 0 ");
//创建人或者处理人等于当前用户
sqlBuilder.Append(" AND (DDB.CREATEUSER = @CREATEUSER OR DDB.SUSER = @CREATEUSER OR (DDB.SUSER IS NULL AND DDB.SDEPT = @SDEPT))");
parameters.Add(new DataParameter { ParameterName = "CREATEUSER", DataType = DbType.String, Value = userId });
parameters.Add(new DataParameter { ParameterName = "SDEPT", DataType = DbType.String, Value = OrganID });
//关键字
if (!string.IsNullOrEmpty(condition.Shkey))
{
sqlBuilder.Append(" AND DDB.SHKEY LIKE '%" + condition.Shkey + "%'");
}
//问题类型
if (!string.IsNullOrEmpty(condition.PType))
{
sqlBuilder.Append(" AND DDB.PTYPE = @PTYPE ");
parameters.Add(new DataParameter { ParameterName = "PTYPE", DataType = DbType.String, Value = condition.PType });
}
//未解决标识
if (!string.IsNullOrEmpty(condition.Ecind))
{
sqlBuilder.Append(" AND DDB.ECIND = @ECIND ");
parameters.Add(new DataParameter { ParameterName = "ECIND", DataType = DbType.String, Value = condition.Ecind });
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题编号
/// <summary>
/// 获取问题编号
/// </summary>
/// <returns></returns>
public int GetSupportInteractionSeq(IDataSession session)
{
int returnSeq = 1;
string sql = " SELECT MAX(PSEQU) FROM T_QM_ZPDDB ";
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = this.ChangeSqlByDB(sql, session);
Object obj = session.ExecuteSqlScalar(sql, parameters.ToArray());
if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
{
returnSeq = Convert.ToInt32(obj) + 1;
}
return returnSeq;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取处理记录列表
/// <summary>
/// 获取处理记录列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetSIDealList(ZPDealInfo condition, DataPage page)
{
StringBuilder sb = new StringBuilder();
List<DataParameter> parameters = new List<DataParameter>();
try
{
sb.Append(@" SELECT ACTION,ACTIONTIME,
CUSER.USERNAME AS SUserName,
ORGA.ORGADESC AS SOrgaDesc
FROM T_QM_ZPDEALINFO DEAL
LEFT JOIN T_QM_ZPDDB DDB ON DEAL.ZPDDB_PID = DDB.PID
LEFT JOIN T_QM_USER CUSER ON CUSER.USERID = DEAL.SUSER
LEFT JOIN T_QM_ORGANIZATION ORGA ON ORGA.ORGAID = CUSER.ORGANID
WHERE DEAL.ZPDDB_PID = @ZPDDB_PID ");
parameters.Add(new DataParameter { ParameterName = "ZPDDB_PID", DataType = DbType.String, Value = condition.ZPDDBPID });
//分页关键字段及排序
page.KeyName = "PID";
if (string.IsNullOrEmpty(page.SortExpression))
{
page.SortExpression = "ACTIONTIME ASC";
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
string sql = this.ChangeSqlByDB(sb.ToString(), session);
page = session.GetDataPage<ZPDealInfo>(sql, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public int Insert(SupportInteraction model)
{
int count = 0;
try
{
using (MutexLock myLock = new MutexLock("SupportInteraction"))
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
model.PSequ = GetSupportInteractionSeq(session);
//插入基本信息
count = session.Insert<SupportInteraction>(model);
//插入支持交互记录
InsertDealInfo(session, model, "创建");
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 提交
/// <summary>
/// 提交
/// </summary>
/// <returns>插入行数</returns>
public int UpdateSupportInteraction(SupportInteraction model, SupportInteraction userModel)
{
List<DataParameter> parameters = new List<DataParameter>();
string sql = null;
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
sql = " UPDATE T_QM_ZPDDB SET SDEPT=@SDEPT,SUSER=@SUSER WHERE PID=@PID ";
//处理人为空时清理原来的处理人
if (!string.IsNullOrEmpty(model.SUser))
{
parameters.Add(new DataParameter { ParameterName = "SUSER", DataType = DbType.String, Value = model.SUser });
}
else
{
parameters.Add(new DataParameter { ParameterName = "SUSER", DataType = DbType.String, Value = DBNull.Value });
}
parameters.Add(new DataParameter { ParameterName = "SDEPT", DataType = DbType.String, Value = model.SDept });
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = model.PID });
sql = this.ChangeSqlByDB(sql, session);
count = session.ExecuteSql(sql, parameters.ToArray());
sql = " SELECT ORGADESC AS SOrgaDesc FROM T_QM_ORGANIZATION WHERE ORGAID=@SDEPT ";
parameters.Clear();
parameters.Add(new DataParameter { ParameterName = "SDEPT", DataType = DbType.String, Value = model.SDept });
sql = this.ChangeSqlByDB(sql, session);
SupportInteraction orgaModel = session.Get<SupportInteraction>(sql, parameters.ToArray());
//流程信息
string dealInfoMessage = "转交至[" + orgaModel.SOrgaDesc + "]";
//用户信息不为空时
if (userModel != null && !string.IsNullOrEmpty(userModel.SUserName))
{
dealInfoMessage = "转交至[" + orgaModel.SOrgaDesc + "]-[" + userModel.SUserName + "]";
}
//插入支持交互记录
InsertDealInfo(session, model, dealInfoMessage);
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取指定用户的邮箱
/// <summary>
/// 获取用户邮箱信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public SupportInteraction GetUserModel(SupportInteraction model)
{
List<DataParameter> parameters = new List<DataParameter>();
try
{
SupportInteraction userModel = null;
//提交人为空时返回
if (model == null || string.IsNullOrEmpty(model.SUser))
{
return userModel;
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
string sql = null;
//查询处理人员名称
sql = " SELECT USERNAME AS SUserName,EMAIL AS Email FROM T_QM_USER WHERE USERID=@USERID ";
parameters.Add(new DataParameter { ParameterName = "USERID", DataType = DbType.String, Value = model.SUser });
sql = this.ChangeSqlByDB(sql, session);
userModel = session.Get<SupportInteraction>(sql, parameters.ToArray());
}
return userModel;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 发送邮件提醒
/// <summary>
/// 给处理用户发送邮件提醒
/// </summary>
/// <param name="userModel"></param>
private void SentMail(SupportInteraction userModel)
{
//如果提交的用户不为空时,给用户发送邮件提醒
}
#endregion
#region 解决问题
/// <summary>
/// 解决问题
/// </summary>
/// <returns>插入行数</returns>
public int SloveSupportInteraction(SupportInteraction model)
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sb = new StringBuilder();
string sql = null;
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
sb.Append(" UPDATE T_QM_ZPDDB SET SOLVE=@SOLVE,SHKEY=@SHKEY,ECIND='1',CDATE=@CDATE,SDAYS=@SDAYS,SUSER=@SUSER ");
if (!string.IsNullOrEmpty(model.IsRefer))
{
sb.Append(" ,ISREFER=@ISREFER,REFER=@REFER ");
parameters.Add(new DataParameter { ParameterName = "ISREFER", DataType = DbType.String, Value = model.IsRefer });
parameters.Add(new DataParameter { ParameterName = "REFER", DataType = DbType.String, Value = model.Refer });
}
sb.Append(" WHERE PID=@PID ");
parameters.Add(new DataParameter { ParameterName = "SOLVE", DataType = DbType.String, Value = model.Solve });
parameters.Add(new DataParameter { ParameterName = "SHKEY", DataType = DbType.String, Value = model.Shkey });
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = model.PID });
parameters.Add(new DataParameter { ParameterName = "CDATE", DataType = DbType.DateTime, Value = model.CDate });
parameters.Add(new DataParameter { ParameterName = "SDAYS", DataType = DbType.Decimal, Value = model.SDays });
parameters.Add(new DataParameter { ParameterName = "SUSER", DataType = DbType.String, Value = model.SUser });
sql = this.ChangeSqlByDB(sb.ToString(), session);
count = session.ExecuteSql(sql, parameters.ToArray());
//插入支持交互记录
InsertDealInfo(session, model, "解决");
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入支持交互处理记录
/// <summary>
/// 插入支持交互处理记录
/// </summary>
/// <param name="session"></param>
/// <param name="model"></param>
private void InsertDealInfo(IDataSession session, SupportInteraction model, string flowName)
{
//交互处理表
ZPDealInfo zpDealInfo = new ZPDealInfo();
zpDealInfo.PID = Guid.NewGuid().ToString();
zpDealInfo.ZPDDBPID = model.PID;
zpDealInfo.SUser = model.CreateUser;
zpDealInfo.Action = flowName;
zpDealInfo.ActionTime = DateTime.Now;
session.Insert<ZPDealInfo>(zpDealInfo);
}
#endregion
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>*信息</returns>
public SupportInteraction Get(SupportInteraction model)
{
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
model = session.Get<SupportInteraction>(model);
}
return model;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>*信息</returns>
public SupportInteraction GetInfo(SupportInteraction condition)
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sb = new StringBuilder();
string sql = null;
try
{
sb.Append(@" SELECT DDB.PID,DDB.PSEQU,DDB.PTYPE,DDB.PDESP,DDB.SDEPT,DDB.SUSER,DDB.SOLVE,DDB.REFER,
DDB.ECIND,TYP.PTYPENAME AS PTypeName,SHKEY,DDB.CREATEDATE,DDB.CREATEUSER,DDB.ATTCHFILENAME,DDB.ATTCHFILE,
(SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.SUSER) AS SUserName,
(SELECT USERNAME FROM T_QM_USER CUSER WHERE CUSER.USERID = DDB.CREATEUSER) AS CUserName,
(SELECT ORGA.ORGADESC FROM T_QM_ORGANIZATION ORGA WHERE ORGA.ORGAID = DDB.SDEPT) AS SOrgaDesc
FROM T_QM_ZPDDB DDB LEFT JOIN T_QM_ZPTYPE TYP ON DDB.PTYPE = TYP.PID
WHERE DDB.FLGDEL = 0 AND DDB.PID = @PID ");
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = condition.PID });
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sb.ToString(), session);
//获取信息
condition = session.Get<SupportInteraction>(sql, parameters.ToArray());
}
return condition;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 判断用户的机构是否在级流程中
/// <summary>
/// 判断用户的机构是否在级流程中
/// </summary>
/// <returns>数据页</returns>
public int CheckCurrentUserInFlowLevel(string flowLevel, string orgaID)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
Object obj = null;
try
{
sql = " SELECT COUNT(*) FROM T_QM_ZPFLOW WHERE FLOWLEVEL = @FLOWLEVEL AND SDEPT = @SDEPT ";
parameters.Add(new DataParameter { ParameterName = "FLOWLEVEL", DataType = DbType.Int32, Value = flowLevel });
parameters.Add(new DataParameter { ParameterName = "SDEPT", DataType = DbType.String, Value = orgaID });
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
obj = session.ExecuteSqlScalar(sql, parameters.ToArray());
}
return obj == null ? 0 : Convert.ToInt32(obj);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取指定处理机构列表
/// <summary>
/// 获取指定处理机构列表
/// </summary>
/// <returns>数据页</returns>
public List<ZPFlow> GetNextFlowLevel(string flowLevel)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
List<ZPFlow> resultList = null;
try
{
sql = " SELECT PID,SDEPT,(SELECT ORGA.ORGADESC FROM T_QM_ORGANIZATION ORGA WHERE ORGA.ORGAID = SDEPT) AS SOrgaDesc FROM T_QM_ZPFLOW WHERE FLOWLEVEL = @FLOWLEVEL ";
parameters.Add(new DataParameter { ParameterName = "FLOWLEVEL", DataType = DbType.Int32, Value = flowLevel });
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
resultList = session.GetList<ZPFlow>(sql, parameters.ToArray()).ToList<ZPFlow>();
}
return resultList;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取所有机构列表
/// <summary>
/// 获取所有机构列表
/// </summary>
/// <returns>数据页</returns>
public List<ZPFlow> GetAllFlowLevel()
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
List<ZPFlow> resultList = null;
try
{
sql = " SELECT ORGAID AS SDEPT,ORGADESC AS SOrgaDesc FROM T_QM_ORGANIZATION ";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
resultList = session.GetList<ZPFlow>(sql, parameters.ToArray()).ToList<ZPFlow>();
}
return resultList;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}