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. 98
      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. 151
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomDto.cs
  5. 103
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs
  6. 28
      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. 995
      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. 176
      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. 793
      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. 526
      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. 146
      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; }
}

98
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;
/// <summary>
/// 采购价格单
/// </summary>
public class PURCHASE_PRICE_DTO : EntityDto<Guid>
{
/// <summary>
/// 采购价格单
/// 零件号
/// </summary>
public class PURCHASE_PRICE_DTO : EntityDto<Guid>
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
public decimal Price { get; set; }
}
[Display(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 导入
/// 价格
/// </summary>
public class PURCHASE_PRICE_IMPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ImporterHeader(Name = "零件号")]
public string LU { get; set; }
[Display(Name = "价格")]
public decimal Price { get; set; }
}
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
[ImporterHeader(Name = "价格")]
public decimal Price { get; set; }
}
/// <summary>
/// 导入
/// </summary>
public class PURCHASE_PRICE_IMPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 导出
/// 价格
/// </summary>
public class PURCHASE_PRICE_EXPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "零件号")]
public string LU { get; set; }
[Display(Name = "价格")]
[ImporterHeader(Name = "价格")]
public decimal Price { get; set; }
}
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
[ExporterHeader(DisplayName = "价格")]
public decimal Price { get; set; }
}
/// <summary>
/// 导出
/// </summary>
public class PURCHASE_PRICE_EXPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[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; }
}
}

151
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<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; }
[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; }
/// <summary>
/// 工厂
/// </summary>
public string Factory { set; get; }
}
}
/// <summary>
/// Bom
/// </summary>
public class BomDto : EntityDto<Guid>
{
/// <summary>
/// 父物料编码
/// </summary>
[Display(Name = "父物料编码")]
public string ParentItemCode { get; set; }
/// <summary>
/// 父物料描述
/// </summary>
[Display(Name = "父物料描述")]
public string ParentItemDesc { get; set; }
/// <summary>
/// 组件编码
/// </summary>
[Display(Name = "组件编码")]
public string ChildItemCode { get; set; }
/// <summary>
/// 组件描述
/// </summary>
[Display(Name = "组件描述")]
public string ChildItemDesc { get; set; }
/// <summary>
/// 组件计量单位
/// </summary>
[Display(Name = "组件计量单位")]
public string ChildItemUom { get; set; }
/// <summary>
/// 组件数量
/// </summary>
[Display(Name = "组件数量")]
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; }
/// <summary>
/// 子物品消耗位置
/// </summary>
[Display(Name = "子物品消耗位置")]
public string IssuePosition { get; set; }
/// <summary>
/// 结构层级
/// </summary>
[Display(Name = "结构层级")]
public int BomLevel { get; set; }
}

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

28
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
{
@ -124,7 +124,7 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
/// <summary>
/// 厂内物料描述
/// </summary>
[ExporterHeaderAttribute(DisplayName = "厂内物料描述")]
[ExporterHeaderAttribute(DisplayName = "厂内物料描述")]
public string MaterialDesc { get; set; }
/// <summary>
@ -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; }
}
/// <summary>
/// 客户零件关系导入
/// </summary>
[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>
@ -386,4 +378,4 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
}
}

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
}
/// <summary>
/// 导出
/// </summary>
public class MaterialExportDto
{
/// <summary>
/// 客户物料号
/// </summary>
[ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { set; get; }
/// <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; }
}
}

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

File diff suppressed because it is too large

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

