diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs new file mode 100644 index 00000000..51a89a5f --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs @@ -0,0 +1,105 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Magicodes.ExporterAndImporter.Core; + +namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos; + +/// +/// HBPO结算单 +/// +public class HBPO_SA_DTO +{ + /// + /// 期间 + /// + [Display(Name = "期间")] + public int Version { get; set; } + + /// + /// 结算单据 + /// + [Display(Name = "结算单据")] + public string BillNum { get; set; } + + /// + /// 出库单号 + /// + [Display(Name = "出库单号")] + public string DNBillNum { get; set; } + + /// + /// 1、新建 2、已有出库3、已有扣减寄售库 + /// + [Display(Name = "状态")] + public string State { get; set; } + + /// + /// 明细记录行数 + /// + [Display(Name = "明细记录行数")] + public string RecordCount { get; set; } + + /// + /// 工厂地点 + /// + [Display(Name = "工厂地点")] + public string Site { get; set; } + + /// + /// 业务类型 + /// + [Display(Name = "业务类型")] + public EnumBusinessType BusinessType { get; set; } +} + +/// +/// HBPO结算明细导入 +/// +public class HBPO_SA_DETAIL_IMPORT_DTO +{ + /// + /// 结算日期 + /// + [Display(Name = "结算日期")] + [ImporterHeader(Name = "ReceiveDate", Format = "yyyy/MM/dd")] + public DateTime SettleDate { set; get; } + + /// + /// 零件号 + /// + [Display(Name = "零件号")] + [Required(ErrorMessage = "{0}不能为空")] + [ImporterHeader(Name = "PartNumber")] + public string LU { get; set; } + + /// + /// 生产号 + /// + [Display(Name = "生产号")] + [ImporterHeader(Name = "productionNumber")] + [Required(ErrorMessage = "{0}不能为空")] + public string PN { get; set; } + + /// + /// 数量 + /// + [Display(Name = "数量")] + [ImporterHeader(Name = "Qty")] + public decimal Qty { get; set; } + + /// + /// 结算分组号 + /// + [Display(Name = "结算分组号")] + [ImporterHeader(Name = "DeliveryNode")] + [Required(ErrorMessage = "{0}不能为空")] + public string GroupNum { get; set; } + + /// + /// 工厂地点 + /// + [Display(Name = "工厂地点")] + [ImporterHeader(Name = "filename")] + [Required(ErrorMessage = "{0}不能为空")] + public string Site { get; set; } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs index e32af455..a139c935 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs @@ -1,67 +1,65 @@ -using Magicodes.ExporterAndImporter.Core; using System; using System.ComponentModel.DataAnnotations; +using Magicodes.ExporterAndImporter.Core; using Volo.Abp.Application.Dtos; -using Win.Sfs.Shared.DtoBase; -namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos +namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos; + +/// +/// 采购价格单 +/// +public class PURCHASE_PRICE_DTO : EntityDto { /// - /// 采购价格单 + /// 零件号 /// - public class PURCHASE_PRICE_DTO : EntityDto - { - /// - /// 零件号 - /// - [Display(Name = "零件号")] - public string LU { get; set; } - - /// - /// 价格 - /// - [Display(Name = "价格")] - public decimal Price { get; set; } - } + [Display(Name = "零件号")] + public string LU { get; set; } /// - /// 导入 + /// 价格 /// - public class PURCHASE_PRICE_IMPORT_DTO - { - /// - /// 零件号 - /// - [Display(Name = "零件号")] - [ImporterHeader(Name = "零件号")] - public string LU { get; set; } + [Display(Name = "价格")] + public decimal Price { get; set; } +} - /// - /// 价格 - /// - [Display(Name = "价格")] - [ImporterHeader(Name = "价格")] - public decimal Price { get; set; } - } +/// +/// 导入 +/// +public class PURCHASE_PRICE_IMPORT_DTO +{ + /// + /// 零件号 + /// + [Display(Name = "零件号")] + [Required(ErrorMessage = "{0}是必填项")] + [ImporterHeader(Name = "零件号")] + public string LU { get; set; } /// - /// 导出 + /// 价格 /// - public class PURCHASE_PRICE_EXPORT_DTO - { - /// - /// 零件号 - /// - [Display(Name = "零件号")] - [ExporterHeader(DisplayName = "零件号")] - public string LU { get; set; } + [Display(Name = "价格")] + [ImporterHeader(Name = "价格")] + public decimal Price { get; set; } +} - /// - /// 价格 - /// - [Display(Name = "价格")] - [ExporterHeader(DisplayName = "价格")] - public decimal Price { get; set; } - } +/// +/// 导出 +/// +public class PURCHASE_PRICE_EXPORT_DTO +{ + /// + /// 零件号 + /// + [Display(Name = "零件号")] + [ExporterHeader(DisplayName = "零件号")] + public string LU { get; set; } + /// + /// 价格 + /// + [Display(Name = "价格")] + [ExporterHeader(DisplayName = "价格")] + public decimal Price { get; set; } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs index 6b7c4e21..82cabdb0 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs @@ -1,4 +1,4 @@ -using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Core; using System; using System.ComponentModel.DataAnnotations; using Volo.Abp.Application.Dtos; @@ -22,12 +22,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "替换零件号")] public string RepLU { set; get; } - /// - /// 客户编码 - /// - [Display(Name = "客户编码")] - public string ClientCode { set; get; } - /// /// 业务类型 /// @@ -41,32 +35,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public class TB_RePartsRelationship_IMPORT_DTO { /// - /// 零件号 + /// 客户物料号 /// - [Display(Name = "零件号")] - [ImporterHeader(Name = "零件号")] + [Display(Name = "客户物料号")] + [Required(ErrorMessage = "{0}是必填项")] + [ImporterHeader(Name = "客户物料号")] public string LU { set; get; } - /// - /// 替换零件号 - /// - [Display(Name = "替换零件号")] - [ImporterHeader(Name = "替换零件号")] - public string RepLU { set; get; } - - /// - /// 客户编码 - /// - [Display(Name = "客户编码")] - [ImporterHeader(Name = "客户编码")] - public string ClientCode { set; get; } - /// /// 业务类型 /// [Display(Name = "业务类型")] - [ImporterHeader(Name = "业务类型")] + [ImporterHeader(Name = "业务分类")] public EnumBusinessType BusinessType { get; set; } + + /// + /// 替换客户物料号 + /// + [Display(Name = "替换客户物料号")] + [Required(ErrorMessage = "{0}是必填项")] + [ImporterHeader(Name = "替换客户物料号")] + public string RepLU { set; get; } } /// @@ -78,29 +67,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// 零件号 /// [Display(Name = "零件号")] - [ExporterHeader(DisplayName = "零件号")] + [ExporterHeader(DisplayName = "客户物料号")] public string LU { set; get; } - /// - /// 替换零件号 - /// - [Display(Name = "替换零件号")] - [ExporterHeader(DisplayName = "替换零件号")] - public string RepLU { set; get; } - - /// - /// 客户编码 - /// - [Display(Name = "客户编码")] - [ExporterHeader(DisplayName = "客户编码")] - public string ClientCode { set; get; } - /// /// 业务类型 /// [Display(Name = "业务类型")] - [ExporterHeader(DisplayName = "业务类型")] + [ExporterHeader(DisplayName = "业务分类")] public EnumBusinessType BusinessType { get; set; } + + /// + /// 替换零件号 + /// + [Display(Name = "替换零件号")] + [ExporterHeader(DisplayName = "替换客户物料号")] + public string RepLU { set; get; } } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomDto.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomDto.cs index bce40eb4..26537991 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomDto.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomDto.cs @@ -1,82 +1,77 @@ -// 闻荫智慧工厂管理套件 -// Copyright (c) 闻荫科技 www.ccwin-in.com - using System; using System.ComponentModel.DataAnnotations; -using Win.Sfs.Shared; -using Win.Sfs.Shared.Constant; -using Win.Sfs.Shared.DtoBase; - -namespace Win.Sfs.SettleAccount.Boms -{ - public class BomDto : AuditedEntityDtoBase, IBranch - { - /// - /// 分支id - /// - [Display(Name = "分支Id")] - [Required(ErrorMessage = "{0}是必填项")] - - public Guid BranchId { get; set; } - [Display(Name = "父物料编码")] - [Required(ErrorMessage = "{0}是必填项")] - public string ParentItemCode { get; set; } - - - [Display(Name = "父物料描述")] - [MaxLength(CommonConsts.MaxDescriptionLength, ErrorMessage = "{0}最多输入{1}个字符")] - public string ParentItemDesc { get; set; } - - - [Display(Name = "组件编码")] - [Required(ErrorMessage = "{0}是必填项")] - public string ChildItemCode { get; set; } - - [Display(Name = "组件描述")] - [MaxLength(CommonConsts.MaxDescriptionLength, ErrorMessage = "{0}最多输入{1}个字符")] - public string ChildItemDesc { get; set; } - - - [Display(Name = "组件计量单位")] - public string ChildItemUom { get; set; } - - - [Display(Name = "组件数量")] - [Required(ErrorMessage = "{0}是必填项")] - public decimal Qty { get; set; } +using Volo.Abp.Application.Dtos; - [Display(Name = "工序")] - public int OperateProcess { get; set; } +namespace Win.Sfs.SettleAccount.Boms; - - [Display(Name = "废品率")] - public decimal ScrapPercent { get; set; } - - [Display(Name = "结构类型")] - [StringLength(CommonConsts.MaxCodeLength, ErrorMessage = "{0}最多输入{1}个字符")] - public string BomType { get; set; } - - [Display(Name = "生效时间")] - public DateTime EffectiveTime { get; set; } - - [Display(Name = "失效时间")] - public DateTime ExpireTime { get; set; } - - [Display(Name = "子物品消耗位置")] - public string IssuePosition { get; set; } - - [Display(Name = "结构层级")] - public int BomLevel { get; set; } - - - public string Version { set; get; } - /// - /// 工厂 - /// - public string Factory { set; get; } - - - - - } -} \ No newline at end of file +/// +/// Bom +/// +public class BomDto : EntityDto +{ + /// + /// 父物料编码 + /// + [Display(Name = "父物料编码")] + public string ParentItemCode { get; set; } + + /// + /// 父物料描述 + /// + [Display(Name = "父物料描述")] + public string ParentItemDesc { get; set; } + + /// + /// 组件编码 + /// + [Display(Name = "组件编码")] + public string ChildItemCode { get; set; } + + /// + /// 组件描述 + /// + [Display(Name = "组件描述")] + public string ChildItemDesc { get; set; } + + /// + /// 组件计量单位 + /// + [Display(Name = "组件计量单位")] + public string ChildItemUom { get; set; } + + /// + /// 组件数量 + /// + [Display(Name = "组件数量")] + public decimal Qty { get; set; } + + /// + /// 结构类型 + /// + [Display(Name = "结构类型")] + public string BomType { get; set; } + + /// + /// 工序 + /// + [Display(Name = "工序")] + public int OperateProcess { get; set; } + + /// + /// 废品率 + /// + [Display(Name = "废品率")] + public decimal ScrapPercent { get; set; } + + /// + /// 子物品消耗位置 + /// + [Display(Name = "子物品消耗位置")] + public string IssuePosition { get; set; } + + /// + /// 结构层级 + /// + [Display(Name = "结构层级")] + public int BomLevel { get; set; } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs index 7d57aa68..1f2e1f56 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs @@ -1,36 +1,87 @@ -using Magicodes.ExporterAndImporter.Core; +using System.ComponentModel.DataAnnotations; +using Magicodes.ExporterAndImporter.Core; -namespace Win.Sfs.SettleAccount.Entities.Boms +namespace Win.Sfs.SettleAccount.Entities.Boms; + +/// +/// Bom导出 +/// +public class BomExportDto { - public class BomExportDto - { - - [ExporterHeader(DisplayName = "期间")] - public string Version { set; get; } - /// - /// 工厂 - /// - [ExporterHeader(DisplayName = "工厂")] - public string Factory { set; get; } + /// + /// 父物料编码 + /// + [Display(Name = "父物料编码")] + [ExporterHeader(DisplayName = "父物料编码")] + public string ParentItemCode { get; set; } + + /// + /// 父物料描述 + /// + [Display(Name = "父物料描述")] + [ExporterHeader(DisplayName = "父物料描述")] + public string ParentItemDesc { get; set; } + + /// + /// 组件编码 + /// + [Display(Name = "组件编码")] + [ExporterHeader(DisplayName = "组件编码")] + public string ChildItemCode { get; set; } + + /// + /// 组件描述 + /// + [Display(Name = "组件描述")] + [ExporterHeader(DisplayName = "组件描述")] + public string ChildItemDesc { get; set; } + /// + /// 组件计量单位 + /// + [Display(Name = "组件计量单位")] + [ExporterHeader(DisplayName = "组件计量单位")] + public string ChildItemUom { get; set; } - [ExporterHeader(DisplayName = "ERP总成物料号")] - public string ParentItemCode { get; set; } + /// + /// 组件数量 + /// + [Display(Name = "组件数量")] + [ExporterHeader(DisplayName = "组件数量")] + public decimal Qty { get; set; } - [ExporterHeader(DisplayName = "ERP总成物料号描述")] - public string ParentItemDesc { get; set; } + /// + /// 结构类型 + /// + [Display(Name = "结构类型")] + [ExporterHeader(DisplayName = "结构类型")] + public string BomType { get; set; } - [ExporterHeader(DisplayName = "ERP组件物料号")] - public string ChildItemCode { get; set; } + /// + /// 工序 + /// + [Display(Name = "工序")] + [ExporterHeader(DisplayName = "工序")] + public int OperateProcess { get; set; } - [ExporterHeader(DisplayName = "ERP组件物料号描述")] - public string ChildItemDesc { get; set; } + /// + /// 废品率 + /// + [Display(Name = "废品率")] + [ExporterHeader(DisplayName = "废品率")] + public decimal ScrapPercent { get; set; } - [ExporterHeader(DisplayName = "组件数量")] - public decimal Qty { get; set; } + /// + /// 子物品消耗位置 + /// + [Display(Name = "子物品消耗位置")] + [ExporterHeader(DisplayName = "子物品消耗位置")] + public string IssuePosition { get; set; } - [ExporterHeader(DisplayName = "组件计量单位")] - public string ChildItemUom { get; set; } - } - + /// + /// 结构层级 + /// + [Display(Name = "结构层级")] + [ExporterHeader(DisplayName = "结构层级")] + public int BomLevel { get; set; } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs index 51f1625b..50089fef 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel.DataAnnotations; using Win.Sfs.Shared.DomainBase; @@ -111,7 +111,7 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships } /// - /// FIS + /// 导出 /// public class MaterialRelationshipExportDto { @@ -124,7 +124,7 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships /// /// 厂内物料描述 /// - [ExporterHeaderAttribute(DisplayName = "厂内物料描述")] + [ExporterHeaderAttribute(DisplayName = "厂内物料描述")] public string MaterialDesc { get; set; } /// @@ -132,15 +132,11 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships /// [ExporterHeaderAttribute(DisplayName = "客户物料号")] public string SettleMaterialCode { get; set; } - - /// - /// 客户物料描述 - /// - [ExporterHeaderAttribute(DisplayName = "客户物料描述")] - public virtual string MaterialProperty { get; set; } - } + /// + /// 客户零件关系导入 + /// [ImportProject(Name = "零件匹配关系")] public class MaterialRelationshipImportDto { @@ -156,6 +152,7 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships /// 厂内物料描述 /// [ImporterHeader(Name = "厂内物料描述")] + [Required(ErrorMessage = "{0}是必填项")] [MaxLength(CommonConsts.MaxNameLength, ErrorMessage = "{0}最多输入{1}个字符")] public string MaterialDesc { get; set; } @@ -163,14 +160,9 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships /// 客户物料号 /// [ImporterHeader(Name = "客户物料号")] + [Required(ErrorMessage = "{0}是必填项")] + [MaxLength(CommonConsts.MaxNameLength, ErrorMessage = "{0}最多输入{1}个字符")] public string SettleMaterialCode { get; set; } - - /// - /// 客户物料描述 - /// - [ImporterHeader(Name = "客户物料描述")] - public virtual string MaterialProperty { get; set; } - } public class MaterialRelationshipDetailDto : EntityDto @@ -386,4 +378,4 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships -} \ No newline at end of file +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs index b8e7bd3d..b5805da9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs @@ -1,4 +1,4 @@ -using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Core; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -361,14 +361,11 @@ namespace Win.Sfs.SettleAccount.Entities.Materials } + /// + /// 导出 + /// public class MaterialExportDto { - /// - /// 客户物料号 - /// - [ExporterHeader(DisplayName = "客户物料号")] - public string CustomerPartCode { set; get; } - /// /// 厂内物料号 /// @@ -376,22 +373,9 @@ namespace Win.Sfs.SettleAccount.Entities.Materials public string MaterialCode { set; get; } /// - /// 物料描述 + /// 厂内物料描述 /// - [ExporterHeader(DisplayName = "物料描述")] + [ExporterHeader(DisplayName = "厂内物料描述")] public string MaterialDesc { set; get; } - - /// - /// 基础计量单位 - /// - [ExporterHeader(DisplayName = "基本计量单位")] - public string Unit { set; get; } - - /// - /// 产品类型 - /// - [ExporterHeader(DisplayName = "产品类型")] - public string EstimateType { set; get; } - } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs index 0d0570dd..db6d27b2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs @@ -1,545 +1,474 @@ -using Magicodes.ExporterAndImporter.Core; -using Magicodes.ExporterAndImporter.Excel; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using Magicodes.ExporterAndImporter.Core; using Volo.Abp.Application.Dtos; using Win.Sfs.SettleAccount.Attributes; using Win.Sfs.SettleAccount.Bases; using Win.Sfs.Shared.Filter; -namespace Win.Sfs.SettleAccount.Entities.Prices +namespace Win.Sfs.SettleAccount.Entities.Prices; + +public class PriceListDto : EntityDto +{ + /// + /// 版本 + /// + [Display(Name = "版本")] + public string Version { set; get; } + /// + ///开始时间 + /// + [Display(Name = "开始时间")] + public DateTime BeginDate { get; set; } + /// + ///结算时间 + /// + [Display(Name = "结算时间")] + public DateTime EndDate { get; set; } + /// + ///价格 + /// + [Display(Name = "价格")] + public decimal Price { get; set; } + /// + ///物料编号 + /// + [Display(Name = "物料编号")] + public string MaterialCode { get; set; } + /// + ///价格类型 + /// + [Display(Name = "价格类型")] + public int Type { get; set; } + + public Guid ParentId { set; get; } + [Display(Name = "客户")] + public string CustomerCode { get; set; } + +} + +/// +/// 销售价格单导出 +/// +public class PriceListExportDto +{ + /// + /// 零件号 + /// + [Display(Name = "零件号")] + [ExporterHeader(DisplayName = "客户零件号")] + public string LU { get; set; } + + /// + /// 价格 + /// + [Display(Name = "价格")] + [ExporterHeader(DisplayName = "价格")] + public Decimal Price { set; get; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + [ExporterHeader(DisplayName = "开始时间")] + public DateTime BeginTime { set; get; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + [ExporterHeader(DisplayName = "结束时间")] + public DateTime EndTime { set; get; } + + /// + /// 客户编码 + /// + [Display(Name = "客户编码")] + [ExporterHeader(DisplayName = "客户编码")] + public string ClientCode { get; set; } + + /// + /// 合同签订时间 + /// + [Display(Name = "合同签订时间")] + [ExporterHeader(DisplayName = "合同签订时间")] + public DateTime Date { get; set; } + + /// + /// 合同号 + /// + [Display(Name = "合同号")] + [ExporterHeader(DisplayName = "合同号")] + public string ContractNo { get; set; } +} + +/// +/// 销售价格导入 +/// +[ImportProject(Name = SettleAccountModuleName.PriceList)] +[Importer(HeaderRowIndex = 22)] +public class PriceListImportDto +{ + /// + /// 合同签订时间 + /// + [ImporterHeader(IsIgnore = true)] + [ExcelImporterHeadDesc(Row = 1, Cell = 1)] + public string Date { get; set; } + + /// + /// 合同号 + /// + [ImporterHeader(IsIgnore = true)] + [ExcelImporterHeadDesc(Row = 2, Cell = 1)] + public string ContractNo { get; set; } + + /// + /// 零件号 + /// + [Display(Name = "零件号")] + [Required(ErrorMessage = "{0}是必填项")] + [ImporterHeader(Name = "Part No.")] + public string PartNo { get; set; } + + /// + /// 价格 + /// + [ImporterHeader(Name = "Total Price")] + public string TotalPrice { get; set; } + + /// + /// 开始时间 + /// + [ImporterHeader(Name = "Valid From")] + public string ValidFrom { get; set; } + + /// + /// 结束时间 + /// + [ImporterHeader(Name = "Valid To")] + public string ValidTo { get; set; } + + /// + /// 客户编码 + /// + [ImporterHeader(Name = "Plant")] + public string Plant { get; set; } +} + +public class PriceListRequestDto : PagedAndSortedResultRequestDto +{ + [Display(Name = "开始时间")] + public DateTime BeginDate { get; set; } + [Display(Name = "结算时间")] + public DateTime EndDate { get; set; } + [Display(Name = "价格")] + public decimal Price { get; set; } + [Display(Name = "物料编号")] + public string MaterialCode { get; set; } + [Display(Name = "价格类型")] + public int Type { get; set; } + + public Guid ParentId { set; get; } + + public int FileType { set; get; } + + public string Version { set; get; } + + public virtual List Filters { get; set; } = new List(); +} + +#region 备件价格 +/// +/// 备件价格 +/// +public class PriceListBJDto : EntityDto { - public class PriceListDto : EntityDto - { - /// - /// 版本 - /// - [Display(Name = "版本")] - public string Version { set; get; } - /// - ///开始时间 - /// - [Display(Name = "开始时间")] - public DateTime BeginDate { get; set; } - /// - ///结算时间 - /// - [Display(Name = "结算时间")] - public DateTime EndDate { get; set; } - /// - ///价格 - /// - [Display(Name = "价格")] - public decimal Price { get; set; } - /// - ///物料编号 - /// - [Display(Name = "物料编号")] - public string MaterialCode { get; set; } - /// - ///价格类型 - /// - [Display(Name = "价格类型")] - public int Type { get; set; } - - public Guid ParentId { set; get; } - [Display(Name = "客户")] - public string CustomerCode { get; set; } - - } - - - /// - /// 销售价格单导出 - /// - public class PriceListExportDto - { - /// - /// 零件号 - /// - [Display(Name = "零件号")] - [ExporterHeader(DisplayName = "零件号")] - public string LU { get; set; } - - /// - /// 价格 - /// - [Display(Name = "价格")] - [ExporterHeader(DisplayName = "价格")] - public Decimal Price { set; get; } - - /// - /// 开始时间 - /// - [Display(Name = "开始时间")] - [ExporterHeader(DisplayName = "开始时间")] - public DateTime BeginTime { set; get; } - - /// - /// 结束时间 - /// - [Display(Name = "结束时间")] - [ExporterHeader(DisplayName = "结束时间")] - public DateTime EndTime { set; get; } - - /// - /// 客户编码 - /// - [Display(Name = "客户编码")] - [ExporterHeader(DisplayName = "客户编码")] - public string ClientCode { get; set; } - - /// - /// 合同签订时间 - /// - [Display(Name = "合同签订时间")] - [ExporterHeader(DisplayName = "合同签订时间")] - public DateTime Date { get; set; } - - /// - /// 合同号 - /// - [Display(Name = "合同号")] - [ExporterHeader(DisplayName = "合同号")] - public string ContractNo { get; set; } - } - - /// - /// 销售价格导入 - /// - [ImportProject(Name = SettleAccountModuleName.PriceList)] - [Importer(HeaderRowIndex = 22)] - public class PriceListImportDto - { - /// - /// 合同签订时间 - /// - [ImporterHeader(IsIgnore = true)] - [ExcelImporterHeadDesc(Row = 1, Cell = 1)] - public string Date { get; set; } - - /// - /// 合同号 - /// - [ImporterHeader(IsIgnore = true)] - [ExcelImporterHeadDesc(Row = 2, Cell = 1)] - public string ContractNo { get; set; } - - ///// - ///// ItemNo - ///// - //[ImporterHeader(Name = "ItemNo")] - //public string ItemNo { get; set; } - - /// - /// 零件号 - /// - [ImporterHeader(Name = "Part No.")] - public string PartNo { get; set; } - - ///// - ///// PartDescription - ///// - //[ImporterHeader(Name = "PartDescription")] - //public string PartDescription { get; set; } - - ///// - ///// ES1 - ///// - //[ImporterHeader(Name = "ES1")] - //public string ES1 { get; set; } - - ///// - ///// ES2 - ///// - //[ImporterHeader(Name = "ES2")] - //public string ES2 { get; set; } - - ///// - ///// ZGS - ///// - //[ImporterHeader(Name = "ZGS")] - //public string ZGS { get; set; } - - ///// - ///// UnitOfMeasure - ///// - //[ImporterHeader(Name = "UnitOfMeasure")] - //public string UnitOfMeasure { get; set; } - - ///// - ///// Currency - ///// - //[ImporterHeader(Name = "Currency")] - //public string Currency { get; set; } - - ///// - ///// PriceType - ///// - //[ImporterHeader(Name = "PriceType")] - //public string PriceType { get; set; } - - /// - /// 价格 - /// - [ImporterHeader(Name = "Total Price")] - public string TotalPrice { get; set; } - - ///// - ///// Base Price(Old) - ///// - //[ImporterHeader(Name = "Base Price(Old)")] - //public string BasePriceOld { get; set; } - - ///// - ///// UnitOfOrder - ///// - //[ImporterHeader(Name = "Unit of Order")] - //public string UnitOfOrder { get; set; } - - ///// - ///// 11000 - BBAC JIS - ///// - //[ImporterHeader(Name = "11000 - BBAC JIS")] - //public string BBACJIS { get; set; } - - /// - /// 开始时间 - /// - [ImporterHeader(Name = "Valid From")] - public string ValidFrom { get; set; } - - /// - /// 结束时间 - /// - [ImporterHeader(Name = "Valid To")] - public string ValidTo { get; set; } - - ///// - ///// ProductionCountry - ///// - //[ImporterHeader(Name = "Production Country")] - //public string ProductionCountry { get; set; } - - /// - /// 客户编码 - /// - [ImporterHeader(Name = "Plant")] - public string Plant { get; set; } - - ///// - ///// Transport Term - ///// - //[ImporterHeader(Name = "Transport Term")] - //public string TransportTerm { get; set; } - - ///// - ///// Transport Term City - ///// - //[ImporterHeader(Name = "Transport Term City")] - //public string TransportTermCity { get; set; } - - ///// - ///// Transport Term Country - ///// - //[ImporterHeader(Name = "Transport Term Country")] - //public string TransportTermCountry { get; set; } - - ///// - ///// Shipping Location - ///// - //[ImporterHeader(Name = "Shipping Location")] - //public string ShippingLocation { get; set; } - - ///// - ///// Production Location - ///// - //[ImporterHeader(Name = "Production Location")] - //public string ProductionLocation { get; set; } - - ///// - ///// VAT Shipping Country - ///// - //[ImporterHeader(Name = "VAT Shipping Country")] - //public string VATShippingCountry { get; set; } - - ///// - ///// Minimum Order Quantity - ///// - //[ImporterHeader(Name = "Minimum Order Quantity")] - //public string MinimumOrderQuantity { get; set; } - - ///// - ///// Payment - ///// - //[ImporterHeader(Name = "Payment")] - //public string Payment { get; set; } - - ///// - ///// Packaging - ///// - //[ImporterHeader(Name = "Packaging")] - //public string Packaging { get; set; } - - ///// - ///// Return - ///// - //[ImporterHeader(Name = "Return")] - //public string Return { get; set; } - - ///// - ///// 3YP - ///// - //[ImporterHeader(Name = "3YP")] - //public string YP3 { get; set; } - } - public class PriceListRequestDto : PagedAndSortedResultRequestDto - { - [Display(Name = "开始时间")] - public DateTime BeginDate { get; set; } - [Display(Name = "结算时间")] - public DateTime EndDate { get; set; } - [Display(Name = "价格")] - public decimal Price { get; set; } - [Display(Name = "物料编号")] - public string MaterialCode { get; set; } - [Display(Name = "价格类型")] - public int Type { get; set; } - - public Guid ParentId { set; get; } - - public int FileType { set; get; } - - public string Version { set; get; } - - public virtual List Filters { get; set; } = new List(); - } - - #region 备件价格 - public class PriceListBJDto : EntityDto - { - /// - /// 零件号 - /// - [Display(Name = "零件号")] - public string LU { get; set; } - - /// - /// 价格 - /// - [Display(Name = "价格")] - public Decimal Price { set; get; } - - /// - /// 客户编码 - /// - [Display(Name = "客户编码")] - public string ClientCode { get; set; } - - } - - [Display(Name = "备件价格")] - public class PriceListBJExportDto - { - /// - /// 零件号 - /// - [ExporterHeader(DisplayName = "零件号")] - public string LU { get; set; } - - /// - /// 价格 - /// - [ExporterHeader(DisplayName = "价格")] - public decimal Price { get; set; } - - /// - ///客户编码 - /// - [ExporterHeader(DisplayName = "客户编码")] - public string ClientCode { get; set; } - - /// - /// 合同签订时间 - /// - [Display(Name = "合同签订时间")] - [ExporterHeader(DisplayName = "合同签订时间")] - public DateTime Date { get; set; } - - /// - /// 合同号 - /// - [Display(Name = "合同号")] - [ExporterHeader(DisplayName = "合同号")] - public string ContractNo { get; set; } - } - - [Importer(HeaderRowIndex = 22)] - public class PriceListBJImportDto - { - /// - /// 零件号 - /// - [ImporterHeader(Name = "零件号")] - public string LU { get; set; } - - /// - /// 价格 - /// - [ImporterHeader(Name = "价格")] - public decimal Price { get; set; } - - /// - ///客户编码 - /// - [ImporterHeader(Name = "客户编码")] - public string ClientCode { get; set; } - - /// - /// 合同签订时间 - /// - [ImporterHeader(IsIgnore = true)] - [ExcelImporterHeadDesc(Row = 1, Cell = 1)] - public string Date { get; set; } - - /// - /// 合同号 - /// - [ImporterHeader(IsIgnore = true)] - [ExcelImporterHeadDesc(Row = 2, Cell = 1)] - public string ContractNo { get; set; } - } - - public class PriceListBJRequestDto : RequestInputBase - { - [Display(Name = "开始时间")] - public DateTime BeginDate { get; set; } - [Display(Name = "结算时间")] - public DateTime EndDate { get; set; } - [Display(Name = "价格")] - public decimal Price { get; set; } - [Display(Name = "物料编号")] - public string MaterialCode { get; set; } - [Display(Name = "价格类型")] - public int Type { get; set; } - - public Guid ParentId { set; get; } - - public int FileType { set; get; } - - public string Version { set; get; } - - public virtual List Filters { get; set; } = new List(); - } - #endregion - - /// - /// 列表 - /// - public class TB_PRICE_LISTDto : AuditedEntityDto - { - /// - /// 零件号 - /// - [Display(Name = "零件号")] - public string LU { get; set; } - - /// - /// 价格 - /// - [Display(Name = "价格")] - public Decimal Price { set; get; } - - /// - /// 开始时间 - /// - [Display(Name = "开始时间")] - public DateTime BeginTime { set; get; } - - /// - /// 结束时间 - /// - [Display(Name = "结束时间")] - public DateTime EndTime { set; get; } - - /// - /// 客户编码 - /// - [Display(Name = "客户编码")] - public string ClientCode { get; set; } - - /// - /// 业务类别 - /// - [Display(Name = "业务类别")] - public EnumBusinessType BusinessType { get; set; } - - /// - /// 版本 - /// - [Display(Name = "版本")] - public string Version { set; get; } - } - - /// - /// 列表请求 - /// - public class TB_PRICE_LIST_RequestDto : PagedAndSortedResultRequestDto - { - /// - /// 零件号 - /// - [Display(Name = "零件号")] - public string LU { get; set; } - - /// - /// 价格 - /// - [Display(Name = "价格")] - public Decimal Price { set; get; } - - /// - /// 开始时间 - /// - [Display(Name = "开始时间")] - public DateTime BeginTime { set; get; } - - /// - /// 结束时间 - /// - [Display(Name = "结束时间")] - public DateTime EndTime { set; get; } - - /// - /// 客户编码 - /// - [Display(Name = "客户编码")] - public string ClientCode { get; set; } - - /// - /// 业务类别 - /// - [Display(Name = "业务类别")] - public EnumBusinessType BusinessType { get; set; } - - /// - /// 版本 - /// - [Display(Name = "版本")] - public string Version { set; get; } - - /// - /// 高级检索 - /// - [Display(Name = "高级检索")] - public virtual List Filters { get; set; } = new List(); - - /// - /// 导出文件类型 - /// - public int FileType { set; get; } - } + /// + /// 客户零件号 + /// + [Display(Name = "客户零件号")] + public string LU { get; set; } + + /// + /// 价格 + /// + [Display(Name = "价格")] + public decimal Price { get; set; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + public DateTime BeginDate { set; get; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + public DateTime EndDate { set; get; } + /// + /// 客户编码 + /// + [Display(Name = "客户编码")] + public string ClientCode { get; set; } + + /// + /// 合同签订时间 + /// + [Display(Name = "合同签订时间")] + public DateTime Date { get; set; } + + /// + /// 合同号 + /// + [Display(Name = "合同号")] + public string ContractNo { get; set; } +} + +/// +/// 备件价格导出 +/// +[Display(Name = "备件价格")] +public class PriceListBJExportDto +{ + /// + /// 客户零件号 + /// + [Display(Name = "客户零件号")] + [ExporterHeader(DisplayName = "客户零件号")] + public string LU { get; set; } + + /// + /// 价格 + /// + [Display(Name = "价格")] + [ExporterHeader(DisplayName = "价格")] + public decimal Price { get; set; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + [ExporterHeader(DisplayName = "开始时间")] + public DateTime BeginDate { set; get; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + [ExporterHeader(DisplayName = "结束时间")] + public DateTime EndDate { set; get; } + + /// + /// 客户编码 + /// + [Display(Name = "客户编码")] + [ExporterHeader(DisplayName = "客户编码")] + public string ClientCode { get; set; } + + /// + /// 合同签订时间 + /// + [Display(Name = "合同签订时间")] + [ExporterHeader(DisplayName = "合同签订时间")] + public DateTime Date { get; set; } + + /// + /// 合同号 + /// + [Display(Name = "合同号")] + [ExporterHeader(DisplayName = "合同号")] + public string ContractNo { get; set; } +} + +/// +/// 客户备件价格导入 +/// +[Importer(HeaderRowIndex = 22)] +public class PriceListBJImportDto +{ + /// + /// 客户零件号 + /// + [Display(Name = "客户零件号")] + [ImporterHeader(Name = "Part No.")] + public string LU { get; set; } + + /// + /// 价格 + /// + [Display(Name = "客户零件号")] + [ImporterHeader(Name = "Total Price")] + public decimal Price { get; set; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + [ImporterHeader(Name = "Valid From")] + public DateTime BeginDate { set; get; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + [ImporterHeader(Name = "Valid To")] + public DateTime EndDate { set; get; } + + /// + /// 客户编码 + /// + [Display(Name = "客户零件号")] + [ImporterHeader(Name = "Plant")] + public string ClientCode { get; set; } + + /// + /// 合同签订时间 + /// + [Display(Name = "客户零件号")] + [ImporterHeader(IsIgnore = true)] + [ExcelImporterHeadDesc(Row = 1, Cell = 1)] + public string Date { get; set; } + + /// + /// 合同号 + /// + [Display(Name = "客户零件号")] + [ImporterHeader(IsIgnore = true)] + [ExcelImporterHeadDesc(Row = 2, Cell = 1)] + public string ContractNo { get; set; } +} + +public class PriceListBJRequestDto : RequestInputBase +{ + [Display(Name = "开始时间")] + public DateTime BeginDate { get; set; } + [Display(Name = "结算时间")] + public DateTime EndDate { get; set; } + [Display(Name = "价格")] + public decimal Price { get; set; } + [Display(Name = "物料编号")] + public string MaterialCode { get; set; } + [Display(Name = "价格类型")] + public int Type { get; set; } + + public Guid ParentId { set; get; } + + public int FileType { set; get; } + + public string Version { set; get; } + + public virtual List Filters { get; set; } = new List(); +} +#endregion + +/// +/// 列表 +/// +public class TB_PRICE_LISTDto : AuditedEntityDto +{ + /// + /// 零件号 + /// + [Display(Name = "零件号")] + public string LU { get; set; } + + /// + /// 价格 + /// + [Display(Name = "价格")] + public Decimal Price { set; get; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + public DateTime BeginTime { set; get; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + public DateTime EndTime { set; get; } + + /// + /// 客户编码 + /// + [Display(Name = "客户编码")] + public string ClientCode { get; set; } + + /// + /// 业务类别 + /// + [Display(Name = "业务类别")] + public EnumBusinessType BusinessType { get; set; } + + /// + /// 版本 + /// + [Display(Name = "版本")] + public string Version { set; get; } +} + +/// +/// 列表请求 +/// +public class TB_PRICE_LIST_RequestDto : PagedAndSortedResultRequestDto +{ + /// + /// 零件号 + /// + [Display(Name = "零件号")] + public string LU { get; set; } + + /// + /// 价格 + /// + [Display(Name = "价格")] + public Decimal Price { set; get; } + + /// + /// 开始时间 + /// + [Display(Name = "开始时间")] + public DateTime BeginTime { set; get; } + + /// + /// 结束时间 + /// + [Display(Name = "结束时间")] + public DateTime EndTime { set; get; } + + /// + /// 客户编码 + /// + [Display(Name = "客户编码")] + public string ClientCode { get; set; } + + /// + /// 业务类别 + /// + [Display(Name = "业务类别")] + public EnumBusinessType BusinessType { get; set; } + + /// + /// 版本 + /// + [Display(Name = "版本")] + public string Version { set; get; } + + /// + /// 高级检索 + /// + [Display(Name = "高级检索")] + public virtual List Filters { get; set; } = new List(); + + /// + /// 导出文件类型 + /// + public int FileType { set; get; } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs new file mode 100644 index 00000000..19c63ec0 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs @@ -0,0 +1,332 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using SettleAccount.Domain.BQ; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Repositories; +using Volo.Abp; +using Win.Sfs.SettleAccount.Entities.BQ.Dtos; +using Volo.Abp.Caching; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Entities.Prices; +using Win.Sfs.SettleAccount.MaterialRelationships; +using Win.Sfs.Shared.RepositoryBase; +using System; +using System.Linq; +using Microsoft.AspNetCore.Http; +using NUglify.Helpers; +using Win.Sfs.SettleAccount.Bases; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; + +namespace Win.Sfs.SettleAccount.Entities.BQ; + +/// +/// HBPO结算 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class HBPO_SA_SERVICE : SettleAccountApplicationBase +{ + /// + /// HBPO结算仓储 + /// + private readonly INormalEfCoreRepository _hbpoSaRepository; + + /// + /// HBPO结算明细仓储 + /// + private readonly INormalEfCoreRepository _hbpoSaDetailRepository; + + /// + /// HBPO可结算仓储 + /// + private readonly INormalEfCoreRepository _hbpoCanSaRepository; + + /// + /// HBPO可结算明细仓储 + /// + private readonly INormalEfCoreRepository _hbpoCanSaDetailRepository; + + /// + /// HBPO不可结算明细仓储 + /// + private readonly INormalEfCoreRepository _hbpoNotSaDetailRepository; + + /// + /// 销售价格仓储 + /// + private readonly INormalEfCoreRepository _priceListRepository; + + /// + /// 客户零件关系仓储 + /// + private readonly INormalEfCoreRepository _materialRelationshipRepository; + + /// + /// 替换件关系仓储 + /// + private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository; + + /// + /// 构造 + /// + public HBPO_SA_SERVICE(INormalEfCoreRepository hbpoSaRepository, + INormalEfCoreRepository hbpoSaDetailRepository, + INormalEfCoreRepository hbpoCanSaRepository, + INormalEfCoreRepository hbpoCanSaDetailRepository, + INormalEfCoreRepository hbpoNotSaDetailRepository, + INormalEfCoreRepository priceListRepository, + INormalEfCoreRepository materialRelationshipRepository, + INormalEfCoreRepository tbRePartsRelationshipRepository, + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) + { + _hbpoSaRepository = hbpoSaRepository; + _hbpoSaDetailRepository = hbpoSaDetailRepository; + _hbpoCanSaRepository = hbpoCanSaRepository; + _hbpoCanSaDetailRepository = hbpoCanSaDetailRepository; + _hbpoNotSaDetailRepository = hbpoNotSaDetailRepository; + _priceListRepository = priceListRepository; + _materialRelationshipRepository = materialRelationshipRepository; + _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; + } + + #region 导入、导出 + /// + /// 导入 + /// + [HttpPost] + public async Task ImportAsync([FromForm] IFormFileCollection files) + { + //业务类型 + var businessType = EnumBusinessType.HBPO; + //数据校验 + var checkList = new List(); + //结算单号 + var hbpoSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); + //结算主表 + var hbpoSa = new HBPO_SA() + { + BillNum = hbpoSaBillNum, + State = "1", + BusinessType = businessType + }; + //结算明细 + var hbpoSaDetails = new List(); + //可结算单号 + var hbpoCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C"); + //可结算主表 + var hbpoCanSa = new HBPO_CAN_SA() + { + BillNum = hbpoCanSaBillNum, + SettleBillNum = hbpoSaBillNum, + State = SettleBillState.未结状态, + BusinessType = businessType + }; + //可结算明细 + var hbpoCanSaDetails = new List(); + //不可结算明细 + var hbpoNotSaDetails = new List(); + //客户零件关系 + var materialRelationships = new List(); + + #region 导入数据转换、数据校验 + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var importPubSaDetails = ObjectMapper.Map, List>(result); + + //结算分组号 + var hbpoSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct(); + + //已存在的结算分组号 + var havPubSaGroupNums = (await _hbpoSaDetailRepository.GetListAsync(t => hbpoSaGroupNums.Contains(t.GroupNum))).Select(t => t.GroupNum).Distinct(); + if (havPubSaGroupNums.Any() == true) + { + foreach (var item in havPubSaGroupNums) + { + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty)); + } + //throw new UserFriendlyException($"导入失败,结算分组号({string.Join(",", havPubSaGroupNums)})已存在", "400"); + } + + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); + } + #endregion + + + #region 处理结算数据 + //销售价格 + var priceListEntitys = await _priceListRepository.GetAllAsync(); + + importPubSaDetails.ForEach(importPubSaDetail => + { + List luList = importPubSaDetail.LU.Split(" ").ToList(); + importPubSaDetail.LU = luList[0].Replace(" ", ""); + if (luList.Count > 1) + { + luList.RemoveAt(0); + var luAssemble = luList.Select(t => t.Replace(" ", "")); + importPubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); + } + + importPubSaDetail.BillNum = hbpoSaBillNum; + //importPubSaDetail.Site = "XX工厂"; + importPubSaDetail.KeyCode = importPubSaDetail.PN + importPubSaDetail.LU; + + //根据物料号、结算日期获取价格 + var priceListEntity = priceListEntitys.Find(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate > t.BeginTime && importPubSaDetail.SettleDate < t.EndTime); + importPubSaDetail.Price = priceListEntity?.Price ?? 0; + importPubSaDetail.BusinessType = businessType; + }); + + //导入的零件号集合 + var importPubSaLUs = importPubSaDetails.Select(t => t.LU).Distinct(); + var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)); + var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); + + /* + * (不存在的客户零件号)差集 + * 转换为厂内零件号 + * 转换规则6个空格替换成“-” + */ + var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); + + noExistSettleMaterialCodes.ForEach(t => + { + var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType.ToString()); + materialRelationships.Add(materialRelationship); + }); + #endregion + + + #region 入库数据赋值 + //结算明细 + hbpoSaDetails = importPubSaDetails; + + //不可结算 结算分组号码(根据价格区分结算、不可结算) + var hbpoNotSaGroupNums = hbpoSaDetails.FindAll(t => t.Price == default(decimal)).Select(t => t.GroupNum).Distinct(); + var hbpoSaDetailsCanSes = hbpoSaDetails.FindAll(t => hbpoNotSaGroupNums.Contains(t.GroupNum) == false); + var hbpoSaDetailsNotCanSes = hbpoSaDetails.FindAll(t => hbpoNotSaGroupNums.Contains(t.GroupNum) == true); + + //可结算明细 + hbpoCanSaDetails = ObjectMapper.Map, List>(hbpoSaDetailsCanSes); + //不可结算明细 + hbpoNotSaDetails = ObjectMapper.Map, List>(hbpoSaDetailsNotCanSes); + #endregion + + #region 添加入库 + await _hbpoSaRepository.InsertAsync(hbpoSa); + await _hbpoSaDetailRepository.InsertManyAsync(hbpoSaDetails); + if (hbpoCanSaDetails.Count > 0) + { + hbpoCanSa.InvGroupNum = hbpoCanSaDetails.Count.ToString(); + hbpoCanSaDetails.ForEach(hbpoCanSaDetail => + { + hbpoCanSaDetail.BillNum = hbpoCanSaDetail.InvGroupNum = hbpoCanSaBillNum; + hbpoCanSaDetail.BusinessType = businessType; + }); + + await _hbpoCanSaRepository.InsertAsync(hbpoCanSa); + await _hbpoCanSaDetailRepository.InsertManyAsync(hbpoCanSaDetails); + } + if (hbpoNotSaDetails.Count > 0) + { + hbpoNotSaDetails.ForEach(hbpoNotSaDetail => + { + hbpoNotSaDetail.InvGroupNum = hbpoCanSaBillNum; + hbpoNotSaDetail.BusinessType = businessType; + }); + + await _hbpoNotSaDetailRepository.InsertManyAsync(hbpoNotSaDetails); + } + if (materialRelationships.Count > 0) + { + await _materialRelationshipRepository.InsertManyAsync(materialRelationships); + } + #endregion + + return ApplicationConsts.SuccessStr; + } + #endregion + + #region CURD + /// + /// 获取列表 + /// + [HttpPost] + public async Task> GetListAsync(RequestDto input) + { + var entities = await _hbpoSaRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); + var totalCount = await _hbpoSaRepository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entities); + return new PagedResultDto(totalCount, dtos); + } + + /// + /// 删除 + /// + [HttpPost] + public async Task DeleteAsync(Guid id) + { + //结算主表 + HBPO_SA hbpoSaDelEntity; + //结算明细 + List hbpoSaDetailDelEntitys; + //可结算主表 + List hbpoCanSaDelEntitys; + //可结算明细 + List hbpoCanSaDetailDelEntitys; + //不可结算 + List hbpoNotSaDetailDelEntitys; + + hbpoSaDelEntity = await _hbpoSaRepository.FindAsync(id); + if (hbpoSaDelEntity == null) + { + throw new UserFriendlyException($"未获取到结算单!", "400"); + } + //结算单据 + string hbpoSaBillNum = hbpoSaDelEntity.BillNum; + + hbpoCanSaDelEntitys = await _hbpoCanSaRepository.GetListAsync(t => t.SettleBillNum == hbpoSaBillNum); + //验证可结算主表状态 + if (hbpoCanSaDelEntitys.Any(t => t.State != SettleBillState.未结状态)) + { + throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400"); + } + + hbpoSaDetailDelEntitys = await _hbpoSaDetailRepository.GetListAsync(t => t.BillNum == hbpoSaBillNum); + hbpoCanSaDetailDelEntitys = await _hbpoCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == hbpoSaBillNum); + hbpoNotSaDetailDelEntitys = await _hbpoNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == hbpoSaBillNum); + + //删除 + await _hbpoSaRepository.DeleteAsync(hbpoSaDelEntity); + if (hbpoSaDetailDelEntitys != null) + { + await _hbpoSaDetailRepository.DeleteManyAsync(hbpoSaDetailDelEntitys); + } + if (hbpoCanSaDelEntitys != null) + { + await _hbpoCanSaRepository.DeleteManyAsync(hbpoCanSaDelEntitys); + } + if (hbpoCanSaDetailDelEntitys != null) + { + await _hbpoCanSaDetailRepository.DeleteManyAsync(hbpoCanSaDetailDelEntitys); + } + if (hbpoNotSaDetailDelEntitys != null) + { + await _hbpoNotSaDetailRepository.DeleteManyAsync(hbpoNotSaDetailDelEntitys); + } + + } + #endregion +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs index 329a6a43..2348a687 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs @@ -1,20 +1,17 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi.Extensions; using SettleAccount.Domain.BQ; -using SettleAccount.Job.Services; using SettleAccount.Job.Services.Report; using Shouldly; using TaskJob.EventArgs; using Volo.Abp; using Volo.Abp.Caching; -using Volo.Abp.Users; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.CommonManagers; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs index 3475a476..952364aa 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs @@ -6,10 +6,8 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.OpenApi.Extensions; using NUglify.Helpers; using SettleAccount.Domain.BQ; -using Shouldly; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; @@ -23,7 +21,6 @@ using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.MaterialRelationships; -using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs index 54de45dd..279f5878 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs @@ -1,12 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using SettleAccount.Domain.BQ; using Shouldly; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; using Win.Abp.Snowflakes; @@ -18,109 +18,107 @@ using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; -namespace Win.Sfs.SettleAccount.Entities.BQ +namespace Win.Sfs.SettleAccount.Entities.BQ; + +/// +/// 采购价格单 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class PURCHASE_PRICE_SERVICE : SettleAccountApplicationBase { /// - /// 采购价格单 + /// 采购价格单仓储 /// - [AllowAnonymous] - [Route("api/settleaccount/[controller]/[action]")] - public class PURCHASE_PRICE_SERVICE : SettleAccountApplicationBase + private readonly INormalEfCoreRepository _repository; + + public PURCHASE_PRICE_SERVICE( + INormalEfCoreRepository repository, + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) { - /// - /// 采购价格单仓储 - /// - private readonly INormalEfCoreRepository _repository; + _repository = repository; + } - public PURCHASE_PRICE_SERVICE( - INormalEfCoreRepository repository, - IDistributedCache cache, - IExcelImportAppService excelImportService, - ISnowflakeIdGenerator snowflakeIdGenerator, - ICommonManager commonManager - ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) - { - _repository = repository; - } + #region 导入、导出 + /// + /// 导入 + /// + [HttpPost] + public async Task ImportAsync([FromForm] IFormFileCollection files) + { + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var _ls = ObjectMapper.Map, List>(result); + List _errorList = new List(); + var checkList = new List(); - #region 导入、导出 - /// - /// 导入 - /// - [HttpPost] - public async Task ImportAsync([FromForm] IFormFileCollection files) + if (_ls.Count > 0) { - ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.UploadExcelImport(files, _excelImportService); - var _ls = ObjectMapper.Map, List>(result); - List _errorList = new List(); - var checkList = new List(); - - if (_ls.Count > 0) + var query = from arc in _ls + group arc by new { arc.LU } + into g + where g.Count() > 1 + select g; + foreach (var itm in query) { - var query = from arc in _ls - group arc by new { arc.LU } - into g - where g.Count() > 1 - - select g; - foreach (var itm in query) - { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("物料号{0}有重复", itm.Key.LU), string.Empty)); - } + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("零件号{0}有重复", itm.Key.LU), string.Empty)); } - foreach (var itm in _ls) + } + foreach (var itm in _ls) + { + var _first = _repository.FirstOrDefault(p => p.LU == itm.LU); + if (_first != null) { - var _first = _repository.FirstOrDefault(p => p.LU == itm.LU); - if (_first != null) - { - _first.Update(itm.Price); - await _repository.UpdateAsync(_first); - } - else - { - await _repository.InsertAsync(itm); - } + _first.Update(itm.Price); + await _repository.UpdateAsync(_first); } - if (checkList.Count > 0) + else { - return await ExportErrorReportAsync(checkList); + await _repository.InsertAsync(itm); } - return ApplicationConsts.SuccessStr; } - - /// - /// 导出 - /// - [HttpPost] - public async Task ExportAsync(RequestDto input) + if (checkList.Count > 0) { - string fileName = $"采购价格单_{Guid.NewGuid()}.xlsx"; - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); - var dtos = ObjectMapper.Map, List>(entities); + return await ExportErrorReportAsync(checkList); + } + return ApplicationConsts.SuccessStr; + } - ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.ExcelExporter(dtos); - result.ShouldNotBeNull(); + /// + /// 导出 + /// + [HttpPost] + public async Task ExportAsync(RequestDto input) + { + string fileName = $"采购价格单_{Guid.NewGuid()}.xlsx"; + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); + var dtos = ObjectMapper.Map, List>(entities); - await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); - return fileName; - } - #endregion + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.ExcelExporter(dtos); + result.ShouldNotBeNull(); - #region CURD - /// - /// 获取列表 - /// - [HttpPost] - public async Task> GetListAsync(RequestDto input) - { - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); - var totalCount = await _repository.GetCountByFilterAsync(input.Filters); - var dtos = ObjectMapper.Map, List>(entities); - return new PagedResultDto(totalCount, dtos); - } - #endregion + await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); + return fileName; + } + #endregion + #region CURD + /// + /// 获取列表 + /// + [HttpPost] + public async Task> GetListAsync(RequestDto input) + { + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); + var totalCount = await _repository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entities); + return new PagedResultDto(totalCount, dtos); } + #endregion + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs index 06590766..cbb30494 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using SettleAccount.Domain.BQ; @@ -66,9 +66,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ select g; foreach (var itm in query) { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("物料号{0}有重复", itm.Key.LU), string.Empty)); + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("客户物料号{0}有重复", itm.Key.LU), string.Empty)); } } + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); + } foreach (var itm in _ls) { var _first = _repository.FirstOrDefault(p => p.LU == itm.LU); @@ -82,10 +86,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ await _repository.InsertAsync(itm); } } - if (checkList.Count > 0) - { - return await ExportErrorReportAsync(checkList); - } return ApplicationConsts.SuccessStr; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs index 08fe2b08..6e877370 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs @@ -1,11 +1,11 @@ -using EFCore.BulkExtensions; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Shouldly; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Shouldly; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; @@ -15,424 +15,419 @@ using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.Shared.RepositoryBase; -namespace Win.Sfs.SettleAccount.Entities.Controls +namespace Win.Sfs.SettleAccount.Entities.Controls; + +/// +/// 期间设置 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class CentralizedControlAppService : SettleAccountApplicationBase { /// - /// 期间设置 + /// 期间设置仓储 + /// + private readonly INormalEfCoreRepository _repository; + + /// + /// 构造 /// - [AllowAnonymous] - [Route("api/settleaccount/[controller]/[action]")] - public class CentralizedControlAppService : SettleAccountApplicationBase + public CentralizedControlAppService( + INormalEfCoreRepository repository, + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) { - /// - /// 期间设置仓储 - /// - private readonly INormalEfCoreRepository _repository; - - /// - /// 构造 - /// - public CentralizedControlAppService( - INormalEfCoreRepository repository, - IDistributedCache cache, - IExcelImportAppService excelImportService, - ISnowflakeIdGenerator snowflakeIdGenerator, - ICommonManager commonManager - ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) - { - _repository = repository; - } + _repository = repository; + } - #region 导出 - /// - /// 导出 - /// - [HttpPost] - public async Task ExportAsync(CentralizedControlRequestDto input) - { - string fileName = $"期间设置_{Guid.NewGuid()}.xlsx"; - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); - var dtos = ObjectMapper.Map, List>(entities); + #region 导出 + /// + /// 导出 + /// + [HttpPost] + public async Task ExportAsync(CentralizedControlRequestDto input) + { + string fileName = $"期间设置_{Guid.NewGuid()}.xlsx"; + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); + var dtos = ObjectMapper.Map, List>(entities); - ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.ExcelExporter(dtos); - result.ShouldNotBeNull(); + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.ExcelExporter(dtos); + result.ShouldNotBeNull(); - await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); - return fileName; - } - #endregion - - #region CURD - /// - /// 获取全部 - /// - [HttpPost] - public async Task> GetAllAsync() - { - var entities = await _repository.GetAllAsync(true); - var dtos = ObjectMapper.Map, List>(entities); - return new ListResultDto(dtos); - } + await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); + return fileName; + } + #endregion - /// - /// 获取列表 - /// - [HttpPost] - public async Task> GetListAsync(CentralizedControlRequestDto input) - { - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); - var totalCount = await _repository.GetCountByFilterAsync(input.Filters); - var dtos = ObjectMapper.Map, List>(entities); - return new PagedResultDto(totalCount, dtos); - } + #region CURD + /// + /// 获取全部 + /// + [HttpPost] + public async Task> GetAllAsync() + { + var entities = await _repository.GetAllAsync(true); + var dtos = ObjectMapper.Map, List>(entities); + return new ListResultDto(dtos); + } + + /// + /// 获取列表 + /// + [HttpPost] + public async Task> GetListAsync(CentralizedControlRequestDto input) + { + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); + var totalCount = await _repository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entities); + return new PagedResultDto(totalCount, dtos); + } + + /// + /// 添加 + /// + [HttpPost] + public async Task CreateAsync(CentralizedControlCreateDto input) + { + var _first = _repository.Where(p => p.Version == input.Version).FirstOrDefault(); - /// - /// 添加 - /// - [HttpPost] - public async Task CreateAsync(CentralizedControlCreateDto input) + if (_first != null) { - var _first = _repository.Where(p => p.Version == input.Version).FirstOrDefault(); + throw new BusinessException("001", "已经存在该期间,不能重复添加!"); + } - if (_first != null) - { - throw new BusinessException("001", "已经存在该期间,不能重复添加!"); - } + var entity = new CentralizedControl( + GuidGenerator.Create(), + input.BranchId, + input.Year, + input.Period, + input.Year + input.Period, + input.State + ); - var entity = new CentralizedControl( - GuidGenerator.Create(), - input.BranchId, - input.Year, - input.Period, - input.Year + input.Period, - input.State - ); + await _repository.InsertAsync(entity); - await _repository.InsertAsync(entity); + var dto = ObjectMapper.Map(entity); + return dto; - var dto = ObjectMapper.Map(entity); - return dto; + } - } + /// + /// 删除实体 + /// + /// ID + /// + [HttpDelete] + public async Task DeleteAsync(Guid id) + { + var entity = await _repository.GetAsync(id); + await _repository.DeleteAsync(id); + } - /// - /// 删除实体 - /// - /// ID - /// - [HttpDelete] - public async Task DeleteAsync(Guid id) - { - var entity = await _repository.GetAsync(id); - await _repository.DeleteAsync(id); - } + /// + /// 按IDs删除实体列表 + /// + [HttpPost] + public async Task DeleteListAsync(List ids) + { + var _query = _repository.Where(p => ids.Contains(p.Id)); + int i = await _query.BatchDeleteAsync(); - /// - /// 按IDs删除实体列表 - /// - [HttpPost] - public async Task DeleteListAsync(List ids) - { - var _query = _repository.Where(p => ids.Contains(p.Id)); - int i = await _query.BatchDeleteAsync(); + return i == 0; + } + #endregion - return i == 0; - } - #endregion - - #region 开启、关闭 - /// - /// 开启版本 - /// - [HttpPost] - public async Task OpenVersion(List ids) + #region 开启、关闭 + /// + /// 开启版本 + /// + [HttpPost] + public async Task OpenVersion(List ids) + { + var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); + foreach (var entity in entitys) { - var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); - foreach (var entity in entitys) - { - entity.OpenVersion(); - } - return true; + entity.OpenVersion(); } + return true; + } - /// - /// 关闭版本 - /// - [HttpPost] - public async Task ClosedVersion(List ids) + /// + /// 关闭版本 + /// + [HttpPost] + public async Task ClosedVersion(List ids) + { + var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); + foreach (var entity in entitys) { - var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); - foreach (var entity in entitys) - { - entity.ClosedVersion(); - } - return true; + entity.ClosedVersion(); } - #endregion - - #region 原方法(废弃) - // /// - // /// 导入功能 - // /// - // /// 上传的文件(前端已经限制只能上传一个附件) - // /// - // [HttpPost] - // [Route("ExcelImport")] - // [DisableRequestSizeLimit] - // [Authorize(SettleAccountPermissions.CentralizedControls.Create)] - // public async Task CentralizedControlUploadExcelImport([FromForm] IFormFileCollection files,Guid branchId) - // { - // ExportImporter _exportImporter = new ExportImporter(); - // var result = await _exportImporter.UploadExcelImport(files, _excelImportService); - // var _ls = ObjectMapper.Map, List>(result); - // foreach (var itm in _ls) - // { - // itm.SetValue(GuidGenerator.Create(), branchId); - // } - // var bulkConfig = new BulkConfig { SetOutputIdentity = true, BatchSize = 10000 }; - // _repository.GetDbContext().BulkInsert(_ls, bulkConfig); - // return ApplicationConsts.SuccessStr; - // } - - - - // /// - // /// 按ID获取唯一实体 - // /// - // /// - // /// 返回实体全部属性 - // /// - // /// ID - // /// 实体DTO - // [HttpGet] - // [Route("{id}")] - // virtual public async Task GetAsync(Guid id) - // { - // var result = await GetFromCacheAsync(id); - // var dto = ObjectMapper.Map(result); - // return dto; - // } - - - // private async Task GetFromCacheAsync(Guid id) - // { - // var result = - // await _repository.GetAsync(id); - - - // return result; - // } - - - // private async Task GetCountAsync(CentralizedControlRequestDto input) - // { - // return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); - // } - - - - - // ///// - - // /// - // /// 根据筛选条件获取实体列表 - // /// - // /// - // /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码 - // /// - // /// 请求条件 - // /// 实体DTO列表 - // [HttpPost] - // [Route("list")] - // virtual public async Task> GetListAsync(CentralizedControlRequestDto input) - // { - // var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, - // input.SkipCount, true); - - // var totalCount = await GetCountAsync(input); - // var dtos = ObjectMapper.Map, List>(entities); - - // return new PagedResultDto(totalCount, dtos); - // } - - - // /// - // /// 获取实体总数 - // /// - // /// 实体总数 - // [HttpGet] - // [Route("count")] - // virtual public async Task GetTotalCountAsync(Guid branchId) - // { - // return await _repository.GetCountAsync(branchId); - // } - - // /// - // /// 获取全部实体列表 - // /// - // /// 实体DTO列表 - // [HttpGet] - // [Route("all")] - // virtual public async Task> GetAllAsync(Guid branchId) - // { - // var entities = await _repository.GetAllAsync(branchId, true); - - - // var dtos = ObjectMapper.Map, List>(entities); - - - // return new ListResultDto(dtos); - // } - - - - - // /// - // /// 新增实体 - // /// - // /// 新增实体DTO - // /// 实体DTO - - // [HttpPost] - // [Route("")] - //[Authorize(SettleAccountPermissions.CentralizedControls.Create)] - // virtual public async Task CreateAsync(CentralizedControlCreateDto input) - // { - // var _first= _repository.Where(p => p.Version == input.Version).FirstOrDefault(); - - // if (_first != null) - // { - // throw new BusinessException("001", "已经存在该期间,不能重复添加!"); - // } - - // var entity = new CentralizedControl( - // GuidGenerator.Create(), - // input.BranchId, - // input.Year, - // input.Period, - // input.Year+input.Period, - // input.State - - - // ); - - // await _repository.InsertAsync(entity); - - // //create cache - // //await Cache.SetAsync(entity.Id.ToString(), entity,CacheStrategyConst.FIVE_MINUTES); - - // var dto = ObjectMapper.Map(entity); - // return dto; - - // } - - // /// - // /// 修改实体 - // /// - // /// ID - // /// 修改实体DTO - // /// 实体DTO - // [HttpPut] - // [Route("{id}")] - //[Authorize(SettleAccountPermissions.CentralizedControls.Update)] - // virtual public async Task UpdateAsync(Guid id, CentralizedControlUpdateDto input) - // { - // var entity = await _repository.GetAsync(id); - // entity.Update(input.Remark); - // await _repository.UpdateAsync(entity); - // //update cache - // //await Cache.SetAsync(id.ToString(), entity, CacheStrategyConst.FIVE_MINUTES); - // var dto = ObjectMapper.Map(entity); - // return dto; - - - - // } - - // /// - // /// 删除实体 - // /// - // /// ID - // /// - // [HttpDelete] - // [Route("{id}")] - //[Authorize(SettleAccountPermissions.CentralizedControls.Delete)] - // virtual public async Task DeleteAsync(Guid id) - // { - // var entity = await GetFromCacheAsync(id); - // await Cache.DeleteAsync(id.ToString()); - // await _repository.DeleteAsync(id); - // } - - // /// - // /// 按IDs删除实体列表 - // /// - // /// IDs - // /// 是否执行成功 - // [HttpPost] - // [Route("delete")] - //[Authorize(SettleAccountPermissions.CentralizedControls.Delete)] - // virtual public async Task DeleteListAsync(List ids) - // { - // var _query = _repository.Where(p => ids.Contains(p.Id)); - // int i = await _query.BatchDeleteAsync(); - - // if (i == 0) - // { - // return false; - // } - // return true; - // } - // [HttpPost] - // [Route("open")] - // [Authorize(SettleAccountPermissions.CentralizedControls.Create)] - // public async Task OpenVersion(List ids) - // { - // foreach (var id in ids) - // { - // var _entity = await _repository.GetAsync(id); - // _entity.OpenVersion(); - - // } - // return true; - // } - // [HttpPost] - // [Route("close")] - // [Authorize(SettleAccountPermissions.CentralizedControls.Create)] - // /// - // /// 关闭版本 - // /// - // /// 选择要关闭的ID - // /// - // public async Task ClosedVersion(List ids) - // { - // foreach (var id in ids) - // { - // var _entity = await _repository.GetAsync(id); - // _entity.ClosedVersion(); - // } - // return true; - // } - // [HttpPost] - // [Route("openlist")] - // /// - // /// 获得开放的版本列表 - // /// - // /// - // public async Task> GetOpenVersionList() - // { - // var _list = await _repository.Where(p => p.State == 0).ToListAsync(); - - // var dtos = ObjectMapper.Map, List>(_list); - - // return dtos; - // } - #endregion - - + return true; } - - + #endregion + + #region 原方法(废弃) + // /// + // /// 导入功能 + // /// + // /// 上传的文件(前端已经限制只能上传一个附件) + // /// + // [HttpPost] + // [Route("ExcelImport")] + // [DisableRequestSizeLimit] + // [Authorize(SettleAccountPermissions.CentralizedControls.Create)] + // public async Task CentralizedControlUploadExcelImport([FromForm] IFormFileCollection files,Guid branchId) + // { + // ExportImporter _exportImporter = new ExportImporter(); + // var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + // var _ls = ObjectMapper.Map, List>(result); + // foreach (var itm in _ls) + // { + // itm.SetValue(GuidGenerator.Create(), branchId); + // } + // var bulkConfig = new BulkConfig { SetOutputIdentity = true, BatchSize = 10000 }; + // _repository.GetDbContext().BulkInsert(_ls, bulkConfig); + // return ApplicationConsts.SuccessStr; + // } + + + + // /// + // /// 按ID获取唯一实体 + // /// + // /// + // /// 返回实体全部属性 + // /// + // /// ID + // /// 实体DTO + // [HttpGet] + // [Route("{id}")] + // virtual public async Task GetAsync(Guid id) + // { + // var result = await GetFromCacheAsync(id); + // var dto = ObjectMapper.Map(result); + // return dto; + // } + + + // private async Task GetFromCacheAsync(Guid id) + // { + // var result = + // await _repository.GetAsync(id); + + + // return result; + // } + + + // private async Task GetCountAsync(CentralizedControlRequestDto input) + // { + // return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); + // } + + + + + // ///// + + // /// + // /// 根据筛选条件获取实体列表 + // /// + // /// + // /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码 + // /// + // /// 请求条件 + // /// 实体DTO列表 + // [HttpPost] + // [Route("list")] + // virtual public async Task> GetListAsync(CentralizedControlRequestDto input) + // { + // var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, + // input.SkipCount, true); + + // var totalCount = await GetCountAsync(input); + // var dtos = ObjectMapper.Map, List>(entities); + + // return new PagedResultDto(totalCount, dtos); + // } + + + // /// + // /// 获取实体总数 + // /// + // /// 实体总数 + // [HttpGet] + // [Route("count")] + // virtual public async Task GetTotalCountAsync(Guid branchId) + // { + // return await _repository.GetCountAsync(branchId); + // } + + // /// + // /// 获取全部实体列表 + // /// + // /// 实体DTO列表 + // [HttpGet] + // [Route("all")] + // virtual public async Task> GetAllAsync(Guid branchId) + // { + // var entities = await _repository.GetAllAsync(branchId, true); + + + // var dtos = ObjectMapper.Map, List>(entities); + + + // return new ListResultDto(dtos); + // } + + + + + // /// + // /// 新增实体 + // /// + // /// 新增实体DTO + // /// 实体DTO + + // [HttpPost] + // [Route("")] + //[Authorize(SettleAccountPermissions.CentralizedControls.Create)] + // virtual public async Task CreateAsync(CentralizedControlCreateDto input) + // { + // var _first= _repository.Where(p => p.Version == input.Version).FirstOrDefault(); + + // if (_first != null) + // { + // throw new BusinessException("001", "已经存在该期间,不能重复添加!"); + // } + + // var entity = new CentralizedControl( + // GuidGenerator.Create(), + // input.BranchId, + // input.Year, + // input.Period, + // input.Year+input.Period, + // input.State + + + // ); + + // await _repository.InsertAsync(entity); + + // //create cache + // //await Cache.SetAsync(entity.Id.ToString(), entity,CacheStrategyConst.FIVE_MINUTES); + + // var dto = ObjectMapper.Map(entity); + // return dto; + + // } + + // /// + // /// 修改实体 + // /// + // /// ID + // /// 修改实体DTO + // /// 实体DTO + // [HttpPut] + // [Route("{id}")] + //[Authorize(SettleAccountPermissions.CentralizedControls.Update)] + // virtual public async Task UpdateAsync(Guid id, CentralizedControlUpdateDto input) + // { + // var entity = await _repository.GetAsync(id); + // entity.Update(input.Remark); + // await _repository.UpdateAsync(entity); + // //update cache + // //await Cache.SetAsync(id.ToString(), entity, CacheStrategyConst.FIVE_MINUTES); + // var dto = ObjectMapper.Map(entity); + // return dto; + + + + // } + + // /// + // /// 删除实体 + // /// + // /// ID + // /// + // [HttpDelete] + // [Route("{id}")] + //[Authorize(SettleAccountPermissions.CentralizedControls.Delete)] + // virtual public async Task DeleteAsync(Guid id) + // { + // var entity = await GetFromCacheAsync(id); + // await Cache.DeleteAsync(id.ToString()); + // await _repository.DeleteAsync(id); + // } + + // /// + // /// 按IDs删除实体列表 + // /// + // /// IDs + // /// 是否执行成功 + // [HttpPost] + // [Route("delete")] + //[Authorize(SettleAccountPermissions.CentralizedControls.Delete)] + // virtual public async Task DeleteListAsync(List ids) + // { + // var _query = _repository.Where(p => ids.Contains(p.Id)); + // int i = await _query.BatchDeleteAsync(); + + // if (i == 0) + // { + // return false; + // } + // return true; + // } + // [HttpPost] + // [Route("open")] + // [Authorize(SettleAccountPermissions.CentralizedControls.Create)] + // public async Task OpenVersion(List ids) + // { + // foreach (var id in ids) + // { + // var _entity = await _repository.GetAsync(id); + // _entity.OpenVersion(); + + // } + // return true; + // } + // [HttpPost] + // [Route("close")] + // [Authorize(SettleAccountPermissions.CentralizedControls.Create)] + // /// + // /// 关闭版本 + // /// + // /// 选择要关闭的ID + // /// + // public async Task ClosedVersion(List ids) + // { + // foreach (var id in ids) + // { + // var _entity = await _repository.GetAsync(id); + // _entity.ClosedVersion(); + // } + // return true; + // } + // [HttpPost] + // [Route("openlist")] + // /// + // /// 获得开放的版本列表 + // /// + // /// + // public async Task> GetOpenVersionList() + // { + // var _list = await _repository.Where(p => p.State == 0).ToListAsync(); + + // var dtos = ObjectMapper.Map, List>(_list); + + // return dtos; + // } + #endregion } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs index c10f61ca..3d53fbed 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Shouldly; @@ -70,7 +70,7 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships select g; foreach (var itm in query) { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ERP物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty)); + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("厂内物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty)); } } if (checkList.Count > 0) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs index 7606c967..e32c83c9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs @@ -13,305 +13,317 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.ImportMap; using Win.Sfs.SettleAccount.Entities.TaskJobs; using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.Shared.RepositoryBase; -namespace Win.Sfs.SettleAccount.Entities.Prices +namespace Win.Sfs.SettleAccount.Entities.Prices; + +/// +/// 销售价格单 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class PriceListAppService : SettleAccountApplicationBase { /// - /// 销售价格单 + /// 销售价格仓储 /// - [AllowAnonymous] - [Route("api/settleaccount/[controller]/[action]")] - public class PriceListAppService : ApplicationService + private readonly INormalEfCoreRepository _priceListRepository; + + private readonly PriceListManager _priceListManager; + private readonly ISettleAccountBranchEfCoreRepository _mapRepository; + private readonly TaskJobService _service; + public PriceListAppService( + INormalEfCoreRepository priceListRepository, + ISettleAccountBranchEfCoreRepository mapRepository, + PriceListManager priceListManager, + TaskJobService service, + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) { - private readonly PriceListManager _priceListManager; - private readonly IExcelImportAppService _excelImportService; - private readonly ISettleAccountBranchEfCoreRepository _mapRepository; - private readonly TaskJobService _service; - public PriceListAppService( - IExcelImportAppService excelImportService, - ISettleAccountBranchEfCoreRepository mapRepository, - PriceListManager priceListManager, - TaskJobService service - ) - { - _mapRepository = mapRepository; - _excelImportService = excelImportService; - _priceListManager = priceListManager; - _service = service; - } - - #region 导入、导出 - ///// - ///// 获取导入模板 - ///// - //[HttpPost("import-template")] - //public virtual async Task ImportTemplateAsync() - //{ - // await Task.CompletedTask; - // return new Microsoft.AspNetCore.Mvc.OkResult(); - //} + _priceListRepository = priceListRepository; + _mapRepository = mapRepository; + _priceListManager = priceListManager; + _service = service; + } + #region 导入、导出 + ///// + ///// 获取导入模板 + ///// + //[HttpPost("import-template")] + //public virtual async Task ImportTemplateAsync() + //{ + // await Task.CompletedTask; + // return new Microsoft.AspNetCore.Mvc.OkResult(); + //} - private string GetOtherSheetStringValue(IWorkbook wk, String sheetName, String location) + /// + /// 导入 + /// + [HttpPost] + public virtual async Task ImportAsync([FromForm] IFormFileCollection files, string version) + { + var checkList = new List(); + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImportByHeadDesc(files, _excelImportService); + List _checkls = new List(); + _checkls.Add("1040"); + _checkls.Add("1046"); + _checkls.Add("104T"); + result = result.Where(p => _checkls.Contains(p.Plant)).ToList(); + var entityList = ObjectMapper.Map, List>(result); + entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList(); + + #region 校验 + var lus = entityList.Select(p => p.LU).ToList(); + var priceListModelEntitys = await _priceListRepository.GetListAsync(p => lus.Contains(p.LU)); + if (priceListModelEntitys.Count > 0) + { + var query = from item1 in priceListModelEntitys + join item2 in entityList + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime) + select item1; + foreach (var item in query) + { + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"物料号:{item.LU},时间区间{item.BeginTime}-{item.EndTime}与系统数据存在时间交集", string.Empty)); + } + } + if (checkList.Count > 0) { - ISheet sheet = wk.GetSheet(sheetName); - var cr = new CellReference(location); - var row = sheet.GetRow(cr.Row); - var cell = row.GetCell(cr.Col); - string result = cell.StringCellValue; - return result; + return await ExportErrorReportAsync(checkList); } + #endregion - /// - /// 导入 - /// - [HttpPost] - public virtual async Task ImportAsync([FromForm] IFormFileCollection files, string version) + foreach (var item in entityList) { - ExportImporter _exportImporter = new ExportImporter(); + item.Update(GuidGenerator.Create()); + } - var result = await _exportImporter.UploadExcelImportByHeadDesc(files, _excelImportService); + await _priceListManager.ImportAsync(entityList.ToList(), version); + return ApplicationConsts.SuccessStr; + } - List _checkls = new List(); - _checkls.Add("1040"); - _checkls.Add("1046"); - _checkls.Add("104T"); + /// + /// 导出 + /// + [HttpPost] + public virtual async Task ExportAsync(RequestDto input) + { + IExporter _csv = new CsvExporter(); + IExporter _excel = new ExcelExporter(); + var entities = await _priceListManager.GetListAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); + var dtoDetails = ObjectMapper.Map, List>(entities); + string fileName = string.Format("销售价格单_{0}.xlsx", Guid.NewGuid().ToString()); + byte[] result = await _excel.ExportAsByteArray(dtoDetails); + result.ShouldNotBeNull(); + + //保存导出文件到服务器存成二进制 + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = fileName, + Content = result + } + ); + return fileName; + } + #endregion - result = result.Where(p => _checkls.Contains(p.Plant)).ToList(); + #region CURD + /// + /// 获取列表 + /// + [HttpPost] + public virtual async Task> GetListAsync(RequestDto input) + { + var entitys = await _priceListManager.GetListAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); + var totalCount = await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create()); + var dtos = ObjectMapper.Map, List>(entitys); + return new PagedResultDto(totalCount, dtos); + } - var entityList = ObjectMapper.Map, List>(result); - var _ls = entityList.OrderByDescending(p => p.BeginTime).GroupBy(p => new { p.LU, p.ClientCode }).Select(p => p.FirstOrDefault()); + /// + /// 删除 + /// + [HttpPost] + virtual public async Task DeleteAsync(Guid id) + { + await _priceListManager.DeleteAsync(id); + } - foreach (var itm in _ls) - { - itm.Update(GuidGenerator.Create(), version); - } - await _priceListManager.ImportAsync(_ls.ToList(), version); - return ApplicationConsts.SuccessStr; - } + /// + /// 批量删除 + /// + [HttpPost] + virtual public async Task DeleteListAsync(List ids) + { + return await _priceListManager.DeleteListAsync(ids); + } + #endregion - /// - /// 导出 - /// - [HttpPost] - public virtual async Task ExportAsync(RequestDto input) - { - IExporter _csv = new CsvExporter(); - IExporter _excel = new ExcelExporter(); - var entities = await _priceListManager.GetListAsync(input.Filters, input.Sorting, int.MaxValue, - 0, true); - var dtoDetails = ObjectMapper.Map, List>(entities); + #region 原方法(废弃) + // /// + // /// 获取总数 + // /// + // private async Task GetCountAsync(PriceListRequestDto input) + // { + // return await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create()); + // } - string _fileName = string.Empty; - //声明导出容器 - _fileName = string.Format("销售价格单_{0}.xlsx", Guid.NewGuid().ToString()); - byte[] result = await _excel.ExportAsByteArray(dtoDetails); - result.ShouldNotBeNull(); + // /// + // /// 结算总成和ERP总成价格对比 + // /// + // /// 上传的文件(前端已经限制只能上传一个附件) + // /// + // [HttpGet] + // [Route("BomDiffPrice-Make")] + // [DisableRequestSizeLimit] + // [Authorize(SettleAccountPermissions.PriceLists.Default)] + + // public async Task SettledPartAndErpPartPriceDiffMake(string version, string customerCode) + // { - //保存导出文件到服务器存成二进制 - await _excelImportService.SaveBlobAsync( - new SaveExcelImportInputDto - { - Name = _fileName, - Content = result - } - ); - return _fileName; - } - #endregion + // List customConditionList = new List(); - #region CURD - /// - /// 获取列表 - /// - [HttpPost] - public virtual async Task> GetListAsync(RequestDto input) - { - var entitys = await _priceListManager.GetListAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); - var totalCount = await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create()); - var dtos = ObjectMapper.Map, List>(entitys); - return new PagedResultDto(totalCount, dtos); - } + // customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "Bom定价差异明细" }); + // customConditionList.Add(new CustomCondition() { Name = "Version", Value = string.IsNullOrEmpty(version) ? string.Empty : version }); + // customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = string.IsNullOrEmpty(customerCode) ? string.Empty : customerCode }); + + // var _taskid = await _service.ExportEnqueueAsync("Bom定价差异明细", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettledPartAndErpPartPriceDiffExportService), customConditionList, (rs) => + // { + + // }); + // return _taskid; + // } + + // [HttpPost] + // [Route("job/list")] + // [Authorize(SettleAccountPermissions.PriceLists.Default)] + // [UnitOfWork(false)] + // virtual public async Task> GetListAsync(JobRequestDto input) + // { + // return await _service.GetListAsync(input); + // } - /// - /// 删除 - /// - [HttpPost] - virtual public async Task DeleteAsync(Guid id) - { - await _priceListManager.DeleteAsync(id); - } + // /// + // /// 按ID获取唯一实体 + // /// + // /// + // /// 返回实体全部属性 + // /// + // /// ID + // /// 实体DTO - /// - /// 批量删除 - /// - [HttpPost] - virtual public async Task DeleteListAsync(List ids) - { - return await _priceListManager.DeleteListAsync(ids); - } - #endregion + // [HttpGet] + // [Route("{id}")] + // /// [Authorize(SettleAccountPermissions.PriceLists.Default)] + // virtual public async Task GetAsync(Guid id) + // { + // var result = await _priceListManager.GetAsync(id); ; + // var dto = ObjectMapper.Map(result); + // return dto; + // } - #region 原方法(废弃) - // /// - // /// 获取总数 - // /// - // private async Task GetCountAsync(PriceListRequestDto input) - // { - // return await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create()); - // } + // /// + // /// 根据筛选条件获取实体列表 + // /// + // /// + // /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码 + // /// + // /// 请求条件 + // /// 实体DTO列表 + // [HttpPost] + // [Route("versionlist")] + //// [Authorize(SettleAccountPermissions.PriceLists.Default)] + // virtual public async Task> GetVersionListAsync(PriceListRequestDto input) + // { - // /// - // /// 结算总成和ERP总成价格对比 - // /// - // /// 上传的文件(前端已经限制只能上传一个附件) - // /// - // [HttpGet] - // [Route("BomDiffPrice-Make")] - // [DisableRequestSizeLimit] - // [Authorize(SettleAccountPermissions.PriceLists.Default)] - - // public async Task SettledPartAndErpPartPriceDiffMake(string version, string customerCode) - // { - // List customConditionList = new List(); + // var entities = await _priceListManager.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount); + // var totalCount = await GetCountAsync(input); + // var dtos = ObjectMapper.Map, List>(entities); + // return new PagedResultDto(totalCount, dtos); + // } - // customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "Bom定价差异明细" }); - // customConditionList.Add(new CustomCondition() { Name = "Version", Value = string.IsNullOrEmpty(version) ? string.Empty : version }); - // customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = string.IsNullOrEmpty(customerCode) ? string.Empty : customerCode }); - - // var _taskid = await _service.ExportEnqueueAsync("Bom定价差异明细", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettledPartAndErpPartPriceDiffExportService), customConditionList, (rs) => - // { - - // }); - // return _taskid; - // } - - // [HttpPost] - // [Route("job/list")] - // [Authorize(SettleAccountPermissions.PriceLists.Default)] - // [UnitOfWork(false)] - // virtual public async Task> GetListAsync(JobRequestDto input) - // { - // return await _service.GetListAsync(input); - // } - - // /// - // /// 按ID获取唯一实体 - // /// - // /// - // /// 返回实体全部属性 - // /// - // /// ID - // /// 实体DTO - - // [HttpGet] - // [Route("{id}")] - // /// [Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task GetAsync(Guid id) - // { - // var result = await _priceListManager.GetAsync(id); ; - // var dto = ObjectMapper.Map(result); - // return dto; - - // } - - - - - - // /// - // /// 根据筛选条件获取实体列表 - // /// - // /// - // /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码 - // /// - // /// 请求条件 - // /// 实体DTO列表 - // [HttpPost] - // [Route("versionlist")] - //// [Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task> GetVersionListAsync(PriceListRequestDto input) - // { - - - // var entities = await _priceListManager.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount); - // var totalCount = await GetCountAsync(input); - // var dtos = ObjectMapper.Map, List>(entities); - // return new PagedResultDto(totalCount, dtos); - // } - - - - - - - // /// - // /// 获取实体总数 - // /// - // /// 实体总数 - // [HttpGet] - // [Route("count")] - // //[Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task GetTotalCountAsync(Guid branchId) - // { - // return await _priceListManager.GetCountAsync(new List(), branchId); - // } - - // /// - // /// 获取全部实体列表 - // /// - // /// 实体DTO列表 - // [HttpGet] - // [Route("all")] - // //[Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task> GetAllAsync(Guid branchId) - // { - // var entities = await _priceListManager.GetAllAsync(branchId); - // var dtos = ObjectMapper.Map, List>(entities); - // return new ListResultDto(dtos); - // } - - - // /// - // /// 修改实体 - // /// - // /// ID - // /// 修改实体DTO - // /// 实体DTO - // [HttpPut] - // [Route("{id}")] - // [Authorize(SettleAccountPermissions.PriceLists.Update)] - // virtual public async Task UpdateAsync(Guid id, PriceListDto input) - // { - // var entity = new PriceList( - - // ); - - // var _ent = await _priceListManager.UpdateAsync(id, entity); - - - // var dto = ObjectMapper.Map(_ent); - // return dto; - // } - #endregion - } + + + + + // /// + // /// 获取实体总数 + // /// + // /// 实体总数 + // [HttpGet] + // [Route("count")] + // //[Authorize(SettleAccountPermissions.PriceLists.Default)] + // virtual public async Task GetTotalCountAsync(Guid branchId) + // { + // return await _priceListManager.GetCountAsync(new List(), branchId); + // } + + // /// + // /// 获取全部实体列表 + // /// + // /// 实体DTO列表 + // [HttpGet] + // [Route("all")] + // //[Authorize(SettleAccountPermissions.PriceLists.Default)] + // virtual public async Task> GetAllAsync(Guid branchId) + // { + // var entities = await _priceListManager.GetAllAsync(branchId); + // var dtos = ObjectMapper.Map, List>(entities); + // return new ListResultDto(dtos); + // } + + + // /// + // /// 修改实体 + // /// + // /// ID + // /// 修改实体DTO + // /// 实体DTO + // [HttpPut] + // [Route("{id}")] + // [Authorize(SettleAccountPermissions.PriceLists.Update)] + // virtual public async Task UpdateAsync(Guid id, PriceListDto input) + // { + // var entity = new PriceList( + + // ); + + // var _ent = await _priceListManager.UpdateAsync(id, entity); + + + // var dto = ObjectMapper.Map(_ent); + // return dto; + // } + #endregion + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs index 3270d577..f1521726 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Shouldly; @@ -8,12 +8,14 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.Prices @@ -48,8 +50,9 @@ namespace Win.Sfs.SettleAccount.Entities.Prices [HttpPost] public async Task ImportAsync([FromForm] IFormFileCollection files, string version) { + var checkList = new List(); ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var result = await _exportImporter.UploadExcelImportByHeadDesc(files, _excelImportService); List _checkls = new List(); _checkls.Add("1040"); _checkls.Add("1046"); @@ -57,13 +60,35 @@ namespace Win.Sfs.SettleAccount.Entities.Prices result = result.Where(p => _checkls.Contains(p.ClientCode)).ToList(); var entityList = ObjectMapper.Map, List>(result); - var _ls = entityList.GroupBy(p => new { p.LU, p.ClientCode }).Select(p => p.FirstOrDefault()); - foreach (var itm in _ls) + entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList(); + + #region 校验 + var lus = entityList.Select(p => p.LU).ToList(); + var priceListBJModelEntitys = await _repository.GetListAsync(p => lus.Contains(p.LU)); + if (priceListBJModelEntitys.Count > 0) + { + var query = from item1 in priceListBJModelEntitys + join item2 in entityList + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + where (item1.BeginDate > item2.BeginDate && item1.BeginDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.BeginDate < item1.EndDate) + select item1; + foreach (var item in query) + { + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"物料号:{item.LU},时间区间{item.BeginDate}-{item.EndDate}与系统数据存在时间交集", string.Empty)); + } + } + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); + } + #endregion + + foreach (var item in entityList) { - itm.Update(GuidGenerator.Create(), version); + item.Update(GuidGenerator.Create()); } - await _priceListManagerBJ.ImportAsync(_ls.ToList(), version); + await _priceListManagerBJ.ImportAsync(entityList, version); return ApplicationConsts.SuccessStr; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index dd1bc465..87625849 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -142,6 +142,8 @@ namespace Win.Sfs.SettleAccount CreateMapHBPO_SE_DETAIL(); CreateMapHBPO_SE_EDI(); + CreateMapHBPO_SA(); + CreateMapHBPO_SA_DETAIL(); CreateMapPUB_SE_DETAIL(); CreateMapPUB_SA(); @@ -493,18 +495,21 @@ namespace Win.Sfs.SettleAccount .ForMember(x => x.Date, y => y.MapFrom(y => DateTime.ParseExact(y.Date, "dd.MM.yyyy", System.Globalization.CultureInfo.CurrentCulture))); CreateMap(); - CreateMap().ReverseMap(); CreateMap().ReverseMap(); } + /// + /// 备件价格 + /// private void CreateMapPriceListBJ() - { + CreateMap() + .ForMember(x => x.Date, y => y.MapFrom(y => DateTime.ParseExact(y.Date, "dd.MM.yyyy", System.Globalization.CultureInfo.CurrentCulture))); + CreateMap().ReverseMap(); CreateMap().ReverseMap(); - CreateMap().ReverseMap(); CreateMap().ReverseMap(); } @@ -959,6 +964,28 @@ namespace Win.Sfs.SettleAccount CreateMap(); } + /// + /// HBPO结算 + /// + private void CreateMapHBPO_SA() + { + CreateMap(); + } + + /// + /// HBPO结算明细 + /// + private void CreateMapHBPO_SA_DETAIL() + { + CreateMap() + .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); + CreateMap() + .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); + //CreateMap(); + + CreateMap(); + } + /// /// PUB发运单 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TB_RePartsRelationship.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TB_RePartsRelationship.cs index e2ad8e38..c771d098 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TB_RePartsRelationship.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TB_RePartsRelationship.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel.DataAnnotations; using Volo.Abp.Domain.Entities.Auditing; using Win.Sfs.SettleAccount; @@ -26,6 +26,11 @@ public class TB_RePartsRelationship : FullAuditedAggregateRoot [Display(Name = "业务类型")] public EnumBusinessType BusinessType { get; set; } + public TB_RePartsRelationship() + { + + } + public TB_RePartsRelationship(string lU, string repLU, string clientCode, EnumBusinessType businessType) { LU = lU; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs index 2ea7ac34..88aad9de 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Diagnostics.Contracts; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -56,6 +57,12 @@ namespace Win.Sfs.SettleAccount.Entities.Prices Type = type; CustomerCode = customerCode; } + + public void Update(Guid id) + { + Id = id; + } + public void Update(Guid id, string version) { Id = id; @@ -164,6 +171,18 @@ namespace Win.Sfs.SettleAccount.Entities.Prices CustomerCode = customerCode; } + public PriceListBJ(Guid Id, string lu, decimal price, DateTime beginDate, DateTime endDate, string clientCode, DateTime date, string contractNo) : base(Id) + { + LU = lu; + Price = price; + BeginDate = beginDate; + EndDate = endDate; + Price = price; + ClientCode = clientCode; + Date = date; + ContractNo = contractNo; + } + public void Set(DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type, string customerCode) { BeginDate = beginDate; @@ -173,6 +192,12 @@ namespace Win.Sfs.SettleAccount.Entities.Prices Type = type; CustomerCode = customerCode; } + + public void Update(Guid id) + { + Id = id; + } + public void Update(Guid id, string version) { Id = id; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs index e6dff4a7..137fa67e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs @@ -7,20 +7,29 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; +using Win.Sfs.Shared.DomainBase; using Win.Sfs.Shared.Filter; +using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.Prices { public class PriceListManager : DomainService { + /// + /// 销售价格仓储 + /// + private readonly INormalEfCoreRepository _priceListRepository; + private readonly ISettleAccountBranchEfCoreRepository _repository; private readonly ISettleAccountBranchEfCoreRepository _versionRepository; protected PriceListManager() { } public PriceListManager( + INormalEfCoreRepository priceListRepository, ISettleAccountBranchEfCoreRepository repository, ISettleAccountBranchEfCoreRepository versionRepository - ) + ) { + _priceListRepository = priceListRepository; _versionRepository = versionRepository; _repository = repository; } @@ -70,55 +79,52 @@ namespace Win.Sfs.SettleAccount.Entities.Prices return await _repository.GetCountByFilterAsync(branchId, p_filter); } - - public virtual async Task> ImportAsync(List entities,string version) + /// + /// 导入 + /// + public virtual async Task> ImportAsync(List entities, string version) { List _errorList = new List(); //写校验在这里 - var pricelist = GetPriceList(version); + var lus = entities.Select(p => p.LU).ToList(); + var pricelist = await _priceListRepository.GetListAsync(p => lus.Contains(p.LU)); - //var LeftJoin = from emp in ListOfEmployees - // join dept in ListOfDepartment - // on emp.DeptID equals dept.ID into JoinedEmpDept - // from dept in JoinedEmpDept.DefaultIfEmpty() + var update = from item1 in entities + join item2 in pricelist + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + where item1.Price != item2.Price && item1.BeginTime == item2.BeginTime && item1.EndTime == item1.EndTime + select new PriceList(item2.Id, item2.LU, item1.Price, item2.BeginTime, item2.EndTime, item2.ClientCode, item2.Date, item2.ContractNo); - var update = from itm1 in entities - join itm2 in pricelist - on new { itm1.ClientCode, itm1.LU, itm1.BeginTime, itm1.EndTime } equals new { itm2.ClientCode, itm2.LU, itm2.BeginTime, itm2.EndTime } - where itm1.Price != itm2.Price - select new PriceList(itm2.Id, itm2.LU, itm1.Price, itm2.BeginTime, itm2.EndTime, itm2.ClientCode, itm2.Date, itm2.ContractNo); - - if (update.Count() > 0) + if (update.Any()) { - - await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); } - else - { - var add = from itm1 in entities - join itm2 in pricelist - on new { itm1.ClientCode, itm1.LU, itm1.BeginTime, itm1.EndTime } - equals new { itm2.ClientCode, itm2.LU, itm2.BeginTime, itm2.EndTime } - into temp - from itm3 in temp.DefaultIfEmpty() - where itm3 == null - select itm1; - await _repository.GetDbContext().BulkInsertAsync(add.ToList()); - } - var _first = _versionRepository.FirstOrDefault(p => p.Version == version); - if (_first == null) + //新零件号 + var addNewLu = from item1 in entities + join item2 in pricelist + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + into temp + from item3 in temp.DefaultIfEmpty() + where item3 == null + select item1; + //新日期 + var addNewDate = from item1 in entities + join item2 in pricelist + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + where item1.BeginTime != item2.BeginTime || item1.EndTime != item2.EndTime + select item1; + + var add = addNewLu.Concat(addNewDate); + if (add.Any()) { - - List _versionList = new List() { new PriceListVersion(GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version) }; - await _versionRepository.GetDbContext().BulkInsertAsync(_versionList); + await _repository.GetDbContext().BulkInsertAsync(add.ToList()); } + return _errorList; } - public virtual async Task CreateAsync(PriceList input) { var entity = new PriceList( @@ -168,14 +174,21 @@ namespace Win.Sfs.SettleAccount.Entities.Prices public class PriceListManagerBJ : DomainService { + /// + /// 备件价格仓储 + /// + private readonly INormalEfCoreRepository _priceListBJRepository; + private readonly ISettleAccountBranchEfCoreRepository _repository; private readonly ISettleAccountBranchEfCoreRepository _versionRepository; protected PriceListManagerBJ() { } public PriceListManagerBJ( + INormalEfCoreRepository priceListBJRepository, ISettleAccountBranchEfCoreRepository repository, ISettleAccountBranchEfCoreRepository versionRepository ) { + _priceListBJRepository = priceListBJRepository; _versionRepository = versionRepository; _repository = repository; } @@ -225,54 +238,51 @@ namespace Win.Sfs.SettleAccount.Entities.Prices return await _repository.GetCountByFilterAsync(branchId, p_filter); } - + /// + /// 导入 + /// public virtual async Task> ImportAsync(List entities, string version) { List _errorList = new List(); //写校验在这里 - var pricelist = GetPriceList(version); - - - //var LeftJoin = from emp in ListOfEmployees - // join dept in ListOfDepartment - // on emp.DeptID equals dept.ID into JoinedEmpDept - // from dept in JoinedEmpDept.DefaultIfEmpty() - - var update = from itm1 in entities - join itm2 in pricelist - on new { itm1.Type, itm1.MaterialCode ,itm1.CustomerCode} equals new { itm2.Type, itm2.MaterialCode ,itm2.CustomerCode} - where itm1.Price != itm2.Price - select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode); + var lus = entities.Select(p => p.LU).ToList(); + var pricelist = await _priceListBJRepository.GetListAsync(p => lus.Contains(p.LU)); - if (update.Count() > 0) + var update = from item1 in entities + join item2 in pricelist + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + where item1.Price != item2.Price && item1.BeginDate == item2.BeginDate && item1.EndDate == item1.EndDate + select new PriceListBJ(item2.Id, item2.LU, item1.Price, item2.BeginDate, item2.EndDate, item2.ClientCode, item2.Date, item2.ContractNo); + if (update.Any()) { await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); } - else - { - var add = from itm1 in entities - join itm2 in pricelist - on new { itm1.Type, itm1.MaterialCode } - equals new { itm2.Type, itm2.MaterialCode } - into temp - from itm3 in temp.DefaultIfEmpty() - where itm3 == null - select itm1; - await _repository.GetDbContext().BulkInsertAsync(add.ToList()); - } - var _first = _versionRepository.FirstOrDefault(p => p.Version == version); - if (_first == null) + //新零件号 + var addNewLu = from item1 in entities + join item2 in pricelist + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + into temp + from item3 in temp.DefaultIfEmpty() + where item3 == null + select item1; + //新日期 + var addNewDate = from item1 in entities + join item2 in pricelist + on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + where item1.BeginDate != item2.BeginDate || item1.EndDate != item2.EndDate + select item1; + + var add = addNewLu.Concat(addNewDate); + if (add.Any()) { - - List _versionList = new List() { new PriceListVersionBJ(GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version) }; - await _versionRepository.GetDbContext().BulkInsertAsync(_versionList); + await _repository.GetDbContext().BulkInsertAsync(add.ToList()); } + return _errorList; } - public virtual async Task CreateAsync(PriceListBJ input) { var entity = new PriceListBJ( diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs index 6c4f21b6..4a1d876c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs @@ -18,6 +18,7 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.ObjectMapping; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount; +using Win.Sfs.SettleAccount.Entities.BQ; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Reports; @@ -36,6 +37,11 @@ namespace SettleAccount.Job.Services.Report /// private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository; + /// + /// PUB二次比对仓储 + /// + private readonly INormalEfCoreRepository _pubSeCDetailRepository; + /// /// Pub结算发运对比Dapper /// @@ -56,11 +62,13 @@ namespace SettleAccount.Job.Services.Report /// public PubSaSeCompareExportService( INormalEfCoreRepository tbRePartsRelationshipRepository, + INormalEfCoreRepository pubSeCDetailRepository, PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, IBlobContainer fileContainer, IObjectMapper objectMapper) { _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; + _pubSeCDetailRepository = pubSeCDetailRepository; _pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; _fileContainer = fileContainer; _objectMapper = objectMapper; @@ -109,6 +117,8 @@ namespace SettleAccount.Job.Services.Report var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); //无结算有发运 var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); + //二次匹配上的记录 + var secondMatchHaveSaHaveSes = new List(); haveSaHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); haveSaNotHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); @@ -139,7 +149,7 @@ namespace SettleAccount.Job.Services.Report { var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN); var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN); - pubSaSeCompareDiffs.Add(new PubSaSeCompareDiff() + secondMatchHaveSaHaveSes.Add(new PubSaSeCompareDiff() { WmsBillNum = notHaveSaHaveSe.WmsBillNum, ShippingDate = notHaveSaHaveSe.ShippingDate, @@ -163,6 +173,14 @@ namespace SettleAccount.Job.Services.Report } } + //二次对比比对上的数据入库 + if (secondMatchHaveSaHaveSes.Count > 0) + { + pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes); + + var pubSeCDetailEntitys = _objectMapper.Map, List>(secondMatchHaveSaHaveSes); + _pubSeCDetailRepository.InsertManyAsync(pubSeCDetailEntitys); + } #endregion if (string.IsNullOrEmpty(lu) == false) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs index 7c754d78..4ae5ff46 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Win.Sfs.SettleAccount.Entities.BQ; using Win.Sfs.SettleAccount.Reports; namespace SettleAccount.Job @@ -17,6 +18,8 @@ namespace SettleAccount.Job { CreateMap() .ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU)); + + CreateMap(); } } }