123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using Ropin.Inspection.Model.Entities;
- using Ropin.Inspection.Model.SearchModel.MTN;
- using Ropin.Inspection.Model.ViewModel.MTN;
- using Ropin.Inspection.Repository.MTN.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Repository.MTN
- {
- public class mtnAlarmShadowRecordRepository : RepositoryBase<TMTN_AlarmShadowRecord, string>, ImtnAlarmShadowRecordRepository
- {
- public mtnAlarmShadowRecordRepository(InspectionDbContext DbContext) : base(DbContext)
- {
- }
- public Task<IEnumerable<AlarmShadowRecordModel>> GetList(AlarmShadowRecordSearch searchModel)
- {
- MySqlConnector.MySqlParameter[] parameters = new[] {
- new MySqlConnector.MySqlParameter("id", searchModel.C_ID),
- new MySqlConnector.MySqlParameter("pushMsgResultCode", searchModel.C_PushMsgResultCode),
- new MySqlConnector.MySqlParameter("devCode", searchModel.C_DevCode),
- new MySqlConnector.MySqlParameter("type", searchModel.C_Type),
- new MySqlConnector.MySqlParameter("cameraServiceType", searchModel.C_CameraServiceType)
- };
- StringBuilder sql = new StringBuilder();
- sql.Append(@" select * from (
- select m.*,c.C_Name as C_CameraName,d.C_Name as C_CameraServiceTypeName,d.C_Value
- from TMTN_AlarmShadowRecord m
- LEFT JOIN TMTN_PushMsgResult p on (m.C_PushMsgResultCode=p.C_ID)
- LEFT JOIN TBDM_CodeDetail d on (m.C_CameraServiceType=d.C_Code)
- LEFT JOIN TVMC_Camera c on (m.C_CameraCode=c.C_ID)
- ) tab where 1=1
- ");
- if (!string.IsNullOrEmpty(searchModel.C_PushMsgResultCode))
- {
- sql.Append(" and C_PushMsgResultCode=@pushMsgResultCode ");
- }
- if (!string.IsNullOrEmpty(searchModel.C_DevCode))
- {
- sql.Append(" and C_DevStoreCode=@devCode ");
- }
- if (!string.IsNullOrEmpty(searchModel.C_Type))
- {
- sql.Append(" and C_Type=@type ");
- }
- if (!string.IsNullOrEmpty(searchModel.C_CameraServiceType))
- {
- sql.Append(" and C_CameraServiceType=@cameraServiceType ");
- }
- if (!string.IsNullOrEmpty(searchModel.C_ID))
- {
- sql.Append(" and C_ID=@id ");
- }
- IEnumerable<AlarmShadowRecordModel> recordItemlist = EntityFrameworkCoreExtensions.GetList<AlarmShadowRecordModel>(DbContext.Database, sql.ToString(), parameters);
- searchModel.TotalCount = recordItemlist.First() != null ? recordItemlist.ToList().Count : 0;
- if (searchModel.TotalCount == 0)
- {
- recordItemlist = new List<AlarmShadowRecordModel>();
- }
- return Task.FromResult(searchModel.IsPagination ? recordItemlist.Skip((searchModel.PageIndex - 1) * searchModel.PageSize).Take(searchModel.PageSize) : recordItemlist);
- }
- }
- }
|