22 changed files with 1190 additions and 4 deletions
@ -0,0 +1,58 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
[Display(Name = "物品基本信息")] |
||||
|
|
||||
|
public class EquipmentDTO : SfsBaseDataDTOBase, IHasCode |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 器具编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "器具编号")] |
||||
|
public string Code { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "类型")] |
||||
|
public string Type { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 型号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "型号")] |
||||
|
public string Model { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 库位编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "库位编号")] |
||||
|
public string LocCode { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "状态")] |
||||
|
public int State { get; set; } = 0; |
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "备注")] |
||||
|
public string Remark { get; set; } = string.Empty; |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建人
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建人")] |
||||
|
public string Creator { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建时间
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建时间")] |
||||
|
public DateTime CreatTime { get; set; } = DateTime.Now; |
||||
|
|
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
[Display(Name = "物料信息")] |
||||
|
public class EquipmentForDongyangExportDTO |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 器具编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "器具编号")] |
||||
|
public string Code { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "类型")] |
||||
|
public string Type { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 型号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "型号")] |
||||
|
public string Model { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 库位编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "库位编号")] |
||||
|
public string LocCode { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "状态")] |
||||
|
public int State { get; set; } = 0; |
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "备注")] |
||||
|
public string Remark { get; set; } = string.Empty; |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建人
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建人")] |
||||
|
public string Creator { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建时间
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建时间")] |
||||
|
public DateTime CreatTime { get; set; } = DateTime.Now; |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
public static class EquipmentPermissions |
||||
|
{ |
||||
|
|
||||
|
public const string Default = BasedataPermissions.GroupName + "." + nameof(Equipment); |
||||
|
public const string Create = Default + "." + BasedataPermissions.CreateStr; |
||||
|
public const string Update = Default + "." + BasedataPermissions.UpdateStr; |
||||
|
public const string Delete = Default + "." + BasedataPermissions.DeleteStr; |
||||
|
|
||||
|
public static void AddEquipmentPermission(this PermissionGroupDefinition permissionGroup) |
||||
|
{ |
||||
|
var EquipmentPermission = permissionGroup.AddPermission(Default, BasedataPermissionDefinitionProvider.L(nameof(Equipment))); |
||||
|
EquipmentPermission.AddChild(Create, BasedataPermissionDefinitionProvider.L(BasedataPermissions.CreateStr)); |
||||
|
EquipmentPermission.AddChild(Update, BasedataPermissionDefinitionProvider.L(BasedataPermissions.UpdateStr)); |
||||
|
EquipmentPermission.AddChild(Delete, BasedataPermissionDefinitionProvider.L(BasedataPermissions.DeleteStr)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Win_in.Sfs.Shared.Application.Contracts; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
public interface IEquipmentAppService |
||||
|
: ISfsBaseDataAppServiceBase<EquipmentDTO, SfsBaseDataRequestInputBase, EquipmentEditInput> |
||||
|
, ISfsGetByCodeAppService<EquipmentDTO> |
||||
|
, ISfsCheckAppService<EquipmentCheckInput> |
||||
|
, ISfsUpsertAppService<EquipmentEditInput> |
||||
|
{ |
||||
|
//Task<bool> CheckItemIsAvailable(string itemCode);
|
||||
|
//[HttpGet("check-item-is-available-no-select-sql")]
|
||||
|
//void CheckItemIsAvailable(EquipmentDTO EquipmentDTO);
|
||||
|
|
||||
|
//Task<List<EquipmentDTO>> GetListByNameAsync(string name);
|
||||
|
|
||||
|
//Task<EquipmentDTO> GetOrAddAsync(EquipmentEditInput input);
|
||||
|
|
||||
|
//Task<EnumItemManageType> GetManageTypeAsync(string itemCode);
|
||||
|
//Task<Dictionary<string, EnumItemManageType>> GetManageTypesAsync(List<string> itemCodes);
|
||||
|
|
||||
|
//Task UpsertAsyncByInterface(EquipmentEditInput input);
|
||||
|
//Task UpsertStdPackQtyAsync(string itemCode, decimal stdpackqty);
|
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
public class EquipmentCheckInput |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 器具编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "器具编号")] |
||||
|
public string Code { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "类型")] |
||||
|
public string Type { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 型号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "型号")] |
||||
|
public string Model { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 库位编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "库位编号")] |
||||
|
public string LocCode { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "状态")] |
||||
|
public int State { get; set; } = 0; |
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "备注")] |
||||
|
public string Remark { get; set; } = string.Empty; |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建人
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建人")] |
||||
|
public string Creator { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建时间
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建时间")] |
||||
|
public DateTime CreatTime { get; set; }=DateTime.Now; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,228 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
public class EquipmentEditInput : SfsBaseDataCreateOrUpdateInputBase |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 器具编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "器具编号")] |
||||
|
[Required(ErrorMessage = "{0}是必填项")] |
||||
|
public string Code { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "类型")] |
||||
|
public string Type { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 型号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "型号")] |
||||
|
public string Model { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 库位编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "库位编号")] |
||||
|
public string LocCode { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "状态")] |
||||
|
public int State { get; set; } = 0; |
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "备注")] |
||||
|
public string Remark { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 创建人
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建人")] |
||||
|
public string Creator { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建时间
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建时间")] |
||||
|
public DateTime CreatTime { get; set; }=DateTime.Now; |
||||
|
|
||||
|
|
||||
|
|
||||
|
//#region Base
|
||||
|
///// <summary>
|
||||
|
///// 名称
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "名称")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Name { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 描述1
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "描述1")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Desc1 { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 描述2
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "描述2")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Desc2 { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 状态
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "状态")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项")]
|
||||
|
//public EnumItemStatus Status { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 制造件
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "制造件")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项")]
|
||||
|
//public bool CanMake { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 采购件
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "采购件")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项")]
|
||||
|
//public bool CanBuy { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 外包件
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "外包件")]
|
||||
|
//public bool CanOutsourcing { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 回收件
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "回收件")]
|
||||
|
//public bool IsRecycled { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 类型
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "类型")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Type { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 种类
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "种类")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Category { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 分组
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "分组")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Group { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 颜色
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "颜色")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Color { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 配置
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "配置")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Configuration { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 虚零件
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "虚零件(Is phantom)")]
|
||||
|
//public virtual bool IsPhantom { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 基本计量单位
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "基本计量单位")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string BasicUom { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 标包数
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "标包数")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项")]
|
||||
|
//public decimal StdPackQty { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// ABC类
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "ABC类")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项", AllowEmptyStrings = true)]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string AbcClass { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 项目
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "项目")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Project { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 版本
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "版本")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Version { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 工程变革
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "工程变革")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Eco { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 有效期
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "有效期")]
|
||||
|
//public int Validity { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 有效期单位
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "有效期单位")]
|
||||
|
//public EnumValidityUnit ValidityUnit { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 管理类型
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "管理类型")]
|
||||
|
//public EnumItemManageType ManageType { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 打印标签用的一个等级
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "Elevel")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Elevel { get; set; }
|
||||
|
//#endregion
|
||||
|
|
||||
|
//#region Create
|
||||
|
///// <summary>
|
||||
|
///// 代码
|
||||
|
///// </summary>
|
||||
|
//[Display(Name = "代码")]
|
||||
|
//[Required(ErrorMessage = "{0}是必填项")]
|
||||
|
//[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
|
||||
|
//public string Code { get; set; }
|
||||
|
//#endregion
|
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Application.Contracts; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
[Display(Name = "物品")] |
||||
|
public class EquipmentImportInput : SfsBaseDataImportInputBase |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 器具编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "器具编号")] |
||||
|
[Required(ErrorMessage = "{0}是必填项")] |
||||
|
public string Code { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "类型")] |
||||
|
public string Type { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 型号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "型号")] |
||||
|
public string Model { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 库位编号
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "库位编号")] |
||||
|
public string LocCode { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "状态")] |
||||
|
public int State { get; set; } = 0; |
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "备注")] |
||||
|
public string Remark { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// 创建人
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建人")] |
||||
|
public string Creator { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建时间
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "创建时间")] |
||||
|
public DateTime CreatTime { get; set; } = DateTime.Now; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,236 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Linq; |
||||
|
using System.Linq.Expressions; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Validation; |
||||
|
using Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
using Win_in.Sfs.Basedata.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application; |
||||
|
|
||||
|
[Authorize] |
||||
|
[Route($"{BasedataConsts.RootPath}Equipment")] |
||||
|
public class EquipmentAppService |
||||
|
: SfsBaseDataWithCodeAppServiceBase<Equipment, EquipmentDTO, SfsBaseDataRequestInputBase, EquipmentEditInput, EquipmentImportInput> |
||||
|
, IEquipmentAppService |
||||
|
{ |
||||
|
//private readonly ItemValidator _itemValidator;
|
||||
|
private readonly IEquipmentManager _manager; |
||||
|
private new readonly IEquipmentRepository _repository; |
||||
|
|
||||
|
public EquipmentAppService( |
||||
|
IEquipmentRepository repository, |
||||
|
IDistributedCache<EquipmentDTO> cache, |
||||
|
// ItemValidator itemValidator,
|
||||
|
IEquipmentManager manager) |
||||
|
: base(repository, cache) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
//_itemValidator = itemValidator;
|
||||
|
_manager = manager; |
||||
|
base.CreatePolicyName = EquipmentPermissions.Create; |
||||
|
base.UpdatePolicyName = EquipmentPermissions.Update; |
||||
|
base.DeletePolicyName = EquipmentPermissions.Delete; |
||||
|
} |
||||
|
|
||||
|
[HttpPost("check")] |
||||
|
//[Authorize(ErpLocationPermissions.Default)]
|
||||
|
|
||||
|
public virtual async Task CheckAsync(string code, EquipmentCheckInput input) |
||||
|
{ |
||||
|
await Task.CompletedTask.ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService<ICategoryAppService>();
|
||||
|
//protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService<IItemCategoryAppService>();
|
||||
|
|
||||
|
//[HttpPost("check")]
|
||||
|
//public virtual async Task CheckAsync(string code, EquipmentCheckInput input)
|
||||
|
//{
|
||||
|
// var result = new AbpValidationResult();
|
||||
|
// _itemValidator.CheckFormat(code);
|
||||
|
// var dto = await GetByCodeAsync(code).ConfigureAwait(false);
|
||||
|
// var entity = ObjectMapper.Map<EquipmentDTO, Equipment>(dto);
|
||||
|
// //_itemValidator.CheckCanBuy(entity, input.CanBuy, result);
|
||||
|
// //_itemValidator.CheckCanMake(entity, input.CanMake, result);
|
||||
|
// //_itemValidator.CheckStatus(entity, input.Statuses, result);
|
||||
|
// //_itemValidator.CheckProject(entity, input.Projects, result);
|
||||
|
// //await _itemValidator.CheckCategoryAsync(entity, input.Categories, result).ConfigureAwait(false);
|
||||
|
// if (result.Errors.Count > 0)
|
||||
|
// {
|
||||
|
// throw new AbpValidationException(result.Errors);
|
||||
|
// }
|
||||
|
//}
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 检物品状态 是否可用
|
||||
|
///// </summary>
|
||||
|
///// <param name="itemCode"></param>
|
||||
|
///// <returns></returns>
|
||||
|
///// <exception cref="NotImplementedException"></exception>
|
||||
|
//[HttpGet("check-item-is-available")]
|
||||
|
//public virtual async Task<bool> CheckItemIsAvailable(string itemCode)
|
||||
|
//{
|
||||
|
// var entity = await _repository.FindAsync(c => c.Code == itemCode).ConfigureAwait(false);
|
||||
|
|
||||
|
// if (entity == null)
|
||||
|
// {
|
||||
|
// throw new UserFriendlyException($"未找到代码为 {itemCode} 的物品");
|
||||
|
// }
|
||||
|
|
||||
|
// return entity.Status == EnumItemStatus.Active;
|
||||
|
//}
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检物品状态 是否可用(不查询数据库 直接根据对象判断)
|
||||
|
/// </summary>
|
||||
|
/// <param name="EquipmentDTO"></param>
|
||||
|
/// <returns></returns>
|
||||
|
//[HttpGet("check-item-is-available-no-select-sql")]
|
||||
|
//public void CheckItemIsAvailable(EquipmentDTO EquipmentDTO)
|
||||
|
//{
|
||||
|
// if (EquipmentDTO != null && EquipmentDTO.Status != EnumItemStatus.Active)
|
||||
|
// {
|
||||
|
// throw new UserFriendlyException($"物料 {EquipmentDTO.Code} 状态为 {EquipmentDTO.Status} ,不是可用状态");
|
||||
|
// }
|
||||
|
//}
|
||||
|
|
||||
|
//[HttpGet("{id}")]
|
||||
|
//public override async Task<EquipmentDTO> GetAsync(Guid id)
|
||||
|
//{
|
||||
|
// var dto = await base.GetAsync(id).ConfigureAwait(false);
|
||||
|
|
||||
|
// dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false);
|
||||
|
|
||||
|
// return dto;
|
||||
|
//}
|
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="name"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||
|
//[HttpGet("list-by-name")]
|
||||
|
//public virtual async Task<List<EquipmentDTO>> GetListByNameAsync(string name)
|
||||
|
//{
|
||||
|
// var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false);
|
||||
|
// var dtos = ObjectMapper.Map<List<Equipment>, List<EquipmentDTO>>(entities);
|
||||
|
// return dtos;
|
||||
|
//}
|
||||
|
|
||||
|
//[HttpGet("get-manage-type")]
|
||||
|
//public virtual async Task<EnumItemManageType> GetManageTypeAsync(string itemCode)
|
||||
|
//{
|
||||
|
// var entity = await GetByCodeAsync(itemCode).ConfigureAwait(false);
|
||||
|
// Check.NotNull(entity, "物品代码", $"物品 {itemCode} 不存在");
|
||||
|
// return entity.ManageType;
|
||||
|
//}
|
||||
|
|
||||
|
//[HttpGet("get-manage-types")]
|
||||
|
//public virtual async Task<Dictionary<string, EnumItemManageType>> GetManageTypesAsync(List<string> itemCodes)
|
||||
|
//{
|
||||
|
// var dtos = await GetByCodesAsync(itemCodes).ConfigureAwait(false);
|
||||
|
// var itemManageTypes = dtos.ToDictionary(dto => dto.Code, dto => dto.ManageType);
|
||||
|
// return itemManageTypes;
|
||||
|
//}
|
||||
|
|
||||
|
//[HttpPost("get-or-add")]
|
||||
|
//public virtual async Task<EquipmentDTO> GetOrAddAsync(EquipmentEditInput input)
|
||||
|
//{
|
||||
|
// var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false);
|
||||
|
// if (result == null)
|
||||
|
// {
|
||||
|
// var entity = ObjectMapper.Map<EquipmentEditInput, Equipment>(input);
|
||||
|
// result = await _repository.InsertAsync(entity, true).ConfigureAwait(false);
|
||||
|
// }
|
||||
|
|
||||
|
// var dto = ObjectMapper.Map<Equipment, EquipmentDTO>(result);
|
||||
|
// return dto;
|
||||
|
//}
|
||||
|
|
||||
|
//[HttpPost("list")]
|
||||
|
//public override async Task<PagedResultDto<EquipmentDTO>> GetPagedListByFilterAsync(
|
||||
|
// SfsBaseDataRequestInputBase sfsRequestInput,
|
||||
|
// bool includeDetails = false,
|
||||
|
// CancellationToken cancellationToken = default)
|
||||
|
//{
|
||||
|
// Expression<Func<Equipment, bool>> expression = sfsRequestInput.Condition.Filters?.Count > 0
|
||||
|
// ? sfsRequestInput.Condition.Filters.ToLambda<Equipment>()
|
||||
|
// : p => true;
|
||||
|
// var pageResult = await GetPagedListAsync(
|
||||
|
// expression,
|
||||
|
// sfsRequestInput.SkipCount,
|
||||
|
// sfsRequestInput.MaxResultCount,
|
||||
|
// sfsRequestInput.Sorting,
|
||||
|
// includeDetails,
|
||||
|
// cancellationToken).ConfigureAwait(false);
|
||||
|
|
||||
|
// foreach (var item in pageResult.Items)
|
||||
|
// {
|
||||
|
// item.ItemCategoryDictionary = await GetItemCategory(item.Code).ConfigureAwait(false);
|
||||
|
// }
|
||||
|
|
||||
|
// return pageResult;
|
||||
|
//}
|
||||
|
|
||||
|
//[HttpPost("upsert")]
|
||||
|
//public virtual async Task UpsertAsync(EquipmentEditInput input)
|
||||
|
//{
|
||||
|
// var entity = ObjectMapper.Map<EquipmentEditInput, Equipment>(input);
|
||||
|
// await _repository.UpsertAsync(entity).ConfigureAwait(false);
|
||||
|
//}
|
||||
|
//[HttpPost("upsert-interface")]
|
||||
|
//public virtual async Task UpsertAsyncByInterface(EquipmentEditInput input)
|
||||
|
//{
|
||||
|
// var entity = ObjectMapper.Map<EquipmentEditInput, Equipment>(input);
|
||||
|
// await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false);
|
||||
|
//}
|
||||
|
|
||||
|
//protected override Expression<Func<Equipment, bool>> BuildSearchExpression(string keyWord)
|
||||
|
//{
|
||||
|
// Expression<Func<Equipment, bool>> expression = p =>
|
||||
|
// p.Code.Contains(keyWord)
|
||||
|
// || p.Name.Contains(keyWord)
|
||||
|
// || p.Desc1.Contains(keyWord)
|
||||
|
// || p.Desc2.Contains(keyWord)
|
||||
|
// || p.AbcClass.Contains(keyWord)
|
||||
|
// || p.BasicUom.Contains(keyWord)
|
||||
|
// || p.Elevel.Contains(keyWord)
|
||||
|
// || p.Project.Contains(keyWord)
|
||||
|
// || p.Version.Contains(keyWord);
|
||||
|
// return expression;
|
||||
|
//}
|
||||
|
|
||||
|
//private async Task<Dictionary<string, string>> GetItemCategory(string itemCode)
|
||||
|
//{
|
||||
|
// // var itemCategorys = await this._itemCategoryApp.GetListByItemCode(itemCode).ConfigureAwait(false);
|
||||
|
|
||||
|
// // return itemCategorys.ToDictionary(x => x.CategoryCode, y => y.Value);
|
||||
|
//}
|
||||
|
|
||||
|
[HttpPost("upsert")] |
||||
|
|
||||
|
public virtual async Task UpsertAsync(EquipmentEditInput input) |
||||
|
{ |
||||
|
var entity = ObjectMapper.Map<EquipmentEditInput, Equipment>(input); |
||||
|
await _repository.UpsertAsync(entity).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
using AutoMapper; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application; |
||||
|
|
||||
|
public partial class BasedataApplicationAutoMapperProfile : Profile |
||||
|
{ |
||||
|
private void EquipmentAutoMapperProfile() |
||||
|
{ |
||||
|
CreateMap<Equipment, EquipmentDTO>() |
||||
|
|
||||
|
.ReverseMap(); |
||||
|
|
||||
|
CreateMap<EquipmentImportInput, Equipment>() |
||||
|
.IgnoreAuditedObjectProperties() |
||||
|
.Ignore(x => x.TenantId) |
||||
|
.Ignore(x => x.Remark) |
||||
|
.Ignore(x => x.ExtraProperties) |
||||
|
.Ignore(x => x.ConcurrencyStamp) |
||||
|
; |
||||
|
|
||||
|
//CreateMap<Equipment, EquipmentImportInput>()
|
||||
|
|
||||
|
//CreateMap<Equipment, EquipmentForDongyangExportDTO>()
|
||||
|
// .Ignore(x => x.ItemCategory)
|
||||
|
// .Ignore(x => x.Color);
|
||||
|
CreateMap<EquipmentEditInput, Equipment>() |
||||
|
.IgnoreAuditedObjectProperties() |
||||
|
.Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id); |
||||
|
} |
||||
|
} |
@ -0,0 +1,160 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Entities; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 物品基本信息
|
||||
|
/// </summary>
|
||||
|
public class Equipment : SfsBaseDataAggregateRootBase, IHasCode |
||||
|
{ |
||||
|
|
||||
|
[IgnoreUpdate] |
||||
|
/// <summary>
|
||||
|
/// 器具编号
|
||||
|
/// </summary>
|
||||
|
public string Code { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 类型
|
||||
|
/// </summary>
|
||||
|
public string Type { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 型号
|
||||
|
/// </summary>
|
||||
|
public string Model { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 库位编号
|
||||
|
/// </summary>
|
||||
|
public string LocCode { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
public int State { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建人
|
||||
|
/// </summary>
|
||||
|
public string Creator { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建时间
|
||||
|
/// </summary>
|
||||
|
public DateTime CreatTime { get; set; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 代码
|
||||
|
///// </summary>
|
||||
|
//[IgnoreUpdate]
|
||||
|
//public string Code { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 名称
|
||||
|
///// </summary>
|
||||
|
//public string Name { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 描述
|
||||
|
///// </summary>
|
||||
|
//public string Desc1 { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 描述2
|
||||
|
///// </summary>
|
||||
|
//public string Desc2 { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 状态
|
||||
|
///// </summary>
|
||||
|
//public EnumItemStatus Status { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 制造件
|
||||
|
///// </summary>
|
||||
|
//public bool CanMake { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 采购件
|
||||
|
///// </summary>
|
||||
|
//[IgnoreUpdate]
|
||||
|
//public bool CanBuy { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 外包件
|
||||
|
///// </summary>
|
||||
|
//public bool CanOutsourcing { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 回收件
|
||||
|
///// </summary>
|
||||
|
//public bool IsRecycled { get; set; }
|
||||
|
|
||||
|
//[Display(Name = "类型")]
|
||||
|
//public string Type { get; set; }
|
||||
|
|
||||
|
//[Display(Name = "种类")]
|
||||
|
//public string Category { get; set; }
|
||||
|
|
||||
|
//[Display(Name = "分组")]
|
||||
|
//public string Group { get; set; }
|
||||
|
|
||||
|
//[Display(Name = "颜色")]
|
||||
|
//public string Color { get; set; }
|
||||
|
|
||||
|
//[Display(Name = "配置")]
|
||||
|
//public string Configuration { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 基本计量单位
|
||||
|
///// </summary>
|
||||
|
//public string BasicUom { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 标包数
|
||||
|
///// </summary>
|
||||
|
//public decimal StdPackQty { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// ABC类,默认为C
|
||||
|
///// </summary>
|
||||
|
//public string AbcClass { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 项目
|
||||
|
///// </summary>
|
||||
|
//public string Project { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 版本
|
||||
|
///// </summary>
|
||||
|
//public string Version { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 工程变革
|
||||
|
///// </summary>
|
||||
|
//public string Eco { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 有效期
|
||||
|
///// </summary>
|
||||
|
//public int Validity { get; set; }
|
||||
|
///// <summary>
|
||||
|
///// 有效期单位
|
||||
|
///// </summary>
|
||||
|
//public EnumValidityUnit ValidityUnit { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 管理类型
|
||||
|
///// </summary>
|
||||
|
//public EnumItemManageType ManageType { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 打印标签用的一个等级
|
||||
|
///// </summary>
|
||||
|
//public string Elevel { get; set; }
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 虚零件
|
||||
|
///// </summary>
|
||||
|
//public virtual bool IsPhantom { get; set; }
|
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
public class EquipmentManager : DomainService, IEquipmentManager |
||||
|
{ |
||||
|
private readonly IEquipmentRepository _repository; |
||||
|
|
||||
|
public EquipmentManager(IEquipmentRepository repository) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 执行导入
|
||||
|
/// </summary>
|
||||
|
public virtual async Task ImportDataAsync(List<Equipment> mergeEntities, List<Equipment> deleteEntities = null) |
||||
|
{ |
||||
|
if (deleteEntities != null && deleteEntities.Count > 0) |
||||
|
{ |
||||
|
await _repository.BulkDeleteAsync(deleteEntities).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
await _repository.BulkMergeAsync(mergeEntities).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,92 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
using Volo.Abp.Validation; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
//public class ItemValidator : DomainService
|
||||
|
//{
|
||||
|
// private readonly IItemCategoryRepository _itemCategoryRepository;
|
||||
|
|
||||
|
// public ItemValidator(
|
||||
|
// IItemCategoryRepository itemCategoryRepository)
|
||||
|
// {
|
||||
|
// _itemCategoryRepository = itemCategoryRepository;
|
||||
|
// }
|
||||
|
// #region Check
|
||||
|
|
||||
|
// public void CheckFormat(string code)
|
||||
|
// {
|
||||
|
// var wrongFormat = false;
|
||||
|
|
||||
|
// //TODO 检查物品号的格式
|
||||
|
|
||||
|
// if (wrongFormat)
|
||||
|
// {
|
||||
|
// var result = new AbpValidationResult();
|
||||
|
// result.Errors.Add(new ValidationResult($"{code} 格式错误"));
|
||||
|
// throw new AbpValidationException(result.Errors);
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// public void CheckCanMake(ItemBasic entity, bool? inputCanMake, AbpValidationResult result)
|
||||
|
// {
|
||||
|
// if (inputCanMake != null && inputCanMake.Value != entity.CanMake)
|
||||
|
// {
|
||||
|
// result.Errors.Add(new ValidationResult($"{entity.Code} {nameof(entity.CanMake)} 状态错误"));
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// public void CheckCanBuy(ItemBasic entity, bool? inputCanBuy, AbpValidationResult result)
|
||||
|
// {
|
||||
|
// if (inputCanBuy != null && inputCanBuy.Value != entity.CanBuy)
|
||||
|
// {
|
||||
|
// result.Errors.Add(new ValidationResult($"{entity.Code} {nameof(entity.CanBuy)} 状态错误"));
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// public void CheckStatus(ItemBasic entity, List<EnumItemStatus> validStatuses, AbpValidationResult result)
|
||||
|
// {
|
||||
|
// if (validStatuses.Any() && !validStatuses.Contains(entity.Status))
|
||||
|
// {
|
||||
|
// result.Errors.Add(new ValidationResult($"{entity.Code} 状态错误"));
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// public void CheckProject(ItemBasic entity, List<string> validProjects, AbpValidationResult result)
|
||||
|
// {
|
||||
|
// if (validProjects.Any() && !validProjects.Contains(entity.Project))
|
||||
|
// {
|
||||
|
// result.Errors.Add(new ValidationResult($"{entity.Code} 项目错误"));
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// public virtual async Task CheckCategoryAsync(ItemBasic entity, Dictionary<string, string> validCategories, AbpValidationResult result)
|
||||
|
// {
|
||||
|
// if (!validCategories.Any())
|
||||
|
// {
|
||||
|
// return;
|
||||
|
// }
|
||||
|
|
||||
|
// var code = entity.Code;
|
||||
|
|
||||
|
// var categories = await _itemCategoryRepository.GetListAsync(p => p.ItemCode == code).ConfigureAwait(false);
|
||||
|
|
||||
|
// foreach (var category in validCategories)
|
||||
|
// {
|
||||
|
// var found = categories.Any(p => p.CategoryCode == category.Key
|
||||
|
// && p.Value == category.Value);
|
||||
|
// if (!found)
|
||||
|
// {
|
||||
|
// result.Errors.Add(new ValidationResult($"{code} 的 {category.Key}:{category.Value}错误"));
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// }
|
||||
|
|
||||
|
// #endregion
|
||||
|
//}
|
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Abp.Domain.Services; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
public interface IEquipmentManager : IDomainService, IBulkImportService<Equipment> |
||||
|
{ |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
public interface IEquipmentRepository : ISfsBaseDataRepositoryBase<Equipment>, ISfsBulkRepositoryBase<Equipment> |
||||
|
{ |
||||
|
public Task UpsertAsync(Equipment entity); |
||||
|
|
||||
|
public Task InsertAutoSaveAsync(Equipment entity); |
||||
|
|
||||
|
public Task UpsertAsyncByInterface(Equipment entity); |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore.Modeling; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.EntityFrameworkCore; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.EntityFrameworkCore; |
||||
|
|
||||
|
public static class EquipmentDbContextModelCreatingExtensions |
||||
|
{ |
||||
|
public static void ConfigureEquipment(this ModelBuilder builder, BasedataModelBuilderConfigurationOptions options) |
||||
|
{ |
||||
|
builder.Entity<Equipment>(b => |
||||
|
{ |
||||
|
//Configure table & schema name
|
||||
|
b.ToTable(options.TablePrefix + nameof(Equipment), options.Schema); |
||||
|
//Configure ABP properties
|
||||
|
b.ConfigureByConvention(); |
||||
|
//Configure Sfs base properties
|
||||
|
b.ConfigureSfsBase(); |
||||
|
|
||||
|
//Properties
|
||||
|
b.Property(q => q.Code).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(true); |
||||
|
b.Property(q => q.Model).HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.LocCode).HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.Type).HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
|
||||
|
|
||||
|
//Relations
|
||||
|
//None
|
||||
|
|
||||
|
//Indexes
|
||||
|
b.HasIndex(q => new { q.Code }).IsUnique(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 器具编号
|
||||
|
/// </summary>
|
@ -0,0 +1,70 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.EntityFrameworkCore; |
||||
|
|
||||
|
public class EquipmentEfCoreRepository : SfsBaseDataEfCoreRepositoryBase<BasedataDbContext, Equipment>, IEquipmentRepository, ISfsBulkRepositoryBase<Equipment> |
||||
|
{ |
||||
|
public EquipmentEfCoreRepository(IDbContextProvider<BasedataDbContext> dbContextProvider) : base(dbContextProvider) |
||||
|
{ |
||||
|
} |
||||
|
public virtual async Task UpsertAsyncByInterface(Equipment entity) |
||||
|
{ |
||||
|
var dbSet = await GetDbSetAsync().ConfigureAwait(false); |
||||
|
var exist = await dbSet.FirstOrDefaultAsync(p => p.Code == entity.Code).ConfigureAwait(false); |
||||
|
if (exist == null) |
||||
|
{ |
||||
|
var insRet = await InsertAsync(entity).ConfigureAwait(false); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
exist.State = entity.State; |
||||
|
exist.Model = entity.Model; |
||||
|
exist.Type = entity.Type; |
||||
|
exist.LastModificationTime = DateTimeOffset.Now.DateTime; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
public virtual async Task UpsertAsync(Equipment entity) |
||||
|
{ |
||||
|
var dbSet = await GetDbSetAsync().ConfigureAwait(false); |
||||
|
var exist = await dbSet.FirstOrDefaultAsync(p => p.Code == entity.Code).ConfigureAwait(false); |
||||
|
if (exist == null) |
||||
|
{ |
||||
|
var insRet = await InsertAsync(entity).ConfigureAwait(false); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
exist.State = entity.State; |
||||
|
exist.Model = entity.Model; |
||||
|
exist.Type = entity.Type; |
||||
|
exist.LastModificationTime = DateTimeOffset.Now.DateTime; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// var context = await GetDbContextAsync();
|
||||
|
// await context.SingleMergeAsync(entity, options =>
|
||||
|
// {
|
||||
|
// //业务主键,可以是联合主键
|
||||
|
// options.ColumnPrimaryKeyExpression = c => new
|
||||
|
// {
|
||||
|
// c.Code
|
||||
|
// };
|
||||
|
// //需要在更新时忽略的属性
|
||||
|
// options.IgnoreOnMergeUpdateExpression = c => new
|
||||
|
// {
|
||||
|
// c.Id,
|
||||
|
// c.ManageType,
|
||||
|
// };
|
||||
|
// });
|
||||
|
} |
||||
|
|
||||
|
public virtual async Task InsertAutoSaveAsync(Equipment entity) |
||||
|
{ |
||||
|
_ = await InsertAsync(entity, true, GetCancellationToken()).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue