12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Model.Entities;
- using Ropin.Inspection.Model.SearchModel.MTN;
- using Ropin.Inspection.Model.ViewModel.MTN;
- using Ropin.Inspection.Repository.TAIC.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Repository.TAIC
- {
- public class TaicAIBoxRepository : RepositoryBase<TaicAibox, string>, ITaicAIBoxRepository
- {
- public TaicAIBoxRepository(InspectionDbContext dbContext) : base(dbContext)
- {
-
- }
- public Task<IEnumerable<AiBoxModel>> GetList(AiBoxSearchModel searchModel)
- {
- MySqlConnector.MySqlParameter[] parameters = new[] {
- new MySqlConnector.MySqlParameter("Status", searchModel.CStatus),
- new MySqlConnector.MySqlParameter("storeCode", searchModel.CStoreCode),
- new MySqlConnector.MySqlParameter("name", "%"+searchModel.Name+"%")
- };
- StringBuilder sql = new StringBuilder();
- sql.Append(@" select * from (
- select a.C_ID as CId,
- a.C_Name as CName,
- a.C_AIBoxNo as CAiboxNo,
- a.C_QRCode as CQrcode,
- a.C_MachineCode as CMachineCode,
- a.D_ProdDate as DProdDate,
- a.C_AIBoxTemplateCode as CAIBoxTemplateCode,
- t.C_Name as CAIBoxTemplateName,
- a.C_StoreCode as CStoreCode,
- s.C_Name as CStoreName,
- a.C_CfgUrl as CCfgUrl,
- a.I_Sort as I_Sort,
- a.C_Remark as CRemark,
- a.C_CreateBy as CCreateBy,
- a.D_CreateOn as DCreateOn,
- a.C_LastUpdatedBy as CLastUpdatedBy,
- a.D_LastUpdatedOn as DLastUpdatedOn,
- a.C_RunStatus as CRunStatus,
- a.C_Status as CStatus
- from TAIC_AIBox a
- LEFT JOIN TPNT_Store s on (a.C_StoreCode=s.C_Code)
- LEFT JOIN TAIC_AIBoxTemplate t on (a.C_AIBoxTemplateCode=t.C_ID)
- ) tab Where 1=1
- ");
- if (searchModel.CStatus.HasValue)
- {
- sql.Append(" AND CStatus=@Status ");
- }
- if (!string.IsNullOrEmpty(searchModel.CStoreCode))
- {
- sql.Append(" and CStoreCode=@storeCode ");
- }
- if (!string.IsNullOrEmpty(searchModel.Name))
- {
- sql.Append(" and CName like @name ");
- }
- sql.Append(" order by DCreateOn desc ");
- IEnumerable<AiBoxModel> recordItemlist = EntityFrameworkCoreExtensions.GetList<AiBoxModel>(DbContext.Database, sql.ToString(), parameters);
- searchModel.TotalCount = recordItemlist.First() != null ? recordItemlist.ToList().Count : 0;
- if (searchModel.TotalCount == 0)
- {
- recordItemlist = new List<AiBoxModel>();
- }
- return Task.FromResult(searchModel.IsPagination ? recordItemlist.Skip((searchModel.PageIndex - 1) * searchModel.PageSize).Take(searchModel.PageSize) : recordItemlist);
- }
- }
- }
|