From d4f771af6aa2a5d300e58ee0f167b56b58cf5af1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com>
Date: Tue, 19 Sep 2023 11:32:25 +0800
Subject: [PATCH 1/2] =?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       | 112 ++++++++++++++----
 .../Bases/BA_SERVICE.cs                       |   2 +-
 .../Bases/PD_SERVICE.cs                       |  74 +++++++++++-
 .../Entities/BQ/BBAC_PD_SERVICE.cs            |  28 ++---
 .../Entities/BQ/HBPO_BA_SERVICE.cs            |   7 +-
 .../Entities/BQ/HBPO_PD_SERVICE.cs            |  29 ++---
 .../Entities/BQ/INVOICE_SERVICE.cs            |  96 +++++++++++----
 .../Entities/BQ/PUB_BA_SERVICE.cs             |   8 +-
 .../Entities/BQ/PUB_PD_SERVICE.cs             |  29 ++---
 .../BQ/Syncs/PendingDeductionService.cs       |  10 +-
 .../Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs   |   5 +-
 .../Entities/BQ/Managers/INV_MNG.cs           |  72 ++++++-----
 .../src/SettleAccount.Domain/EnumBillState.cs |   4 +-
 13 files changed, 302 insertions(+), 174 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 4e967ff6..15107410 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
@@ -246,13 +246,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
         public List<INVOICE_WAIT_DETAIL_BBAC_DTO> INVOICE_WAIT_DETAIL_BBAC { get; set; }
 
 
-
+        /// <summary>
+        /// 发票明细备件
+        /// </summary>
         public List<INVOICE_WAIT_DETAIL_BJ_DTO> INVOICE_WAIT_DETAIL_BJ { get; set; }
 
         /// <summary>
         /// 发票和结算分组对应关系
         /// </summary>
         public List<INVOICE_MAP_GROUP_DTO> INVOICE_MAP_GROUP { get; set; }
+
+        /// <summary>
+        /// 买单发票和结算分组对应关系
+        /// </summary>
+        public List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO> MAIDAN_HBPO_INVOICE_MAP_GROUP { get; set; }
+
+
         /// <summary>
         /// 已结分组包含不可结算零件
         /// </summary>
@@ -261,22 +270,45 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
         /// 发票调整明细
         /// </summary>
         public List<PUB_ADJ_DETAIL_DTO> ADJ_DETAIL { get; set; }
+        /// <summary>
+        /// JIT全部未结明细
+        /// </summary>
+        public List<JIT_UNSETTLED_DETAIL_DTO> JIT_UNSETTLED_DETAIL { get; set; }
 
+        /// <summary>
+        /// JIT全部未结明细
+        /// </summary>
+        public List<MAIDAN_HBPO_UNSETTLED_DETAIL_DTO> MAIDAN_HBPO_UNSETTLED_DETAIL { get; set; }
 
         /// <summary>
-        /// 全部未结明细
+        /// JIT全部未结明细
         /// </summary>
-        public List<UNSETTLED_DETAIL_DTO> UNSETTLED_DETAIL { get; set; }
+        public List<JIT_UNSETTLED_DETAIL_DTO> UNSETTLED_DETAIL { get; set; }
 
 
 
+    }
+    public class JIT_UNSETTLED_DETAIL_DTO
+    {
+        [Display(Name ="结算分组号")]
+        public string GroupNum { set; get; }
+
+        [Display(Name = "零件号")]
+        public string LU { set; get; }
+        [Display(Name = "数量")]
+        public decimal Qty { set; get; }
 
 
     }
