Browse Source

基础数据导入、导出Dto修改

master
mahao 1 year ago
parent
commit
8cae245323
  1. 105
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs
  2. 42
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs
  3. 64
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs
  4. 87
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomDto.cs
  5. 89
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs
  6. 22
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs
  7. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs
  8. 333
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs
  9. 332
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  10. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs
  11. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  12. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs
  13. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
  14. 29
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs
  15. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  16. 100
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  17. 37
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  18. 33
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  19. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TB_RePartsRelationship.cs
  20. 25
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs
  21. 140
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs
  22. 20
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  23. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs

105
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;
/// <summary>
/// HBPO结算单
/// </summary>
public class HBPO_SA_DTO
{
/// <summary>
/// 期间
/// </summary>
[Display(Name = "期间")]
public int Version { get; set; }
/// <summary>
/// 结算单据
/// </summary>
[Display(Name = "结算单据")]
public string BillNum { get; set; }
/// <summary>
/// 出库单号
/// </summary>
[Display(Name = "出库单号")]
public string DNBillNum { get; set; }
/// <summary>
/// 1、新建 2、已有出库3、已有扣减寄售库
/// </summary>
[Display(Name = "状态")]
public string State { get; set; }
/// <summary>
/// 明细记录行数
/// </summary>
[Display(Name = "明细记录行数")]
public string RecordCount { get; set; }
/// <summary>
/// 工厂地点
/// </summary>
[Display(Name = "工厂地点")]
public string Site { get; set; }
/// <summary>
/// 业务类型
/// </summary>
[Display(Name = "业务类型")]
public EnumBusinessType BusinessType { get; set; }
}
/// <summary>
/// HBPO结算明细导入
/// </summary>
public class HBPO_SA_DETAIL_IMPORT_DTO
{
/// <summary>
/// 结算日期
/// </summary>
[Display(Name = "结算日期")]
[ImporterHeader(Name = "ReceiveDate", Format = "yyyy/MM/dd")]
public DateTime SettleDate { set; get; }
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "PartNumber")]
public string LU { get; set; }
/// <summary>
/// 生产号
/// </summary>
[Display(Name = "生产号")]
[ImporterHeader(Name = "productionNumber")]
[Required(ErrorMessage = "{0}不能为空")]
public string PN { get; set; }
/// <summary>
/// 数量
/// </summary>
[Display(Name = "数量")]
[ImporterHeader(Name = "Qty")]
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// </summary>
[Display(Name = "结算分组号")]
[ImporterHeader(Name = "DeliveryNode")]
[Required(ErrorMessage = "{0}不能为空")]
public string GroupNum { get; set; }
/// <summary>
/// 工厂地点
/// </summary>
[Display(Name = "工厂地点")]
[ImporterHeader(Name = "filename")]
[Required(ErrorMessage = "{0}不能为空")]
public string Site { get; set; }
}

42
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs

@ -1,16 +1,15 @@
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;
/// <summary>
/// 采购价格单
/// </summary>
public class PURCHASE_PRICE_DTO : EntityDto<Guid>
{
/// <summary>
/// 采购价格单
/// </summary>
public class PURCHASE_PRICE_DTO : EntityDto<Guid>
{
/// <summary>
/// 零件号
/// </summary>
@ -22,17 +21,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "价格")]
public decimal Price { get; set; }
}
}
/// <summary>
/// 导入
/// </summary>
public class PURCHASE_PRICE_IMPORT_DTO
{
/// <summary>
/// 导入
/// </summary>
public class PURCHASE_PRICE_IMPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "零件号")]
public string LU { get; set; }
@ -42,13 +42,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[Display(Name = "价格")]
[ImporterHeader(Name = "价格")]
public decimal Price { get; set; }
}
}
/// <summary>
/// 导出
/// </summary>
public class PURCHASE_PRICE_EXPORT_DTO
{
/// <summary>
/// 导出
/// </summary>
public class PURCHASE_PRICE_EXPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
@ -62,6 +62,4 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[Display(Name = "价格")]
[ExporterHeader(DisplayName = "价格")]
public decimal Price { get; set; }
}
}