176
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;
/// <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>
private readonly INormalEfCoreRepository<PURCHASE_PRICE, Guid> _repository;
public PURCHASE_PRICE_SERVICE(
INormalEfCoreRepository<PURCHASE_PRICE, Guid> repository,
IDistributedCache<PURCHASE_PRICE> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
/// <summary>
/// 采购价格单仓储
/// </summary>
private readonly INormalEfCoreRepository<PURCHASE_PRICE, Guid> _repository;
_repository = repository;
}
public PURCHASE_PRICE_SERVICE(
INormalEfCoreRepository<PURCHASE_PRICE, Guid> repository,
IDistributedCache<PURCHASE_PRICE> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_repository = repository;
}
#region 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PURCHASE_PRICE_IMPORT_DTO>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<PURCHASE_PRICE_IMPORT_DTO>, List<PURCHASE_PRICE>>(result);
List<string> _errorList = new List<string>();
var checkList = new List<ErrorExportDto>();
#region 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
if (_ls.Count > 0)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PURCHASE_PRICE_IMPORT_DTO>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<PURCHASE_PRICE_IMPORT_DTO>, List<PURCHASE_PRICE>>(result);
List<string> _errorList = new List<string>();
var checkList = new List<ErrorExportDto>();
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;
}
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> 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<PURCHASE_PRICE>, List<PURCHASE_PRICE_EXPORT_DTO>>(entities);
return await ExportErrorReportAsync(checkList);
}
return ApplicationConsts.SuccessStr;
}
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> 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<PURCHASE_PRICE>, List<PURCHASE_PRICE_EXPORT_DTO>>(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
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<PURCHASE_PRICE_DTO>> 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<PURCHASE_PRICE>, List<PURCHASE_PRICE_DTO>>(entities);
return new PagedResultDto<PURCHASE_PRICE_DTO>(totalCount, dtos);
}
#endregion
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
#region CURD
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<PURCHASE_PRICE_DTO>> 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<PURCHASE_PRICE>, List<PURCHASE_PRICE_DTO>>(entities);
return new PagedResultDto<PURCHASE_PRICE_DTO>(totalCount, dtos);
}
#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;
}