-    public class UNSETTLED_DETAIL_DTO
+    public class MAIDAN_HBPO_UNSETTLED_DETAIL_DTO
     {
-        [Display(Name ="结算分组号")]
+        [Display(Name = "五联单号")]
         public string GroupNum { set; get; }
+
+        [Display(Name = "生产码")]
+        public string PN { set; get; }
+
+
         [Display(Name = "零件号")]
         public string LU { set; get; }
         [Display(Name = "数量")]
@@ -287,33 +319,49 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
 
 
 
+
+
+
+
+
+
+
     public class INVOICE_WAIT_DETAIL_BJ_DTO
     {
-        ///// <summary>
-        /////期间
-        ///// </summary>
-        //[Display(Name = "行号")]
-        //public int LineCode { get; set; }
-        /// <summary>
-        ///期间
-        /// </summary>
-        [Display(Name = "期间")]
+      
         public int Version { get; set; }
         [Display(Name = "金税发票号")]
         public string RealInvbillNum { get; set; }
         [Display(Name = "发票日期")]
         public DateTime? InvDate { set; get; }
-
         /// <summary>
         ///扩展字段1
         /// </summary>
         [Display(Name = "凭证号")]
         public string Extend1 { get; set; }
+
+        [Display(Name = "交货号")]
+        public string DeliveryNumber { get; set; }
         /// <summary>
         ///发票号
         /// </summary>
         [Display(Name = "发票号")]
         public string InvbillNum { get; set; }
+        [Display(Name = "供应商代码")]
+        public string VendorCode { get; set; }
+        [Display(Name = "供应商名称")]
+        public string VendorName { get; set; }
+        [Display(Name = "PurchaseOrderNumber")]
+        public string PurchaseOrderNumber { get; set; }
+        [Display(Name = "业务分类")]
+        public string DeliveryIndexNumber { get; set; }
+        /// <summary>
+        ///零件号
+        /// </summary>
+        [Display(Name = "零件号")]
+        public string PartCode { get; set; }
+        [Display(Name = "PartName")]
+        public string PartName { get; set; }
         /// <summary>
         ///发票分组号
         /// </summary>
@@ -325,15 +373,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
         [Display(Name = "客户零件号")]
         public string LU { get; set; }
 
-        /// <summary>
-        ///零件号
-        /// </summary>
-        [Display(Name = "零件号")]
-        public string PartCode { get; set; }
-
         [Display(Name = "零件描述")]
         public string PartDesc { get; set; }
-
         /// <summary>
         ///单价
         /// </summary>
@@ -352,9 +393,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
         /// <summary>
         ///业务分类
         /// </summary>
-        [Display(Name = "业务分类")]
-        public string BussiessType { get; set; }
-
 
         /// <summary>
         ///扩展字段3
@@ -591,6 +629,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
         /// </summary>
         [Display(Name = "结算分组号")]
         public string SettleGroupNum { get; set; }
+
+
+    
+
         /// <summary>
         ///金额
         /// </summary>
@@ -611,6 +653,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
     }
 
 
+    public class MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO
+    {
+
+        /// <summary>
+        ///发票分组号
+        /// </summary>
+        [Display(Name = "发票分组号")]
+        public string InvGroupNum { get; set; }
+        /// <summary>
+        ///结算分组号
+        /// </summary>
+        [Display(Name = "五联单号")]
+        public string SettleGroupNum { get; set; }
+
+        [Display(Name = "现生产码")]
+        public string Extend1 { get; set; }
+
+    }
+
+
 
     public class INVOICE_MAP_GROUP_EXP_DTO
     {
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
index fc538ad2..20cd76d8 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
@@ -209,7 +209,7 @@ namespace Win.Sfs.SettleAccount.Bases
                                PRICE = itm.PRICE,
                                Qty = itm.Qty,
                                Amt = itm.Amt,
-                               BussiessType = itm.BussiessType,
+                           
                                Extend1 = itm.Extend1,
                                BeginDate = itm.BeginDate,
                                EndDate = itm.EndDate,
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
index 0b9861c3..16367b23 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
@@ -2,6 +2,7 @@ using AutoMapper;
 using DocumentFormat.OpenXml.Bibliography;
 using DocumentFormat.OpenXml.Drawing.Charts;
 using DocumentFormat.OpenXml.Office2010.Excel;
+using EFCore.BulkExtensions;
 using Magicodes.ExporterAndImporter.Core;
 using Magicodes.ExporterAndImporter.Csv;
 using Magicodes.ExporterAndImporter.Excel;
@@ -11,6 +12,7 @@ using NPOI.HPSF;
 using NPOI.OpenXmlFormats.Spreadsheet;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
 using SettleAccount.Bases;
+using SettleAccount.Job.Services;
 using Shouldly;
 using System;
 using System.Collections.Generic;
@@ -21,6 +23,7 @@ using System.Text;
 using System.Threading.Tasks;
 using TaskJob.EventArgs;
 using TaskJob.Services;
+using Volo.Abp;
 using Volo.Abp.Application.Dtos;
 using Volo.Abp.Application.Services;
 using Volo.Abp.Domain.Entities;
@@ -32,6 +35,7 @@ using Win.Sfs.SettleAccount.Entities.BQ;
 using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
 using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
 using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
+using Win.Sfs.SettleAccount.Entities.TaskJobs;
 using Win.Sfs.SettleAccount.ExcelImporter;
 using Win.Sfs.SettleAccount.ExportReports;
 using Win.Sfs.Shared.RepositoryBase;
@@ -138,8 +142,76 @@ namespace Win.Sfs.SettleAccount.Bases
         //[Route("generateinvoice")]
         public virtual async Task<string> ApprovalPassed(List<string> p_list)
         {
+
+
+
+
+
+
             return ApplicationConsts.SuccessStr;
         }
+
+
+
+        protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false)
+        {
+            var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
+            var first=detailist.FirstOrDefault();
+            List<CustomCondition> customConditionList = new List<CustomCondition>();
+            customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
+            customConditionList.Add(new CustomCondition() { Name = "Type", Value =first.BusinessType.ToString() });
+            if (isback == false)
+            {
+                customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
+            }
+            else
+            {
+                customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "in" });
+            }
+           
+            var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
+            var lst=new List<TEntity>();
+            if (isback == false)
+            {
+                 lst = ls.Where(p => (p.State == SettleBillState.已提交扣减 || p.State == SettleBillState.已扣减)).ToList();
+            }
+            else
+            {
+                 lst = ls.Where(p => (p.State == SettleBillState.已提交撤销扣减|| p.State == SettleBillState.客户已收票)).ToList();
+            }
+
+         
+            if (lst.Count() > 0)
+            {
+                throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
+            }
+            foreach (var item in ls)
+            {
+                if (isback == false)
+                {
+                    item.State = SettleBillState.已提交扣减;
+                }
+                else
+                {
+                    item.State = SettleBillState.已提交撤销扣减;
+                }
+            }
+            await _repository.DbContext.BulkUpdateAsync(ls);
+            
+            var _taskid = await p_service.ExportEnqueueAsync($"{first.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
+            {
+            });
+
+            return _taskid;
+        }
+
+
+
+
+
+
+
+
         /// <summary>
         /// 查询主表
         /// </summary>