64
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; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
public string ClientCode { set; get; }
/// <summary>
/// 业务类型
/// </summary>
@ -41,32 +35,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public class TB_RePartsRelationship_IMPORT_DTO
{
/// <summary>
/// 零件
/// 客户物料
/// </summary>
[Display(Name = "零件号")]
[ImporterHeader(Name = "零件号")]
[Display(Name = "客户物料号")]
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "客户物料号")]
public string LU { set; get; }
/// <summary>
/// 替换零件号
/// </summary>
[Display(Name = "替换零件号")]
[ImporterHeader(Name = "替换零件号")]
public string RepLU { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
[ImporterHeader(Name = "客户编码")]
public string ClientCode { set; get; }
/// <summary>
/// 业务类型
/// </summary>
[Display(Name = "业务类型")]
[ImporterHeader(Name = "业务类")]
[ImporterHeader(Name = "业务分类")]
public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 替换客户物料号
/// </summary>
[Display(Name = "替换客户物料号")]
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "替换客户物料号")]
public string RepLU { set; get; }
}
/// <summary>
@ -78,29 +67,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "零件号")]
[ExporterHeader(DisplayName = "客户物料号")]
public string LU { set; get; }
/// <summary>
/// 替换零件号
/// </summary>
[Display(Name = "替换零件号")]
[ExporterHeader(DisplayName = "替换零件号")]
public string RepLU { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
[ExporterHeader(DisplayName = "客户编码")]
public string ClientCode { set; get; }
/// <summary>
/// 业务类型
/// </summary>
[Display(Name = "业务类型")]
[ExporterHeader(DisplayName = "业务类")]
[ExporterHeader(DisplayName = "业务分类")]
public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 替换零件号
/// </summary>
[Display(Name = "替换零件号")]
[ExporterHeader(DisplayName = "替换客户物料号")]
public string RepLU { set; get; }
}
}

87
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;
using Volo.Abp.Application.Dtos;
namespace Win.Sfs.SettleAccount.Boms;
namespace Win.Sfs.SettleAccount.Boms
/// <summary>
/// Bom
/// </summary>
public class BomDto : EntityDto<Guid>
{
public class BomDto : AuditedEntityDtoBase<Guid>, IBranch<Guid>
{
/// <summary>
/// 分支id
/// 父物料编码
/// </summary>
[Display(Name = "分支Id")]
[Required(ErrorMessage = "{0}是必填项")]
public Guid BranchId { get; set; }
[Display(Name = "父物料编码")]
[Required(ErrorMessage = "{0}是必填项")]
public string ParentItemCode { get; set; }
/// <summary>
/// 父物料描述
/// </summary>
[Display(Name = "父物料描述")]
[MaxLength(CommonConsts.MaxDescriptionLength, ErrorMessage = "{0}最多输入{1}个字符")]
public string ParentItemDesc { get; set; }
/// <summary>
/// 组件编码
/// </summary>
[Display(Name = "组件编码")]
[Required(ErrorMessage = "{0}是必填项")]
public string ChildItemCode { get; set; }
/// <summary>
/// 组件描述
/// </summary>
[Display(Name = "组件描述")]
[MaxLength(CommonConsts.MaxDescriptionLength, ErrorMessage = "{0}最多输入{1}个字符")]
public string ChildItemDesc { get; set; }
/// <summary>
/// 组件计量单位
/// </summary>
[Display(Name = "组件计量单位")]
public string ChildItemUom { get; set; }
/// <summary>
/// 组件数量
/// </summary>
[Display(Name = "组件数量")]
[Required(ErrorMessage = "{0}是必填项")]
public decimal Qty { get; set; }
/// <summary>
/// 结构类型
/// </summary>
[Display(Name = "结构类型")]
public string BomType { get; set; }
/// <summary>
/// 工序
/// </summary>
[Display(Name = "工序")]
public int OperateProcess { get; set; }
/// <summary>
/// 废品率
/// </summary>
[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; }
/// <summary>
/// 子物品消耗位置
/// </summary>
[Display(Name = "子物品消耗位置")]
public string IssuePosition { get; set; }
[Display(Name = "结构层级")]
public int BomLevel { get; set; }
public string Version { set; get; }
/// <summary>
/// 工厂
/// 结构层级
/// </summary>
public string Factory { set; get; }
}
[Display(Name = "结构层级")]
public int BomLevel { get; set; }
}