793
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;
/// <summary>
/// 期间设置
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl>
{
/// <summary>
/// 期间设置
/// 期间设置仓储
/// </summary>
private readonly INormalEfCoreRepository<CentralizedControl, Guid> _repository;
/// <summary>
/// 构造
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl>
public CentralizedControlAppService(
INormalEfCoreRepository<CentralizedControl, Guid> repository,
IDistributedCache<CentralizedControl> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
/// <summary>
/// 期间设置仓储
/// </summary>
private readonly INormalEfCoreRepository<CentralizedControl, Guid> _repository;
/// <summary>
/// 构造
/// </summary>
public CentralizedControlAppService(
INormalEfCoreRepository<CentralizedControl, Guid> repository,
IDistributedCache<CentralizedControl> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_repository = repository;
}
_repository = repository;
}
#region 导出
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> 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<CentralizedControl>, List<CentralizedControlExportDto>>(entities);
#region 导出
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> 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<CentralizedControl>, List<CentralizedControlExportDto>>(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
/// <summary>
/// 获取全部
/// </summary>
[HttpPost]
public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync()
{
var entities = await _repository.GetAllAsync(true);
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities);
return new ListResultDto<CentralizedControlDto>(dtos);
}
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<CentralizedControlDto>> 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<CentralizedControl>, List<CentralizedControlDto>>(entities);
return new PagedResultDto<CentralizedControlDto>(totalCount, dtos);
}
#region CURD
/// <summary>
/// 获取全部
/// </summary>
[HttpPost]
public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync()
{
var entities = await _repository.GetAllAsync(true);
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities);
return new ListResultDto<CentralizedControlDto>(dtos);
}
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<CentralizedControlDto>> 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<CentralizedControl>, List<CentralizedControlDto>>(entities);
return new PagedResultDto<CentralizedControlDto>(totalCount, dtos);
}
/// <summary>
/// 添加
/// </summary>
[HttpPost]
public async Task<CentralizedControlDto> CreateAsync(CentralizedControlCreateDto input)
{
var _first = _repository.Where(p => p.Version == input.Version).FirstOrDefault();
/// <summary>
/// 添加
/// </summary>
[HttpPost]
public async Task<CentralizedControlDto> 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<CentralizedControl, CentralizedControlDto>(entity);
return dto;
var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(entity);
return dto;
}
}
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
public async Task DeleteAsync(Guid id)
{
var entity = await _repository.GetAsync(id);
await _repository.DeleteAsync(id);
}
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
public async Task DeleteAsync(Guid id)
{
var entity = await _repository.GetAsync(id);
await _repository.DeleteAsync(id);
}
/// <summary>
/// 按IDs删除实体列表
/// </summary>
[HttpPost]
public async Task<bool> DeleteListAsync(List<Guid> ids)
{
var _query = _repository.Where(p => ids.Contains(p.Id));
int i = await _query.BatchDeleteAsync();
/// <summary>
/// 按IDs删除实体列表
/// </summary>
[HttpPost]
public async Task<bool> DeleteListAsync(List<Guid> ids)
{
var _query = _repository.Where(p => ids.Contains(p.Id));
int i = await _query.BatchDeleteAsync();
return i == 0;
}
#endregion
return i == 0;
}
#endregion
#region 开启、关闭
/// <summary>
/// 开启版本
/// </summary>
[HttpPost]
public async Task<bool> OpenVersion(List<Guid> ids)
#region 开启、关闭
/// <summary>
/// 开启版本
/// </summary>
[HttpPost]
public async Task<bool> OpenVersion(List<Guid> 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;
}
/// <summary>
/// 关闭版本
/// </summary>
[HttpPost]
public async Task<bool> ClosedVersion(List<Guid> ids)
/// <summary>
/// 关闭版本
/// </summary>
[HttpPost]
public async Task<bool> ClosedVersion(List<Guid> 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 原方法(废弃)
// /// <summary>
// /// 导入功能
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <returns></returns>
// [HttpPost]
// [Route("ExcelImport")]
// [DisableRequestSizeLimit]
// [Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// public async Task<string> CentralizedControlUploadExcelImport([FromForm] IFormFileCollection files,Guid branchId)
// {
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.UploadExcelImport<CentralizedControlImportDto>(files, _excelImportService);
// var _ls = ObjectMapper.Map<List<CentralizedControlImportDto>, List<CentralizedControl>>(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;
// }
// /// <summary>
// /// 按ID获取唯一实体
// /// </summary>
// /// <remarks>
// /// 返回实体全部属性
// /// </remarks>
// /// <param name="id">ID</param>
// /// <returns>实体DTO</returns>
// [HttpGet]
// [Route("{id}")]
// virtual public async Task<CentralizedControlDto> GetAsync(Guid id)
// {
// var result = await GetFromCacheAsync(id);
// var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(result);
// return dto;
// }
// private async Task<CentralizedControl> GetFromCacheAsync(Guid id)
// {
// var result =
// await _repository.GetAsync(id);
// return result;
// }
// private async Task<long> GetCountAsync(CentralizedControlRequestDto input)
// {
// return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
// }
// ///// <summary>
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// [HttpPost]
// [Route("list")]
// virtual public async Task<PagedResultDto<CentralizedControlDto>> 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<CentralizedControl>, List<CentralizedControlDto>>(entities);
// return new PagedResultDto<CentralizedControlDto>(totalCount, dtos);
// }
// /// <summary>
// /// 获取实体总数
// /// </summary>
// /// <returns>实体总数</returns>
// [HttpGet]
// [Route("count")]
// virtual public async Task<long> GetTotalCountAsync(Guid branchId)
// {
// return await _repository.GetCountAsync(branchId);
// }
// /// <summary>
// /// 获取全部实体列表
// /// </summary>
// /// <returns>实体DTO列表</returns>
// [HttpGet]
// [Route("all")]
// virtual public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync(Guid branchId)
// {
// var entities = await _repository.GetAllAsync(branchId, true);
// var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities);
// return new ListResultDto<CentralizedControlDto>(dtos);
// }
// /// <summary>
// /// 新增实体
// /// </summary>
// /// <param name="input">新增实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPost]
// [Route("")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// virtual public async Task<CentralizedControlDto> 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<CentralizedControl, CentralizedControlDto>(entity);
// return dto;
// }
// /// <summary>
// /// 修改实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <param name="input">修改实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPut]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Update)]
// virtual public async Task<CentralizedControlDto> 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<CentralizedControl, CentralizedControlDto>(entity);
// return dto;
// }
// /// <summary>
// /// 删除实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <returns>无</returns>
// [HttpDelete]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
// virtual public async Task DeleteAsync(Guid id)
// {
// var entity = await GetFromCacheAsync(id);
// await Cache.DeleteAsync<CentralizedControl>(id.ToString());
// await _repository.DeleteAsync(id);
// }
// /// <summary>
// /// 按IDs删除实体列表
// /// </summary>
// /// <param name="ids">IDs</param>
// /// <returns>是否执行成功</returns>
// [HttpPost]
// [Route("delete")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
// virtual public async Task<bool> DeleteListAsync(List<Guid> 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<bool> OpenVersion(List<Guid> ids)
// {
// foreach (var id in ids)
// {
// var _entity = await _repository.GetAsync(id);
// _entity.OpenVersion();
// }
// return true;
// }
// [HttpPost]
// [Route("close")]
// [Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// /// <summary>
// /// 关闭版本
// /// </summary>
// /// <param name="ids">选择要关闭的ID</param>
// /// <returns></returns>
// public async Task<bool> ClosedVersion(List<Guid> ids)
// {
// foreach (var id in ids)
// {
// var _entity = await _repository.GetAsync(id);
// _entity.ClosedVersion();
// }
// return true;
// }
// [HttpPost]
// [Route("openlist")]
// /// <summary>
// /// 获得开放的版本列表
// /// </summary>
// /// <returns></returns>
// public async Task<List<CentralizedControlDto>> GetOpenVersionList()
// {
// var _list = await _repository.Where(p => p.State == 0).ToListAsync();
// var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(_list);
// return dtos;
// }
#endregion
return true;
}
#endregion
#region 原方法(废弃)
// /// <summary>
// /// 导入功能
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <returns></returns>
// [HttpPost]
// [Route("ExcelImport")]
// [DisableRequestSizeLimit]
// [Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// public async Task<string> CentralizedControlUploadExcelImport([FromForm] IFormFileCollection files,Guid branchId)
// {
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.UploadExcelImport<CentralizedControlImportDto>(files, _excelImportService);
// var _ls = ObjectMapper.Map<List<CentralizedControlImportDto>, List<CentralizedControl>>(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;
// }
// /// <summary>
// /// 按ID获取唯一实体
// /// </summary>
// /// <remarks>
// /// 返回实体全部属性
// /// </remarks>
// /// <param name="id">ID</param>
// /// <returns>实体DTO</returns>
// [HttpGet]
// [Route("{id}")]
// virtual public async Task<CentralizedControlDto> GetAsync(Guid id)
// {
// var result = await GetFromCacheAsync(id);
// var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(result);
// return dto;
// }
// private async Task<CentralizedControl> GetFromCacheAsync(Guid id)
// {
// var result =
// await _repository.GetAsync(id);
// return result;
// }
// private async Task<long> GetCountAsync(CentralizedControlRequestDto input)
// {
// return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
// }
// ///// <summary>
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// [HttpPost]
// [Route("list")]
// virtual public async Task<PagedResultDto<CentralizedControlDto>> 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<CentralizedControl>, List<CentralizedControlDto>>(entities);
// return new PagedResultDto<CentralizedControlDto>(totalCount, dtos);
// }
// /// <summary>
// /// 获取实体总数
// /// </summary>
// /// <returns>实体总数</returns>
// [HttpGet]
// [Route("count")]
// virtual public async Task<long> GetTotalCountAsync(Guid branchId)
// {
// return await _repository.GetCountAsync(branchId);
// }
// /// <summary>
// /// 获取全部实体列表
// /// </summary>
// /// <returns>实体DTO列表</returns>
// [HttpGet]
// [Route("all")]
// virtual public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync(Guid branchId)
// {
// var entities = await _repository.GetAllAsync(branchId, true);
// var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities);
// return new ListResultDto<CentralizedControlDto>(dtos);
// }
// /// <summary>
// /// 新增实体
// /// </summary>
// /// <param name="input">新增实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPost]
// [Route("")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// virtual public async Task<CentralizedControlDto> 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<CentralizedControl, CentralizedControlDto>(entity);
// return dto;
// }
// /// <summary>
// /// 修改实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <param name="input">修改实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPut]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Update)]
// virtual public async Task<CentralizedControlDto> 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<CentralizedControl, CentralizedControlDto>(entity);
// return dto;
// }
// /// <summary>
// /// 删除实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <returns>无</returns>
// [HttpDelete]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
// virtual public async Task DeleteAsync(Guid id)
// {
// var entity = await GetFromCacheAsync(id);
// await Cache.DeleteAsync<CentralizedControl>(id.ToString());
// await _repository.DeleteAsync(id);
// }
// /// <summary>
// /// 按IDs删除实体列表
// /// </summary>
// /// <param name="ids">IDs</param>
// /// <returns>是否执行成功</returns>
// [HttpPost]
// [Route("delete")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
// virtual public async Task<bool> DeleteListAsync(List<Guid> 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<bool> OpenVersion(List<Guid> ids)
// {
// foreach (var id in ids)
// {
// var _entity = await _repository.GetAsync(id);
// _entity.OpenVersion();
// }
// return true;
// }
// [HttpPost]
// [Route("close")]
// [Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// /// <summary>
// /// 关闭版本
// /// </summary>
// /// <param name="ids">选择要关闭的ID</param>
// /// <returns></returns>
// public async Task<bool> ClosedVersion(List<Guid> ids)
// {
// foreach (var id in ids)
// {
// var _entity = await _repository.GetAsync(id);
// _entity.ClosedVersion();
// }
// return true;
// }
// [HttpPost]
// [Route("openlist")]
// /// <summary>
// /// 获得开放的版本列表
// /// </summary>
// /// <returns></returns>
// public async Task<List<CentralizedControlDto>> GetOpenVersionList()
// {
// var _list = await _repository.Where(p => p.State == 0).ToListAsync();
// var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(_list);
// return dtos;
// }
#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)