@@ -160,7 +232,7 @@ namespace Win.Sfs.SettleAccount.Bases
         /// <param name="input"></param>
         /// <returns></returns>
         [HttpPost]
-        public virtual async Task<string> RejectAsync(TRequestMainInput input)
+        public virtual async Task<string> RejectAsync(List<string> p_list)
         {
             return ApplicationConsts.SuccessStr;
         }
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
index 9f22e696..6a350c6b 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
@@ -50,27 +50,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
         [UnitOfWork(false)]
         public override async Task<string> ApprovalPassed(List<string> p_list)
         {
-            var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
-            List<CustomCondition> customConditionList = new List<CustomCondition>();
-            customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value =string.Join(",",p_list) });
-            customConditionList.Add(new CustomCondition() { Name = "Type", Value = EnumBusinessType.JisBBAC.ToString() });
-            customConditionList.Add(new CustomCondition() { Name = "IsOut", Value ="out"});
-            var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
-            var lst = ls.Where(p => (p.State == SettleBillState.已提交扣减 || p.State == SettleBillState.已扣减));
-            if (lst.Count() > 0)
-            {
-                throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
-            }
-            foreach (var item in ls)
-            {
-                item.State = SettleBillState.已提交扣减;
-            }
-            await _repository.DbContext.BulkUpdateAsync(ls);
-            var _taskid = await _service.ExportEnqueueAsync("BBAC待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
-            {
-            });
+            return await InvokePD(p_list, _service,  false);
         
-            return _taskid;
+        }
+
+        [UnitOfWork(false)]
+        public override async Task<string> RejectAsync(List<string> p_list)
+        {
+            return await InvokePD(p_list, _service, true);
+
         }
         //[HttpPost]
         //public virtual async Task<string> RejectAsync(List<string> p_list)
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
index 9a057873..6ad2db8f 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
@@ -372,7 +372,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                                                           //}
                 var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
                 var q = from d in dto1s
-                        join p in priceList on d.PartCode equals p.LU
+                        join p in priceList on d.LU equals p.LU
                         where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
                         select new TEMP_CAN_SA_DETAIL
                         {
@@ -445,9 +445,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
             {
                 return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
             }
-
-
-
             var invBilllist = new List<INVOICE_REPEAT_DTO>();
 
             var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
@@ -522,7 +519,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                                                           //}
                 var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
                 var q = from d in dto1s
-                        join p in priceList on d.PartCode equals p.LU
+                        join p in priceList on d.LU equals p.LU
                         where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
                         select new TEMP_CAN_SA_DETAIL
                         {
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
index 97a1fe4e..5ad14199 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
@@ -44,31 +44,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
         [UnitOfWork(false)]
         public override async Task<string> ApprovalPassed(List<string> p_list)
         {
-            var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
-            List<CustomCondition> customConditionList = new List<CustomCondition>();
-            customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
-            customConditionList.Add(new CustomCondition() { Name = "Type", Value = EnumBusinessType.JisHBPO.ToString() });
-            customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
-            var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
-            var lst = ls.Where(p => (p.State == SettleBillState.已提交扣减 || p.State == SettleBillState.已扣减));
-            if (lst.Count() > 0)
-            {
-                throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交","400");
-            }
-            foreach (var item in ls)
-            {
-                item.State = SettleBillState.已提交扣减;
-            }
-            await _repository.DbContext.BulkUpdateAsync(ls);
-            var _taskid = await _service.ExportEnqueueAsync("HBPO待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
-            {
-            });
-
-            return _taskid;
-
+            return await InvokePD(p_list, _service, false);
+        }
+        [UnitOfWork(false)]
+        public override async Task<string> RejectAsync(List<string> p_list)
+        {
+            return await InvokePD(p_list, _service, true);
         }
 
 
 
+
     }
 }
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
index 4e96e232..6d2f652b 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
@@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using NPOI.HPSF;
 using SettleAccount.Domain.BQ;