89
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
{
public class BomExportDto
{
namespace Win.Sfs.SettleAccount.Entities.Boms;
[ExporterHeader(DisplayName = "期间")]
public string Version { set; get; }
/// <summary>
/// Bom导出
/// </summary>
public class BomExportDto
{
/// <summary>
/// 工厂
/// 父物料编码
/// </summary>
[ExporterHeader(DisplayName = "工厂")]
public string Factory { set; get; }
[ExporterHeader(DisplayName = "ERP总成物料号")]
[Display(Name = "父物料编码")]
[ExporterHeader(DisplayName = "父物料编码")]
public string ParentItemCode { get; set; }
[ExporterHeader(DisplayName = "ERP总成物料号描述")]
/// <summary>
/// 父物料描述
/// </summary>
[Display(Name = "父物料描述")]
[ExporterHeader(DisplayName = "父物料描述")]
public string ParentItemDesc { get; set; }
[ExporterHeader(DisplayName = "ERP组件物料号")]
/// <summary>
/// 组件编码
/// </summary>
[Display(Name = "组件编码")]
[ExporterHeader(DisplayName = "组件编码")]
public string ChildItemCode { get; set; }
[ExporterHeader(DisplayName = "ERP组件物料号描述")]
/// <summary>
/// 组件描述
/// </summary>
[Display(Name = "组件描述")]
[ExporterHeader(DisplayName = "组件描述")]
public string ChildItemDesc { get; set; }
/// <summary>
/// 组件计量单位
/// </summary>
[Display(Name = "组件计量单位")]
[ExporterHeader(DisplayName = "组件计量单位")]
public string ChildItemUom { get; set; }
/// <summary>
/// 组件数量
/// </summary>
[Display(Name = "组件数量")]
[ExporterHeader(DisplayName = "组件数量")]
public decimal Qty { get; set; }
[ExporterHeader(DisplayName = "组件计量单位")]
public string ChildItemUom { get; set; }
}
/// <summary>
/// 结构类型
/// </summary>
[Display(Name = "结构类型")]
[ExporterHeader(DisplayName = "结构类型")]
public string BomType { get; set; }
/// <summary>
/// 工序
/// </summary>
[Display(Name = "工序")]
[ExporterHeader(DisplayName = "工序")]
public int OperateProcess { get; set; }
/// <summary>
/// 废品率
/// </summary>
[Display(Name = "废品率")]
[ExporterHeader(DisplayName = "废品率")]
public decimal ScrapPercent { get; set; }
/// <summary>
/// 子物品消耗位置
/// </summary>
[Display(Name = "子物品消耗位置")]
[ExporterHeader(DisplayName = "子物品消耗位置")]
public string IssuePosition { get; set; }
/// <summary>
/// 结构层级
/// </summary>
[Display(Name = "结构层级")]
[ExporterHeader(DisplayName = "结构层级")]
public int BomLevel { get; set; }
}

22
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
}
/// <summary>
/// FIS
/// 导出
/// </summary>
public class MaterialRelationshipExportDto
{
@ -132,15 +132,11 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
/// </summary>
[ExporterHeaderAttribute(DisplayName = "客户物料号")]
public string SettleMaterialCode { get; set; }
}
/// <summary>
/// 客户物料描述
/// 客户零件关系导入
/// </summary>
[ExporterHeaderAttribute(DisplayName = "客户物料描述")]
public virtual string MaterialProperty { get; set; }
}
[ImportProject(Name = "零件匹配关系")]
public class MaterialRelationshipImportDto
{
@ -156,6 +152,7 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
/// 厂内物料描述
/// </summary>
[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
/// 客户物料号
/// </summary>
[ImporterHeader(Name = "客户物料号")]
[Required(ErrorMessage = "{0}是必填项")]
[MaxLength(CommonConsts.MaxNameLength, ErrorMessage = "{0}最多输入{1}个字符")]
public string SettleMaterialCode { get; set; }
/// <summary>
/// 客户物料描述
/// </summary>
[ImporterHeader(Name = "客户物料描述")]
public virtual string MaterialProperty { get; set; }
}
public class MaterialRelationshipDetailDto : EntityDto<Guid>

28
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
{
/// <summary>
/// 客户物料号
/// 导出
/// </summary>
[ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { set; get; }
public class MaterialExportDto
{
/// <summary>
/// 厂内物料号
/// </summary>
@ -376,22 +373,9 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
public string MaterialCode { set; get; }
/// <summary>
/// 物料描述
/// 厂内物料描述
/// </summary>
[ExporterHeader(DisplayName = "物料描述")]
[ExporterHeader(DisplayName = "厂内物料描述")]
public string MaterialDesc { set; get; }
/// <summary>
/// 基础计量单位
/// </summary>
[ExporterHeader(DisplayName = "基本计量单位")]
public string Unit { set; get; }
/// <summary>
/// 产品类型
/// </summary>
[ExporterHeader(DisplayName = "产品类型")]
public string EstimateType { set; get; }
}
}

333
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs

@ -1,17 +1,16 @@
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<Guid>
{
public class PriceListDto : EntityDto<Guid>
{
/// <summary>
/// 版本
/// </summary>
@ -47,19 +46,18 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[Display(Name = "客户")]
public string CustomerCode { get; set; }
}
}
/// <summary>
/// 销售价格单导出
/// </summary>
public class PriceListExportDto
{
/// <summary>
/// 销售价格单导出
/// </summary>
public class PriceListExportDto
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string LU { get; set; }
/// <summary>
@ -103,15 +101,15 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[Display(Name = "合同号")]
[ExporterHeader(DisplayName = "合同号")]
public string ContractNo { get; set; }
}
}
/// <summary>
/// 销售价格导入
/// </summary>
[ImportProject(Name = SettleAccountModuleName.PriceList)]
[Importer(HeaderRowIndex = 22)]
public class PriceListImportDto
{
/// <summary>
/// 销售价格导入
/// </summary>
[ImportProject(Name = SettleAccountModuleName.PriceList)]
[Importer(HeaderRowIndex = 22)]
public class PriceListImportDto
{
/// <summary>
/// 合同签订时间
/// </summary>
@ -126,84 +124,20 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[ExcelImporterHeadDesc(Row = 2, Cell = 1)]
public string ContractNo { get; set; }
///// <summary>
///// ItemNo
///// </summary>
//[ImporterHeader(Name = "ItemNo")]
//public string ItemNo { get; set; }
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "Part No.")]
public string PartNo { get; set; }
///// <summary>
///// PartDescription
///// </summary>
//[ImporterHeader(Name = "PartDescription")]
//public string PartDescription { get; set; }
///// <summary>
///// ES1
///// </summary>
//[ImporterHeader(Name = "ES1")]
//public string ES1 { get; set; }
///// <summary>
///// ES2
///// </summary>
//[ImporterHeader(Name = "ES2")]
//public string ES2 { get; set; }
///// <summary>
///// ZGS
///// </summary>
//[ImporterHeader(Name = "ZGS")]
//public string ZGS { get; set; }
///// <summary>
///// UnitOfMeasure
///// </summary>
//[ImporterHeader(Name = "UnitOfMeasure")]
//public string UnitOfMeasure { get; set; }
///// <summary>
///// Currency
///// </summary>
//[ImporterHeader(Name = "Currency")]
//public string Currency { get; set; }
///// <summary>
///// PriceType
///// </summary>
//[ImporterHeader(Name = "PriceType")]
//public string PriceType { get; set; }
/// <summary>
/// 价格
/// </summary>
[ImporterHeader(Name = "Total Price")]
public string TotalPrice { get; set; }
///// <summary>
///// Base Price(Old)
///// </summary>
//[ImporterHeader(Name = "Base Price(Old)")]
//public string BasePriceOld { get; set; }
///// <summary>
///// UnitOfOrder
///// </summary>
//[ImporterHeader(Name = "Unit of Order")]
//public string UnitOfOrder { get; set; }
///// <summary>
///// 11000 - BBAC JIS
///// </summary>
//[ImporterHeader(Name = "11000 - BBAC JIS")]
//public string BBACJIS { get; set; }
/// <summary>
/// 开始时间
/// </summary>
@ -216,86 +150,15 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[ImporterHeader(Name = "Valid To")]
public string ValidTo { get; set; }
///// <summary>
///// ProductionCountry
///// </summary>
//[ImporterHeader(Name = "Production Country")]
//public string ProductionCountry { get; set; }
/// <summary>
/// 客户编码
/// </summary>
[ImporterHeader(Name = "Plant")]
public string Plant { get; set; }
}
///// <summary>
///// Transport Term
///// </summary>
//[ImporterHeader(Name = "Transport Term")]
//public string TransportTerm { get; set; }
///// <summary>
///// Transport Term City
///// </summary>
//[ImporterHeader(Name = "Transport Term City")]
//public string TransportTermCity { get; set; }
///// <summary>
///// Transport Term Country
///// </summary>
//[ImporterHeader(Name = "Transport Term Country")]
//public string TransportTermCountry { get; set; }
///// <summary>
///// Shipping Location
///// </summary>
//[ImporterHeader(Name = "Shipping Location")]
//public string ShippingLocation { get; set; }
///// <summary>
///// Production Location
///// </summary>
//[ImporterHeader(Name = "Production Location")]
//public string ProductionLocation { get; set; }
///// <summary>
///// VAT Shipping Country
///// </summary>
//[ImporterHeader(Name = "VAT Shipping Country")]
//public string VATShippingCountry { get; set; }
///// <summary>
///// Minimum Order Quantity
///// </summary>
//[ImporterHeader(Name = "Minimum Order Quantity")]
//public string MinimumOrderQuantity { get; set; }
///// <summary>
///// Payment
///// </summary>
//[ImporterHeader(Name = "Payment")]
//public string Payment { get; set; }
///// <summary>
///// Packaging
///// </summary>
//[ImporterHeader(Name = "Packaging")]
//public string Packaging { get; set; }
///// <summary>
///// Return
///// </summary>
//[ImporterHeader(Name = "Return")]
//public string Return { get; set; }
///// <summary>
///// 3YP
///// </summary>
//[ImporterHeader(Name = "3YP")]
//public string YP3 { get; set; }
}
public class PriceListRequestDto : PagedAndSortedResultRequestDto
{
public class PriceListRequestDto : PagedAndSortedResultRequestDto
{
[Display(Name = "开始时间")]
public DateTime BeginDate { get; set; }
[Display(Name = "结算时间")]
@ -314,22 +177,37 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public string Version { set; get; }
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
}
}
#region 备件价格
public class PriceListBJDto : EntityDto<Guid>
{
#region 备件价格
/// <summary>
/// 备件价格
/// </summary>
public class PriceListBJDto : EntityDto<Guid>
{
/// <summary>
/// 零件号
/// 客户零件号
/// </summary>
[Display(Name = "零件号")]
[Display(Name = "客户零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
public Decimal Price { set; get; }
public decimal Price { get; set; }
/// <summary>
/// 开始时间
/// </summary>
[Display(Name = "开始时间")]
public DateTime BeginDate { set; get; }
/// <summary>
/// 结束时间
/// </summary>
[Display(Name = "结束时间")]
public DateTime EndDate { set; get; }
/// <summary>
/// 客户编码
@ -337,26 +215,57 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[Display(Name = "客户编码")]
public string ClientCode { get; set; }
}
/// <summary>
/// 合同签订时间
/// </summary>
[Display(Name = "合同签订时间")]
public DateTime Date { get; set; }
[Display(Name = "备件价格")]
public class PriceListBJExportDto
{
/// <summary>
/// 零件号
/// 合同号
/// </summary>
[Display(Name = "合同号")]
public string ContractNo { get; set; }
}
/// <summary>
/// 备件价格导出
/// </summary>
[Display(Name = "备件价格")]
public class PriceListBJExportDto
{
/// <summary>
/// 客户零件号
/// </summary>
[ExporterHeader(DisplayName = "零件号")]
[Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
[ExporterHeader(DisplayName = "价格")]
public decimal Price { get; set; }
/// <summary>
///客户编码
/// 开始时间
/// </summary>
[Display(Name = "开始时间")]
[ExporterHeader(DisplayName = "开始时间")]
public DateTime BeginDate { set; get; }
/// <summary>
/// 结束时间
/// </summary>
[Display(Name = "结束时间")]
[ExporterHeader(DisplayName = "结束时间")]
public DateTime EndDate { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
[ExporterHeader(DisplayName = "客户编码")]
public string ClientCode { get; set; }
@ -373,32 +282,53 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
[Display(Name = "合同号")]
[ExporterHeader(DisplayName = "合同号")]
public string ContractNo { get; set; }
}
}
[Importer(HeaderRowIndex = 22)]
public class PriceListBJImportDto
{
/// <summary>
/// 客户备件价格导入
/// </summary>
[Importer(HeaderRowIndex = 22)]
public class PriceListBJImportDto
{
/// <summary>
/// 零件号
/// 客户零件号
/// </summary>
[ImporterHeader(Name = "零件号")]
[Display(Name = "客户零件号")]
[ImporterHeader(Name = "Part No.")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[ImporterHeader(Name = "价格")]
[Display(Name = "客户零件号")]
[ImporterHeader(Name = "Total Price")]
public decimal Price { get; set; }
/// <summary>
///客户编码
/// 开始时间
/// </summary>
[Display(Name = "开始时间")]
[ImporterHeader(Name = "Valid From")]
public DateTime BeginDate { set; get; }
/// <summary>
/// 结束时间
/// </summary>
[Display(Name = "结束时间")]
[ImporterHeader(Name = "Valid To")]
public DateTime EndDate { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[ImporterHeader(Name = "客户编码")]
[Display(Name = "客户零件号")]
[ImporterHeader(Name = "Plant")]
public string ClientCode { get; set; }
/// <summary>
/// 合同签订时间
/// </summary>
[Display(Name = "客户零件号")]
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 1, Cell = 1)]
public string Date { get; set; }
@ -406,13 +336,14 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
/// <summary>
/// 合同号
/// </summary>
[Display(Name = "客户零件号")]
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 2, Cell = 1)]
public string ContractNo { get; set; }
}
}
public class PriceListBJRequestDto : RequestInputBase
{
public class PriceListBJRequestDto : RequestInputBase
{
[Display(Name = "开始时间")]
public DateTime BeginDate { get; set; }
[Display(Name = "结算时间")]
@ -431,14 +362,14 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public string Version { set; get; }
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
}
#endregion
}
#endregion
/// <summary>
/// 列表
/// </summary>
public class TB_PRICE_LISTDto : AuditedEntityDto<Guid>
{
/// <summary>
/// 列表
/// </summary>
public class TB_PRICE_LISTDto : AuditedEntityDto<Guid>
{
/// <summary>
/// 零件号
/// </summary>
@ -480,13 +411,13 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
/// </summary>
[Display(Name = "版本")]
public string Version { set; get; }
}
}
/// <summary>
/// 列表请求
/// </summary>
public class TB_PRICE_LIST_RequestDto : PagedAndSortedResultRequestDto
{
/// <summary>
/// 列表请求
/// </summary>
public class TB_PRICE_LIST_RequestDto : PagedAndSortedResultRequestDto
{
/// <summary>
/// 零件号
/// </summary>
@ -539,7 +470,5 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
/// 导出文件类型
/// </summary>
public int FileType { set; get; }
}
}

332
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;
/// <summary>
/// HBPO结算
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
{
/// <summary>
/// HBPO结算仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SA, Guid> _hbpoSaRepository;
/// <summary>
/// HBPO结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SA_DETAIL, Guid> _hbpoSaDetailRepository;
/// <summary>
/// HBPO可结算仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_CAN_SA, Guid> _hbpoCanSaRepository;
/// <summary>
/// HBPO可结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> _hbpoCanSaDetailRepository;
/// <summary>
/// HBPO不可结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> _hbpoNotSaDetailRepository;
/// <summary>
/// 销售价格仓储
/// </summary>
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository;
/// <summary>
/// 客户零件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<MaterialRelationship, Guid> _materialRelationshipRepository;
/// <summary>
/// 替换件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
/// <summary>
/// 构造
/// </summary>
public HBPO_SA_SERVICE(INormalEfCoreRepository<HBPO_SA, Guid> hbpoSaRepository,
INormalEfCoreRepository<HBPO_SA_DETAIL, Guid> hbpoSaDetailRepository,
INormalEfCoreRepository<HBPO_CAN_SA, Guid> hbpoCanSaRepository,
INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> hbpoCanSaDetailRepository,
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> hbpoNotSaDetailRepository,
INormalEfCoreRepository<PriceList, Guid> priceListRepository,
INormalEfCoreRepository<MaterialRelationship, Guid> materialRelationshipRepository,
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
IDistributedCache<HBPO_SA> 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 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
{
//业务类型
var businessType = EnumBusinessType.HBPO;
//数据校验
var checkList = new List<ErrorExportDto>();
//结算单号
var hbpoSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
//结算主表
var hbpoSa = new HBPO_SA()
{
BillNum = hbpoSaBillNum,
State = "1",
BusinessType = businessType
};
//结算明细
var hbpoSaDetails = new List<HBPO_SA_DETAIL>();
//可结算单号
var hbpoCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C");
//可结算主表
var hbpoCanSa = new HBPO_CAN_SA()
{
BillNum = hbpoCanSaBillNum,
SettleBillNum = hbpoSaBillNum,
State = SettleBillState.,
BusinessType = businessType
};
//可结算明细
var hbpoCanSaDetails = new List<HBPO_CAN_SA_DETAIL>();
//不可结算明细
var hbpoNotSaDetails = new List<HBPO_NOT_SA_DETAIL>();
//客户零件关系
var materialRelationships = new List<MaterialRelationship>();
#region 导入数据转换、数据校验
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<HBPO_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var importPubSaDetails = ObjectMapper.Map<List<HBPO_SA_DETAIL_IMPORT_DTO>, List<HBPO_SA_DETAIL>>(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<string> 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<HBPO_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL>>(hbpoSaDetailsCanSes);
//不可结算明细
hbpoNotSaDetails = ObjectMapper.Map<List<HBPO_SA_DETAIL>, List<HBPO_NOT_SA_DETAIL>>(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
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<HBPO_SA_DTO>> 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<HBPO_SA>, List<HBPO_SA_DTO>>(entities);
return new PagedResultDto<HBPO_SA_DTO>(totalCount, dtos);
}
/// <summary>
/// 删除
/// </summary>
[HttpPost]
public async Task DeleteAsync(Guid id)
{
//结算主表
HBPO_SA hbpoSaDelEntity;
//结算明细
List<HBPO_SA_DETAIL> hbpoSaDetailDelEntitys;
//可结算主表
List<HBPO_CAN_SA> hbpoCanSaDelEntitys;
//可结算明细
List<HBPO_CAN_SA_DETAIL> hbpoCanSaDetailDelEntitys;
//不可结算
List<HBPO_NOT_SA_DETAIL> 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
}

3
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;

3
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

28
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,15 +18,15 @@ 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;
/// <summary>
/// 采购价格单
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class PURCHASE_PRICE_SERVICE : SettleAccountApplicationBase<PURCHASE_PRICE>
{
/// <summary>
/// 采购价格单
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class PURCHASE_PRICE_SERVICE : SettleAccountApplicationBase<PURCHASE_PRICE>
{
/// <summary>
/// 采购价格单仓储
/// </summary>
@ -62,11 +62,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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)
@ -122,5 +121,4 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
#endregion
}
}

12
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;
}

29
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,15 +15,15 @@ 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;
/// <summary>
/// 期间设置
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl>
{
/// <summary>
/// 期间设置
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl>
{
/// <summary>
/// 期间设置仓储
/// </summary>
@ -430,9 +430,4 @@ namespace Win.Sfs.SettleAccount.Entities.Controls
// }
#endregion
}
}

4
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)

100
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -13,35 +13,49 @@ 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;
/// <summary>
/// 销售价格单
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class PriceListAppService : SettleAccountApplicationBase<PriceList>
{
/// <summary>
/// 销售价格单
/// 销售价格仓储
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class PriceListAppService : ApplicationService
{
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository;
private readonly PriceListManager _priceListManager;
private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
private readonly TaskJobService _service;
public PriceListAppService(
IExcelImportAppService excelImportService,
INormalEfCoreRepository<PriceList, Guid> priceListRepository,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
PriceListManager priceListManager,
TaskJobService service
)
TaskJobService service,
IDistributedCache<PriceList> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_priceListRepository = priceListRepository;
_mapRepository = mapRepository;
_excelImportService = excelImportService;
_priceListManager = priceListManager;
_service = service;
}
@ -57,42 +71,50 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
// return new Microsoft.AspNetCore.Mvc.OkResult();
//}
private string GetOtherSheetStringValue(IWorkbook wk, String sheetName, String location)
{
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;
}
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public virtual async Task<string> ImportAsync([FromForm] IFormFileCollection files, string version)
{
var checkList = new List<ErrorExportDto>();
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListImportDto>(files, _excelImportService);
List<string> _checkls = new List<string>();
_checkls.Add("1040");
_checkls.Add("1046");
_checkls.Add("104T");
result = result.Where(p => _checkls.Contains(p.Plant)).ToList();
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
var _ls = entityList.OrderByDescending(p => p.BeginTime).GroupBy(p => new { p.LU, p.ClientCode }).Select(p => p.FirstOrDefault());
entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList();
foreach (var itm in _ls)
#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)
{
itm.Update(GuidGenerator.Create(), version);
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"物料号:{item.LU},时间区间{item.BeginTime}-{item.EndTime}与系统数据存在时间交集", string.Empty));
}
}
await _priceListManager.ImportAsync(_ls.ToList(), version);
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
#endregion
foreach (var item in entityList)
{
item.Update(GuidGenerator.Create());
}
await _priceListManager.ImportAsync(entityList.ToList(), version);
return ApplicationConsts.SuccessStr;
}
@ -103,19 +125,10 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public virtual async Task<string> 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 entities = await _priceListManager.GetListAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtoDetails = ObjectMapper.Map<List<PriceList>, List<PriceListExportDto>>(entities);
string _fileName = string.Empty;
//声明导出容器
_fileName = string.Format("销售价格单_{0}.xlsx", Guid.NewGuid().ToString());
string fileName = string.Format("销售价格单_{0}.xlsx", Guid.NewGuid().ToString());
byte[] result = await _excel.ExportAsByteArray(dtoDetails);
result.ShouldNotBeNull();
@ -123,11 +136,11 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Name = fileName,
Content = result
}
);
return _fileName;
return fileName;
}
#endregion
@ -312,6 +325,5 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
// }
#endregion
}
}

