first commit
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// AGV任务表
|
||||
/// </summary>
|
||||
public partial class AGVTask : AggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// ErpTaskId
|
||||
/// </summary>
|
||||
public Guid ErpTaskId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格证号
|
||||
/// </summary>
|
||||
public string BarCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户名称
|
||||
/// </summary>
|
||||
public string CustomName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string MateriaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料类型
|
||||
/// </summary>
|
||||
public string MateriaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单个托盘上面的物料数量
|
||||
/// </summary>
|
||||
public int MateriaNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批次号的生成规则为: 作业单号+日期+班次
|
||||
/// </summary>
|
||||
public string MateriaBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string MateriaCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单状态 1:生成任务 2:开始执行 3:第一次暂停 4:执行第二段 5:第二次暂停 6:执行第三段 7:执行成功 -1:任务取消
|
||||
/// </summary>
|
||||
public int TaskStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public int TaskType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级 1:入库 10:出库 20:托盘入库 30:托盘出库 40:移库 99:其它
|
||||
/// </summary>
|
||||
public int Priority { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 楼层
|
||||
/// </summary>
|
||||
public int Floor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起点(库位编号)
|
||||
/// </summary>
|
||||
public string StartPositionCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 终点(库位编号
|
||||
/// </summary>
|
||||
public string EndPositionCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 码头位置 1:北区 2:南区 3:人工 4:退货到车间 99:其它
|
||||
/// </summary>
|
||||
public int Transport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务是否锁定(在锁定的情况下agvtask暂时不向rcs发送命令,待解锁后才可以,例如入库二楼提升机出口任务,如果托盘还未到出口则该任务还不能执行)
|
||||
/// </summary>
|
||||
public bool IsLock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Erp数据上传状态
|
||||
/// </summary>
|
||||
public int ErpUploadStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Erp返回错误信息
|
||||
/// </summary>
|
||||
public string ErpReturnMsg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 重试次数
|
||||
/// </summary>
|
||||
public int RetryNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组Id
|
||||
/// </summary>
|
||||
public Guid GroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务信息(生成失败提示等)
|
||||
/// </summary>
|
||||
public string TaskMsg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModifiedTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// ERP任务表
|
||||
/// </summary>
|
||||
public partial class ERPTask : AggregateRoot
|
||||
{
|
||||
public ERPTask() { }
|
||||
|
||||
/// <summary>
|
||||
/// 库位编号
|
||||
/// </summary>
|
||||
public string StorageRackNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产退库单号
|
||||
/// </summary>
|
||||
public string ProduceReturnCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 销售单号
|
||||
/// </summary>
|
||||
public string SaleNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 销售退库单号
|
||||
/// </summary>
|
||||
public string SaleReturnCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格证号
|
||||
/// </summary>
|
||||
public string BarCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户名称
|
||||
/// </summary>
|
||||
public string CustomName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string MateriaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料类型
|
||||
/// </summary>
|
||||
public string MateriaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批次号的生成规则为: 作业单号+日期+班次
|
||||
/// </summary>
|
||||
public string MateriaBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string MateriaCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 联动线出口,机械手设备唯一号
|
||||
/// </summary>
|
||||
public string EquipmentNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp下发命令中出入库总数量
|
||||
/// </summary>
|
||||
public int ErpOrderNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单状态 1:生成任务 2:开始执行 3:第一次暂停 4:执行第二段 5:第二次暂停 6:执行第三段 7:执行成功 -1:任务取消
|
||||
/// </summary>
|
||||
public int TaskStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务类型 1:码垛入库(实际没用了) 2:PDA入库 3:出库 4:销售退库 5:生产退库
|
||||
/// </summary>
|
||||
public int TaskType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 楼层(入库,尾托回库指定楼层使用)
|
||||
/// </summary>
|
||||
public int Floor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 码头位置 1:北区 2:南区 3:人工 4:退货到车间 99:其它
|
||||
/// </summary>
|
||||
public int Transport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级 1:入库 10:出库 20:托盘入库 30:托盘出库 40:移库 99:其它
|
||||
/// </summary>
|
||||
public int Priority { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 锁定 0:未锁定 1:锁定
|
||||
/// </summary>
|
||||
public bool IsLock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已上传给Erp的数量
|
||||
/// </summary>
|
||||
public int AlreadyUploadNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Erp出库撤单数量
|
||||
/// </summary>
|
||||
public int ErpCancelNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 回调Erp失败/成功 1:成功 0:失败
|
||||
/// </summary>
|
||||
public bool IsCallBackErpEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Erp回调Wms接口地址
|
||||
/// </summary>
|
||||
public string ErpCallWmsInterface { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Wms回调Erp接口地址
|
||||
/// </summary>
|
||||
public string WmsCallErpInterface { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务信息(生成失败提示等)
|
||||
/// </summary>
|
||||
public string TaskMsg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModifiedTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 提升机取货信号统计信息
|
||||
/// </summary>
|
||||
public class ElevatorCount : AggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 提升机编号(1 2)
|
||||
/// </summary>
|
||||
public int ElevatorNo { get; set; }
|
||||
/// <summary>
|
||||
/// 通道号(网带编号)
|
||||
/// </summary>
|
||||
public int ElevatorChannel { get; set; }
|
||||
/// <summary>
|
||||
/// 数量(放货口是wms实际放货的数量,取货口是PLC给的取货信号的次数,如果有货的时候重启wms会造成计数多一个)
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 提升机的PLC队列(出、入库)
|
||||
/// </summary>
|
||||
public class ElevatorPlcQueue : AggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 提升机编号(1 2)
|
||||
/// </summary>
|
||||
public int ElevatorNo { get; set; }
|
||||
/// <summary>
|
||||
/// 通道号(网带编号)
|
||||
/// </summary>
|
||||
public int ElevatorChannel { get; set; }
|
||||
/// <summary>
|
||||
/// AgvTask的Id
|
||||
/// </summary>
|
||||
public Guid AgvTaskId { get; set; }
|
||||
/// <summary>
|
||||
/// 是否锁定
|
||||
/// </summary>
|
||||
public bool IsLock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModifiedTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作来源
|
||||
/// </summary>
|
||||
public enum OperationSource
|
||||
{
|
||||
None = 0,
|
||||
ERP = 1,
|
||||
PDA = 2,
|
||||
WEB = 3,
|
||||
RCS = 4
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public enum OperationType
|
||||
{
|
||||
None = 0,
|
||||
StockIn = 1,
|
||||
SaleOut = 2,
|
||||
StockOutCancel = 3,
|
||||
ProductionOut = 4,
|
||||
TailIn = 5,
|
||||
Carry = 6,
|
||||
RcsCallBack = 7,
|
||||
UpdateErpTask = 8,
|
||||
UpdateStorageRack = 9,
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 备纸错误状态(0:正常 1:错误)
|
||||
/// </summary>
|
||||
public enum PreparationErrorStateEnum
|
||||
{
|
||||
Sucess = 0,
|
||||
Error = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using JSMachine.WMS.Domain.Entity.Enums;
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
public class OperationLog : AggregateRoot
|
||||
{
|
||||
public OperationSource OperationSource { get; set; }
|
||||
public OperationType OperationType { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public string OldObject { get; set; }
|
||||
public string NewObject { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using JSMachine.WMS.Infrastructure.LambdaHelp;
|
||||
using SqlSugar;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 分页查询条件
|
||||
/// </summary>
|
||||
public class PageQueryCondition
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前页
|
||||
/// </summary>
|
||||
public int CurrentPage { get; set; }
|
||||
/// <summary>
|
||||
/// 每页显示的条数
|
||||
/// </summary>
|
||||
public int PageSize { get; set; }
|
||||
/// <summary>
|
||||
/// 要排序的字段
|
||||
/// </summary>
|
||||
public string OrderByFiled { get; set; }
|
||||
/// <summary>
|
||||
///排序方式
|
||||
/// </summary>
|
||||
public OrderByType OrderByType { get; set; }
|
||||
/// <summary>
|
||||
/// 查询条件
|
||||
/// </summary>
|
||||
public List<IConditionalModel> Filters { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用分页查询结果,封装分页统计信息和当前页数据。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">页数据的元素类型。</typeparam>
|
||||
public class PagedResult<T>
|
||||
{
|
||||
public static readonly PagedResult<T> EmptyPagedResult = new PagedResult<T>(0, 0, 0, 0, null);
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// 总记录数
|
||||
/// </summary>
|
||||
public int TotalRecords { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总页数
|
||||
/// </summary>
|
||||
public int TotalPages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每页的记录数
|
||||
/// </summary>
|
||||
public int PageSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码
|
||||
/// </summary>
|
||||
public int PageNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置当前页码的记录
|
||||
/// </summary>
|
||||
public List<T> PageData { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建空的分页结果,页数据初始化为空集合。
|
||||
/// </summary>
|
||||
public PagedResult()
|
||||
{
|
||||
this.PageData = new List<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用完整分页统计信息创建结果。
|
||||
/// </summary>
|
||||
/// <param name="totalRecords">符合条件的总记录数。</param>
|
||||
/// <param name="totalPages">总页数。</param>
|
||||
/// <param name="pageSize">每页记录数。</param>
|
||||
/// <param name="pageNumber">当前页码。</param>
|
||||
/// <param name="data">当前页数据。</param>
|
||||
public PagedResult(int totalRecords, int totalPages, int pageSize, int pageNumber, List<T> data)
|
||||
{
|
||||
this.TotalPages = totalPages;
|
||||
this.TotalRecords = totalRecords;
|
||||
this.PageSize = pageSize;
|
||||
this.PageNumber = pageNumber;
|
||||
this.PageData = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据总记录数和分页参数计算总页数并创建结果。
|
||||
/// </summary>
|
||||
/// <param name="totalRecords">符合条件的总记录数。</param>
|
||||
/// <param name="pageSize">每页记录数。</param>
|
||||
/// <param name="pageNumber">当前页码。</param>
|
||||
/// <param name="data">当前页数据。</param>
|
||||
public PagedResult(int totalRecords, int pageSize, int pageNumber, List<T> data)
|
||||
{
|
||||
if (pageSize > 0)
|
||||
{
|
||||
this.TotalPages = totalRecords % pageSize == 0 ? totalRecords / pageSize : totalRecords / pageSize + 1;
|
||||
}
|
||||
|
||||
this.TotalRecords = totalRecords;
|
||||
this.PageSize = pageSize;
|
||||
this.PageNumber = pageNumber;
|
||||
this.PageData = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 原纸出库表
|
||||
/// </summary>
|
||||
public partial class PaperStockOut : AggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 序号(排序用)
|
||||
/// </summary>
|
||||
//public int SequenceNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Acs中的Id
|
||||
/// </summary>
|
||||
public Guid AcsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束状态
|
||||
/// </summary>
|
||||
public int FinishState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备纸顺序是否错误状态
|
||||
/// </summary>
|
||||
public int PreparationErrorState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每批所包含的全部Id
|
||||
/// </summary>
|
||||
public string Ids { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新卷残卷Id
|
||||
/// </summary>
|
||||
public Guid NewStockReStockID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原纸卷标
|
||||
/// </summary>
|
||||
public string PaperLabel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产线名称
|
||||
/// </summary>
|
||||
public string ProductLineName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 供应商
|
||||
/// </summary>
|
||||
public string Supplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制造商
|
||||
/// </summary>
|
||||
public string MakerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原纸克重
|
||||
/// </summary>
|
||||
public int PaperUnitWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原纸编码(纸质)
|
||||
/// </summary>
|
||||
public string PaperCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 门幅
|
||||
/// </summary>
|
||||
public int PaperWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 机台
|
||||
/// </summary>
|
||||
public string MachineNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库重量
|
||||
/// </summary>
|
||||
public decimal OutWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库名称
|
||||
/// </summary>
|
||||
public string StockHouseName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原纸出库类型
|
||||
/// </summary>
|
||||
public string StockOutType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 米长
|
||||
/// </summary>
|
||||
public decimal MeterLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位
|
||||
/// </summary>
|
||||
public string LocationMark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否在库(0:不在库 1:在库)
|
||||
/// </summary>
|
||||
public int InOutState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Memo { get; set; }
|
||||
/// <summary>
|
||||
/// 需要的纸质(未代纸情况下此值和实际纸质相等,代纸情况下则不等)
|
||||
/// </summary>
|
||||
public string WantedPaperCode { get; set; }
|
||||
/// <summary>
|
||||
/// 需要的幅宽(未代纸情况下此值和实际幅宽相等,代纸情况下则不等)
|
||||
/// </summary>
|
||||
public int WantedPaperWidth { get; set; }
|
||||
/// <summary>
|
||||
/// 企望接口出库记录上传状态(0-上传成功,1-上传失败,2-接口请求成功但数据被ERP拒收)
|
||||
/// </summary>
|
||||
public int WantitErpUploadStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 扫码信息来源
|
||||
/// </summary>
|
||||
public int BarCodeSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
public DateTime? LastModifiedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Erp接口调用成功,但是返回入库失败
|
||||
/// </summary>
|
||||
public string ErpStockInMsg { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
public class RcsTask : AggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务id
|
||||
/// </summary>
|
||||
public string TaskId { get; set; }
|
||||
/// <summary>
|
||||
/// wms上传时间
|
||||
/// </summary>
|
||||
public DateTime UploadTime { get; set; }
|
||||
/// <summary>
|
||||
/// 起点
|
||||
/// </summary>
|
||||
public string StartPositionCode { get; set; }
|
||||
/// <summary>
|
||||
/// 终点
|
||||
/// </summary>
|
||||
public string EndPositionCode { get; set; }
|
||||
/// <summary>
|
||||
/// 任务状态
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
public DateTime? LastModifiedTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 库区库位表
|
||||
/// </summary>
|
||||
public partial class StorageRack: AggregateRoot
|
||||
{
|
||||
public StorageRack()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 库位编号
|
||||
/// </summary>
|
||||
public string StorageRackNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 途径提升机指定点的坐标
|
||||
/// </summary>
|
||||
public string AgvPassPointNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 提升机通道号(PLC定义的网带编号),提升机库位专用
|
||||
/// </summary>
|
||||
public int? ElevatorChannel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位是否锁定 0:未锁定 1:锁定
|
||||
/// </summary>
|
||||
public bool IsLock { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 库位状态 1:满载具(有货) 2:空载具 3:料架进入 4:料架离开 5:没有载具(无货) 6:未知
|
||||
///// </summary>
|
||||
//public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位名称
|
||||
/// </summary>
|
||||
public string StorageRackName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所在的库区排序
|
||||
/// </summary>
|
||||
public int AreaNumSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位排序
|
||||
/// </summary>
|
||||
public int NumSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属库区
|
||||
/// </summary>
|
||||
public long? ReservoirAreaId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属库区列(小车进入库位的方向为列)
|
||||
/// </summary>
|
||||
public long? ReservoirAreaColumnId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属楼层编号(1-一楼 2-二楼)
|
||||
/// </summary>
|
||||
public int? Floor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// AGV名称
|
||||
/// </summary>
|
||||
public string MachineName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 确认时间
|
||||
/// </summary>
|
||||
public DateTime? ConfirmDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否禁用
|
||||
/// </summary>
|
||||
public bool IsDisabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格证号
|
||||
/// </summary>
|
||||
public string BarCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
public string CustomName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string MateriaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string MateriaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单个托盘上的物料数量
|
||||
/// </summary>
|
||||
public int MateriaNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批次号的生成规则为: 作业单号+日期+班次
|
||||
/// </summary>
|
||||
public string MateriaBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string MateriaCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 联动线出口,机械手设备唯一号
|
||||
/// </summary>
|
||||
public string EquipmentNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 码头位置 1:北区 2:南区 3:人工 4:退货到车间 99:其它
|
||||
/// </summary>
|
||||
public int Transport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Erp回调Wms接口地址
|
||||
/// </summary>
|
||||
public string ErpCallWmsInterface { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Wms回调Erp接口地址
|
||||
/// </summary>
|
||||
public string WmsCallErpInterface { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModifiedTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Entity
|
||||
{
|
||||
public class UserInfo : AggregateRoot
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using JSMachine.WMS.Infrastructure.Helper;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Exstension
|
||||
{
|
||||
public static class SqlSugarExstension
|
||||
{
|
||||
public static async Task<bool> InsertableExecuteCommandAsync<TAggregateRoot>(this IInsertable<TAggregateRoot> updateable) where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
await updateable.ExecuteCommandAsync();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库插入过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> UpdateableExecuteCommandAsync<TAggregateRoot>(this IUpdateable<TAggregateRoot> updateable) where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
await updateable.ExecuteCommandAsync();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库更改过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> DeletetableExecuteCommandAsync<TAggregateRoot>(this IDeleteable<TAggregateRoot> updateable) where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
await updateable.ExecuteCommandAsync();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库删除过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<List<TAggregateRoot>> ToListExAsync<TAggregateRoot>(this ISugarQueryable<TAggregateRoot> sugarQueryable) where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await sugarQueryable.ToListAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询(多个)过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new List<TAggregateRoot>();
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<TAggregateRoot> FirstExAsync<TAggregateRoot>(this ISugarQueryable<TAggregateRoot> sugarQueryable, Expression<Func<TAggregateRoot, bool>> expression) where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await sugarQueryable.FirstAsync(expression);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询(单个)过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<int> CountExAsync<TAggregateRoot>(this ISugarQueryable<TAggregateRoot> sugarQueryable, Expression<Func<TAggregateRoot, bool>> expression=null) where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (expression == null)
|
||||
return await sugarQueryable.CountAsync();
|
||||
else
|
||||
return await sugarQueryable.CountAsync(expression);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询(计数)过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IAGVTaskRepository : IBaseRepository<AGVTask>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 领域聚合根标记接口,用于约束可由通用仓储持久化的实体。
|
||||
/// </summary>
|
||||
public interface IAggregateRoot
|
||||
{
|
||||
Guid Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using JSMachine.WMS.Domain.Repository;
|
||||
using SqlSugar;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 基于 SqlSugar 的通用仓储契约,提供聚合根的增删改查和分页能力。
|
||||
/// </summary>
|
||||
/// <typeparam name="TAggregateRoot">仓储管理的聚合根类型。</typeparam>
|
||||
public interface IBaseRepository<TAggregateRoot> where TAggregateRoot : AggregateRoot, IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置仓储共享的数据库作用域。
|
||||
/// </summary>
|
||||
public static SqlSugarScope DB { get; set; }
|
||||
|
||||
#region Add
|
||||
/// <summary>
|
||||
/// 添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(TAggregateRoot entity, SqlSugarScope sqlSugarScope = null);
|
||||
/// <summary>
|
||||
/// 添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="ignoreColumns">要忽略的字段</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(TAggregateRoot entity, params string[] ignoreColumns);
|
||||
/// <summary>
|
||||
/// 批量插入实体
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(List<TAggregateRoot> entities);
|
||||
/// <summary>
|
||||
/// 字典方式添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名称</param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add(string tableName, Dictionary<string, object> dic);
|
||||
/// <summary>
|
||||
/// 添加之前判断指定字段是否存在,不存在则添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddIfNotExist(TAggregateRoot entity, Expression<Func<TAggregateRoot, bool>> expression);
|
||||
#endregion
|
||||
|
||||
#region Delete
|
||||
/// <summary>
|
||||
/// 根据Id删除记录
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteById(Guid id, SqlSugarScope sqlSugarScope = null);
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id批量删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteBatch(Guid[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体删除
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteByEntity(TAggregateRoot aggregateRoot);
|
||||
/// <summary>
|
||||
/// 根据实体批量删除
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoots"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteByEntity(List<TAggregateRoot> aggregateRoots);
|
||||
/// <summary>
|
||||
/// 根据条件删除
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleByExpression(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
/// <summary>
|
||||
/// 更改单个实体
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingal(TAggregateRoot aggregateRoot);
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体但忽略指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="ignoredColumns">忽略指定的条件</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingal(TAggregateRoot aggregateRoot, Expression<Func<TAggregateRoot, object>> ignoredColumns);
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体但忽略指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="ignoredColumns">要忽略的列名</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingal(TAggregateRoot aggregateRoot, string[] ignoredColumns);
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体中指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="columns">要更改的列名</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditSingalWithSpecificCols(TAggregateRoot aggregateRoot, string[] columns);
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoots"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditBatch(List<TAggregateRoot> aggregateRoots);
|
||||
/// <summary>
|
||||
/// 快速批量更新
|
||||
/// </summary>
|
||||
/// <param name="dtos"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditBatchFast(List<TAggregateRoot> dtos);
|
||||
|
||||
/// <summary>
|
||||
/// 字典方式更改
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditByDic(string tableName, Dictionary<string, object> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 字典方式批量更改
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EditByDic(string tableName, List<Dictionary<string, object>> dic);
|
||||
#endregion
|
||||
|
||||
#region Query
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetAll();
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetAll(Expression<Func<TAggregateRoot, object>> orderByExpress, OrderByType orderByType);
|
||||
/// <summary>
|
||||
/// 分片查询所有
|
||||
/// </summary>
|
||||
/// <param name="fragmentSize"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
Task<List<TAggregateRoot>> GetAllFragment(int fragmentSize = 50000);
|
||||
/// <summary>
|
||||
/// 分片查询所有(带排序功能)
|
||||
/// </summary>
|
||||
/// <param name="orderByExpress">要排序的字段</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="fragmentSize">分片大小,分片越大效率越高,但是占用的内存也越大,需要合理考虑数据量和硬件性能确定此参数大小</param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetAllFragment(Expression<Func<TAggregateRoot, object>> orderByExpress, OrderByType orderByType, int fragmentSize = 200);
|
||||
|
||||
/// <summary>
|
||||
/// 查询数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> Count();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询数量
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> Count(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键查询
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAggregateRoot> QueryByKey(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的第一个
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAggregateRoot> GetSingalByExpression(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的第一个(带排序)
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <param name="orderByExpress"></param>
|
||||
/// <param name="orderByType"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAggregateRoot> GetSingalByExpression(
|
||||
Expression<Func<TAggregateRoot, bool>> expression,
|
||||
Expression<Func<TAggregateRoot, object>> orderByExpress,
|
||||
OrderByType orderByType);
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的所有实体
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetListByExpression(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
/// <summary>
|
||||
/// 查询满足条件的所有实体(带排序功能)
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <param name="orderByExpress"></param>
|
||||
/// <param name="orderByType">Asc = 0,Desc = 1</param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetListByExpression(Expression<Func<TAggregateRoot, bool>> expression,
|
||||
string filedName,
|
||||
OrderByType orderByType = OrderByType.Desc);
|
||||
/// <summary>
|
||||
/// 通过实体查询满足条件的数据
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetListWhereClass(TAggregateRoot aggregateRoot);
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="pageQueryCondition">当前页码</param>
|
||||
/// <returns></returns>
|
||||
Task<PagedResult<TAggregateRoot>> QueryByPage(PageQueryCondition pageQueryCondition);
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键批量查询
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> QueryByIds(Guid[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Exist(Expression<Func<TAggregateRoot, bool>> expression);
|
||||
#endregion
|
||||
|
||||
#region RawSql Sql操作
|
||||
/// <summary>
|
||||
/// sql查询,不带参数
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetBySql(string sql);
|
||||
/// <summary>
|
||||
/// sql查询,带参数 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<TAggregateRoot>> GetBySql(string sql, Dictionary<string, object> sqlParam);
|
||||
/// <summary>
|
||||
/// sql查询匿名类型
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<dynamic>> GetDynamicsBysql(string sql);
|
||||
/// <summary>
|
||||
/// sql查询匿名类型,附带参数 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<dynamic>> GetDynamicsBysql(string sql, Dictionary<string, object> sqlParam);
|
||||
/// <summary>
|
||||
/// 通过sql查询DataTable
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataTable> GetDataTableBysql(string sql);
|
||||
/// <summary>
|
||||
/// 通过sql查询DataTable, 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataTable> GetDataTableBysql(string sql, Dictionary<string, object> sqlParam);
|
||||
/// <summary>
|
||||
/// 执行原生sql
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="params"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> ExcuteSql(string sql, params SugarParameter[] @params);
|
||||
#endregion
|
||||
|
||||
#region 事务
|
||||
/// <summary>
|
||||
/// 开始事务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task BeginTran(SqlSugarScope sqlSugarScope);
|
||||
/// <summary>
|
||||
/// 提交事务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task CommitTran(SqlSugarScope sqlSugarScope);
|
||||
/// <summary>
|
||||
/// 回滚事务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task RollbackTran(SqlSugarScope sqlSugarScope);
|
||||
SqlSugarTransaction UseTranAsync();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库配置接口,用于不同数据库切换
|
||||
/// </summary>
|
||||
public interface IDbConnectionConfig
|
||||
{
|
||||
ConnectionConfig ConnectionConfig { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IERPTaskRepository : IBaseRepository<ERPTask>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IElevatorCountRepository : IBaseRepository<ElevatorCount>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IElevatorPlcQueueRepository : IBaseRepository<ElevatorPlcQueue>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IOperationLogRepository : IBaseRepository<OperationLog>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IRcsTaskRepository : IBaseRepository<RcsTask>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IStorageRackRepository : IBaseRepository<StorageRack>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
|
||||
namespace JSMachine.WMS.Domain.IRepository
|
||||
{
|
||||
public interface IUserInfoRepository : IBaseRepository<UserInfo>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.167" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JSMachine.WMS.Infrastructure\JSMachine.WMS.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class AGVTaskRepository : BccBaseRepository<AGVTask>, IAGVTaskRepository
|
||||
{
|
||||
public AGVTaskRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 领域实体的公共基类,提供主键和审计时间字段。
|
||||
/// 继承此类的实体可被通用仓储按主键进行持久化操作。
|
||||
/// </summary>
|
||||
public class AggregateRoot : IAggregateRoot
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
/// <summary>
|
||||
/// 实体唯一标识,同时映射为数据库主键。
|
||||
/// </summary>
|
||||
public Guid Id
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体创建时间。
|
||||
/// </summary>
|
||||
public DateTime? CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实体最后修改时间。
|
||||
/// </summary>
|
||||
public DateTime? LastModifiedTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,617 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.Exstension;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using JSMachine.WMS.Infrastructure.Helper;
|
||||
using JSMachine.WMS.Infrastructure.LambdaHelp;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using NPOI.OpenXmlFormats.Dml;
|
||||
using SqlSugar;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// SqlSugar官方文档 https://www.donet5.com/Doc/1/1193
|
||||
/// 参考 SqlSugar官方文档 数据查询->表格查询即可实现动态条件查询,可不必使用自定义的框架
|
||||
/// </summary>
|
||||
/// <typeparam name="TAggregateRoot"></typeparam>
|
||||
public class BaseRepository<TAggregateRoot> : IBaseRepository<TAggregateRoot> where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
private SqlSugarScope _sqlSugarScope;
|
||||
public BaseRepository(SqlSugarScope sqlSugarScope)
|
||||
{
|
||||
_sqlSugarScope = sqlSugarScope;
|
||||
}
|
||||
|
||||
|
||||
#region Add
|
||||
/// <summary>
|
||||
/// 添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Add(TAggregateRoot entity, SqlSugarScope sqlSugarScope = null)
|
||||
{
|
||||
if (sqlSugarScope == null)
|
||||
|
||||
return await _sqlSugarScope.Insertable(entity).InsertableExecuteCommandAsync();
|
||||
else
|
||||
return await sqlSugarScope.Insertable(entity).ExecuteCommandAsync()>=0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="ignoreColumns">要忽略的字段</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Add(TAggregateRoot entity, params string[] ignoreColumns)
|
||||
{
|
||||
return await _sqlSugarScope.Insertable(entity).IgnoreColumns(ignoreColumns).InsertableExecuteCommandAsync();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量插入
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Add(List<TAggregateRoot> entities)
|
||||
{
|
||||
return await _sqlSugarScope.Insertable(entities).InsertableExecuteCommandAsync();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 字典方式添加单个实体
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名称</param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Add(string tableName, Dictionary<string, object> dic)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _sqlSugarScope.Insertable(dic).AS(tableName).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库插入过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加之前判断指定字段是否存在,不存在则添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddIfNotExist(TAggregateRoot entity, Expression<Func<TAggregateRoot, bool>> expression)
|
||||
{
|
||||
bool bRte = await this.Exist(expression);
|
||||
|
||||
if (bRte)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return await Add(entity);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Delete
|
||||
/// <summary>
|
||||
/// 根据Id删除记录
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DeleteById(Guid id, SqlSugarScope sqlSugarScope = null)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
return false;
|
||||
if (sqlSugarScope == null)
|
||||
|
||||
return await _sqlSugarScope.Deleteable<TAggregateRoot>().In(id).DeletetableExecuteCommandAsync();
|
||||
else
|
||||
return await sqlSugarScope.Deleteable<TAggregateRoot>().In(id).ExecuteCommandAsync()>=0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id批量删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DeleteBatch(Guid[] ids)
|
||||
{
|
||||
if (ids == null || ids.Length == 0)
|
||||
return false;
|
||||
|
||||
return await _sqlSugarScope.Deleteable<TAggregateRoot>().In(ids).DeletetableExecuteCommandAsync();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体删除
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DeleteByEntity(TAggregateRoot aggregateRoot)
|
||||
{
|
||||
return await _sqlSugarScope.Deleteable(aggregateRoot).DeletetableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体批量删除
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoots"></param>
|
||||
/// <returns>受影响行数不等于实体数量视为删除失败</returns>
|
||||
public async Task<bool> DeleteByEntity(List<TAggregateRoot> aggregateRoots)
|
||||
{
|
||||
return await _sqlSugarScope.Deleteable(aggregateRoots).DeletetableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件删除
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DeleByExpression(Expression<Func<TAggregateRoot, bool>> expression)
|
||||
{
|
||||
return await _sqlSugarScope.Deleteable<TAggregateRoot>().Where(expression).DeletetableExecuteCommandAsync();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
/// <summary>
|
||||
/// 更改单个实体
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditSingal(TAggregateRoot aggregateRoot)
|
||||
{
|
||||
return await _sqlSugarScope.Updateable(aggregateRoot).WhereColumns(p => p.Id).UpdateableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体但忽略指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="ignoredColumns">忽略指定的条件</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditSingal(TAggregateRoot aggregateRoot, Expression<Func<TAggregateRoot, object>> ignoredColumns)
|
||||
{
|
||||
return await _sqlSugarScope.Updateable(aggregateRoot).WhereColumns(p => p.Id).IgnoreColumns(ignoredColumns).UpdateableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体但忽略指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="ignoredColumns">要忽略的列名</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditSingal(TAggregateRoot aggregateRoot, string[] ignoredColumns)
|
||||
{
|
||||
return await _sqlSugarScope.Updateable(aggregateRoot).WhereColumns(p => p.Id).IgnoreColumns(ignoredColumns).UpdateableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改单个实体中指定的列
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="columns">要更改的列名</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditSingalWithSpecificCols(TAggregateRoot aggregateRoot, string[] columns)
|
||||
{
|
||||
return await _sqlSugarScope.Updateable(aggregateRoot).WhereColumns(p => p.Id).UpdateColumns(columns).UpdateableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoots"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditBatch(List<TAggregateRoot> aggregateRoots)
|
||||
{
|
||||
if (aggregateRoots == null || aggregateRoots.Count == 0)
|
||||
return false;
|
||||
|
||||
return await _sqlSugarScope.Updateable(aggregateRoots).UpdateableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 快速批量更新
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoots"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditBatchFast(List<TAggregateRoot> aggregateRoots)
|
||||
{
|
||||
if (aggregateRoots == null || aggregateRoots.Count == 0)
|
||||
return false;
|
||||
|
||||
return await _sqlSugarScope.Fastest<TAggregateRoot>().BulkUpdateAsync(aggregateRoots) == aggregateRoots.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典方式更改
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditByDic(string tableName, Dictionary<string, object> dic)
|
||||
{
|
||||
return await _sqlSugarScope.Updateable<TAggregateRoot>(dic).AS(tableName).WhereColumns("Id").UpdateableExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典方式批量更改
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditByDic(string tableName, List<Dictionary<string, object>> dic)
|
||||
{
|
||||
return await _sqlSugarScope.Updateable<TAggregateRoot>(dic).AS(tableName).WhereColumns("Id").UpdateableExecuteCommandAsync();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Query
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetAll()
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().ToListExAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetAll(Expression<Func<TAggregateRoot, object>> orderByExpress, OrderByType orderByType)
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().OrderBy(orderByExpress, orderByType).ToListExAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分片查询所有
|
||||
/// </summary>
|
||||
/// <param name="fragmentSize"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetAllFragment(int fragmentSize = 50000)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<TAggregateRoot> aggregateRoots = new();
|
||||
|
||||
await _sqlSugarScope.Queryable<TAggregateRoot>().ForEachAsync(p => aggregateRoots.Add(p), fragmentSize);
|
||||
|
||||
return aggregateRoots;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new List<TAggregateRoot>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分片查询所有
|
||||
/// </summary>
|
||||
/// <param name="fragmentSize"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetAllFragment(Expression<Func<TAggregateRoot, object>> orderByExpress, OrderByType orderByType, int fragmentSize = 200)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<TAggregateRoot> aggregateRoots = new();
|
||||
|
||||
await _sqlSugarScope.Queryable<TAggregateRoot>().OrderBy(orderByExpress, orderByType).ForEachAsync(p => aggregateRoots.Add(p), fragmentSize);
|
||||
|
||||
return aggregateRoots;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new List<TAggregateRoot>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键查询
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TAggregateRoot> QueryByKey(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().InSingleAsync(key);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的第一个
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TAggregateRoot> GetSingalByExpression(Expression<Func<TAggregateRoot, bool>> expression)
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().FirstExAsync(expression);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的第一个
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TAggregateRoot> GetSingalByExpression(
|
||||
Expression<Func<TAggregateRoot, bool>> expression,
|
||||
Expression<Func<TAggregateRoot, object>> orderByExpress,
|
||||
OrderByType orderByType)
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().OrderBy(orderByExpress, orderByType).FirstExAsync(expression);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的所有实体
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetListByExpression(Expression<Func<TAggregateRoot, bool>> expression)
|
||||
{
|
||||
return await _sqlSugarScope.CopyNew().Queryable<TAggregateRoot>().Where(expression).ToListExAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询满足条件的所有实体(带排序功能)
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <param name="orderByExpress"></param>
|
||||
/// <param name="orderByType">Asc = 0,Desc = 1</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetListByExpression(Expression<Func<TAggregateRoot, bool>> expression,
|
||||
string filedName,
|
||||
OrderByType orderByType = OrderByType.Desc)
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().Where(expression).OrderBy(LambdaHelper<TAggregateRoot>.GetOrderExpression<object>(filedName), orderByType).ToListExAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过实体查询满足条件的数据
|
||||
/// </summary>
|
||||
/// <param name="aggregateRoot"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetListWhereClass(TAggregateRoot aggregateRoot)
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().WhereClass(aggregateRoot, true).ToListExAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="pageQueryCondition">当前页码</param>
|
||||
public async Task<PagedResult<TAggregateRoot>> QueryByPage(PageQueryCondition pageQueryCondition)
|
||||
{
|
||||
try
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
List<TAggregateRoot> data = await _sqlSugarScope.Queryable<TAggregateRoot>()
|
||||
.Where(pageQueryCondition.Filters)
|
||||
.OrderBy(LambdaHelper<TAggregateRoot>.GetOrderExpression<object>(pageQueryCondition.OrderByFiled), pageQueryCondition.OrderByType)
|
||||
.ToPageListAsync(pageQueryCondition.CurrentPage, pageQueryCondition.PageSize, total);
|
||||
|
||||
return new PagedResult<TAggregateRoot>(total, pageQueryCondition.PageSize, pageQueryCondition.CurrentPage, data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new PagedResult<TAggregateRoot>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="pageQueryCondition">当前页码</param>
|
||||
public async Task<PagedResult<TAggregateRoot>> QueryByPage(Expression<Func<TAggregateRoot,bool>> expression,int pageSize,int currentPage,string orderByFiled,OrderByType orderByType)
|
||||
{
|
||||
try
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
List<TAggregateRoot> data = await _sqlSugarScope.Queryable<TAggregateRoot>()
|
||||
.Where(expression)
|
||||
.OrderBy(LambdaHelper<TAggregateRoot>.GetOrderExpression<object>(orderByFiled), orderByType)
|
||||
.ToPageListAsync(currentPage, pageSize, total);
|
||||
|
||||
return new PagedResult<TAggregateRoot>(total, pageSize, currentPage, data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new PagedResult<TAggregateRoot>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Exist(Expression<Func<TAggregateRoot, bool>> expression)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().AnyAsync(expression);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> Count()
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().CountExAsync();
|
||||
}
|
||||
|
||||
public async Task<int> Count(Expression<Func<TAggregateRoot, bool>> expression)
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().CountExAsync(expression);
|
||||
}
|
||||
|
||||
public async Task<List<TAggregateRoot>> QueryByIds(Guid[] ids)
|
||||
{
|
||||
return await _sqlSugarScope.Queryable<TAggregateRoot>().Where(p => ids.Contains(p.Id)).ToListExAsync();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RawSql sql操作
|
||||
/// <summary>
|
||||
/// sql查询,带参数 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetBySql(string sql, Dictionary<string, object> sqlParam)
|
||||
{
|
||||
return await _sqlSugarScope.SqlQueryable<TAggregateRoot>(sql).AddParameters(sqlParam?.Select(p => new SugarParameter(p.Key, p.Value)).ToList()).ToListExAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// sql查询,不带参数
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TAggregateRoot>> GetBySql(string sql)
|
||||
{
|
||||
|
||||
return await _sqlSugarScope.SqlQueryable<TAggregateRoot>(sql).ToListExAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// sql查询匿名类型
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<dynamic>> GetDynamicsBysql(string sql)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _sqlSugarScope.SqlQueryable<dynamic>(sql).ToListAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new List<dynamic>();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// sql查询匿名类型,附带参数 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<dynamic>> GetDynamicsBysql(string sql, Dictionary<string, object> sqlParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _sqlSugarScope.SqlQueryable<dynamic>(sql).AddParameters(sqlParam?.Select(p => new SugarParameter(p.Key, p.Value)).ToList()).ToListAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new List<dynamic>();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过sql查询DataTable
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<DataTable> GetDataTableBysql(string sql)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _sqlSugarScope.Ado.GetDataTableAsync(sql);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return new DataTable();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过sql查询DataTable, 参数示例 select * from table where id=@id and name=@name 则字典的key为 "@id"
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParam"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<DataTable> GetDataTableBysql(string sql, Dictionary<string, object> sqlParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _sqlSugarScope.Ado.GetDataTableAsync(sql, sqlParam?.Select(p => new SugarParameter(p.Key, p.Value)).ToList());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库查询过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行原生sql
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="params"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ExcuteSql(string sql, params SugarParameter[] @params)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _sqlSugarScope.Ado.ExecuteCommandAsync(sql, @params);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error($"执行数据库原生sql过程中发生错误,{ex.Message}\n{ex.StackTrace}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事务操作
|
||||
public async Task BeginTran(SqlSugarScope sqlSugarScope)
|
||||
{
|
||||
LogHelper.Info($"开始事务 {sqlSugarScope.ContextID}");
|
||||
|
||||
await sqlSugarScope.AsTenant().BeginTranAsync();
|
||||
}
|
||||
|
||||
public async Task CommitTran(SqlSugarScope sqlSugarScope)
|
||||
{
|
||||
LogHelper.Info($"提交事务 {sqlSugarScope.ContextID}");
|
||||
|
||||
await sqlSugarScope.AsTenant().CommitTranAsync();
|
||||
}
|
||||
|
||||
public async Task RollbackTran(SqlSugarScope sqlSugarScope)
|
||||
{
|
||||
LogHelper.Info($"回滚事务 {sqlSugarScope.ContextID}");
|
||||
await sqlSugarScope.AsTenant().RollbackTranAsync();
|
||||
}
|
||||
|
||||
public SqlSugarTransaction UseTranAsync()
|
||||
{
|
||||
return _sqlSugarScope.UseTran();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using JSMachine.WMS.Infrastructure.Helper;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class BccBaseRepository<TAggregateRoot> : BaseRepository<TAggregateRoot> where TAggregateRoot : AggregateRoot, IAggregateRoot, new()
|
||||
{
|
||||
public BccBaseRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using JSMachine.WMS.Common;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// BCC 数据库连接配置,将应用配置映射为 SqlSugar 的 SQL Server 连接定义。
|
||||
/// </summary>
|
||||
public class BccDbConnectionConfig : IDbConnectionConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取数据库连接配置;连接字符串由全局应用配置提供。
|
||||
/// </summary>
|
||||
public ConnectionConfig ConnectionConfig => new()
|
||||
{
|
||||
ConfigId = "Bcc",
|
||||
DbType = DbType.SqlServer,
|
||||
IsAutoCloseConnection = true,
|
||||
ConnectionString = Global.AppSettings.DataBaseCon,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
LanguageType=LanguageType.Chinese
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class ERPTaskRepository : BccBaseRepository<ERPTask>, IERPTaskRepository
|
||||
{
|
||||
public ERPTaskRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class ElevatorCountRepository : BccBaseRepository<ElevatorCount>, IElevatorCountRepository
|
||||
{
|
||||
public ElevatorCountRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class ElevatorPlcQueueRepository : BccBaseRepository<ElevatorPlcQueue>, IElevatorPlcQueueRepository
|
||||
{
|
||||
public ElevatorPlcQueueRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class OperationLogRepository : BccBaseRepository<OperationLog>, IOperationLogRepository
|
||||
{
|
||||
public OperationLogRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class RcsTaskRepository : BccBaseRepository<RcsTask>, IRcsTaskRepository
|
||||
{
|
||||
public RcsTaskRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class StorageRackRepository : BccBaseRepository<StorageRack>, IStorageRackRepository
|
||||
{
|
||||
public StorageRackRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Domain.IRepository;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.Domain.Repository
|
||||
{
|
||||
public class UserInfoRepository : BccBaseRepository<UserInfo>, IUserInfoRepository
|
||||
{
|
||||
public UserInfoRepository(SqlSugarScope sqlSugarScope) : base(sqlSugarScope)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user