|
- using Dapper;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
-
- namespace Learun.Application.TwoDevelopment.LogisticsManagement
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-05-05 15:44
- /// 描 述:宿舍卫生管理
- /// </summary>
- public class SanitationService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<Acc_SanitationEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append(@"select fb.* ,zb.ID zbid,zb.AType,zb.Grade,zb.GradedUser,zb.GradedTime,zb.Remark demo from Acc_Sanitation zb
- left join(
- select ci.*, ad.* from Acc_DormitoryBuild ad
- left join (
- select aa.classno ,aa.classname,fb1.empno as empnoone,fb1.Mobile as MobileOne,
- fb2.empno empnoTwo,fb2.Mobile as MobileTwo from classinfo aa
- left join empinfo fb1 on aa.classdiredctorno = fb1.EmpNo
- left join empinfo fb2 on aa.ClassTutorNo = fb2.EmpNo
- )ci on ci.classno = ad.class
- )fb on zb.roomid = fb.id where 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["RoomID"].IsEmpty())
- {
- dp.Add("RoomID", queryParam["RoomID"].ToString(), DbType.String);
- strSql.Append(" AND zb.RoomID =@RoomID ");
- }
- return this.BaseRepository("CollegeMIS").FindList<Acc_SanitationEntity>(strSql.ToString(), dp, pagination).OrderByDescending(a => a.GradedTime).ToList();
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取Acc_Sanitation表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public Acc_SanitationEntity GetAcc_SanitationEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<Acc_SanitationEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取树形数据(不包含床位的树数据)
- /// </summary>
- /// <returns></returns>
- public List<Acc_DormitoryBuildEntity> GetSqlTree()
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>().Where(a => a.BuildType != "5").OrderBy(a => a.Name).ToList();
- }
- 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)
- {
- try
- {
- this.BaseRepository("CollegeMIS").Delete<Acc_SanitationEntity>(t => t.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 SaveEntity(string keyValue, Acc_SanitationEntity entity)
- {
- try
- {
- var loginuser = LoginUserInfo.Get();
- entity.CreateUser = loginuser.realName;
- entity.CreateTime = DateTime.Now;
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.Modify(keyValue);
- this.BaseRepository("CollegeMIS").Update(entity);
- }
- else
- {
- entity.Create();
- this.BaseRepository("CollegeMIS").Insert(entity);
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- }
- }
|