|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- 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
-
- }
- }
|