using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Lskj.Model; using Lskj.Core; using Lskj.Util; namespace Lskj.Business.Impl { public class NoticeImpl : BaseImpl { /// /// 说明:判断数据库中是否存在默认消息记录表 /// 创建人:王一帆 /// 创建日期:2020-09-21 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static void CreationNoticeTable() { string sqlValue = string.Format(@"Create Table p_systemNoticeSheet -- 消息通知信息表 ( Id int identity(1,1) primary key, -- 分类ID,主键,自动增长 Msg varchar(20) unique not null, -- 写入数据库信息 Created datetime not null, -- 此分类下的问题数量 UserId int default 1, -- 是否在问题列表里显示此类(1-显示(默认),0-不显示) )"); ExecSqlValue(sqlValue); } /// /// 说明:更新提醒框的标识字段 /// 创建人:王一帆 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable UpdRemindField(DataRow item, string dllName) { string Billsql = string.Format("Update wms_BillflowComfirm set isdel=1 where modid='{0}' and keyvalue='{1}' and operatorid={2}", item["moduleid"] + "", item["keyvalue"] + "", ERPInfo.Instance.UserId); string Basesql = string.Format("Update p_baseflowComfirm set isdel=1 where modid='{0}' and keyvalue='{1}' and operatorid={2}", item["moduleid"] + "", item["keyvalue"] + "", ERPInfo.Instance.UserId); return GetDataTableResult(dllName == "Lskj.BaseInfo.dll" ? Basesql : Billsql); } /// /// 说明:获取审批通知数据 /// 创建人:龚宇超 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetNoticeData(string userName) { string sqlValue = string.Format("select '['+typeName+']'+'=>'+keyvalue+'单子需要审核' as AuditMessages,* from wms_billflowOperView WITH(NOLOCK) where CHARINDEX(',{0},',',' + browsers + ',')>0", userName); return GetDataTableResult(sqlValue); } /// /// 说明:删除标识为1的当前行字段 /// 创建人:王一帆 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static void UpeNoticeData(DataRow item, bool isCustomNotice = true) { string sqlValue = string.Empty; if (HasExistsTable("p_systemMessageTab") && isCustomNotice) { sqlValue = string.Format("Update p_systemMessageTab set ReadFlag=1, DeleteFlag=1 where Id={0}", item["id"] + ""); ExecSqlValue(sqlValue); } else { sqlValue = string.Format("delete p_systemNotification where Id={0}", item["id"] + ""); ExecSqlValue(sqlValue); } if (HasExistsTable("p_systemNoticeSheet")) { sqlValue = string.Format("insert into p_systemNoticeSheet (Msg, Created,UserId) VALUES ('{0}','{1}',{2})", item["AuditMessages"] + "", DateTime.Now.ToString("yyyy-MM-dd"), ERPInfo.Instance.UserId); ExecSqlValue(sqlValue); } ApiHelper apiHelper = null; Interface.Api.ActionType actionType = Interface.Api.ActionType.None; //string moduleid = item["moduleid"] + ""; string moduleid = "SkipToNotice"; if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleContextMenu, moduleid, -1)) { System.Threading.Thread thread = new System.Threading.Thread(() => { apiHelper = new ApiHelper(moduleid, "", "", "", -1, null); actionType = Interface.Api.ActionType.None; apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleContextMenu, actionType); }); thread.Start(); } } /// /// 说明:删除所有标识为1的消息 /// 创建人:王一帆 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable UpeNoticeData(string messid) { string sqlValue = string.Format("delete p_systemNotification where messid={0} ", messid); return GetDataTableResult(sqlValue); } /// /// 说明:新获取审批通知数据 /// 创建人:王一帆 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable GetNoticeData2(string userId, out string sqlStr) { if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.MessageSql)&&!string.IsNullOrWhiteSpace(userId)) { string sql=ReplaceHelper.ReplaceUserInfo(SystemInfo.Instance.MessageSql); sqlStr = sql; return GetDataTableResult(sql); } string MessageTab = string.Empty; string SkipToMessageTab = string.Empty; string RecordsTime = " ,null as FirstViewTime"; if (BaseImpl.HasExistsColumn("p_systemMessageTab", "FirstViewTime", "datetime")) { RecordsTime = ",FirstViewTime"; } if (BaseImpl.HasExistsTable("p_systemMessageTab")) { if (BaseImpl.HasExistsColumn("p_systemMessageTab", "pubdll", "VARCHAR(100)")) { MessageTab = string.Format(@" union all select Msg,CreateDate,id,1,DllCoid,0,pubdll,Title,MsgDetail,0,0,0,0,aa.employeename,a.CreateUserName,'p_systemMessageTab' {1} from p_systemMessageTab a with(nolock) left join P_EmployeeTab aa with(nolock) on a.CreateUserID=aa.employeeid where NoticeUserID={0} and DeleteFlag=0", userId, RecordsTime); } SkipToMessageTab = string.Format(@" union all select Msg AuditMessages, Created OperateDate, id, messid, DLLCoid moduleid, Cnt1 num, DllFileName dllname, modulename, '' keyvalue, stepcode, '' menumode, menuid, '' hasSearch, null as EmployeeName ,'' as CreateUserName,'p_systemNotification' ,null as FirstViewTime from p_systemNotification with(nolock) where dllcoid = 'SkipToNotice' and UserId = {0}", userId); } string sqlValue = string.Format(@"select distinct '['+b.MenuCaption+']'+'=>'+isnull(a.billdocument_id,'')+msg as AuditMessages ,a.Created as OperateDate,a.id,messid,a.DLLCoid moduleid,Cnt1 num,a.DllFileName dllname,b.MenuCaption modulename ,billdocument_id keyvalue,stepcode ,ISNULL(MenuMode_Mobile,0) menumode,b.menuid,case when ISNULL(c.DllCoid,'')='' then isnull(d.defaultShowSearch,0) else isnull(c.defaultShowSearch,0) end hasSearch,null as EmployeeName ,'' as CreateUserName,'p_systemNotification' as TableName ,null as FirstViewTime from p_systemNotification a with(nolock) inner join P_FormMenuConfigTab b with(nolock) ON ISNULL(a.menuid,0)=b.MenuId LEFT JOIN p_systemdlltab c with(nolock) ON b.UrlParams = c.DllCoid LEFT JOIN p_systembilltype d with(nolock) ON b.UrlParams = d.typeCode where isnull(a.billdocument_id,'')<>'' and isnull(a.status,0)=0 and isnull(a.Cnt1,0)<>0 and a.UserId={0} {1} {2}", userId, MessageTab, SkipToMessageTab); sqlValue = string.Format("select * from ({0}) a order by OperateDate desc", sqlValue); sqlStr = sqlValue; return GetDataTableResult(sqlValue); } /// /// 说明:更新第一次点开的时间 /// 创建人: /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// DataTable. public static DataTable UpeNoticeData(string tableName,string id) { string sqlValue = string.Format("update {0} set FirstViewTime=GETDATE() where id={1} ", tableName,id); return GetDataTableResult(sqlValue); } } }