37
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<string> ImportAsync([FromForm] IFormFileCollection files, string version)
{
var checkList = new List<ErrorExportDto>();
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PriceListBJImportDto>(files, _excelImportService);
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListBJImportDto>(files, _excelImportService);
List<string> _checkls = new List<string>();
_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<PriceListBJImportDto>, List<PriceListBJ>>(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;
}

33
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<PriceList, PriceListExportDto>();
CreateMap<PriceList, PriceListDto>().ReverseMap();
CreateMap<PriceList, PriceListRequestDto>().ReverseMap();
}
/// <summary>
/// 备件价格
/// </summary>
private void CreateMapPriceListBJ()
{
CreateMap<PriceListBJImportDto, PriceListBJ>()
.ForMember(x => x.Date, y => y.MapFrom(y => DateTime.ParseExact(y.Date, "dd.MM.yyyy", System.Globalization.CultureInfo.CurrentCulture)));
CreateMap<PriceListBJ, PriceListBJDto>().ReverseMap();
CreateMap<PriceListBJ, PriceListBJRequestDto>().ReverseMap();
CreateMap<PriceListBJ, PriceListBJImportDto>().ReverseMap();
CreateMap<PriceListBJ, PriceListBJExportDto>().ReverseMap();
}
@ -959,6 +964,28 @@ namespace Win.Sfs.SettleAccount
CreateMap<HBPO_SE_EDI, HBPO_SE_EDI_EXPORT_DTO>();
}
/// <summary>
/// HBPO结算
/// </summary>
private void CreateMapHBPO_SA()
{
CreateMap<HBPO_SA, HBPO_SA_DTO>();
}
/// <summary>
/// HBPO结算明细
/// </summary>
private void CreateMapHBPO_SA_DETAIL()
{
CreateMap<HBPO_SA_DETAIL, HBPO_CAN_SA_DETAIL>()
.ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum));
CreateMap<HBPO_SA_DETAIL, HBPO_NOT_SA_DETAIL>()
.ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum));
//CreateMap<HBPO_SA_DETAIL, HBPO_SA_DETAIL_EXPORT_DTO>();
CreateMap<HBPO_SA_DETAIL_IMPORT_DTO, HBPO_SA_DETAIL>();
}
/// <summary>
/// PUB发运单
/// </summary>

