From e611fcd4ef8fa9eb339f6176ffb63c3ad827d75e Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Wed, 13 Mar 2024 10:48:38 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=99=A8=E5=85=B7?= =?UTF-8?q?=E9=9B=B6=E4=BB=B6=E3=80=81=E5=99=A8=E5=85=B7=E5=BA=93=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/DTOs/EquipmentLocDTO.cs | 31 ++ .../Equipments/DTOs/EquipmentPartCodeDTO.cs | 73 ++++ .../DTOs/EquipmentRecordErrorDTO.cs | 19 ++ .../Equipments/IEquipmentLocAppService.cs | 33 ++ .../IEquipmentPartCodeAppService.cs | 31 ++ .../Inputs/EquipmentLocCheckInput .cs | 27 ++ .../Inputs/EquipmentLocEditInput.cs | 28 ++ .../Inputs/EquipmentLocImportInput.cs | 33 ++ .../Inputs/EquipmentPartCodeCheckInput.cs | 43 +++ .../Inputs/EquipmentPartCodeEditInput.cs | 53 +++ .../Inputs/EquipmentPartCodeImportInput.cs | 60 ++++ .../BasedataApplicationAutoMapperProfile.cs | 2 + .../Equipments/EquipmentAppService.cs | 2 +- .../EquipmentAreaAutoMapperProfile.cs | 5 +- .../Equipments/EquipmentAutoMapperProfile.cs | 4 +- .../Equipments/EquipmentLocAppService.cs | 316 +++++++++++++++++ .../EquipmentLocAutoMapperProfile.cs | 34 ++ .../Equipments/EquipmentPartCodeAppService.cs | 319 ++++++++++++++++++ .../EquipmentPartCodeAutoMapperProfile.cs | 35 ++ .../Kittings/KittingAppService.cs | 61 +--- .../Equipments/Equipment.cs | 114 +------ .../Equipments/EquipmentLoc.cs | 36 ++ .../Equipments/EquipmentLocManager.cs | 29 ++ .../Equipments/EquipmentPartCode.cs | 44 +++ .../Equipments/EquipmentPartCodeManager.cs | 29 ++ .../Equipments/IEquipmentLocManager.cs | 8 + .../Equipments/IEquipmentLocRepository.cs | 13 + .../Equipments/IEquipmentPartCodeManager.cs | 8 + .../IEquipmentPartCodeRepository.cs | 13 + ...asedataDbContextModelCreatingExtensions.cs | 2 + .../BasedataEntityFrameworkCoreModule.cs | 4 +- ...mentLocDbContextModelCreatingExtensions.cs | 40 +++ .../EquipmentLocEfCoreRepository.cs | 54 +++ ...artCodeDbContextModelCreatingExtensions.cs | 40 +++ .../EquipmentPartCodeEfCoreRepository.cs | 68 ++++ .../Enums/Basedata/EnumEquipmentModel.cs | 37 ++ .../Store/Statuses/EnumEquipmentRecordType.cs | 13 + .../Equipments/IEquipmentRecordAppService.cs | 30 +- .../Equipments/EquipmentRecordAppService.cs | 133 ++------ .../Equipments/EquipmentLocCap.cs | 36 ++ .../Equipments/EquipmentLocCapManager.cs | 41 +++ .../Equipments/EquipmentRecord.cs | 17 +- .../Equipments/EquipmentRecordManager.cs | 298 ++++++++++------ .../Equipments/IEquipmentLocCapManager.cs | 13 + .../Equipments/IEquipmentLocCapRepository.cs | 10 + .../Equipments/IEquipmentRecordManager.cs | 11 +- ...tLocCapDbContextModelCreatingExtensions.cs | 32 ++ .../EquipmentLocCapEfCoreRepository.cs | 23 ++ ...tRecordDbContextModelCreatingExtensions.cs | 8 +- .../StoreDbContextModelCreatingExtensions.cs | 2 +- 50 files changed, 2012 insertions(+), 403 deletions(-) create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocDTO.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentRecordErrorDTO.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocAppService.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentPartCodeAppService.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCheckInput .cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocEditInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocImportInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeCheckInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeEditInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeImportInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAutoMapperProfile.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAutoMapperProfile.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLoc.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocManager.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCode.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCodeManager.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocManager.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocRepository.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeManager.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeRepository.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocDbContextModelCreatingExtensions.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocEfCoreRepository.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeDbContextModelCreatingExtensions.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeEfCoreRepository.cs create mode 100644 be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Basedata/EnumEquipmentModel.cs create mode 100644 be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumEquipmentRecordType.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCap.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCapManager.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapManager.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocDTO.cs new file mode 100644 index 000000000..6833d79ca --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocDTO.cs @@ -0,0 +1,31 @@ +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 EquipmentLocDTO : SfsBaseDataDTOBase, IHasCode +{ + + /// + /// 器具编号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + /// + /// 库位编号 + /// + [Display(Name = "库位代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string LocCode { get; set; } + + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs new file mode 100644 index 000000000..03e9f4dba --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs @@ -0,0 +1,73 @@ +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 EquipmentPartCodeDTO : SfsBaseDataDTOBase, IHasCode +{ + + /// + /// 器具代号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + + ///// + ///// 型号 + ///// + //[Display(Name = "型号")] + //public string Model { get; set; } = string.Empty; + /// + /// 库位编号 + /// + [Display(Name = "零件代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string PartCode { get; set; } + + + + /// + /// 标包数量 + /// + [Display(Name = "标包数")] + [Required(ErrorMessage = "{0}是必填项")] + public decimal StdQty { get; set; } + + + + /// + /// 单位 + /// + [Display(Name = "单位")] + public string Unit { get; set; } + + + + + /// + /// 状态 + /// + + //[Display(Name = "状态")] + //public int State { get; set; } = 0; + + ///// + ///// 创建人 + ///// + //[Display(Name = "创建人")] + //public string Creator { get; set; } + + ///// + ///// 创建时间 + ///// + //[Display(Name = "创建时间")] + //public DateTime CreatTime { get; set; } = DateTime.Now; +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentRecordErrorDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentRecordErrorDTO.cs new file mode 100644 index 000000000..dc82187c1 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentRecordErrorDTO.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Win_in.Sfs.Basedata.Equipments.DTOs; +[Display(Name = "器具校验信息")] +public class EquipmentRecordErrorDTO +{ + [Display(Name = "器具代码")] + public string EqptCode { set; get; } + [Display(Name = "零件代码")] + public string PartCode { set; get; } + [Display(Name = "错误信息")] + public string Error { set; get; } + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocAppService.cs new file mode 100644 index 000000000..6278b4aa3 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocAppService.cs @@ -0,0 +1,33 @@ +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 IEquipmentLocAppService + : ISfsBaseDataAppServiceBase + , ISfsGetByCodeAppService + , ISfsCheckAppService + , ISfsUpsertAppService +{ + + + Task> GetEquipmentLocAsync(List p_ls); + + + //Task CheckItemIsAvailable(string itemCode); + //[HttpGet("check-item-is-available-no-select-sql")] + //void CheckItemIsAvailable(EquipmentLocDTO EquipmentLocDTO); + + //Task> GetListByNameAsync(string name); + + //Task GetOrAddAsync(EquipmentLocEditInput input); + + //Task GetManageTypeAsync(string itemCode); + //Task> GetManageTypesAsync(List itemCodes); + + //Task UpsertAsyncByInterface(EquipmentLocEditInput input); + //Task UpsertStdPackQtyAsync(string itemCode, decimal stdpackqty); +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentPartCodeAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentPartCodeAppService.cs new file mode 100644 index 000000000..03bd162eb --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentPartCodeAppService.cs @@ -0,0 +1,31 @@ +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 IEquipmentPartCodeAppService + : ISfsBaseDataAppServiceBase + , ISfsGetByCodeAppService + + , ISfsUpsertAppService +{ + + + Task> GetEquipmentPartCodesAsync(List p_ls); + //Task CheckItemIsAvailable(string itemCode); + //[HttpGet("check-item-is-available-no-select-sql")] + //void CheckItemIsAvailable(EquipmentPartCodeDTO EquipmentPartCodeDTO); + + //Task> GetListByNameAsync(string name); + + //Task GetOrAddAsync(EquipmentPartCodeEditInput input); + + //Task GetManageTypeAsync(string itemCode); + //Task> GetManageTypesAsync(List itemCodes); + + //Task UpsertAsyncByInterface(EquipmentPartCodeEditInput input); + //Task UpsertStdPackQtyAsync(string itemCode, decimal stdpackqty); +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCheckInput .cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCheckInput .cs new file mode 100644 index 000000000..9b1473845 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCheckInput .cs @@ -0,0 +1,27 @@ +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 EquipmentLocCheckInput +{ + + /// + /// 器具编号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + /// + /// 库位编号 + /// + [Display(Name = "库位代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string LocCode { get; set; } + + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocEditInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocEditInput.cs new file mode 100644 index 000000000..0f2c0e919 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocEditInput.cs @@ -0,0 +1,28 @@ +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 EquipmentLocEditInput : SfsBaseDataCreateOrUpdateInputBase +{ + /// + /// 器具编号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + /// + /// 库位编号 + /// + [Display(Name = "库位代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string LocCode { get; set; } + + [Display(Name = "状态")] + public int State { get; set; } = 0; + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocImportInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocImportInput.cs new file mode 100644 index 000000000..2dffe09b6 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocImportInput.cs @@ -0,0 +1,33 @@ +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 EquipmentLocImportInput : SfsBaseDataImportInputBase +{ + /// + /// 器具编号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + /// + /// 库位编号 + /// + [Display(Name = "库位代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string LocCode { get; set; } + + + [Display(Name = "状态")] + public int State { get; set; } = 0; + + + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeCheckInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeCheckInput.cs new file mode 100644 index 000000000..2e8051cb1 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeCheckInput.cs @@ -0,0 +1,43 @@ +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 EquipmentPartCodeCheckInput +{ + + /// + /// 器具代号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + + + + ///// + ///// 型号 + ///// + //[Display(Name = "型号")] + //public string Model { get; set; } = string.Empty; + /// + /// 库位编号 + /// + [Display(Name = "零件代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string PartCode { get; set; } + + + + /// + /// 标包数量 + /// + [Display(Name = "标包数")] + [Required(ErrorMessage = "{0}是必填项")] + public decimal StdQty { get; set; } + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeEditInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeEditInput.cs new file mode 100644 index 000000000..aa5b93511 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeEditInput.cs @@ -0,0 +1,53 @@ +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 EquipmentPartCodeEditInput : SfsBaseDataCreateOrUpdateInputBase +{ + /// + /// 器具代号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + + + + ///// + ///// 型号 + ///// + //[Display(Name = "型号")] + //public string Model { get; set; } = string.Empty; + /// + /// 库位编号 + /// + [Display(Name = "零件代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string PartCode { get; set; } + + + + /// + /// 标包数量 + /// + [Display(Name = "标包数")] + [Required(ErrorMessage = "{0}是必填项")] + public decimal StdQty { get; set; } + + + + /// + /// 标包数量 + /// + [Display(Name = "单位")] + [Required(ErrorMessage = "{0}是必填项")] + public string Unit { get; set; } + + [Display(Name = "状态")] + public int State { get; set; } = 0; + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeImportInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeImportInput.cs new file mode 100644 index 000000000..77e58034e --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentPartCodeImportInput.cs @@ -0,0 +1,60 @@ +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 EquipmentPartCodeImportInput : SfsBaseDataImportInputBase +{ + /// + /// 器具代号 + /// + [Display(Name = "器具代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string Code { get; set; } + + + + + ///// + ///// 型号 + ///// + //[Display(Name = "型号")] + //public string Model { get; set; } = string.Empty; + /// + /// 库位编号 + /// + [Display(Name = "零件代码")] + [Required(ErrorMessage = "{0}是必填项")] + public string PartCode { get; set; } + + + + /// + /// 标包数量 + /// + [Display(Name = "标包数")] + [Required(ErrorMessage = "{0}是必填项")] + public decimal StdQty { get; set; } + + + /// + /// 标包数量 + /// + [Display(Name = "单位")] + [Required(ErrorMessage = "{0}是必填项")] + public string Unit { get; set; } + + + [Display(Name = "状态")] + public int State { get; set; } = 0; + + + + + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs index 1372ef60a..4f94c8ef2 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs @@ -52,6 +52,8 @@ public partial class BasedataApplicationAutoMapperProfile : Profile EquipmentAutoMapperProfile(); SplitPackingRecAutoMapperProfile(); KittingAutoMapperProfile(); + EquipmentLocAutoMapperProfile(); + EquipmentPartCodeAutoMapperProfile(); } } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs index a93db8119..10df8fd9d 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs @@ -292,7 +292,7 @@ public class EquipmentAppService { var entity = ObjectMapper.Map(input); entity.Code = string.Format("{0}{1}", "Q", entity.Code); - entity.Model = "Q"; + await _repository.UpsertAsync(entity).ConfigureAwait(false); var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAreaAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAreaAutoMapperProfile.cs index 503434c56..459e6dacd 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAreaAutoMapperProfile.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAreaAutoMapperProfile.cs @@ -18,9 +18,8 @@ public partial class BasedataApplicationAutoMapperProfile : Profile .Ignore(x => x.TenantId) .Ignore(x => x.Remark) .Ignore(x => x.ExtraProperties) - .Ignore(x => x.ConcurrencyStamp) - - ; + .Ignore(x => x.ConcurrencyStamp); + //CreateMap() diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAutoMapperProfile.cs index 0f2899506..a21be096e 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAutoMapperProfile.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAutoMapperProfile.cs @@ -19,9 +19,7 @@ public partial class BasedataApplicationAutoMapperProfile : Profile .Ignore(x => x.Remark) .Ignore(x => x.ExtraProperties) .Ignore(x => x.ConcurrencyStamp) - .ForMember(p =>p.Code, p => p.MapFrom(q =>"Q" +q.Code)) - - ; + .ForMember(p => p.Code, p => p.MapFrom(q => "Q" + q.Code)); //CreateMap() diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs new file mode 100644 index 000000000..70af283a3 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs @@ -0,0 +1,316 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +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.Application.Contracts; +using Win_in.Sfs.Shared.Application.Contracts.ExportAndImport; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; + +namespace Win_in.Sfs.Basedata.Application; + +[Authorize] +[Route($"{BasedataConsts.RootPath}EquipmentLoc")] +public class EquipmentLocAppService + : SfsBaseDataWithCodeAppServiceBase + , IEquipmentLocAppService +{ + //private readonly ItemValidator _itemValidator; + private readonly IEquipmentLocManager _manager; + private new readonly IEquipmentLocRepository _repository; + private readonly IExportImportService _importService; + + public EquipmentLocAppService( + IEquipmentLocRepository repository, + IDistributedCache cache, + IExportImportService importService, + // ItemValidator itemValidator, + IEquipmentLocManager manager) + : base(repository, cache) + { + _importService=importService; + _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, EquipmentLocCheckInput input) + { + await Task.CompletedTask.ConfigureAwait(false); + } + //public override async Task ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) + //{ + // List errors = new List(); + // using var ms = new MemoryStream(); + // await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); + // var inputFileBytes = ms.GetAllBytes(); + // var dtos=_importService.Import(inputFileBytes).ToList(); + // var list=ObjectMapper.Map, List>(dtos); + + + + + + // foreach (var itm in list) + // { + // itm.SetId(GuidGenerator.Create()); + // itm.Code = string.Format("{0}{1}", "Q", itm.Code); + + // } + + + + + // ////var bytes = result.FileContents; + // ////result.FileContents = null; + + // ////HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders = "X-Response"; + // ////HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", + // //// JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); + + // ////Console.WriteLine(@"导入错误信息:" + result.ExceptionMessage); + + // ////var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; + // ////resultAction.errorNum = result.ErrorNum; + // ////resultAction.successNum = resultAction.successNum; + // //return resultAction; + + + + + + + + + // // return base.ImportAsync(requestInput, file); + //} + + //protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService(); + //protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService(); + + //[HttpPost("check")] + //public virtual async Task CheckAsync(string code, EquipmentLocCheckInput input) + //{ + // var result = new AbpValidationResult(); + // _itemValidator.CheckFormat(code); + // var dto = await GetByCodeAsync(code).ConfigureAwait(false); + // var entity = ObjectMapper.Map(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); + // } + //} + + ///// + ///// 检物品状态 是否可用 + ///// + ///// + ///// + ///// + //[HttpGet("check-item-is-available")] + //public virtual async Task 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; + //} + + /// + /// 检物品状态 是否可用(不查询数据库 直接根据对象判断) + /// + /// + /// + //[HttpGet("check-item-is-available-no-select-sql")] + //public void CheckItemIsAvailable(EquipmentLocDTO EquipmentLocDTO) + //{ + // if (EquipmentLocDTO != null && EquipmentLocDTO.Status != EnumItemStatus.Active) + // { + // throw new UserFriendlyException($"物料 {EquipmentLocDTO.Code} 状态为 {EquipmentLocDTO.Status} ,不是可用状态"); + // } + //} + + //[HttpGet("{id}")] + //public override async Task GetAsync(Guid id) + //{ + // var dto = await base.GetAsync(id).ConfigureAwait(false); + + // dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false); + + // return dto; + //} + + /// + /// + /// + /// + /// + /// + //[HttpGet("list-by-name")] + //public virtual async Task> GetListByNameAsync(string name) + //{ + // var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false); + // var dtos = ObjectMapper.Map, List>(entities); + // return dtos; + //} + + //[HttpGet("get-manage-type")] + //public virtual async Task 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> GetManageTypesAsync(List 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 GetOrAddAsync(EquipmentLocEditInput input) + //{ + // var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false); + // if (result == null) + // { + // var entity = ObjectMapper.Map(input); + // result = await _repository.InsertAsync(entity, true).ConfigureAwait(false); + // } + + // var dto = ObjectMapper.Map(result); + // return dto; + //} + + //[HttpPost("list")] + //public override async Task> GetPagedListByFilterAsync( + // SfsBaseDataRequestInputBase sfsRequestInput, + // bool includeDetails = false, + // CancellationToken cancellationToken = default) + //{ + // Expression> expression = sfsRequestInput.Condition.Filters?.Count > 0 + // ? sfsRequestInput.Condition.Filters.ToLambda() + // : 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(EquipmentLocEditInput input) + //{ + // var entity = ObjectMapper.Map(input); + // await _repository.UpsertAsync(entity).ConfigureAwait(false); + //} + //[HttpPost("upsert-interface")] + //public virtual async Task UpsertAsyncByInterface(EquipmentLocEditInput input) + //{ + // var entity = ObjectMapper.Map(input); + // await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false); + //} + + //protected override Expression> BuildSearchExpression(string keyWord) + //{ + // Expression> 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> 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(EquipmentLocEditInput input) + { + var entity = ObjectMapper.Map(input); + + await _repository.UpsertAsync(entity).ConfigureAwait(false); + } + + [HttpPost] + [Route("")] + public override async Task CreateAsync(EquipmentLocEditInput input) + { + var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + if (first == null) + { + var entity = ObjectMapper.Map(input); + //entity.Code = string.Format("{0}{1}",entity.Code); + + + await _repository.UpsertAsync(entity).ConfigureAwait(false); + var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + return ObjectMapper.Map(entity1); + } + else + { + throw new UserFriendlyException($"已存在器具编号{input.Code}!"); + } + + } + [HttpPost] + [Route("GetEquipmentLocs")] + public async Task> GetEquipmentLocAsync(List p_ls) + { + var query=await _repository.GetQueryableAsync().ConfigureAwait(false); + var list =query.Where(p => p_ls.Contains(p.Code)); + return ObjectMapper.Map< List ,List>(list.ToList()); + + } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAutoMapperProfile.cs new file mode 100644 index 000000000..a7754a6ed --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAutoMapperProfile.cs @@ -0,0 +1,34 @@ +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 EquipmentLocAutoMapperProfile() + { + CreateMap() + + .ReverseMap(); + + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.TenantId) + .Ignore(x => x.Remark) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.ConcurrencyStamp) + .Ignore(x=>x.State) + .ForMember(p =>p.Code, p => p.MapFrom(q =>q.Code)) ; + + //CreateMap() + + //CreateMap() + // .Ignore(x => x.ItemCategory) + // .Ignore(x => x.Color); + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id); + } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs new file mode 100644 index 000000000..13e5b4d5e --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs @@ -0,0 +1,319 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.ObjectMapping; +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.Application.Contracts; +using Win_in.Sfs.Shared.Application.Contracts.ExportAndImport; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; + +namespace Win_in.Sfs.Basedata.Application; + +[Authorize] +[Route($"{BasedataConsts.RootPath}EquipmentPartCode")] +public class EquipmentPartCodeAppService + : SfsBaseDataWithCodeAppServiceBase + , IEquipmentPartCodeAppService +{ + //private readonly ItemValidator _itemValidator; + private readonly IEquipmentPartCodeManager _manager; + private new readonly IEquipmentPartCodeRepository _repository; + private readonly IExportImportService _importService; + + public EquipmentPartCodeAppService( + IEquipmentPartCodeRepository repository, + IDistributedCache cache, + IExportImportService importService, + + IEquipmentPartCodeManager manager) + : base(repository, cache) + { + _importService=importService; + _repository = repository; + _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, EquipmentPartCodeCheckInput input) + { + await Task.CompletedTask.ConfigureAwait(false); + } + //public override async Task ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) + //{ + // List errors = new List(); + // using var ms = new MemoryStream(); + // await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); + // var inputFileBytes = ms.GetAllBytes(); + // var dtos=_importService.Import(inputFileBytes).ToList(); + // var list=ObjectMapper.Map, List>(dtos); + + + + + + // foreach (var itm in list) + // { + // itm.SetId(GuidGenerator.Create()); + // itm.Code = string.Format("{0}{1}", "Q", itm.Code); + + // } + + + + + // ////var bytes = result.FileContents; + // ////result.FileContents = null; + + // ////HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders = "X-Response"; + // ////HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", + // //// JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); + + // ////Console.WriteLine(@"导入错误信息:" + result.ExceptionMessage); + + // ////var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; + // ////resultAction.errorNum = result.ErrorNum; + // ////resultAction.successNum = resultAction.successNum; + // //return resultAction; + + + + + + + + + // // return base.ImportAsync(requestInput, file); + //} + + //protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService(); + //protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService(); + + //[HttpPost("check")] + //public virtual async Task CheckAsync(string code, EquipmentPartCodeCheckInput input) + //{ + // var result = new AbpValidationResult(); + // _itemValidator.CheckFormat(code); + // var dto = await GetByCodeAsync(code).ConfigureAwait(false); + // var entity = ObjectMapper.Map(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); + // } + //} + + ///// + ///// 检物品状态 是否可用 + ///// + ///// + ///// + ///// + //[HttpGet("check-item-is-available")] + //public virtual async Task 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; + //} + + /// + /// 检物品状态 是否可用(不查询数据库 直接根据对象判断) + /// + /// + /// + //[HttpGet("check-item-is-available-no-select-sql")] + //public void CheckItemIsAvailable(EquipmentPartCodeDTO EquipmentPartCodeDTO) + //{ + // if (EquipmentPartCodeDTO != null && EquipmentPartCodeDTO.Status != EnumItemStatus.Active) + // { + // throw new UserFriendlyException($"物料 {EquipmentPartCodeDTO.Code} 状态为 {EquipmentPartCodeDTO.Status} ,不是可用状态"); + // } + //} + + //[HttpGet("{id}")] + //public override async Task GetAsync(Guid id) + //{ + // var dto = await base.GetAsync(id).ConfigureAwait(false); + + // dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false); + + // return dto; + //} + + /// + /// + /// + /// + /// + /// + //[HttpGet("list-by-name")] + //public virtual async Task> GetListByNameAsync(string name) + //{ + // var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false); + // var dtos = ObjectMapper.Map, List>(entities); + // return dtos; + //} + + //[HttpGet("get-manage-type")] + //public virtual async Task 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> GetManageTypesAsync(List 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 GetOrAddAsync(EquipmentPartCodeEditInput input) + //{ + // var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false); + // if (result == null) + // { + // var entity = ObjectMapper.Map(input); + // result = await _repository.InsertAsync(entity, true).ConfigureAwait(false); + // } + + // var dto = ObjectMapper.Map(result); + // return dto; + //} + + //[HttpPost("list")] + //public override async Task> GetPagedListByFilterAsync( + // SfsBaseDataRequestInputBase sfsRequestInput, + // bool includeDetails = false, + // CancellationToken cancellationToken = default) + //{ + // Expression> expression = sfsRequestInput.Condition.Filters?.Count > 0 + // ? sfsRequestInput.Condition.Filters.ToLambda() + // : 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(EquipmentPartCodeEditInput input) + //{ + // var entity = ObjectMapper.Map(input); + // await _repository.UpsertAsync(entity).ConfigureAwait(false); + //} + //[HttpPost("upsert-interface")] + //public virtual async Task UpsertAsyncByInterface(EquipmentPartCodeEditInput input) + //{ + // var entity = ObjectMapper.Map(input); + // await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false); + //} + + //protected override Expression> BuildSearchExpression(string keyWord) + //{ + // Expression> 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> 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(EquipmentPartCodeEditInput input) + { + var entity = ObjectMapper.Map(input); + + await _repository.UpsertAsync(entity).ConfigureAwait(false); + } + + [HttpPost] + [Route("")] + public override async Task CreateAsync(EquipmentPartCodeEditInput input) + { + var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + if (first == null) + { + var entity = ObjectMapper.Map(input); + + await _repository.UpsertAsync(entity).ConfigureAwait(false); + var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + return ObjectMapper.Map(entity1); + } + else + { + throw new UserFriendlyException($"已存在器具编号{input.Code}!"); + } + + } + [HttpPost] + [Route("GetEquipmentPartCodes")] + public async Task> GetEquipmentPartCodesAsync(List p_ls) + { + var query = await _repository.GetQueryableAsync().ConfigureAwait(false); + var list = query.Where(p => p_ls.Contains(p.Code)); + + return ObjectMapper.Map, List>(list.ToList()); + + } + + + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAutoMapperProfile.cs new file mode 100644 index 000000000..c89a35201 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAutoMapperProfile.cs @@ -0,0 +1,35 @@ +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 EquipmentPartCodeAutoMapperProfile() + { + CreateMap() + + .ReverseMap(); + + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.TenantId) + .Ignore(x => x.Remark) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.ConcurrencyStamp) + .ForMember(p =>p.Code, p => p.MapFrom(q =>q.Code)) + + ; + + //CreateMap() + + //CreateMap() + // .Ignore(x => x.ItemCategory) + // .Ignore(x => x.Color); + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id); + } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Kittings/KittingAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Kittings/KittingAppService.cs index bd3f3bde9..f2f376764 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Kittings/KittingAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Kittings/KittingAppService.cs @@ -151,10 +151,7 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase(inputFileBytes).ToList(); - var checklist=importList.GroupBy(p => new { p.Code, p.PartCode }).Where(g => g.Count() > 1).Select(p => new { Code = p.Key.Code, PartCode = p.Key.PartCode });//导入重复报错 - //检测是否导入重复 - - + var checklist=importList.GroupBy(p => new { p.Code, p.PartCode }).Where(g => g.Count() > 1).Select(p => new { Code = p.Key.Code, PartCode = p.Key.PartCode });//导入重复报错 //检测是否导入重复 List errors = new List(); if (checklist.Any()) { @@ -163,14 +160,7 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBasep.Code).Distinct().ToList(); var includeList = query.Where(p => codeList.Contains(p.Code)).ToList(); var existCodeList = includeList.Select(p => p.Code).ToList(); @@ -246,25 +236,23 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase list1 = new List(); // foreach (var itm in existKittingInputList) // { @@ -329,24 +315,13 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase p.Details).ToList(); - - // //await _repository.GetDbContext().BulkInsertAsync(newKittingDetailList).ConfigureAwait(continueOnCapturedContext: false); // //await _repository.GetDbContext().BulkUpdateAsync(existKittingDetailList).ConfigureAwait(continueOnCapturedContext: false); // // var ls= ObjectMapper.Map< List ,List >(existKittingInputList); - - // //await _repository.UpdateManyAsync(list1,true).ConfigureAwait(continueOnCapturedContext: false); - - // await _manager.ImportDataAsync(includeList).ConfigureAwait(false); - - - - } if (errors.Count > 0) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/Equipment.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/Equipment.cs index 6ee992529..fbd852777 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/Equipment.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/Equipment.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Entities; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; namespace Win_in.Sfs.Basedata.Domain; @@ -20,11 +21,11 @@ public class Equipment : SfsBaseDataAggregateRootBase, IHasCode /// /// 类型 /// - public string Type { get; set; } + public EnumEquipmentType Type { get; set; } /// /// 型号 /// - public string Model { get; set; } + public EnumEquipmentModel Model { get; set; } /// /// 库位编号 /// @@ -50,113 +51,4 @@ public class Equipment : SfsBaseDataAggregateRootBase, IHasCode public decimal StdQty { get; set; } - - - - - - - ///// - ///// 代码 - ///// - //[IgnoreUpdate] - //public string Code { get; set; } - ///// - ///// 名称 - ///// - //public string Name { get; set; } - ///// - ///// 描述 - ///// - //public string Desc1 { get; set; } - ///// - ///// 描述2 - ///// - //public string Desc2 { get; set; } - ///// - ///// 状态 - ///// - //public EnumItemStatus Status { get; set; } - ///// - ///// 制造件 - ///// - //public bool CanMake { get; set; } - ///// - ///// 采购件 - ///// - //[IgnoreUpdate] - //public bool CanBuy { get; set; } - ///// - ///// 外包件 - ///// - //public bool CanOutsourcing { get; set; } - ///// - ///// 回收件 - ///// - //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; } - ///// - ///// 基本计量单位 - ///// - //public string BasicUom { get; set; } - - ///// - ///// 标包数 - ///// - //public decimal StdPackQty { get; set; } - - ///// - ///// ABC类,默认为C - ///// - //public string AbcClass { get; set; } - ///// - ///// 项目 - ///// - //public string Project { get; set; } - ///// - ///// 版本 - ///// - //public string Version { get; set; } - ///// - ///// 工程变革 - ///// - //public string Eco { get; set; } - ///// - ///// 有效期 - ///// - //public int Validity { get; set; } - ///// - ///// 有效期单位 - ///// - //public EnumValidityUnit ValidityUnit { get; set; } - - ///// - ///// 管理类型 - ///// - //public EnumItemManageType ManageType { get; set; } - - ///// - ///// 打印标签用的一个等级 - ///// - //public string Elevel { get; set; } - - ///// - ///// 虚零件 - ///// - //public virtual bool IsPhantom { get; set; } - } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLoc.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLoc.cs new file mode 100644 index 000000000..17dcb0e73 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLoc.cs @@ -0,0 +1,36 @@ +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; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; + +namespace Win_in.Sfs.Basedata.Domain; + +/// +/// 物品基本信息 +/// +public class EquipmentLoc : SfsBaseDataAggregateRootBase, IHasCode +{ + /// + /// 器具代码 + /// + public string Code { get; set; } + ///// + ///// 类型 + ///// + //public EquipmentType Type { get; set; } + ///// + ///// 型号 + ///// + //public EquipmentModel Model { get; set; } + /// + /// 库位代码 + /// + public string LocCode { get; set; } + /// + /// 状态 + /// + public int State { get; set; } + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocManager.cs new file mode 100644 index 000000000..f6b451bab --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocManager.cs @@ -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 EquipmentLocManager : DomainService, IEquipmentLocManager +{ + private readonly IEquipmentLocRepository _repository; + + public EquipmentLocManager(IEquipmentLocRepository repository) + { + _repository = repository; + } + + /// + /// 执行导入 + /// + public virtual async Task ImportDataAsync(List mergeEntities, List deleteEntities = null) + { + if (deleteEntities != null && deleteEntities.Count > 0) + { + await _repository.BulkDeleteAsync(deleteEntities).ConfigureAwait(false); + } + + await _repository.BulkMergeAsync(mergeEntities).ConfigureAwait(false); + } +} + diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCode.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCode.cs new file mode 100644 index 000000000..4bf934a80 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCode.cs @@ -0,0 +1,44 @@ +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; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; + +namespace Win_in.Sfs.Basedata.Domain; + +/// +/// 器具基本信息 +/// +public class EquipmentPartCode : SfsBaseDataAggregateRootBase, IHasCode +{ + + /// + /// 器具编号 + /// + public string Code { get; set; } + ///// + ///// 类型 + ///// + //public EquipmentType Type { get; set; } + ///// + ///// 型号 + ///// + //public EquipmentModel Model { get; set; } + /// + /// 库位编号 + /// + public string PartCode { get; set; } + /// + /// 数量 + /// + public decimal StdQty { get; set; } + /// + /// 状态 + /// + public int State { get; set; } + /// + /// 单位 + /// + public string Unit { get; set; } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCodeManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCodeManager.cs new file mode 100644 index 000000000..ad208ed4a --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentPartCodeManager.cs @@ -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 EquipmentPartCodeManager : DomainService, IEquipmentPartCodeManager +{ + private readonly IEquipmentPartCodeRepository _repository; + + public EquipmentPartCodeManager(IEquipmentPartCodeRepository repository) + { + _repository = repository; + } + + /// + /// 执行导入 + /// + public virtual async Task ImportDataAsync(List mergeEntities, List deleteEntities = null) + { + if (deleteEntities != null && deleteEntities.Count > 0) + { + await _repository.BulkDeleteAsync(deleteEntities).ConfigureAwait(false); + } + + await _repository.BulkMergeAsync(mergeEntities).ConfigureAwait(false); + } +} + diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocManager.cs new file mode 100644 index 000000000..cf35e9d99 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocManager.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Domain.Services; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Basedata.Domain; + +public interface IEquipmentLocManager : IDomainService, IBulkImportService +{ +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocRepository.cs new file mode 100644 index 000000000..a525565b7 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocRepository.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Basedata.Domain; + +public interface IEquipmentLocRepository : ISfsBaseDataRepositoryBase, ISfsBulkRepositoryBase +{ + public Task UpsertAsync(EquipmentLoc entity); + + public Task InsertAutoSaveAsync(EquipmentLoc entity); + + public Task UpsertAsyncByInterface(EquipmentLoc entity); +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeManager.cs new file mode 100644 index 000000000..1e369d57c --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeManager.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Domain.Services; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Basedata.Domain; + +public interface IEquipmentPartCodeManager : IDomainService, IBulkImportService +{ +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeRepository.cs new file mode 100644 index 000000000..2768ff9c3 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentPartCodeRepository.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Basedata.Domain; + +public interface IEquipmentPartCodeRepository : ISfsBaseDataRepositoryBase, ISfsBulkRepositoryBase +{ + public Task UpsertAsync(EquipmentPartCode entity); + + public Task InsertAutoSaveAsync(EquipmentPartCode entity); + + public Task UpsertAsyncByInterface(EquipmentPartCode entity); +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataDbContextModelCreatingExtensions.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataDbContextModelCreatingExtensions.cs index dacc3c500..cb9249054 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataDbContextModelCreatingExtensions.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataDbContextModelCreatingExtensions.cs @@ -69,6 +69,8 @@ public static class BasedataDbContextModelCreatingExtensions builder.ConfigurePositionCode(options); builder.ConfigureSplitPackingRec(options); builder.ConfigureKitting(options); + builder.ConfigureEquipmentLoc(options); + builder.ConfigureEquipmentPartCode(options); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs index ab9e3628b..4f239caf4 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs @@ -69,9 +69,11 @@ public class BasedataEntityFrameworkCoreModule : AbpModule context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); -context.Services.AddTransient(); + context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); + context.Services.AddTransient(); + context.Services.AddTransient(); ConfigureEntity(); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocDbContextModelCreatingExtensions.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocDbContextModelCreatingExtensions.cs new file mode 100644 index 000000000..442d052a8 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocDbContextModelCreatingExtensions.cs @@ -0,0 +1,40 @@ +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 EquipmentLocDbContextModelCreatingExtensions +{ + public static void ConfigureEquipmentLoc(this ModelBuilder builder, BasedataModelBuilderConfigurationOptions options) + { + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(options.TablePrefix + nameof(EquipmentLoc), 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.LocCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(true); + + + + //Relations + //None + + //Indexes + b.HasIndex(q => new { q.Code ,q.LocCode}).IsUnique(); + }); + } +} + + +/// +/// 器具编号 +/// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocEfCoreRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocEfCoreRepository.cs new file mode 100644 index 000000000..8d3734d85 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocEfCoreRepository.cs @@ -0,0 +1,54 @@ +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 EquipmentLocEfCoreRepository : SfsBaseDataEfCoreRepositoryBase, IEquipmentLocRepository, ISfsBulkRepositoryBase +{ + public EquipmentLocEfCoreRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + public virtual async Task UpsertAsyncByInterface(EquipmentLoc 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.LastModificationTime = DateTimeOffset.Now.DateTime; + + } + } + public virtual async Task UpsertAsync(EquipmentLoc 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.LastModificationTime = DateTimeOffset.Now.DateTime; + + } + + + } + + public virtual async Task InsertAutoSaveAsync(EquipmentLoc entity) + { + _ = await InsertAsync(entity, true, GetCancellationToken()).ConfigureAwait(false); + } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeDbContextModelCreatingExtensions.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeDbContextModelCreatingExtensions.cs new file mode 100644 index 000000000..055fe60a9 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeDbContextModelCreatingExtensions.cs @@ -0,0 +1,40 @@ +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 EquipmentPartCodeDbContextModelCreatingExtensions +{ + public static void ConfigureEquipmentPartCode(this ModelBuilder builder, BasedataModelBuilderConfigurationOptions options) + { + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(options.TablePrefix + nameof(EquipmentPartCode), 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.PartCode).HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(true); + + + + //Relations + //None + + //Indexes + b.HasIndex(q => new { q.Code,q.PartCode }).IsUnique(); + }); + } +} + + +/// +/// 器具编号 +/// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeEfCoreRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeEfCoreRepository.cs new file mode 100644 index 000000000..a9b50c45d --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentPartCodeEfCoreRepository.cs @@ -0,0 +1,68 @@ +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 EquipmentPartCodeEfCoreRepository : SfsBaseDataEfCoreRepositoryBase, IEquipmentPartCodeRepository, ISfsBulkRepositoryBase +{ + public EquipmentPartCodeEfCoreRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + public virtual async Task UpsertAsyncByInterface(EquipmentPartCode 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.LastModificationTime = DateTimeOffset.Now.DateTime; + + } + } + public virtual async Task UpsertAsync(EquipmentPartCode 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.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(EquipmentPartCode entity) + { + _ = await InsertAsync(entity, true, GetCancellationToken()).ConfigureAwait(false); + } +} diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Basedata/EnumEquipmentModel.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Basedata/EnumEquipmentModel.cs new file mode 100644 index 000000000..65dd23a40 --- /dev/null +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Basedata/EnumEquipmentModel.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; +public enum EnumEquipmentType +{ + [Display(Name = "小")] + Small =0, + [Display(Name = "大")] + Large =1, + [Display(Name = "超大")] + Oversized =2 +} + +public enum EnumEquipmentModel +{ + + /// + /// 内部 + /// + [Display(Name = "内部")] + Internal = 0, + + /// + /// 外部 + /// + [Display(Name = "外部")] + External = 1, + + + + +} diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumEquipmentRecordType.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumEquipmentRecordType.cs new file mode 100644 index 000000000..4557aca04 --- /dev/null +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumEquipmentRecordType.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Statuses; +public enum EnumEquipmentRecordType +{ + Bind=0, + UnBind=1 + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Equipments/IEquipmentRecordAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Equipments/IEquipmentRecordAppService.cs index 53043298c..e9f750f2d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Equipments/IEquipmentRecordAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Equipments/IEquipmentRecordAppService.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Win_in.Sfs.Basedata.Equipments.DTOs; using Win_in.Sfs.Shared.Application.Contracts; +using Win_in.Sfs.Wms.Store.Equipments; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -12,34 +14,10 @@ public interface IEquipmentRecordAppService , ISfsUpsertAppService { - ///// - ///// 打开订单明细 - ///// - ///// - //Task OpenDetailAsync(Guid id, Guid detailId); - ///// - ///// 关闭订单明细 - ///// - ///// - //Task CloseDetailAsync(Guid id, Guid detailId); + Task> Bind(List p_ls); + Task> UnBind(List p_ls); - ///// - ///// 更新订单明细 - ///// - ///// - ///// - ///// - //Task UpdateDetailsAsync(string number,List input); - ///// - ///// 【批量创建】到货通知 (收货单) - ///// - ///// - ///// - //Task> CreateManyAsync(List inputs); - //Task> GetListBySupplierCodeAsync(string supplierCode, string itemCode); - //Task> GetNoPoBillList(List poBillNo); - //Task CreateOrUpdateAsync(PurchaseOrderEditInput input); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs index 56a246d0c..d32648c2f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs @@ -10,6 +10,7 @@ using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; using Volo.Abp.ObjectMapping; +using Win_in.Sfs.Basedata.Equipments.DTOs; using Win_in.Sfs.Shared.Application; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Store.Application.Contracts; @@ -42,6 +43,28 @@ public class EquipmentRecordAppService _manager = manager; _repository = repository; } + /// + /// 绑定器具记录 + /// + /// + /// + /// + public Task> Bind(List p_ls) + { + return _manager.Bind(p_ls); + } + + /// + /// 解绑器具记录 + /// + /// + /// + /// + public Task> UnBind(List p_ls) + { + return _manager.UnBind(p_ls); + } + /// /// 没用 /// @@ -54,6 +77,9 @@ public class EquipmentRecordAppService { throw new NotImplementedException(); } + + + /// /// 没用 /// @@ -70,6 +96,8 @@ public class EquipmentRecordAppService { throw new NotImplementedException(); } + + /// /// 没用 /// @@ -96,109 +124,4 @@ public class EquipmentRecordAppService } - - //[HttpGet("by-batchsize")] - //public virtual async Task> GetToBeProcessedListAsync(int batchSize) - //{ - // var entities = await _manager.GetToBeProcessedListAsync(batchSize).ConfigureAwait(false); - // var dtos = ObjectMapper.Map, List>(entities); - // return dtos; - //} - - //[HttpPost("re-send-by-id/{id}")] - //public virtual async Task ReSendByNumberAsync(Guid id) - //{ - // var EquipmentRecordOld = await _repository.GetAsync(id).ConfigureAwait(false); - // if (EquipmentRecordOld == null) - // { - // throw new UserFriendlyException($"未找到ID为【{id.ToString()}】的数据"); - // } - - // EquipmentRecordOld.Status = EnumEquipmentRecordStatus.Error; - - // var EquipmentRecordNew = new ExchangeData() - // { - // DataAction = exchangeDataOld.DataAction, - // DataContent = exchangeDataOld.DataContent, - // DataIdentityCode = exchangeDataOld.DataIdentityCode, - // DataType = exchangeDataOld.DataType, - // DestinationSystem = exchangeDataOld.DestinationSystem, - // EffectiveDate = exchangeDataOld.EffectiveDate, - // Remark = exchangeDataOld.Remark, - // SourceSystem = exchangeDataOld.SourceSystem, - // WriteTime = DateTime.Now, - // Writer = null, - // }; - // var entityNew= await _repository.InsertAsync(exchangeDataNew).ConfigureAwait(false); - - // exchangeDataOld.Remark = $"在【{DateTime.Now}】时,重新生成了新的接口数据:ID为【{entityNew.Id}】"; - // await _repository.UpdateAsync(exchangeDataOld).ConfigureAwait(false); - - // return new ExchangeDataDTO() { Id = entityNew.Id }; - //} - - //[HttpPost("by-batchsize-post")] - //public virtual async Task> GetToBeProcessedListPostAsync(int batchSize) - //{ - // var resultList=new List(); - - // var entities = await - // (await _repository.GetDbSetAsync().ConfigureAwait(false)) - // .Where(p => p.Status == EnumExchangeDataStatus.Unread) - // .OrderBy(p => p.TyrpNumber) - // .Take(batchSize) - // .ToListAsync().ConfigureAwait(false); - - // foreach (var entity in entities) - // { - // entity.Status = EnumExchangeDataStatus.Success; - // entity.ReadTime = Clock.Now; - // entity.Reader = "DataExchange.Agent"; - // resultList.Add(await _repository.UpdateAsync(entity).ConfigureAwait(false)); - // } - - // var dtos = ObjectMapper.Map, List>(resultList); - // return dtos; - //} - - //[HttpPost("by-batchsize-only-read")] - //public virtual async Task> GetToBeProcessedListOnlyReadAsync(int batchSize) - //{ - // var entities = await - // (await _repository.GetDbSetAsync().ConfigureAwait(false)) - // .Where(p => p.Status == EnumExchangeDataStatus.Unread) - // .OrderBy(p => p.TyrpNumber) - // .Take(batchSize) - // .ToListAsync().ConfigureAwait(false); - - // var dtos = ObjectMapper.Map, List>(entities); - // return dtos; - //} - - //[HttpPost("update-status-by-id-list")] - //public virtual async Task> UpdateStatusByIdListAsync(List list) - //{ - // List listExchangeDatas = new EditableList(); - // var resultList = new List(); - - // foreach (var id in list) - // { - // listExchangeDatas.Add(await _repository.GetAsync(id).ConfigureAwait(false)); - // } - - // listExchangeDatas.ForEach(p => - // { - // p.Status = EnumExchangeDataStatus.Success; - // p.ReadTime = Clock.Now; - // p.Reader = "DataExchange.Agent"; - // }); - - // foreach (var entity in listExchangeDatas) - // { - // resultList.Add(await _repository.UpdateAsync(entity).ConfigureAwait(false)); - // } - - // var dtos = ObjectMapper.Map, List>(resultList); - // return dtos; - //} } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCap.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCap.cs new file mode 100644 index 000000000..65f5ffb09 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCap.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Wms.Store.Equipments; + + +public class EquipmentLocCap:SfsAggregateRootBase +{ + /// + /// 器具编码 + /// + public string EqptCode { get; set; } + /// + /// 零件号 + /// + public string PartCode { get; set; } + /// + /// 占用百分比 + /// + public decimal Percent { get; set; } + + /// + /// 录入数量 + /// + public decimal Qty { get; set; } + + /// + /// 标包数量 + /// + public decimal StdQty { get; set; } + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCapManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCapManager.cs new file mode 100644 index 000000000..4fe04254a --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCapManager.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Domain.Services; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Store.Equipments; + +namespace Win_in.Sfs.Wms.Store.Domain; + +public class EquipmentLocCapManager : DomainService, IEquipmentLocCapManager +{ + private readonly IEquipmentRecordRepository _repository; + + + public EquipmentLocCapManager(IEquipmentRecordRepository repository + + ) + { + _repository = repository; + + } + + + public Task ImportDataAsync(List entities, List deleteEntities = null) + { + throw new NotImplementedException(); + } + + public Task ImportDataAsync(List entities, List deleteEntities = null) + { + throw new NotImplementedException(); + } + + private async Task SetDetailAsync(List details) + { + + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecord.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecord.cs index 7e7dac3f7..1fed8946a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecord.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecord.cs @@ -4,10 +4,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Statuses; namespace Win_in.Sfs.Wms.Store.Equipments; - +/// +/// 器具绑定解绑记录 +/// public class EquipmentRecord:SfsAggregateRootBase { /// @@ -27,9 +30,15 @@ public class EquipmentRecord:SfsAggregateRootBase /// public string Batch { get; set; } /// - /// 库位 + /// 来源库位 /// - public string LocCode { get; set; } + public string FromLocCode { get; set; } + + /// + /// 目标库位 + /// + public string ToLocCode { get; set; } + /// /// 数量 /// @@ -41,7 +50,7 @@ public class EquipmentRecord:SfsAggregateRootBase /// /// 记录类型 /// - public int Type { get; set;} + public EnumEquipmentRecordType Type { get; set;} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs index 2bdf03217..281383947 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs @@ -1,108 +1,219 @@ using System; using System.Collections.Generic; + using System.Linq; using System.Threading.Tasks; -using Volo.Abp; +using DocumentFormat.OpenXml.Packaging; using Volo.Abp.Domain.Services; using Win_in.Sfs.Basedata.Application.Contracts; -using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Basedata.Domain.Shared; +using Win_in.Sfs.Basedata.Equipments.DTOs; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Statuses; using Win_in.Sfs.Wms.Store.Equipments; namespace Win_in.Sfs.Wms.Store.Domain; + + + public class EquipmentRecordManager : DomainService, IEquipmentRecordManager { private readonly IEquipmentRecordRepository _repository; - //private readonly IPurchaseReceiptNoteManager _purchaseReceiptNoteManager; - //private readonly ISupplierAppService _supplierApp; - //private readonly IWarehouseAppService _warehouseApp; - - public EquipmentRecordManager(IEquipmentRecordRepository repository - //, IPurchaseReceiptNoteManager purchaseReceiptNoteManager - //, ISupplierAppService supplierApp - // , IWarehouseAppService warehouseApp + private readonly IEquipmentLocCapRepository _repositoryCap; + + private readonly IEquipmentLocAppService _locService; + private readonly IEquipmentPartCodeAppService _partService; + + public EquipmentRecordManager( + IEquipmentRecordRepository repository, + IEquipmentLocCapRepository repositoryCap, + IEquipmentLocAppService locService, + IEquipmentPartCodeAppService partService ) { + _locService=locService; _repository = repository; - //_purchaseReceiptNoteManager = purchaseReceiptNoteManager; - // _supplierApp = supplierApp; - // _warehouseApp = warehouseApp; + _repositoryCap = repositoryCap; + _partService= partService; } - /// - ///// 打开订单明细 - ///// - ///// - //public virtual async Task CheckIsCloseAsync(string number,string supplierCode, string itemCode) - //{ - // bool result = false; - // var entitys = await _repository.GetListAsync(p =>p.Number==number && p.Details.Any(y => y.ItemCode == itemCode&&y.LineStatus== EnumOrderStatus.Close) && p.SupplierCode == supplierCode, true).ConfigureAwait(false); - // if (entitys.Count!=0) result = true; - // return result; - //} - ///// - ///// 打开订单明细 - ///// - ///// - //public virtual async Task OpenDetailAsync(Guid id, Guid detailId) - //{ - // var entity = await Repository.GetAsync(id).ConfigureAwait(false); - // Check.NotNull(entity, EntityClassName); - // await entity.OpenDetailAsync(detailId).ConfigureAwait(false); - //} - - ///// - ///// 关闭订单明细 - ///// - ///// - //public virtual async Task CloseDetailAsync(Guid id, Guid detailId) - //{ - // var entity = await Repository.GetAsync(id).ConfigureAwait(false); - // Check.NotNull(entity, EntityClassName); - // await entity.CloseDetailAsync(detailId).ConfigureAwait(false); - //} - - //public override async Task CreateAsync(PurchaseOrder purchaseOrder) - //{ - // //接收到新的采购订单时,更新无PO收货单的PoNumber - // //await _purchaseReceiptNoteManager.AppendPoNumberAsync(purchaseOrder).ConfigureAwait(false); - // purchaseOrder.SetIdAndNumberWithDetails(GuidGenerator, purchaseOrder.Number); - // //不要用base.create 要不会把number覆盖 - // purchaseOrder = await Repository.InsertAsync(purchaseOrder).ConfigureAwait(false); - // await PublishCreatedAsync(purchaseOrder).ConfigureAwait(false); - // return purchaseOrder; - - //} - - ///// - ///// 执行导入 - ///// - //public virtual async Task ImportDataAsync(List mergeEntities, List deleteEntities = null) - //{ - // //if (deleteEntities != null && deleteEntities.Count > 0) - // //{ - // // await _repository.BulkDeleteAsync(deleteEntities).ConfigureAwait(false); - // //} - - // //foreach (var entity in mergeEntities) - // //{ - // // entity.SetIdAndNumberWithDetails(GuidGenerator, await GenerateNumberAsync(nameof(PurchaseOrder), entity.OrderDate).ConfigureAwait(false)); - // //} - - // //await _repository.BulkMergeAsync(mergeEntities).ConfigureAwait(false); - - // //var insertDetails = new List(); - - // //foreach (var item in mergeEntities) - // //{ - // // await SetDetailAsync(item.Details).ConfigureAwait(false); - - // // insertDetails.AddRange(item.Details); - // //} - - // // await _repository.BulkInsertAsync(insertDetails).ConfigureAwait(false); - - //} + public async Task> Bind(List p_ls) + { + List errors=new List(); + var list= p_ls.GroupBy(p => new { p.EqptCode, p.PartCode }).Select(p=>new { EqptCode= p.Key.EqptCode, PartCode= p.Key.PartCode,SumQty=p.Sum(p=>p.Qty)});//导入零件 + var partialErrors1=list.GroupBy(p => p.EqptCode).Where(g =>g.Count()>1).Select(p => new EquipmentRecordErrorDTO() { EqptCode= p.Key,PartCode=string.Empty,Error=$"同器具代码有{p.Count().ToString()}种零件!" }); + errors.AddRange(partialErrors1.ToList());//同容器放不同零件校验 + var ls=p_ls.Select(p => p.EqptCode).Distinct().ToList();//录入的器具记录代码列表 + var Locs=_locService.GetEquipmentLocAsync(ls).Result;//获取器具库位关系 + var parts =_partService.GetEquipmentPartCodesAsync(ls).Result;//获取器具零件关系 + //零件和器具关系校验 + var partErrorQery = from itm in list + join itm1 in parts on + new { itm.EqptCode, PartCode = itm.PartCode } equals new { EqptCode = itm1.Code, PartCode = itm1.PartCode } + into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select new EquipmentRecordErrorDTO() + { + EqptCode = itm.EqptCode, + PartCode = itm.PartCode, + Error = $"器具零件关系不存在!" + }; + errors.AddRange(partErrorQery.ToList()); + var query= await _repositoryCap.GetQueryableAsync().ConfigureAwait(false); + var capExistList= query.Where(p => ls.Contains(p.EqptCode)).ToList();//器具容量 + + var partialErrors2 = from itm in capExistList + join itm1 in list.ToList() on itm.EqptCode equals itm1.EqptCode + where itm.PartCode != itm.PartCode + select new EquipmentRecordErrorDTO() { + EqptCode = itm.EqptCode,PartCode=itm.PartCode ,Error=$"录入器具代码{itm.EqptCode}零件代码{itm.PartCode}与器具容量{itm1.EqptCode}零件代码{itm1.PartCode}不符!" + }; + errors.AddRange(partialErrors2.ToList());//导入记录和容量记录零件不是同一零件 + var existList = from itm in list + join itm1 in capExistList + on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } + select itm; + foreach (var itm in existList) + { + var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + cap.Qty += itm.SumQty;//当前数量 + + if (cap.Qty > cap.StdQty) + { + errors.Add(new EquipmentRecordErrorDTO() { EqptCode=itm.EqptCode,PartCode=itm.PartCode,Error=$"超出容量限制!" }); + } + } + + if (errors.Count > 0) + { + return errors; + } + //新建器具容量 + var newList =from itm in list + join itm1 in capExistList + on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } + into temp1 + from tm1 in temp1.DefaultIfEmpty() + where tm1 == null + select itm; + List newlocList=new List(); + foreach (var itm in newList) + { + var gpart = parts.FirstOrDefault(p => p.Code == itm.EqptCode && p.PartCode == itm.PartCode); + var stdQty = gpart.StdQty;//标包 + var qty = itm.SumQty; + var cap = new EquipmentLocCap() + + { + EqptCode=itm.EqptCode, + PartCode=itm.PartCode, + Percent=qty/stdQty, + Qty=qty, + StdQty=stdQty, + }; + cap.SetId(GuidGenerator.Create()); + newlocList.Add(cap); + } + //已存在器具容量变更 + + foreach (var itm in existList) + { + var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + cap.Qty = cap.Qty+itm.SumQty;//当前数量 + cap.Percent = cap.Qty / cap.StdQty; + } + + foreach (var itm in p_ls) + { + itm.Type = EnumEquipmentRecordType.Bind; + itm.SetId(GuidGenerator.Create()); + } + await _repositoryCap.InsertManyAsync(newlocList).ConfigureAwait(false); + await _repository.InsertManyAsync(p_ls).ConfigureAwait(false); + + + return errors; + + } + + + + + public async Task> UnBind(List p_ls) + { + List errors = new List(); + var list = p_ls.GroupBy(p => new { p.EqptCode, p.PartCode }).Select(p => new { EqptCode = p.Key.EqptCode, PartCode = p.Key.PartCode, SumQty = p.Sum(p => p.Qty) });//导入零件 + var partialErrors1 = list.GroupBy(p => p.EqptCode).Where(g => g.Count() > 1).Select(p => new EquipmentRecordErrorDTO() { EqptCode = p.Key, PartCode = string.Empty, Error = $"同器具代码有{p.Count().ToString()}种零件!" }); + errors.AddRange(partialErrors1.ToList());//同容器放不同零件校验 + var ls = p_ls.Select(p => p.EqptCode).Distinct().ToList();//录入的器具记录代码列表 + var Locs = _locService.GetEquipmentLocAsync(ls).Result;//获取器具库位关系 + var parts = _partService.GetEquipmentPartCodesAsync(ls).Result;//获取器具零件关系 + //零件和器具关系校验 + var partErrorQery = from itm in list + join itm1 in parts on + new { itm.EqptCode, PartCode = itm.PartCode } equals new { EqptCode = itm1.Code, PartCode = itm1.PartCode } + into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select new EquipmentRecordErrorDTO() + { + EqptCode = itm.EqptCode, + PartCode = itm.PartCode, + Error = $"器具零件关系不存在!" + }; + errors.AddRange(partErrorQery.ToList()); + var query = await _repositoryCap.GetQueryableAsync().ConfigureAwait(false); + var capExistList = query.Where(p => ls.Contains(p.EqptCode)).ToList();//器具容量 + + var partialErrors2 = from itm in capExistList + join itm1 in list.ToList() on itm.EqptCode equals itm1.EqptCode + where itm.PartCode != itm.PartCode + select new EquipmentRecordErrorDTO() + { + EqptCode = itm.EqptCode, + PartCode = itm.PartCode, + Error = $"录入器具代码{itm.EqptCode}零件代码{itm.PartCode}与器具容量{itm1.EqptCode}零件代码{itm1.PartCode}不符!" + }; + errors.AddRange(partialErrors2.ToList());//导入记录和器具容量记录零件不是同一零件 + var existList = from itm in list + join itm1 in capExistList + on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } + select itm; + foreach (var itm in existList) + { + var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + cap.Qty =cap.Qty- itm.SumQty;//当前数量 + + if (cap.Qty <0) + { + errors.Add(new EquipmentRecordErrorDTO() { EqptCode = itm.EqptCode, PartCode = itm.PartCode, Error = $"解绑数量小0!" }); + } + } + + foreach (var itm in existList) + { + var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + cap.Qty = cap.Qty - itm.SumQty;//当前数量 + cap.Percent = cap.Qty / cap.StdQty; + } + + foreach (var itm in p_ls) + { + itm.Type = EnumEquipmentRecordType.UnBind; + itm.SetId(GuidGenerator.Create()); + } + + await _repository.InsertManyAsync(p_ls).ConfigureAwait(false); + + + + + + + return errors; + + } public Task ImportDataAsync(List entities, List deleteEntities = null) { throw new NotImplementedException(); @@ -110,17 +221,6 @@ public class EquipmentRecordManager : DomainService, IEquipmentRecordManager private async Task SetDetailAsync(List details) { - //foreach (var detail in details) - //{ - // var item = await ItemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); - // Check.NotNull(item, "物品代码", $"物品 {detail.ItemCode} 不存在"); - - // if (item != null) - // { - // detail.ItemName = item.Name; - // detail.ItemDesc1 = item.Desc1; - // detail.ItemDesc2 = item.Desc2; - // } - //} + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapManager.cs new file mode 100644 index 000000000..8e5c49158 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapManager.cs @@ -0,0 +1,13 @@ +using System; +using System.Threading.Tasks; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Wms.Store.Equipments; + +namespace Win_in.Sfs.Wms.Store.Domain; + +public interface IEquipmentLocCapManager : IBulkImportService +{ + //Task OpenDetailAsync(Guid id, Guid detailId); + //Task CloseDetailAsync(Guid id, Guid detailId); + //Task CheckIsCloseAsync(string number, string supplierCode, string itemCode); +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs new file mode 100644 index 000000000..9875da3bf --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Wms.Store.Equipments; + +namespace Win_in.Sfs.Wms.Store.Domain; + +public interface IEquipmentLocCapRepository : ISfsStoreRepositoryBase, ISfsBulkRepositoryBase +{ + Task UpsertAsync(EquipmentLocCap newData); +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentRecordManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentRecordManager.cs index b3cfa93e3..4b22f2e05 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentRecordManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentRecordManager.cs @@ -1,13 +1,16 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; +using Win_in.Sfs.Basedata.Equipments.DTOs; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Wms.Store.Equipments; namespace Win_in.Sfs.Wms.Store.Domain; -public interface IEquipmentRecordManager :IBulkImportService +public interface IEquipmentRecordManager : IBulkImportService { - //Task OpenDetailAsync(Guid id, Guid detailId); - //Task CloseDetailAsync(Guid id, Guid detailId); - //Task CheckIsCloseAsync(string number, string supplierCode, string itemCode); + Task> Bind(List p_ls); + Task> UnBind(List p_ls); + + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs new file mode 100644 index 000000000..7055a4055 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs @@ -0,0 +1,32 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Modeling; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Store.Domain; +using Win_in.Sfs.Wms.Store.Equipments; + +namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; + +public static class EquipmentLocCapDbContextModelCreatingExtensions +{ + public static void ConfigureEquipmentLocCap(this ModelBuilder builder, StoreModelBuilderConfigurationOptions options) + { + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(options.TablePrefix + nameof(EquipmentLocCap), options.Schema); + //Configure ABP properties + b.ConfigureByConvention(); + //Configure Sfs base properties + b.ConfigureSfsStoreBase(); + + b.Property(q => q.EqptCode).HasMaxLength(SfsPropertyConst.CodeLength); + + b.Property(q => q.PartCode).HasMaxLength(SfsPropertyConst.CodeLength); + + b.HasIndex(q => new { q.EqptCode }); + + }); + + + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs new file mode 100644 index 000000000..22b627b26 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs @@ -0,0 +1,23 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Wms.Store.Domain; +using Win_in.Sfs.Wms.Store.Equipments; + +namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; + +public class EquipmentLocCapEfCoreRepository : SfsStoreEfCoreRepositoryBase, IEquipmentLocCapRepository, ISfsBulkRepositoryBase +{ + public EquipmentLocCapEfCoreRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + + + public Task UpsertAsync(EquipmentLocCap newData) + { + throw new System.NotImplementedException(); + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentRecordDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentRecordDbContextModelCreatingExtensions.cs index 1457d74ad..4d27863b9 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentRecordDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentRecordDbContextModelCreatingExtensions.cs @@ -22,11 +22,15 @@ public static class EquipmentRecordDbContextModelCreatingExtensions b.Property(q => q.BarCode).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.Batch).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.EqptCode).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.LocCode).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.ToLocCode).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.FromLocCode).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.PartCode).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.Batch).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.Type).HasMaxLength(SfsPropertyConst.CodeLength); - + + + + b.HasIndex(q => new { q.EqptCode }); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs index 62d3e058d..cc1d76eac 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs @@ -30,7 +30,7 @@ public static class StoreDbContextModelCreatingExtensions builder.ConfigureWorkOrder(options); builder.ConfigureEquipmentRecord(options); - + builder.ConfigureEquipmentLocCap(options); From 2cd020dda950267449235ab5236419b503d51dff Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Wed, 13 Mar 2024 11:10:13 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/EquipmentPartCodeAppService.cs | 225 +----------------- 1 file changed, 8 insertions(+), 217 deletions(-) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs index 13e5b4d5e..ffccac6cd 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs @@ -59,220 +59,6 @@ public class EquipmentPartCodeAppService { await Task.CompletedTask.ConfigureAwait(false); } - //public override async Task ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) - //{ - // List errors = new List(); - // using var ms = new MemoryStream(); - // await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); - // var inputFileBytes = ms.GetAllBytes(); - // var dtos=_importService.Import(inputFileBytes).ToList(); - // var list=ObjectMapper.Map, List>(dtos); - - - - - - // foreach (var itm in list) - // { - // itm.SetId(GuidGenerator.Create()); - // itm.Code = string.Format("{0}{1}", "Q", itm.Code); - - // } - - - - - // ////var bytes = result.FileContents; - // ////result.FileContents = null; - - // ////HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders = "X-Response"; - // ////HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", - // //// JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); - - // ////Console.WriteLine(@"导入错误信息:" + result.ExceptionMessage); - - // ////var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; - // ////resultAction.errorNum = result.ErrorNum; - // ////resultAction.successNum = resultAction.successNum; - // //return resultAction; - - - - - - - - - // // return base.ImportAsync(requestInput, file); - //} - - //protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService(); - //protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService(); - - //[HttpPost("check")] - //public virtual async Task CheckAsync(string code, EquipmentPartCodeCheckInput input) - //{ - // var result = new AbpValidationResult(); - // _itemValidator.CheckFormat(code); - // var dto = await GetByCodeAsync(code).ConfigureAwait(false); - // var entity = ObjectMapper.Map(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); - // } - //} - - ///// - ///// 检物品状态 是否可用 - ///// - ///// - ///// - ///// - //[HttpGet("check-item-is-available")] - //public virtual async Task 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; - //} - - /// - /// 检物品状态 是否可用(不查询数据库 直接根据对象判断) - /// - /// - /// - //[HttpGet("check-item-is-available-no-select-sql")] - //public void CheckItemIsAvailable(EquipmentPartCodeDTO EquipmentPartCodeDTO) - //{ - // if (EquipmentPartCodeDTO != null && EquipmentPartCodeDTO.Status != EnumItemStatus.Active) - // { - // throw new UserFriendlyException($"物料 {EquipmentPartCodeDTO.Code} 状态为 {EquipmentPartCodeDTO.Status} ,不是可用状态"); - // } - //} - - //[HttpGet("{id}")] - //public override async Task GetAsync(Guid id) - //{ - // var dto = await base.GetAsync(id).ConfigureAwait(false); - - // dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false); - - // return dto; - //} - - /// - /// - /// - /// - /// - /// - //[HttpGet("list-by-name")] - //public virtual async Task> GetListByNameAsync(string name) - //{ - // var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false); - // var dtos = ObjectMapper.Map, List>(entities); - // return dtos; - //} - - //[HttpGet("get-manage-type")] - //public virtual async Task 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> GetManageTypesAsync(List 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 GetOrAddAsync(EquipmentPartCodeEditInput input) - //{ - // var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false); - // if (result == null) - // { - // var entity = ObjectMapper.Map(input); - // result = await _repository.InsertAsync(entity, true).ConfigureAwait(false); - // } - - // var dto = ObjectMapper.Map(result); - // return dto; - //} - - //[HttpPost("list")] - //public override async Task> GetPagedListByFilterAsync( - // SfsBaseDataRequestInputBase sfsRequestInput, - // bool includeDetails = false, - // CancellationToken cancellationToken = default) - //{ - // Expression> expression = sfsRequestInput.Condition.Filters?.Count > 0 - // ? sfsRequestInput.Condition.Filters.ToLambda() - // : 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(EquipmentPartCodeEditInput input) - //{ - // var entity = ObjectMapper.Map(input); - // await _repository.UpsertAsync(entity).ConfigureAwait(false); - //} - //[HttpPost("upsert-interface")] - //public virtual async Task UpsertAsyncByInterface(EquipmentPartCodeEditInput input) - //{ - // var entity = ObjectMapper.Map(input); - // await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false); - //} - - //protected override Expression> BuildSearchExpression(string keyWord) - //{ - // Expression> 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> GetItemCategory(string itemCode) - //{ - // // var itemCategorys = await this._itemCategoryApp.GetListByItemCode(itemCode).ConfigureAwait(false); - - // // return itemCategorys.ToDictionary(x => x.CategoryCode, y => y.Value); - //} [HttpPost("upsert")] @@ -287,7 +73,7 @@ public class EquipmentPartCodeAppService [Route("")] public override async Task CreateAsync(EquipmentPartCodeEditInput input) { - var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code && p.PartCode==input.PartCode); if (first == null) { var entity = ObjectMapper.Map(input); @@ -298,9 +84,8 @@ public class EquipmentPartCodeAppService } else { - throw new UserFriendlyException($"已存在器具编号{input.Code}!"); + throw new UserFriendlyException($"已存在器具代码{input.Code}和零件代码{input.PartCode}关系!"); } - } [HttpPost] [Route("GetEquipmentPartCodes")] @@ -312,6 +97,12 @@ public class EquipmentPartCodeAppService return ObjectMapper.Map, List>(list.ToList()); } + protected override async Task ValidateImportModelAsync(EquipmentPartCodeImportInput importInput, List validationRresult) + { + await base.CheckItemBasicItemCodeAsync(importInput.Code, validationRresult).ConfigureAwait(false); + + // await base.CheckComponentAndComponentQtyAsync(importInput.Component, importInput.ComponentQty, validationRresult).ConfigureAwait(false); + } From 37cfb20326643165abfb02f63f8e3b7cb444d18a Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Wed, 13 Mar 2024 11:21:36 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/EquipmentLocAppService.cs | 227 +----------------- 1 file changed, 3 insertions(+), 224 deletions(-) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs index 70af283a3..2748602db 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs @@ -59,250 +59,30 @@ public class EquipmentLocAppService { await Task.CompletedTask.ConfigureAwait(false); } - //public override async Task ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) - //{ - // List errors = new List(); - // using var ms = new MemoryStream(); - // await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); - // var inputFileBytes = ms.GetAllBytes(); - // var dtos=_importService.Import(inputFileBytes).ToList(); - // var list=ObjectMapper.Map, List>(dtos); - - - - - - // foreach (var itm in list) - // { - // itm.SetId(GuidGenerator.Create()); - // itm.Code = string.Format("{0}{1}", "Q", itm.Code); - - // } - - - - - // ////var bytes = result.FileContents; - // ////result.FileContents = null; - - // ////HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders = "X-Response"; - // ////HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", - // //// JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); - - // ////Console.WriteLine(@"导入错误信息:" + result.ExceptionMessage); - - // ////var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; - // ////resultAction.errorNum = result.ErrorNum; - // ////resultAction.successNum = resultAction.successNum; - // //return resultAction; - - - - - - - - - // // return base.ImportAsync(requestInput, file); - //} - - //protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService(); - //protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService(); - - //[HttpPost("check")] - //public virtual async Task CheckAsync(string code, EquipmentLocCheckInput input) - //{ - // var result = new AbpValidationResult(); - // _itemValidator.CheckFormat(code); - // var dto = await GetByCodeAsync(code).ConfigureAwait(false); - // var entity = ObjectMapper.Map(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); - // } - //} - - ///// - ///// 检物品状态 是否可用 - ///// - ///// - ///// - ///// - //[HttpGet("check-item-is-available")] - //public virtual async Task 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; - //} - - /// - /// 检物品状态 是否可用(不查询数据库 直接根据对象判断) - /// - /// - /// - //[HttpGet("check-item-is-available-no-select-sql")] - //public void CheckItemIsAvailable(EquipmentLocDTO EquipmentLocDTO) - //{ - // if (EquipmentLocDTO != null && EquipmentLocDTO.Status != EnumItemStatus.Active) - // { - // throw new UserFriendlyException($"物料 {EquipmentLocDTO.Code} 状态为 {EquipmentLocDTO.Status} ,不是可用状态"); - // } - //} - - //[HttpGet("{id}")] - //public override async Task GetAsync(Guid id) - //{ - // var dto = await base.GetAsync(id).ConfigureAwait(false); - - // dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false); - - // return dto; - //} - - /// - /// - /// - /// - /// - /// - //[HttpGet("list-by-name")] - //public virtual async Task> GetListByNameAsync(string name) - //{ - // var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false); - // var dtos = ObjectMapper.Map, List>(entities); - // return dtos; - //} - - //[HttpGet("get-manage-type")] - //public virtual async Task 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> GetManageTypesAsync(List 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 GetOrAddAsync(EquipmentLocEditInput input) - //{ - // var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false); - // if (result == null) - // { - // var entity = ObjectMapper.Map(input); - // result = await _repository.InsertAsync(entity, true).ConfigureAwait(false); - // } - - // var dto = ObjectMapper.Map(result); - // return dto; - //} - - //[HttpPost("list")] - //public override async Task> GetPagedListByFilterAsync( - // SfsBaseDataRequestInputBase sfsRequestInput, - // bool includeDetails = false, - // CancellationToken cancellationToken = default) - //{ - // Expression> expression = sfsRequestInput.Condition.Filters?.Count > 0 - // ? sfsRequestInput.Condition.Filters.ToLambda() - // : 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(EquipmentLocEditInput input) - //{ - // var entity = ObjectMapper.Map(input); - // await _repository.UpsertAsync(entity).ConfigureAwait(false); - //} - //[HttpPost("upsert-interface")] - //public virtual async Task UpsertAsyncByInterface(EquipmentLocEditInput input) - //{ - // var entity = ObjectMapper.Map(input); - // await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false); - //} - - //protected override Expression> BuildSearchExpression(string keyWord) - //{ - // Expression> 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> 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(EquipmentLocEditInput input) { var entity = ObjectMapper.Map(input); - await _repository.UpsertAsync(entity).ConfigureAwait(false); } - [HttpPost] [Route("")] public override async Task CreateAsync(EquipmentLocEditInput input) { - var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code && p.LocCode==input.LocCode); if (first == null) { var entity = ObjectMapper.Map(input); - //entity.Code = string.Format("{0}{1}",entity.Code); - - await _repository.UpsertAsync(entity).ConfigureAwait(false); var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); return ObjectMapper.Map(entity1); } else { - throw new UserFriendlyException($"已存在器具编号{input.Code}!"); + throw new UserFriendlyException($"已存在器具代码{input.Code}和库位{input.LocCode}关系!"); } - } [HttpPost] [Route("GetEquipmentLocs")] @@ -311,6 +91,5 @@ public class EquipmentLocAppService var query=await _repository.GetQueryableAsync().ConfigureAwait(false); var list =query.Where(p => p_ls.Contains(p.Code)); return ObjectMapper.Map< List ,List>(list.ToList()); - } } From b5ae650c96936dc2e93eff6c367529252d91157c Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Wed, 13 Mar 2024 11:41:13 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/EquipmentLocAppService.cs | 2 +- .../Equipments/EquipmentPartCodeAppService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs index 2748602db..d51a9a303 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocAppService.cs @@ -76,7 +76,7 @@ public class EquipmentLocAppService { var entity = ObjectMapper.Map(input); await _repository.UpsertAsync(entity).ConfigureAwait(false); - var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code && p.LocCode == input.LocCode); return ObjectMapper.Map(entity1); } else diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs index ffccac6cd..6b56e8522 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs @@ -79,7 +79,7 @@ public class EquipmentPartCodeAppService var entity = ObjectMapper.Map(input); await _repository.UpsertAsync(entity).ConfigureAwait(false); - var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code && p.PartCode == input.PartCode); return ObjectMapper.Map(entity1); } else From 5fd4470a8bfefce5e607c1d1f641fd31eadc9911 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Wed, 13 Mar 2024 11:50:17 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/EquipmentPartCodeAppService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs index 6b56e8522..e1f998265 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs @@ -31,7 +31,7 @@ public class EquipmentPartCodeAppService : SfsBaseDataWithCodeAppServiceBase , IEquipmentPartCodeAppService { - //private readonly ItemValidator _itemValidator; + private readonly IEquipmentPartCodeManager _manager; private new readonly IEquipmentPartCodeRepository _repository; private readonly IExportImportService _importService; From 5175b4aae4b06e5c50b5827c14517dbc4f34dfbd Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Wed, 13 Mar 2024 16:04:52 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/DTOs/EquipmentDTO.cs | 5 +- .../Equipments/Inputs/EquipmentEditInput.cs | 5 +- .../Equipments/Inputs/EquipmentImportInput.cs | 9 +- .../Equipments/EquipmentAppService.cs | 224 ------------- .../Equipments/EquipmentPartCodeAppService.cs | 5 +- .../Equipments/EquipmentLocCap.cs | 2 +- .../Equipments/EquipmentLocCapManager.cs | 19 +- .../Equipments/IEquipmentLocCapManager.cs | 4 +- .../Equipments/IEquipmentLocCapRepository.cs | 11 + .../BasedataEntityFrameworkCoreModule.cs | 1 + ...uipmentDbContextModelCreatingExtensions.cs | 24 ++ .../Equipments/EquipmentEfCoreRepository.cs | 36 +- .../EquipmentLocCapEfCoreRepository.cs | 66 ++++ .../Equipments/EquipmentRecordManager.cs | 308 +++++++++--------- .../Equipments/IEquipmentLocCapRepository.cs | 10 - ...tLocCapDbContextModelCreatingExtensions.cs | 32 -- .../EquipmentLocCapEfCoreRepository.cs | 23 -- .../StoreDbContextModelCreatingExtensions.cs | 2 +- 18 files changed, 299 insertions(+), 487 deletions(-) rename be/Modules/{Store/src/Win_in.Sfs.Wms.Store.Domain => BaseData/src/Win_in.Sfs.Basedata.Domain}/Equipments/EquipmentLocCap.cs (94%) rename be/Modules/{Store/src/Win_in.Sfs.Wms.Store.Domain => BaseData/src/Win_in.Sfs.Basedata.Domain}/Equipments/EquipmentLocCapManager.cs (52%) rename be/Modules/{Store/src/Win_in.Sfs.Wms.Store.Domain => BaseData/src/Win_in.Sfs.Basedata.Domain}/Equipments/IEquipmentLocCapManager.cs (81%) create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs delete mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs delete mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs delete mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentDTO.cs index f9af753d9..c61f712b2 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentDTO.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentDTO.cs @@ -6,6 +6,7 @@ namespace Win_in.Sfs.Basedata.Application.Contracts; using System; using System.Collections.Generic; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; [Display(Name = "器具基本信息")] @@ -15,7 +16,7 @@ public class EquipmentDTO : SfsBaseDataDTOBase, IHasCode /// 类型 /// [Display(Name = "类型")] - public string Type { get; set; } = string.Empty; + public EnumEquipmentType Type { get; set; } /// /// 器具编号 /// @@ -35,7 +36,7 @@ public class EquipmentDTO : SfsBaseDataDTOBase, IHasCode /// 型号 /// [Display(Name = "型号")] - public string Model { get; set; } = string.Empty; + public EnumEquipmentModel Model { get; set; } /// /// 库位编号 /// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs index 9c00c6a23..e5fe9a2e5 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs @@ -2,6 +2,7 @@ using System; using System.ComponentModel.DataAnnotations; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; namespace Win_in.Sfs.Basedata.Application.Contracts; @@ -11,7 +12,7 @@ public class EquipmentEditInput : SfsBaseDataCreateOrUpdateInputBase /// 类型 /// [Display(Name = "类型")] - public string Type { get; set; } = string.Empty; + public EnumEquipmentType Type { get; set; } /// /// 器具编号 /// @@ -31,7 +32,7 @@ public class EquipmentEditInput : SfsBaseDataCreateOrUpdateInputBase /// 型号 /// [Display(Name = "型号")] - public string Model { get; set; } = string.Empty; + public EnumEquipmentModel Model { get; set; } /// /// 库位编号 /// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs index c09872d2a..2894c5c1b 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs @@ -1,8 +1,7 @@ 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; + +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; namespace Win_in.Sfs.Basedata.Application.Contracts; @@ -13,7 +12,7 @@ public class EquipmentImportInput : SfsBaseDataImportInputBase /// 类型 /// [Display(Name = "类型")] - public string Type { get; set; } = string.Empty; + public Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata.EnumEquipmentType Type { get; set; } /// /// 器具编号 /// @@ -33,7 +32,7 @@ public class EquipmentImportInput : SfsBaseDataImportInputBase /// 型号 /// [Display(Name = "型号")] - public string Model { get; set; } = string.Empty; + public EnumEquipmentModel Model { get; set; } /// /// 库位编号 /// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs index 10df8fd9d..be46cb4df 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentAppService.cs @@ -30,22 +30,18 @@ public class EquipmentAppService : SfsBaseDataWithCodeAppServiceBase , IEquipmentAppService { - //private readonly ItemValidator _itemValidator; private readonly IEquipmentManager _manager; private new readonly IEquipmentRepository _repository; private readonly IExportImportService _importService; - public EquipmentAppService( IEquipmentRepository repository, IDistributedCache cache, IExportImportService importService, - // ItemValidator itemValidator, IEquipmentManager manager) : base(repository, cache) { _importService=importService; _repository = repository; - //_itemValidator = itemValidator; _manager = manager; base.CreatePolicyName = EquipmentPermissions.Create; base.UpdatePolicyName = EquipmentPermissions.Update; @@ -54,232 +50,15 @@ public class EquipmentAppService [HttpPost("check")] //[Authorize(ErpLocationPermissions.Default)] - public virtual async Task CheckAsync(string code, EquipmentCheckInput input) { await Task.CompletedTask.ConfigureAwait(false); } - //public override async Task ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) - //{ - // List errors = new List(); - // using var ms = new MemoryStream(); - // await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); - // var inputFileBytes = ms.GetAllBytes(); - // var dtos=_importService.Import(inputFileBytes).ToList(); - // var list=ObjectMapper.Map, List>(dtos); - - - - - - // foreach (var itm in list) - // { - // itm.SetId(GuidGenerator.Create()); - // itm.Code = string.Format("{0}{1}", "Q", itm.Code); - - // } - - - - - // ////var bytes = result.FileContents; - // ////result.FileContents = null; - - // ////HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders = "X-Response"; - // ////HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", - // //// JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); - - // ////Console.WriteLine(@"导入错误信息:" + result.ExceptionMessage); - - // ////var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; - // ////resultAction.errorNum = result.ErrorNum; - // ////resultAction.successNum = resultAction.successNum; - // //return resultAction; - - - - - - - - - // // return base.ImportAsync(requestInput, file); - //} - - //protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService(); - //protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService(); - - //[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(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); - // } - //} - - ///// - ///// 检物品状态 是否可用 - ///// - ///// - ///// - ///// - //[HttpGet("check-item-is-available")] - //public virtual async Task 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; - //} - - /// - /// 检物品状态 是否可用(不查询数据库 直接根据对象判断) - /// - /// - /// - //[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 GetAsync(Guid id) - //{ - // var dto = await base.GetAsync(id).ConfigureAwait(false); - - // dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false); - - // return dto; - //} - - /// - /// - /// - /// - /// - /// - //[HttpGet("list-by-name")] - //public virtual async Task> GetListByNameAsync(string name) - //{ - // var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false); - // var dtos = ObjectMapper.Map, List>(entities); - // return dtos; - //} - - //[HttpGet("get-manage-type")] - //public virtual async Task 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> GetManageTypesAsync(List 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 GetOrAddAsync(EquipmentEditInput input) - //{ - // var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false); - // if (result == null) - // { - // var entity = ObjectMapper.Map(input); - // result = await _repository.InsertAsync(entity, true).ConfigureAwait(false); - // } - - // var dto = ObjectMapper.Map(result); - // return dto; - //} - - //[HttpPost("list")] - //public override async Task> GetPagedListByFilterAsync( - // SfsBaseDataRequestInputBase sfsRequestInput, - // bool includeDetails = false, - // CancellationToken cancellationToken = default) - //{ - // Expression> expression = sfsRequestInput.Condition.Filters?.Count > 0 - // ? sfsRequestInput.Condition.Filters.ToLambda() - // : 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(input); - // await _repository.UpsertAsync(entity).ConfigureAwait(false); - //} - //[HttpPost("upsert-interface")] - //public virtual async Task UpsertAsyncByInterface(EquipmentEditInput input) - //{ - // var entity = ObjectMapper.Map(input); - // await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false); - //} - - //protected override Expression> BuildSearchExpression(string keyWord) - //{ - // Expression> 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> 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(input); - await _repository.UpsertAsync(entity).ConfigureAwait(false); } @@ -292,8 +71,6 @@ public class EquipmentAppService { var entity = ObjectMapper.Map(input); entity.Code = string.Format("{0}{1}", "Q", entity.Code); - - await _repository.UpsertAsync(entity).ConfigureAwait(false); var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); return ObjectMapper.Map(entity1); @@ -304,5 +81,4 @@ public class EquipmentAppService } } - } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs index e1f998265..5a9bf75b8 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs @@ -30,8 +30,7 @@ namespace Win_in.Sfs.Basedata.Application; public class EquipmentPartCodeAppService : SfsBaseDataWithCodeAppServiceBase , IEquipmentPartCodeAppService -{ - +{ private readonly IEquipmentPartCodeManager _manager; private new readonly IEquipmentPartCodeRepository _repository; private readonly IExportImportService _importService; @@ -101,7 +100,7 @@ public class EquipmentPartCodeAppService { await base.CheckItemBasicItemCodeAsync(importInput.Code, validationRresult).ConfigureAwait(false); - // await base.CheckComponentAndComponentQtyAsync(importInput.Component, importInput.ComponentQty, validationRresult).ConfigureAwait(false); + //await base.CheckComponentAndComponentQtyAsync(importInput.Component, importInput.ComponentQty, validationRresult).ConfigureAwait(false); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCap.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCap.cs similarity index 94% rename from be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCap.cs rename to be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCap.cs index 65f5ffb09..d2e0183c5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCap.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCap.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Win_in.Sfs.Shared.Domain; -namespace Win_in.Sfs.Wms.Store.Equipments; +namespace Win_in.Sfs.Basedata.Domain; public class EquipmentLocCap:SfsAggregateRootBase diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCapManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCapManager.cs similarity index 52% rename from be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCapManager.cs rename to be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCapManager.cs index 4fe04254a..df81df2c1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentLocCapManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCapManager.cs @@ -4,18 +4,18 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Domain.Services; -using Win_in.Sfs.Basedata.Application.Contracts; + using Win_in.Sfs.Shared.Domain.Shared; -using Win_in.Sfs.Wms.Store.Equipments; -namespace Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Basedata.Domain; public class EquipmentLocCapManager : DomainService, IEquipmentLocCapManager { - private readonly IEquipmentRecordRepository _repository; + private readonly IEquipmentLocCapRepository _repository; - public EquipmentLocCapManager(IEquipmentRecordRepository repository + public EquipmentLocCapManager(IEquipmentLocCapRepository repository ) { @@ -24,17 +24,14 @@ public class EquipmentLocCapManager : DomainService, IEquipmentLocCapManager } - public Task ImportDataAsync(List entities, List deleteEntities = null) - { - throw new NotImplementedException(); - } - public Task ImportDataAsync(List entities, List deleteEntities = null) { throw new NotImplementedException(); } - private async Task SetDetailAsync(List details) + + + private async Task SetDetailAsync(List details) { } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapManager.cs similarity index 81% rename from be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapManager.cs rename to be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapManager.cs index 8e5c49158..5a62ee241 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapManager.cs @@ -1,9 +1,9 @@ using System; using System.Threading.Tasks; using Win_in.Sfs.Shared.Domain; -using Win_in.Sfs.Wms.Store.Equipments; -namespace Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Basedata.Domain; public interface IEquipmentLocCapManager : IBulkImportService { diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs new file mode 100644 index 000000000..6bd79f7bf --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; +using Volo.Abp.Domain.Services; +using Win_in.Sfs.Shared.Domain; + + +namespace Win_in.Sfs.Basedata.Domain; + +public interface IEquipmentLocCapRepository : IDomainService, ISfsBulkRepositoryBase +{ + Task UpsertAsync(EquipmentLocCap newData); +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs index 4f239caf4..c2fa0071a 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/BasedataEntityFrameworkCoreModule.cs @@ -74,6 +74,7 @@ public class BasedataEntityFrameworkCoreModule : AbpModule context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); + context.Services.AddTransient(); ConfigureEntity(); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs index 7a78d99cf..cf85b7de0 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs @@ -32,6 +32,30 @@ public static class EquipmentDbContextModelCreatingExtensions //Indexes b.HasIndex(q => new { q.Code }).IsUnique(); }); + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(options.TablePrefix + nameof(EquipmentLocCap), options.Schema); + //Configure ABP properties + b.ConfigureByConvention(); + //Configure Sfs base properties + b.ConfigureSfsBase(); + + //Properties + b.Property(q => q.EqptCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(true); + b.Property(q => q.PartCode).HasMaxLength(SfsPropertyConst.CodeLength); + + + //Relations + //None + + //Indexes + b.HasIndex(q => new { q.EqptCode }).IsUnique(); + }); + + + + } } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs index 5d0bab8cb..2c56b70d6 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs @@ -15,10 +15,20 @@ public class EquipmentEfCoreRepository : SfsBaseDataEfCoreRepositoryBase p.Code == entity.Code).ConfigureAwait(false); if (exist == null) { var insRet = await InsertAsync(entity).ConfigureAwait(false); + + + var cap = new EquipmentLocCap() { EqptCode = entity.Code,PartCode=string.Empty,Percent=0, Qty=0 , StdQty=0 }; + + await DbContext.Set().AddAsync(cap).ConfigureAwait(false); + + } else { @@ -36,6 +46,15 @@ public class EquipmentEfCoreRepository : SfsBaseDataEfCoreRepositoryBase().AddAsync(cap).ConfigureAwait(false); + + + } else { @@ -43,24 +62,7 @@ public class EquipmentEfCoreRepository : SfsBaseDataEfCoreRepositoryBase - // { - // //业务主键,可以是联合主键 - // options.ColumnPrimaryKeyExpression = c => new - // { - // c.Code - // }; - // //需要在更新时忽略的属性 - // options.IgnoreOnMergeUpdateExpression = c => new - // { - // c.Id, - // c.ManageType, - // }; - // }); } public virtual async Task InsertAutoSaveAsync(Equipment entity) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs new file mode 100644 index 000000000..2c0124040 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs @@ -0,0 +1,66 @@ +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 EquipmentLocCapEfCoreRepository : SfsBaseDataEfCoreRepositoryBase, IEquipmentLocCapRepository, ISfsBulkRepositoryBase +{ + public EquipmentLocCapEfCoreRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + public virtual async Task UpsertAsyncByInterface(EquipmentLocCap entity) + { + var dbSet = await GetDbSetAsync().ConfigureAwait(false); + + + + var exist = await dbSet.FirstOrDefaultAsync(p => p.EqptCode == entity.EqptCode).ConfigureAwait(false); + if (exist == null) + { + var insRet = await InsertAsync(entity).ConfigureAwait(false); + + + + + } + else + { + exist.Qty = entity.Qty; + exist.StdQty = entity.StdQty; + exist.Percent = entity.Percent; + exist.LastModificationTime = DateTimeOffset.Now.DateTime; + + } + } + public virtual async Task UpsertAsync(EquipmentLocCap entity) + { + var dbSet = await GetDbSetAsync().ConfigureAwait(false); + + var exist = await dbSet.FirstOrDefaultAsync(p => p.EqptCode == entity.EqptCode).ConfigureAwait(false); + if (exist == null) + { + var insRet = await InsertAsync(entity).ConfigureAwait(false); + + + + + } + else + { + exist.Qty = entity.Qty; + exist.StdQty = entity.StdQty; + exist.Percent = entity.Percent; + exist.LastModificationTime = DateTimeOffset.Now.DateTime; + + } + } + + public virtual async Task InsertAutoSaveAsync(EquipmentLocCap entity) + { + _ = await InsertAsync(entity, true, GetCancellationToken()).ConfigureAwait(false); + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs index 281383947..cf4486906 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/EquipmentRecordManager.cs @@ -19,118 +19,118 @@ namespace Win_in.Sfs.Wms.Store.Domain; public class EquipmentRecordManager : DomainService, IEquipmentRecordManager { private readonly IEquipmentRecordRepository _repository; - private readonly IEquipmentLocCapRepository _repositoryCap; + // private readonly IEquipmentLocCapRepository _repositoryCap; private readonly IEquipmentLocAppService _locService; private readonly IEquipmentPartCodeAppService _partService; public EquipmentRecordManager( IEquipmentRecordRepository repository, - IEquipmentLocCapRepository repositoryCap, + //IEquipmentLocCapRepository repositoryCap, IEquipmentLocAppService locService, IEquipmentPartCodeAppService partService ) { _locService=locService; _repository = repository; - _repositoryCap = repositoryCap; + // _repositoryCap = repositoryCap; _partService= partService; } public async Task> Bind(List p_ls) { List errors=new List(); - var list= p_ls.GroupBy(p => new { p.EqptCode, p.PartCode }).Select(p=>new { EqptCode= p.Key.EqptCode, PartCode= p.Key.PartCode,SumQty=p.Sum(p=>p.Qty)});//导入零件 - var partialErrors1=list.GroupBy(p => p.EqptCode).Where(g =>g.Count()>1).Select(p => new EquipmentRecordErrorDTO() { EqptCode= p.Key,PartCode=string.Empty,Error=$"同器具代码有{p.Count().ToString()}种零件!" }); - errors.AddRange(partialErrors1.ToList());//同容器放不同零件校验 - var ls=p_ls.Select(p => p.EqptCode).Distinct().ToList();//录入的器具记录代码列表 - var Locs=_locService.GetEquipmentLocAsync(ls).Result;//获取器具库位关系 - var parts =_partService.GetEquipmentPartCodesAsync(ls).Result;//获取器具零件关系 - //零件和器具关系校验 - var partErrorQery = from itm in list - join itm1 in parts on - new { itm.EqptCode, PartCode = itm.PartCode } equals new { EqptCode = itm1.Code, PartCode = itm1.PartCode } - into temp - from tm in temp.DefaultIfEmpty() - where tm == null - select new EquipmentRecordErrorDTO() - { - EqptCode = itm.EqptCode, - PartCode = itm.PartCode, - Error = $"器具零件关系不存在!" - }; - errors.AddRange(partErrorQery.ToList()); - var query= await _repositoryCap.GetQueryableAsync().ConfigureAwait(false); - var capExistList= query.Where(p => ls.Contains(p.EqptCode)).ToList();//器具容量 - - var partialErrors2 = from itm in capExistList - join itm1 in list.ToList() on itm.EqptCode equals itm1.EqptCode - where itm.PartCode != itm.PartCode - select new EquipmentRecordErrorDTO() { - EqptCode = itm.EqptCode,PartCode=itm.PartCode ,Error=$"录入器具代码{itm.EqptCode}零件代码{itm.PartCode}与器具容量{itm1.EqptCode}零件代码{itm1.PartCode}不符!" - }; - errors.AddRange(partialErrors2.ToList());//导入记录和容量记录零件不是同一零件 - var existList = from itm in list - join itm1 in capExistList - on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } - select itm; - foreach (var itm in existList) - { - var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 - cap.Qty += itm.SumQty;//当前数量 - - if (cap.Qty > cap.StdQty) - { - errors.Add(new EquipmentRecordErrorDTO() { EqptCode=itm.EqptCode,PartCode=itm.PartCode,Error=$"超出容量限制!" }); - } - } - - if (errors.Count > 0) - { - return errors; - } - //新建器具容量 - var newList =from itm in list - join itm1 in capExistList - on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } - into temp1 - from tm1 in temp1.DefaultIfEmpty() - where tm1 == null - select itm; - List newlocList=new List(); - foreach (var itm in newList) - { - var gpart = parts.FirstOrDefault(p => p.Code == itm.EqptCode && p.PartCode == itm.PartCode); - var stdQty = gpart.StdQty;//标包 - var qty = itm.SumQty; - var cap = new EquipmentLocCap() - - { - EqptCode=itm.EqptCode, - PartCode=itm.PartCode, - Percent=qty/stdQty, - Qty=qty, - StdQty=stdQty, - }; - cap.SetId(GuidGenerator.Create()); - newlocList.Add(cap); - } - //已存在器具容量变更 + // var list= p_ls.GroupBy(p => new { p.EqptCode, p.PartCode }).Select(p=>new { EqptCode= p.Key.EqptCode, PartCode= p.Key.PartCode,SumQty=p.Sum(p=>p.Qty)});//导入零件 + // var partialErrors1=list.GroupBy(p => p.EqptCode).Where(g =>g.Count()>1).Select(p => new EquipmentRecordErrorDTO() { EqptCode= p.Key,PartCode=string.Empty,Error=$"同器具代码有{p.Count().ToString()}种零件!" }); + // errors.AddRange(partialErrors1.ToList());//同容器放不同零件校验 + // var ls=p_ls.Select(p => p.EqptCode).Distinct().ToList();//录入的器具记录代码列表 + // var Locs=_locService.GetEquipmentLocAsync(ls).Result;//获取器具库位关系 + // var parts =_partService.GetEquipmentPartCodesAsync(ls).Result;//获取器具零件关系 + // //零件和器具关系校验 + // var partErrorQery = from itm in list + // join itm1 in parts on + // new { itm.EqptCode, PartCode = itm.PartCode } equals new { EqptCode = itm1.Code, PartCode = itm1.PartCode } + // into temp + // from tm in temp.DefaultIfEmpty() + // where tm == null + // select new EquipmentRecordErrorDTO() + // { + // EqptCode = itm.EqptCode, + // PartCode = itm.PartCode, + // Error = $"器具零件关系不存在!" + // }; + // errors.AddRange(partErrorQery.ToList()); + // var query= await _repositoryCap.GetQueryableAsync().ConfigureAwait(false); + // var capExistList= query.Where(p => ls.Contains(p.EqptCode)).ToList();//器具容量 + + // var partialErrors2 = from itm in capExistList + // join itm1 in list.ToList() on itm.EqptCode equals itm1.EqptCode + // where itm.PartCode != itm.PartCode + // select new EquipmentRecordErrorDTO() { + // EqptCode = itm.EqptCode,PartCode=itm.PartCode ,Error=$"录入器具代码{itm.EqptCode}零件代码{itm.PartCode}与器具容量{itm1.EqptCode}零件代码{itm1.PartCode}不符!" + // }; + // errors.AddRange(partialErrors2.ToList());//导入记录和容量记录零件不是同一零件 + // var existList = from itm in list + // join itm1 in capExistList + // on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } + // select itm; + // foreach (var itm in existList) + // { + // var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + // cap.Qty += itm.SumQty;//当前数量 + + // if (cap.Qty > cap.StdQty) + // { + // errors.Add(new EquipmentRecordErrorDTO() { EqptCode=itm.EqptCode,PartCode=itm.PartCode,Error=$"超出容量限制!" }); + // } + // } + + // if (errors.Count > 0) + // { + // return errors; + // } + // //新建器具容量 + //var newList =from itm in list + // join itm1 in capExistList + // on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } + // into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // where tm1 == null + // select itm; + // List newlocList=new List(); + // foreach (var itm in newList) + // { + // var gpart = parts.FirstOrDefault(p => p.Code == itm.EqptCode && p.PartCode == itm.PartCode); + // var stdQty = gpart.StdQty;//标包 + // var qty = itm.SumQty; + // var cap = new EquipmentLocCap() + + // { + // EqptCode=itm.EqptCode, + // PartCode=itm.PartCode, + // Percent=qty/stdQty, + // Qty=qty, + // StdQty=stdQty, + // }; + // cap.SetId(GuidGenerator.Create()); + // newlocList.Add(cap); + // } + // //已存在器具容量变更 - foreach (var itm in existList) - { - var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 - cap.Qty = cap.Qty+itm.SumQty;//当前数量 - cap.Percent = cap.Qty / cap.StdQty; - } - - foreach (var itm in p_ls) - { - itm.Type = EnumEquipmentRecordType.Bind; - itm.SetId(GuidGenerator.Create()); - } - await _repositoryCap.InsertManyAsync(newlocList).ConfigureAwait(false); - await _repository.InsertManyAsync(p_ls).ConfigureAwait(false); + // foreach (var itm in existList) + // { + // var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + // cap.Qty = cap.Qty+itm.SumQty;//当前数量 + // cap.Percent = cap.Qty / cap.StdQty; + // } + + // foreach (var itm in p_ls) + // { + // itm.Type = EnumEquipmentRecordType.Bind; + // itm.SetId(GuidGenerator.Create()); + // } + // await _repositoryCap.InsertManyAsync(newlocList).ConfigureAwait(false); + // await _repository.InsertManyAsync(p_ls).ConfigureAwait(false); return errors; @@ -143,68 +143,68 @@ public class EquipmentRecordManager : DomainService, IEquipmentRecordManager public async Task> UnBind(List p_ls) { List errors = new List(); - var list = p_ls.GroupBy(p => new { p.EqptCode, p.PartCode }).Select(p => new { EqptCode = p.Key.EqptCode, PartCode = p.Key.PartCode, SumQty = p.Sum(p => p.Qty) });//导入零件 - var partialErrors1 = list.GroupBy(p => p.EqptCode).Where(g => g.Count() > 1).Select(p => new EquipmentRecordErrorDTO() { EqptCode = p.Key, PartCode = string.Empty, Error = $"同器具代码有{p.Count().ToString()}种零件!" }); - errors.AddRange(partialErrors1.ToList());//同容器放不同零件校验 - var ls = p_ls.Select(p => p.EqptCode).Distinct().ToList();//录入的器具记录代码列表 - var Locs = _locService.GetEquipmentLocAsync(ls).Result;//获取器具库位关系 - var parts = _partService.GetEquipmentPartCodesAsync(ls).Result;//获取器具零件关系 - //零件和器具关系校验 - var partErrorQery = from itm in list - join itm1 in parts on - new { itm.EqptCode, PartCode = itm.PartCode } equals new { EqptCode = itm1.Code, PartCode = itm1.PartCode } - into temp - from tm in temp.DefaultIfEmpty() - where tm == null - select new EquipmentRecordErrorDTO() - { - EqptCode = itm.EqptCode, - PartCode = itm.PartCode, - Error = $"器具零件关系不存在!" - }; - errors.AddRange(partErrorQery.ToList()); - var query = await _repositoryCap.GetQueryableAsync().ConfigureAwait(false); - var capExistList = query.Where(p => ls.Contains(p.EqptCode)).ToList();//器具容量 - - var partialErrors2 = from itm in capExistList - join itm1 in list.ToList() on itm.EqptCode equals itm1.EqptCode - where itm.PartCode != itm.PartCode - select new EquipmentRecordErrorDTO() - { - EqptCode = itm.EqptCode, - PartCode = itm.PartCode, - Error = $"录入器具代码{itm.EqptCode}零件代码{itm.PartCode}与器具容量{itm1.EqptCode}零件代码{itm1.PartCode}不符!" - }; - errors.AddRange(partialErrors2.ToList());//导入记录和器具容量记录零件不是同一零件 - var existList = from itm in list - join itm1 in capExistList - on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } - select itm; - foreach (var itm in existList) - { - var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 - cap.Qty =cap.Qty- itm.SumQty;//当前数量 - - if (cap.Qty <0) - { - errors.Add(new EquipmentRecordErrorDTO() { EqptCode = itm.EqptCode, PartCode = itm.PartCode, Error = $"解绑数量小0!" }); - } - } - - foreach (var itm in existList) - { - var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 - cap.Qty = cap.Qty - itm.SumQty;//当前数量 - cap.Percent = cap.Qty / cap.StdQty; - } - - foreach (var itm in p_ls) - { - itm.Type = EnumEquipmentRecordType.UnBind; - itm.SetId(GuidGenerator.Create()); - } + //var list = p_ls.GroupBy(p => new { p.EqptCode, p.PartCode }).Select(p => new { EqptCode = p.Key.EqptCode, PartCode = p.Key.PartCode, SumQty = p.Sum(p => p.Qty) });//导入零件 + //var partialErrors1 = list.GroupBy(p => p.EqptCode).Where(g => g.Count() > 1).Select(p => new EquipmentRecordErrorDTO() { EqptCode = p.Key, PartCode = string.Empty, Error = $"同器具代码有{p.Count().ToString()}种零件!" }); + //errors.AddRange(partialErrors1.ToList());//同容器放不同零件校验 + //var ls = p_ls.Select(p => p.EqptCode).Distinct().ToList();//录入的器具记录代码列表 + //var Locs = _locService.GetEquipmentLocAsync(ls).Result;//获取器具库位关系 + //var parts = _partService.GetEquipmentPartCodesAsync(ls).Result;//获取器具零件关系 + ////零件和器具关系校验 + //var partErrorQery = from itm in list + // join itm1 in parts on + // new { itm.EqptCode, PartCode = itm.PartCode } equals new { EqptCode = itm1.Code, PartCode = itm1.PartCode } + // into temp + // from tm in temp.DefaultIfEmpty() + // where tm == null + // select new EquipmentRecordErrorDTO() + // { + // EqptCode = itm.EqptCode, + // PartCode = itm.PartCode, + // Error = $"器具零件关系不存在!" + // }; + //errors.AddRange(partErrorQery.ToList()); + //var query = await _repositoryCap.GetQueryableAsync().ConfigureAwait(false); + //var capExistList = query.Where(p => ls.Contains(p.EqptCode)).ToList();//器具容量 + + //var partialErrors2 = from itm in capExistList + // join itm1 in list.ToList() on itm.EqptCode equals itm1.EqptCode + // where itm.PartCode != itm.PartCode + // select new EquipmentRecordErrorDTO() + // { + // EqptCode = itm.EqptCode, + // PartCode = itm.PartCode, + // Error = $"录入器具代码{itm.EqptCode}零件代码{itm.PartCode}与器具容量{itm1.EqptCode}零件代码{itm1.PartCode}不符!" + // }; + //errors.AddRange(partialErrors2.ToList());//导入记录和器具容量记录零件不是同一零件 + //var existList = from itm in list + // join itm1 in capExistList + // on new { itm.EqptCode, itm.PartCode } equals new { itm1.EqptCode, itm1.PartCode } + // select itm; + //foreach (var itm in existList) + //{ + // var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + // cap.Qty =cap.Qty- itm.SumQty;//当前数量 + + // if (cap.Qty <0) + // { + // errors.Add(new EquipmentRecordErrorDTO() { EqptCode = itm.EqptCode, PartCode = itm.PartCode, Error = $"解绑数量小0!" }); + // } + //} + + //foreach (var itm in existList) + //{ + // var cap = capExistList.FirstOrDefault(p => p.EqptCode == itm.EqptCode && p.PartCode == itm.PartCode);//读取当前器具容量 + // cap.Qty = cap.Qty - itm.SumQty;//当前数量 + // cap.Percent = cap.Qty / cap.StdQty; + //} + + //foreach (var itm in p_ls) + //{ + // itm.Type = EnumEquipmentRecordType.UnBind; + // itm.SetId(GuidGenerator.Create()); + //} - await _repository.InsertManyAsync(p_ls).ConfigureAwait(false); + //await _repository.InsertManyAsync(p_ls).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs deleted file mode 100644 index 9875da3bf..000000000 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Equipments/IEquipmentLocCapRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Threading.Tasks; -using Win_in.Sfs.Shared.Domain; -using Win_in.Sfs.Wms.Store.Equipments; - -namespace Win_in.Sfs.Wms.Store.Domain; - -public interface IEquipmentLocCapRepository : ISfsStoreRepositoryBase, ISfsBulkRepositoryBase -{ - Task UpsertAsync(EquipmentLocCap newData); -} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs deleted file mode 100644 index 7055a4055..000000000 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapDbContextModelCreatingExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore.Modeling; -using Win_in.Sfs.Shared.Domain.Shared; -using Win_in.Sfs.Wms.Store.Domain; -using Win_in.Sfs.Wms.Store.Equipments; - -namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; - -public static class EquipmentLocCapDbContextModelCreatingExtensions -{ - public static void ConfigureEquipmentLocCap(this ModelBuilder builder, StoreModelBuilderConfigurationOptions options) - { - builder.Entity(b => - { - //Configure table & schema name - b.ToTable(options.TablePrefix + nameof(EquipmentLocCap), options.Schema); - //Configure ABP properties - b.ConfigureByConvention(); - //Configure Sfs base properties - b.ConfigureSfsStoreBase(); - - b.Property(q => q.EqptCode).HasMaxLength(SfsPropertyConst.CodeLength); - - b.Property(q => q.PartCode).HasMaxLength(SfsPropertyConst.CodeLength); - - b.HasIndex(q => new { q.EqptCode }); - - }); - - - } -} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs deleted file mode 100644 index 22b627b26..000000000 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore; -using Win_in.Sfs.Shared.Domain; -using Win_in.Sfs.Wms.Store.Domain; -using Win_in.Sfs.Wms.Store.Equipments; - -namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; - -public class EquipmentLocCapEfCoreRepository : SfsStoreEfCoreRepositoryBase, IEquipmentLocCapRepository, ISfsBulkRepositoryBase -{ - public EquipmentLocCapEfCoreRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } - - - - public Task UpsertAsync(EquipmentLocCap newData) - { - throw new System.NotImplementedException(); - } -} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs index cc1d76eac..7e073a98a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs @@ -30,7 +30,7 @@ public static class StoreDbContextModelCreatingExtensions builder.ConfigureWorkOrder(options); builder.ConfigureEquipmentRecord(options); - builder.ConfigureEquipmentLocCap(options); + //builder.ConfigureEquipmentLocCap(options); From 44ada2128a42555dd4f2ee500b3380d2793a86de Mon Sep 17 00:00:00 2001 From: liuyunfeng Date: Wed, 13 Mar 2024 16:16:52 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E9=A2=84=E5=85=A5=E5=BA=93=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SplitPackings/Commons/SplitPacking_UpdateDetailInput.cs | 3 +++ .../ExpectOuts/ExpectOutAppService.cs | 4 ++-- .../Notes/TransferNotes/TransferNoteAppService.cs | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/SplitPackings/Commons/SplitPacking_UpdateDetailInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/SplitPackings/Commons/SplitPacking_UpdateDetailInput.cs index 9b47d3434..765da4cfd 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/SplitPackings/Commons/SplitPacking_UpdateDetailInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/SplitPackings/Commons/SplitPacking_UpdateDetailInput.cs @@ -36,5 +36,8 @@ public class SplitPacking_UpdateDetailInput [Range(1, 99999, ErrorMessage = "{0}值范围在1至99999之间")] public decimal ToQty { get; set; } + public string FromLocationCode { get; set; } + + public string ToLocationCode { get; set; } } diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs index c1700e45d..67dbeb18a 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs @@ -189,10 +189,10 @@ public class ExpectOutAppService [HttpPost("save-detail-split-packing")] public virtual async Task> SaveDetail_SplitPackingAsync(SplitPacking_UpdateDetailInput input) { - var obj = await _repository.FindAsync(p => p.JobNumber == input.Number && p.PackingCode == input.FromPackingCode && p.Qty == input.FromQty).ConfigureAwait(false); + var obj = await _repository.FindAsync(p => p.JobNumber == input.Number && p.PackingCode == input.FromPackingCode && p.Qty == input.FromQty && p.LocationCode == input.FromLocationCode).ConfigureAwait(false); if (obj == null) { - return null; + throw new UserFriendlyException($"预计出表没有数据:JobNumber={input.Number}|PackingCode={input.FromPackingCode}|Qty={input.FromQty}|LocationCode={input.FromLocationCode}"); } //插入目标箱 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs index 3ee3eb757..18bf55a9e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs @@ -451,6 +451,8 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase newInput.FromQty = updateJobDetailInput.FromQty; newInput.ToPackingCode = updateJobDetailInput.ToPackingCode; newInput.ToQty = updateJobDetailInput.ToQty; + newInput.FromLocationCode = transferNoteEditInput.Details[0].FromLocationCode; + newInput.ToLocationCode = transferNoteEditInput.Details[0].ToLocationCode; var expectOutRet = await _expectOutAppService.SaveDetail_SplitPackingAsync(newInput).ConfigureAwait(false); var jobRet = await _inspectJobAppService.SaveDetail_SplitPackingAsync(updateJobDetailInput).ConfigureAwait(false); var ret = await SplitPackingAsync(transferNoteEditInput).ConfigureAwait(false); //库存操作 @@ -472,6 +474,8 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase newInput.FromQty = updateJobDetailInput.FromQty; newInput.ToPackingCode = updateJobDetailInput.ToPackingCode; newInput.ToQty = updateJobDetailInput.ToQty; + newInput.FromLocationCode = transferNoteEditInput.Details[0].FromLocationCode; + newInput.ToLocationCode = transferNoteEditInput.Details[0].ToLocationCode; var expectOutRet = await _expectOutAppService.SaveDetail_SplitPackingAsync(newInput).ConfigureAwait(false); var jobRet = await _issueJobAppService.SaveDetail_SplitPackingAsync(updateJobDetailInput).ConfigureAwait(false); var ret = await SplitPackingAsync(transferNoteEditInput).ConfigureAwait(false); //库存操作 From 1da74411cef4175911fa0b41aef9bd273941af70 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Wed, 13 Mar 2024 16:27:11 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0EquipmentRecocd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/EquipmentRecordAppService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs index d32648c2f..a57637e3b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Equipments/EquipmentRecordAppService.cs @@ -49,6 +49,7 @@ public class EquipmentRecordAppService /// /// /// + [HttpPost("Bind")] public Task> Bind(List p_ls) { return _manager.Bind(p_ls); @@ -60,6 +61,7 @@ public class EquipmentRecordAppService /// /// /// + [HttpPost("UnBind")] public Task> UnBind(List p_ls) { return _manager.UnBind(p_ls); From c02a2f9a768b2ed602b27c47615add5d9ab98cbe Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Thu, 14 Mar 2024 10:27:14 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=99=A8=E5=85=B7?= =?UTF-8?q?=E5=AE=B9=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Equipments/DTOs/EquipmentLocCapDTO.cs | 40 +++++++++++ .../Equipments/DTOs/EquipmentPartCodeDTO.cs | 2 +- .../Equipments/IEquipmentLocCapAppService.cs | 28 ++++++++ .../Inputs/EquipmentLocCapCheckInput.cs | 20 ++++++ .../Inputs/EquipmentLocCapEditInput.cs | 20 ++++++ .../Inputs/EquipmentLocCapImportInput.cs | 38 ++++++++++ .../BasedataApplicationAutoMapperProfile.cs | 4 +- .../Equipments/EquipmentLocCapAppService.cs | 70 +++++++++++++++++++ .../EquipmentLocCapAutoMapperProfile.cs | 43 ++++++++++++ .../Equipments/EquipmentLocCap.cs | 6 +- .../Equipments/IEquipmentLocCapRepository.cs | 2 +- ...uipmentDbContextModelCreatingExtensions.cs | 4 +- .../Equipments/EquipmentEfCoreRepository.cs | 4 +- .../EquipmentLocCapEfCoreRepository.cs | 4 +- 14 files changed, 273 insertions(+), 12 deletions(-) create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocCapDTO.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocCapAppService.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapCheckInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapEditInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapImportInput.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAppService.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAutoMapperProfile.cs diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocCapDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocCapDTO.cs new file mode 100644 index 000000000..6a4ad91ce --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentLocCapDTO.cs @@ -0,0 +1,40 @@ +using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; + +namespace Win_in.Sfs.Basedata.Application.Contracts; + + + +[Display(Name = "器具容量占用信息")] + +public class EquipmentLocCapDTO : SfsBaseDataDTOBase, IHasCode +{ + /// + /// 器具代码 + /// + [Display(Name = "器具代码")] + public string Code { get; set; } + /// 占用百分比 + /// + [Display(Name = "占用百分比")] + public decimal Percent { get; set; } + + + /// + /// 零件号 + /// + public string PartCode { get; set; } + + /// + /// 录入数量 + /// + public decimal Qty { get; set; } + + /// + /// 标包数量 + /// + public decimal StdQty { get; set; } + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs index 03e9f4dba..2a6510242 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/DTOs/EquipmentPartCodeDTO.cs @@ -7,7 +7,7 @@ namespace Win_in.Sfs.Basedata.Application.Contracts; using System; using System.Collections.Generic; -[Display(Name = "器具基本信息")] +[Display(Name = "器具零件关系信息")] public class EquipmentPartCodeDTO : SfsBaseDataDTOBase, IHasCode { diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocCapAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocCapAppService.cs new file mode 100644 index 000000000..dfe01c9b7 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/IEquipmentLocCapAppService.cs @@ -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 IEquipmentLocCapAppService + : ISfsBaseDataAppServiceBase + , ISfsGetByCodeAppService + , ISfsCheckAppService + , ISfsUpsertAppService +{ + //Task CheckItemIsAvailable(string itemCode); + //[HttpGet("check-item-is-available-no-select-sql")] + //void CheckItemIsAvailable(EquipmentLocCapDTO EquipmentLocCapDTO); + + //Task> GetListByNameAsync(string name); + + //Task GetOrAddAsync(EquipmentLocCapEditInput input); + + //Task GetManageTypeAsync(string itemCode); + //Task> GetManageTypesAsync(List itemCodes); + + //Task UpsertAsyncByInterface(EquipmentLocCapEditInput input); + //Task UpsertStdPackQtyAsync(string itemCode, decimal stdpackqty); +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapCheckInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapCheckInput.cs new file mode 100644 index 000000000..d7b272c8e --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapCheckInput.cs @@ -0,0 +1,20 @@ +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 EquipmentLocCapCheckInput +{ + /// + /// 器具代码 + /// + [Display(Name = "器具代码")] + public string Code { get; set; } + /// 占用百分比 + /// + [Display(Name = "占用百分比")] + public decimal Percent { get; set; } + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapEditInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapEditInput.cs new file mode 100644 index 000000000..ef9146b56 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapEditInput.cs @@ -0,0 +1,20 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; + +namespace Win_in.Sfs.Basedata.Application.Contracts; + +public class EquipmentLocCapEditInput : SfsBaseDataCreateOrUpdateInputBase +{ + /// + /// 器具代码 + /// + [Display(Name = "器具代码")] + public string Code { get; set; } + /// 占用百分比 + /// + [Display(Name = "占用百分比")] + public decimal Percent { get; set; } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapImportInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapImportInput.cs new file mode 100644 index 000000000..796c95708 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentLocCapImportInput.cs @@ -0,0 +1,38 @@ +using System; +using System.ComponentModel.DataAnnotations; + +using Win_in.Sfs.Shared.Domain.Shared.Enums.Basedata; + +namespace Win_in.Sfs.Basedata.Application.Contracts; + +[Display(Name = "器具容量")] +public class EquipmentLocCapImportInput : SfsBaseDataImportInputBase +{ + /// + /// 器具代码 + /// + [Display(Name = "器具代码")] + public string Code { get; set; } + /// 占用百分比 + /// + [Display(Name = "占用百分比")] + public decimal Percent { get; set; } + //[Display(Name = "零件代码")] + + //public string PartCode { get; set; } + + //[Display(Name = "当前数量")] + ///// + ///// 录入数量 + ///// + //public decimal Qty { get; set; } + //[Display(Name = "标包数量")] + ///// + ///// 标包数量 + ///// + //public decimal StdQty { get; set; } + + + + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs index 4f94c8ef2..c5301da0f 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/BasedataApplicationAutoMapperProfile.cs @@ -54,6 +54,8 @@ public partial class BasedataApplicationAutoMapperProfile : Profile KittingAutoMapperProfile(); EquipmentLocAutoMapperProfile(); EquipmentPartCodeAutoMapperProfile(); - + EquipmentLocCapAutoMapperProfile(); + + } } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAppService.cs new file mode 100644 index 000000000..8b1e527b9 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAppService.cs @@ -0,0 +1,70 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Caching; +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.Application.Contracts.ExportAndImport; +namespace Win_in.Sfs.Basedata.Application; + +[Authorize] +[Route($"{BasedataConsts.RootPath}EquipmentLocCap")] +public class EquipmentLocCapAppService + : SfsBaseDataWithCodeAppServiceBase + , IEquipmentLocCapAppService +{ + private readonly IEquipmentLocCapManager _manager; + private new readonly IEquipmentLocCapRepository _repository; + private readonly IExportImportService _importService; + public EquipmentLocCapAppService( + IEquipmentLocCapRepository repository, + IDistributedCache cache, + IExportImportService importService, + IEquipmentLocCapManager manager) + : base(repository, cache) + { + _importService=importService; + _repository = repository; + _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, EquipmentLocCapCheckInput input) + { + await Task.CompletedTask.ConfigureAwait(false); + } + [HttpPost("upsert")] + + public virtual async Task UpsertAsync(EquipmentLocCapEditInput input) + { + var entity = ObjectMapper.Map(input); + await _repository.UpsertAsync(entity).ConfigureAwait(false); + } + + [HttpPost] + [Route("")] + public override async Task CreateAsync(EquipmentLocCapEditInput input) + { + var query =await _repository.GetQueryableAsync().ConfigureAwait(false); + var first=query.FirstOrDefault(p => p.Code == input.Code); + if (first == null) + { + var entity = ObjectMapper.Map(input); + entity.Code = string.Format("{0}{1}", "Q", entity.Code); + await _repository.UpsertAsync(entity).ConfigureAwait(false); + var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + return ObjectMapper.Map(entity1); + } + else + { + throw new UserFriendlyException($"已存在器具编号{input.Code}!"); + } + } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAutoMapperProfile.cs new file mode 100644 index 000000000..fd94d51bb --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentLocCapAutoMapperProfile.cs @@ -0,0 +1,43 @@ +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 EquipmentLocCapAutoMapperProfile() + { + CreateMap() + .IgnoreAuditedObjectProperties() + + .ReverseMap(); + + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.TenantId) + .Ignore(x => x.Remark) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.ConcurrencyStamp) + .Ignore(x => x.StdQty) + .Ignore(x => x.PartCode) + .Ignore(x => x.Qty) + .Ignore(x => x.ConcurrencyStamp) + + + .ForMember(p => p.Code, p => p.MapFrom(q =>q.Code)); + + //CreateMap() + + //CreateMap() + // .Ignore(x => x.ItemCategory) + // .Ignore(x => x.Color); + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.StdQty) + .Ignore(x => x.PartCode) + .Ignore(x => x.Qty) + .Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id); + } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCap.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCap.cs index d2e0183c5..facd32dde 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCap.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/EquipmentLocCap.cs @@ -8,12 +8,12 @@ using Win_in.Sfs.Shared.Domain; namespace Win_in.Sfs.Basedata.Domain; -public class EquipmentLocCap:SfsAggregateRootBase +public class EquipmentLocCap:SfsAggregateRootBase, IHasCode { /// - /// 器具编码 + /// 器具代码 /// - public string EqptCode { get; set; } + public string Code { get; set; } /// /// 零件号 /// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs index 6bd79f7bf..1d8089fe8 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Equipments/IEquipmentLocCapRepository.cs @@ -5,7 +5,7 @@ using Win_in.Sfs.Shared.Domain; namespace Win_in.Sfs.Basedata.Domain; -public interface IEquipmentLocCapRepository : IDomainService, ISfsBulkRepositoryBase +public interface IEquipmentLocCapRepository : ISfsBaseDataRepositoryBase, ISfsBulkRepositoryBase { Task UpsertAsync(EquipmentLocCap newData); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs index cf85b7de0..37b9c9852 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs @@ -42,7 +42,7 @@ public static class EquipmentDbContextModelCreatingExtensions b.ConfigureSfsBase(); //Properties - b.Property(q => q.EqptCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(true); + b.Property(q => q.Code).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(true); b.Property(q => q.PartCode).HasMaxLength(SfsPropertyConst.CodeLength); @@ -50,7 +50,7 @@ public static class EquipmentDbContextModelCreatingExtensions //None //Indexes - b.HasIndex(q => new { q.EqptCode }).IsUnique(); + b.HasIndex(q => new { q.Code }).IsUnique(); }); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs index 2c56b70d6..1d52ed2b1 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentEfCoreRepository.cs @@ -24,7 +24,7 @@ public class EquipmentEfCoreRepository : SfsBaseDataEfCoreRepositoryBase().AddAsync(cap).ConfigureAwait(false); @@ -49,7 +49,7 @@ public class EquipmentEfCoreRepository : SfsBaseDataEfCoreRepositoryBase().AddAsync(cap).ConfigureAwait(false); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs index 2c0124040..6315ea9e0 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentLocCapEfCoreRepository.cs @@ -18,7 +18,7 @@ public class EquipmentLocCapEfCoreRepository : SfsBaseDataEfCoreRepositoryBase p.EqptCode == entity.EqptCode).ConfigureAwait(false); + var exist = await dbSet.FirstOrDefaultAsync(p => p.Code == entity.Code).ConfigureAwait(false); if (exist == null) { var insRet = await InsertAsync(entity).ConfigureAwait(false); @@ -40,7 +40,7 @@ public class EquipmentLocCapEfCoreRepository : SfsBaseDataEfCoreRepositoryBase p.EqptCode == entity.EqptCode).ConfigureAwait(false); + var exist = await dbSet.FirstOrDefaultAsync(p => p.Code == entity.Code).ConfigureAwait(false); if (exist == null) { var insRet = await InsertAsync(entity).ConfigureAwait(false);