+using ShardingCore.Extensions;
 using Shouldly;
 using SqlSugar;
 using System;
@@ -25,6 +26,7 @@ using System.Text;
 using System.Threading.Tasks;
 using Volo.Abp.Application.Dtos;
 using Volo.Abp.Application.Services;
+using Volo.Abp.Data;
 using Volo.Abp.Domain.Entities;
 using Volo.Abp.Uow;
 using Win.Abp.Snowflakes;
@@ -164,8 +166,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
             var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
             var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m);
             var first = invs.FirstOrDefault();
-          
-
 
             if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC)
             {
@@ -201,8 +201,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                 var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
 
                 B.OrderBy(p => p.LineCode);
-                var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B);
 
+                List<INVOICE_WAIT_DETAIL_BJ_DTO> BMap = new List<INVOICE_WAIT_DETAIL_BJ_DTO>();
+                foreach (var itm in B)
+                {
+                    INVOICE_WAIT_DETAIL_BJ_DTO bj = new INVOICE_WAIT_DETAIL_BJ_DTO();
+                    bj.LU = itm.LU;
+                    bj.PartCode = itm.PartCode;
+                    bj.PRICE = itm.PRICE;
+          
+                    bj.InvGroupNum =         itm.InvGroupNum;
+                    bj.DeliveryNumber=       itm.GetProperty("DeliveryNumber", "");//交货号
+                    bj.InvbillNum =          itm.GetProperty("InvoiceNumber", "");//发票号
+                    bj.VendorCode =          itm.GetProperty("VendorCode", "");//供应商代码
+                    bj.VendorName =          itm.GetProperty("VendorName", "");//供应商名称
+                    bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号
+                    bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号
+                    bj.PartName = itm.GetProperty("PartName", "");//零件名称
+                }
+
+                //var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B);
                 var wquery = from itm in BMap
                              join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
                              join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
@@ -221,7 +239,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                                PRICE = itm.PRICE,
                                Qty = itm.Qty,
                                Amt = itm.Amt,
-                               BussiessType = itm.BussiessType,
+                               DeliveryNumber =       itm.DeliveryNumber ,
+                               VendorCode =           itm.VendorCode ,
+                               VendorName =           itm.VendorName ,
+                               PurchaseOrderNumber =  itm.PurchaseOrderNumber, 
+                               DeliveryIndexNumber =itm.DeliveryIndexNumber ,
                                Extend1 = itm.Extend1,
                                BeginDate = itm.BeginDate,
                                EndDate = itm.EndDate,
@@ -230,7 +252,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
             }
             else
             {
-
                 var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
                 var wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w);
                 var wquery = from itm in wdtos
@@ -240,7 +261,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                              select
                            new INVOICE_WAIT_DETAIL_DTO()
                            {
-
                                PartDesc = tm == null ? string.Empty : itm.PartDesc,
                                InvDate = itm1.CreationTime,
                                RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum,
@@ -318,26 +338,46 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                 SettleGroupNum = p.FirstOrDefault().SettleGroupNum,
             }
             );
-            if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
+            if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)//BBAC直供未结
             {
                 //var all = entity.INVOICE_NOT_SETTLE.Select(p => p.SettleGroupNum).Distinct().ToList();//全部分组号
                 //var part = mquery.ToList().Select(p => p.SettleGroupNum).Distinct().ToList();//发票对应分组号
                 //var unsettled = all.Where(p => !part.Contains(p));//排除发票对应分组号,都为不可结
                 var unsettledList = sdtos
                     .GroupBy(p => new { p.LU, p.SettleGroupNum })
-                    .Select(p => new UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) });
-                entity.UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList();
+                    .Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) });
+                entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList();
             }
-
-            if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC)
+            if (first.BusinessType == EnumBusinessType.JisHBPO)
             {
                 entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号
             }
-            if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO)
+
+            if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO)//hbpo买单未结
             {
-                entity.INVOICE_MAP_GROUP = mdtos;
+                List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO> hbpomaplist = new List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO>();
+                foreach (var itm in m)
+                {
+                    hbpomaplist.Add(new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO()
+                    {
+                        InvGroupNum = itm.InvGroupNum,
+                        SettleGroupNum = itm.SettleGroupNum,
+                        Extend1 = itm.Extend1,
+                    });
+                }
+                entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = hbpomaplist;
+                if (sdtos != null && sdtos.Count > 0)
+                {
+                    var hbpo=sdtos.Select(p => new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO(){
+                         GroupNum = p.SettleGroupNum,//五联单号
+                         LU=p.LU,
+                         PN=p.Extend1,//生产码
+
+                    });
+                    entity.MAIDAN_HBPO_UNSETTLED_DETAIL = hbpo.ToList();
+                }
+
             }
-          
             entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList();
             return entity;
         }
