mahao
1 year ago
23 changed files with 2086 additions and 1606 deletions
@ -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; } |
|||
} |
@ -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; } |
|||
} |
|||
|
@ -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; } |
|||
} |
|||
|
@ -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; } |
|||
} |
|||
|
File diff suppressed because it is too large
@ -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
|
|||
} |
Loading…
Reference in new issue