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.
1331 lines
52 KiB
1331 lines
52 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using QM.Exchange.Adapters.Mail;
|
|
using QM.Exchange.Adapters.SMS;
|
|
using QMAPP.BLL;
|
|
using QMAPP.BLL.Sys;
|
|
using QMAPP.Entity;
|
|
using QMAPP.Entity.Sys;
|
|
using QMAPP.FJC.BLL.Basic;
|
|
using QMAPP.FJC.BLL.Dict;
|
|
using QMAPP.FJC.BLL.FwMark;
|
|
using QMAPP.FJC.DAL.Andon;
|
|
using QMAPP.FJC.DAL.Basic;
|
|
using QMAPP.FJC.DAL.Equipment;
|
|
using QMAPP.FJC.Entity.Andon;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.Entity.MaximoDataDB;
|
|
using QMAPP.MD.BLL;
|
|
using QMAPP.MD.DAL;
|
|
using QMAPP.MD.Entity;
|
|
using QMFrameWork.Data;
|
|
using QMFrameWork.Log;
|
|
using Resource = QMAPP.FJC.Entity.Resource;
|
|
using WorkCenterDAL = QMAPP.MD.DAL.WorkCenterDAL;
|
|
using System.Data;
|
|
using System.Net.Mail;
|
|
|
|
namespace QMAPP.FJC.BLL.Andon
|
|
{
|
|
|
|
public class AndonCallBLL : BaseBLL
|
|
{
|
|
|
|
#region T_AD_CALLREASON
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>信息</returns>
|
|
public DataResult<CallReasonEntity> Get(CallReasonEntity model)
|
|
{
|
|
DataResult<CallReasonEntity> result = new DataResult<CallReasonEntity>();
|
|
try
|
|
{
|
|
result.Result = new AndonCallDAL().Get(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "获取信息!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataResult<DataPage> GetList(CallReasonEntity condition, DataPage page)
|
|
{
|
|
|
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
|
try
|
|
{
|
|
//获取信息列表
|
|
DataPage dataPage = new AndonCallDAL().GetList(condition, page);
|
|
|
|
#region 转换
|
|
List<CallReasonEntity> CallReasonInfoList = dataPage.Result as List<CallReasonEntity>;
|
|
var configDetailList = new ConfigDetailBLL().GetAllList("CALL_TYPE");
|
|
|
|
foreach (CallReasonEntity m in CallReasonInfoList)
|
|
{
|
|
//呼叫类型
|
|
var configDetail = configDetailList.FirstOrDefault(x => x.DetailTypeCode == m.CALL_TYPE.Trim());
|
|
if (configDetail != null)
|
|
m.CALL_TYPE_TXT = configDetail.DetailTypeName;
|
|
}
|
|
|
|
#endregion
|
|
|
|
result.Result = dataPage;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "获取列表!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
//获取呼叫原因的数据 查询表[T_AD_CALLREASON]
|
|
public CallReasonEntity GetCallReason(string pid)
|
|
{
|
|
try
|
|
{
|
|
return new AndonCallDAL().GetCallReason(pid);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取呼叫原因错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
//获取呼叫原因的数据 查询表[T_AD_CALLREASON]
|
|
public List<CallReasonEntity> GetCallReasonList(CallReasonEntity model)
|
|
{
|
|
try
|
|
{
|
|
return new AndonCallDAL().GetCallReasonList(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取呼叫原因错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 插入
|
|
|
|
public DataResult<int> InsertCallReason(CallReasonEntity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
//基本信息
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
try
|
|
{
|
|
|
|
result.Result = new AndonCallDAL().InsertCallReason(model);
|
|
result.IsSuccess = true;
|
|
|
|
result.Msg = Resource.MsgSuccess;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "插入表异常!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
}
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 更新
|
|
|
|
public DataResult<int> UpdateCallReason(CallReasonEntity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
model.UPDATEUSER = this.LoginUser.UserID;
|
|
model.UPDATEDATE = DateTime.Now;
|
|
|
|
try
|
|
{
|
|
result.Result = new AndonCallDAL().UpdateCallReason(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "更新表异常!" });
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
|
|
public DataResult<int> DeleteCallReason(string strs)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
string[] list = strs.Split(":".ToCharArray());
|
|
try
|
|
{
|
|
foreach (string str in list)
|
|
{
|
|
result.Result += this.DeleteMateriel(new CallReasonEntity { PID = str });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "逻辑层-删除!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// 删除信息
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>删除个数</returns>
|
|
public int DeleteMateriel(CallReasonEntity model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
count = new AndonCallDAL().DeleteCallReason(model);
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region T_AD_CALLLOG
|
|
|
|
public DataResult<DataPage> GetCallLogListWeb(CallLogEntity condition, DataPage page)
|
|
{
|
|
|
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
|
try
|
|
{
|
|
//获取信息列表
|
|
DataPage dataPage = new AndonCallDAL().GetCallLogListWeb(condition, page);
|
|
|
|
#region 转换
|
|
List<CallLogEntity> CallLogList = dataPage.Result as List<CallLogEntity>;
|
|
var configDetailList = new ConfigDetailBLL().GetAllList("CALL_TYPE");
|
|
DictManageBLL dictCallStateBll = new DictManageBLL(DictKind.CALL_STATE);
|
|
var userList = new UserManageBLL().GetAllUsers(new User());
|
|
var shiftList = new ProduceShiftBLL().GetWorkcenterShifts("All");
|
|
var teamList = new TeamBLL().GetAllTeam(new Team());
|
|
var workLocList = new WorkLocDAL().GetList(new WorkLoc());
|
|
var workCenterList = new WorkCenterDAL().GetWorkCenterList(new QMAPP.MD.Entity.WorkCenter());
|
|
var machineInfoList = new MachineInfoDAL().GetList(new MachineInfo());
|
|
|
|
foreach (CallLogEntity item in CallLogList)
|
|
{
|
|
if (item.START_TIME != null && item.START_TIME != DateTime.MinValue && item.COMPLETE_TIME != null && item.COMPLETE_TIME != DateTime.MinValue)
|
|
{
|
|
var handleTiem = "";
|
|
var timeSpan = ((DateTime)item.COMPLETE_TIME).Subtract((DateTime)item.START_TIME);
|
|
if (timeSpan.Days > 0)
|
|
{
|
|
handleTiem = timeSpan.Days + "天";
|
|
}
|
|
else if (timeSpan.Hours > 0)
|
|
{
|
|
handleTiem += timeSpan.Hours + "时";
|
|
}
|
|
else if (timeSpan.Minutes > 0)
|
|
{
|
|
handleTiem += timeSpan.Minutes + "分";
|
|
}
|
|
else if (timeSpan.Seconds >= 0)
|
|
{
|
|
handleTiem += timeSpan.Seconds + "秒";
|
|
}
|
|
item.HANDLER_TIME = handleTiem;
|
|
}
|
|
|
|
if (item.ANSWER_TIME == DateTime.MinValue)
|
|
{
|
|
item.ANSWER_TIME = null;
|
|
}
|
|
if (item.START_TIME == DateTime.MinValue)
|
|
{
|
|
item.START_TIME = null;
|
|
}
|
|
if (item.COMPLETE_TIME == DateTime.MinValue)
|
|
{
|
|
item.COMPLETE_TIME = null;
|
|
}
|
|
//呼叫类型
|
|
var configDetail = configDetailList.FirstOrDefault(x => x.DetailTypeCode == item.CALL_TYPE.Trim());
|
|
if (configDetail != null)
|
|
item.CALL_TYPE_TXT = configDetail.DetailTypeName;
|
|
item.CALL_STATE_TXT = dictCallStateBll.GetDictValue(item.CALL_STATE);
|
|
//处理人
|
|
if (!string.IsNullOrEmpty(item.HANDLER))
|
|
{
|
|
var user = userList.FirstOrDefault(x => x.UserID == item.HANDLER);
|
|
if (user != null)
|
|
item.HANDLER_NAME = user.UserName;
|
|
}
|
|
//班次
|
|
if (!string.IsNullOrEmpty(item.SHIFT_CODE))
|
|
{
|
|
var shift = shiftList.FirstOrDefault(x => x.PRODUCESHIFTTCODE == item.SHIFT_CODE);
|
|
if (shift != null)
|
|
item.SHIFT_CODE_TXT = shift.PRODUCESHIFTNAME;
|
|
}
|
|
//班组
|
|
if (!string.IsNullOrEmpty(item.TEAM_CODE))
|
|
{
|
|
var team = teamList.FirstOrDefault(x => x.TEAM_CODE == item.TEAM_CODE);
|
|
if (team != null)
|
|
item.TEAM_CODE_TXT = team.TEAM_NAME;
|
|
}
|
|
//工位
|
|
if (!string.IsNullOrEmpty(item.WORKLOC_CODE))
|
|
{
|
|
var workloc = workLocList.FirstOrDefault(x => x.WORKLOC_CODE == item.WORKLOC_CODE);
|
|
if (workloc != null)
|
|
item.WORKLOC_NAME = workloc.WORKLOC_NAME;
|
|
}
|
|
//工作中心
|
|
if (!string.IsNullOrEmpty(item.WORKCENTER_CODE))
|
|
{
|
|
var workCenter = workCenterList.FirstOrDefault(x => x.WORKCENTER_CODE == item.WORKCENTER_CODE);
|
|
if (workCenter != null)
|
|
item.WORKCENTER_NAME = workCenter.WORKCENTER_NAME;
|
|
}
|
|
//设备
|
|
if (!string.IsNullOrEmpty(item.MACHINECODDE))
|
|
{
|
|
var machineInfo = machineInfoList.FirstOrDefault(x => x.MACHINECODDE == item.MACHINECODDE);
|
|
if (machineInfo != null)
|
|
item.MACHINECODDE_NAME = machineInfo.MACHINENAME;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
result.Result = dataPage;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "获取列表!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
|
|
// 获取呼叫次数
|
|
public List<CallLogEntity> GetCallLogCount(CallLogEntity condition)
|
|
{
|
|
try
|
|
{
|
|
List<CallLogEntity> CallLogList = new AndonCallDAL().GetCallLogCount(condition);
|
|
var MachineInfoList = new MachineInfoBLL().GetAllList(new MachineInfo());
|
|
foreach (CallLogEntity item in CallLogList)
|
|
{
|
|
//设备
|
|
if (!string.IsNullOrEmpty(item.MACHINECODDE))
|
|
{
|
|
var MachineInfo = MachineInfoList.FirstOrDefault(x => x.MACHINECODDE == item.MACHINECODDE);
|
|
if (MachineInfo != null)
|
|
item.MACHINECODDE_NAME = MachineInfo.MACHINENAME;
|
|
}
|
|
}
|
|
return CallLogList;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取视频播放表错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
public List<CallLogEntity> GetCallLogCountNew(CallLogEntity condition)
|
|
{
|
|
try
|
|
{
|
|
List<CallLogEntity> CallLogList = new AndonCallDAL().GetCallLogCountNew(condition);
|
|
var MachineInfoList = new MachineInfoBLL().GetAllList(new MachineInfo());
|
|
foreach (CallLogEntity item in CallLogList)
|
|
{
|
|
//设备
|
|
if (!string.IsNullOrEmpty(item.MACHINECODDE))
|
|
{
|
|
var MachineInfo = MachineInfoList.FirstOrDefault(x => x.MACHINECODDE == item.MACHINECODDE);
|
|
if (MachineInfo != null)
|
|
item.MACHINECODDE_NAME = MachineInfo.MACHINENAME;
|
|
}
|
|
}
|
|
return CallLogList;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取视频播放表错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
public List<DivStyleEntity> GetDivStyle(string type)
|
|
{
|
|
List<DivStyleEntity> DivStyles = new AndonCallDAL().GetDivStyle(type);
|
|
|
|
return DivStyles;
|
|
}
|
|
// 获取呼叫记录的数据 查询表[T_AD_CALLLOG]
|
|
public List<CallLogEntity> GetCallLogList(CallLogEntity model)
|
|
{
|
|
try
|
|
{
|
|
//List<CallLogEntity> CallLogList = new List<CallLogEntity>();
|
|
var callLogList= new AndonCallDAL().GetCallLogList(model);
|
|
if (callLogList != null)
|
|
{
|
|
DictManageBLL dictCallStateBll = new DictManageBLL(DictKind.CALL_STATE);
|
|
var configDetailList = new ConfigDetailBLL().GetAllList("CALL_TYPE");
|
|
var userList = new UserManageBLL().GetAllUsers(new User());
|
|
foreach (var item in callLogList)
|
|
{
|
|
if (item.START_TIME != null && item.START_TIME != DateTime.MinValue && item.COMPLETE_TIME != null && item.COMPLETE_TIME != DateTime.MinValue)
|
|
{
|
|
var handleTiem = "";
|
|
var timeSpan = ((DateTime)item.START_TIME).Subtract((DateTime)item.COMPLETE_TIME);
|
|
if (timeSpan.Days > 0)
|
|
{
|
|
handleTiem = timeSpan.Days + "天";
|
|
}
|
|
else if (timeSpan.Hours > 0)
|
|
{
|
|
handleTiem += timeSpan.Hours + "时";
|
|
}
|
|
else if (timeSpan.Minutes > 0)
|
|
{
|
|
handleTiem += timeSpan.Minutes + "分";
|
|
}
|
|
else if (timeSpan.Seconds > 0)
|
|
{
|
|
handleTiem += timeSpan.Seconds + "秒";
|
|
}
|
|
item.HANDLER_TIME = handleTiem;
|
|
}
|
|
|
|
if (item.ANSWER_TIME == DateTime.MinValue)
|
|
{
|
|
item.ANSWER_TIME = null;
|
|
}
|
|
if (item.START_TIME == DateTime.MinValue)
|
|
{
|
|
item.START_TIME = null;
|
|
}
|
|
if (item.COMPLETE_TIME == DateTime.MinValue)
|
|
{
|
|
item.COMPLETE_TIME = null;
|
|
}
|
|
//转换显示状态
|
|
//item.CALL_STATE_TXT = System.Enum.GetName(typeof(AndonEnum.CallState), int.Parse(item.CALL_STATE));
|
|
//item.CALL_TYPE_TXT = System.Enum.GetName(typeof(AndonEnum.CallType), int.Parse(item.CALL_TYPE));
|
|
item.CALL_STATE_TXT = dictCallStateBll.GetDictValue(item.CALL_STATE);
|
|
//呼叫类型
|
|
var configDetail = configDetailList.FirstOrDefault(x => x.DetailTypeCode == item.CALL_TYPE.Trim());
|
|
if (configDetail != null)
|
|
item.CALL_TYPE_TXT = configDetail.DetailTypeName;
|
|
//处理人
|
|
if (!string.IsNullOrEmpty(item.HANDLER))
|
|
{
|
|
var user = userList.FirstOrDefault(x => x.UserID == item.HANDLER.Trim());
|
|
if (user != null)
|
|
item.HANDLER_NAME = user.UserName;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return callLogList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取视频播放表错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
//获取状态为“正在呼叫”的呼叫记录,判断是否超过应答超时时间;
|
|
public List<CallLogEntity> GetCallLogTimeOutList()
|
|
{
|
|
try
|
|
{
|
|
//List<CallLogEntity> CallLogList = new List<CallLogEntity>();
|
|
return new AndonCallDAL().GetCallLogTimeOutList();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取视频播放表错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
// 呼叫状态下重置删除表[T_AD_CALLLOG]
|
|
public DataResult<int> DeleteCallLog(string pid)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
var model = new CallLogEntity { PID = pid };
|
|
try
|
|
{
|
|
result.Result = new AndonCallDAL().DeleteCallLog(model);
|
|
result.IsSuccess = true;
|
|
result.Msg = Resource.MsgSuccess;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "呼叫状态下重置删除表[T_AD_CALLLOG]"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
}
|
|
return result;
|
|
}
|
|
//更新状态 表[T_AD_CALLLOG]
|
|
public DataResult<int> UpdateCallLog(CallLogEntity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>
|
|
{
|
|
IsSuccess = true,
|
|
Msg = Resource.MsgSuccess
|
|
};
|
|
try
|
|
{
|
|
if (model.ANSWER_TIME == null)
|
|
{
|
|
model.ANSWER_TIME = DateTime.MinValue;
|
|
}
|
|
if (model.START_TIME == null)
|
|
{
|
|
model.START_TIME = DateTime.MinValue;
|
|
}
|
|
if (model.COMPLETE_TIME == null)
|
|
{
|
|
model.COMPLETE_TIME = DateTime.MinValue;
|
|
}
|
|
model.UPDATEUSER = this.LoginUser.UserID;
|
|
model.UPDATEDATE = DateTime.Now;
|
|
result.Result = new AndonCallDAL().UpdateCallLog(model);
|
|
//////////////////////////////////////////
|
|
//// 因为临时表没有,暂时屏蔽。20180420 zxd
|
|
//// 放开 20180424 zxd
|
|
//等于维护,状态为“已应答”的呼叫插入临时表
|
|
//20180706 把状态为“已应答”修改为"开始处理".(因为已经取消“已应答”状态)
|
|
/*
|
|
if (model.CALL_TYPE == "0" && model.CALL_STATE == "2")
|
|
{
|
|
//插入临时表
|
|
//获取公司代码组织机构代码
|
|
var corp = new QMAPP.MD.DAL.CorpDAL().Get();
|
|
//报告人
|
|
string INSPECTOR = System.Configuration.ConfigurationManager.AppSettings["INSPECTOR"];
|
|
//流水号
|
|
string Wonum = "QD" + DateTime.Now.ToString("yyyyMMddhhmmss");
|
|
var mto = new MainTainOrder
|
|
{
|
|
PID = model.PID,
|
|
Siteid = corp.Siteid,
|
|
Orgid = corp.Orgid,
|
|
Wonum = Wonum,
|
|
WORKTYPE = "MEND",
|
|
STATUS = "INIT",
|
|
ASSETNUM = model.MACHINECODDE,
|
|
REPORTEDBY = INSPECTOR,
|
|
REPORTDATE = DateTime.Now,
|
|
READFLAG = 0,
|
|
ACTSTART = DateTime.Now
|
|
};
|
|
using (IDataSession Bsession = AppDataFactory.CreateSession("maindbMaximo"))
|
|
{
|
|
new AndonCallDAL().InsertMainTainOrder(mto, Bsession);
|
|
}
|
|
}
|
|
//等于维护,状态为“处理完成”的呼叫更新临时表
|
|
if (model.CALL_TYPE == "0" && model.CALL_STATE == "3")
|
|
{
|
|
using (IDataSession Bsession = AppDataFactory.CreateSession("maindbMaximo"))
|
|
{
|
|
var mto = new MainTainOrder
|
|
{
|
|
PID = model.PID,
|
|
};
|
|
var mainTainOrder = new AndonCallDAL().SelectMainTainOrder(mto, Bsession);
|
|
if (mainTainOrder != null)
|
|
{
|
|
mainTainOrder.READFLAG = 0;
|
|
mainTainOrder.ACTFINISH = DateTime.Now;
|
|
new AndonCallDAL().UpdateMainTainOrder(mainTainOrder, Bsession);
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
//////////////////////////////////////////
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "更新表异常!" });
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region T_AD_LEVELSETTING
|
|
|
|
//获取呼叫等级
|
|
public List<LevelSettingEntity> GetLevelSetting(LevelSettingEntity model)
|
|
{
|
|
try
|
|
{
|
|
return new AndonCallDAL().GetLevelSetting(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region T_AD_MESSAGEQUEUE
|
|
|
|
//插入消息发送队列
|
|
public int InsertMessageQueue(MessageQueueEntity model)
|
|
{
|
|
try
|
|
{
|
|
return new AndonCallDAL().InsertMessageQueue(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
//更新消息发送队列
|
|
public int UpdateMessageQueue(MessageQueueEntity model)
|
|
{
|
|
try
|
|
{
|
|
return new AndonCallDAL().UpdateMessageQueue(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
//查询未发送的短信和邮件
|
|
public List<MessageQueueEntity> GetMessageQueueList()
|
|
{
|
|
try
|
|
{
|
|
//List<CallLogEntity> CallLogList = new List<CallLogEntity>();
|
|
return new AndonCallDAL().GetMessageQueueList();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取视频播放表错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 发送消息(事物)
|
|
|
|
public DataResult<int> InsertCallLogAndMessageQueue(CallLogEntity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
try
|
|
{
|
|
|
|
|
|
AndonCallDAL andonDal = new AndonCallDAL();
|
|
andonDal.BaseSession = session;
|
|
|
|
//CallLog基本信息
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
//班次
|
|
var shift=new ProduceShiftBLL().GetWorkingShift(model.WORKCENTER_CODE);
|
|
model.SHIFT_CODE = shift != null ? shift.PRODUCESHIFTTCODE : "";
|
|
//班组
|
|
model.TEAM_CODE = GetTeamCode(model.FACTORY_CODE, model.SHIFT_CODE, model.CALL_TYPE);
|
|
//收件人(一个人改多个人)20180404
|
|
//model.RECIPIENT = GetRecipient(model.FACTORY_CODE, model.CALL_TYPE, model.CALL_LEVEL,
|
|
// model.TEAM_CODE);
|
|
|
|
var teamMemberList = GetRecipient(model.FACTORY_CODE,model.WORKCENTER_CODE, model.CALL_TYPE, model.CALL_LEVEL,
|
|
model.TEAM_CODE);
|
|
//翻译工位
|
|
List<WorkLoc> WorkLocList = new WorkLocDAL().GetList(new WorkLoc());
|
|
if (WorkLocList.Count>0)
|
|
{
|
|
var workLoc = WorkLocList.FirstOrDefault(x => x.WORKLOC_CODE == model.WORKLOC_CODE);
|
|
if (workLoc!=null)
|
|
{
|
|
model.WORKLOC_NAME = workLoc.WORKLOC_NAME;
|
|
}
|
|
}
|
|
//防止翻译后的工位为空
|
|
if (string.IsNullOrEmpty(model.WORKLOC_NAME))
|
|
{
|
|
model.WORKLOC_NAME = model.WORKLOC_CODE;
|
|
}
|
|
//消息模版
|
|
model.MESSAGE = GetMessageTemplate(model.FACTORY_CODE, model.CALL_TYPE,model.CALL_LEVEL, null,
|
|
model.CALL_REASION, model.CALL_TIME.ToString("yy-MM-dd hh:mm:ss"), model.WORKLOC_NAME);
|
|
|
|
//消息基本信息
|
|
//0.未发送 1.发送 ISSENT
|
|
//1.短信 2.邮件 MESSAGE_TYPE
|
|
var messageModel = new MessageQueueEntity
|
|
{
|
|
//PID = Guid.NewGuid().ToString(),
|
|
FACTORY_CODE = model.FACTORY_CODE,
|
|
//RECIPIENT = model.RECIPIENT,
|
|
LANGUAGE = null,
|
|
MESSAGE = model.MESSAGE,
|
|
CREATE_TIME = DateTime.Now,
|
|
MESSAGE_TYPE = "1",
|
|
ISSENT = "0"
|
|
};
|
|
//1.短信 2.邮件
|
|
//插入消息发送队列
|
|
result.Msg = "没找到发件人或模版,短信提醒失败.";
|
|
//多个消息人
|
|
var recipients = "";
|
|
// 开始事务
|
|
session.OpenTs();
|
|
if (!string.IsNullOrEmpty(messageModel.MESSAGE) && teamMemberList != null && teamMemberList.Count > 0)
|
|
{
|
|
foreach (var tme in teamMemberList)
|
|
{
|
|
messageModel.PID = Guid.NewGuid().ToString();
|
|
messageModel.RECIPIENT = tme.MEMBER_CODE;
|
|
recipients += tme.MEMBER_NAME + ","; ;
|
|
result.Result = andonDal.InsertMessageQueue(messageModel);
|
|
}
|
|
result.Msg = "呼叫原因: " + model.CALL_REASION + ",短信提醒发送成功.";
|
|
}
|
|
|
|
model.RECIPIENT = recipients;
|
|
model.REMARK = result.Msg;
|
|
//插入CallLog表
|
|
result.Result += andonDal.InsertCallLog(model);
|
|
|
|
|
|
// 事务提交
|
|
session.CommitTs();
|
|
result.IsSuccess = true;
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
session.RollbackTs();
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 报警
|
|
|
|
public bool ADSendtoLight(string workcenterCode)
|
|
{
|
|
FWMARKDeal fw = new FWMARKDeal();
|
|
return fw.ADSendtoLight(workcenterCode);
|
|
}
|
|
public bool ADCloseLight(string WORKCENTER_CODE)
|
|
{
|
|
FWMARKDeal fw = new FWMARKDeal();
|
|
return fw.ADCloseLight(WORKCENTER_CODE);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 发送邮件(事物)--不用了
|
|
|
|
public DataResult<int> UpdateCallLogAndInsertMessageQueue(CallLogEntity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
try
|
|
{
|
|
// 开始事务
|
|
session.OpenTs();
|
|
|
|
AndonCallDAL andonDal = new AndonCallDAL();
|
|
andonDal.BaseSession = session;
|
|
|
|
//CallLog基本信息
|
|
if (model.ANSWER_TIME == null)
|
|
{
|
|
model.ANSWER_TIME = DateTime.MinValue;
|
|
}
|
|
if (model.START_TIME == null)
|
|
{
|
|
model.START_TIME = DateTime.MinValue;
|
|
}
|
|
if (model.COMPLETE_TIME == null)
|
|
{
|
|
model.COMPLETE_TIME = DateTime.MinValue;
|
|
}
|
|
model.UPDATEUSER = this.LoginUser.UserID;
|
|
model.UPDATEDATE = DateTime.Now;
|
|
//插入CallLog表
|
|
result.Result = andonDal.UpdateCallLog(model);
|
|
|
|
//消息基本信息 ISSENT初始状态为0.未发送 1.发送
|
|
var messageModel = new MessageQueueEntity
|
|
{
|
|
PID = Guid.NewGuid().ToString(),
|
|
FACTORY_CODE = model.FACTORY_CODE,
|
|
MESSAGE_TYPE = model.MESSAGE_TYPE,
|
|
RECIPIENT = model.RECIPIENT,
|
|
LANGUAGE = model.LANGUAGE,
|
|
MESSAGE = model.MESSAGE,
|
|
CREATE_TIME = DateTime.Now,
|
|
ISSENT = "0"
|
|
};
|
|
//1.短信 2.邮件
|
|
//插入消息发送队列
|
|
result.Msg = "呼叫超时,但没找到发件人或模版,邮件提醒失败.";
|
|
if (!string.IsNullOrEmpty(messageModel.MESSAGE) && !string.IsNullOrEmpty(messageModel.RECIPIENT))
|
|
{
|
|
result.Result += andonDal.InsertMessageQueue(messageModel);
|
|
result.Msg = "呼叫原因: " + model.CALL_REASION + " ; 呼叫等级: " + model.CALL_LEVEL + "级. 邮件提醒发送成功!";
|
|
}
|
|
|
|
// 事务提交
|
|
session.CommitTs();
|
|
result.IsSuccess = true;
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
session.RollbackTs();
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 查询T_AD_CALLLOG 并发送状态为“未发送”的消息(任务)
|
|
|
|
//短信邮件发送
|
|
public void SendMsgAndMailForServer()
|
|
{
|
|
//com口
|
|
//var commPort = ConfigurationManager.AppSettings["CommPort"];
|
|
//短信
|
|
//SMSAdapter smsAdapter = new SMSAdapter(commPort);
|
|
|
|
//邮件参数
|
|
//var smtpServer = ConfigurationManager.AppSettings["SmtpServerAndon"];
|
|
//var senderPassword = ConfigurationManager.AppSettings["SenderPassword"];
|
|
//var doMain = ConfigurationManager.AppSettings["DoMainAndon"];
|
|
//var senderUser = ConfigurationManager.AppSettings["SenderUser"];
|
|
|
|
//邮件服务器
|
|
//SmtpServerInfo smtpServerInfo=new SmtpServerInfo(smtpServer,senderUser,senderPassword,doMain,senderUserEmail);
|
|
//MailHelper mailHelper=new MailHelper();
|
|
//获取未发送的消息列表
|
|
var messageQueueList = GetMessageQueueList();
|
|
foreach (var item in messageQueueList)
|
|
{
|
|
User user=new User();
|
|
UserManageBLL userManageBll=new UserManageBLL();
|
|
user.UserID = item.RECIPIENT;
|
|
user = userManageBll.Get(user);
|
|
|
|
var username = "信息异常";
|
|
var Mbno = ConfigurationManager.AppSettings["Mbno"];
|
|
var Msg = "报警人信息异常:" + item.MESSAGE;
|
|
var email = "";
|
|
if (user != null)
|
|
{
|
|
username = user.UserName;
|
|
Mbno = user.Tel;
|
|
Msg = item.MESSAGE;
|
|
email = user.Email;
|
|
}
|
|
else
|
|
{
|
|
LogManager.LogHelper.Info(new LogInfo()
|
|
{
|
|
Tag = "短信猫发送失败",
|
|
Info = "报警人员为空,userID:" + item.RECIPIENT
|
|
});
|
|
}
|
|
var SendTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
//var ComPort = "000";
|
|
//var Report = "新增短信猫";
|
|
|
|
// 1. 短信 2. 邮件
|
|
if (item.MESSAGE_TYPE == "1")
|
|
{
|
|
//暂时不用
|
|
//smsAdapter.SendMsg(user.Tel,item.MESSAGE);
|
|
|
|
//临时插入OutBox短信猫发送
|
|
|
|
if (string.IsNullOrEmpty(Mbno))
|
|
{
|
|
LogManager.LogHelper.Info(new LogInfo()
|
|
{
|
|
Tag = "短信猫发送失败",
|
|
Info = "报警人员手机号为空,userID:" + item.RECIPIENT
|
|
});
|
|
}
|
|
else
|
|
{
|
|
var parameters = new List<DataParameter>();
|
|
var sql = "INSERT INTO OutBox ([username],[Mbno],[Msg],[SendTime]) VALUES('" + username +
|
|
"','" + Mbno + "','" + Msg + "','" + SendTime + "')";
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
try
|
|
{
|
|
//插入发送短信
|
|
session.ExecuteSql(sql, parameters.ToArray());
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
Tag = "短信猫发送失败",
|
|
ErrorInfo = e
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
else if (item.MESSAGE_TYPE == "2")
|
|
{
|
|
//邮件
|
|
//MailInfo mailInfo = new MailInfo();
|
|
//mailInfo.Subject = subject;
|
|
//mailInfo.Content = item.MESSAGE;
|
|
//mailInfo.ToMail = new[] { email };
|
|
//mailHelper.SendMailForServer(mailInfo, smtpServerInfo);
|
|
|
|
//标题
|
|
var subject = ConfigurationManager.AppSettings["Subject"];
|
|
//发件人
|
|
var senderUserEmail = ConfigurationManager.AppSettings["SenderUserEmail"];
|
|
try
|
|
{
|
|
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient
|
|
{
|
|
Host = "10.4.8.19",
|
|
Port = 25,
|
|
UseDefaultCredentials = true
|
|
};
|
|
//client.Credentials = new NetworkCredential("ali90@adient.com","ZXasqw12!@");
|
|
//MailMessage msg = new MailMessage("qiwei.li@adient.com", " qiwei.li@adient.com ", "testmail", "testmail");
|
|
MailMessage msg = new MailMessage(senderUserEmail, email, subject, item.MESSAGE);
|
|
client.Send(msg);
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
Tag = "邮件发送失败",
|
|
ErrorInfo = e
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
//更新消息队列
|
|
item.ISSENT = "1";
|
|
item.SEND_TIME=DateTime.Now;
|
|
UpdateMessageQueue(item);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 超时发送邮件(任务)
|
|
//邮件
|
|
public void UpdateCallLogAndInsertMailForServer()
|
|
{
|
|
var callLogList = GetCallLogTimeOutList();
|
|
foreach (var item in callLogList)
|
|
{
|
|
//获取超时分钟数
|
|
LevelSettingEntity levelSetting=new LevelSettingEntity();
|
|
levelSetting.CALL_TYPE = item.CALL_TYPE;
|
|
levelSetting.FACTORY_CODE = item.FACTORY_CODE;
|
|
//现在只有一级。
|
|
//levelSetting.LEVEL = item.CALL_LEVEL;
|
|
var levelSettingList = GetLevelSetting(levelSetting);
|
|
if (levelSettingList != null && levelSettingList.Count>0)
|
|
{
|
|
//计算时间差
|
|
var timeSpan = DateTime.Now.Subtract(item.CALL_TIME);
|
|
//超时处理--分钟数
|
|
if (timeSpan.TotalMinutes > levelSettingList[0].ANSWER_TIMEOUT)
|
|
{
|
|
//只增加一级
|
|
item.CALL_LEVEL = 2;
|
|
//获得班组
|
|
var shift = new ProduceShiftBLL().GetWorkingShift(item.WORKCENTER_CODE);
|
|
//班组
|
|
var teamCode = GetTeamCode(item.FACTORY_CODE, shift != null ? shift.PRODUCESHIFTTCODE : "", item.CALL_TYPE);
|
|
//收件人
|
|
var recipients = "";
|
|
var teamMemberList = GetRecipient(item.FACTORY_CODE,item.WORKCENTER_CODE, item.CALL_TYPE, item.CALL_LEVEL,
|
|
teamCode);
|
|
|
|
//根据工位获得工序
|
|
//WorkLoc workLoc = new WorkLoc {WORKCELL_CODE = item.WORKLOC_CODE};
|
|
//var workcellCode = new WorkLocBLL().Get(workLoc).Result.WORKCELL_CODE;
|
|
//根据工序获得工作中心
|
|
//WorkCell workCell = new WorkCell {WORKCELL_CODE = workcellCode};
|
|
//var workCenterCode = new WorkCellBLL().Get(workCell).Result.WORKCENTER_CODE;
|
|
//获得负责人和语言
|
|
//AreaKeeperEntity areaKeeper = new AreaKeeperEntity
|
|
//{
|
|
// FACTORY_CODE = item.FACTORY_CODE,
|
|
// CALL_TYPE = item.CALL_TYPE,
|
|
// LEVEL = item.CALL_LEVEL,
|
|
// TEAM_CODE = shift,
|
|
// WORKCENTER_CODE = workCenterCode
|
|
//};
|
|
//var areaKeeperItem = GetAreaKeeper(areaKeeper);
|
|
|
|
//获得消息模版
|
|
MessageTemplateEntity messageTemplate = new MessageTemplateEntity
|
|
{
|
|
FACTORY_CODE = item.FACTORY_CODE,
|
|
CALL_TYPE = item.CALL_TYPE,
|
|
//LEVEL = item.CALL_LEVEL,
|
|
//LANGUAGE = null
|
|
};
|
|
var temp = new AndonCallDAL().GetMessageTemplate(messageTemplate);
|
|
if (temp!=null)
|
|
{
|
|
var template = temp.TEMPLATE;
|
|
if (!string.IsNullOrEmpty(template))
|
|
{
|
|
//替换模版
|
|
template = template.Replace("{CALL_TYPE}", item.CALL_TYPE);
|
|
template = template.Replace("{CALL_REASION}", item.CALL_REASION);
|
|
template = template.Replace("{CALL_TIME}",
|
|
item.CALL_TIME.ToString(CultureInfo.InvariantCulture));
|
|
template = template.Replace("{CALL_LEVEL}", item.CALL_LEVEL.ToString());
|
|
template = template.Replace("{WORKLOC_CODE}", item.WORKLOC_CODE);
|
|
}
|
|
//插入T_AD_MESSAGEQUEUE邮件
|
|
if (!string.IsNullOrEmpty(template) && teamMemberList != null && teamMemberList.Count > 0)
|
|
{
|
|
//消息基本信息 ISSENT 0.未发送 1.发送 MESSAGE_TYPE 1.短信 2.邮件
|
|
var messageModel = new MessageQueueEntity
|
|
{
|
|
//PID = Guid.NewGuid().ToString(),
|
|
FACTORY_CODE = item.FACTORY_CODE,
|
|
MESSAGE_TYPE = "2",
|
|
//RECIPIENT = recipient,
|
|
LANGUAGE = null,
|
|
MESSAGE = template,
|
|
CREATE_TIME = DateTime.Now,
|
|
ISSENT = "0"
|
|
};
|
|
foreach (var tme in teamMemberList)
|
|
{
|
|
messageModel.PID = Guid.NewGuid().ToString();
|
|
messageModel.RECIPIENT = tme.MEMBER_CODE;
|
|
recipients += tme.MEMBER_NAME + ","; ;
|
|
InsertMessageQueue(messageModel);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
item.REMARK += " 邮件提醒失败.";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
item.REMARK += " 邮件提醒失败.";
|
|
}
|
|
//更新CallLog表
|
|
item.RECIPIENT += recipients;
|
|
if (item.ANSWER_TIME == null)
|
|
{
|
|
item.ANSWER_TIME = DateTime.MinValue;
|
|
}
|
|
if (item.START_TIME == null)
|
|
{
|
|
item.START_TIME = DateTime.MinValue;
|
|
}
|
|
if (item.COMPLETE_TIME == null)
|
|
{
|
|
item.COMPLETE_TIME = DateTime.MinValue;
|
|
}
|
|
item.UPDATEUSER = LoginUser.UserID;
|
|
item.UPDATEDATE = DateTime.Now;
|
|
//呼叫升级
|
|
item.CALL_STATE = "5";
|
|
UpdateCallLog(item);
|
|
|
|
#region //事务
|
|
//using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
//{
|
|
// try
|
|
// {
|
|
// // 开始事务
|
|
// session.OpenTs();
|
|
|
|
// AndonCallDAL andonDal = new AndonCallDAL();
|
|
// andonDal.BaseSession = session;
|
|
|
|
// //CallLog基本信息
|
|
// if (item.ANSWER_TIME == null)
|
|
// {
|
|
// item.ANSWER_TIME = DateTime.MinValue;
|
|
// }
|
|
// if (item.START_TIME == null)
|
|
// {
|
|
// item.START_TIME = DateTime.MinValue;
|
|
// }
|
|
// ++item.CALL_LEVEL;
|
|
// item.UPDATEUSER = this.LoginUser.UserID;
|
|
// item.UPDATEDATE = DateTime.Now;
|
|
// //更新CallLog表
|
|
// andonDal.UpdateCallLog(item);
|
|
|
|
// //消息基本信息 ISSENT 0.未发送 1.发送 MESSAGE_TYPE1.短信 2.邮件
|
|
// var messageModel = new MessageQueueEntity
|
|
// {
|
|
// PID = Guid.NewGuid().ToString(),
|
|
// FACTORY_CODE = item.FACTORY_CODE,
|
|
// MESSAGE_TYPE = "2",
|
|
// RECIPIENT = areaKeeper.KEEPER,
|
|
// LANGUAGE = areaKeeper.LANGUAGE,
|
|
// MESSAGE = template,
|
|
// CREATE_TIME = DateTime.Now,
|
|
// ISSENT = "0"
|
|
// };
|
|
// andonDal.InsertMessageQueue(messageModel);
|
|
|
|
// // 事务提交
|
|
// session.CommitTs();
|
|
|
|
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// session.RollbackTs();
|
|
// throw e;
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 根据班次到排班表T_QT_SCHEDULE获取班组
|
|
|
|
public string GetTeamCode(string factoryCode, string shifCode,string teamType)
|
|
{
|
|
string teamCode = null;
|
|
ScheduleEntity model = new ScheduleEntity
|
|
{
|
|
//FACTORY_CODE = factoryCode,
|
|
TEAM_TYPE=teamType,
|
|
SHIFT_CODE = shifCode,
|
|
NOW_DATE = DateTime.Now
|
|
};
|
|
var list = new ScheduleBLL().GetAllSchedule(model);
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
teamCode = list.OrderByDescending(p => p.START_DATE).FirstOrDefault().TEAM_CODE;
|
|
}
|
|
return teamCode;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取收件人(改为班组成员,暂时不需要语言)
|
|
//发一人修改为多人20180404
|
|
public List<TeamMemberEntity> GetRecipient(string factoryCode,string workcentercode, string callType, int callLevel, string teamCode)
|
|
{
|
|
string recipient = null;
|
|
TeamMemberEntity model = new TeamMemberEntity
|
|
{
|
|
WORKCELL_CODE=workcentercode,
|
|
TEAM_CODE = teamCode,
|
|
TEAMTYPE = callType,
|
|
CALL_LEVEL = callLevel,
|
|
IS_CALL = "1"
|
|
};
|
|
var list = new TeamMemberBLL().GetAllTeamMember(model);
|
|
if (list != null && list.Count>0)
|
|
{
|
|
return list;
|
|
}
|
|
return null;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取消息模版(改为班组成员,暂时不需要语言)
|
|
public string GetMessageTemplate(string factoryCode, string callType, int callLevel, string language,
|
|
string callReasion, string callTime, string worklocCode)
|
|
{
|
|
string template = null;
|
|
MessageTemplateEntity model = new MessageTemplateEntity
|
|
{
|
|
//FACTORY_CODE = factoryCode,
|
|
CALL_TYPE = callType,
|
|
LEVEL = callLevel,
|
|
LANGUAGE = language
|
|
};
|
|
var list = new AndonCallDAL().GetMessageTemplate(model);
|
|
if (list == null) return template;
|
|
template = list.TEMPLATE;
|
|
if (string.IsNullOrEmpty(template)) return template;
|
|
//替换模版
|
|
var configDetailList = new ConfigDetailBLL().GetAllList("CALL_TYPE");
|
|
var callTypeTxt = callType;
|
|
//呼叫类型
|
|
var configDetail = configDetailList.FirstOrDefault(x => x.DetailTypeCode == callType);
|
|
if (configDetail != null)
|
|
callTypeTxt = configDetail.DetailTypeName;
|
|
template = template.Replace("{CALL_TYPE}", callTypeTxt);
|
|
template = template.Replace("{CALL_REASION}", callReasion);
|
|
template = template.Replace("{CALL_TIME}", callTime);
|
|
template = template.Replace("{CALL_LEVEL}", callLevel.ToString());
|
|
template = template.Replace("{WORKLOC_CODE}", worklocCode);
|
|
return template;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region Excel导出
|
|
public DataTable ExportExcelData(CallLogEntity model)
|
|
{
|
|
try
|
|
{
|
|
DataTable dt = new AndonCallDAL().ExportExcelData(model);
|
|
|
|
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|