7
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<Guid>
[Display(Name = "业务类型")]
public EnumBusinessType BusinessType { get; set; }
public TB_RePartsRelationship()
{
}
public TB_RePartsRelationship(string lU, string repLU, string clientCode, EnumBusinessType businessType)
{
LU = lU;

25
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;

140
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
{
/// <summary>
/// 销售价格仓储
/// </summary>
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository;
private readonly ISettleAccountBranchEfCoreRepository<PriceList, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> _versionRepository;
protected PriceListManager() { }
public PriceListManager(
INormalEfCoreRepository<PriceList, Guid> priceListRepository,
ISettleAccountBranchEfCoreRepository<PriceList, Guid> repository,
ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> 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<List<string>> ImportAsync(List<PriceList> entities,string version)
/// <summary>
/// 导入
/// </summary>
public virtual async Task<List<string>> ImportAsync(List<PriceList> entities, string version)
{
List<string> _errorList = new List<string>();
//写校验在这里
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 lus = entities.Select(p => p.LU).ToList();
var pricelist = await _priceListRepository.GetListAsync(p => lus.Contains(p.LU));
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);
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);
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 }
//新零件号
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 itm3 in temp.DefaultIfEmpty()
where itm3 == null
select itm1;
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList());
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 _first = _versionRepository.FirstOrDefault(p => p.Version == version);
if (_first == null)
var add = addNewLu.Concat(addNewDate);
if (add.Any())
{
List<PriceListVersion> _versionList = new List<PriceListVersion>() { 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<PriceList> CreateAsync(PriceList input)
{
var entity = new PriceList(
@ -168,14 +174,21 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public class PriceListManagerBJ : DomainService
{
/// <summary>
/// 备件价格仓储
/// </summary>
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _priceListBJRepository;
private readonly ISettleAccountBranchEfCoreRepository<PriceListBJ, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<PriceListVersionBJ, Guid> _versionRepository;
protected PriceListManagerBJ() { }
public PriceListManagerBJ(
INormalEfCoreRepository<PriceListBJ, Guid> priceListBJRepository,
ISettleAccountBranchEfCoreRepository<PriceListBJ, Guid> repository,
ISettleAccountBranchEfCoreRepository<PriceListVersionBJ, Guid> versionRepository
)
{
_priceListBJRepository = priceListBJRepository;
_versionRepository = versionRepository;
_repository = repository;
}
@ -225,54 +238,51 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
return await _repository.GetCountByFilterAsync(branchId, p_filter);
}
/// <summary>
/// 导入
/// </summary>
public virtual async Task<List<string>> ImportAsync(List<PriceListBJ> entities, string version)
{
List<string> _errorList = new List<string>();
//写校验在这里
var pricelist = GetPriceList(version);
var lus = entities.Select(p => p.LU).ToList();
var pricelist = await _priceListBJRepository.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 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);
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 }
//新零件号
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 itm3 in temp.DefaultIfEmpty()
where itm3 == null
select itm1;
await _repository.GetDbContext().BulkInsertAsync<PriceListBJ>(add.ToList());
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 _first = _versionRepository.FirstOrDefault(p => p.Version == version);
if (_first == null)
var add = addNewLu.Concat(addNewDate);
if (add.Any())
{
List<PriceListVersionBJ> _versionList = new List<PriceListVersionBJ>() { 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<PriceListBJ> CreateAsync(PriceListBJ input)
{
var entity = new PriceListBJ(

20
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
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
/// <summary>
/// PUB二次比对仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSeCDetailRepository;
/// <summary>
/// Pub结算发运对比Dapper
/// </summary>
@ -56,11 +62,13 @@ namespace SettleAccount.Job.Services.Report
/// </summary>
public PubSaSeCompareExportService(
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository,
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository,
IBlobContainer<MyFileContainer> 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<PubSaSeCompareDiff>();
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<PubSaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
_pubSeCDetailRepository.InsertManyAsync(pubSeCDetailEntitys);
}
#endregion
if (string.IsNullOrEmpty(lu) == false)

3
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<PubSaSeCompareDiff, PubSaSeCompareDetailExport>()
.ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU));
CreateMap<PubSaSeCompareDiff, PUB_SEC_DETAIL>();
}
}
}

Loading…
Cancel
Save