@@ -403,6 +443,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
             var unsettle = invdetail.UNSETTLED_DETAIL;//全部未结明细
 
 
+            var jitunsettle = invdetail.JIT_UNSETTLED_DETAIL;
+            var maidanunsettle = invdetail.MAIDAN_HBPO_UNSETTLED_DETAIL;
+            var maidangroup = invdetail.MAIDAN_HBPO_INVOICE_MAP_GROUP;
+
             var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name;
             string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx";
 
@@ -425,18 +469,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
             {
                 _excel.Append(m, "发票结算分组对应");//发票分组对应结算号
             }
-            if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC )
+            if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC  )
             {
-                _excel.Append(unsettle, "未结零件结算汇总");
+                if(jitunsettle != null)
+                {
+                    _excel.Append(jitunsettle, "未结零件结算汇总");
+                }
+                //_excel.Append(m, "发票结算分组对应");
+
             }
-            if (first.BusinessType == EnumBusinessType.JisHBPO)
+            if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO)
             {
-                _excel.Append(unsettle, "未结零件列表");
+                if(maidangroup != null)
+                {
+                    _excel.Append(maidangroup, "结算对应关系");
+                }
+                if (maidanunsettle != null)
+                {
+                    _excel.Append(maidanunsettle, "未结零件结算汇总");
+                }
             }
 
-
-
-
             foreach (var itm in entities)
             {
                 var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList();
@@ -529,6 +582,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                 }
                 _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet();
             }
+
           
             var result = _excel.ExportAppendDataAsByteArray();
             result.ShouldNotBeNull();
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
index 821f7a9e..1f75c3ac 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
@@ -63,14 +63,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
             var errorlist = await CheckRepeat(p_list);
             if (errorlist.Count > 0)
             {
-
                 return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorlist) });
-
             }
-
             var first = p_list.FirstOrDefault();
             var invbillnum = first.InvBillNum;
-
             List<INVOICE_WAIT_DETAIL_DTO> ls = new List<INVOICE_WAIT_DETAIL_DTO>();
             var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
             if (adjlist == null && adjlist.Count == 0)
@@ -271,7 +267,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                 }
                     //  var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
                     var q = from d in entitys
-                            join p in priceList on d.PartCode equals p.LU
+                            join p in priceList on d.LU equals p.LU
                             where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site
                             select new TEMP_CAN_SA_DETAIL
                             {
@@ -404,7 +400,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                                                           //}
                 var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);
                 var q = from d in dto1s
-                        join p in priceList on d.PartCode equals p.LU
+                        join p in priceList on d.LU equals p.LU
                         where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
                         select new TEMP_CAN_SA_DETAIL
                         {
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
index 52dcea77..34bab242 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
@@ -40,30 +40,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
         [UnitOfWork(false)]
         public override async Task<string> ApprovalPassed(List<string> p_list)
         {
-            var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
-            List<CustomCondition> customConditionList = new List<CustomCondition>();
-            customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
-            var first=detailist.FirstOrDefault();
-            customConditionList.Add(new CustomCondition() { Name = "Type", Value = first.BusinessType.ToString()});
-            customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
-            var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
-            var lst = ls.Where(p => (p.State == SettleBillState.已提交扣减 || p.State == SettleBillState.已扣减));
-            if (lst.Count() > 0)
-            {
-                throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
-            }
-            foreach (var item in ls)
-            {
-                item.State = SettleBillState.已提交扣减;
-            }
-            await _repository.DbContext.BulkUpdateAsync(ls);
-            var _taskid = await _service.ExportEnqueueAsync("PUB待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
-            {
-            });
+            return await InvokePD(p_list, _service, false);
+        }
+        [UnitOfWork(false)]
+        public override async Task<string> RejectAsync(List<string> p_list)
+        {
+            return await InvokePD(p_list, _service, true);
+        }
 
-            return _taskid;
 
 
-        }
     }
 }
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
index c582bd3f..63f69c1b 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
@@ -65,7 +65,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
                 {
                     if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2))
                     {
-                        itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description;
+                        itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description;//通用表读取
                     }
                     else
                     {
@@ -213,9 +213,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
             itm.SetId(GuidGenerator.Create());
         }
         var _first = p_ls.FirstOrDefault();
-
         bool issucess = true;
-
         using (var transaction = _dbcontext.Database.BeginTransaction())
         {
             try
@@ -248,7 +246,6 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
                             {
                                 item.State = SettleBillState.客户已收票;
                             }
-
                         }
                         _dbcontext.BulkUpdate(pdList);
                     }
@@ -306,12 +303,10 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
                 issucess = false;  
                 // 回滚事务
                 transaction.Rollback();
-               
             }
         }
         if (issucess ==false)
         {
-
             var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();
             var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
             if (pdList.Count > 0)
@@ -327,7 +322,6 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
                         item.State = SettleBillState.已扣减;
 
                     }