526
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;
/// <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 ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
private readonly TaskJobService _service;
public PriceListAppService(
INormalEfCoreRepository<PriceList, Guid> priceListRepository,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
PriceListManager priceListManager,
TaskJobService service,
IDistributedCache<PriceList> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
private readonly PriceListManager _priceListManager;
private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
private readonly TaskJobService _service;
public PriceListAppService(
IExcelImportAppService excelImportService,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
PriceListManager priceListManager,
TaskJobService service
)
{
_mapRepository = mapRepository;
_excelImportService = excelImportService;
_priceListManager = priceListManager;
_service = service;
}
#region 导入、导出
///// <summary>
///// 获取导入模板
///// </summary>
//[HttpPost("import-template")]
//public virtual async Task<IActionResult> ImportTemplateAsync()
//{
// await Task.CompletedTask;
// return new Microsoft.AspNetCore.Mvc.OkResult();
//}
_priceListRepository = priceListRepository;
_mapRepository = mapRepository;
_priceListManager = priceListManager;
_service = service;
}
#region 导入、导出
///// <summary>
///// 获取导入模板
///// </summary>
//[HttpPost("import-template")]
//public virtual async Task<IActionResult> ImportTemplateAsync()
//{
// await Task.CompletedTask;
// return new Microsoft.AspNetCore.Mvc.OkResult();
//}
private string GetOtherSheetStringValue(IWorkbook wk, String sheetName, String location)
/// <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);
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
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public virtual async Task<string> ImportAsync([FromForm] IFormFileCollection files, string version)
foreach (var item in entityList)
{
ExportImporter _exportImporter = new ExportImporter();
item.Update(GuidGenerator.Create());
}
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListImportDto>(files, _excelImportService);
await _priceListManager.ImportAsync(entityList.ToList(), version);
return ApplicationConsts.SuccessStr;
}
List<string> _checkls = new List<string>();
_checkls.Add("1040");
_checkls.Add("1046");
_checkls.Add("104T");
/// <summary>
/// 导出
/// </summary>
[HttpPost]
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 dtoDetails = ObjectMapper.Map<List<PriceList>, List<PriceListExportDto>>(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
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public virtual async Task<PagedResultDto<TB_PRICE_LISTDto>> 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<PriceList>, List<TB_PRICE_LISTDto>>(entitys);
return new PagedResultDto<TB_PRICE_LISTDto>(totalCount, dtos);
}
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());
/// <summary>
/// 删除
/// </summary>
[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;
}
/// <summary>
/// 批量删除
/// </summary>
[HttpPost]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
return await _priceListManager.DeleteListAsync(ids);
}
#endregion
/// <summary>
/// 导出
/// </summary>
[HttpPost]
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 dtoDetails = ObjectMapper.Map<List<PriceList>, List<PriceListExportDto>>(entities);
#region 原方法(废弃)
// /// <summary>
// /// 获取总数
// /// </summary>
// private async Task<long> 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();
// /// <summary>
// /// 结算总成和ERP总成价格对比
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <returns></returns>
// [HttpGet]
// [Route("BomDiffPrice-Make")]
// [DisableRequestSizeLimit]
// [Authorize(SettleAccountPermissions.PriceLists.Default)]
// public async Task<string> SettledPartAndErpPartPriceDiffMake(string version, string customerCode)
// {
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}
#endregion
// List<CustomCondition> customConditionList = new List<CustomCondition>();
#region CURD
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
public virtual async Task<PagedResultDto<TB_PRICE_LISTDto>> 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<PriceList>, List<TB_PRICE_LISTDto>>(entitys);
return new PagedResultDto<TB_PRICE_LISTDto>(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<List<JobDto>> GetListAsync(JobRequestDto input)
// {
// return await _service.GetListAsync(input);
// }
/// <summary>
/// 删除
/// </summary>
[HttpPost]
virtual public async Task DeleteAsync(Guid id)
{
await _priceListManager.DeleteAsync(id);
}
// /// <summary>
// /// 按ID获取唯一实体
// /// </summary>
// /// <remarks>
// /// 返回实体全部属性
// /// </remarks>
// /// <param name="id">ID</param>
// /// <returns>实体DTO</returns>
/// <summary>
/// 批量删除
/// </summary>
[HttpPost]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
return await _priceListManager.DeleteListAsync(ids);
}
#endregion
// [HttpGet]
// [Route("{id}")]
// /// [Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<PriceListDto> GetAsync(Guid id)
// {
// var result = await _priceListManager.GetAsync(id); ;
// var dto = ObjectMapper.Map<PriceList, PriceListDto>(result);
// return dto;
// }
#region 原方法(废弃)
// /// <summary>
// /// 获取总数
// /// </summary>
// private async Task<long> GetCountAsync(PriceListRequestDto input)
// {
// return await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create());
// }
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// [HttpPost]
// [Route("versionlist")]
//// [Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<PagedResultDto<PriceListVersionDto>> GetVersionListAsync(PriceListRequestDto input)
// {
// /// <summary>
// /// 结算总成和ERP总成价格对比
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <returns></returns>
// [HttpGet]
// [Route("BomDiffPrice-Make")]
// [DisableRequestSizeLimit]
// [Authorize(SettleAccountPermissions.PriceLists.Default)]
// public async Task<string> SettledPartAndErpPartPriceDiffMake(string version, string customerCode)
// {
// List<CustomCondition> customConditionList = new List<CustomCondition>();
// var entities = await _priceListManager.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount);
// var totalCount = await GetCountAsync(input);
// var dtos = ObjectMapper.Map<List<PriceListVersion>, List<PriceListVersionDto>>(entities);
// return new PagedResultDto<PriceListVersionDto>(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<List<JobDto>> GetListAsync(JobRequestDto input)
// {
// return await _service.GetListAsync(input);
// }
// /// <summary>
// /// 按ID获取唯一实体
// /// </summary>
// /// <remarks>
// /// 返回实体全部属性
// /// </remarks>
// /// <param name="id">ID</param>
// /// <returns>实体DTO</returns>
// [HttpGet]
// [Route("{id}")]
// /// [Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<PriceListDto> GetAsync(Guid id)
// {
// var result = await _priceListManager.GetAsync(id); ;
// var dto = ObjectMapper.Map<PriceList, PriceListDto>(result);
// return dto;
// }
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// [HttpPost]
// [Route("versionlist")]
//// [Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<PagedResultDto<PriceListVersionDto>> 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<PriceListVersion>, List<PriceListVersionDto>>(entities);
// return new PagedResultDto<PriceListVersionDto>(totalCount, dtos);
// }
// /// <summary>
// /// 获取实体总数
// /// </summary>
// /// <returns>实体总数</returns>
// [HttpGet]
// [Route("count")]
// //[Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<long> GetTotalCountAsync(Guid branchId)
// {
// return await _priceListManager.GetCountAsync(new List<FilterCondition>(), branchId);
// }
// /// <summary>
// /// 获取全部实体列表
// /// </summary>
// /// <returns>实体DTO列表</returns>
// [HttpGet]
// [Route("all")]
// //[Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<ListResultDto<PriceListDto>> GetAllAsync(Guid branchId)
// {
// var entities = await _priceListManager.GetAllAsync(branchId);
// var dtos = ObjectMapper.Map<List<PriceList>, List<PriceListDto>>(entities);
// return new ListResultDto<PriceListDto>(dtos);
// }
// /// <summary>
// /// 修改实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <param name="input">修改实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPut]
// [Route("{id}")]
// [Authorize(SettleAccountPermissions.PriceLists.Update)]
// virtual public async Task<PriceListDto> UpdateAsync(Guid id, PriceListDto input)
// {
// var entity = new PriceList(
// );
// var _ent = await _priceListManager.UpdateAsync(id, entity);
// var dto = ObjectMapper.Map<PriceList, PriceListDto>(_ent);
// return dto;
// }
#endregion
}
// /// <summary>
// /// 获取实体总数
// /// </summary>
// /// <returns>实体总数</returns>
// [HttpGet]
// [Route("count")]
// //[Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<long> GetTotalCountAsync(Guid branchId)
// {
// return await _priceListManager.GetCountAsync(new List<FilterCondition>(), branchId);
// }
// /// <summary>
// /// 获取全部实体列表
// /// </summary>
// /// <returns>实体DTO列表</returns>
// [HttpGet]
// [Route("all")]
// //[Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<ListResultDto<PriceListDto>> GetAllAsync(Guid branchId)
// {
// var entities = await _priceListManager.GetAllAsync(branchId);
// var dtos = ObjectMapper.Map<List<PriceList>, List<PriceListDto>>(entities);
// return new ListResultDto<PriceListDto>(dtos);
// }
// /// <summary>
// /// 修改实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <param name="input">修改实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPut]
// [Route("{id}")]
// [Authorize(SettleAccountPermissions.PriceLists.Update)]
// virtual public async Task<PriceListDto> UpdateAsync(Guid id, PriceListDto input)
// {
// var entity = new PriceList(
// );
// var _ent = await _priceListManager.UpdateAsync(id, entity);
// var dto = ObjectMapper.Map<PriceList, PriceListDto>(_ent);
// return dto;
// }
#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;

146
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 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<PriceList>(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<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 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<PriceListBJ>(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<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