diff --git a/SlnMesnac.Config/SqlConfig.cs b/SlnMesnac.Config/SqlConfig.cs index cc3de31..b1207d2 100644 --- a/SlnMesnac.Config/SqlConfig.cs +++ b/SlnMesnac.Config/SqlConfig.cs @@ -34,7 +34,7 @@ namespace SlnMesnac.Config public string configId { get; set; } /// - /// 数据库类型,MySql-0;SqlServer-1;Sqlite-2;Oracle-3 + /// 数据库类型,MySql-0;SqlServer-1;Sqlite-2;Oracle-3,4 /// public int dbType { get; set; } diff --git a/SlnMesnac.Model/domain/BaseCode.cs b/SlnMesnac.Model/domain/BaseCode.cs index ffe886a..f7b6c64 100644 --- a/SlnMesnac.Model/domain/BaseCode.cs +++ b/SlnMesnac.Model/domain/BaseCode.cs @@ -1,7 +1,37 @@ -namespace SlnMesnac.Model.domain +using System.Runtime.Serialization; +using SqlSugar; + +namespace SlnMesnac.Model.domain { + /// + /// 异常监控编码对应表 + /// + [SugarTable("BaseCode"), TenantAttribute("mes")] + [DataContract(Name = "BaseCode 基础表")] public class BaseCode { + /// + /// + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "code")] + public string Code { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "state")] + public string State { get; set; } + + + /// + /// 1 RFid 2 视觉 + /// + [SugarColumn(ColumnName = "category")] + public int Category { get; set; } } } \ No newline at end of file diff --git a/SlnMesnac.Model/domain/Page.cs b/SlnMesnac.Model/domain/Page.cs index cdbf8ee..deab148 100644 --- a/SlnMesnac.Model/domain/Page.cs +++ b/SlnMesnac.Model/domain/Page.cs @@ -1,7 +1,24 @@ -namespace SlnMesnac.Model.domain +using System.Collections.Generic; + +namespace SlnMesnac.Model.domain { public class Page { + public int PageIndex { get; set; } + public int PageSize { get; set; } + public int TotalCount { get; set; } + public int TotalPage { get; set; } + public List Data { get; set; } } + + public class Page:Page + { + public List Data { get; set; } + + /// + /// 判断有没有下一页 + /// + public bool HasNext => TotalPage > PageIndex; + } } \ No newline at end of file diff --git a/SlnMesnac.Model/domain/ScanLog.cs b/SlnMesnac.Model/domain/ScanLog.cs index 5bb82a8..8d20e2f 100644 --- a/SlnMesnac.Model/domain/ScanLog.cs +++ b/SlnMesnac.Model/domain/ScanLog.cs @@ -6,7 +6,7 @@ namespace SlnMesnac.Model.domain { [SugarTable("ScanLog"), Tenant("mes")] [DataContract(Name = "ScanLog ɨ־")] - public class ScanLog + public class ScanLogModel { /// /// diff --git a/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs b/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs index 692120e..4a87885 100644 --- a/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs +++ b/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs @@ -1,7 +1,13 @@ -namespace SlnMesnac.Repository.service.ScanLog +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; + +namespace SlnMesnac.Repository.service.ScanLog { - public class IScanLogService + public interface IScanLogService:IBaseService { + void CreatTable(); + + Page QueryPage(int pageIndex, int pageSize); } } \ No newline at end of file diff --git a/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs b/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs index b085f3a..3b7b0c8 100644 --- a/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs +++ b/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs @@ -30,5 +30,20 @@ namespace SlnMesnac.Repository.service.ScanLog this.Insert(ls); } + + public Page QueryPage(int pageIndex, int pageSize) + { + int totalCount = 0; + var list= _rep.Context.Queryable().OrderByDescending(x => x.CreateTime) + .ToPageList(pageIndex, pageSize, ref totalCount); + Page page = new Page(); + page.Data=list; + page.PageIndex = pageIndex; + page.PageSize = pageSize; + page.TotalCount = totalCount; + page.TotalPage = (int)Math.Ceiling(totalCount / (double)pageSize); + return page; + + } } } \ No newline at end of file diff --git a/SlnMesnac.Repository/service/baseCode/BaseCodeServiceImpl.cs b/SlnMesnac.Repository/service/baseCode/BaseCodeServiceImpl.cs index e86145e..b90d0a6 100644 --- a/SlnMesnac.Repository/service/baseCode/BaseCodeServiceImpl.cs +++ b/SlnMesnac.Repository/service/baseCode/BaseCodeServiceImpl.cs @@ -1,7 +1,29 @@ -namespace SlnMesnac.Repository.service +using System.Linq; +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; + +namespace SlnMesnac.Repository.service { - public class BaseCodeServiceImpl + public class BaseCodeServiceImpl:BaseServiceImpl,IBaseCodeService { - + public BaseCodeServiceImpl(Repository rep) : base(rep) + { + + } + + public void CreateBaseCode() + { + _rep.Context.CodeFirst.InitTables(typeof(BaseCode)); + } + + /// + /// 根据Code去查询单个数据 + /// + /// + /// + public BaseCode QueryCode(string code) + { + return this.Query(x => x.Code == code).First(); + } } } \ No newline at end of file diff --git a/SlnMesnac.Repository/service/baseCode/IBaseCodeService.cs b/SlnMesnac.Repository/service/baseCode/IBaseCodeService.cs index efc756a..5efca06 100644 --- a/SlnMesnac.Repository/service/baseCode/IBaseCodeService.cs +++ b/SlnMesnac.Repository/service/baseCode/IBaseCodeService.cs @@ -1,7 +1,12 @@ -namespace SlnMesnac.Repository.service +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; + +namespace SlnMesnac.Repository.service { - public class IBaseCodeService + public interface IBaseCodeService:IBaseService { - + void CreateBaseCode(); + + BaseCode QueryCode(string code); } } \ No newline at end of file