-
                 }
                 _dbcontext.BulkUpdate(pdList);
             }
@@ -343,7 +337,6 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
                     else
                     {
                         item.State = SettleBillState.已扣减;
-
                     }
                 }
                 _dbcontext.BulkUpdate(bbacList);
@@ -360,7 +353,6 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
                     else
                     {
                         item.State = SettleBillState.已扣减;
-
                     }
                 }
                 _dbcontext.BulkUpdate(hbpoList);
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
index 6c61c6bb..b913c6df 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
@@ -58,9 +58,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                     errors.Add($"生产号{itm.PN}零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
                 }
             }
-            if (first.BusinessType == EnumBusinessType.JisHBPO)
+            if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.MaiDanJianHBPO)
             {
-
                 var ls = p_list.Select(p => p.Site.Substring(0, 3)).Distinct().ToList();
                 if (ls.Count > 1)
                 {
@@ -70,8 +69,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                 {
                     return errors;
                 }
-
-              
             }
             var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
             var _entity = new HBPO_CAN_SA();
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
index f3109228..1ce11db5 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
@@ -435,7 +435,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
         /// <returns></returns>
         public virtual async Task<bool> ReceivedAsync(List<string> p_invs) 
         {
+
             var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息
+  
             int count = invList.Select(p => p.InvGroupNum).Distinct().Count();
             if (count > 1)
             {
@@ -912,7 +914,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
         /// <returns></returns>
         public virtual async Task<bool> Reject(string groupbillNum)
         {
-
             var ls = await _repository.Where(p => p.InvGroupNum == groupbillNum).ToListAsync();
             if (ls != null && ls.Count > 0)
             {
@@ -953,7 +954,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                         }
                         //await _repository.DbContext.BulkUpdateAsync(canList);
                     }
-
                 }
             }
             else
@@ -970,7 +970,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
         /// <returns></returns>
         public virtual async Task<bool> BackAsync(string billNum)
         {
-
             var _ls = await _repository.Where(p => p.InvGroupNum == billNum).ToListAsync();
             if (_ls != null && _ls.Count > 0)
             {
@@ -978,7 +977,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                 {
 
                 }
-
             }
             //if (_ls != null && _ls.Count > 0)
             //{
@@ -1022,7 +1020,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
         [UnitOfWork(false)]
         public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
             where TDetail : SA_CAN_BASE
-
         {
             List<string> _invls = new List<string>();
             var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
@@ -1237,9 +1234,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
 
                       );
                     invbill.ClientCode = clientCode;
-
-                 
-
                     invbill.Site = dtos.FirstOrDefault().Site;
                     invlist.Add(invbill);
                 }
@@ -1536,8 +1530,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                 //}
                 _invls = invlist.Select(p => p.InvbillNum).ToList();
             }
-
-
             return _invls;
         }
 
@@ -1697,7 +1689,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                             invGroupNum: p_InvGroupNum,
                             settleGroupNum: groupnum.GroupNum,
                             amt: 0,
-                            extend1: groupnum.PN,
+                            extend1: groupnum.PN,//生产码
                             extend2: string.Empty
                             )
                             );
@@ -1706,32 +1698,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                         {
                             groupList.AddRange(mapList);
                         }
-                        var notsettle= _nothbpoRepository.Where(p => p.SettleBillNum == p_InvGroupNum);//一次开票时查找不可结数据,追加需求
-
-                        if (notsettle != null && notsettle.Count() > 0)
-                        {
-                            var innotls = new List<INVOICE_NOT_SETTLE>();
-                            foreach (var nitm in notsettle)
-                            {
-                                innotls.Add(new INVOICE_NOT_SETTLE(
-                                    guid: GuidGenerator.Create(),
-                                    version: p_version,
-                                    invGroupNum: p_InvGroupNum,
-                                    settleGroupNum: nitm.GroupNum,
-                                    lU: nitm.LU,
-                                    lU1: nitm.LU,
-                                    extend1: "不可结算",
-                                    extend2: string.Empty,
-                                    qty: nitm.Qty,
-                                    p_invbillnum: string.Empty
-                                    ));
-                            }
-                            if (innotls.Count > 0)
-                            {
-                                notDetialList.AddRange(innotls);
-                            }
-
-                        }
+ 
                         //invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
                     }
 
@@ -1760,6 +1727,37 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
                     {
                         detailList.AddRange(_entityDetailList);
                     }
