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.
954 lines
37 KiB
954 lines
37 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.DAL;
|
|
using QMAPP.FJC.DAL.ODS;
|
|
using QMAPP.FJC.Entity.Andon;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.Entity.MaximoDataDB;
|
|
using QMAPP.FJC.Entity.ODS;
|
|
using QMAPP.MD.Entity;
|
|
using QMFrameWork.Data;
|
|
using QMFrameWork.Log;
|
|
|
|
namespace QMAPP.FJC.DAL.Andon
|
|
{
|
|
public class AndonCallDAL : BaseDAL
|
|
{
|
|
|
|
#region CallReason
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>*信息</returns>
|
|
public CallReasonEntity Get(CallReasonEntity model)
|
|
{
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//获取信息
|
|
model = session.Get<CallReasonEntity>(model);
|
|
}
|
|
return model;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "获取信息"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataPage GetList(CallReasonEntity condition, DataPage page)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = this.GetCallReasonListSql(condition, ref parameters);
|
|
|
|
#region 排序
|
|
//分页关键字段及排序
|
|
page.KeyName = "PID";
|
|
if (string.IsNullOrEmpty(page.SortExpression))
|
|
{
|
|
page.SortExpression = "CALL_TYPE DESC";
|
|
}
|
|
else
|
|
{
|
|
//按照标题排序
|
|
//if (page.SortExpression.IndexOf("STATUSTXT") > -1)
|
|
//{
|
|
// page.SortExpression = page.SortExpression.Replace("STATUSTXT", "STATUS");
|
|
//}
|
|
//if (page.SortExpression.IndexOf("ISCONTROLTXT") > -1)
|
|
//{
|
|
// page.SortExpression = page.SortExpression.Replace("ISCONTROLTXT", "ISCONTROL");
|
|
//}
|
|
//if (page.SortExpression.IndexOf("PROCESSTYPETXT") > -1)
|
|
//{
|
|
// page.SortExpression = page.SortExpression.Replace("PROCESSTYPETXT", "PROCESSTYPE");
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
page = session.GetDataPage<CallReasonEntity>(sql, parameters.ToArray(), page);
|
|
}
|
|
return page;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "获取列表"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
//获取一个实体
|
|
public CallReasonEntity GetCallReason(string pid)
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
string sql = "SELECT * FROM T_AD_CALLREASON WHERE PID='" + pid + "'";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.Get<CallReasonEntity>(sql, parameters.ToArray());
|
|
}
|
|
}
|
|
//获取呼叫原因的数据 查询表[T_AD_CALLREASON]
|
|
public List<CallReasonEntity> GetCallReasonList(CallReasonEntity model)
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
string sql = this.GetCallReasonListSql(model, ref parameters);
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<CallReasonEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
//sql语句
|
|
private string GetCallReasonListSql(CallReasonEntity model, ref List<DataParameter> parameters)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sqlBuilder.AppendLine(" SELECT U.PID ");
|
|
sqlBuilder.AppendLine(" ,U.CALL_TYPE");
|
|
sqlBuilder.AppendLine(" ,U.CALL_REASION");
|
|
sqlBuilder.AppendLine(" ,U.FACTORY_CODE");
|
|
sqlBuilder.AppendLine(" ,U.PARENTID");
|
|
sqlBuilder.AppendLine(" ,U.CREATEUSER");
|
|
sqlBuilder.AppendLine(" ,U.CREATEDATE");
|
|
sqlBuilder.AppendLine(" ,U.UPDATEUSER");
|
|
sqlBuilder.AppendLine(" ,U.UPDATEDATE");
|
|
sqlBuilder.AppendLine(" ,B.USERNAME AS CREATEUSERNAME");
|
|
sqlBuilder.AppendLine(" ,M.USERNAME AS UPDATEUSERNAME");
|
|
sqlBuilder.AppendLine(" FROM T_AD_CALLREASON U ");
|
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER B ON B.USERID = U.CREATEUSER ");
|
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER M ON M.USERID = U.UPDATEUSER ");
|
|
|
|
//查询条件
|
|
|
|
//呼叫类型
|
|
if (string.IsNullOrEmpty(model.CALL_TYPE) == false)
|
|
{
|
|
whereBuilder.Append(" AND CALL_TYPE = @CALL_TYPE ");
|
|
parameters.Add(new DataParameter { ParameterName = "CALL_TYPE", DataType = DbType.String, Value = model.CALL_TYPE });
|
|
}
|
|
//上级主键(为空的时候是一级)
|
|
//if (string.IsNullOrEmpty(model.PARENTID) == false)
|
|
//{
|
|
// whereBuilder.Append(" AND PARENTID = @PARENTID ");
|
|
// parameters.Add(new DataParameter
|
|
// {
|
|
// ParameterName = "PARENTID",
|
|
// DataType = DbType.String,
|
|
// Value = model.PARENTID
|
|
// });
|
|
//}
|
|
//else
|
|
//{
|
|
// whereBuilder.Append(" AND ( PARENTID is NULL or PARENTID = '' ) ");
|
|
//}
|
|
|
|
|
|
if (whereBuilder.Length > 0)
|
|
{
|
|
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
|
}
|
|
return sqlBuilder.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 插入
|
|
|
|
public int InsertCallReason(CallReasonEntity model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//插入基本信息
|
|
count = session.Insert(model);
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新
|
|
|
|
public int UpdateCallReason(CallReasonEntity model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
count = session.Update(model);
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
|
|
public int DeleteCallReason(CallReasonEntity model)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
int count = 0;
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//删除基本信息
|
|
count = session.Delete<CallReasonEntity>(model);
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "数据层-删除信息"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region T_AD_CALLLOG
|
|
|
|
// 根据选择的呼叫原因生成呼叫记录写入表[T_AD_CALLLOG]
|
|
public int InsertCallLog(CallLogEntity model)
|
|
{
|
|
try
|
|
{
|
|
int count;
|
|
|
|
if (BaseSession != null)
|
|
{
|
|
//插入基本信息
|
|
count = BaseSession.Insert(model);
|
|
////临时插入OutBox短信猫发送
|
|
//var parameters = new List<DataParameter>();
|
|
//var sql = "INSERT INTO OutBox ([username],[Mbno],[Msg],[SendTime],[ComPort],[Report]) VALUES('1','18686613360','" + model.MESSAGE + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','1')";
|
|
//count += BaseSession.ExecuteSql(sql, parameters.ToArray());
|
|
return count;
|
|
}
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//插入基本信息
|
|
count = session.Insert(model);
|
|
return count;
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
//获取状态为“正在呼叫”的呼叫记录,判断是否超过应答超时时间;
|
|
public List<CallLogEntity> GetCallLogTimeOutList()
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
string sql = "SELECT * FROM T_AD_CALLLOG WHERE CALL_STATE = '0'";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<CallLogEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
//获取呼叫记录的数据 查询表[T_AD_CALLLOG]
|
|
public List<CallLogEntity> GetCallLogList(CallLogEntity model)
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
string sql = this.GetCallLogListSql(model, ref parameters);
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<CallLogEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
//获取呼叫次数
|
|
public List<CallLogEntity> GetCallLogCount(CallLogEntity condition)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
//if (condition.isFirst == "1")
|
|
//{
|
|
// sql = "select '" + condition .CALL_TYPE+ "' as CALL_TYPE, MACHINECODDE,MACHINENAME as MACHINECODDE_NAME from T_BD_MACHINEINFO";
|
|
//}
|
|
//else
|
|
//{
|
|
// sql = "SELECT [CALL_TYPE],[MACHINECODDE],count([MACHINECODDE]) as CALL_COUNT FROM [T_AD_CALLLOG] where CALL_STATE in( '0','1','2') and CALL_TYPE = '" + condition.CALL_TYPE + "' group by [CALL_TYPE] ,[MACHINECODDE]";
|
|
//}
|
|
sql = "SELECT [CALL_TYPE],[WORKLOC_CODE] as MACHINECODDE,count([WORKLOC_CODE]) as CALL_COUNT FROM [T_AD_CALLLOG] where CALL_STATE in( '0','1','2') and CALL_TYPE = '" + condition.CALL_TYPE + "' group by [CALL_TYPE] ,[WORKLOC_CODE]";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<CallLogEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
public List<CallLogEntity> GetCallLogCountNew(CallLogEntity condition)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
sql = "SELECT [CALL_TYPE],[WORKLOC_CODE] as MACHINECODDE,count([WORKLOC_CODE]) as CALL_COUNT FROM [T_AD_CALLLOG] where CALL_STATE in( '0','1','2') group by [CALL_TYPE] ,[WORKLOC_CODE]";
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<CallLogEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
public List<DivStyleEntity> GetDivStyle(string type)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
sql = "SELECT * FROM [T_AD_DivStyle] where type='" + type + "'";
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<DivStyleEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
public DataPage GetCallLogListWeb(CallLogEntity condition, DataPage page)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = this.GetCallLogListSqlWeb(condition, ref parameters);
|
|
|
|
#region 排序
|
|
//分页关键字段及排序
|
|
page.KeyName = "PID";
|
|
if (string.IsNullOrEmpty(page.SortExpression))
|
|
{
|
|
page.SortExpression = "UPDATEDATE DESC";
|
|
}
|
|
else
|
|
{
|
|
//按照标题排序
|
|
//if (page.SortExpression.IndexOf("STATUSTXT") > -1)
|
|
//{
|
|
// page.SortExpression = page.SortExpression.Replace("STATUSTXT", "STATUS");
|
|
//}
|
|
//if (page.SortExpression.IndexOf("ISCONTROLTXT") > -1)
|
|
//{
|
|
// page.SortExpression = page.SortExpression.Replace("ISCONTROLTXT", "ISCONTROL");
|
|
//}
|
|
//if (page.SortExpression.IndexOf("PROCESSTYPETXT") > -1)
|
|
//{
|
|
// page.SortExpression = page.SortExpression.Replace("PROCESSTYPETXT", "PROCESSTYPE");
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
page = session.GetDataPage<CallLogEntity>(sql, parameters.ToArray(), page);
|
|
}
|
|
return page;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "获取列表"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
//sql语句
|
|
private string GetCallLogListSql(CallLogEntity model, ref List<DataParameter> parameters)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sqlBuilder.AppendLine(" SELECT C.*,M.MACHINENAME AS MACHINECODDE_NAME ");
|
|
|
|
sqlBuilder.AppendLine(" FROM T_AD_CALLLOG C ");
|
|
sqlBuilder.AppendLine(" LEFT JOIN T_BD_MACHINEINFO M ON M.MACHINECODDE = C.MACHINECODDE ");
|
|
sqlBuilder.AppendLine(" WHERE C.CALL_STATE in ('0','1','2','5') ");
|
|
|
|
//查询条件
|
|
|
|
//工厂
|
|
if (string.IsNullOrEmpty(model.FACTORY_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.FACTORY_CODE = @FACTORY_CODE ");
|
|
parameters.Add(new DataParameter { ParameterName = "FACTORY_CODE", DataType = DbType.String, Value = model.FACTORY_CODE });
|
|
}
|
|
//工位
|
|
if (string.IsNullOrEmpty(model.WORKLOC_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.WORKLOC_CODE = @WORKLOC_CODE ");
|
|
parameters.Add(new DataParameter { ParameterName = "WORKLOC_CODE", DataType = DbType.String, Value = model.WORKLOC_CODE });
|
|
}
|
|
//工作中心
|
|
if (string.IsNullOrEmpty(model.WORKCENTER_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.WORKCENTER_CODE = @WORKCENTER_CODE ");
|
|
parameters.Add(new DataParameter { ParameterName = "WORKCENTER_CODE", DataType = DbType.String, Value = model.WORKCENTER_CODE });
|
|
}
|
|
//类型
|
|
if (string.IsNullOrEmpty(model.CALL_TYPE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.CALL_TYPE = @CALL_TYPE ");
|
|
parameters.Add(new DataParameter { ParameterName = "CALL_TYPE", DataType = DbType.String, Value = model.CALL_TYPE });
|
|
}
|
|
|
|
|
|
if (whereBuilder.Length > 0)
|
|
{
|
|
sqlBuilder.Append(whereBuilder);
|
|
}
|
|
|
|
sqlBuilder.AppendLine(" ORDER BY C.UPDATEDATE DESC");
|
|
|
|
return sqlBuilder.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
private string GetCallLogListSqlWeb(CallLogEntity model, ref List<DataParameter> parameters)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sqlBuilder.AppendLine(" SELECT * FROM T_AD_CALLLOG ");
|
|
|
|
//查询条件
|
|
//设备
|
|
if (string.IsNullOrEmpty(model.MACHINECODDE) == false)
|
|
{
|
|
sqlBuilder.AppendLine(" WHERE CALL_STATE in ('0','1','2') ");
|
|
|
|
whereBuilder.Append(" AND WORKLOC_CODE = @MACHINECODDE ");
|
|
parameters.Add(new DataParameter
|
|
{
|
|
ParameterName = "MACHINECODDE",
|
|
DataType = DbType.String,
|
|
Value = model.MACHINECODDE
|
|
});
|
|
}
|
|
else
|
|
{
|
|
sqlBuilder.AppendLine(" WHERE 1=1 ");
|
|
}
|
|
//工厂
|
|
if (string.IsNullOrEmpty(model.FACTORY_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND FACTORY_CODE = @FACTORY_CODE ");
|
|
parameters.Add(new DataParameter { ParameterName = "FACTORY_CODE", DataType = DbType.String, Value = model.FACTORY_CODE });
|
|
}
|
|
//工位
|
|
if (string.IsNullOrEmpty(model.WORKLOC_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND WORKLOC_CODE = @WORKLOC_CODE");
|
|
parameters.Add(new DataParameter { ParameterName = "WORKLOC_CODE", DataType = DbType.String, Value = model.WORKLOC_CODE });
|
|
}
|
|
//工作中心
|
|
if (string.IsNullOrEmpty(model.WORKCENTER_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND WORKCENTER_CODE = @WORKCENTER_CODE");
|
|
parameters.Add(new DataParameter { ParameterName = "WORKCENTER_CODE", DataType = DbType.String, Value = model.WORKCENTER_CODE });
|
|
}
|
|
//类型
|
|
if (string.IsNullOrEmpty(model.CALL_TYPE) == false)
|
|
{
|
|
whereBuilder.Append(" AND CALL_TYPE = @CALL_TYPE ");
|
|
parameters.Add(new DataParameter { ParameterName = "CALL_TYPE", DataType = DbType.String, Value = model.CALL_TYPE });
|
|
}
|
|
//状态
|
|
if (string.IsNullOrEmpty(model.CALL_STATE) == false)
|
|
{
|
|
whereBuilder.Append(" AND CALL_STATE = @CALL_STATE ");
|
|
parameters.Add(new DataParameter
|
|
{
|
|
ParameterName = "CALL_STATE",
|
|
DataType = DbType.String,
|
|
Value = model.CALL_STATE
|
|
});
|
|
}
|
|
//呼叫时间
|
|
if (string.IsNullOrEmpty(model.STARTDATE) == false)
|
|
{
|
|
whereBuilder.Append(" AND CALL_TIME >= @STARTDATE");
|
|
parameters.Add(new DataParameter { ParameterName = "STARTDATE", DataType = DbType.String, Value = model.STARTDATE });
|
|
}
|
|
if (string.IsNullOrEmpty(model.ENDDATE) == false)
|
|
{
|
|
whereBuilder.Append(" AND CALL_TIME <= @ENDDATE");
|
|
parameters.Add(new DataParameter { ParameterName = "ENDDATE", DataType = DbType.String, Value = model.ENDDATE });
|
|
}
|
|
|
|
if (whereBuilder.Length > 0)
|
|
{
|
|
sqlBuilder.Append(whereBuilder);
|
|
}
|
|
|
|
|
|
return sqlBuilder.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
// 呼叫状态下重置删除表[T_AD_CALLLOG]
|
|
public int DeleteCallLog(CallLogEntity model)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
int count = 0;
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//删除基本信息
|
|
sqlBuilder.Append("DELETE T_AD_CALLLOG ");
|
|
sqlBuilder.Append("WHERE PID = @PID ");
|
|
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = model.PID });
|
|
count = session.ExecuteSql(sqlBuilder.ToString(), parameters.ToArray());
|
|
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
//更新状态 表[T_AD_CALLLOG]
|
|
public int UpdateCallLog(CallLogEntity model)
|
|
{
|
|
try
|
|
{
|
|
if (BaseSession != null)
|
|
{
|
|
//插入基本信息
|
|
return BaseSession.Update(model);
|
|
}
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.Update(model);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
//插入临时中间表
|
|
public int InsertMainTainOrder(MainTainOrder model, IDataSession Bsession)
|
|
{
|
|
return Bsession.Insert(model);
|
|
}
|
|
//更新临时中间表-呼叫完成时间
|
|
public int UpdateMainTainOrder(MainTainOrder model, IDataSession Bsession)
|
|
{
|
|
return Bsession.Update(model);
|
|
}
|
|
//查询临时中间表
|
|
public MainTainOrder SelectMainTainOrder(MainTainOrder model, IDataSession Bsession)
|
|
{
|
|
//return Bsession.Update(model);
|
|
return Bsession.Get<MainTainOrder>(model);
|
|
}
|
|
#endregion
|
|
|
|
#region T_AD_MESSAGETEMPLATE
|
|
|
|
//获取呼叫模板
|
|
public MessageTemplateEntity GetMessageTemplate(MessageTemplateEntity model)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = "SELECT * FROM T_AD_MESSAGETEMPLATE where 0=0 ";
|
|
|
|
if (string.IsNullOrEmpty(model.CALL_TYPE) == false)
|
|
{
|
|
sql += " AND CALL_TYPE = @CALL_TYPE";
|
|
parameters.Add(new DataParameter("CALL_TYPE", model.CALL_TYPE));
|
|
}
|
|
if (string.IsNullOrEmpty(model.FACTORY_CODE) == false)
|
|
{
|
|
sql += " AND FACTORY_CODE = @FACTORY_CODE";
|
|
parameters.Add(new DataParameter("FACTORY_CODE", model.FACTORY_CODE));
|
|
}
|
|
if (model.LEVEL > 0)
|
|
{
|
|
sql += " AND LEVEL = @LEVEL";
|
|
parameters.Add(new DataParameter("LEVEL", model.LEVEL));
|
|
}
|
|
if (string.IsNullOrEmpty(model.LANGUAGE) == false)
|
|
{
|
|
sql += " AND LANGUAGE = @LANGUAGE";
|
|
parameters.Add(new DataParameter("LANGUAGE", model.LANGUAGE));
|
|
}
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
// 对应多种数据库
|
|
//string sqlChange = this.ChangeSqlByDB(sql, session);
|
|
//获取信息
|
|
model = session.Get<MessageTemplateEntity>(sql, parameters.ToArray());
|
|
}
|
|
return model;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region T_AD_AREAKEEPER
|
|
|
|
////获取区域负责人
|
|
public AreaKeeperEntity GetAreaKeeper(AreaKeeperEntity model)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = "SELECT * FROM T_AD_AREAKEEPER where STATE=0 ";
|
|
|
|
if (string.IsNullOrEmpty(model.CALL_TYPE) == false)
|
|
{
|
|
sql += " AND CALL_TYPE = @CALL_TYPE";
|
|
parameters.Add(new DataParameter("CALL_TYPE", model.CALL_TYPE));
|
|
}
|
|
if (string.IsNullOrEmpty(model.FACTORY_CODE) == false)
|
|
{
|
|
sql += " AND FACTORY_CODE = @FACTORY_CODE";
|
|
parameters.Add(new DataParameter("FACTORY_CODE", model.FACTORY_CODE));
|
|
}
|
|
if (model.LEVEL > 0)
|
|
{
|
|
sql += " AND LEVEL = @LEVEL";
|
|
parameters.Add(new DataParameter("LEVEL", model.LEVEL));
|
|
}
|
|
if (string.IsNullOrEmpty(model.TEAM_CODE) == false)
|
|
{
|
|
sql += " AND TEAM_CODE = @TEAM_CODE";
|
|
parameters.Add(new DataParameter("TEAM_CODE", model.TEAM_CODE));
|
|
}
|
|
if (string.IsNullOrEmpty(model.WORKCENTER_CODE) == false)
|
|
{
|
|
sql += " AND WORKCENTER_CODE = @WORKCENTER_CODE";
|
|
parameters.Add(new DataParameter("WORKCENTER_CODE", model.WORKCENTER_CODE));
|
|
}
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
// 对应多种数据库
|
|
//string sqlChange = this.ChangeSqlByDB(sql, session);
|
|
//获取信息
|
|
model = session.Get<AreaKeeperEntity>(sql, parameters.ToArray());
|
|
}
|
|
return model;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region T_AD_LEVELSETTING
|
|
|
|
////获取呼叫等级
|
|
public List<LevelSettingEntity> GetLevelSetting(LevelSettingEntity model)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = "SELECT * FROM T_AD_LEVELSETTING where 1=1 ";
|
|
|
|
if (string.IsNullOrEmpty(model.CALL_TYPE) == false)
|
|
{
|
|
sql += " AND CALL_TYPE = @CALL_TYPE";
|
|
parameters.Add(new DataParameter("CALL_TYPE", model.CALL_TYPE));
|
|
}
|
|
if (string.IsNullOrEmpty(model.FACTORY_CODE) == false)
|
|
{
|
|
sql += " AND FACTORY_CODE = @FACTORY_CODE";
|
|
parameters.Add(new DataParameter("FACTORY_CODE", model.FACTORY_CODE));
|
|
}
|
|
if (model.LEVEL>0)
|
|
{
|
|
sql += " AND LEVEL = @LEVEL";
|
|
parameters.Add(new DataParameter("LEVEL", model.LEVEL));
|
|
}
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
// 对应多种数据库
|
|
//string sqlChange = this.ChangeSqlByDB(sql, session);
|
|
//获取信息
|
|
return session.GetList<LevelSettingEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
//return model;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region T_AD_MESSAGEQUEUE
|
|
|
|
//插入消息发送队列
|
|
public int InsertMessageQueue(MessageQueueEntity model)
|
|
{
|
|
try
|
|
{
|
|
if (BaseSession != null)
|
|
{
|
|
//插入基本信息
|
|
return BaseSession.Insert<MessageQueueEntity>(model);
|
|
}
|
|
else
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//插入基本信息
|
|
return session.Insert<MessageQueueEntity>(model);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
//更新消息发送队列
|
|
public int UpdateMessageQueue(MessageQueueEntity model)
|
|
{
|
|
try
|
|
{
|
|
if (BaseSession != null)
|
|
{
|
|
//插入基本信息
|
|
return BaseSession.Update<MessageQueueEntity>(model);
|
|
}
|
|
else
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//插入基本信息
|
|
return session.Update<MessageQueueEntity>(model);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
//查询未发送的短信和邮件
|
|
public List<MessageQueueEntity> GetMessageQueueList()
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
//string sql = this.GetQuerySql(condition, ref parameters);
|
|
string sql = "SELECT * FROM T_AD_MESSAGEQUEUE WHERE ISSENT = '0'";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<MessageQueueEntity>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public DataTable ExportExcelData(CallLogEntity model)
|
|
{
|
|
DataParameter[] parameters;
|
|
string sql = this.GetCallListSql(model, out parameters);
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetTable(sql, parameters);
|
|
}
|
|
}
|
|
|
|
|
|
private string GetCallListSql(CallLogEntity model, out DataParameter[] parameters)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
List<DataParameter> parametersList = new List<DataParameter>();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sqlBuilder.AppendLine(@"
|
|
SELECT C.[PID]
|
|
,C.[CALL_TYPE]
|
|
,C.[CALL_REASION]
|
|
,C.[FACTORY_CODE]
|
|
,C.[WORKLOC_CODE]
|
|
,C.[WORKCENTER_CODE]
|
|
,CONVERT(VARCHAR(19),C.[CALL_TIME],120) AS [CALL_TIME]
|
|
,C.[ANSWER_TIME]
|
|
,CONVERT(VARCHAR(19),C.[START_TIME],120) AS [START_TIME]
|
|
,CONVERT(VARCHAR(19),C.[COMPLETE_TIME],120) AS [COMPLETE_TIME]
|
|
,CASE C.[CALL_STATE] WHEN '0' THEN '正在呼叫' WHEN '1' THEN '已应答' WHEN '2' THEN '开始处理' WHEN '3' THEN '处理完成' WHEN '4' THEN '呼叫取消' ELSE '呼叫升级' END AS CALL_STATE_TXT
|
|
,C.[CALL_LEVEL]
|
|
,C.[HANDLER]
|
|
,h.PRODUCESHIFTNAME AS SHIFT_CODE_TXT
|
|
,C.[MACHINECODDE]
|
|
,C.[TEAM_CODE] AS TEAM_CODE_TXT
|
|
,C.[REMARK]
|
|
,C.[CREATEUSER]
|
|
,C.[CREATEDATE]
|
|
,C.[UPDATEUSER]
|
|
,C.[UPDATEDATE]
|
|
,C.[CALL_PROBLEM],w.WORKCENTER_NAME, L.WORKLOC_NAME,m.MACHINENAME as MACHINECODDE_NAME,u.USERNAME as HANDLER_NAME,
|
|
S.DetailTypeName AS CALL_TYPE_TXT
|
|
FROM T_AD_CALLLOG C
|
|
left join T_MD_WORKCENTER w on w.WORKCENTER_CODE = c.WORKCENTER_CODE
|
|
left join T_BD_PRODUCESHIFT h on h.PRODUCESHIFTTCODE = c.SHIFT_CODE
|
|
left join T_MD_WORKLOC L on L.WORKLOC_CODE = c.WORKLOC_CODE
|
|
left join t_bd_machineinfo m on m.machinecodde = c.machinecodde
|
|
left join T_QM_USER u on u.USERID = c.HANDLER
|
|
left join T_MD_CONFIGDETAIL S on S.DetailTypeCode= c.CALL_TYPE AND MainTypeCode='CALL_TYPE'");
|
|
|
|
//查询条件
|
|
//设备
|
|
if (string.IsNullOrEmpty(model.MACHINECODDE) == false)
|
|
{
|
|
sqlBuilder.AppendLine(" WHERE C.CALL_STATE in ('0','1','2') ");
|
|
|
|
whereBuilder.Append(" AND C.WORKLOC_CODE = @MACHINECODDE ");
|
|
parametersList.Add(new DataParameter
|
|
{
|
|
ParameterName = "MACHINECODDE",
|
|
DataType = DbType.String,
|
|
Value = model.MACHINECODDE
|
|
});
|
|
}
|
|
else
|
|
{
|
|
sqlBuilder.AppendLine(" WHERE 1=1 ");
|
|
}
|
|
//工厂
|
|
if (string.IsNullOrEmpty(model.FACTORY_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.FACTORY_CODE = @FACTORY_CODE ");
|
|
parametersList.Add(new DataParameter { ParameterName = "FACTORY_CODE", DataType = DbType.String, Value = model.FACTORY_CODE });
|
|
}
|
|
//工位
|
|
if (string.IsNullOrEmpty(model.WORKLOC_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.WORKLOC_CODE = @WORKLOC_CODE");
|
|
parametersList.Add(new DataParameter { ParameterName = "WORKLOC_CODE", DataType = DbType.String, Value = model.WORKLOC_CODE });
|
|
}
|
|
//工作中心
|
|
if (string.IsNullOrEmpty(model.WORKCENTER_CODE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.WORKCENTER_CODE = @WORKCENTER_CODE");
|
|
parametersList.Add(new DataParameter { ParameterName = "WORKCENTER_CODE", DataType = DbType.String, Value = model.WORKCENTER_CODE });
|
|
}
|
|
//类型
|
|
if (string.IsNullOrEmpty(model.CALL_TYPE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.CALL_TYPE = @CALL_TYPE ");
|
|
parametersList.Add(new DataParameter { ParameterName = "CALL_TYPE", DataType = DbType.String, Value = model.CALL_TYPE });
|
|
}
|
|
//状态
|
|
if (string.IsNullOrEmpty(model.CALL_STATE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.CALL_STATE = @CALL_STATE ");
|
|
parametersList.Add(new DataParameter
|
|
{
|
|
ParameterName = "C.CALL_STATE",
|
|
DataType = DbType.String,
|
|
Value = model.CALL_STATE
|
|
});
|
|
}
|
|
//呼叫时间
|
|
if (string.IsNullOrEmpty(model.STARTDATE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.CALL_TIME >= @STARTDATE");
|
|
parametersList.Add(new DataParameter { ParameterName = "STARTDATE", DataType = DbType.String, Value = model.STARTDATE });
|
|
}
|
|
if (string.IsNullOrEmpty(model.ENDDATE) == false)
|
|
{
|
|
whereBuilder.Append(" AND C.CALL_TIME <= @ENDDATE");
|
|
parametersList.Add(new DataParameter { ParameterName = "ENDDATE", DataType = DbType.String, Value = model.ENDDATE });
|
|
}
|
|
|
|
if (whereBuilder.Length > 0)
|
|
{
|
|
sqlBuilder.Append(whereBuilder);
|
|
}
|
|
|
|
parameters = parametersList.ToArray();
|
|
return sqlBuilder.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|