|
- using Dapper;
- using Learun.Application.Organization;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
-
- namespace Learun.Application.TwoDevelopment.PersonnelManagement
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
- /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- /// 创 建:超级管理员
- /// 日 期:2021-02-21 10:07
- /// 描 述:会议管理
- /// </summary>
- public class MeetingManagementService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<MeetingManagementEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.*,r.Name as ConferenceRoomName ");
- strSql.Append(" FROM MeetingManagement t left join ConferenceRoom r on t.MeetingPlace=r.ID ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["MeetingTitle"].IsEmpty())
- {
- dp.Add("MeetingTitle", "%" + queryParam["MeetingTitle"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.MeetingTitle Like @MeetingTitle ");
- }
- if (!queryParam["MeetingPlace"].IsEmpty())
- {
- dp.Add("MeetingPlace", queryParam["MeetingPlace"].ToString(), DbType.String);
- strSql.Append(" AND t.MeetingPlace = @MeetingPlace ");
- }
- if (!queryParam["CreateUser"].IsEmpty())
- {
- dp.Add("CreateUser", queryParam["CreateUser"].ToString(), DbType.String);
- strSql.Append(" AND t.CreateUser = @CreateUser ");
- }
- if (!queryParam["InternalParticipants"].IsEmpty())
- {
- dp.Add("InternalParticipants", "%" + queryParam["InternalParticipants"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.InternalParticipants Like @InternalParticipants ");
- }
- return this.BaseRepository("CollegeMIS").FindList<MeetingManagementEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<MeetingManagementEntity> GetList(string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.*");
- strSql.Append(" FROM MeetingManagement t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["MeetingTitle"].IsEmpty())
- {
- dp.Add("MeetingTitle", "%" + queryParam["MeetingTitle"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.MeetingTitle Like @MeetingTitle ");
- }
- if (!queryParam["MeetingPlace"].IsEmpty())
- {
- dp.Add("MeetingPlace", queryParam["MeetingPlace"].ToString(), DbType.String);
- strSql.Append(" AND t.MeetingPlace = @MeetingPlace ");
- }
- if (!queryParam["CreateUser"].IsEmpty())
- {
- dp.Add("CreateUser", queryParam["CreateUser"].ToString(), DbType.String);
- strSql.Append(" AND t.CreateUser = @CreateUser ");
- }
- return this.BaseRepository("CollegeMIS").FindList<MeetingManagementEntity>(strSql.ToString(), dp);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取MeetingManagement表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public MeetingManagementEntity GetMeetingManagementEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<MeetingManagementEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取MeetingManagement表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public MeetingManagementEntity GetMeetingManagementEntityByProcessId(string processId)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<MeetingManagementEntity>(x => x.ProcessId == processId);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取报表数据
- /// </summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public DataTable GetStatisticList(string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(@"
- t.meetingtitle,
- t.begintime,
- t.endtime,
- t.正常,
- t.未到
- ");
- strSql.Append(" FROM (select m.MeetingTitle,isnull(t.正常,0) 正常,isnull(t.未到,0) 未到,m.BeginTime,m.EndTime from MeetingManagement m left join (select meetid,sum(case issignin when 1 then 1 else 0 end) as 正常, sum(case issignin when 0 then 1 else 0 end) as 未到 from MeetingSignInRecord group by meetid) t on t.MeetID=m.Id)t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["meetingtitle"].IsEmpty())
- {
- dp.Add("meetingtitle", "%" + queryParam["meetingtitle"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.meetingtitle Like @meetingtitle ");
- }
- if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
- {
- dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
- dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
- strSql.Append(" AND ( t.begintime >= @startTime AND t.begintime <= @endTime ) ");
- }
- return this.BaseRepository("CollegeMIS").FindTable(strSql.ToString(), dp);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DeleteEntity(string keyValue)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- //会议签到记录表中删除参会人员记录
- db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == keyValue);
- //会议工作管理表删除会议
- db.Delete<MeetingManagementEntity>(t => t.Id == keyValue);
-
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SaveEntity(UserInfo userInfo, string keyValue, MeetingManagementEntity entity)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.Modify(keyValue, userInfo);
- db.Update(entity);
- }
- else
- {
- entity.Create(userInfo);
- db.Insert(entity);
- }
-
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 审核实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DoCheck(UserInfo userInfo, string keyValue, string status)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- //修改会议工作管理表的审核字段;
- db.ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',CheckUser='" + userInfo.userId + "',CheckTime='" + DateTime.Now + "' where Id='" + keyValue + "' ");
- if (status == "1")//审核通过:会议签到记录表中增加参会人员;
- {
- var entity = db.FindEntity<MeetingManagementEntity>(x => x.Id == keyValue);
- if (entity != null)
- {
- //增加校内参入人员:
- if (!string.IsNullOrEmpty(entity.InternalParticipants))
- {
- if (entity.InternalParticipants.IndexOf(',') == -1)
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantID = entity.InternalParticipants,
- ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == entity.InternalParticipants)?.F_RealName,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- else
- {
- foreach (var item in entity.InternalParticipants.Split(','))
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantID = item,
- ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == item)?.F_RealName,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- }
- }
- //增加校外参入人员:
- if (!string.IsNullOrEmpty(entity.ExternalParticipants))
- {
- if (entity.ExternalParticipants.IndexOf(',') == -1)
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantName = entity.ExternalParticipants,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- else
- {
- foreach (var item in entity.ExternalParticipants.Split(','))
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantName = item,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- }
- }
-
- }
- }
- else if (status == "2") //审核不通过:会议签到记录表中删除参会人员记录;
- {
- db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == keyValue);
- }
-
- db.Commit();
-
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 提交实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DoSubmit(string keyValue, string status, string processId)
- {
- try
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 审核实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void ChangeStatusByProcessId(string processId, string status, string userId)
- {
- UserInfo userInfo = LoginUserInfo.Get();
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- //修改会议工作管理表的审核字段;
- db.ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',CheckUser='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
- var entity = db.FindEntity<MeetingManagementEntity>(x => x.ProcessId == processId);
- if (entity != null)
- {
- if (status == "1")//审核通过:会议签到记录表中增加参会人员;
- {
- //增加校内参入人员:
- if (!string.IsNullOrEmpty(entity.InternalParticipants))
- {
- if (entity.InternalParticipants.IndexOf(',') == -1)
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantID = entity.InternalParticipants,
- ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == entity.InternalParticipants)?.F_RealName,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- else
- {
- foreach (var item in entity.InternalParticipants.Split(','))
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantID = item,
- ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == item)?.F_RealName,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- }
- }
- //增加校外参入人员:
- if (!string.IsNullOrEmpty(entity.ExternalParticipants))
- {
- if (entity.ExternalParticipants.IndexOf(',') == -1)
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantName = entity.ExternalParticipants,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- else
- {
- foreach (var item in entity.ExternalParticipants.Split(','))
- {
- var model = new MeetingSignInRecordEntity()
- {
- MeetID = entity.Id,
- ParticipantName = item,
- IsSignIn = false
- };
- model.Create(userInfo);
- db.Insert(model);
- }
- }
- }
-
- }
- else if (status == "2") //审核不通过:会议签到记录表中删除参会人员记录;
- {
- db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == entity.Id);
- }
- }
-
- db.Commit();
-
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
-
- #endregion
-
- }
- }
|