+
+                    if (p_first == true)
+                    {
+                        var notsettle = _nothbpoRepository.Where(p => p.SettleBillNum == p_InvGroupNum);//一次开票时查找不可结数据,追加需求
+
+                        if (notsettle != null && notsettle.Count() > 0)
+                        {
+                            var innotls = new List<INVOICE_NOT_SETTLE>();
+                            foreach (var nitm in notsettle)
+                            {
+                                innotls.Add(new INVOICE_NOT_SETTLE(
+                                    guid: GuidGenerator.Create(),
+                                    version: p_version,
+                                    invGroupNum: p_InvGroupNum,
+                                    settleGroupNum: nitm.GroupNum,
+                                    lU: nitm.LU,
+                                    lU1: nitm.LU,
+                                    extend1: nitm.PN,
+                                    extend2: string.Empty,
+                                    qty: nitm.Qty,
+                                    p_invbillnum: string.Empty
+                                    ));
+                            }
+                            if (innotls.Count > 0)
+                            {
+                                notDetialList.AddRange(innotls);
+                            }
+
+                        }
+                    }
+
                     decimal amt = detailList.Sum(k => k.Amt);//金额
                     decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
                     decimal realAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs
index dadd788a..1b0aace9 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs
@@ -31,7 +31,9 @@ namespace Win.Sfs.SettleAccount
         [Description("客户已收票")]
         客户已收票 = 4,
         [Description("已提交扣减")]
-        已提交扣减 = 6
+        已提交扣减 = 6,
+        [Description("已提交撤销扣减")]
+        已提交撤销扣减 = 7
     }
 
     public enum PDBillState

From c44db78a811710d5551372e92af2681c8b306015 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com>
Date: Tue, 19 Sep 2023 11:58:56 +0800
Subject: [PATCH 2/2] =?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

---
 .../Bases/BA_SERVICE.cs                       |  2 +-
 .../Bases/PD_SERVICE.cs                       | 38 +++++++++----------
 .../Entities/BQ/BBAC_PD_SERVICE.cs            | 26 ++-----------
 .../Entities/BQ/HBPO_PD_SERVICE.cs            | 19 +---------
 .../Entities/BQ/INVOICE_SERVICE.cs            | 16 ++++----
 .../Entities/BQ/PUB_PD_SERVICE.cs             | 20 +---------
 6 files changed, 34 insertions(+), 87 deletions(-)

diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
index adbcadde..544ae483 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
@@ -188,7 +188,7 @@ namespace Win.Sfs.SettleAccount.Bases
                                 PRICE = itm.PRICE,
                                 Qty = itm.Qty,
                                 Amt = itm.Amt,
-                                BussiessType = itm.BussiessType,
+                           
                                 Extend1 = itm.Extend1,
                                 BeginDate = itm.BeginDate,
                                 EndDate = itm.EndDate,
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
index 0ef02157..3c537c2d 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
@@ -2,6 +2,7 @@
 using DocumentFormat.OpenXml.Bibliography;
 using DocumentFormat.OpenXml.Drawing.Charts;
 using DocumentFormat.OpenXml.Office2010.Excel;
+using EFCore.BulkExtensions;
 using Magicodes.ExporterAndImporter.Core;
 using Magicodes.ExporterAndImporter.Csv;
 using Magicodes.ExporterAndImporter.Excel;
@@ -19,7 +20,9 @@ using System.Text;
 using System.Threading.Tasks;
 using TaskJob.EventArgs;
 using TaskJob.Services;
+using Volo.Abp;
 using Volo.Abp.Application.Dtos;
+using Volo.Abp.Uow;
 using Win.Abp.Snowflakes;
 using Win.Sfs.BaseData.ImportExcelCommon;
 using Win.Sfs.SettleAccount.CommonManagers;
@@ -28,6 +31,7 @@ using Win.Sfs.SettleAccount.Entities.BQ;
 using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
 using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
 using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
+using Win.Sfs.SettleAccount.Entities.TaskJobs;
 using Win.Sfs.SettleAccount.ExcelImporter;
 using Win.Sfs.SettleAccount.ExportReports;
 using Win.Sfs.Shared.RepositoryBase;
@@ -50,7 +54,7 @@ namespace Win.Sfs.SettleAccount.Bases
         protected readonly INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> _bbacSecRepository;
         protected readonly INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> _hbpoSecRepository;
         protected readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSecRepository;
-
+        private readonly TaskJobService _service;
         public PD_SERVICE(
 
             INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository,
@@ -61,9 +65,11 @@ namespace Win.Sfs.SettleAccount.Bases
             ICommonManager commonManager,
             INormalEfCoreRepository<TEntity, Guid> repository,
             VmiAppService vimservice,
-            INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
+            INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
+            TaskJobService service
             ) : base(excelImportService, snowflakeIdGenerator, commonManager)
         {
+            _service = service;
             _vimservice = vimservice;
             _repository = repository;
             _detailRepository = detailRepository;
@@ -127,18 +133,17 @@ namespace Win.Sfs.SettleAccount.Bases
             return _fileName;
         }
         [HttpPost]
-        //[Route("generateinvoice")]
+        [UnitOfWork(false)]
         public virtual async Task<string> ApprovalPassed(List<string> p_list)
         {
-
-
-
-
-
-
-            return ApplicationConsts.SuccessStr;
+            return await InvokePD(p_list, _service, false);
+        }
+        [HttpPost]
+        [UnitOfWork(false)]
+        public virtual async Task<string> RejectAsync(List<string> p_list)
+        {
+            return await InvokePD(p_list, _service, true);
         }
