From 2818c26274b3e93ad998b44b29ea1f520e712c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Sat, 19 Aug 2023 11:02:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Dtos/INVOICE_GRP_DTO.cs | 4 + .../Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs | 4 + .../Bases/ADJ_SERVICE.cs | 93 ++++++++++++++++--- 3 files changed, 88 insertions(+), 13 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs index 1a789a81..6e49217f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs @@ -463,6 +463,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public string LU1 { get; set; } + [Display(Name = "不可结算零件号")] + public string InvBillNum { get; set; } + + //[Display(Name = "不可结算零件号")] //public string LU1 { get; set; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs index 18a55fd1..c96fcb90 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; @@ -42,6 +43,9 @@ public class PUB_ADJ_DETAIL_DTO : EntityDto [Display(Name = "键值")] public string KeyCode { get; set; } + [Display(Name = "价格")] + public string Price { get; set; } + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs index 12d2d490..1f41e39f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs @@ -1,15 +1,18 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Linq.Dynamic.Core; using System.Text; using System.Threading.Tasks; using DocumentFormat.OpenXml.Bibliography; using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Wordprocessing; using EFCore.BulkExtensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using SettleAccount.Bases; using SettleAccount.Domain.BQ; using Volo.Abp; @@ -22,10 +25,12 @@ using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Temp; +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.RepositoryBase; +using static System.Runtime.CompilerServices.RuntimeHelpers; namespace Win.Sfs.SettleAccount.Bases; /// @@ -42,6 +47,8 @@ public class ADJ_SERVICE : BASE_SERVICE protected readonly INormalEfCoreRepository _bbacRepository; protected readonly INormalEfCoreRepository _pubRepository; protected readonly INormalEfCoreRepository _hbpoRepository; + protected readonly INormalEfCoreRepository _priceRepository; + protected readonly INormalEfCoreRepository _pricebjRepository; public ADJ_SERVICE( @@ -54,7 +61,9 @@ public class ADJ_SERVICE : BASE_SERVICE INormalEfCoreRepository relRepository, INormalEfCoreRepository bbacRepository, INormalEfCoreRepository pubRepository, - INormalEfCoreRepository hbpoRepository + INormalEfCoreRepository hbpoRepository, + INormalEfCoreRepository priceRepository, + INormalEfCoreRepository pricebjRepository ) : base(excelImportService, snowflakeIdGenerator, commonManager) @@ -65,7 +74,9 @@ public class ADJ_SERVICE : BASE_SERVICE _baseDomainService = baseDomainService; _bbacRepository = bbacRepository; _pubRepository = pubRepository; - _hbpoRepository= hbpoRepository; + _hbpoRepository = hbpoRepository; + _priceRepository = priceRepository; + _pricebjRepository = pricebjRepository; } /// ///查询明细 @@ -73,7 +84,7 @@ public class ADJ_SERVICE : BASE_SERVICE /// 明细查询条件 /// [HttpPost] - + public virtual async Task> DetailQueryAsync(PUB_ADJ_DETAIL_REQ_DTO input) { var entitys = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); @@ -193,11 +204,11 @@ public class ADJ_SERVICE : BASE_SERVICE { itm.KeyCode = itm.PN + itm.LU.Replace(" ", "").Trim(); } - var pnlist=p_list.Select(p => p.PN).Distinct(); - + var pnlist = p_list.Select(p => p.PN).Distinct(); + int flag = 0; var keylist = p_list.Select(p => p.KeyCode).Distinct(); List errorList = new List(); - var first=p_list.FirstOrDefault(); + var first = p_list.FirstOrDefault(); if (first != null) { var inv = _invRepository.Where(p => p.InvbillNum == first.InvBillNum).FirstOrDefault(); @@ -228,6 +239,7 @@ public class ADJ_SERVICE : BASE_SERVICE } break; case EnumBusinessType.BeiJian: + flag = 1; var errors3 = _pubRepository.Where(p => pnlist.Contains(p.PN)); foreach (var p in errors3) { @@ -238,18 +250,18 @@ public class ADJ_SERVICE : BASE_SERVICE var errors4 = _bbacRepository.Where(p => keylist.Contains(p.KeyCode)); foreach (var p in errors4) { - errorList.Add(new ERR_EXP_DTO() {Message=$"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); + errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); } break; case EnumBusinessType.JisHBPO: - var errors5=_hbpoRepository.Where(p => keylist.Contains(p.KeyCode)); + var errors5 = _hbpoRepository.Where(p => keylist.Contains(p.KeyCode)); foreach (var p in errors5) { errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); } break; case EnumBusinessType.YinDuJian: - var errors6=_pubRepository.Where(p => pnlist.Contains(p.PN)); + var errors6 = _pubRepository.Where(p => pnlist.Contains(p.PN)); foreach (var p in errors6) { errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在发货单{p.PN}数据,不能导入调整表" }); @@ -259,7 +271,7 @@ public class ADJ_SERVICE : BASE_SERVICE } } - + var entityList = ObjectMapper.Map, List>(p_list); var codelist = entityList.Select(p => p.LU).ToList(); var errors = await _baseDomainService.CheckBase(codelist, new BASE_CONF() { IsRelationShip = true }); @@ -279,10 +291,65 @@ public class ADJ_SERVICE : BASE_SERVICE if (errorList.Count > 0) { return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) }); - + + } + List ls = new List(); + if (flag == 1) + { + var pricebjlist = _pricebjRepository.ToList(); + + + var inner = from d in p_list + join p in pricebjlist on d.LU equals p.LU + where + d.SettleDate >= p.BeginDate && d.SettleDate <= p.EndDate + select + new PUB_ADJ_DETAIL_DTO() + { + InvBillNum = d.InvBillNum, + SettleDate = d.SettleDate, + LU = d.LU, + PN = d.PN, + Qty = d.Qty, + GroupNum = d.GroupNum, + KeyCode = d.KeyCode, + Price = d.Price, + }; + + ls = inner.ToList(); + } + else + { + var pricelist = _priceRepository.ToList(); + + + var inner = from d in p_list + join p in pricelist on d.LU equals p.LU + where + d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime + select new PUB_ADJ_DETAIL_DTO() + { + InvBillNum = d.InvBillNum, + SettleDate = d.SettleDate, + LU = d.LU, + PN = d.PN, + Qty = d.Qty, + GroupNum = d.GroupNum, + KeyCode = d.KeyCode, + Price = d.Price, + }; + ls = inner.ToList(); + } - - return new JsonResult(new { Code = 200, Message = "校验成功" }); ; + + + + + + + + + return new JsonResult(new { Code = 200, Message =ls }); ; } }