-
 
 
         protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false)
@@ -214,16 +219,7 @@ namespace Win.Sfs.SettleAccount.Bases
             var dtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entitys);
             return new PagedResultDto<TEntityDto>(totalCount, dtos);
         }
-        /// <summary>
-        /// 退回
-        /// </summary>
-        /// <param name="input"></param>
-        /// <returns></returns>
-        [HttpPost]
-        public virtual async Task<string> RejectAsync(List<string> p_list)
-        {
-            return ApplicationConsts.SuccessStr;
-        }
+       
         protected virtual async Task<TEntity> GetMainAsync([FromBody] string billNum)
         {
             return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync().ConfigureAwait(false);
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
index cea46314..d61b8516 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
@@ -31,29 +31,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
         BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO>
     {
 
-        private readonly TaskJobService _service;
-        public BBAC_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, VmiAppService vimservice,
-            INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository,
-            TaskJobService service
 
-            ) :
-            base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository)
-        {
-            _service = service;
-        }
-        [UnitOfWork(false)]
-        public override async Task<string> ApprovalPassed(List<string> p_list)
-        {
-            return await InvokePD(p_list, _service,  false);
-        
-        }
 
-        [UnitOfWork(false)]
-        public override async Task<string> RejectAsync(List<string> p_list)
-        {
-            return await InvokePD(p_list, _service, true);
 
-        }
         //[HttpPost]
         //public virtual async Task<string> RejectAsync(List<string> p_list)
         //{
@@ -79,6 +59,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
         //    return _taskid;
 
         //}
-
+        public BBAC_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service)
+        {
+        }
     }
 }
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
index a98edfe6..44c215a4 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
@@ -25,23 +25,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
         HBPO_PD_DETAIL, HBPO_PD_DETAIL_DTO, HBPO_PD_REQ_DTO,
         HBPO_PD_DETAIL_REQ_DTO, HBPO_PD_DETAIL_EXP_DTO>
     {
-        private readonly TaskJobService _service;
-        public HBPO_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository)
+        public HBPO_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service)
         {
-            _service = service;
         }
-
-        [UnitOfWork(false)]
-        public override async Task<string> ApprovalPassed(List<string> p_list)
-        {
-            return await InvokePD(p_list, _service, false);
-        }
-        [UnitOfWork(false)]
-        public override async Task<string> RejectAsync(List<string> p_list)
-        {
-            return await InvokePD(p_list, _service, true);
-        }
-
-
     }
 }
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
index e395127a..e6e6a762 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
@@ -199,14 +199,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
                     bj.PartCode = itm.PartCode;
                     bj.PRICE = itm.PRICE;
           
-                    bj.InvGroupNum =         itm.InvGroupNum;
-                    bj.DeliveryNumber=       itm.GetProperty("DeliveryNumber", "");//交货号
-                    bj.InvbillNum =          itm.GetProperty("InvoiceNumber", "");//发票号
-                    bj.VendorCode =          itm.GetProperty("VendorCode", "");//供应商代码
-                    bj.VendorName =          itm.GetProperty("VendorName", "");//供应商名称
-                    bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号
-                    bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号
-                    bj.PartName = itm.GetProperty("PartName", "");//零件名称
+                    //bj.InvGroupNum =         itm.InvGroupNum;
+                    //bj.DeliveryNumber=       itm.GetProperty("DeliveryNumber", "");//交货号
+                    //bj.InvbillNum =          itm.GetProperty("InvoiceNumber", "");//发票号
+                    //bj.VendorCode =          itm.GetProperty("VendorCode", "");//供应商代码
+                    //bj.VendorName =          itm.GetProperty("VendorName", "");//供应商名称
+                    //bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号
+                    //bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号
+                    //bj.PartName = itm.GetProperty("PartName", "");//零件名称
                 }
 
                 //var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B);
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
index c35aea7c..1244d5d0 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
@@ -26,24 +26,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
         PUB_PD_DETAIL, PUB_PD_DETAIL_DTO, PUB_PD_REQ_DTO,
         PUB_PD_DETAIL_REQ_DTO, PUB_PD_DETAIL_EXP_DTO>
     {
-        private readonly TaskJobService _service;
-        public PUB_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository)
+        public PUB_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service)
         {
-            _service = service;
-        }
-        [UnitOfWork(false)]
-        public override async Task<string> ApprovalPassed(List<string> p_list)
-        {
-            return await InvokePD(p_list, _service, false);
-        }
-        [UnitOfWork(false)]
-        public override async Task<string> RejectAsync(List<string> p_list)
-        {
-            return await InvokePD(p_list, _service, true);
-        }
-
-
-
         }
     }
 }