From 553728514e33fe20bfbf93485eccbcaee51fc165 Mon Sep 17 00:00:00 2001 From: me Date: Fri, 1 Aug 2025 11:46:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0M110=E5=92=8CRepeatM110?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=AE=9E=E4=BD=93DTO=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MenBanReports/MenBanPackingListDto.cs | 5 +- .../MsgCheck/BillM110s/Dtos/BillM110Dto.cs | 128 + .../BillM110s/Dtos/BillM110PartDto.cs | 38 + .../BillM110s/Dtos/CreateUpdateBillM110Dto.cs | 104 + .../Dtos/CreateUpdateBillM110PartDto.cs | 32 + .../BillM110s/Dtos/QueryBillM110Dto.cs | 127 + .../BillM110s/Dtos/ResultBillM110Dto.cs | 157 + .../Interfaces/IBillM110AppService.cs | 115 + .../Dtos/CreateUpdateRepeatM110Dto.cs | 85 + .../Dtos/CreateUpdateRepeatM110PartDto.cs | 35 + .../M110Repeat/Dtos/QueryRepeatM110Dto.cs | 87 + .../M110Repeat/Dtos/RepeatM110Dto.cs | 115 + .../M110Repeat/Dtos/RepeatM110PartDto.cs | 38 + .../Interfaces/IRepeatM110AppService.cs | 58 + .../WY.NewJit.Application.Contracts.xml | 1082 +++- .../MsgCheck/BillM110s/BillM110AppService.cs | 5088 +++++++++++++++++ .../RepeatMessages/RepeatM100AppService.cs | 2 +- .../RepeatMessages/RepeatM110AppService.cs | 375 ++ .../RepeatMessages/RepeatR100AppService.cs | 2 +- .../NewJitApplicationAutoMapperProfile.cs | 17 + .../WY.NewJit.Application.xml | 308 + .../MsgCheck/Entitys/BillM110.cs | 187 +- .../MsgCheck/Entitys/BillM110Part.cs | 49 +- .../MsgCheck/Entitys/RepeatM110.cs | 40 +- .../MsgCheck/Entitys/RepeatM110Part.cs | 12 +- .../NewJitDbContextModelCreatingExtensions.cs | 49 +- .../Messages/MsgTransmissionService.cs | 4 +- 27 files changed, 8154 insertions(+), 185 deletions(-) create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110Dto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110PartDto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110Dto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110PartDto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/QueryBillM110Dto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/ResultBillM110Dto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Interfaces/IBillM110AppService.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110Dto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110PartDto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/QueryRepeatM110Dto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110Dto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110PartDto.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Interfaces/IRepeatM110AppService.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM110s/BillM110AppService.cs create mode 100644 Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM110AppService.cs diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPackingListDto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPackingListDto.cs index 63362f8..de20e8e 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPackingListDto.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPackingListDto.cs @@ -90,7 +90,10 @@ namespace WY.NewJit.Extends /// public virtual List Details { get; set; } - + /// + /// 报表状态 + /// + public virtual ReportStatusEnum ReportStatus { get; set; } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110Dto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110Dto.cs new file mode 100644 index 0000000..fdb57c9 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110Dto.cs @@ -0,0 +1,128 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + /// + /// 零件查询结果DTO + /// + [ExcelExporter(Name = "M110单据", AutoFitAllColumn = true, MaxRowNumberOnASheet = 1000)] //一个Sheet最大允许的行数,设置了之后将输出多个Sheet + [Serializable] + public class BillM110Dto: AuditedEntityDto + { + /// + /// 流水号# + /// + [ExporterHeader(DisplayName = "流水号")] + [ImporterHeader(Name = "流水号")] + public int? SerialNum { get; set; } + + /// + /// 大众顺序号 + /// + [ExporterHeader(DisplayName = "大众顺序号")] + [ImporterHeader(Name = "大众顺序号")] + public int? HostSN { get; set; } + + /// + /// KNR + /// + [ExporterHeader(DisplayName = "KNR")] + [ImporterHeader(Name = "KNR")] + public string KNR { get; set; } + + /// + /// 底牌号# + /// + [ExporterHeader(DisplayName = "底牌号")] + [ImporterHeader(Name = "底牌号")] + public string VIN { get; set; } + + /// + /// 总成ID + /// + [ExporterHeader(DisplayName = "总成ID")] + [ImporterHeader(Name = "总成ID")] + public Guid? AssemblyID { get; set; } + + /// + /// 上线时间 + /// + [ExporterHeader(DisplayName = "上线时间")] + [ImporterHeader(Name = "上线时间")] + public DateTime? OnlineTime { get; set; } + + /// + /// 车型代码(取通用字典) + /// + [ExporterHeader(DisplayName = "车型代码")] + [ImporterHeader(Name = "车型代码")] + public string VehicleModelCode { get; set; } + + /// + /// 生产线(派格按生产线分类) + /// + [ExporterHeader(DisplayName = " 生产线")] + [ImporterHeader(Name = " 生产线")] + public virtual string ProductLine { get; set; } + + /// + /// 版本 + /// + [ExporterHeader(DisplayName = "版本")] + [ImporterHeader(Name = "版本")] + public string Version { get; set; } + + /// + /// 接收时间 + /// + [ExporterHeader(DisplayName = "接收时间")] + [ImporterHeader(Name = "接收时间")] + public DateTime? ReceiveTime { get; set; } + + /// + /// 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + /// + [ExporterHeader(DisplayName = "单据状态")] + [ImporterHeader(Name = "单据状态")] + public BillStatusEnum BillStatus { get; set; } + + /// + /// 描述 + /// + [ExporterHeader(DisplayName = "描述")] + [ImporterHeader(Name = "描述")] + public string Description { get; set; } + + /// + /// 涂装重复单据包含的零件列表 + /// + public List BillM110Parts { get; set; } + + /// + /// 手工操作类型:0 none,1 手工添加,2 手工修改 + /// + [ExporterHeader(DisplayName = "手工操作类型")] + [ImporterHeader(Name = "手工操作类型")] + public ManualOperationTypeEnum OperationType { get; set; } + + /// + /// 手工操作员 + /// + [ExporterHeader(DisplayName = "手工操作员")] + [ImporterHeader(Name = "手工操作员")] + public string Operator { get; set; } + + /// + /// 手工操作日期 + /// + [ExporterHeader(DisplayName = "手工操作日期")] + [ImporterHeader(Name = "手工操作日期")] + public DateTime? OperationTime { get; set; } + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110PartDto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110PartDto.cs new file mode 100644 index 0000000..8b788ff --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/BillM110PartDto.cs @@ -0,0 +1,38 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + /// + /// 零件查询结果DTO + /// + [ExcelExporter(Name = "M110单据包含的零件信息", AutoFitAllColumn = true, MaxRowNumberOnASheet = 1000)] //一个Sheet最大允许的行数,设置了之后将输出多个Sheet + [Serializable] + public class BillM110PartDto : EntityDto + { + /// + /// 客户零件代码 + /// + [ExporterHeader(DisplayName = "客户零件代码")] + [ImporterHeader(Name = "客户零件代码")] + public string PartCode { get; set; } + + /// + /// 客户零件数量 + /// + [ExporterHeader(DisplayName = "客户零件数量")] + [ImporterHeader(Name = "客户零件数量")] + public double? PartNum { get; set; } + + /// + /// 描述 + /// + [ExporterHeader(DisplayName = "描述")] + [ImporterHeader(Name = "描述")] + public string Description { get; set; } + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110Dto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110Dto.cs new file mode 100644 index 0000000..7736308 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110Dto.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + [Serializable] + public class CreateUpdateBillM110Dto + { + + /// + /// 流水号# + /// + public int? SerialNum { get; set; } + + /// + /// 大众顺序号 + /// + [Required] + public int? HostSN { get; set; } + + /// + /// KNR + /// + [Required] + [StringLength(100)] + public string KNR { get; set; } + + /// + /// 底牌号# + /// + [Required] + [StringLength(100)] + public string VIN { get; set; } + + /// + /// 总成ID + /// + public Guid? AssemblyID { get; set; } + + /// + /// 上线时间 + /// + [Required] + public DateTime? OnlineTime { get; set; } + + /// + /// 车型代码(取通用字典) + /// + [Required] + public string VehicleModelCode { get; set; } + + /// + /// 生产线(派格按生产线分类) + /// + public virtual string ProductLine { get; set; } + + /// + /// 版本 + /// + public string Version { get; set; } + + /// + /// 接收时间 + /// + [Required] + public DateTime? ReceiveTime { get; set; } + + /// + /// 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + /// + [Required] + public BillStatusEnum BillStatus { get; set; } + + /// + /// 描述 + /// + [StringLength(200)] + public string Description { get; set; } + + /// + /// 涂装重复单据包含的零件列表 + /// + public virtual List BillM110Parts { get; set; } + + /// + /// 手工操作类型:0 none,1 手工添加,2 手工修改 + /// + public ManualOperationTypeEnum OperationType { get; set; } + + /// + /// 手工操作员 + /// + public string Operator { get; set; } + + /// + /// 手工操作日期 + /// + public DateTime? OperationTime { get; set; } + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110PartDto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110PartDto.cs new file mode 100644 index 0000000..7962a39 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/CreateUpdateBillM110PartDto.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + [Serializable] + public class CreateUpdateBillM110PartDto + { + /// + /// 客户零件代码 + /// + [Required] + [StringLength(100)] + public string PartCode { get; set; } + + /// + /// 客户零件数量 + /// + [Required] + public double? PartNum { get; set; } + + /// + /// 描述 + /// + [StringLength(200)] + public string Description { get; set; } + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/QueryBillM110Dto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/QueryBillM110Dto.cs new file mode 100644 index 0000000..263674c --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/QueryBillM110Dto.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Volo.Abp.Application.Dtos; +using WY.NewJit.Common; + +namespace WY.NewJit.MsgCheck +{ + [Serializable] + public class QueryBillM110Dto : PagedAndSortedBase + { + /// + /// 流水号起 + /// + public int? SerialNumBegin { get; set; } + + /// + /// 流水号止 + /// + public int? SerialNumEnd { get; set; } + + /// + /// 大众顺序号起 + /// + public int? HostSNBegin { get; set; } + + /// + /// 大众顺序号止 + /// + public int? HostSNEnd { get; set; } + + /// + /// KNR起 + /// + public string KNRBegin { get; set; } + + /// + /// KNR止 + /// + public string KNREnd { get; set; } + + /// + /// 底牌号起 + /// + public string VINBegin { get; set; } + + /// + /// 底牌号止 + /// + public string VINEnd { get; set; } + + /// + /// 总成ID + /// + public Guid? AssemblyID { get; set; } + + /// + /// 上线时间起 + /// + public DateTime? OnlineTimeBegin { get; set; } + + /// + /// 上线时间止 + /// + public DateTime? OnlineTimeEnd { get; set; } + + + /// + /// 车型代码(取通用字典) + /// + public string VehicleModelCode { get; set; } + + /// + /// 生产线(派格按生产线分类) + /// + public virtual string ProductLine { get; set; } + + /// + /// 版本 + /// + public string Version { get; set; } + + /// + /// 接收时间起 + /// + public DateTime? ReceiveTimeBegin { get; set; } + + /// + /// 接收时间止 + /// + public DateTime? ReceiveTimeEnd { get; set; } + + /// + /// 单据状态(0 空;1 未匹配;2 未打印;3 已打印) + /// + public BillStatusEnum? BillStatus { get; set; } + + /// + /// 是否单据维护 + /// + public bool? IsBillMaintenance { get; set; } + + /// + /// 不可打印 + /// + public bool? CanNotPrint { get; set; } + + /// + /// 柱护板单据状态(0 空;1 未匹配;2 未打印;3 已打印) + /// + public ZHBBillStatusEnum? ZHBBillStatus { get; set; } + + /// + /// 为真时只显示需要补打的记录 + /// + public bool IsNeedReplenishPrint { get; set; } + + + public string GroupName { get; set; } = ""; + + /// + /// 是否查询M110归档数据 + /// + public bool IsQueryArchive { get; set; } = false; + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/ResultBillM110Dto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/ResultBillM110Dto.cs new file mode 100644 index 0000000..1668835 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Dtos/ResultBillM110Dto.cs @@ -0,0 +1,157 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + /// + /// 零件查询结果DTO + /// + [ExcelExporter(Name = "M110单据查询结果", AutoFitAllColumn = true, MaxRowNumberOnASheet = 1000)] //一个Sheet最大允许的行数,设置了之后将输出多个Sheet + [Serializable] + public class ResultBillM110Dto : EntityDto + { + /// + /// 流水号# + /// + [ExporterHeader(DisplayName = "流水号")] + [ImporterHeader(Name = "流水号")] + public int? SerialNum { get; set; } + + /// + /// 大众顺序号 + /// + [ExporterHeader(DisplayName = "大众顺序号")] + [ImporterHeader(Name = "大众顺序号")] + public int? HostSN { get; set; } + + /// + /// KNR + /// + [ExporterHeader(DisplayName = "KNR")] + [ImporterHeader(Name = "KNR")] + public string KNR { get; set; } + + /// + /// 底牌号# + /// + [ExporterHeader(DisplayName = "底牌号")] + [ImporterHeader(Name = "底牌号")] + public string VIN { get; set; } + + /// + /// 总成ID + /// + [ExporterHeader(DisplayName = "总成ID")] + [ImporterHeader(Name = "总成ID")] + public Guid? AssemblyID { get; set; } + + /// + /// 上线时间 + /// + [ExporterHeader(DisplayName = "上线时间")] + [ImporterHeader(Name = "上线时间")] + public DateTime? OnlineTime { get; set; } + + /// + /// 车型代码(取通用字典) + /// + [ExporterHeader(DisplayName = "车型代码")] + [ImporterHeader(Name = "车型代码")] + public string VehicleModelCode { get; set; } + + /// + /// 生产线(派格按生产线分类) + /// + public virtual string ProductLine { get; set; } + + /// + /// 版本 + /// + [ExporterHeader(DisplayName = "版本")] + [ImporterHeader(Name = "版本")] + public string Version { get; set; } + + /// + /// 接收时间 + /// + [ExporterHeader(DisplayName = "接收时间")] + [ImporterHeader(Name = "接收时间")] + public DateTime? ReceiveTime { get; set; } + + /// + /// 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + /// + [ExporterHeader(DisplayName = "单据状态")] + [ImporterHeader(Name = "单据状态")] + public BillStatusEnum BillStatus { get; set; } + + /// + /// 描述 + /// + [ExporterHeader(DisplayName = "描述")] + [ImporterHeader(Name = "描述")] + public string Description { get; set; } + + ///// + ///// 涂装重复单据包含的零件列表 + ///// + //public List M110BillParts { get; set; } + + /// + /// 总成名称 + /// + [ExporterHeader(DisplayName = "总成名称")] + [ImporterHeader(Name = "总成名称")] + public string AssemblyName { get; set; } + + /// + /// 车型名称(取通用字典) + /// + [ExporterHeader(DisplayName = "车型名称")] + [ImporterHeader(Name = "车型名称")] + public string VehicleModelName { get; set; } + + /// + /// R100总成名称 + /// + [ExporterHeader(DisplayName = "R100总成名称")] + [ImporterHeader(Name = "R100总成名称")] + public string R100AssemblyName { get; set; } + + /// + /// R100上线时间 + /// + [ExporterHeader(DisplayName = "R100上线时间")] + [ImporterHeader(Name = "R100上线时间")] + public DateTime? R100OnlineTime { get; set; } + + /// + /// 打印时间 + /// + [ExporterHeader(DisplayName = "打印时间")] + [ImporterHeader(Name = "打印时间")] + public virtual DateTime? PrintTime { get; set; } + + /// + /// 不可打印 + /// + [ExporterHeader(IsIgnore =true)] + [ImporterHeader(IsIgnore = true)] + public virtual bool? CanNotPrint { get; set; } + + /// + /// 柱护板打印状态(不为空时表示已打印) + /// + [ExporterHeader(IsIgnore = true)] + [ImporterHeader(IsIgnore = true)] + public virtual string PrintBillNum { get; set; } + + + + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Interfaces/IBillM110AppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Interfaces/IBillM110AppService.cs new file mode 100644 index 0000000..900ce5c --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM110s/Interfaces/IBillM110AppService.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using WY.NewJit.Extends; + +namespace WY.NewJit.MsgCheck +{ + public interface IBillM110AppService + { + #region 接口方法 + + /// 根据筛选条件获取分页实体列表 + /// + /// 输入查询条件 + /// 输入分页条件 + /// 返回符合条件的排序分页列表 + Task> GetListAsync(QueryBillM110Dto input); + + /// + /// 按主键获取唯一实体 + /// + /// 主键 + /// 实体信息 + Task> GetAsync(Guid id); + + /// + /// 添加实体 + /// + /// 添加内容 + /// 执行成功返回真 + Task> CreateAsync(CreateUpdateBillM110Dto input); + + /// + /// 修改实体 + /// + /// 更新主键 + /// 修改内容 + /// 执行成功返回真 + Task UpdateAsync(Guid id, CreateUpdateBillM110Dto input); + + + /// + /// 删除实体 + /// + /// 删除主键 + /// 执行成功返回真 + Task DeleteAsync(string id); + + /// + /// 导出信息 + /// + /// 导出查询条件 + /// 执行成功返回真 + Task> ExportAsync(QueryBillM110Dto input); + + /// + /// 导入信息 + /// + /// 导入文件流 + /// 执行成功返回真 + Task ImportAsync(Byte[] input); + + /// + /// 根据生产线获取正常打印单据的起始大众顺序号 + /// + /// 生产线 + /// 起始大众顺序号 + Task> GetPrintStartHostSN2(string productLine, string isZhuHuBan,string GroupName = null); + + /// + /// 打印前检查门板大众顺序号是否断号 + /// + /// + /// 断号时Item不为空 + Task> CheckMBHostSNBreakNum(MenBanPrintInputDto input); + + /// + /// 打印前检查柱护板大众顺序号是否断号 + /// + /// + /// 断号时Item不为空 + //Task> CheckZHBHostSNBreakNum(ZhuHuBanPrintInputDto input); + + /// + /// 打印门板装箱单 + /// + /// + /// 执行成功返回真 + //Task> PrintMenBanPackingList(MenBanPrintInputDto input); + + /// + /// 打印柱护板装箱单 + /// + /// + /// 执行成功返回真 + //Task> PrintZhuHuBanPackingList(ZhuHuBanPrintInputDto input); + + + #endregion + + /// + /// 生产线超时提醒 + /// + /// 生产线编号列表 + /// 生产线超时情况 + Task> ProductLineTimeoutRemind(TimeOutRemindInputDto input); + + //Task> GetReplenishPrintListAsync(QueryBillM110Dto input); + + + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110Dto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110Dto.cs new file mode 100644 index 0000000..9af6a0c --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110Dto.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Entities.Auditing; + +namespace WY.NewJit.MsgCheck +{ + /// + /// 涂装重复单据 + /// + [Serializable] + public class CreateUpdateRepeatM110Dto + { + /// + /// 报文接收ID,对应报文接收表主键 + /// + public Guid MessageFileReceiveID { get; set; } + + /// + /// 流水号# + /// + public int? SerialNum { get; set; } + + /// + /// 大众顺序号 + /// + public int? HostSN { get; set; } + /// + /// KNR + /// + public string KNR { get; set; } + + /// + /// 底牌号# + /// + public string VIN { get; set; } + /// + /// 总成ID + /// + public Guid? AssemblyID { get; set; } + /// + /// 上线时间 + /// + public DateTime? OnlineTime { get; set; } + /// + /// 接收时间 + /// + public DateTime? ReceiveTime { get; set; } + /// + /// 车型代码(取通用字典) + /// + public string VehicleModelCode { get; set; } + + /// + /// 生产线(派格按生产线分类) + /// + public virtual string ProductLine { get; set; } + + /// + /// 版本 + /// + public string Version { get; set; } + /// + /// 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + /// + public BillStatusEnum BillStatus { get; set; } + + /// + /// 描述 + /// + public virtual string Description { get; set; } + + /// + /// 涂装重复单据包含的零件列表 + /// + public virtual List M110RepeatParts { get; set; } + + public CreateUpdateRepeatM110Dto() + { } + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110PartDto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110PartDto.cs new file mode 100644 index 0000000..351c3c8 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/CreateUpdateRepeatM110PartDto.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Entities.Auditing; + +namespace WY.NewJit.MsgCheck +{ + /// + /// 涂装重复单据和零件关系表 + /// + [Serializable] + public class CreateUpdateRepeatM110PartDto + { + /// + /// 客户零件代码 + /// + public string PartCode { get; set; } + + /// + /// 客户零件数量 + /// + public double? PartNum { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + public CreateUpdateRepeatM110PartDto() + { } + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/QueryRepeatM110Dto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/QueryRepeatM110Dto.cs new file mode 100644 index 0000000..ead06e3 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/QueryRepeatM110Dto.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.Application.Dtos; +using WY.NewJit.Common; + +namespace WY.NewJit.MsgCheck +{ + [Serializable] + public class QueryRepeatM110Dto : PagedAndSortedBase + { + /// + /// 大众顺序号起 + /// + public int? HostSNBegin { get; set; } + + /// + /// 大众顺序号止 + /// + public int? HostSNEnd { get; set; } + + /// + /// KNR起 + /// + public string KNRBegin { get; set; } + + /// + /// KNR止 + /// + public string KNREnd { get; set; } + + /// + /// 底牌号起 + /// + public string VINBegin { get; set; } + + /// + /// 底牌号止 + /// + public string VINEnd { get; set; } + + /// + /// 总成ID + /// + //public Guid? AssemblyID { get; set; } + + /// + /// 上线时间起 + /// + public DateTime? OnlineTimeBegin { get; set; } + + /// + /// 上线时间止 + /// + public DateTime? OnlineTimeEnd { get; set; } + + + /// + /// 车型代码(取通用字典) + /// + public string VehicleModelCode { get; set; } + + /// + /// 生产线(派格按生产线分类) + /// + public virtual string ProductLine { get; set; } + + + /// + /// 版本 + /// + public string Version { get; set; } + + /// + /// 接收时间起 + /// + public DateTime? ReceiveTimeBegin { get; set; } + + /// + /// 接收时间止 + /// + public DateTime? ReceiveTimeEnd { get; set; } + + + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110Dto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110Dto.cs new file mode 100644 index 0000000..ddee39c --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110Dto.cs @@ -0,0 +1,115 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + /// + /// 零件查询结果DTO + /// + [ExcelExporter(Name = "M110重复报文", AutoFitAllColumn = true, MaxRowNumberOnASheet = 1000)] //一个Sheet最大允许的行数,设置了之后将输出多个Sheet + [Serializable] + public class RepeatM110Dto: AuditedEntityDto + { + /// + /// 流水号# + /// + [ExporterHeader(DisplayName = "流水号")] + [ImporterHeader(Name = "流水号")] + public int? SerialNum { get; set; } + + /// + /// 大众顺序号 + /// + [ExporterHeader(DisplayName = "大众顺序号")] + [ImporterHeader(Name = "大众顺序号")] + public int? HostSN { get; set; } + /// + /// KNR + /// + [ExporterHeader(DisplayName = "KNR")] + [ImporterHeader(Name = "KNR")] + public string KNR { get; set; } + + /// + /// 底牌号# + /// + [ExporterHeader(DisplayName = "底牌号")] + [ImporterHeader(Name = "底牌号")] + public string VIN { get; set; } + /// + /// 总成ID + /// + [ExporterHeader(DisplayName = "总成ID")] + [ImporterHeader(Name = "总成ID")] + public Guid? AssemblyID { get; set; } + /// + /// 上线时间 + /// + [ExporterHeader(DisplayName = "上线时间")] + [ImporterHeader(Name = "上线时间")] + public DateTime? OnlineTime { get; set; } + /// + /// 接收时间 + /// + [ExporterHeader(DisplayName = "接收时间")] + [ImporterHeader(Name = "接收时间")] + public DateTime? ReceiveTime { get; set; } + /// + /// 车型代码(取通用字典) + /// + [ExporterHeader(DisplayName = "车型代码")] + [ImporterHeader(Name = "车型代码")] + public string VehicleModelCode { get; set; } + + /// + /// 生产线(派格按生产线分类) + /// + [ExporterHeader(DisplayName = "生产线")] + [ImporterHeader(Name = "生产线")] + public virtual string ProductLine { get; set; } + + /// + /// 版本 + /// + [ExporterHeader(DisplayName = "版本")] + [ImporterHeader(Name = "版本")] + public string Version { get; set; } + /// + /// 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + /// + [ExporterHeader(DisplayName = "单据状态")] + [ImporterHeader(Name = "单据状态")] + public BillStatusEnum BillStatus { get; set; } + + /// + /// 描述 + /// + [ExporterHeader(DisplayName = "描述")] + [ImporterHeader(Name = "描述")] + public string Description { get; set; } + + /// + /// 涂装重复单据包含的零件列表 + /// + public List M110RepeatParts { get; set; } + + /// + /// 总成名称 + /// + [ExporterHeader(DisplayName = "总成名称")] + [ImporterHeader(Name = "总成名称")] + public string AssemblyName { get; set; } + + /// + /// 车型名称(取通用字典) + /// + [ExporterHeader(DisplayName = "车型名称")] + [ImporterHeader(Name = "车型名称")] + public string VehicleModelName { get; set; } + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110PartDto.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110PartDto.cs new file mode 100644 index 0000000..1fe85ae --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Dtos/RepeatM110PartDto.cs @@ -0,0 +1,38 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + /// + /// 零件查询结果DTO + /// + [ExcelExporter(Name = "M110重复报文包含的零件信息", AutoFitAllColumn = true, MaxRowNumberOnASheet = 1000)] //一个Sheet最大允许的行数,设置了之后将输出多个Sheet + [Serializable] + public class RepeatM110PartDto : EntityDto + { + /// + /// 客户零件代码 + /// + [ExporterHeader(DisplayName = "客户零件代码")] + [ImporterHeader(Name = "客户零件代码")] + public string PartCode { get; set; } + + /// + /// 客户零件数量 + /// + [ExporterHeader(DisplayName = "客户零件数量")] + [ImporterHeader(Name = "客户零件数量")] + public double? PartNum { get; set; } + + /// + /// 描述 + /// + [ExporterHeader(DisplayName = "描述")] + [ImporterHeader(Name = "描述")] + public string Description { get; set; } + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Interfaces/IRepeatM110AppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Interfaces/IRepeatM110AppService.cs new file mode 100644 index 0000000..d173c18 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/RepeatMessages/M110Repeat/Interfaces/IRepeatM110AppService.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgCheck +{ + public interface IRepeatM110AppService + { + #region 接口方法 + + /// 根据筛选条件获取分页实体列表 + /// + /// 输入查询条件 + /// 输入分页条件 + /// 返回符合条件的排序分页列表 + Task> GetListAsync(QueryRepeatM110Dto input); + + /// + /// 按主键获取唯一实体 + /// + /// 主键 + /// 实体信息 + Task> GetAsync(Guid id); + + /// + /// 添加实体 + /// + /// 添加内容 + /// 执行成功返回真 + Task> CreateAsync(CreateUpdateRepeatM110Dto input); + + /// + /// 删除实体 + /// + /// 删除主键 + /// 执行成功返回真 + Task DeleteAsync(string id); + + /// + /// 导出信息 + /// + /// 导出查询条件 + /// 执行成功返回真 + Task> ExportAsync(QueryRepeatM110Dto input); + + /// + /// 导入信息 + /// + /// 导入文件流 + /// 执行成功返回真 + Task ImportAsync(Byte[] input); + #endregion + + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml index c18958b..c7408b9 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml @@ -79,6 +79,11 @@ 门板装箱单明细 + + + 报表状态 + + 顺序号开始 @@ -1982,387 +1987,432 @@ - + 零件查询结果DTO - + + + 流水号# + + + 大众顺序号 - + KNR - + - 总成ID + 底牌号# - + - 上线时间 + 总成ID - + - 接收时间 + 上线时间 - + 车型代码(取通用字典) - + 生产线(派格按生产线分类) - + 版本 - + - 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + 接收时间 - + + + 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + + + 描述 - + - 焊装重复单据包含的零件列表 + 涂装重复单据包含的零件列表 - + + + 手工操作类型:0 none,1 手工添加,2 手工修改 + + + + + 手工操作员 + + + + + 手工操作日期 + + + 零件查询结果DTO - + 客户零件代码 - + 客户零件数量 - + 描述 - + + + 流水号# + + + 大众顺序号 - + KNR - + - 总成ID + 底牌号# - + - 上线时间 + 总成ID - + - 接收时间 + 上线时间 - + 车型代码(取通用字典) - + 生产线(派格按生产线分类) - + 版本 - + - 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + 接收时间 - + - 描述 + 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) - + - 焊装重复单据包含的零件列表 + 描述 - + - 客户零件代码 + 涂装重复单据包含的零件列表 - + - 客户零件数量 + 手工操作类型:0 none,1 手工添加,2 手工修改 - + - 描述 + 手工操作员 - + - 零件查询结果DTO + 手工操作日期 - + - KNR + 客户零件代码 - + - ERP总成编码 + 客户零件数量 - + - ERP总成名称 + 描述 - + - ERP总成数量 + 流水号起 - + - 大众顺序号 + 流水号止 - + - 上线时间 + 大众顺序号起 - + - 接收时间 + 大众顺序号止 - + - 生产线(派格按生产线分类) + KNR起 - + - 车型代码(取通用字典) + KNR止 - + - 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + 底牌号起 - + - 描述 + 底牌号止 - + - 大众顺序号起 + 总成ID - + - 大众顺序号止 + 上线时间起 - + - KNR起 + 上线时间止 - + - KNR止 + 车型代码(取通用字典) - + - 总成ID + 生产线(派格按生产线分类) - + - 上线时间起 + 版本 - + - 上线时间止 + 接收时间起 - + - 接收时间起 + 接收时间止 - + - 接收时间止 + 单据状态(0 空;1 未匹配;2 未打印;3 已打印) - + - 车型代码(取通用字典) + 是否单据维护 - + - 生产线(派格按生产线分类) + 不可打印 - + - 版本 + 柱护板单据状态(0 空;1 未匹配;2 未打印;3 已打印) - + - 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + 为真时只显示需要补打的记录 - + - 零件查询结果DTO + 是否查询M110归档数据 - + - 主键 + 零件查询结果DTO - + - KNR + 流水号# - + - 一个或多个ERP总成编码(逗号分隔) + 大众顺序号 - + - 一个或多个ERP总成名称(逗号分隔) + KNR - + - ERP总成数量 + 底牌号# - + - 大众顺序号 + 总成ID - + 上线时间 - + - 接收时间 + 车型代码(取通用字典) - + 生产线(派格按生产线分类) - + - 车型代码(取通用字典) + 版本 - + - 版本 + 接收时间 - + - 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) - + 描述 - + 总成名称 - + 车型名称(取通用字典) - + - 总成ID + R100总成名称 - + + + R100上线时间 + + + 打印时间 - - + + + 不可打印 + + + + + 柱护板打印状态(不为空时表示已打印) + + + + 按主键获取唯一实体 主键 实体信息 - + 添加实体 添加内容 执行成功返回真 - + 修改实体 @@ -2370,65 +2420,495 @@ 修改内容 执行成功返回真 - + 删除实体 删除主键 执行成功返回真 - + 导出信息 导出查询条件 执行成功返回真 - - - 导出包含ERP总成编码的信息 - - 导出查询条件 - 执行成功返回真 - - + 导入信息 导入文件流 执行成功返回真 - - + - 导出信息 + 根据生产线获取正常打印单据的起始大众顺序号 - 导出查询条件 - 执行成功返回真 + 生产线 + 起始大众顺序号 - + - 有焊装无总装 + 打印前检查门板大众顺序号是否断号 + + 断号时Item不为空 - + - 有焊装有总装 + 生产线超时提醒 + 生产线编号列表 + 生产线超时情况 - + - 流水号起 + 零件查询结果DTO - + - 流水号止 + 大众顺序号 - + - 大众顺序号起 + KNR + + + + + 总成ID + + + + + 上线时间 + + + + + 接收时间 + + + + + 车型代码(取通用字典) + + + + + 生产线(派格按生产线分类) + + + + + 版本 + + + + + 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + + + + + 描述 + + + + + 焊装重复单据包含的零件列表 + + + + + 零件查询结果DTO + + + + + 客户零件代码 + + + + + 客户零件数量 + + + + + 描述 + + + + + 大众顺序号 + + + + + KNR + + + + + 总成ID + + + + + 上线时间 + + + + + 接收时间 + + + + + 车型代码(取通用字典) + + + + + 生产线(派格按生产线分类) + + + + + 版本 + + + + + 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + + + + + 描述 + + + + + 焊装重复单据包含的零件列表 + + + + + 客户零件代码 + + + + + 客户零件数量 + + + + + 描述 + + + + + 零件查询结果DTO + + + + + KNR + + + + + ERP总成编码 + + + + + ERP总成名称 + + + + + ERP总成数量 + + + + + 大众顺序号 + + + + + 上线时间 + + + + + 接收时间 + + + + + 生产线(派格按生产线分类) + + + + + 车型代码(取通用字典) + + + + + 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + + + + + 描述 + + + + + 大众顺序号起 + + + + + 大众顺序号止 + + + + + KNR起 + + + + + KNR止 + + + + + 总成ID + + + + + 上线时间起 + + + + + 上线时间止 + + + + + 接收时间起 + + + + + 接收时间止 + + + + + 车型代码(取通用字典) + + + + + 生产线(派格按生产线分类) + + + + + 版本 + + + + + 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + + + + + 零件查询结果DTO + + + + + 主键 + + + + + KNR + + + + + 一个或多个ERP总成编码(逗号分隔) + + + + + 一个或多个ERP总成名称(逗号分隔) + + + + + ERP总成数量 + + + + + 大众顺序号 + + + + + 上线时间 + + + + + 接收时间 + + + + + 生产线(派格按生产线分类) + + + + + 车型代码(取通用字典) + + + + + 版本 + + + + + 单据状态(0 空;1 未匹配;2 已匹配未导出;3 已导出) + + + + + 描述 + + + + + 总成名称 + + + + + 车型名称(取通用字典) + + + + + 总成ID + + + + + 打印时间 + + + + + + 按主键获取唯一实体 + + 主键 + 实体信息 + + + + 添加实体 + + 添加内容 + 执行成功返回真 + + + + 修改实体 + + 更新主键 + 修改内容 + 执行成功返回真 + + + + 删除实体 + + 删除主键 + 执行成功返回真 + + + + 导出信息 + + 导出查询条件 + 执行成功返回真 + + + + 导出包含ERP总成编码的信息 + + 导出查询条件 + 执行成功返回真 + + + + 导入信息 + + 导入文件流 + 执行成功返回真 + + + + + 导出信息 + + 导出查询条件 + 执行成功返回真 + + + + 有焊装无总装 + + + + + 有焊装有总装 + + + + + 流水号起 + + + + + 流水号止 + + + + + 大众顺序号起 @@ -2897,6 +3377,302 @@ 导入文件流 执行成功返回真 + + + 涂装重复单据 + + + + + 报文接收ID,对应报文接收表主键 + + + + + 流水号# + + + + + 大众顺序号 + + + + + KNR + + + + + 底牌号# + + + + + 总成ID + + + + + 上线时间 + + + + + 接收时间 + + + + + 车型代码(取通用字典) + + + + + 生产线(派格按生产线分类) + + + + + 版本 + + + + + 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + + + + + 描述 + + + + + 涂装重复单据包含的零件列表 + + + + + 涂装重复单据和零件关系表 + + + + + 客户零件代码 + + + + + 客户零件数量 + + + + + 描述 + + + + + 大众顺序号起 + + + + + 大众顺序号止 + + + + + KNR起 + + + + + KNR止 + + + + + 底牌号起 + + + + + 底牌号止 + + + + + 上线时间起 + + + + + 上线时间止 + + + + + 车型代码(取通用字典) + + + + + 生产线(派格按生产线分类) + + + + + 版本 + + + + + 接收时间起 + + + + + 接收时间止 + + + + + 零件查询结果DTO + + + + + 流水号# + + + + + 大众顺序号 + + + + + KNR + + + + + 底牌号# + + + + + 总成ID + + + + + 上线时间 + + + + + 接收时间 + + + + + 车型代码(取通用字典) + + + + + 生产线(派格按生产线分类) + + + + + 版本 + + + + + 单据状态(0 空;1 未匹配;2 已匹配未打印;3 已打印) + + + + + 描述 + + + + + 涂装重复单据包含的零件列表 + + + + + 总成名称 + + + + + 车型名称(取通用字典) + + + + + 零件查询结果DTO + + + + + 客户零件代码 + + + + + 客户零件数量 + + + + + 描述 + + + + + + 按主键获取唯一实体 + + 主键 + 实体信息 + + + + 添加实体 + + 添加内容 + 执行成功返回真 + + + + 删除实体 + + 删除主键 + 执行成功返回真 + + + + 导出信息 + + 导出查询条件 + 执行成功返回真 + + + + 导入信息 + + 导入文件流 + 执行成功返回真 + diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM110s/BillM110AppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM110s/BillM110AppService.cs new file mode 100644 index 0000000..8be7ed5 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM110s/BillM110AppService.cs @@ -0,0 +1,5088 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using Volo.Abp.Domain.Repositories.Dapper; +using WY.NewJit.EntityFrameworkCore; +using WY.NewJit.Common; +using Shouldly; +using Volo.Abp.BlobStoring; +using Microsoft.AspNetCore.Mvc; +using WY.NewJit.Extends; +using WY.NewJit.MsgBaseData; +using WY.NewJit.Extends.PaiGe; +using WY.NewJit.Extends.PaiGe.WMS; +using System.Reflection; +using WY.NewJit.Commons; +using Volo.Abp; +using System.Diagnostics; + +namespace WY.NewJit.MsgCheck +{ + /// + /// M110单据管理应用服务实现 + /// + [Route("api/newjit/bill-M110")] + [ApiExplorerSettings(GroupName = SwaggerGroupConsts.报文解析及校验)] + public class BillM110AppService : ApplicationService, IBillM110AppService + { + #region 成员 + /// + /// 仓储 + /// + private readonly IRepository _billM110Repository; + + private readonly IRepository _billM110PartRepository; + + private readonly IRepository _printTemplateConfigurationRepository; + + private readonly IRepository _zHBPrintStatusRepository; + /// + /// 日志 + /// + private ILogger _logger; + + /// + /// Dapper仓储 + /// + private readonly NewJitDapperRepository _newJitDapperRepository; + + /// + /// BLOB存储 + /// + private readonly IBlobContainer _blobContainer; + + /// + /// 门板装箱单仓储 + /// + private readonly IRepository _menBanPackingListRepository; + + /// + /// 门板装箱单仓储明细 + /// + private readonly IRepository _menBanPackingRecRepository; + + /// + /// 柱护板装箱单仓储 + /// + private readonly IRepository _zhuHuBanPackingListRepository; + + /// + /// 柱护板装箱单仓储明细 + /// + private readonly IRepository _zhuHuBanPackingRecRepository; + + + /// + /// ERP总成仓储 + /// + private readonly IRepository _assemblyCfgErpRepository; + + /// + /// 整车总成配置仓库 + /// + private readonly IRepository _assemblyCfgVehicleRepository; + + /// + /// 零件配置 + /// + private readonly IRepository _partCfgRepository; + + /// + /// 派格版本物料库扩展 + /// + private readonly IRepository _materialExtRepository; + + /// + /// 最大右边号的领域方法 + /// + private readonly LineSNDomianService _lineSNDomianService; + + + /// + /// 库存系统Dapper仓储 + /// + private readonly WMSDapperRepository _wmsDapperRepository; + + /// + /// 序列领域服务 + /// + private readonly SequenceDomainService _sequenceDomainService; + + /// + /// 配置 + /// + private readonly Microsoft.Extensions.Configuration.IConfiguration _configuration; + + private readonly IUnitOfWorkManager _unitOfWorkManager; + + private readonly IRepository _tbBillRepository; + private readonly IRepository _tsSortDetailRepository; + private readonly IRepository _tbBillHisRepository; + private readonly IRepository _tsSortDetailHisRepository; + + private readonly IRepository _dicItemRepository; + + /// + /// 错误信息前缀 + /// + private string _errorMessagePrefix + { + get + { + return System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."; + } + } + + private const string _providerCode = "0709FAW-VW7XH"; + + private const int _hostSNMaxVal = 1999; + + /// + /// 柱护板缓存列表(打印柱护板时用到) + /// + private List _zhbCacheList = new List(); + + private string _topBoxPositionNumPrefix; + #endregion + + #region 构造函数 + /// + /// 构造函数 + /// + public BillM110AppService( + IRepository BillM110Repository, + IRepository BillM110PartRepository, + ILogger logger, + NewJitDapperRepository newJitDapperRepository, + IBlobContainer blobContainer, + IRepository menBanPackingListRepository, + IRepository zhuHuBanPackingListRepository, + IRepository assemblyCfgErpRepository, + IRepository assemblyCfgVehicleRepository, + IRepository partCfgRepository, + IRepository materialExtRepository, + WMSDapperRepository wmsDapperRepository, + IRepository menBanPackingRecRepository, + LineSNDomianService lineSNDomianService, + IRepository zhuHuBanPackingRecRepository, + SequenceDomainService sequenceDomainService, + Microsoft.Extensions.Configuration.IConfiguration configuration, + IUnitOfWorkManager unitOfWorkManager, + IRepository tbBillRepository, + IRepository tsSortDetailRepository, + IRepository tbBillHisRepository, + IRepository tsSortDetailHisRepository, + IRepository printTemplateConfigurationRepository, + IRepository zHBPrintStatusRepository, + IRepository dicItemRepository + + + ) + { + _billM110Repository = BillM110Repository; + _billM110PartRepository = BillM110PartRepository; + _logger = logger; + _newJitDapperRepository = newJitDapperRepository; + _blobContainer = blobContainer; + _menBanPackingListRepository = menBanPackingListRepository; + _zhuHuBanPackingListRepository = zhuHuBanPackingListRepository; + _assemblyCfgErpRepository = assemblyCfgErpRepository; + _assemblyCfgVehicleRepository = assemblyCfgVehicleRepository; + _partCfgRepository = partCfgRepository; + _materialExtRepository = materialExtRepository; + _wmsDapperRepository = wmsDapperRepository; + _menBanPackingRecRepository = menBanPackingRecRepository; + _zhuHuBanPackingRecRepository = zhuHuBanPackingRecRepository; + _lineSNDomianService = lineSNDomianService; + _sequenceDomainService = sequenceDomainService; + _configuration = configuration; + _unitOfWorkManager = unitOfWorkManager; + _tbBillRepository = tbBillRepository; + _tsSortDetailRepository = tsSortDetailRepository; + _tbBillHisRepository = tbBillHisRepository; + _tsSortDetailHisRepository = tsSortDetailHisRepository; + _printTemplateConfigurationRepository = printTemplateConfigurationRepository; + _zHBPrintStatusRepository = zHBPrintStatusRepository; + _topBoxPositionNumPrefix = _configuration["ConfigDic:TopBoxPositionNumPrefix"]; + _dicItemRepository = dicItemRepository; + } + #endregion + + #region 私有方法 + /// + /// 查询柱护板 + /// + /// + /// + /// + private async Task> QueryZHBByConditionAsync(QueryBillM110Dto input, PagedAndSortedBase page) + { + PagedResultDto ret = new PagedResultDto(); + + string sqlCnt = @" +with d as +( + select * from FisZHBPrintStatus where groupName='{1}' +) +, r as +( + select rr.KNR, aa.AssemblyName, rr.OnlineTime from FisBillR100 rr left join FisAssemblyCfgVehicle aa on rr.AssemblyID = aa.Id +) +select * from +( + select count(*) as cnt + from FisBillM110 b + left join d on b.VIN=d.VIN + left join FisAssemblyCfgVehicle a on b.AssemblyID = a.Id + left join r on b.KNR = r.KNR + where 1=1 {0} +) t +"; + + string sql = @" +with d as +( + select *from [dbo].[FisZHBPrintStatus] where groupName='{3}' +) +, r as +( + select rr.KNR, aa.AssemblyName, rr.OnlineTime from FisBillR100 rr left join FisAssemblyCfgVehicle aa on rr.AssemblyID = aa.Id +) +select * from +( + select ROW_NUMBER() OVER(order by b.SerialNumStr) as row_number, + b.*, a.AssemblyName, r.AssemblyName as R100AssemblyName, r.OnlineTime as R100OnlineTime + from FisBillM110 b + left join d on b.VIN=d.VIN + left join FisAssemblyCfgVehicle a on b.AssemblyID = a.Id + left join r on b.KNR = r.KNR + where 1=1 {0} +) t where row_number between {1} and {2} order by SerialNumStr +"; + if (input.IsQueryArchive == true) + { + sqlCnt = sqlCnt.Replace("FisBillM110", "FisBillM110_His"); + sql = sql.Replace("FisBillM110", "FisBillM110_His"); + } + + + string where = ""; + //if (!string.IsNullOrEmpty(input.VehicleModelCode)) + //{ + // where += string.Format(" and d.DicItemName = '{0}'", input.VehicleModelCode); + //} + if (input.SerialNumBegin != null) + { + where += string.Format(" and b.SerialNum >= {0}", input.SerialNumBegin); + } + if (input.SerialNumEnd != null) + { + where += string.Format(" and b.SerialNum <= {0}", input.SerialNumEnd); + } + if (input.HostSNBegin != null) + { + where += string.Format(" and b.HostSN >= {0}", input.HostSNBegin); + } + if (input.HostSNEnd != null) + { + where += string.Format(" and b.HostSN <= {0}", input.HostSNEnd); + } + if (!string.IsNullOrEmpty(input.KNRBegin)) + { + where += string.Format(" and b.KNR >= '{0}'", input.KNRBegin); + } + if (!string.IsNullOrEmpty(input.KNREnd)) + { + where += string.Format(" and b.KNR <= '{0}'", input.KNREnd); + } + if (!string.IsNullOrEmpty(input.VINBegin)) + { + where += string.Format(" and b.VIN >= '{0}'", input.VINBegin); + } + if (!string.IsNullOrEmpty(input.VINEnd)) + { + where += string.Format(" and b.VIN <= '{0}'", input.VINEnd); + } + if (input.AssemblyID != null) + { + where += string.Format(" and b.AssemblyID = '{0}'", input.AssemblyID.ToString()); + } + if (input.OnlineTimeBegin != null) + { + where += string.Format(" and b.OnlineTime >= '{0}'", ((DateTime)input.OnlineTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.OnlineTimeEnd != null) + { + where += string.Format(" and b.OnlineTime <= '{0}'", ((DateTime)input.OnlineTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.VehicleModelCode != null) + { + where += string.Format(" and b.VehicleModelCode like '%{0}%'", input.VehicleModelCode); + } + if (input.ProductLine != null) + { + where += string.Format(" and b.ProductLine = '{0}'", input.ProductLine); + } + if (input.Version != null) + { + where += string.Format(" and b.Version like '%{0}%'", input.Version); + } + if (input.ReceiveTimeBegin != null) + { + where += string.Format(" and b.ReceiveTime >= '{0}'", ((DateTime)input.ReceiveTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.ReceiveTimeEnd != null) + { + where += string.Format(" and b.ReceiveTime <= '{0}'", ((DateTime)input.ReceiveTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.IsBillMaintenance == true) //M110单据信息维护模块使用 + { + where += " and b.Operator is not null"; + } + if (input.CanNotPrint == true) + { + where += " and b.CanNotPrint = 1"; + } + else if (input.CanNotPrint == false) + { + where += " and (b.CanNotPrint is null or b.CanNotPrint = 0)"; + where += " and (b.NeedReplenishPrint is null or b.NeedReplenishPrint = 0)"; + } + + if (input.ZHBBillStatus != null && input.ZHBBillStatus != ZHBBillStatusEnum.None) + { + if (input.ZHBBillStatus == ZHBBillStatusEnum.Print) //柱护板已打印 + { + where += " and ( b.PrintBillNum is not null or d.BillStatus=1 ) "; + } + else if (input.ZHBBillStatus == ZHBBillStatusEnum.NotPrint) //柱护板未打印 + { + where += " and b.PrintBillNum is null and d.BillStatus is null "; + } + } + else if (input.BillStatus != null && input.BillStatus != BillStatusEnum.None) + { + where += string.Format(" and b.BillStatus = {0}", ((int)input.BillStatus).ToString()); + } + else + { + where += " and b.BillStatus in (2,3)"; //单据状态是已匹配、已打印 + } + + if (input.IsNeedReplenishPrint == true) //只显示需要补打的记录 + { + where += " and b.NeedReplenishPrint = 1"; + } + string groupname = input.GroupName; + sqlCnt = string.Format(sqlCnt, where, groupname); + ret.TotalCount = await _newJitDapperRepository.GetSingleBySqlAsync(sqlCnt); + + //计算分页 + int fromRec = page.SkipCount + 1; + int ToRec = page.SkipCount + page.MaxResultCount; + + sql = string.Format(sql, where, fromRec, ToRec, groupname); + var lst = await _newJitDapperRepository.GetListBySqlAsync(sql); + ret.Items = lst; + return ret; + } + + + /// + /// 从M110中取当前产线、已经打印的最大大众顺序号 + /// + /// + /// + private async Task GetMenBanLastPrintNum(MenBanPrintInputDto input) + { + string sql = @" select top(1) HostSN from FisBillM110 where ProductLine = '{0}' and BillStatus = 3 order by SerialNumStr desc"; + sql = string.Format(sql, input.ProductLine); + var lastNum = await _newJitDapperRepository.GetSingleBySqlAsync(sql); + return lastNum; + } + +// private async Task GetZhuHuBanLastPrintNum(ZhuHuBanPrintInputDto input) +// { +// string sql = @" with d as +//( +// select *from [dbo].[FisZHBPrintStatus] where groupName='{0}' +//) + +//select top(1) HostSN from +//( +// select d.CreationTime as ptime, +// b.* +// from FisBillM110 b +// join d on b.VIN=d.VIN +// where 1=1 and ProductLine='{1}' and ( b.PrintBillNum is not null or d.BillStatus=1) +//) t order by SerialNumStr desc "; +// sql = string.Format(sql, input.GroupName,input.ProductLine); +// var lastNum = await _newJitDapperRepository.GetSingleBySqlAsync(sql); +// return lastNum; +// } + + /// + /// 根据筛选条件获取实体列表 + /// + private async Task> QueryByConditionAsync(QueryBillM110Dto input, PagedAndSortedBase page) + { + PagedResultDto ret = new PagedResultDto(); + + string sqlCnt = @" +with d as +( + select * from FisDicItem where DicTypeCode in (select DicTypeCode from FisDicType where DicTypeName = '车型') +) +, r as +( + select rr.KNR, '' as AssemblyName, rr.OnlineTime from FisBillR100 rr +) +select * from +( + select count(*) as cnt + from FisBillM110 b + left join d on b.VehicleModelCode = d.DicItemCode + --left join FisAssemblyCfgVehicle a on b.AssemblyID = a.Id + left join r on b.KNR = r.KNR + where 1=1 {0} +) t +"; + + string sql = @" +with d as +( + select * from FisDicItem where DicTypeCode in (select DicTypeCode from FisDicType where DicTypeName = '车型') +) +, r as +( + select rr.KNR, '' as AssemblyName, rr.OnlineTime from FisBillR100 rr +) +select * from +( + select ROW_NUMBER() OVER(order by b.SerialNumStr) as row_number, + b.*, d.DicItemName as VehicleModelName, '' as AssemblyName, r.AssemblyName as R100AssemblyName, r.OnlineTime as R100OnlineTime + from FisBillM110 b + left join d on b.VehicleModelCode = d.DicItemCode + --left join FisAssemblyCfgVehicle a on b.AssemblyID = a.Id + left join r on b.KNR = r.KNR + where 1=1 {0} +) t where row_number between {1} and {2} order by SerialNumStr +"; + if (input.IsQueryArchive == true) + { + sqlCnt = sqlCnt.Replace("FisBillM110", "FisBillM110_His"); + sql = sql.Replace("FisBillM110", "FisBillM110_His"); + } + + string where = ""; + //if (!string.IsNullOrEmpty(input.VehicleModelCode)) + //{ + // where += string.Format(" and d.DicItemName = '{0}'", input.VehicleModelCode); + //} + if (input.SerialNumBegin != null) + { + where += string.Format(" and b.SerialNum >= {0}", input.SerialNumBegin); + } + if (input.SerialNumEnd != null) + { + where += string.Format(" and b.SerialNum <= {0}", input.SerialNumEnd); + } + if (input.HostSNBegin != null) + { + where += string.Format(" and b.HostSN >= {0}", input.HostSNBegin); + } + if (input.HostSNEnd != null) + { + where += string.Format(" and b.HostSN <= {0}", input.HostSNEnd); + } + if (!string.IsNullOrEmpty(input.KNRBegin)) + { + where += string.Format(" and b.KNR >= '{0}'", input.KNRBegin); + } + if (!string.IsNullOrEmpty(input.KNREnd)) + { + where += string.Format(" and b.KNR <= '{0}'", input.KNREnd); + } + if (!string.IsNullOrEmpty(input.VINBegin)) + { + where += string.Format(" and b.VIN >= '{0}'", input.VINBegin); + } + if (!string.IsNullOrEmpty(input.VINEnd)) + { + where += string.Format(" and b.VIN <= '{0}'", input.VINEnd); + } + if (input.AssemblyID != null) + { + where += string.Format(" and b.AssemblyID = '{0}'", input.AssemblyID.ToString()); + } + if (input.OnlineTimeBegin != null) + { + where += string.Format(" and b.OnlineTime >= '{0}'", ((DateTime)input.OnlineTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.OnlineTimeEnd != null) + { + where += string.Format(" and b.OnlineTime <= '{0}'", ((DateTime)input.OnlineTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.VehicleModelCode != null) + { + where += string.Format(" and b.VehicleModelCode like '%{0}%'", input.VehicleModelCode); + } + if (input.ProductLine != null) + { + where += string.Format(" and b.ProductLine = '{0}'", input.ProductLine); + } + if (input.Version != null) + { + where += string.Format(" and b.Version like '%{0}%'", input.Version); + } + if (input.ReceiveTimeBegin != null) + { + where += string.Format(" and b.ReceiveTime >= '{0}'", ((DateTime)input.ReceiveTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.ReceiveTimeEnd != null) + { + where += string.Format(" and b.ReceiveTime <= '{0}'", ((DateTime)input.ReceiveTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.IsBillMaintenance == true) //M110单据信息维护模块使用 + { + where += " and b.Operator is not null"; + } + if (input.CanNotPrint == true) + { + where += " and b.CanNotPrint = 1"; + } + else if (input.CanNotPrint == false) + { + where += " and (b.CanNotPrint is null or b.CanNotPrint = 0)"; + where += " and (b.NeedReplenishPrint is null or b.NeedReplenishPrint = 0)"; + } + + if (input.ZHBBillStatus != null && input.ZHBBillStatus != ZHBBillStatusEnum.None) + { + if (input.ZHBBillStatus == ZHBBillStatusEnum.Print) //柱护板已打印 + { + where += " and b.PrintBillNum is not null"; + } + else if (input.ZHBBillStatus == ZHBBillStatusEnum.NotPrint) //柱护板未打印 + { + where += " and b.PrintBillNum is null"; + } + } + else if (input.BillStatus != null && input.BillStatus != BillStatusEnum.None) + { + where += string.Format(" and b.BillStatus = {0}", ((int)input.BillStatus).ToString()); + } + else + { + //where += " and b.BillStatus in (2,3)"; //单据状态是已匹配、已打印 + } + + if (input.IsNeedReplenishPrint == true) //只显示需要补打的记录 + { + where += " and b.NeedReplenishPrint = 1"; + } + + sqlCnt = string.Format(sqlCnt, where); + ret.TotalCount = await _newJitDapperRepository.GetSingleBySqlAsync(sqlCnt); + + //计算分页 + int fromRec = page.SkipCount + 1; + int ToRec = page.SkipCount + page.MaxResultCount; + sql = string.Format(sql, where, fromRec, ToRec); + var lst = await _newJitDapperRepository.GetListBySqlAsync(sql); + ret.Items = lst; + return ret; + } + + /// + /// 取单据包含的ERP总成列表 + /// + /// + /// + //private List GetErpAssemblyListByBill(Guid vehicleAssemblyId) + //{ + // List retLst = new List(); + // AssemblyCfgVehicle vobj = _assemblyCfgVehicleRepository.GetAsync(vehicleAssemblyId).GetAwaiter().GetResult(); //取单据对应的整车总成 + // if (vobj != null && vobj.AssemblyCfgVehicleChilds != null && vobj.AssemblyCfgVehicleChilds.Count > 0) + // { + // List vehicleChildLst = vobj.AssemblyCfgVehicleChilds; + // foreach (AssemblyCfgVehicleChild vehicleChildItm in vehicleChildLst) + // { + // AssemblyCfgErp erpObj = _assemblyCfgErpRepository.GetAsync(vehicleChildItm.ErpAssemblyId).GetAwaiter().GetResult(); + // if (erpObj != null) + // { + // retLst.Add(erpObj); + // } + // } + // } + // return retLst; + //} + + #endregion + + #region 门板装箱单 + + /// + /// 根据条件取用于打印的门板单据列表 + /// + /// + /// 断号时是否填充 + /// 是否柱护板装箱单调用 + /// + private async Task> GetMBReportDetailList(MenBanPrintInputDto input, bool isFillBreakNum = false) + { + List billLst = new List(); + ListResultDto ret = new ListResultDto(billLst); + + int printBillCnt = 0; + if (input.PrintType == PrintTypeEnum.正常打印) + { + if ((input.BeginHostSN % 10000) > 1999) + { + throw new Exception("起始大众顺序号不能大于1999!"); + } + if (input.BeginHostSN > input.EndHostSN) + { + throw new Exception("起始大众顺序号不能大于止大众顺序号!"); + } + + printBillCnt = input.EndHostSN - input.BeginHostSN + 1; + + var firstObj = await _billM110Repository.FirstOrDefaultAsync(itm => + itm.ProductLine == input.ProductLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && itm.BillStatus != BillStatusEnum.Publish //不等于 已打印 + && itm.HostSN == input.BeginHostSN + ); + if (firstObj == null) + { + throw new Exception("没有找到起始大众顺序号!!"); + } + + if ((input.EndHostSN % 10000) > 1999) //存在大众顺序号1999、0001的情况 + { + string firstSNStr = firstObj.SerialNumStr; + var tempLst = await _billM110Repository + .Include(itm => itm.BillM110Parts) + .Where(itm => itm.ProductLine == input.ProductLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && itm.BillStatus != BillStatusEnum.Publish //不等于 已打印 + && itm.SerialNumStr.CompareTo(firstSNStr) >= 0) + .OrderBy(itm => itm.SerialNumStr) + .Take(printBillCnt * 2).ToListAsync(); + + #region 1998、1999和0001、0002反了 + var tempLst1999 = tempLst.Where(itm => itm.HostSN % 10000 > 1999 - 240).OrderBy(itm => itm.HostSN).ToList(); + var tempLst0001 = tempLst.Where(itm => itm.HostSN % 10000 < 240).OrderBy(itm => itm.HostSN).ToList(); + billLst.AddRange(tempLst1999); + billLst.AddRange(tempLst0001); + billLst = billLst.Take(printBillCnt).ToList(); + #endregion + } + else //起止大众顺序号都小于等于1999 + { + string firstSNStr2 = firstObj.SerialNumStr; + billLst = await _billM110Repository + .Include(itm => itm.BillM110Parts) + .Where(itm => itm.ProductLine == input.ProductLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && itm.BillStatus != BillStatusEnum.Publish //不等于 已打印 + && itm.SerialNumStr.CompareTo(firstSNStr2) >= 0 + && itm.HostSN >= input.BeginHostSN + && itm.HostSN <= input.EndHostSN + ).OrderBy(itm => itm.HostSN).ToListAsync(); + } + + bool hasData = billLst.Any(); + if (hasData == false) + { + ret.Message = $"输入的起始大众顺序号没有对应的数据。生产线:{input.ProductLine},起止顺序号:{input.BeginHostSN} - {input.EndHostSN}"; + ret.Status = false; + return ret; + } + } + else if (input.PrintType == PrintTypeEnum.补打) + { + //string beginVin = input.BeginVin.TryToRight(6); + //string endVin = input.EndVin.TryToRight(6); + ////printBillCnt = endVin.TryToIntZero() - beginVin.TryToIntZero() + 1; + + //string sql = "select Id from FisBillM110 where ProductLine = '{0}' and BillStatus = {1} and right(vin,6) between '{2}' and '{3}'"; + //sql = string.Format(sql, input.ProductLine, (int)BillStatusEnum.Match, beginVin, endVin); + //List guidLst = await _newJitDapperRepository.GetListBySqlAsync(sql, true); + //if (guidLst.Count == 0) + //{ + // ret.Message = $"输入的起止底盘号没有对应的数据。生产线:{input.ProductLine},底盘号:{beginVin}至{endVin}"; + // ret.Status = false; + // return ret; + //} + + ////取指定生产线、等于已匹配状态、起止VIN范围 + //billLst = await _billM110Repository.GetListAsync( + // itm => guidLst.Contains(itm.Id) + // , true); + //billLst = billLst.OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + } + + # region 断号处理 + if (isFillBreakNum == true && billLst.Count > 1 && input.PrintType != PrintTypeEnum.补打) + { + billLst = DoBreakNumOperation(input.BeginHostSN, input.EndHostSN, billLst); + } + #endregion + + if ((input.EndHostSN % 10000) > 1999) + { + #region 1998、1999和0001、0002反了 + var tempLst1999 = billLst.Where(itm => itm.HostSN % 10000 > 1999 - 240).OrderBy(itm => itm.HostSN).ToList(); + var tempLst0001 = billLst.Where(itm => itm.HostSN % 10000 < 240).OrderBy(itm => itm.HostSN).ToList(); + billLst.Clear(); + billLst.AddRange(tempLst1999); + billLst.AddRange(tempLst0001); + if (printBillCnt > 0) //tst + { + billLst = billLst.Take(printBillCnt).ToList(); + } + #endregion + } + else + { + if (printBillCnt > 0) //tst + billLst = billLst.OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).Take(printBillCnt).ToList(); + else + billLst = billLst.OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + } + ret.Item = billLst; + return ret; + } + + /// + /// 补充断号数据 + /// + /// + /// + /// + /// + private static List DoBreakNumOperation(int beginHostSN, int endHostSN, List billLst) + { + List emptyLst = new List(); + int cnt = endHostSN - beginHostSN + 1; + + List newLst = billLst; + + bool hasBegin = newLst.Any(itm => itm.HostSN == beginHostSN); + if (hasBegin == false) //没有起始报文、插入起始报文 + { + BillM110 newObj = new BillM110(); + newObj.OnlineTime = ((DateTime)newLst[0].OnlineTime).AddMinutes(-1); + newObj.HostSN = beginHostSN; + newObj.HostSN2 = beginHostSN; + //newObj.SerialNumStr = ServerHelper.ToSerialNumStr(newObj.OnlineTime, newObj.HostSN2, "M110", billLst[0].ProductLine); + newObj.SerialNumStr = ServerHelper.ToSerialNumStr(billLst[0].SerialNumStr, newObj.HostSN2); + newLst.Add(newObj); + } + //1999跨号:HostSN 51998 51999 50001 50002 => HostSN2 51998 51999 52000 52001 + if ((endHostSN % 10000) > 1999) + { + foreach (BillM110 newObj in newLst) + { + int newHostSN = (newObj.HostSN ?? 0) % 10000; + + if (newHostSN < 1000) //HostSN 50001 50002 => 52000 52001 ... + { + newObj.HostSN2 = newObj.HostSN; //newObj.HostSN2 = newObj.HostSN + 1999; + //newObj.SerialNumStr = ServerHelper.ToSerialNumStr(newObj.OnlineTime, newObj.HostSN2, "M110", newObj.ProductLine); //屏蔽:SerialNumStr通过加秒部分(默认00,上线时间相同情况下跨号时01)已经实现正确排序 + } + else //HostSN ... 51998 51999 + { + newObj.HostSN2 = newObj.HostSN; + } + } + } + else + { + foreach (BillM110 newObj in newLst) + { + newObj.HostSN2 = newObj.HostSN; + } + } + //newLst = newLst.OrderBy(itm => itm.HostSN2).ThenBy(itm => itm.HostSN).ToList(); + newLst = newLst.OrderBy(itm => itm.SerialNumStr).ToList(); + //插入断号数据 + for (int i = 1; i < newLst.Count; i++) + { + int priorHostSN2 = (int)newLst[i - 1].HostSN2; + int curHostSN2 = (int)newLst[i].HostSN2; + if (curHostSN2 > priorHostSN2) //0005、0006 + { + if (curHostSN2 > priorHostSN2 + 1) //0005、0008时,补号 0006、0007 + { + for (int j = priorHostSN2 + 1; j < curHostSN2; j++) + { + BillM110 newObj = new BillM110(); + newObj.OnlineTime = newLst[i - 1].OnlineTime; + newObj.HostSN = ((j % 10000) > 1999) ? (j - 1999) : j; + newObj.HostSN2 = j; + //newObj.SerialNumStr = ServerHelper.ToSerialNumStr(newObj.OnlineTime, newObj.HostSN2, "M110", billLst[0].ProductLine); + newObj.SerialNumStr = ServerHelper.ToSerialNumStr(newLst[i - 1].SerialNumStr, newObj.HostSN2); + emptyLst.Add(newObj); + //if (newLst.Count + emptyLst.Count > cnt) + if (emptyLst.Count > cnt) + { + break; + } + } + } + } + //else if (curSN < priorSN) //1999到0001的情况 + //{ + // if (curSN + _hostSNMaxVal > priorSN + 1) //0005、0008时,补号 0006、0007 + // { + // for (int j = priorSN + 1; j < curSN + _hostSNMaxVal; j++) + // { + // BillM110 newObj = new BillM110(); + // newObj.OnlineTime = newLst[i - 1].OnlineTime; + // newObj.HostSN = (j > _hostSNMaxVal ? j - _hostSNMaxVal : j); + // emptyLst.Add(newObj); + // if (newLst.Count + emptyLst.Count > cnt) + // { + // break; + // } + + // } + // } + //} + } + newLst.AddRange(emptyLst); + //newLst = newLst.OrderBy(itm => itm.HostSN2).ThenBy(itm => itm.HostSN).ToList(); + newLst = newLst.OrderBy(itm => itm.SerialNumStr).ToList(); + return newLst; + } + + /// + /// 取新的装箱单号 + /// + /// 加1后的序号 + /// + //private string GetBillNum(long newSN) + //{ + // string newSNStr = newSN.ToString(); + // //装箱单号规则 1开头,11位,自增顺序号 + // if (newSNStr.Length < 11) + // { + // return "F" + newSNStr.PadLeft(10, '0'); + // } + // return newSNStr; + //} + + /// + /// 打印左侧或右侧门板 + /// + /// + /// + /// + /// + /// + /// + /// + /// + private MenBanPackingList DoMBPrint(MenBanPrintInputDto input, int pageIdx, double maxSN, List billLst, string reportSort, string[] partLargeType) + { + const int _colNumberPerPage = 12; + + //取当前页内容 + List curPageLst = billLst.Skip(pageIdx * _colNumberPerPage).Take(_colNumberPerPage).ToList(); + + var vmLst = curPageLst.Select(itm => itm.VehicleModelCode).Distinct().JoinAsString(","); //取车型 + string ymd = ServerHelper.CurrentDateTime.ToString("yyyyMMdd"); + string serialNum = maxSN.ToString().PadLeft(3, '0'); //075 + + MenBanPackingList packingMain = new MenBanPackingList(); + packingMain.SetId(GuidGenerator.Create()); + packingMain.BillNum = $"C{ymd}{serialNum}{reportSort}"; + packingMain.VehicleModel = vmLst; + packingMain.BillSerialNum = serialNum; + packingMain.PrintDate = ServerHelper.CurrentDateTime; + packingMain.ProductLine = billLst[0].ProductLine; + + var tempLst = curPageLst.Where(itm => string.IsNullOrEmpty(itm.VIN) == false).OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + if (tempLst.Count > 0) + { + packingMain.BeginVin = tempLst[0].VIN; + packingMain.EndVin = tempLst[tempLst.Count - 1].VIN; + packingMain.BeginHostSN = tempLst[0].HostSN.ToString(); + packingMain.EndHostSN = tempLst[tempLst.Count - 1].HostSN.ToString(); + } + packingMain.MinOnlineTime = tempLst.Min(itm => itm.OnlineTime); //本单据最早的上线时间 + //明细 + int sn = 1; + foreach (BillM110 billObj in curPageLst) + { + MenBanPackingRec packingDetail = new MenBanPackingRec(); + packingDetail.SetId(GuidGenerator.Create()); + packingDetail.M100BillId = billObj.Id; + packingDetail.KNR = billObj.KNR; + packingDetail.VIN = billObj.VIN; + packingDetail.HostSN = billObj.HostSN?.ToString(); + if (billObj.VIN == null) + { + packingDetail.VIN += "*断号*"; + } + //第一个零件 + if (partLargeType.Length >= 1) + { + var partObj = billObj.BillM110Parts.FirstOrDefault(itm => itm.PartType3 == partLargeType[0]); + if (partObj != null) + { + packingDetail.PartCode1 = partObj.PartCode; + } + } + //第二个零件 + if (partLargeType.Length >= 2) + { + var partObj = billObj.BillM110Parts.FirstOrDefault(itm => itm.PartType3 == partLargeType[1]); + if (partObj != null) + { + packingDetail.PartCode2 = partObj.PartCode; + } + } + //第三个零件 + if (partLargeType.Length >= 3) + { + var partObj = billObj.BillM110Parts.FirstOrDefault(itm => itm.PartType3 == partLargeType[2]); + if (partObj != null) + { + packingDetail.PartCode3 = partObj.PartCode; + } + } + //第四个零件 + if (partLargeType.Length >= 4) + { + var partObj = billObj.BillM110Parts.FirstOrDefault(itm => itm.PartType3 == partLargeType[3]); + if (partObj != null) + { + packingDetail.PartCode4 = partObj.PartCode; + } + } + packingDetail.SN = sn.ToString(); + packingMain.Details.Add(packingDetail); + sn++; + } + return packingMain; + } + + /// + /// 上箱位号加前缀 + /// KNR前4位 大于等于 2402的 属于新发货状态, 不加前缀; + /// 小于 2402的 属于老发货状态, 加前缀 + /// + /// + /// + /// + //private string GetTopBoxPositionNumPrefix(string knr) + //{ + // if (knr.IsNullOrEmpty() || knr.Length < 4) + // { + // return ""; + // } + // string knrPrefix = knr.Substring(0, 4); + + // int res = string.Compare(knrPrefix, "2402"); + // if (res >= 0) + // { + // return ""; + // } + // else + // { + // return _topBoxPositionNumPrefix ?? ""; + // } + + //} + + /// + /// 打印门板装箱单时调用库存系统接口 + /// + /// + //private void CallWMSInterface_MB(List input) + //{ + + // List targetMainLst = new List(); + // List targetDetailLst = new List(); + // List cxLst = new List(); + // foreach (MenBanPackingList sourceObj in input) + // { + // TB_BILL targetMain = new TB_BILL(); + // targetMain.BillNum = sourceObj.BillNum; //单据编号 + // targetMain.State = 0; + // targetMain.BillType = 206; //单据类型 + // targetMain.SubBillType = 21004; //单据子类型 + // targetMain.BillTime = sourceObj.PrintDate; //单据时间 + // targetMain.OperName = sourceObj.CreatorId.ToString(); //操作员 + // targetMain.DetailQty = 0; //明细数量 + // targetMain.CustId = _providerCode; //供应商编号 + // //targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + // //targetMain.DockCode = sourceObj.BillLocation; + + // targetMain.GateCode = sourceObj.PartType; //B柱下 + // targetMain.GateName = sourceObj.BillSerialNum; //顺序号 + // targetMain.DockCode = sourceObj.VehicleModel; //左或右 + // targetMain.Remark = sourceObj.MinOnlineTime == null ? null : ((DateTime)sourceObj.MinOnlineTime).ToString("yyyy-MM-dd HH:mm"); //最早上线时间(预计到达时间) + // targetMain.TransportType = sourceObj.BillSerialNum; //顺序号 + // targetMain.SourceBillNum3 = sourceObj.ProductLine; //2022-10-13加生产线 + // targetMainLst.Add(targetMain); + // int idx = 0; + // int idx2 = 0; + // foreach (MenBanPackingRec sourceRec in sourceObj.Details) + // { + // idx2++; + // if (sourceRec.PartCode2.IsNullOrEmpty() == false) + // { + // var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.PartCode2 && itm.MaterialType == "1"); + // idx++; + // TS_SORT_DETAIL targetDetail = new TS_SORT_DETAIL(); + // targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + // targetDetail.LineNum = idx2; //行号 + // targetDetail.VinCode = sourceRec.VIN; //VIN码 + // targetDetail.SeqNum = idx2.ToString(); //顺序号sourceRec.HostSN.ToString() + // targetDetail.PartCode = sourceRec.PartCode2; //物料号 + // //targetDetail.BarCode = sourceRec.TopBoxPositionNum; //箱码 + // targetDetail.ProjectId = ""; //车型 + // targetDetail.PlanQty = 1; //计划数量 + // targetDetail.State = "0"; //状态 + // targetDetail.CustPartCode = materialObj == null ? null : materialObj.RelationKey; + // targetDetail.FullBarCode = null; + // targetDetail.VendId = sourceRec.KNR; + + // //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + + // targetDetailLst.Add(targetDetail); + // if (materialObj != null && materialObj.VehicleModel != null) + // { + // cxLst.Add(materialObj.VehicleModel); + // } + // } + // if (sourceRec.PartCode4.IsNullOrEmpty() == false) + // { + // var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.PartCode4 && itm.MaterialType == "1"); + + // idx++; + // TS_SORT_DETAIL targetDetail = new TS_SORT_DETAIL(); + // targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + // targetDetail.VinCode = sourceRec.VIN; //VIN码 + // targetDetail.PartCode = sourceRec.PartCode4; //物料号 + // targetDetail.LineNum = (idx2 + 12); //行号 + // targetDetail.SeqNum = (idx2 + 12).ToString(); //顺序号sourceRec.HostSN.ToString() + // //targetDetail.BarCode = sourceRec.TopBoxPositionNum; //箱码 + // targetDetail.ProjectId = ""; //车型 + // targetDetail.State = "0"; //状态 + // targetDetail.PlanQty = 1; //计划数量 + // targetDetail.CustPartCode = materialObj == null ? null : materialObj.RelationKey; + // targetDetail.FullBarCode = null; + // targetDetail.VendId = sourceRec.KNR; + + // //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + + // targetDetailLst.Add(targetDetail); + // if (materialObj != null && materialObj.VehicleModel != null) + // { + // cxLst.Add(materialObj.VehicleModel); + // } + // } + // } + // //生成车型 + // string cxStr = ""; + // foreach (string cxObj in cxLst.Distinct()) + // { + // cxStr += cxObj + "、"; + // } + // if (cxStr.Length > 0) + // { + // cxStr = cxStr.Substring(0, cxStr.Length - 1); + // } + // targetMain.ProjectId = cxStr; //添加车型 + + // if (string.IsNullOrEmpty(cxStr)) + // { + // targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + // } + + // } + // foreach (TB_BILL targetMain in targetMainLst) + // { + // //明细数量 + // targetMain.DetailQty = targetDetailLst.Where(p=>p.BillNum== targetMain.BillNum).Count(); + // int cnt = InsertOrUpdateWMSMain(targetMain); + // if (cnt == 0) + // { + // throw new Exception("插入或更新库存系统接口表记录数为零!"); + // } + // } + // foreach (TS_SORT_DETAIL targetDetail in targetDetailLst) + // { + // int cnt = InsertOrUpdateWMSDetail(targetDetail); + // if (cnt == 0) + // { + // throw new Exception("插入或更新库存系统接口表记录数为零!"); + // } + // } + + //} + //private int InsertOrUpdateWMSMain(TB_BILL targetMain) + //{ + // int ret = 0; + // string sqlSelMain = string.Format("select * from TB_BILL where BillNum = '{0}'", targetMain.BillNum); + // TB_BILL wmsMain = _wmsDapperRepository.GetSingleBySql(sqlSelMain, true); + // if (wmsMain == null) + // { + // string sqlInsertMain = @" + // insert into TB_BILL (BillNum, [State], BillType, SubBillType, BillTime, OperName, DetailQty, CustId, ProjectId, DockCode, GateCode, GateName, Remark) + // values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')"; + // sqlInsertMain = string.Format(sqlInsertMain, + // targetMain.BillNum, targetMain.State, targetMain.BillType, targetMain.SubBillType, targetMain.BillTime, + // targetMain.OperName, targetMain.DetailQty, targetMain.CustId, targetMain.ProjectId, targetMain.DockCode, targetMain.GateCode, targetMain.GateName, targetMain.Remark); + // try + // { + // ret = _wmsDapperRepository.ExecuteSql(sqlInsertMain, null, true); + // } + // catch (Exception ex) + // { + // throw new Exception("调用InsertOrUpdateWMSMain方法时报错:" + ex.Message + "SQL:" + sqlInsertMain + "单据号:" + targetMain.BillNum); + // } + // } + // else + // { + // if (wmsMain.State != 0) + // { + // throw new Exception("库存系统接口主表中已经存在该单据,并且已经排序,不能重新打印,单据号" + wmsMain.BillNum); + // } + // string sqlUpdateMain = @" + // update TB_BILL set + // [State] = '{1}', + // BillType = '{2}', + // SubBillType = '{3}', + // BillTime = '{4}', + // OperName = '{5}', + // DetailQty = '{6}', + // CustId = '{7}', + // ProjectId = '{8}', + // DockCode = '{9}', + // GateCode = '{10}', + // GateName = '{11}', + // Remark = '{12}' + // where BillNum = '{0}' + // "; + // sqlUpdateMain = string.Format(sqlUpdateMain, + // targetMain.BillNum, targetMain.State, targetMain.BillType, targetMain.SubBillType, targetMain.BillTime, + // targetMain.OperName, targetMain.DetailQty, targetMain.CustId, targetMain.ProjectId, targetMain.DockCode, targetMain.GateCode, targetMain.GateName, targetMain.Remark); + // try + // { + // ret = _wmsDapperRepository.ExecuteSql(sqlUpdateMain, null, true); + // } + // catch (Exception ex) + // { + // throw new Exception("调用InsertOrUpdateWMSMain方法时报错:" + ex.Message + "SQL:" + sqlUpdateMain + "单据号:" + targetMain.BillNum); + // } + + // } + // return ret; + //} + + //private int InsertOrUpdateWMSDetail(TS_SORT_DETAIL targetDetail) + //{ + // int ret = 0; + // string sqlSelDetail = string.Format("select * from TS_SORT_DETAIL where BillNum = '{0}' and VinCode = '{1}' and PartCode = '{2}'", targetDetail.BillNum, targetDetail.VinCode, targetDetail.PartCode); + // TS_SORT_DETAIL wmsDetail = _wmsDapperRepository.GetSingleBySql(sqlSelDetail, true); + // if (wmsDetail == null) + // { + // string sqlInsertDetail = @" + // insert into TS_SORT_DETAIL ( + // BillNum, VinCode, PartCode, LineNum, SeqNum, + // ProjectId, [State], BarCode, PlanQty, CustPartCode, + // FullBarCode, VendId) + // values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}')"; + // sqlInsertDetail = string.Format(sqlInsertDetail, + // targetDetail.BillNum, targetDetail.VinCode, targetDetail.PartCode, targetDetail.LineNum, targetDetail.SeqNum, + // targetDetail.ProjectId, targetDetail.State, targetDetail.BarCode, targetDetail.PlanQty, targetDetail.CustPartCode, + // targetDetail.FullBarCode, targetDetail.VendId); + // try + // { + // ret = _wmsDapperRepository.ExecuteSql(sqlInsertDetail, null, true); + // } + // catch (Exception ex) + // { + // throw new Exception("调用InsertOrUpdateWMSDetail方法时报错:" + ex.Message + "SQL:" + sqlInsertDetail); + // } + // } + // else + // { + // string sqlUpdateDetail = @" + // update TS_SORT_DETAIL set + // LineNum = '{3}', + // SeqNum = '{4}', + // ProjectId = '{5}', + // [State] = '{6}', + // BarCode = '{7}', + // PlanQty = '{8}', + // CustPartCode = '{9}', + // FullBarCode = '{10}' + // VendId = '{11}' + // where BillNum = '{0}' and VinCode = '{1}' and PartCode = '{2}' + // "; + // sqlUpdateDetail = string.Format(sqlUpdateDetail, + // targetDetail.BillNum, targetDetail.VinCode, targetDetail.PartCode, targetDetail.LineNum, targetDetail.SeqNum, + // targetDetail.ProjectId, targetDetail.State, targetDetail.BarCode, targetDetail.PlanQty, targetDetail.CustPartCode, + // targetDetail.FullBarCode, targetDetail.VendId); + // try + // { + // ret = _wmsDapperRepository.ExecuteSql(sqlUpdateDetail, null, true); + // } + // catch (Exception ex) + // { + // throw new Exception("调用InsertOrUpdateWMSDetail方法时报错:" + ex.Message + "SQL:" + sqlUpdateDetail); + // } + // } + // return ret; + //} + + #endregion + /* + #region 柱护板装箱单 + //private void DelOrScrapWMSInterface(string billNum) + //{ + // //重新打印时,库存系统接口如果存在已发运的正常打印单据,则不允许重新打印;如果存在未发运的正常打印单据则删除该单据 + // string oldBillNum = billNum; + // TB_BILL oldBillObj = _wmsDapperRepository.GetSingleBySql($"select top 1 * from TB_BILL where BillNum = '{oldBillNum}'", true); + // if (oldBillObj != null) + // { + // if (oldBillObj.State == 0) + // { + // string sqlMain = $"delete from TS_SORT_DETAIL where BillNum = '{oldBillNum}'"; + // _wmsDapperRepository.ExecuteSql(sqlMain, null, true); + + // string sqlDetail = $"delete from TB_BILL where BillNum = '{oldBillNum}'"; + // _wmsDapperRepository.ExecuteSql(sqlDetail, null, true); + // } + // else + // { + // throw new BusinessException("1001", $"该单据{oldBillNum}在库存系统中已经排序或发运,不允许删除!"); + // } + // } + //} + + /// + /// 根据条件取用于打印的柱护板单据列表 + /// + /// + /// + /// + private async Task> GetZHBReportDetailList(ZhuHuBanPrintInputDto input, bool isFillBreakNum = false) + { + List billLst = new List(); + ListResultDto ret = new ListResultDto(billLst); + + int printBillCnt = 0; + if (input.PrintType == PrintTypeEnum.正常打印) + { + if ((input.BeginHostSN % 10000) > 1999) + { + throw new Exception("起始大众顺序号不能大于1999!"); + } + if (input.BeginHostSN > input.EndHostSN) + { + throw new Exception("起始大众顺序号不能大于止大众顺序号!"); + } + + printBillCnt = input.EndHostSN - input.BeginHostSN + 1; + + var query = from a in _billM110Repository.Where(r => r.ProductLine == input.ProductLine + && r.CanNotPrint != true + && string.IsNullOrEmpty(r.PrintBillNum) == true + && r.HostSN >= input.BeginHostSN + && r.HostSN <= input.EndHostSN) + join b in _zHBPrintStatusRepository.Where(r => r.GroupName == input.GroupName) + on a.VIN equals b.VIN + into cls + from c in cls.DefaultIfEmpty() + where c.GroupName != null + select a.HostSN; + + + var oldsn = await query.ToListAsync(); + if ((input.EndHostSN % 10000) > 1999) + { + var firstObj = await _billM110Repository.FirstOrDefaultAsync(itm => + itm.ProductLine == input.ProductLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && string.IsNullOrEmpty(itm.PrintBillNum) == true //不等于 已打印 + && itm.HostSN == input.BeginHostSN + && !oldsn.Contains(itm.HostSN) + ); + if (firstObj != null) + { + string firstSNStr = firstObj.SerialNumStr; + List idLst = await _billM110Repository.Where(itm => + itm.ProductLine == input.ProductLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && string.IsNullOrEmpty(itm.PrintBillNum) == true //不等于 已打印 + && itm.SerialNumStr.CompareTo(firstSNStr) >= 0 + && !oldsn.Contains(itm.HostSN) + ) + .OrderBy(itm => itm.SerialNumStr) + .Take(printBillCnt * 2).Select(itm => itm.Id).ToListAsync(); + + var tempLst = await _billM110Repository.GetListAsync(itm => idLst.Contains(itm.Id), true); + + #region 1998、1999和0001、0002反了 + var tempLst1999 = tempLst.Where(itm => itm.HostSN % 10000 > 1999 - 240).OrderBy(itm => itm.HostSN).ToList(); + var tempLst0001 = tempLst.Where(itm => itm.HostSN % 10000 < 240).OrderBy(itm => itm.HostSN).ToList(); + billLst.AddRange(tempLst1999); + billLst.AddRange(tempLst0001); + billLst = billLst.Take(printBillCnt).ToList(); + #endregion + //billLst = billLst.OrderBy(itm => itm.SerialNumStr).ToList(); + } + else + { + throw new Exception("没有找到起始大众顺序号!!"); + } + } + else //起止大众顺序号都小于等于1999 + { + + var firstObj2 = await _billM110Repository.FirstOrDefaultAsync(itm => + itm.ProductLine == input.ProductLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && string.IsNullOrEmpty(itm.PrintBillNum) == true //不等于 已打印 + && itm.HostSN == input.BeginHostSN + && !oldsn.Contains(itm.HostSN) + ); + if (firstObj2 != null) + { + string firstSNStr2 = firstObj2.SerialNumStr; + billLst = await _billM110Repository.GetListAsync(itm => + itm.ProductLine == input.ProductLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && string.IsNullOrEmpty(itm.PrintBillNum) == true //不等于 已打印 + && itm.SerialNumStr.CompareTo(firstSNStr2) >= 0 + && itm.HostSN >= input.BeginHostSN + && itm.HostSN <= input.EndHostSN + && !oldsn.Contains(itm.HostSN) + , true); + } + else + { + throw new Exception("没有找到起始大众顺序号!!"); + } + billLst = billLst.OrderBy(itm => itm.HostSN).ToList(); + } + + bool hasData = billLst.Any(); + if (hasData == false) + { + ret.Message = $"输入的起始大众顺序号没有对应的数据。生产线:{input.ProductLine},起止顺序号:{input.BeginHostSN} - {input.EndHostSN}"; + ret.Status = false; + return ret; + } + } + else if (input.PrintType == PrintTypeEnum.补打) + { + //string beginVin = input.BeginVin.TryToRight(6); + //string endVin = input.EndVin.TryToRight(6); + ////printBillCnt = endVin.TryToIntZero() - beginVin.TryToIntZero() + 1; + + //string sql = "select Id from FisBillM110 where ProductLine = '{0}' and BillStatus = {1} and right(vin,6) between '{2}' and '{3}'"; + //sql = string.Format(sql, input.ProductLine, (int)BillStatusEnum.Match, beginVin, endVin); + //List guidLst = await _newJitDapperRepository.GetListBySqlAsync(sql, true); + //if (guidLst.Count == 0) + //{ + // ret.Message = $"输入的起止底盘号没有对应的数据。生产线:{input.ProductLine},底盘号:{beginVin}至{endVin}"; + // ret.Status = false; + // return ret; + //} + + ////取指定生产线、等于已匹配状态、起止VIN范围 + //billLst = await _billM110Repository.GetListAsync( + // itm => guidLst.Contains(itm.Id) + // , true); + //billLst = billLst.OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + } + + #region 断号处理 + if (isFillBreakNum == true && billLst.Count > 1 && input.PrintType != PrintTypeEnum.补打) + { + billLst = DoBreakNumOperation(input.BeginHostSN, input.EndHostSN, billLst); + } + #endregion + + if ((input.EndHostSN % 10000) > 1999) + { + #region 1998、1999和0001、0002反了 + var tempLst1999 = billLst.Where(itm => itm.HostSN % 10000 > 1999 - 240).OrderBy(itm => itm.HostSN).ToList(); + var tempLst0001 = billLst.Where(itm => itm.HostSN % 10000 < 240).OrderBy(itm => itm.HostSN).ToList(); + billLst.Clear(); + billLst.AddRange(tempLst1999); + billLst.AddRange(tempLst0001); + if (printBillCnt > 0) //tst + { + billLst = billLst.Take(printBillCnt).ToList(); + } + #endregion + } + else + { + if (printBillCnt > 0) //tst + billLst = billLst.OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).Take(printBillCnt).ToList(); + else + billLst = billLst.OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + } + //billLst = billLst.OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).Take(24).ToList(); + ret.Item = billLst; + return ret; + } + + /// + /// 打印柱护板(3*8 左右合并成一个单元格)A上C上 + /// + /// + /// + /// + /// + /// + /// + /// + /// + private List DoZHBPrint_3x8_LRMerge(string zhbPartType, ZhuHuBanPrintInputDto input, long maxBillNum, double maxSN, DateTime printTime, List billLst, string rightOrLeft) + { + List retLst = new List(); + + //填充柱护板装箱单主实体 + ZhuHuBanPackingList zhbObj = new ZhuHuBanPackingList(); + zhbObj.SetId(GuidGenerator.Create()); + + zhbObj.BillNum = GetBillNum(maxBillNum); + zhbObj.BillSerialNum = maxSN.ToString().PadLeft(2, '0'); + + zhbObj.BillLocation = null; //右或左或空 + zhbObj.ProviderCode = _providerCode; //供应商厂家代码 + zhbObj.PartType = zhbPartType; //零件类型:例如 B柱下 + //int rongLiang = billLst.Count(itm => itm.BillStatus == BillStatusEnum.Match || itm.BillStatus == BillStatusEnum.Publish); + int rongLiang = billLst.Count(); + zhbObj.Capacity = $"{rongLiang * 2} + {rongLiang * 2}"; //器具容量 + zhbObj.PrintDate = printTime; //打印日期 + zhbObj.PrintType = input.PrintType; + zhbObj.ProductLine = input.ProductLine; + + var tempLst = billLst.Where(itm => string.IsNullOrEmpty(itm.VIN) == false).OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + if (tempLst.Count > 0) + { + zhbObj.BeginVin = tempLst[0].VIN; ; + zhbObj.EndVin = tempLst[tempLst.Count - 1].VIN; + zhbObj.BeginHostSN = tempLst[0].HostSN.ToString(); + zhbObj.EndHostSN = tempLst[tempLst.Count - 1].HostSN.ToString(); + } + zhbObj.MinOnlineTime = billLst.Min(itm => itm.OnlineTime); //取最早上线时间,库存接口用 + + //取当前页的详细信息 + foreach (BillM110 billObj in billLst) + { + ZhuHuBanPackingRec zhbRec = new ZhuHuBanPackingRec(); + zhbRec.SetId(GuidGenerator.Create()); + zhbRec.M110BillId = billObj.Id; + zhbRec.KNR = billObj.KNR; + zhbRec.VIN = billObj.VIN; + zhbRec.HostSN = billObj.HostSN; + if (billObj.BillM110Parts != null && billObj.BillM110Parts.Count > 0) + { + //取柱护板-A上C上 + if (zhbPartType == "A上C上") + { + //左、右两个单元格合并,合并后一页有24个单元格(3行*8列),一页包含24辆车、48个A上柱护板、48个C上柱护板 + MaterialExt materialObj = GetZhuHuBanByType("A柱上", rightOrLeft + "侧", billObj); + if (materialObj != null) + { + zhbRec.MaterialDescription = materialObj.MaterialDescription; + zhbRec.PartCode = materialObj.RelationKey; + } + + MaterialExt materialObj2 = GetZhuHuBanByType("C柱上", rightOrLeft + "侧", billObj); + if (materialObj2 != null) + { + zhbRec.MaterialDescription2 = materialObj2.MaterialDescription; + zhbRec.PartCode2 = materialObj2.RelationKey; + } + + } //A上C上 + } + zhbObj.Details.Add(zhbRec); + } //foreach + retLst.Add(zhbObj); + return retLst; + } //DoZHBPrint + + /// + /// 打印柱护板(3*8 分左右)A柱下A中 + /// + /// + /// + /// + /// + /// + /// + /// + /// + private List DoZHBPrint_3x8_LR(string zhbPartType, ZhuHuBanPrintInputDto input, long maxBillNum, double maxSN, DateTime printTime, List billLst, string rightOrLeft) + { + List retLst = new List(); + + //填充柱护板装箱单主实体 + ZhuHuBanPackingList zhbObj = new ZhuHuBanPackingList(); + zhbObj.SetId(GuidGenerator.Create()); + + long maxBillNum2 = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + zhbObj.BillNum = GetBillNum(maxBillNum2); + zhbObj.BillSerialNum = maxSN.ToString().PadLeft(2, '0'); + + zhbObj.BillLocation = rightOrLeft; //右或左或空 + zhbObj.ProviderCode = _providerCode; //供应商厂家代码 + zhbObj.PartType = zhbPartType; //零件类型:例如 B柱下 + //string rongLiang = billLst.Count(itm => itm.BillStatus == BillStatusEnum.Match || itm.BillStatus == BillStatusEnum.Publish).ToString(); + string rongLiang = billLst.Count().ToString(); + zhbObj.Capacity = rongLiang + "+" + rongLiang; //器具容量 + zhbObj.PrintDate = printTime; //打印日期 + zhbObj.PrintType = input.PrintType; + zhbObj.ProductLine = input.ProductLine; + var tempLst = billLst.Where(itm => string.IsNullOrEmpty(itm.VIN) == false).OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + if (tempLst.Count > 0) + { + zhbObj.BeginVin = tempLst[0].VIN; + zhbObj.EndVin = tempLst[tempLst.Count - 1].VIN; + zhbObj.BeginHostSN = tempLst[0].HostSN.ToString(); + zhbObj.EndHostSN = tempLst[tempLst.Count - 1].HostSN.ToString(); + } + zhbObj.MinOnlineTime = billLst.Min(itm => itm.OnlineTime); //取最早上线时间,库存接口用 + + + //取当前页的详细信息 + foreach (BillM110 billObj in billLst) + { + ZhuHuBanPackingRec zhbRec = new ZhuHuBanPackingRec(); + zhbRec.SetId(GuidGenerator.Create()); + zhbRec.M110BillId = billObj.Id; + zhbRec.KNR = billObj.KNR; + zhbRec.VIN = billObj.VIN; + zhbRec.HostSN = billObj.HostSN; + if (billObj.BillM110Parts != null && billObj.BillM110Parts.Count > 0) + { + //取A柱下、A中 + if (zhbPartType == "A柱下A中") + { + //每页3行*8列,一次打印24辆车,分两页,一张显示左A柱下A中、一张显示右; + //紧邻两行,上行显示A下、下行显示A中。A下目前只有一种颜色 + MaterialExt materialObj = GetZhuHuBanByType("A柱下", rightOrLeft + "侧", billObj); + if (materialObj != null) + { + zhbRec.MaterialDescription = materialObj.MaterialDescription; + zhbRec.PartCode = materialObj.RelationKey; + } + + MaterialExt materialObj2 = GetZhuHuBanByType("A柱中", rightOrLeft + "侧", billObj); + if (materialObj2 != null) + { + zhbRec.MaterialDescription2 = materialObj2.MaterialDescription; + zhbRec.PartCode2 = materialObj2.RelationKey; + } + + }//if A柱下A中 + } + zhbObj.Details.Add(zhbRec); + } //foreach + retLst.Add(zhbObj); + return retLst; + } //DoZHBPrint + + /// + /// 打印柱护板(4*6 分左右)B柱上;B柱下;后轮上装饰板 + /// + /// + /// + /// + /// + /// + /// + /// + /// + private List DoZHBPrint_4x6_LR(string zhbPartType, ZhuHuBanPrintInputDto input, long maxBillNum, double maxSN, DateTime printTime, List billLst, string rightOrLeft) + { + List retLst = new List(); + + //填充柱护板装箱单主实体 + ZhuHuBanPackingList zhbObj = new ZhuHuBanPackingList(); + zhbObj.SetId(GuidGenerator.Create()); + + long maxBillNum2 = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + zhbObj.BillNum = GetBillNum(maxBillNum2); + zhbObj.BillSerialNum = maxSN.ToString().PadLeft(2, '0'); + + zhbObj.BillLocation = rightOrLeft; //右或左 + zhbObj.ProviderCode = _providerCode; //供应商厂家代码 + zhbObj.PartType = zhbPartType; //零件类型:例如 B柱下 + if (zhbPartType == "后轮上装饰板") + { + //string rongLiang = billLst.Count(itm => itm.BillStatus == BillStatusEnum.Match || itm.BillStatus == BillStatusEnum.Publish).ToString(); + string rongLiang = billLst.Count().ToString(); + zhbObj.Capacity = rongLiang + "+" + rongLiang; + } + else + { + //zhbObj.Capacity = billLst.Count(itm => itm.BillStatus == BillStatusEnum.Match || itm.BillStatus == BillStatusEnum.Publish).ToString(); //器具容量 + zhbObj.Capacity = billLst.Count().ToString(); //器具容量 + } + zhbObj.PrintDate = printTime; //打印日期 + zhbObj.PrintType = input.PrintType; + zhbObj.ProductLine = input.ProductLine; + var tempLst = billLst.Where(itm => string.IsNullOrEmpty(itm.VIN) == false).OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + if (tempLst.Count > 0) + { + zhbObj.BeginVin = tempLst[0].VIN; + zhbObj.EndVin = tempLst[tempLst.Count - 1].VIN; + zhbObj.BeginHostSN = tempLst[0].HostSN.ToString(); + zhbObj.EndHostSN = tempLst[tempLst.Count - 1].HostSN.ToString(); + } + zhbObj.MinOnlineTime = billLst.Min(itm => itm.OnlineTime); //取最早上线时间,库存接口用 + + + //取当前页的详细信息 + foreach (BillM110 billObj in billLst) + { + ZhuHuBanPackingRec zhbRec; + if (billObj.BillM110Parts != null && billObj.BillM110Parts.Count > 0) + { + if (zhbPartType == "B柱上") + { + zhbRec = new ZhuHuBanPackingRec(); + zhbRec.SetId(GuidGenerator.Create()); + zhbRec.M110BillId = billObj.Id; + zhbRec.KNR = billObj.KNR; + zhbRec.VIN = billObj.VIN; + zhbRec.HostSN = billObj.HostSN; + + //B柱上:左右柱护板分别打印在不同的两页,每页4行*6列 + MaterialExt materialObj = GetZhuHuBanByType(zhbPartType, rightOrLeft + "侧", billObj); + if (materialObj != null) + { + zhbRec.MaterialDescription = materialObj.MaterialDescription; + zhbRec.PartCode = materialObj.RelationKey; + } + zhbObj.Details.Add(zhbRec); + } + else if (zhbPartType == "B柱下") + { + zhbRec = new ZhuHuBanPackingRec(); + zhbRec.SetId(GuidGenerator.Create()); + zhbRec.M110BillId = billObj.Id; + zhbRec.KNR = billObj.KNR; + zhbRec.VIN = billObj.VIN; + zhbRec.HostSN = billObj.HostSN; + + //B柱下:左右柱护板分别打印在不同的两页,每页4行*6列 + MaterialExt materialObj = GetZhuHuBanByType(zhbPartType, rightOrLeft + "侧", billObj); + if (materialObj != null) + { + zhbRec.MaterialDescription = materialObj.MaterialDescription; + zhbRec.PartCode = materialObj.RelationKey; + } + zhbObj.Details.Add(zhbRec); + } + else if (zhbPartType == "后轮上装饰板") + { + zhbRec = new ZhuHuBanPackingRec(); + zhbRec.SetId(GuidGenerator.Create()); + zhbRec.M110BillId = billObj.Id; + zhbRec.KNR = billObj.KNR; + zhbRec.VIN = billObj.VIN; + zhbRec.HostSN = billObj.HostSN; + //后轮上装饰板:显示后轮; 左右柱护板分别打印在不同的两页,每页4行*6列 + MaterialExt materialObj = GetZhuHuBanByType("后轮", rightOrLeft + "侧", billObj); + if (materialObj != null) + { + zhbRec.MaterialDescription = materialObj.MaterialDescription; + zhbRec.PartCode = materialObj.RelationKey; + } + + MaterialExt materialObj2 = GetZhuHuBanByType("上装饰板", rightOrLeft + "侧", billObj); + if (materialObj2 != null) + { + zhbRec.MaterialDescription2 = materialObj2.MaterialDescription; + zhbRec.PartCode2 = materialObj2.RelationKey; + } + zhbObj.Details.Add(zhbRec); + + } //if 后轮上装饰板 + } + else + { + //没有柱护板字典时,用空白单元格填充(之前不填充,造成后面空行) + zhbRec = new ZhuHuBanPackingRec(); + zhbRec.SetId(GuidGenerator.Create()); + zhbRec.M110BillId = billObj.Id; + zhbRec.KNR = billObj.KNR; + zhbRec.VIN = billObj.VIN; + zhbRec.HostSN = billObj.HostSN; + zhbObj.Details.Add(zhbRec); + } + + } //foreach + retLst.Add(zhbObj); + return retLst; + } //DoZHBPrint + + /// + /// 打印柱护板(4*3 左右相邻)D柱 + /// + /// + /// + /// + /// + /// + /// + /// + /// + private List DoZHBPrint_4x3(string zhbPartType, ZhuHuBanPrintInputDto input, long maxBillNum, double maxSN, DateTime printTime, List billLst, string rightOrLeft = null) + { + List retLst = new List(); + + //填充柱护板装箱单主实体 + ZhuHuBanPackingList zhbObj = new ZhuHuBanPackingList(); + zhbObj.SetId(GuidGenerator.Create()); + + long maxBillNum2 = maxBillNum; //_sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + zhbObj.BillNum = GetBillNum(maxBillNum2); + zhbObj.BillSerialNum = maxSN.ToString().PadLeft(2, '0'); + + zhbObj.BillLocation = null; //右或左 + zhbObj.ProviderCode = _providerCode; //供应商厂家代码 + zhbObj.PartType = zhbPartType; //零件类型:例如 B柱下 + //int capacity = billLst.Count(itm => itm.BillStatus == BillStatusEnum.Match || itm.BillStatus == BillStatusEnum.Publish); + int capacity = billLst.Count(); + zhbObj.Capacity = $"{capacity}+{capacity}"; //器具容量 + zhbObj.PrintDate = printTime; //打印日期 + zhbObj.PrintType = input.PrintType; + zhbObj.ProductLine = input.ProductLine; + var tempLst = billLst.Where(itm => string.IsNullOrEmpty(itm.VIN) == false).OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList(); + if (tempLst.Count > 0) + { + zhbObj.BeginVin = tempLst[0].VIN; + zhbObj.EndVin = tempLst[tempLst.Count - 1].VIN; + zhbObj.BeginHostSN = tempLst[0].HostSN.ToString(); + zhbObj.EndHostSN = tempLst[tempLst.Count - 1].HostSN.ToString(); + } + zhbObj.MinOnlineTime = billLst.Min(itm => itm.OnlineTime); //取最早上线时间,库存接口用 + + //取当前页的详细信息 + foreach (BillM110 billObj in billLst) + { + string[] leftRightArr = new string[2] { "左", "右" }; + if (rightOrLeft == "左") + { + leftRightArr = new string[1] { "左" }; + } + else if (rightOrLeft == "右") + { + leftRightArr = new string[1] { "右" }; + } + foreach (string leftRightStr in leftRightArr) + { + ZhuHuBanPackingRec zhbRec = new ZhuHuBanPackingRec(); + zhbRec.SetId(GuidGenerator.Create()); + zhbRec.M110BillId = billObj.Id; + zhbRec.KNR = billObj.KNR; + zhbRec.VIN = billObj.VIN; + zhbRec.HostSN = billObj.HostSN; + if (billObj.BillM110Parts != null && billObj.BillM110Parts.Count > 0) + { + if (zhbPartType == "D柱") + { + //D柱:每页4*6个单元格,相邻列分为左右两列,分别显示D柱左、D柱右。 右列的右侧留空格=》4*3套 + MaterialExt materialObj = GetZhuHuBanByType(zhbPartType, leftRightStr + "侧", billObj); + if (materialObj != null) + { + zhbRec.MaterialDescription = materialObj.MaterialDescription; + zhbRec.PartCode = materialObj.RelationKey; + } + } //if D柱 + } + zhbObj.Details.Add(zhbRec); + } //二级foreach + } + retLst.Add(zhbObj); + return retLst; + } //DoZHBPrint + + /// + /// 打印柱护板装箱单时调用库存系统接口 + /// + /// + private void CallWMSInterface_ZHB(List input) + { + List targetMainLst = new List(); + List targetDetailLst = new List(); + + List cxLst = new List(); + foreach (ZhuHuBanPackingList sourceObj in input) + { + TB_BILL targetMain = new TB_BILL(); + targetMain.BillNum = sourceObj.BillNum; //单据编号 + targetMain.State = 0; + targetMain.BillType = 206; //单据类型 + targetMain.SubBillType = 20110; //单据子类型 + targetMain.BillTime = sourceObj.PrintDate; //单据时间 + targetMain.OperName = sourceObj.CreatorId.ToString(); //操作员 + targetMain.DetailQty = 0; //明细数量 + targetMain.CustId = _providerCode; //供应商编号 + //targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + + targetMain.GateName = sourceObj.BillSerialNum; //顺序号 + targetMain.GateCode = sourceObj.PartType; //B柱下 + targetMain.DockCode = sourceObj.BillLocation; //左或右 + targetMain.Remark = sourceObj.MinOnlineTime == null ? null : ((DateTime)sourceObj.MinOnlineTime).ToString("yyyy-MM-dd HH:mm"); //最早上线时间 + targetMain.TransportType = sourceObj.BillSerialNum; //顺序号 + targetMain.SourceBillNum3 = sourceObj.ProductLine; //2022-10-13加生产线 + + targetMainLst.Add(targetMain); + int idx = 0; + int barCode = 0; + foreach (ZhuHuBanPackingRec sourceRec in sourceObj.Details) + { + barCode++; + if (sourceRec.PartCode.IsNullOrEmpty() == false) + { + idx++; + //var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode && itm.MaterialType == "2"); + var materialObj = _zhbCacheList.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode); + TS_SORT_DETAIL targetDetail = new TS_SORT_DETAIL(); + targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + targetDetail.VinCode = sourceRec.VIN; //VIN码 + targetDetail.PartCode = materialObj == null ? sourceRec.PartCode : materialObj.MaterialNum; //SAP物料号 + targetDetail.LineNum = idx; //行号 + targetDetail.SeqNum = idx.ToString(); //顺序号 + targetDetail.ProjectId = ""; //车型 + targetDetail.State = "0"; //状态 + //targetDetail.BarCode = barCode.ToString(); //箱码 + targetDetail.PlanQty = 1; //计划数量 + targetDetail.CustPartCode = sourceRec.PartCode; //客户零件号 + targetDetail.FullBarCode = null; + targetDetail.VendId = sourceRec.KNR; + + //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + + targetDetailLst.Add(targetDetail); + if (materialObj != null && materialObj.VehicleModel != null) + { + cxLst.Add(materialObj.VehicleModel); + } + + } + if (sourceRec.PartCode2.IsNullOrEmpty() == false) + { + idx++; + //var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode2 && itm.MaterialType == "2"); + var materialObj = _zhbCacheList.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode2); + + TS_SORT_DETAIL targetDetail = new TS_SORT_DETAIL(); + targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + targetDetail.VinCode = sourceRec.VIN; //VIN码 + targetDetail.PartCode = materialObj == null ? sourceRec.PartCode2 : materialObj.MaterialNum; //SAP物料号 + targetDetail.LineNum = idx; //行号 + targetDetail.SeqNum = idx.ToString(); //顺序号 + targetDetail.ProjectId = ""; //车型 + targetDetail.State = "0"; //状态 + //targetDetail.BarCode = barCode.ToString(); //箱码 + targetDetail.PlanQty = 1; //计划数量 + targetDetail.CustPartCode = sourceRec.PartCode2; //客户零件号 + targetDetail.FullBarCode = null; + targetDetail.VendId = sourceRec.KNR; + //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + + targetDetailLst.Add(targetDetail); + if (materialObj != null && materialObj.VehicleModel != null) + { + cxLst.Add(materialObj.VehicleModel); + } + } + } + //生成车型 + string cxStr = ""; + foreach (string cxObj in cxLst.Distinct()) + { + cxStr += cxObj + "、"; + } + if (cxStr.Length > 0) + { + cxStr = cxStr.Substring(0, cxStr.Length - 1); + } + targetMain.ProjectId = cxStr; //添加车型 + + if (string.IsNullOrEmpty(cxStr)) + { + targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + } + } + foreach (TB_BILL targetMain in targetMainLst) + { + //明细数量 + targetMain.DetailQty = targetDetailLst.Where(p => p.BillNum == targetMain.BillNum).Count(); + + int cnt = InsertOrUpdateWMSMain(targetMain); + if (cnt == 0) + { + throw new Exception("插入或更新库存系统接口表记录数为零!"); + } + } + foreach (TS_SORT_DETAIL targetDetail in targetDetailLst) + { + int cnt = InsertOrUpdateWMSDetail(targetDetail); + if (cnt == 0) + { + throw new Exception("插入或更新库存系统接口表记录数为零!"); + } + } + } + + private static string GetTrueString(string str) + { + return str == null ? " " : str.Trim(); ; + } + + /// + /// 查找M110结算件中是否包含指定类型(如D柱)的柱护板 + /// + /// + /// + /// + /// + private MaterialExt GetZhuHuBanByType(string p_materialType2, string p_materialType3, BillM110 p_billM110) + { + //List keyLst = _materialExtRepository.Where(itm => itm.MaterialType == "2" && itm.MaterialType2 == p_materialType2 && itm.MaterialType3 == p_materialType3).Select(itm => itm.RelationKey).ToList(); //取A柱上物料对应的结算件编码 + List keyLst = _zhbCacheList.Where(itm => itm.MaterialType2 == p_materialType2 && itm.MaterialType3 == p_materialType3).Select(itm => itm.RelationKey).ToList(); //取A柱上物料对应的结算件编码 + foreach (BillM110Part billObj in p_billM110.BillM110Parts) + { + if (keyLst.Contains(billObj.PartCode)) + { + //MaterialExt materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialType == "2" && itm.MaterialType2 == p_materialType2 && itm.MaterialType3 == p_materialType3 && itm.RelationKey == billObj.PartCode); + MaterialExt materialObj = _zhbCacheList.FirstOrDefault(itm => itm.MaterialType2 == p_materialType2 && itm.MaterialType3 == p_materialType3 && itm.RelationKey == billObj.PartCode); + if (materialObj != null) + { + return materialObj; + } + } + } + return null; + } + #endregion + */ + #region 报表公共方法 + + /// + /// 打印前检查大众顺序号是否断号 + /// + /// + /// 断号时Item不为空 + [UnitOfWork(false)] + [HttpPost] + [Route("check-mb-hostsn-break-num")] + public virtual async Task> CheckMBHostSNBreakNum(MenBanPrintInputDto input) + { + List retLst = new List(); + try + { + int lastNum = await GetMenBanLastPrintNum(input); //从M110中取当前产线、已经打印的最大大众顺序号 + if (lastNum > 0) + { + if ((lastNum % 10000) == 1999) + { + if ((input.BeginHostSN % 10000) != 1) + { + string msg = $"单据之间断号,上次打印的最后大众顺序号为【{lastNum}】,与本次打印开始号【{input.BeginHostSN}】中间存在断号!"; + retLst.Add(msg); + _logger.LogDebug(msg); + } + } + else + { + if (lastNum + 1 != input.BeginHostSN) + { + string msg = $"单据之间断号,上次打印的最后大众顺序号为【{lastNum}】,与本次打印开始号【{input.BeginHostSN}】中间存在断号!"; + retLst.Add(msg); + _logger.LogDebug(msg); + } + } + } + + + ListResultDto tempLst = await GetMBReportDetailList(input, false); + List billLst = tempLst.Item; + if (billLst.Count < 2) + { + return new ListResultDto(retLst); + } + for (int i = 1; i < billLst.Count; i++) + { + BillM110 priorObj = billLst[i - 1]; + BillM110 curObj = billLst[i]; + int priorHostSN = (int)billLst[i - 1].HostSN; + int curHostSN = (int)billLst[i].HostSN; + + if (curHostSN > priorHostSN) //0005、0006 + { + if (curHostSN > priorHostSN + 1) //0005、0008时,补号 0006、0007 + { + retLst.Add($"大众顺序号{priorObj.HostSN}与{curObj.HostSN}之间存在断号情况!"); + } + } + else if (curHostSN < priorHostSN) //1999到0001的情况 + { + if (curHostSN + _hostSNMaxVal > priorHostSN + 1) //0005、0008时,补号 0006、0007 + { + retLst.Add($"大众顺序号{priorObj.HostSN}与{curObj.HostSN}之间存在断号情况!"); + } + } + } + if (retLst.Count == 0 && billLst.Count < input.EndHostSN - input.BeginHostSN + 1) + { + retLst.Add($"本车装箱单不满架!"); + } + + return new ListResultDto(retLst); + } + catch (Exception ex) + { + ListResultDto ret = new ListResultDto(); + ret.Status = false; + ret.Message = _errorMessagePrefix + "打印前检查大众顺序号是否断号ChecMBkHostSNBreakNum 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + + } + + /// + /// 打印前检查大众顺序号是否断号 + /// + /// + /// 是否柱护板 + /// 断号时Item不为空 + //[UnitOfWork(false)] + //[HttpPost] + //[Route("check-zhb-hostsn-break-num")] + //public virtual async Task> CheckZHBHostSNBreakNum(ZhuHuBanPrintInputDto input) + //{ + // List retLst = new List(); + // try + // { + // int lastNum = await GetZhuHuBanLastPrintNum(input); + // int newNum = lastNum + 1; + // if ((lastNum % 10000) == 1999) + // { + // if ((input.BeginHostSN % 10000) != 1) + // { + // retLst.Add($"上次打印的最后大众顺序号为【{lastNum}】,与本次打印开始号【{input.BeginHostSN}】中间存在断号!"); + // } + // } + // else + // { + // if (newNum != input.BeginHostSN) + // { + // retLst.Add($"上次打印的最后大众顺序号为【{lastNum}】,与本次打印开始号【{input.BeginHostSN}】中间存在断号!"); + // } + // } + // ListResultDto tempLst = await GetZHBReportDetailList(input, false); + // List billLst = tempLst.Item; + // if (billLst.Count < 2) + // { + // return new ListResultDto(retLst); + // } + // for (int i = 1; i < billLst.Count; i++) + // { + // BillM110 priorObj = billLst[i - 1]; + // BillM110 curObj = billLst[i]; + // int priorHostSN = (int)billLst[i - 1].HostSN; + // int curHostSN = (int)billLst[i].HostSN; + + // if (curHostSN > priorHostSN) //0005、0006 + // { + // if (curHostSN > priorHostSN + 1) //0005、0008时,补号 0006、0007 + // { + // retLst.Add($"大众顺序号{priorObj.HostSN}与{curObj.HostSN}之间存在断号情况!"); + // } + // } + // else if (curHostSN < priorHostSN) //1999到0001的情况 + // { + // if (curHostSN + _hostSNMaxVal > priorHostSN + 1) //0005、0008时,补号 0006、0007 + // { + // retLst.Add($"大众顺序号{priorObj.HostSN}与{curObj.HostSN}之间存在断号情况!"); + // } + // } + // } + // return new ListResultDto(retLst); + // } + // catch (Exception ex) + // { + // ListResultDto ret = new ListResultDto(); + // ret.Status = false; + // ret.Message = _errorMessagePrefix + "打印前检查大众顺序号是否断号CheckZHBHostSNBreakNum 执行出错:" + ex.Message; + // _logger.LogError(ret.Message); + // return ret; + // } + //} + + + /// + /// 根据生产线获取正常打印单据的起始大众顺序号2 + /// + /// 生产线 + /// 柱护板是1 门板是非1 + /// 柱护板分组类型 + /// 起始大众顺序号 + [UnitOfWork] + [HttpGet] + [Route("get-print-start-hostsn2")] + public virtual async Task> GetPrintStartHostSN2(string productLine, string isZhuHuBan,string GroupName=null) + { + int? beginHostSN = null; + try + { + if (isZhuHuBan == "1") //是柱护板, 根据PrintBillNum非空判断是柱护板 + { + //string minSNStr = await _billM110Repository.Where(itm => + // itm.ProductLine == productLine //指定生产线 + // && itm.CanNotPrint != true //能打印 + // && string.IsNullOrEmpty(itm.PrintBillNum) == true //等于 未打印 + // && itm.NeedReplenishPrint != 1 //排除补打 + // ).MinAsync(itm => itm.SerialNumStr); + string sql = @" +with d as +( + select *from [dbo].[FisZHBPrintStatus] where groupName='{1}' +) + +select min(SerialNumStr) from FisBillM110 a left join d on a.VIN=d.VIN + + where ProductLine='{0}' and (CanNotPrint !=1 or CanNotPrint is null) and (PrintBillNum is null or PrintBillNum ='') and (NeedReplenishPrint!=1 or NeedReplenishPrint is null) and d.BillStatus is null"; + + sql = string.Format(sql, productLine, GroupName); + var minSNStr = await _newJitDapperRepository.GetSingleBySqlAsync(sql); + + + beginHostSN = await _billM110Repository.Where(itm => + itm.ProductLine == productLine //指定生产线 + && itm.CanNotPrint != true //能打印 + && string.IsNullOrEmpty(itm.PrintBillNum) == true //等于 未打印 + && itm.SerialNumStr == minSNStr + ).MinAsync(itm => itm.HostSN); + } + else //---------------门板----------------------------------------------------------------------------------- + { + string minSNStr2 = await _billM110Repository.Where(itm => + itm.ProductLine == productLine //指定生产线 + && itm.CanNotPrint != true //能打印 + //&& itm.BillStatus == BillStatusEnum.Match //等于 未打印(和M110上线信息匹配) + && itm.BillStatus != BillStatusEnum.Publish //未知总成也显示在装箱单 + && itm.NeedReplenishPrint != 1 //排除补打 + ).MinAsync(itm => itm.SerialNumStr); + + beginHostSN = await _billM110Repository.Where(itm => + itm.ProductLine == productLine //指定生产线 + && itm.CanNotPrint != true //能打印 + //&& itm.BillStatus == BillStatusEnum.Match //等于 未打印 + && itm.BillStatus != BillStatusEnum.Publish //未知总成也显示在装箱单 + && itm.SerialNumStr == minSNStr2 + ).MinAsync(itm => itm.HostSN); + } + return new ObjectResultDto(beginHostSN); + } + catch (Exception ex) + { + ObjectResultDto ret = new ObjectResultDto(); + ret.Status = false; + ret.Message = _errorMessagePrefix + "GetPrintStartHostSN2 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 打印门板装箱单 + /// + /// + /// 执行成功返回真 + //[UnitOfWork] + //[HttpPost] + //[Route("print-menban-packing-list")] + //public virtual async Task> PrintMenBanPackingList(MenBanPrintInputDto input) + //{ + // /* + // 1、 一次打印24辆车,分为4页纸张,四个纸张的装箱单号不是一样 + // 2、 按大众顺序号过滤打印,一次打印12套(不是24辆车),到1999后按2000、2001顺序排,下次打印按3延续排列右前 + // 5、 物料描述字体尽量大 + // 6、 右上角的“01 左” 字体尽量大 + // 7、 零件类别: C8是车型, DP表示门板 + // 8、 器具容量: 24表示当页包含24个门板 + // 9、 车型门板代码: 从物料汇总文件- 补充备注 字段中取 Q5-DV OQ N5K 3L4 QQ2 6XE 7HB 9VS 7X1 3Y4 + // 3、 根据物料描述字段区分左后、左前、右后、右前 + // 4、 车型C8的第一二页分为左后, 右前,第三四页分为右后、左前;其它车型 第一二页分为左后、左前,第三四页分为右后、 + // 10、 物料描述: 从物料汇总文件-物料描述 字段中取 + // */ + // MenBanPrintResultDto retObj = new MenBanPrintResultDto(); + // ObjectResultDto ret = new ObjectResultDto(retObj); + // ret.Status = false; + // try + // { + // List reportMainLst = new List(); + + // if (input.PrintType == PrintTypeEnum.正常打印) + // { + // if (input.BeginHostSN != 0 && input.EndHostSN != 0) + // { + // if (input.BeginHostSN > input.EndHostSN) + // { + // ret.Message = "止大众顺序号必须大于等于起大众顺序号!"; + // ret.Status = false; + // return ret; + // } + // } + // ListResultDto tempLst = await GetMBReportDetailList(input, true); //----------------------------- + // List billLst = tempLst.Item; + // if (tempLst.Status == false) + // { + // ret.Message = tempLst.Message; + // ret.Status = false; + // return ret; + // } + + // int pageCnt = (int)Math.Ceiling(billLst.Count / 12.0); //每页打印12列,取打印页数 + + // double maxBillNum = 0; + + // DateTime printTime = ServerHelper.CurrentDateTime; + + // for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++) + // { + // //取右上角顺序号:按生产线分组,取当前生产线的最大流水号:01至99循环,例如01左、01右 + // double maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.门板, input.ProductLine, string.Empty); + // // 先打印两张:左后左前,再打印两张:右后右前 + // List leftLst = DoMBPrint(input, pageIdx, ref maxBillNum, maxSN, printTime, billLst, "左"); + // List rightLst = DoMBPrint(input, pageIdx, ref maxBillNum, maxSN, printTime, billLst, "右"); + + // //作废时需要同时作废相同VIN的左右两页,SortId相同表示是同一组左右 + // Guid sortId = GuidGenerator.Create(); + // foreach (var leftItm in leftLst) + // { + // leftItm.SortId = sortId; + // } + // foreach (var rightItm in rightLst) + // { + // rightItm.SortId = sortId; + // } + + // reportMainLst.AddRange(rightLst); + // reportMainLst.AddRange(leftLst); + // } + + // //调用派格版库存接口 + // CallWMSInterface_MB(reportMainLst); + + // //插入门板打印记录表 + // await _menBanPackingListRepository.InsertManyAsync(reportMainLst, true); + + // //更新M110的门板打印标志:BillStatus=3 + // foreach (BillM110 billObj in billLst) + // { + // if (billObj.BillStatus == BillStatusEnum.Match) + // { + // billObj.SetBillStatus(BillStatusEnum.Publish); + // billObj.PrintTime = ServerHelper.CurrentDateTime; + // billObj.NeedReplenishPrint = 0; //不需要补打 + // await _billM110Repository.UpdateAsync(billObj, true); + // } + // else if (billObj.BillStatus == BillStatusEnum.NotMatch) + // { + // //billObj.PrintTime = ServerHelper.CurrentDateTime; + // billObj.NeedReplenishPrint = 1; //需要补打 + // await _billM110Repository.UpdateAsync(billObj, true); + // } + // } + // } + // else if (input.PrintType == PrintTypeEnum.重新打印) //和正常打印单据完全一样,可以打印部分单据 + // { + // reportMainLst = await _menBanPackingListRepository.GetListAsync(itm => input.ReportIdList.Contains(itm.Id), true); + // //按大众顺序号排序 + // foreach (var reportMainObj in reportMainLst) + // { + // List recLst = reportMainObj.Details; + // if (recLst == null) + // continue; + // //bool has1999 = recLst.Any(itm => itm.HostSN.Contains("1999") || itm.HostSN.Contains("1998") || itm.HostSN.Contains("1997")); + // //bool has0001 = recLst.Any(itm => itm.HostSN.Contains("0001") || itm.HostSN.Contains("0002") || itm.HostSN.Contains("0003")); + // bool has1999 = recLst.Any(itm => itm.HostSN.Contains("1999") || itm.HostSN.Contains("1998") || itm.HostSN.Contains("1997") + // || itm.HostSN.Contains("1996") || itm.HostSN.Contains("1995") || itm.HostSN.Contains("1994") + // || itm.HostSN.Contains("1993") || itm.HostSN.Contains("1992") || itm.HostSN.Contains("1991") + // || itm.HostSN.Contains("1990") || itm.HostSN.Contains("1989") || itm.HostSN.Contains("1988") + // || itm.HostSN.Contains("1987") || itm.HostSN.Contains("1986") || itm.HostSN.Contains("1985") + // || itm.HostSN.Contains("1984") || itm.HostSN.Contains("1983") || itm.HostSN.Contains("1982") + // || itm.HostSN.Contains("1981") || itm.HostSN.Contains("1980") || itm.HostSN.Contains("1979") + // || itm.HostSN.Contains("1978") || itm.HostSN.Contains("1977") || itm.HostSN.Contains("1976") + // ); + // bool has0001 = recLst.Any(itm => itm.HostSN.Contains("0001") || itm.HostSN.Contains("0002") || itm.HostSN.Contains("0003") + // || itm.HostSN.Contains("0004") || itm.HostSN.Contains("0005") || itm.HostSN.Contains("0006") + // || itm.HostSN.Contains("0007") || itm.HostSN.Contains("0008") || itm.HostSN.Contains("0009") + // || itm.HostSN.Contains("0010") || itm.HostSN.Contains("0011") || itm.HostSN.Contains("0012") + // || itm.HostSN.Contains("0013") || itm.HostSN.Contains("0014") || itm.HostSN.Contains("0015") + // || itm.HostSN.Contains("0016") || itm.HostSN.Contains("0017") || itm.HostSN.Contains("0018") + // || itm.HostSN.Contains("0019") || itm.HostSN.Contains("0020") || itm.HostSN.Contains("0021") + // || itm.HostSN.Contains("0022") || itm.HostSN.Contains("0023") || itm.HostSN.Contains("0024") + // ); + // if (has1999 && has0001) + // { + // reportMainObj.Details = recLst.OrderBy(itm => (itm.HostSN.TryToIntZero() % 10000) < 240 ? (itm.HostSN.TryToIntZero() % 10000 + 1999) : (itm.HostSN.TryToIntZero() % 10000)).ToList(); + // } + // else + // { + // reportMainObj.Details = recLst.OrderBy(itm => itm.HostSN).ToList(); + // } + // } + // } + // else if (input.PrintType == PrintTypeEnum.补打) + // { + // List billLst = _billM110Repository.Where(itm => input.M110IdList.Contains(itm.Id)).OrderBy(itm => itm.SerialNumStr).ToList(); + // if (billLst.Count == 0) + // { + // ret.Message = "没有补打的单据,请先选择要补打的单据!"; + // ret.Status = false; + // return ret; + // } + + // int pageCnt = (int)Math.Ceiling(billLst.Count / 12.0); //每页打印12列,取打印页数 + + // double maxBillNum = 0; + + // DateTime printTime = ServerHelper.CurrentDateTime; + + // for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++) + // { + // //取右上角顺序号:按生产线分组,取当前生产线的最大流水号:01至99循环,例如01左、01右 + // double maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.门板, input.ProductLine, string.Empty); + // // 先打印两张:左后左前,再打印两张:右后右前 + // List leftLst = DoMBPrint(input, pageIdx, ref maxBillNum, maxSN, printTime, billLst, "左"); + // List rightLst = DoMBPrint(input, pageIdx, ref maxBillNum, maxSN, printTime, billLst, "右"); + + // //作废时需要同时作废相同VIN的左右两页,SortId相同表示是同一组左右 + // Guid sortId = GuidGenerator.Create(); + // foreach (var leftItm in leftLst) + // { + // leftItm.SortId = sortId; + // } + // foreach (var rightItm in rightLst) + // { + // rightItm.SortId = sortId; + // } + + // reportMainLst.AddRange(rightLst); + // reportMainLst.AddRange(leftLst); + // } + // //校验底盘号、零件是否重复打印 + // string checkVinPartRepeatSql = @" + // select top 1 a.BillNum from FisMenBanPackingList a join FisMenBanPackingRec b + // on a.Id = b.MenBanPackingListId + // where a.ReportStatus = 0 + // and b.VIN = '{0}' and (TopSAPMaterialNum = '{1}' or BelowSAPMaterialNum = '{1}') + // "; + // foreach (MenBanPackingList reportMainObj in reportMainLst) + // { + // foreach (MenBanPackingRec reportRecObj in reportMainObj.Details) + // { + // string sql1 = string.Format(checkVinPartRepeatSql, reportRecObj.VIN, reportRecObj.PartCode2); + // string checkVinPartRepeatBillNum1 = _newJitDapperRepository.GetSingleBySql(sql1, true); + // if (string.IsNullOrEmpty(checkVinPartRepeatBillNum1) == false) + // { + // throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum1}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.PartCode2}之间重复!"); + // } + + // string sql2 = string.Format(checkVinPartRepeatSql, reportRecObj.VIN, reportRecObj.PartCode4); + // string checkVinPartRepeatBillNum2 = _newJitDapperRepository.GetSingleBySql(sql2, true); + // if (string.IsNullOrEmpty(checkVinPartRepeatBillNum2) == false) + // { + // throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum2}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.PartCode4}之间重复!"); + // } + // } + // } + + // //调用派格版库存接口 + // CallWMSInterface_MB(reportMainLst); + + // //插入门板打印记录表 + // await _menBanPackingListRepository.InsertManyAsync(reportMainLst); + + // //更新M110的门板打印标志:BillStatus=3 + // foreach (BillM110 billObj in billLst) + // { + // if (billObj.BillStatus == BillStatusEnum.Match) + // { + // billObj.SetBillStatus(BillStatusEnum.Publish); + // billObj.PrintTime = ServerHelper.CurrentDateTime; + // await _billM110Repository.UpdateAsync(billObj); + // } + // } + // } + + + // #region 格式转换 + // //实体 转 DTO + // List targetLst = ObjectMapper.Map, List>(reportMainLst); + // targetLst = targetLst.OrderBy(itm => itm.BillNum).ToList(); + + // //补充空行 + // foreach (var masterObj in targetLst) + // { + // int trueCnt = masterObj.Details.Count; + // int planCnt = 12; + // if (trueCnt > planCnt) + // { + // throw new Exception($"实际打印行数{trueCnt}超过每页总行数{planCnt}, 底盘起{masterObj.BeginVin}底盘止{masterObj.EndVin}"); + // } + // int diffCnt = planCnt - trueCnt; + // for (int i = 0; i < diffCnt; i++) + // { + // MenBanPackingRecDto dtlObj = new MenBanPackingRecDto(); + // masterObj.Details.Add(dtlObj); + // } + // } + // //子表BillNum赋值, BillNum填充空格 + // foreach (var masterObj in targetLst) + // { + // masterObj.BillNum = GetTrueString(masterObj.BillNum); + // int sn = 1; + // foreach (var detailObj in masterObj.Details) + // { + // detailObj.BillNum = masterObj.BillNum; + // detailObj.KNR = GetTrueString(detailObj.KNR); + // detailObj.sn = sn++; + // detailObj.VIN = detailObj.VIN.TryToRight(6); //底盘号返回后六位 + // } + // } + // //返回结果格式转换 + // foreach (var masterObj in targetLst) + // { + // foreach (var detailObj in masterObj.Details) + // { + // retObj.DetailList.Add(detailObj); + // } + // masterObj.Details = null; + // retObj.MasterList.Add(masterObj); + // } + // #endregion + // ret.Status = true; + // return ret; + // } + // catch (Exception ex) + // { + // string errorMsg = _errorMessagePrefix + "PrintMenBanPackingList 执行出错:" + ex.Message; + // _logger.LogError(errorMsg); + // throw new BusinessException("1001", errorMsg); + // ret.Status = false; + // ret.Message = ex.Message; + // return ret; + // } + //} + + + + + /// + /// 打印柱护板装箱单 + /// + /// + /// 执行成功返回真 + //[UnitOfWork(isTransactional:false)] + //[HttpPost] + //[Route("print-zhuhuban-packing-list")] + //public virtual async Task> PrintZhuHuBanPackingList(ZhuHuBanPrintInputDto input) + //{ + // ZhuHuBanPrintResultDto retObj = new ZhuHuBanPrintResultDto(); + // ObjectResultDto ret = new ObjectResultDto(retObj); + // ret.Status = false; + // try + // { + // List reportMainLst = new List(); + // List forWMSLst = new List(); + + + // if (input.PrintType == PrintTypeEnum.正常打印) + // { + // if (input.BeginHostSN > input.EndHostSN) + // { + // ret.Message = "起大众顺序号不能大于止大众顺序号!"; + // ret.Status = false; + // return ret; + // } + + // ListResultDto tempLst = await GetZHBReportDetailList(input, true); //------------------- + // List billLst = tempLst.Item; + // if (tempLst.Status == false) + // { + // ret.Message = tempLst.Message; + // ret.Status = false; + // return ret; + // } + // if (billLst.Count > 24) + // { + // ret.Message = "打印柱护板单据的数量不能大于24!"; + // ret.Status = false; + // return ret; + // } + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + // long maxBillNum = 0; //子方法内部赋值 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; + + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + // //A柱下,A中 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + // //B柱上 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // //B柱下 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); //左用于打印 + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); //左右用于库存接口 + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + + // //后轮,上装饰板 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + + // #region 调用库存接口 + // //List forWMSLst = new List(); + // //forWMSLst.AddRange(reportMainLst); + // //forWMSLst.AddRange(acLstOnlyWMSUse); + // CallWMSInterface_ZHB(forWMSLst); + // #endregion + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // var ret22 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // } + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // foreach (var updObj in updLst) + // { + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // await _billM110Repository.UpdateManyAsync(updLst, true); + + // } + // else if (input.PrintType == PrintTypeEnum.重新打印) //和正常打印单据完全一样,可以打印部分单据 + // { + // if (input.DataResultType == "1") //全部11条数据 + // { + // var firObj = await _zhuHuBanPackingListRepository.FirstOrDefaultAsync(itm => input.ReportIdList.Contains(itm.Id)); + // if (firObj != null) + // { + // Guid? sortId = firObj.SortId; + // reportMainLst = await _zhuHuBanPackingListRepository.GetListAsync(itm => itm.SortId == sortId, true); + // } + // } + // else + // { + // reportMainLst = await _zhuHuBanPackingListRepository.GetListAsync(itm => input.ReportIdList.Contains(itm.Id), true); + // } + + // //按大众顺序号排序 + // foreach (var reportMainObj in reportMainLst) + // { + // List recLst = reportMainObj.Details; + // if (recLst == null) + // continue; + // //bool has1999 = recLst.Any(itm => itm.HostSN.ToString().Contains("1999") || itm.HostSN.ToString().Contains("1998")); + // //bool has0001 = recLst.Any(itm => itm.HostSN.ToString().Contains("0001") || itm.HostSN.ToString().Contains("0002")); + // bool has1999 = recLst.Any(itm => (itm.HostSN % 10000) >= 1999 - 24); + // bool has0001 = recLst.Any(itm => (itm.HostSN % 10000) <= 24); + // if (has1999 && has0001) + // { + // reportMainObj.Details = recLst.OrderBy(itm => (itm.HostSN % 10000) <= 23 ? (itm.HostSN % 10000 + 1999) : (itm.HostSN % 10000)).ToList(); + // } + // else + // { + // reportMainObj.Details = recLst.OrderBy(itm => itm.HostSN).ToList(); + // } + // } + // } + // else if (input.PrintType == PrintTypeEnum.补打) + // { + // if (input.M110IdList.Count > 24) + // { + // throw new BusinessException("1001", $"选中的柱护板补打不能超过24个底盘!"); + // } + + // List billLst = _billM110Repository.GetListAsync(itm => input.M110IdList.Contains(itm.Id), true).GetAwaiter().GetResult(); + // if (billLst.Count == 0) + // { + // ret.Message = "没有补打的柱护板,请先选择要补打的柱护板!"; + // ret.Status = false; + // return ret; + // } + // billLst = billLst.OrderBy(itm => itm.SerialNumStr).ToList(); + + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + // long maxBillNum = 0; //全局唯一装箱单号 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; //右上角顺序号01-99 + + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + // //A柱下,A中 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + // //B柱上 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // //B柱下 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + + // //后轮,上装饰板 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + + // #region 调用库存接口 + // //List forWMSLst = new List(); + // //forWMSLst.AddRange(reportMainLst); + // //forWMSLst.AddRange(acLstOnlyWMSUse); + // CallWMSInterface_ZHB(forWMSLst); + // #endregion + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // var ret22 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // } + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // foreach (var updObj in updLst) + // { + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // await _billM110Repository.UpdateManyAsync(updLst, true); + // } + + // #region 返回结果格式转换 + // //实体 转 DTO + // List targetLst = ObjectMapper.Map, List>(reportMainLst); + // //补充空行 + // foreach (var masterObj in targetLst) + // { + // int trueCnt = masterObj.Details.Count; + + // int planCnt = 0; + // switch (masterObj.PartType) + // { + // case "A上C上": + // case "A柱下A中": + // case "B柱上": + // case "B柱下": + // case "后轮上装饰板": + // planCnt = 24; + // break; + // case "D柱": + // planCnt = 12; + // break; + // default: + // planCnt = 24; + // break; + // } + // if (trueCnt > planCnt) + // { + // throw new Exception($"实际打印行数{trueCnt}超过每页总行数{planCnt}, 底盘起{masterObj.BeginVin}底盘止{masterObj.EndVin}"); + // } + // int diffCnt = planCnt - trueCnt; + // for (int i = 0; i < diffCnt; i++) + // { + // ZhuHuBanPackingRecDto dtlObj = new ZhuHuBanPackingRecDto(); + // masterObj.Details.Add(dtlObj); + // } + // } + // //子表BillNum赋值, BillNum填充空格, SN赋值 + // foreach (var masterObj in targetLst) + // { + // masterObj.BillNum = GetTrueString(masterObj.BillNum); + // int sn = 1; + // foreach (var detailObj in masterObj.Details) + // { + // detailObj.BillNum = masterObj.BillNum; + // detailObj.KNR = GetTrueString(detailObj.KNR); + // detailObj.KNR = detailObj.KNR.Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("/n", "").Replace("/r", ""); + // detailObj.sn = sn++; + // detailObj.VIN = detailObj.VIN.TryToRight(6); //底盘号返回后六位 + // //客户要求显示零件描述,替换之前的零件编码 + // detailObj.PartCode = detailObj.MaterialDescription; + // detailObj.PartCode2 = detailObj.MaterialDescription2; + // detailObj.MaterialDescription = null; + // detailObj.MaterialDescription2 = null; + // } + // } + + // retObj.MasterList_AC = targetLst.Where(itm => itm.PartType == "A上C上").ToList(); + // if (retObj.MasterList_AC.Count == 0) retObj.IsVisibleAC = false; + // foreach (var masterObj in retObj.MasterList_AC) + // { + // retObj.DetailList_AC.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_AA = targetLst.Where(itm => itm.PartType == "A柱下A中").ToList(); + // if (retObj.MasterList_AA.Count == 0) retObj.IsVisibleAA = false; + // foreach (var masterObj in retObj.MasterList_AA) + // { + // retObj.DetailList_AA.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_BS = targetLst.Where(itm => itm.PartType == "B柱上").ToList(); + // if (retObj.MasterList_BS.Count == 0) retObj.IsVisibleBS = false; + // foreach (var masterObj in retObj.MasterList_BS) + // { + // retObj.DetailList_BS.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_BX = targetLst.Where(itm => itm.PartType == "B柱下").ToList(); + // if (retObj.MasterList_BX.Count == 0) retObj.IsVisibleBX = false; + // foreach (var masterObj in retObj.MasterList_BX) + // { + // retObj.DetailList_BX.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_D = targetLst.Where(itm => itm.PartType == "D柱").ToList(); + // if (retObj.MasterList_D.Count == 0) retObj.IsVisibleD = false; + // foreach (var masterObj in retObj.MasterList_D) + // { + // retObj.DetailList_D.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_HL = targetLst.Where(itm => itm.PartType == "后轮上装饰板").ToList(); + // if (retObj.MasterList_HL.Count == 0) retObj.IsVisibleHL = false; + // foreach (var masterObj in retObj.MasterList_HL) + // { + // retObj.DetailList_HL.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + // #endregion + // ret.Status = true; + // return ret; + // } + // catch (Exception ex) + // { + // string errorMsg = _errorMessagePrefix + "PrintZhuHuBanPackingList 执行出错:" + ex.Message; + // _logger.LogError(errorMsg); + // throw new BusinessException("1001", errorMsg); + // ret.Status = false; + // ret.Message = ex.Message; + // return ret; + // } + //} + + #endregion + + #region 补打 + /// + /// 取门板补打列表(IsNeedReplenishPrint=true、单据状态BillStatus是未打印) + /// + /// 输入查询条件 + /// 返回符合条件的排序分页列表 + //[HttpGet] + //[UnitOfWork(false)] + //[Route("replenish-print-list")] + //public virtual async Task> GetReplenishPrintListAsync(QueryBillM110Dto input) + //{ + // _logger.LogDebug(_errorMessagePrefix + "GetReplenishPrintListAsync 进入"); + // try + // { + // input.CanNotPrint = null; //忽略不能打印 + // input.ZHBBillStatus = null; + // input.BillStatus = BillStatusEnum.Match; //单据状态是已解析未打印 + // input.IsNeedReplenishPrint = true; //只显示需要补打的记录 + // PagedResultDto ret = await QueryByConditionAsync(input, (PagedAndSortedBase)input); + // return ret; + // } + // catch (Exception ex) + // { + // string errMsg = _errorMessagePrefix + "GetReplenishPrintListAsync 执行出错:" + ex.Message; + // _logger.LogError(errMsg); + // return new PagedResultDto(0, new List()); + // } + //} + + /// + /// 取柱护板补打列表(IsNeedReplenishPrint=true、单据状态BillStatus是未打印) + /// + /// 输入查询条件 + /// 返回符合条件的排序分页列表 + //[HttpGet] + //[UnitOfWork(false)] + //[Route("replenish-print-zhb-list")] + //public virtual async Task> GetReplenishPrintZHBListAsync(QueryBillM110Dto input) + //{ + // _logger.LogDebug(_errorMessagePrefix + "GetReplenishPrintZHBListAsync 进入"); + // try + // { + // input.CanNotPrint = null; //忽略不能打印 + // input.BillStatus = null; + // input.ZHBBillStatus = ZHBBillStatusEnum.NotPrint; //柱护板状态是已解析未打印 + // input.IsNeedReplenishPrint = true; //只显示需要补打的记录 + // PagedResultDto ret = await QueryZHBByConditionAsync(input, (PagedAndSortedBase)input); + // return ret; + // } + // catch (Exception ex) + // { + // string errMsg = _errorMessagePrefix + "GetReplenishPrintZHBListAsync 执行出错:" + ex.Message; + // _logger.LogError(errMsg); + // return new PagedResultDto(0, new List()); + // } + //} + + #endregion + + #region 公共方法 + + /// + /// 根据筛选条件获取分页实体列表 + /// + /// 输入查询条件 + /// 输入分页条件 + /// 返回符合条件的排序分页列表 + [HttpGet] + [UnitOfWork(false)] + [Route("list")] + public virtual async Task> GetListAsync(QueryBillM110Dto input) + { + _logger.LogDebug(_errorMessagePrefix + "GetListAsync 进入"); + try + { + PagedResultDto ret = new PagedResultDto(); + if (!string.IsNullOrEmpty(input.GroupName)) + { + ret = await QueryZHBByConditionAsync(input, (PagedAndSortedBase)input); + } + else + { + ret = await QueryByConditionAsync(input, (PagedAndSortedBase)input); + } + + return ret; + } + catch (Exception ex) + { + string errMsg = _errorMessagePrefix + "GetListAsync 执行出错:" + ex.Message; + _logger.LogError(errMsg); + return new PagedResultDto(0, new List()); + } + } + + /// + /// 按主键获取唯一实体 + /// + /// 主键 + /// 实体信息 + [HttpGet] + [Route("{id}")]//obj/ + public virtual async Task> GetAsync(Guid id) + { + _logger.LogDebug(_errorMessagePrefix + "GetAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + BillM110 sourceObj = await _billM110Repository.GetAsync(id); + BillM110Dto targetObj = ObjectMapper.Map(sourceObj); + ret.Item = targetObj; + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "GetAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 添加实体 + /// + /// 添加内容 + /// 执行成功返回真 + [HttpPost] + [UnitOfWork] + [Route("")]//create + public virtual async Task> CreateAsync(CreateUpdateBillM110Dto input) + { + _logger.LogDebug(_errorMessagePrefix + "CreateAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + //取M110单据 最大流水号 + //int billMaxSN = _billM110Repository.Max(itm => itm.SerialNum) ?? 0; + + BillM110 obj = ObjectMapper.Map(input); + #region 主子表主键Id赋值 + foreach (var item in obj.BillM110Parts) + { + item.SetId(GuidGenerator.Create()); + } + #endregion + obj.SetSerialNum(ServerHelper.VinToSN(obj.VIN)); //++billMaxSN 取底盘后六位 + obj.SerialNumStr = ServerHelper.ToSerialNumStr(obj.OnlineTime, obj.HostSN, "M110", obj.ProductLine); + BillM110 obj2 = await _billM110Repository.InsertAsync(obj, true); + ret.Item = obj2.Id; //返回添加对象的主键 + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "CreateAsync 执行出错:" + ex.Message + ex?.InnerException?.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 修改实体 + /// + /// 更新主键 + /// 修改内容 + /// 执行成功返回真 + [HttpPut] + [UnitOfWork] + [Route("{id}")]//update/ + public virtual async Task UpdateAsync(Guid id, CreateUpdateBillM110Dto input) + { + _logger.LogDebug(_errorMessagePrefix + "UpdateAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + BillM110 targetObj = await _billM110Repository.GetAsync(id); + await _billM110PartRepository.DeleteManyAsync(targetObj.BillM110Parts); //先删除子实体列表 + ObjectMapper.Map(input, targetObj); + await _billM110Repository.UpdateAsync(targetObj); + await _billM110PartRepository.InsertManyAsync(targetObj.BillM110Parts); //再添加子实体列表 + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "UpdateAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 删除实体 + /// + /// 删除主键 + /// 执行成功返回真 + [UnitOfWork] + [HttpDelete] + [Route("{id}")]//delete/ + public virtual async Task DeleteAsync(string id) + { + _logger.LogDebug(_errorMessagePrefix + "DeleteAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + List idLst = ServerHelper.GetGuidListByStr(id); + foreach (Guid item in idLst) + { + BillM110 sourceObj = await _billM110Repository.GetAsync(item); + if (sourceObj != null) + { + await _billM110PartRepository.DeleteManyAsync(sourceObj.BillM110Parts); + await _billM110Repository.DeleteAsync(item); + } + } + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "DeleteAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 导出信息 + /// + /// 导出查询条件 + /// 执行成功返回真 + [UnitOfWork(false)] + [HttpPost] + [Route("export")] + public virtual async Task> ExportAsync(QueryBillM110Dto input) + { + _logger.LogDebug(_errorMessagePrefix + "ExportAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + input.SkipCount = 0; + input.MaxResultCount = 50000; + PagedResultDto query = new PagedResultDto(); + if (!string.IsNullOrEmpty(input.GroupName)) + { + query = await QueryZHBByConditionAsync(input, (PagedAndSortedBase)input); + } + else + { + query = await QueryByConditionAsync(input, (PagedAndSortedBase)input); + } + List items = query.Items.ToList(); + //将实体列表转换成excel文件流 + IExporter exporter = new ExcelExporter(); + byte[] byteArr = await exporter.ExportAsByteArray(items); + byteArr.ShouldNotBeNull(); + //将excel文件流保存到服务器端文件系统 + string fileName = string.Format("单据M110_{0}.xlsx", Guid.NewGuid().ToString()); + await _blobContainer.SaveAsync(fileName, byteArr); + + ret.Item = fileName; + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "ExportAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 导入信息 + /// + /// 导入文件流 + /// 执行成功返回真 + [UnitOfWork] + [HttpPost] + [Route("import")] + public virtual async Task ImportAsync(byte[] input) + { + throw new NotImplementedException("暂不实现所有导入"); + } + + #endregion + + + #region 超时提醒 + /// + /// 生产线超时提醒 + /// + /// 生产线编号列表 + /// 生产线超时情况 + [UnitOfWork] + [HttpPost] + [Route("product-line-timeout-remind")] + public virtual async Task> ProductLineTimeoutRemind(TimeOutRemindInputDto input) + { + List retLst = new List(); + foreach (string plStr in input.ProductLineList) + { + TimeOutRemindResultDto retObj = new TimeOutRemindResultDto(); + retObj.ProductLine = plStr; + retObj.ConfigMinutes = _configuration[$"ConfigDic:ProductLineTimeoutRemind:{plStr}"].TryToInt() ?? 30; + + string maxSNStr = await _billM110Repository.Where(itm => itm.ProductLine == plStr).MaxAsync(itm => itm.SerialNumStr); + BillM110 lastBill = await _billM110Repository.FirstOrDefaultAsync(itm => itm.ProductLine == plStr && itm.SerialNumStr == maxSNStr); + if (lastBill != null) + { + retObj.LastReceiveTime = lastBill.ReceiveTime ?? ServerHelper.CurrentDateTime; + retObj.TimeoutMinutes = MinuteDiff(retObj.LastReceiveTime, ServerHelper.CurrentDateTime); + } + retLst.Add(retObj); + } + return new ListResultDto(retLst); + } + + private int MinuteDiff(DateTime beginTime, DateTime endTime) + { + TimeSpan beginSpan = new TimeSpan(beginTime.Ticks); + TimeSpan endSpan = new TimeSpan(endTime.Ticks); + TimeSpan diffSpan = endSpan.Subtract(beginSpan).Duration(); + return (int)(diffSpan.TotalMinutes); + } + + #endregion + + #region 保存报表、加载打印报表分离 + //[UnitOfWork] + [UnitOfWork(IsDisabled = true)] + [HttpPost] + [Route("save-menban-report")] + public virtual async Task>> SaveMenBanReport(MenBanPrintInputDto input) + { + Stopwatch sw = new Stopwatch(); + + _logger.LogDebug(_errorMessagePrefix + "SaveMenBanReport 进入"); + + List retLst = new List(); + ObjectResultDto> ret = new ObjectResultDto>(); + ret.Status = false; + + using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: System.Data.IsolationLevel.Unspecified)) + { + try + { + List reportMainLst = new List(); + + if (input.PrintType == PrintTypeEnum.正常打印) + { + if (input.BeginHostSN != 0 && input.EndHostSN != 0) + { + if (input.BeginHostSN > input.EndHostSN) + { + ret.Message = "止大众顺序号必须大于等于起大众顺序号!"; + ret.Status = false; + return ret; + } + } + ListResultDto tempLst = await GetMBReportDetailList(input, true); //----------------------------- + List billLst = tempLst.Item; + if (tempLst.Status == false) + { + ret.Message = tempLst.Message; + ret.Status = false; + return ret; + } + + _logger.LogWarning($"SaveMenBanReport读取数据 - {sw.ElapsedMilliseconds}毫秒"); + + int pageCnt = (int)Math.Ceiling(billLst.Count / 12.0); //每页打印12列,取打印页数 + + //double maxBillNum = 0; + + //DateTime printTime = ServerHelper.CurrentDateTime; + + var reportSortDic = _dicItemRepository + .Where(itm => itm.DicTypeCode == "零件大类" && itm.DicItemSort2 == input.ProductLine) + .ToList() + .GroupBy(itm => itm.DicItemSort4) + .ToDictionary(itm => itm.Key, it2 => it2.Select(itm => itm.DicItemCode).ToArray()); + + for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++) + { + + foreach (var reportSortItem in reportSortDic) + { + //生成顺序号:按生产线分组,取当前生产线的最大流水号:001至999往复循环 + double maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.门板, input.ProductLine, string.Empty); + + MenBanPackingList packingObj = DoMBPrint(input, pageIdx, maxSN, billLst, reportSortItem.Key, reportSortItem.Value); + reportMainLst.Add(packingObj); + } + } + + _logger.LogWarning($"SaveMenBanReport转换数据 - {sw.ElapsedMilliseconds}毫秒"); + + //插入门板打印记录表 + await _menBanPackingListRepository.InsertManyAsync(reportMainLst, true); + retLst.AddRange(reportMainLst.Select(itm => itm.Id)); + + _logger.LogWarning($"SaveMenBanReport插入门板打印记录表 - {sw.ElapsedMilliseconds}毫秒"); + + + //调用派格版库存接口 + //await SaveMiddleTable_MB(reportMainLst); + + _logger.LogWarning($"SaveMenBanReport插入中间表 - {sw.ElapsedMilliseconds}毫秒"); + + + //更新M110的门板打印标志:BillStatus=3 + foreach (BillM110 billObj in billLst) + { + if (billObj.BillStatus == BillStatusEnum.Match) + { + billObj.SetBillStatus(BillStatusEnum.Publish); + billObj.PrintTime = ServerHelper.CurrentDateTime; + billObj.NeedReplenishPrint = 0; //不需要补打 + await _billM110Repository.UpdateAsync(billObj, true); + } + else if (billObj.BillStatus == BillStatusEnum.NotMatch) + { + //billObj.PrintTime = ServerHelper.CurrentDateTime; + billObj.NeedReplenishPrint = 1; //需要补打 + await _billM110Repository.UpdateAsync(billObj, true); + } + } + + _logger.LogWarning($"SaveMenBanReport更新M110的门板打印标志 - {sw.ElapsedMilliseconds}毫秒"); + + } + //else if (input.PrintType == PrintTypeEnum.重新打印) //和正常打印单据完全一样,可以打印部分单据 + //{ + // throw new BusinessException("请调用LoadMenBanReport方法!"); + //} + //else if (input.PrintType == PrintTypeEnum.补打) + //{ + // List billLst = _billM110Repository.Where(itm => input.M110IdList.Contains(itm.Id)).OrderBy(itm => itm.SerialNumStr).ToList(); + // if (billLst.Count == 0) + // { + // ret.Message = "没有补打的单据,请先选择要补打的单据!"; + // ret.Status = false; + // return ret; + // } + + // int pageCnt = (int)Math.Ceiling(billLst.Count / 12.0); //每页打印12列,取打印页数 + + // double maxBillNum = 0; + + // DateTime printTime = ServerHelper.CurrentDateTime; + + // for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++) + // { + // //取右上角顺序号:按生产线分组,取当前生产线的最大流水号:01至99循环,例如01左、01右 + // double maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.门板, input.ProductLine, string.Empty); + // // 先打印两张:左后左前,再打印两张:右后右前 + // List leftLst = DoMBPrint(input, pageIdx, ref maxBillNum, maxSN, printTime, billLst, "左"); + // List rightLst = DoMBPrint(input, pageIdx, ref maxBillNum, maxSN, printTime, billLst, "右"); + + // //作废时需要同时作废相同VIN的左右两页,SortId相同表示是同一组左右 + // Guid sortId = GuidGenerator.Create(); + // foreach (var leftItm in leftLst) + // { + // leftItm.SortId = sortId; + // } + // foreach (var rightItm in rightLst) + // { + // rightItm.SortId = sortId; + // } + + // reportMainLst.AddRange(rightLst); + // reportMainLst.AddRange(leftLst); + // } + // //校验底盘号、零件是否重复打印 + // string checkVinPartRepeatSql = @" + // select top 1 a.BillNum from FisMenBanPackingList a join FisMenBanPackingRec b + // on a.Id = b.MenBanPackingListId + // where a.ReportStatus = 0 + // and b.VIN = '{0}' and (TopSAPMaterialNum = '{1}' or BelowSAPMaterialNum = '{1}') + // "; + // foreach (MenBanPackingList reportMainObj in reportMainLst) + // { + // foreach (MenBanPackingRec reportRecObj in reportMainObj.Details) + // { + // string sql1 = string.Format(checkVinPartRepeatSql, reportRecObj.VIN, reportRecObj.PartCode2); + // string checkVinPartRepeatBillNum1 = _newJitDapperRepository.GetSingleBySql(sql1, true); + // if (string.IsNullOrEmpty(checkVinPartRepeatBillNum1) == false) + // { + // throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum1}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.PartCode2}之间重复!"); + // } + + // string sql2 = string.Format(checkVinPartRepeatSql, reportRecObj.VIN, reportRecObj.PartCode4); + // string checkVinPartRepeatBillNum2 = _newJitDapperRepository.GetSingleBySql(sql2, true); + // if (string.IsNullOrEmpty(checkVinPartRepeatBillNum2) == false) + // { + // throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum2}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.PartCode4}之间重复!"); + // } + // } + // } + + // //调用派格版库存接口 + // await SaveMiddleTable_MB(reportMainLst); + + // //插入门板打印记录表 + // //await _menBanPackingListRepository.InsertManyAsync(reportMainLst); + // foreach (var reportMainObj in reportMainLst) + // { + // var insObj = await _menBanPackingListRepository.InsertAsync(reportMainObj, true); + // if (insObj != null) + // { + // retLst.Add(insObj.Id); + // } + // } + // //更新M110的门板打印标志:BillStatus=3 + // foreach (BillM110 billObj in billLst) + // { + // if (billObj.BillStatus == BillStatusEnum.Match) + // { + // billObj.SetBillStatus(BillStatusEnum.Publish); + // billObj.PrintTime = ServerHelper.CurrentDateTime; + // await _billM110Repository.UpdateAsync(billObj); + // } + // } + //} //补打if + await uow.CompleteAsync(); + ret.Status = true; + ret.Item = retLst; + return ret; + } + catch (Exception ex) + { + await uow.RollbackAsync(); + string errorMsg = _errorMessagePrefix + "SaveMenBanReport 执行出错:" + ex.Message; + _logger.LogError(errorMsg); + ret.Status = false; + ret.Message = ex.Message; + return ret; + } + } //事务 + } + + [UnitOfWork] + [HttpPost] + [Route("load-menban-report")] + public virtual async Task> LoadMenBanReport(List input) + { + _logger.LogDebug(_errorMessagePrefix + "LoadMenBanReport 进入"); + + try + { + List reportMainLst = new List(); + + reportMainLst = await _menBanPackingListRepository.GetListAsync(itm => input.Contains(itm.Id) == true, true); + //按大众顺序号排序 + foreach (var reportMainObj in reportMainLst) + { + List recLst = reportMainObj.Details; + if (recLst == null) + continue; + + bool has1999 = recLst.Any(itm => itm.HostSN.Contains("1999") || itm.HostSN.Contains("1998") || itm.HostSN.Contains("1997") + || itm.HostSN.Contains("1996") || itm.HostSN.Contains("1995") || itm.HostSN.Contains("1994") + || itm.HostSN.Contains("1993") || itm.HostSN.Contains("1992") || itm.HostSN.Contains("1991") + || itm.HostSN.Contains("1990") || itm.HostSN.Contains("1989") || itm.HostSN.Contains("1988") + || itm.HostSN.Contains("1987") || itm.HostSN.Contains("1986") || itm.HostSN.Contains("1985") + || itm.HostSN.Contains("1984") || itm.HostSN.Contains("1983") || itm.HostSN.Contains("1982") + || itm.HostSN.Contains("1981") || itm.HostSN.Contains("1980") || itm.HostSN.Contains("1979") + || itm.HostSN.Contains("1978") || itm.HostSN.Contains("1977") || itm.HostSN.Contains("1976") + ); + bool has0001 = recLst.Any(itm => itm.HostSN.Contains("0001") || itm.HostSN.Contains("0002") || itm.HostSN.Contains("0003") + || itm.HostSN.Contains("0004") || itm.HostSN.Contains("0005") || itm.HostSN.Contains("0006") + || itm.HostSN.Contains("0007") || itm.HostSN.Contains("0008") || itm.HostSN.Contains("0009") + || itm.HostSN.Contains("0010") || itm.HostSN.Contains("0011") || itm.HostSN.Contains("0012") + || itm.HostSN.Contains("0013") || itm.HostSN.Contains("0014") || itm.HostSN.Contains("0015") + || itm.HostSN.Contains("0016") || itm.HostSN.Contains("0017") || itm.HostSN.Contains("0018") + || itm.HostSN.Contains("0019") || itm.HostSN.Contains("0020") || itm.HostSN.Contains("0021") + || itm.HostSN.Contains("0022") || itm.HostSN.Contains("0023") || itm.HostSN.Contains("0024") + ); + if (has1999 && has0001) + { + reportMainObj.Details = recLst.OrderBy(itm => (itm.HostSN.TryToIntZero() % 10000) < 240 ? (itm.HostSN.TryToIntZero() % 10000 + 1999) : (itm.HostSN.TryToIntZero() % 10000)).ToList(); + } + else + { + reportMainObj.Details = recLst.OrderBy(itm => itm.HostSN).ToList(); + } + } + + #region 格式转换 + //实体 转 DTO + List targetLst = ObjectMapper.Map, List>(reportMainLst); + targetLst = targetLst.OrderBy(itm => itm.BillNum).ToList(); + + //子表BillNum赋值, BillNum填充空格 + foreach (var masterObj in targetLst) + { + masterObj.BillNum = GetTrueString(masterObj.BillNum); + int sn = 1; + foreach (var detailObj in masterObj.Details) + { + detailObj.BillNum = masterObj.BillNum; + detailObj.KNR = GetTrueString(detailObj.KNR); + detailObj.SN = (sn++).ToString(); + detailObj.VIN = detailObj.VIN.TryToRight(6); //底盘号返回后六位 + } + } + #endregion + return targetLst; + } + catch (Exception ex) + { + string errorMsg = _errorMessagePrefix + "LoadMenBanReport 执行出错:" + ex.Message; + _logger.LogError(errorMsg); + throw new UserFriendlyException(errorMsg); + } + } + + private static string GetTrueString(string str) + { + return str == null ? " " : str.Trim(); ; + } + + /// + /// 打印柱护板装箱单 + /// + /// + /// 执行成功返回真 + //[UnitOfWork] + //[HttpPost] + //[Route("print-group-zhuhuban-packing-list")] + //public virtual async Task> PrintGroupZhuHuBanPackingList(ZhuHuBanPrintInputDto input) + //{ + // throw new NotImplementedException(); + + // ZhuHuBanPrintResultDto retObj = new ZhuHuBanPrintResultDto(); + // ObjectResultDto ret = new ObjectResultDto(retObj); + // ret.Status = false; + // try + // { + // List reportMainLst = new List(); + // List forWMSLst = new List(); + + + // if (input.PrintType == PrintTypeEnum.正常打印) + // { + // if (input.BeginHostSN > input.EndHostSN) + // { + // ret.Message = "起大众顺序号不能大于止大众顺序号!"; + // ret.Status = false; + // return ret; + // } + + // ListResultDto tempLst = await GetZHBReportDetailList(input, true); //------------------- + // List billLst = tempLst.Item; + // if (tempLst.Status == false) + // { + // ret.Message = tempLst.Message; + // ret.Status = false; + // return ret; + // } + // if (billLst.Count > 24) + // { + // ret.Message = "打印柱护板单据的数量不能大于24!"; + // ret.Status = false; + // return ret; + // } + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + // long maxBillNum = 0; //子方法内部赋值 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; + + // //获取当前打印柱护板的零件类型 + // var partTypes = await _printTemplateConfigurationRepository.GetListAsync(r => r.GroupName == input.GroupName); + // foreach (var partType in partTypes) + // { + // switch (partType.PartType) + // { + // case "A上C上": + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + // break; + // case "A柱下A中": + // //A柱下,A中 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + + // break; + // case "B柱上": + // //B柱上 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // break; + // case "B柱下": + // //B柱下 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // break; + // case "D柱": + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); //左用于打印 + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); //左右用于库存接口 + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + // break; + // case "后轮上装饰板": + // //后轮,上装饰板 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + // break; + // } + // } + + // #region 调用库存接口 + // //List forWMSLst = new List(); + // //forWMSLst.AddRange(reportMainLst); + // //forWMSLst.AddRange(acLstOnlyWMSUse); + // CallWMSInterface_ZHB(forWMSLst); + // #endregion + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // var ret22 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // } + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // foreach (var updObj in updLst) + // { + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // await _billM110Repository.UpdateManyAsync(updLst, true); + + // } + // else if (input.PrintType == PrintTypeEnum.重新打印) //和正常打印单据完全一样,可以打印部分单据 + // { + // if (input.DataResultType == "1") //全部11条数据 + // { + // var firObj = await _zhuHuBanPackingListRepository.FirstOrDefaultAsync(itm => input.ReportIdList.Contains(itm.Id)); + // if (firObj != null) + // { + // Guid? sortId = firObj.SortId; + // reportMainLst = await _zhuHuBanPackingListRepository.GetListAsync(itm => itm.SortId == sortId, true); + // } + // } + // else + // { + // reportMainLst = await _zhuHuBanPackingListRepository.GetListAsync(itm => input.ReportIdList.Contains(itm.Id), true); + // } + + // //按大众顺序号排序 + // foreach (var reportMainObj in reportMainLst) + // { + // List recLst = reportMainObj.Details; + // if (recLst == null) + // continue; + // //bool has1999 = recLst.Any(itm => itm.HostSN.ToString().Contains("1999") || itm.HostSN.ToString().Contains("1998")); + // //bool has0001 = recLst.Any(itm => itm.HostSN.ToString().Contains("0001") || itm.HostSN.ToString().Contains("0002")); + // bool has1999 = recLst.Any(itm => (itm.HostSN % 10000) >= 1977); + // bool has0001 = recLst.Any(itm => (itm.HostSN % 10000) <= 23); + // if (has1999 && has0001) + // { + // reportMainObj.Details = recLst.OrderBy(itm => (itm.HostSN % 10000) <= 23 ? (itm.HostSN % 10000 + 1999) : (itm.HostSN % 10000)).ToList(); + // } + // else + // { + // reportMainObj.Details = recLst.OrderBy(itm => itm.HostSN).ToList(); + // } + // } + // } + // else if (input.PrintType == PrintTypeEnum.补打) + // { + // if (input.M110IdList.Count > 24) + // { + // throw new BusinessException("1001", $"选中的柱护板补打不能超过24个底盘!"); + // } + + // List billLst = _billM110Repository.GetListAsync(itm => input.M110IdList.Contains(itm.Id), true).GetAwaiter().GetResult(); + // if (billLst.Count == 0) + // { + // ret.Message = "没有补打的柱护板,请先选择要补打的柱护板!"; + // ret.Status = false; + // return ret; + // } + // billLst = billLst.OrderBy(itm => itm.SerialNumStr).ToList(); + + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + // long maxBillNum = 0; //全局唯一装箱单号 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; //右上角顺序号01-99 + + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + // //A柱下,A中 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + // //B柱上 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // //B柱下 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + + // //后轮,上装饰板 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + + // #region 调用库存接口 + // //List forWMSLst = new List(); + // //forWMSLst.AddRange(reportMainLst); + // //forWMSLst.AddRange(acLstOnlyWMSUse); + // CallWMSInterface_ZHB(forWMSLst); + // #endregion + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // var ret22 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // } + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // foreach (var updObj in updLst) + // { + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // await _billM110Repository.UpdateManyAsync(updLst, true); + // } + + // #region 返回结果格式转换 + // //实体 转 DTO + // List targetLst = ObjectMapper.Map, List>(reportMainLst); + // //补充空行 + // foreach (var masterObj in targetLst) + // { + // int trueCnt = masterObj.Details.Count; + + // int planCnt = 0; + // switch (masterObj.PartType) + // { + // case "A上C上": + // case "A柱下A中": + // case "B柱上": + // case "B柱下": + // case "后轮上装饰板": + // planCnt = 24; + // break; + // case "D柱": + // planCnt = 12; + // break; + // default: + // planCnt = 24; + // break; + // } + // if (trueCnt > planCnt) + // { + // throw new Exception($"实际打印行数{trueCnt}超过每页总行数{planCnt}, 底盘起{masterObj.BeginVin}底盘止{masterObj.EndVin}"); + // } + // int diffCnt = planCnt - trueCnt; + // for (int i = 0; i < diffCnt; i++) + // { + // ZhuHuBanPackingRecDto dtlObj = new ZhuHuBanPackingRecDto(); + // masterObj.Details.Add(dtlObj); + // } + // } + // //子表BillNum赋值, BillNum填充空格, SN赋值 + // foreach (var masterObj in targetLst) + // { + // masterObj.BillNum = GetTrueString(masterObj.BillNum); + // int sn = 1; + // foreach (var detailObj in masterObj.Details) + // { + // detailObj.BillNum = masterObj.BillNum; + // detailObj.KNR = GetTrueString(detailObj.KNR); + // detailObj.KNR = detailObj.KNR.Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("/n", "").Replace("/r", ""); + // detailObj.sn = sn++; + // detailObj.VIN = detailObj.VIN.TryToRight(6); //底盘号返回后六位 + // //客户要求显示零件描述,替换之前的零件编码 + // detailObj.PartCode = detailObj.MaterialDescription; + // detailObj.PartCode2 = detailObj.MaterialDescription2; + // detailObj.MaterialDescription = null; + // detailObj.MaterialDescription2 = null; + // } + // } + + // retObj.MasterList_AC = targetLst.Where(itm => itm.PartType == "A上C上").ToList(); + // if (retObj.MasterList_AC.Count == 0) retObj.IsVisibleAC = false; + // foreach (var masterObj in retObj.MasterList_AC) + // { + // retObj.DetailList_AC.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_AA = targetLst.Where(itm => itm.PartType == "A柱下A中").ToList(); + // if (retObj.MasterList_AA.Count == 0) retObj.IsVisibleAA = false; + // foreach (var masterObj in retObj.MasterList_AA) + // { + // retObj.DetailList_AA.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_BS = targetLst.Where(itm => itm.PartType == "B柱上").ToList(); + // if (retObj.MasterList_BS.Count == 0) retObj.IsVisibleBS = false; + // foreach (var masterObj in retObj.MasterList_BS) + // { + // retObj.DetailList_BS.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_BX = targetLst.Where(itm => itm.PartType == "B柱下").ToList(); + // if (retObj.MasterList_BX.Count == 0) retObj.IsVisibleBX = false; + // foreach (var masterObj in retObj.MasterList_BX) + // { + // retObj.DetailList_BX.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_D = targetLst.Where(itm => itm.PartType == "D柱").ToList(); + // if (retObj.MasterList_D.Count == 0) retObj.IsVisibleD = false; + // foreach (var masterObj in retObj.MasterList_D) + // { + // retObj.DetailList_D.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_HL = targetLst.Where(itm => itm.PartType == "后轮上装饰板").ToList(); + // if (retObj.MasterList_HL.Count == 0) retObj.IsVisibleHL = false; + // foreach (var masterObj in retObj.MasterList_HL) + // { + // retObj.DetailList_HL.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + // #endregion + // ret.Status = true; + // return ret; + // } + // catch (Exception ex) + // { + // string errorMsg = _errorMessagePrefix + "PrintZhuHuBanPackingList 执行出错:" + ex.Message; + // _logger.LogError(errorMsg); + // throw new BusinessException("1001", errorMsg); + // ret.Status = false; + // ret.Message = ex.Message; + // return ret; + // } + //} + + /// + /// 保存柱护板装箱单报表 + /// + //[UnitOfWork] + //[HttpPost] + //[Route("save-group-zhuhuban-report")] + //public virtual async Task>> SaveGroupZhuHuBanReport(ZhuHuBanPrintInputDto input) + //{ + // throw new NotImplementedException(); + + // _logger.LogDebug(_errorMessagePrefix + "SaveGroupZhuHuBanReport 进入"); + + // List retLst = new List(); + // ObjectResultDto> ret = new ObjectResultDto>(); + // ret.Status = false; + // using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: System.Data.IsolationLevel.Unspecified )) + // { + // try + // { + // List reportMainLst = new List(); + // List forWMSLst = new List(); + + // if (input.PrintType == PrintTypeEnum.正常打印) + // { + // if (input.BeginHostSN > input.EndHostSN) + // { + // ret.Message = "起大众顺序号不能大于止大众顺序号!"; + // ret.Status = false; + // return ret; + // } + + // ListResultDto tempLst = await GetZHBReportDetailList(input, true); //------------------- + // List billLst = tempLst.Item; + // if (tempLst.Status == false) + // { + // ret.Message = tempLst.Message; + // ret.Status = false; + // return ret; + // } + // if (billLst.Count > 24) + // { + // ret.Message = "打印柱护板单据的数量不能大于24!"; + // ret.Status = false; + // return ret; + // } + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + // long maxBillNum = 0; //子方法内部赋值 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; + + + + + // //获取当前打印柱护板的零件类型 + // var partTypes = await _printTemplateConfigurationRepository.GetListAsync(r => r.GroupName == input.GroupName); + // foreach (var partType in partTypes) + // { + // switch (partType.PartType) + // { + // case "A上C上": + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + // break; + // case "A柱下A中": + // //A柱下,A中 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + // break; + // case "B柱上": + // //B柱上 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // break; + // case "B柱下": + // //B柱下 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // break; + // case "D柱": + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); //左用于打印 + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); //左右用于库存接口 + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + // break; + // case "后轮上装饰板": + // //后轮,上装饰板 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + // break; + // } + // } + // #region 调用库存接口 + // await SaveMiddleTable_ZHB(forWMSLst); + // #endregion + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // var insObj2 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // if (insObj2 != null) + // { + // retLst.Add(insObj2.Id); + // } + // } + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // List list = new List(); + // foreach (var updObj in updLst) + // { + // ZHBPrintStatus item = new ZHBPrintStatus( + // GuidGenerator.Create(), + // updObj.VIN, + // input.GroupName, + // 1 + // ); + // list.Add(item); + + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // await _zHBPrintStatusRepository.InsertManyAsync(list);//柱护板插入状态 + // await _billM110Repository.UpdateManyAsync(updLst, true); + // } + // else if (input.PrintType == PrintTypeEnum.重新打印) //和正常打印单据完全一样,可以打印部分单据 + // { + // throw new BusinessException("请调用LoadZhuHuBanReport方法!"); + // } + // else if (input.PrintType == PrintTypeEnum.补打) + // { + // if (input.M110IdList.Count > 24) + // { + // throw new BusinessException("1001", $"选中的柱护板补打不能超过24个底盘!"); + // } + + // List billLst = _billM110Repository.GetListAsync(itm => input.M110IdList.Contains(itm.Id), true).GetAwaiter().GetResult(); + // if (billLst.Count == 0) + // { + // ret.Message = "没有补打的柱护板,请先选择要补打的柱护板!"; + // ret.Status = false; + // return ret; + // } + // billLst = billLst.OrderBy(itm => itm.SerialNumStr).ToList(); + + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + // long maxBillNum = 0; //全局唯一装箱单号 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; //右上角顺序号01-99 + + // //获取当前打印柱护板的零件类型 + // var partTypes = await _printTemplateConfigurationRepository.GetListAsync(r => r.GroupName == input.GroupName); + // foreach (var partType in partTypes) + // { + // switch (partType.PartType) + // { + // case "A上C上": + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + // break; + // case "A柱下A中": + // //A柱下,A中 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + // break; + // case "B柱上": + + // //B柱上 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // break; + // case "B柱下": + // //B柱下 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // break; + // case "D柱": + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + + // break; + // case "后轮上装饰板": + // //后轮,上装饰板 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + + // break; + // } + // } + // #region 调用库存接口 + // await SaveMiddleTable_ZHB(forWMSLst); + // #endregion + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // var insObj2 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // if (insObj2 != null) + // { + // retLst.Add(insObj2.Id); + // } + // } + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // foreach (var updObj in updLst) + // { + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // await _billM110Repository.UpdateManyAsync(updLst, true); + // } //补打if + + // await uow.CompleteAsync(); + // ret.Status = true; + // ret.Item = retLst; + // return ret; + // } + // catch (Exception ex) + // { + // await uow.RollbackAsync(); + // string errorMsg = _errorMessagePrefix + "SaveGroupZhuHuBanReport 执行出错:" + ex.Message; + // _logger.LogError(errorMsg); + // //throw new BusinessException("1001", errorMsg); + // ret.Status = false; + // ret.Message = ex.Message; + // return ret; + // } + + // } //事务 + //} + + /// + /// 保存柱护板装箱单报表 + /// + //[UnitOfWork(IsDisabled = true)] + //[HttpPost] + //[Route("save-zhuhuban-report")] + //public virtual async Task>> SaveZhuHuBanReport(ZhuHuBanPrintInputDto input) + //{ + // throw new NotImplementedException(); + // Stopwatch sw = new Stopwatch(); + + // _logger.LogDebug(_errorMessagePrefix + "SaveZhuHuBanReport 进入"); + // List retLst = new List(); + // ObjectResultDto> ret = new ObjectResultDto>(); + // ret.Status = false; + // using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: System.Data.IsolationLevel.Unspecified)) + // { + // try + // { + // List reportMainLst = new List(); + // List forWMSLst = new List(); + + // if (input.PrintType == PrintTypeEnum.正常打印) + // { + // if (input.BeginHostSN > input.EndHostSN) + // { + // ret.Message = "起大众顺序号不能大于止大众顺序号!"; + // ret.Status = false; + // return ret; + // } + + // ListResultDto tempLst = await GetZHBReportDetailList(input, true); //------------------- + // List billLst = tempLst.Item; + // if (tempLst.Status == false) + // { + // ret.Message = tempLst.Message; + // ret.Status = false; + // return ret; + // } + // if (billLst.Count > 24) + // { + // ret.Message = "打印柱护板单据的数量不能大于24!"; + // ret.Status = false; + // return ret; + // } + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + + // _logger.LogWarning($"SaveZhuHuBanReport 加载缓存 - {sw.ElapsedMilliseconds}毫秒"); + + + + // long maxBillNum = 0; //子方法内部赋值 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; + + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); //插入序列表、并返回序列 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + + + // _logger.LogWarning($"SaveZhuHuBanReport 转换A上C上 - {sw.ElapsedMilliseconds}毫秒"); + + + + // //A柱下,A中 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + // //B柱上 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // //B柱下 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); //左用于打印 + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); //左右用于库存接口 + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + + // //后轮,上装饰板 + // maxSN = await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + + + // _logger.LogWarning($"SaveZhuHuBanReport 转换除A上C上的其它 - {sw.ElapsedMilliseconds}毫秒"); + + + + // #region 调用库存接口 + // await SaveMiddleTable_ZHB(forWMSLst); + // #endregion + + + // _logger.LogWarning($"SaveZhuHuBanReport 保存中间库 - {sw.ElapsedMilliseconds}毫秒"); + + + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // //var insObj2 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // //if (insObj2 != null) + // //{ + // // retLst.Add(insObj2.Id); + // //} + // retLst.Add(srcObj2.Id); + // } + // await _zhuHuBanPackingListRepository.InsertManyAsync(reportMainLst); + + + // _logger.LogWarning($"SaveZhuHuBanReport 插入柱护板打印记录表 - {sw.ElapsedMilliseconds}毫秒"); + + + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // foreach (var updObj in updLst) + // { + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // //await _billM110Repository.UpdateManyAsync(updLst, true); + // await _billM110Repository.UpdateManyAsync(updLst); + + + // _logger.LogWarning($"SaveZhuHuBanReport 更新M110的柱护板打印标志 - {sw.ElapsedMilliseconds}毫秒"); + + // } + // else if (input.PrintType == PrintTypeEnum.重新打印) //和正常打印单据完全一样,可以打印部分单据 + // { + // throw new BusinessException("请调用LoadZhuHuBanReport方法!"); + // } + // else if (input.PrintType == PrintTypeEnum.补打) + // { + // if (input.M110IdList.Count > 24) + // { + // throw new BusinessException("1001", $"选中的柱护板补打不能超过24个底盘!"); + // } + + // List billLst = _billM110Repository.GetListAsync(itm => input.M110IdList.Contains(itm.Id), true).GetAwaiter().GetResult(); + // if (billLst.Count == 0) + // { + // ret.Message = "没有补打的柱护板,请先选择要补打的柱护板!"; + // ret.Status = false; + // return ret; + // } + // billLst = billLst.OrderBy(itm => itm.SerialNumStr).ToList(); + + // //加载柱护板缓存列表 + // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件 + + // long maxBillNum = 0; //全局唯一装箱单号 + // DateTime printTime = ServerHelper.CurrentDateTime; + // double maxSN; //右上角顺序号01-99 + + // //A上C上 + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A上C上"); + // List acLst = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List acLstOnlyWMSUse = DoZHBPrint_3x8_LRMerge("A上C上", input, maxBillNum, maxSN, printTime, billLst, "右"); //仅库存系统接口使用,打印记录表不保存 + // if (acLstOnlyWMSUse.Count > 0 && acLst.Count > 0) + // { + // acLstOnlyWMSUse[0].Details.InsertRange(0, acLst[0].Details); //右插入左 + // } + // reportMainLst.AddRange(acLst); + // forWMSLst.AddRange(acLstOnlyWMSUse); + // //A柱下,A中 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "A柱下A中"); + + // List aaLst1 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List aaLst2 = DoZHBPrint_3x8_LR("A柱下A中", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(aaLst1); + // reportMainLst.AddRange(aaLst2); + // forWMSLst.AddRange(aaLst1); + // forWMSLst.AddRange(aaLst2); + // //B柱上 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱上"); + // List bUpLst1 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bUpLst2 = DoZHBPrint_4x6_LR("B柱上", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bUpLst1); + // reportMainLst.AddRange(bUpLst2); + // forWMSLst.AddRange(bUpLst1); + // forWMSLst.AddRange(bUpLst2); + // //B柱下 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "B柱下"); + + // List bDownLst1 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List bDownLst2 = DoZHBPrint_4x6_LR("B柱下", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(bDownLst1); + // reportMainLst.AddRange(bDownLst2); + // forWMSLst.AddRange(bDownLst1); + // forWMSLst.AddRange(bDownLst2); + // //D柱 + // var lst1 = billLst.Take(12).ToList(); + // var lst2 = billLst.Skip(12).ToList(); + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1, "左"); + // List forWMSLst1 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst1); + + // maxBillNum = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号); + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "D柱"); + // List dLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2, "左"); + // List forWMSLst2 = DoZHBPrint_4x3("D柱", input, maxBillNum, maxSN, printTime, lst2); + // reportMainLst.AddRange(dLst1); + // reportMainLst.AddRange(dLst2); + // forWMSLst.AddRange(forWMSLst1); + // forWMSLst.AddRange(forWMSLst2); + + // //后轮,上装饰板 + // maxSN = 0; // await _lineSNDomianService.GetMaxSN(ProductTypeEnum.柱护板, input.ProductLine, "后轮上装饰板"); + // List hsLst1 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "左"); + // List hsLst2 = DoZHBPrint_4x6_LR("后轮上装饰板", input, maxBillNum, maxSN, printTime, billLst, "右"); + // reportMainLst.AddRange(hsLst1); + // reportMainLst.AddRange(hsLst2); + // forWMSLst.AddRange(hsLst1); + // forWMSLst.AddRange(hsLst2); + + // #region 调用库存接口 + // await SaveMiddleTable_ZHB(forWMSLst); + // #endregion + + // //插入柱护板打印记录表 + // Guid sortId = GuidGenerator.Create(); + // foreach (var srcObj2 in reportMainLst) + // { + // srcObj2.SortId = sortId; //一次打印SortId相同 + // var insObj2 = await _zhuHuBanPackingListRepository.InsertAsync(srcObj2, true); + // if (insObj2 != null) + // { + // retLst.Add(insObj2.Id); + // } + // } + + // ////更新M110的柱护板打印标志: PrintBillNum不为空时表示已打印 + // var updIdLst = billLst.Select(itm => itm.Id).ToList(); + // var updLst = await _billM110Repository.GetListAsync(itm => updIdLst.Contains(itm.Id)); + // foreach (var updObj in updLst) + // { + // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印" + // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板 + // } + // await _billM110Repository.UpdateManyAsync(updLst, true); + // } //补打if + + // await uow.CompleteAsync(); + + // _logger.LogWarning($"SaveZhuHuBanReport CompleteAsync - {sw.ElapsedMilliseconds}毫秒"); + + // ret.Status = true; + // ret.Item = retLst; + // return ret; + // } + // catch (Exception ex) + // { + // await uow.RollbackAsync(); + // string errorMsg = _errorMessagePrefix + "SaveZhuHuBanReport 执行出错:" + ex.Message; + // _logger.LogError(errorMsg); + // //throw new BusinessException("1001", errorMsg); + // ret.Status = false; + // ret.Message = ex.Message; + // return ret; + // } + + // } //事务 + //} + + /// + /// 加载柱护板装箱单报表【仅ReportIdList、DataResultType参数有效】 + /// + //[UnitOfWork] + //[HttpPost] + //[Route("load-zhuhuban-report")] + //public virtual async Task> LoadZhuHuBanReport(ZhuHuBanPrintInputDto input) + //{ + // throw new NotImplementedException(); + + // Stopwatch sw = new Stopwatch(); + + + // _logger.LogDebug(_errorMessagePrefix + "LoadZhuHuBanReport 进入"); + + // ZhuHuBanPrintResultDto retObj = new ZhuHuBanPrintResultDto(); + // ObjectResultDto ret = new ObjectResultDto(retObj); + // ret.Status = false; + // try + // { + // List reportMainLst = new List(); + // List forWMSLst = new List(); + + // if (input.DataResultType == "1") //全部11条数据 + // { + // var firObj = await _zhuHuBanPackingListRepository.FirstOrDefaultAsync(itm => input.ReportIdList.Contains(itm.Id)); + // if (firObj != null) + // { + // Guid? sortId = firObj.SortId; + // reportMainLst = await _zhuHuBanPackingListRepository.GetListAsync(itm => itm.SortId == sortId, true); + // } + // } + // else + // { + // reportMainLst = await _zhuHuBanPackingListRepository.GetListAsync(itm => input.ReportIdList.Contains(itm.Id), true); + // } + + + // _logger.LogWarning($"LoadZhuHuBanReport 取柱护板数据 - {sw.ElapsedMilliseconds}毫秒"); + + + // //按大众顺序号排序 + // foreach (var reportMainObj in reportMainLst) + // { + // List recLst = reportMainObj.Details; + // if (recLst == null) + // continue; + // //bool has1999 = recLst.Any(itm => itm.HostSN.ToString().Contains("1999") || itm.HostSN.ToString().Contains("1998")); + // //bool has0001 = recLst.Any(itm => itm.HostSN.ToString().Contains("0001") || itm.HostSN.ToString().Contains("0002")); + // bool has1999 = recLst.Any(itm => (itm.HostSN % 10000) > 1999 - 240); + // bool has0001 = recLst.Any(itm => (itm.HostSN % 10000) < 240); + // if (has1999 && has0001) + // { + // reportMainObj.Details = recLst.OrderBy(itm => (itm.HostSN % 10000) < 240 ? (itm.HostSN % 10000 + 1999) : (itm.HostSN % 10000)).ToList(); + // } + // else + // { + // reportMainObj.Details = recLst.OrderBy(itm => itm.HostSN).ToList(); + // } + // } + + // #region 返回结果格式转换 + // //实体 转 DTO + // List targetLst = ObjectMapper.Map, List>(reportMainLst); + // //补充空行 + // foreach (var masterObj in targetLst) + // { + // int trueCnt = masterObj.Details.Count; + + // int planCnt = 0; + // switch (masterObj.PartType) + // { + // case "A上C上": + // case "A柱下A中": + // case "B柱上": + // case "B柱下": + // case "后轮上装饰板": + // planCnt = 24; + // break; + // case "D柱": + // planCnt = 12; + // break; + // default: + // planCnt = 24; + // break; + // } + // if (trueCnt > planCnt) + // { + // throw new Exception($"实际打印行数{trueCnt}超过每页总行数{planCnt}, 底盘起{masterObj.BeginVin}底盘止{masterObj.EndVin}"); + // } + // int diffCnt = planCnt - trueCnt; + // for (int i = 0; i < diffCnt; i++) + // { + // ZhuHuBanPackingRecDto dtlObj = new ZhuHuBanPackingRecDto(); + // masterObj.Details.Add(dtlObj); + // } + // } + // //子表BillNum赋值, BillNum填充空格, SN赋值 + // foreach (var masterObj in targetLst) + // { + // masterObj.BillNum = GetTrueString(masterObj.BillNum); + // int sn = 1; + // foreach (var detailObj in masterObj.Details) + // { + // detailObj.BillNum = masterObj.BillNum; + // detailObj.KNR = GetTrueString(detailObj.KNR); + // detailObj.KNR = detailObj.KNR.Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("/n", "").Replace("/r", ""); + // detailObj.sn = sn++; + // detailObj.VIN = detailObj.VIN.TryToRight(6); //底盘号返回后六位 + // //客户要求显示零件描述,替换之前的零件编码 + // detailObj.PartCode = detailObj.MaterialDescription; + // detailObj.PartCode2 = detailObj.MaterialDescription2; + // detailObj.MaterialDescription = null; + // detailObj.MaterialDescription2 = null; + // } + // } + + // retObj.MasterList_AC = targetLst.Where(itm => itm.PartType == "A上C上").ToList(); + // if (retObj.MasterList_AC.Count == 0) retObj.IsVisibleAC = false; + // foreach (var masterObj in retObj.MasterList_AC) + // { + // retObj.DetailList_AC.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_AA = targetLst.Where(itm => itm.PartType == "A柱下A中").ToList(); + // if (retObj.MasterList_AA.Count == 0) retObj.IsVisibleAA = false; + // foreach (var masterObj in retObj.MasterList_AA) + // { + // retObj.DetailList_AA.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_BS = targetLst.Where(itm => itm.PartType == "B柱上").ToList(); + // if (retObj.MasterList_BS.Count == 0) retObj.IsVisibleBS = false; + // foreach (var masterObj in retObj.MasterList_BS) + // { + // retObj.DetailList_BS.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_BX = targetLst.Where(itm => itm.PartType == "B柱下").ToList(); + // if (retObj.MasterList_BX.Count == 0) retObj.IsVisibleBX = false; + // foreach (var masterObj in retObj.MasterList_BX) + // { + // retObj.DetailList_BX.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_D = targetLst.Where(itm => itm.PartType == "D柱").ToList(); + // if (retObj.MasterList_D.Count == 0) retObj.IsVisibleD = false; + // foreach (var masterObj in retObj.MasterList_D) + // { + // retObj.DetailList_D.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + + // retObj.MasterList_HL = targetLst.Where(itm => itm.PartType == "后轮上装饰板").ToList(); + // if (retObj.MasterList_HL.Count == 0) retObj.IsVisibleHL = false; + // foreach (var masterObj in retObj.MasterList_HL) + // { + // retObj.DetailList_HL.AddRange(masterObj.Details); + // masterObj.Details = null; + // } + // #endregion + + + // _logger.LogWarning($"LoadZhuHuBanReport 排序及转换 - {sw.ElapsedMilliseconds}毫秒"); + + // ret.Status = true; + // return ret; + // } + // catch (Exception ex) + // { + // string errorMsg = _errorMessagePrefix + "LoadZhuHuBanReport 执行出错:" + ex.Message; + // _logger.LogError(errorMsg); + // //throw new BusinessException("1001", errorMsg); + // ret.Status = false; + // ret.Message = ex.Message; + // return ret; + // } + //} + + /// + /// 保存门板信息到中间表,中间表是位于FIS库,和WMS中间表结构相同 + /// + /// + //private async Task SaveMiddleTable_MB(List input) + //{ + // throw new NotImplementedException(); + + // List targetMainLst = new List(); + // List targetDetailLst = new List(); + // List cxLst = new List(); + // foreach (MenBanPackingList sourceObj in input) + // { + // FisTB_BILL targetMain = new FisTB_BILL(); + // targetMain.BillNum = sourceObj.BillNum; //单据编号 + // targetMain.State = 0; + // targetMain.BillType = 206; //单据类型 + // targetMain.SubBillType = 21004; //单据子类型 + // targetMain.BillTime = sourceObj.PrintDate; //单据时间 + // targetMain.OperName = sourceObj.CreatorId.ToString(); //操作员 + // targetMain.DetailQty = 0; //明细数量 + // targetMain.CustId = _providerCode; //供应商编号 + // //targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + // //targetMain.DockCode = sourceObj.BillLocation; + + // targetMain.GateCode = sourceObj.PartType; //B柱下 + // targetMain.GateName = sourceObj.BillSerialNum; //顺序号 + // targetMain.DockCode = sourceObj.VehicleModel; //左或右 + // targetMain.Remark = sourceObj.MinOnlineTime == null ? null : ((DateTime)sourceObj.MinOnlineTime).ToString("yyyy-MM-dd HH:mm"); //最早上线时间(预计到达时间) + // targetMain.TransportType = sourceObj.BillSerialNum; //顺序号 + // targetMain.SourceBillNum3 = sourceObj.ProductLine; //2022-10-13加生产线 + // targetMainLst.Add(targetMain); + // int idx = 0; + // int idx2 = 0; + // foreach (MenBanPackingRec sourceRec in sourceObj.Details) + // { + // idx2++; + // if (sourceRec.PartCode2.IsNullOrEmpty() == false) + // { + // var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.PartCode2 && itm.MaterialType == "1"); + // idx++; + // FisTS_SORT_DETAIL targetDetail = new FisTS_SORT_DETAIL(); + // targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + // targetDetail.LineNum = idx2; //行号 + // targetDetail.VinCode = sourceRec.VIN; //VIN码 + // targetDetail.SeqNum = idx2.ToString(); //顺序号sourceRec.HostSN.ToString() + // targetDetail.PartCode = sourceRec.PartCode2; //物料号 + // //targetDetail.BarCode = sourceRec.TopBoxPositionNum; //箱码 + // targetDetail.ProjectId = ""; //车型 + // targetDetail.PlanQty = 1; //计划数量 + // targetDetail.State = "0"; //状态 + // targetDetail.CustPartCode = materialObj == null ? null : materialObj.RelationKey; + // targetDetail.FullBarCode = "-"; + // targetDetail.VendId = sourceRec.KNR; + // //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + // targetDetailLst.Add(targetDetail); + // if (materialObj != null && materialObj.VehicleModel != null) + // { + // cxLst.Add(materialObj.VehicleModel); + // } + // } + // if (sourceRec.PartCode4.IsNullOrEmpty() == false) + // { + // var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.PartCode4 && itm.MaterialType == "1"); + + // idx++; + // FisTS_SORT_DETAIL targetDetail = new FisTS_SORT_DETAIL(); + // targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + // targetDetail.VinCode = sourceRec.VIN; //VIN码 + // targetDetail.PartCode = sourceRec.PartCode4; //物料号 + // targetDetail.LineNum = (idx2 + 12); //行号 + // targetDetail.SeqNum = (idx2 + 12).ToString(); //顺序号sourceRec.HostSN.ToString() + // //targetDetail.BarCode = sourceRec.TopBoxPositionNum; //箱码 + // targetDetail.ProjectId = ""; //车型 + // targetDetail.State = "0"; //状态 + // targetDetail.PlanQty = 1; //计划数量 + // targetDetail.CustPartCode = materialObj == null ? null : materialObj.RelationKey; + // targetDetail.FullBarCode = "-"; + // targetDetail.VendId = sourceRec.KNR; + // //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + // targetDetailLst.Add(targetDetail); + // if (materialObj != null && materialObj.VehicleModel != null) + // { + // cxLst.Add(materialObj.VehicleModel); + // } + // } + // } + // //生成车型 + // string cxStr = ""; + // foreach (string cxObj in cxLst.Distinct()) + // { + // cxStr += cxObj + "、"; + // } + // if (cxStr.Length > 0) + // { + // cxStr = cxStr.Substring(0, cxStr.Length - 1); + // } + // targetMain.ProjectId = cxStr; //添加车型 + + // if (string.IsNullOrEmpty(cxStr)) + // { + // targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + // } + // } + + // foreach (FisTB_BILL targetMain in targetMainLst) + // { + // //明细数量 + // targetMain.DetailQty = targetDetailLst.Where(p => p.BillNum == targetMain.BillNum).Count(); + // } + // //保存到数据表 + // await _tbBillRepository.InsertManyAsync(targetMainLst, true); + // await _tsSortDetailRepository.InsertManyAsync(targetDetailLst, true); + //} + + /// + /// 保存柱护板信息到中间表,中间表是位于FIS库,和WMS中间表结构相同 + /// + /// + //private async Task SaveMiddleTable_ZHB(List input) + //{ + // throw new NotImplementedException(); + + // List targetMainLst = new List(); + // List targetDetailLst = new List(); + + // List cxLst = new List(); + // foreach (ZhuHuBanPackingList sourceObj in input) + // { + // FisTB_BILL targetMain = new FisTB_BILL(); + // targetMain.BillNum = sourceObj.BillNum; //单据编号 + // targetMain.State = 0; + // targetMain.BillType = 206; //单据类型 + // targetMain.SubBillType = 20110; //单据子类型 + // targetMain.BillTime = sourceObj.PrintDate; //单据时间 + // targetMain.OperName = sourceObj.CreatorId.ToString(); //操作员 + // targetMain.DetailQty = 0; //明细数量 + // targetMain.CustId = _providerCode; //供应商编号 + // //targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + + // targetMain.GateName = sourceObj.BillSerialNum; //顺序号 + // targetMain.GateCode = sourceObj.PartType; //B柱下 + // targetMain.DockCode = sourceObj.BillLocation; //左或右 + // targetMain.Remark = sourceObj.MinOnlineTime == null ? null : ((DateTime)sourceObj.MinOnlineTime).ToString("yyyy-MM-dd HH:mm"); //最早上线时间 + // targetMain.TransportType = sourceObj.BillSerialNum; //顺序号 + // targetMain.SourceBillNum3 = sourceObj.ProductLine; //2022-10-13加生产线 + // targetMainLst.Add(targetMain); + // int idx = 0; + // int barCode = 0; + // foreach (ZhuHuBanPackingRec sourceRec in sourceObj.Details) + // { + // barCode++; + // if (sourceRec.PartCode.IsNullOrEmpty() == false) + // { + // idx++; + // //var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode && itm.MaterialType == "2"); + // var materialObj = _zhbCacheList.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode); + // FisTS_SORT_DETAIL targetDetail = new FisTS_SORT_DETAIL(); + // targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + // targetDetail.VinCode = sourceRec.VIN; //VIN码 + // targetDetail.PartCode = materialObj == null ? sourceRec.PartCode : materialObj.MaterialNum; //SAP物料号 + // targetDetail.LineNum = idx; //行号 + // targetDetail.SeqNum = idx.ToString(); //顺序号 + // targetDetail.ProjectId = ""; //车型 + // targetDetail.State = "0"; //状态 + // //targetDetail.BarCode = barCode.ToString(); //箱码 + // targetDetail.PlanQty = 1; //计划数量 + // targetDetail.CustPartCode = sourceRec.PartCode; //客户零件号 + // targetDetail.FullBarCode = "-"; + // targetDetail.VendId = sourceRec.KNR; + // //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + // targetDetailLst.Add(targetDetail); + // if (materialObj != null && materialObj.VehicleModel != null) + // { + // cxLst.Add(materialObj.VehicleModel); + // } + + // } + // if (sourceRec.PartCode2.IsNullOrEmpty() == false) + // { + // idx++; + // //var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode2 && itm.MaterialType == "2"); + // var materialObj = _zhbCacheList.FirstOrDefault(itm => itm.RelationKey == sourceRec.PartCode2); + + // FisTS_SORT_DETAIL targetDetail = new FisTS_SORT_DETAIL(); + // targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接 + // targetDetail.VinCode = sourceRec.VIN; //VIN码 + // targetDetail.PartCode = materialObj == null ? sourceRec.PartCode2 : materialObj.MaterialNum; //SAP物料号 + // targetDetail.LineNum = idx; //行号 + // targetDetail.SeqNum = idx.ToString(); //顺序号 + // targetDetail.ProjectId = ""; //车型 + // targetDetail.State = "0"; //状态 + // //targetDetail.BarCode = barCode.ToString(); //箱码 + // targetDetail.PlanQty = 1; //计划数量 + // targetDetail.CustPartCode = sourceRec.PartCode2; //客户零件号 + // targetDetail.FullBarCode = "-"; + // targetDetail.VendId = sourceRec.KNR; + // //targetDetail.BarCode = sourceRec.HostSN.ToString(); //2022-10-13加 + // targetDetailLst.Add(targetDetail); + // if (materialObj != null && materialObj.VehicleModel != null) + // { + // cxLst.Add(materialObj.VehicleModel); + // } + // } + // } + // //生成车型 + // string cxStr = ""; + // foreach (string cxObj in cxLst.Distinct()) + // { + // cxStr += cxObj + "、"; + // } + // if (cxStr.Length > 0) + // { + // cxStr = cxStr.Substring(0, cxStr.Length - 1); + // } + // targetMain.ProjectId = cxStr; //添加车型 + + // if (string.IsNullOrEmpty(cxStr)) + // { + // targetMain.ProjectId = sourceObj.PartType == null ? null : sourceObj.PartType.Replace(" DP", ""); //添加车型 + // } + // } + // foreach (FisTB_BILL targetMain in targetMainLst) + // { + // //明细数量 + // targetMain.DetailQty = targetDetailLst.Where(p => p.BillNum == targetMain.BillNum).Count(); + // } + // //保存到数据表 + // //await _tbBillRepository.InsertManyAsync(targetMainLst, true); + // //await _tsSortDetailRepository.InsertManyAsync(targetDetailLst, true); + // await _tbBillRepository.InsertManyAsync(targetMainLst); + // await _tsSortDetailRepository.InsertManyAsync(targetDetailLst); + //} + + #endregion + + //[UnitOfWork(false)] + //[HttpPost] + //[Route("get-last-hostsn-by-pl")] + //public virtual async Task> GetLastHostSNByPL(MenBanPrintInputDto input) + //{ + // throw new NotImplementedException(); + + // _logger.LogDebug(_errorMessagePrefix + "GetLastHostSNByPL 进入"); + // ObjectResultDto ret = new ObjectResultDto(); + // try + // { + // string lastHostSNSql = $@" + // select top 1 EndHostSN from FisMenBanPackingList a + // where a.ProductLine = '{input.ProductLine}' and a.BillLocation = '左' + // and a.ReportStatus = 0 and a.PrintType = 0 + // order by a.BillNum desc, a.MinOnlineTime desc + // "; + // string lastHostSNStr = await _newJitDapperRepository.GetSingleBySqlAsync(lastHostSNSql); + // int lastHostSN = lastHostSNStr.TryToIntZero(); + // if ((input.BeginHostSN % 10000) == 1) + // { + // if (lastHostSN == 0) + // { + // } + // else if ((lastHostSN % 10000) != 1999) + // { + // ret.Message = $"上次打印到{lastHostSN},本次从{input.BeginHostSN}开始打印,之间存在断号!"; + // _logger.LogError("断号校验:" + ret.Message); + + // ret.Status = false; + // return ret; + // } + // } + // else + // { + // if (input.BeginHostSN != lastHostSN + 1) + // { + // ret.Message = $"上次打印到{lastHostSN},本次从{input.BeginHostSN}开始打印,之间存在断号!"; + // _logger.LogError("断号校验:" + ret.Message); + // ret.Status = false; + // return ret; + // } + // } + // ret.Status = true; + // return ret; + // } + // catch (Exception ex) + // { + + // string errMsg = _errorMessagePrefix + "GetLastHostSNByPL 执行出错:" + ex.Message; + // _logger.LogError(errMsg); + // ret.Message = errMsg; + // ret.Status = false; + // return ret; + // } + + + //} + } + +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM100AppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM100AppService.cs index 0ca5511..0e34f01 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM100AppService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM100AppService.cs @@ -110,7 +110,7 @@ with d as ) select * from ( - select ROW_NUMBER() OVER(order by r.SerialNumStr) as row_number, + select ROW_NUMBER() OVER(order by r.OnlineTime, r.HostSN) as row_number, r.*, d.DicItemName as VehicleModelName, a.AssemblyName from FisRepeatM100 r left join d on r.VehicleModelCode = d.DicItemCode diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM110AppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM110AppService.cs new file mode 100644 index 0000000..c230af8 --- /dev/null +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatM110AppService.cs @@ -0,0 +1,375 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using Volo.Abp.Domain.Repositories.Dapper; +using WY.NewJit.EntityFrameworkCore; +using WY.NewJit.Common; +using Shouldly; +using Volo.Abp.BlobStoring; +using Microsoft.AspNetCore.Mvc; + +namespace WY.NewJit.MsgCheck +{ + /// + /// M110重复报文应用服务实现 + /// + [Route("api/newjit/repeat-M110")] + [ApiExplorerSettings(GroupName = SwaggerGroupConsts.报文解析及校验)] + public class RepeatM110AppService : ApplicationService, IRepeatM110AppService + { + /// + /// 仓储 + /// + private readonly IRepository _repeatM110Repository; + + private readonly IRepository _repeatM110PartRepository; + + + /// + /// 日志 + /// + private ILogger _logger; + + /// + /// Dapper仓储 + /// + private readonly NewJitDapperRepository _newJitDapperRepository; + + /// + /// BLOB存储 + /// + private readonly IBlobContainer _blobContainer; + + /// + /// 错误信息前缀 + /// + private string _errorMessagePrefix + { + get + { + return System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."; + } + } + + /// + /// 构造函数 + /// + public RepeatM110AppService( + IRepository repeatM110Repository, + IRepository repeatM110PartRepository, + ILogger logger, + NewJitDapperRepository newJitDapperRepository, + IBlobContainer blobContainer + ) + { + _repeatM110Repository = repeatM110Repository; + _repeatM110PartRepository = repeatM110PartRepository; + _logger = logger; + _newJitDapperRepository = newJitDapperRepository; + _blobContainer = blobContainer; + } + + #region 私有方法 + /// + /// 根据筛选条件获取实体列表 + /// + private async Task> QueryByConditionAsync(QueryRepeatM110Dto input, PagedAndSortedBase page) + { + PagedResultDto ret = new PagedResultDto(); + + string sqlCnt = @" +with d as +( + select * from FisDicItem where DicTypeCode in (select DicTypeCode from FisDicType where DicTypeName = '车型') +) +select * from +( + select count(*) as cnt + from FisRepeatM110 r + left join d on r.VehicleModelCode = d.DicItemCode + left join FisAssemblyCfgVehicle a on r.AssemblyID = a.Id + where 1=1 {0} +) t +"; + + string sql = @" +with d as +( + select * from FisDicItem where DicTypeCode in (select DicTypeCode from FisDicType where DicTypeName = '车型') +) +select * from +( + select ROW_NUMBER() OVER(order by r.OnlineTime, r.HostSN) as row_number, + r.*, d.DicItemName as VehicleModelName, a.AssemblyName + from FisRepeatM110 r + left join d on r.VehicleModelCode = d.DicItemCode + left join FisAssemblyCfgVehicle a on r.AssemblyID = a.Id + where 1=1 {0} +) t where row_number between {1} and {2} +"; + string where = ""; + if (input.HostSNBegin != null) + { + where += string.Format(" and r.HostSN >= {0}", input.HostSNBegin); + } + if (input.HostSNEnd != null) + { + where += string.Format(" and r.HostSN <= {0}", input.HostSNEnd); + } + if (!string.IsNullOrEmpty(input.KNRBegin)) + { + where += string.Format(" and r.KNR >= '{0}'", input.KNRBegin); + } + if (!string.IsNullOrEmpty(input.KNREnd)) + { + where += string.Format(" and r.KNR <= '{0}'", input.KNREnd); + } + + if (!string.IsNullOrEmpty(input.VINBegin)) + { + where += string.Format(" and r.VIN >= '{0}'", input.VINBegin); + } + if (!string.IsNullOrEmpty(input.VINEnd)) + { + where += string.Format(" and r.VIN <= '{0}'", input.VINEnd); + } + if (input.OnlineTimeBegin != null) + { + where += string.Format(" and r.OnlineTime >= '{0}'", ((DateTime)input.OnlineTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.OnlineTimeEnd != null) + { + where += string.Format(" and r.OnlineTime <= '{0}'", ((DateTime)input.OnlineTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (!string.IsNullOrEmpty(input.VehicleModelCode)) + { + where += string.Format(" and r.VehicleModelCode = '{0}'", input.VehicleModelCode); + } + if (input.ProductLine != null) + { + where += string.Format(" and r.ProductLine = '{0}'", input.ProductLine); + } + if (input.Version != null) + { + where += string.Format(" and r.Version like '%{0}%'", input.Version); + } + if (input.ReceiveTimeBegin != null) + { + where += string.Format(" and r.ReceiveTime >= '{0}'", ((DateTime)input.ReceiveTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); + } + if (input.ReceiveTimeEnd != null) + { + where += string.Format(" and r.ReceiveTime <= '{0}'", ((DateTime)input.ReceiveTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); + } + sqlCnt = string.Format(sqlCnt, where); + ret.TotalCount = await _newJitDapperRepository.GetSingleBySqlAsync(sqlCnt); + + //计算分页 + int fromRec = page.SkipCount + 1; + int ToRec = page.SkipCount + page.MaxResultCount; + sql = string.Format(sql, where, fromRec, ToRec); + var lst = await _newJitDapperRepository.GetListBySqlAsync(sql); + ret.Items = lst; + return ret; + } + #endregion + + #region 公共方法 + + /// + /// 根据筛选条件获取分页实体列表 + /// + /// 输入查询条件 + /// 输入分页条件 + /// 返回符合条件的排序分页列表 + [HttpGet] + [UnitOfWork(false)] + [Route("list")] + public virtual async Task> GetListAsync(QueryRepeatM110Dto input) + { + _logger.LogDebug(_errorMessagePrefix + "GetListAsync 进入"); + try + { + PagedResultDto ret = await QueryByConditionAsync(input, (PagedAndSortedBase)input); + return ret; + } + catch (Exception ex) + { + string errMsg = _errorMessagePrefix + "GetListAsync 执行出错:" + ex.Message; + _logger.LogError(errMsg); + return new PagedResultDto(0, new List()); + } + } + + /// + /// 按主键获取唯一实体 + /// + /// 主键 + /// 实体信息 + [HttpGet] + [Route("{id}")]//obj/ + public virtual async Task> GetAsync(Guid id) + { + _logger.LogDebug(_errorMessagePrefix + "GetAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + RepeatM110 sourceObj = await _repeatM110Repository.GetAsync(id); + RepeatM110Dto targetObj = ObjectMapper.Map(sourceObj); + ret.Item = targetObj; + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "GetAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + + + /// + /// 添加实体 + /// + /// 添加内容 + /// 执行成功返回真 + [HttpPost] + [UnitOfWork] + [Route("")]//create + public virtual async Task> CreateAsync(CreateUpdateRepeatM110Dto input) + { + _logger.LogDebug(_errorMessagePrefix + "CreateAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + //取重复报文 最大流水号 + //int repeatMaxSN = _repeatM110Repository.Max(itm => itm.SerialNum) ?? 0; + + + RepeatM110 obj = ObjectMapper.Map(input); + obj.SetSerialNum(ServerHelper.VinToSN(obj.VIN)); //++repeatMaxSN + #region 主子表主键Id赋值 + foreach (var item in obj.M110RepeatParts) + { + item.SetId(GuidGenerator.Create()); + } + #endregion + RepeatM110 obj2 = await _repeatM110Repository.InsertAsync(obj); + ret.Item = obj2.Id; //返回添加对象的主键 + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "CreateAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + + + + + /// + /// 删除实体 + /// + /// 删除主键 + /// 执行成功返回真 + [UnitOfWork] + [HttpDelete] + [Route("{id}")]//delete/ + public virtual async Task DeleteAsync(string id) + { + _logger.LogDebug(_errorMessagePrefix + "DeleteAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + List idLst = ServerHelper.GetGuidListByStr(id); + foreach (Guid item in idLst) + { + RepeatM110 sourceObj = await _repeatM110Repository.GetAsync(item); + if (sourceObj != null) + { + await _repeatM110PartRepository.DeleteManyAsync(sourceObj.M110RepeatParts); + await _repeatM110Repository.DeleteAsync(item); + } + } + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "DeleteAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 导出信息 + /// + /// 导出查询条件 + /// 执行成功返回真 + [UnitOfWork(false)] + [HttpPost] + [Route("export")] + public virtual async Task> ExportAsync(QueryRepeatM110Dto input) + { + _logger.LogDebug(_errorMessagePrefix + "ExportAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + input.SkipCount = 0; + input.MaxResultCount = 50000; + PagedResultDto query = await QueryByConditionAsync(input, (PagedAndSortedBase)input); + List items = query.Items.ToList(); + //将实体列表转换成excel文件流 + IExporter exporter = new ExcelExporter(); + byte[] byteArr = await exporter.ExportAsByteArray(items); + byteArr.ShouldNotBeNull(); + //将excel文件流保存到服务器端文件系统 + string fileName = string.Format("重复报文M110_{0}.xlsx", Guid.NewGuid().ToString()); + await _blobContainer.SaveAsync(fileName, byteArr); + + ret.Item = fileName; + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "ExportAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + + /// + /// 导入信息 + /// + /// 导入文件流 + /// 执行成功返回真 + [UnitOfWork] + [HttpPost] + [Route("import")] + public virtual async Task ImportAsync(byte[] input) + { + throw new NotImplementedException("暂不实现所有导入"); + } + #endregion + + } +} diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatR100AppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatR100AppService.cs index 900ba3d..1b640ad 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatR100AppService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/RepeatMessages/RepeatR100AppService.cs @@ -110,7 +110,7 @@ with d as ) select * from ( - select ROW_NUMBER() OVER(order by r.SerialNumStr) as row_number, + select ROW_NUMBER() OVER(order by r.OnlineTime, r.HostSN) as row_number, r.*, d.DicItemName as VehicleModelName, a.AssemblyName from FisRepeatR100 r left join d on r.VehicleModelCode = d.DicItemCode diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs index 786a158..b67bf94 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs @@ -75,6 +75,23 @@ namespace WY.NewJit .ForMember(dest => dest.UnknownAssemblyParts, option => option.MapFrom(src => src.UnknownAssemblyParts)).ReverseMap(); CreateMap().ReverseMap(); + #region M110 + CreateMap() + .ForMember(dest => dest.M110RepeatParts, option => option.MapFrom(src => src.M110RepeatParts)).ReverseMap(); + CreateMap().ReverseMap(); + + CreateMap() + .ForMember(dest => dest.M110RepeatParts, option => option.MapFrom(src => src.M110RepeatParts)).ReverseMap(); + CreateMap().ReverseMap(); + + CreateMap() + .ForMember(dest => dest.BillM110Parts, option => option.MapFrom(src => src.BillM110Parts)).ReverseMap(); + CreateMap().ReverseMap(); + CreateMap() + .ForMember(dest => dest.BillM110Parts, option => option.MapFrom(src => src.BillM110Parts)).ReverseMap(); + CreateMap().ReverseMap(); + #endregion + //未知总成 没加//!! #endregion diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml index 38a8501..f216a6a 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml @@ -1254,6 +1254,231 @@ + + + M110单据管理应用服务实现 + + + + + 仓储 + + + + + 日志 + + + + + Dapper仓储 + + + + + BLOB存储 + + + + + 门板装箱单仓储 + + + + + 门板装箱单仓储明细 + + + + + 柱护板装箱单仓储 + + + + + 柱护板装箱单仓储明细 + + + + + ERP总成仓储 + + + + + 整车总成配置仓库 + + + + + 零件配置 + + + + + 派格版本物料库扩展 + + + + + 最大右边号的领域方法 + + + + + 库存系统Dapper仓储 + + + + + 序列领域服务 + + + + + 配置 + + + + + 错误信息前缀 + + + + + 柱护板缓存列表(打印柱护板时用到) + + + + + 构造函数 + + + + + 查询柱护板 + + + + + + + + 从M110中取当前产线、已经打印的最大大众顺序号 + + + + + + + 根据筛选条件获取实体列表 + + + + + 根据条件取用于打印的门板单据列表 + + + 断号时是否填充 + 是否柱护板装箱单调用 + + + + + 补充断号数据 + + + + + + + + + 打印左侧或右侧门板 + + + + + + + + + + + + + 打印前检查大众顺序号是否断号 + + + 断号时Item不为空 + + + + 根据生产线获取正常打印单据的起始大众顺序号2 + + 生产线 + 柱护板是1 门板是非1 + 柱护板分组类型 + 起始大众顺序号 + + + + 根据筛选条件获取分页实体列表 + + 输入查询条件 + 输入分页条件 + 返回符合条件的排序分页列表 + + + + 按主键获取唯一实体 + + 主键 + 实体信息 + + + + 添加实体 + + 添加内容 + 执行成功返回真 + + + + 修改实体 + + 更新主键 + 修改内容 + 执行成功返回真 + + + + 删除实体 + + 删除主键 + 执行成功返回真 + + + + 导出信息 + + 导出查询条件 + 执行成功返回真 + + + + 导入信息 + + 导入文件流 + 执行成功返回真 + + + + 生产线超时提醒 + + 生产线编号列表 + 生产线超时情况 + R100单据管理应用服务实现 @@ -1501,6 +1726,89 @@ 导入文件流 执行成功返回真 + + + M110重复报文应用服务实现 + + + + + 仓储 + + + + + 日志 + + + + + Dapper仓储 + + + + + BLOB存储 + + + + + 错误信息前缀 + + + + + 构造函数 + + + + + 根据筛选条件获取实体列表 + + + + + 根据筛选条件获取分页实体列表 + + 输入查询条件 + 输入分页条件 + 返回符合条件的排序分页列表 + + + + 按主键获取唯一实体 + + 主键 + 实体信息 + + + + 添加实体 + + 添加内容 + 执行成功返回真 + + + + 删除实体 + + 删除主键 + 执行成功返回真 + + + + 导出信息 + + 导出查询条件 + 执行成功返回真 + + + + 导入信息 + + 导入文件流 + 执行成功返回真 + R100重复报文应用服务实现 diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110.cs index 29695c0..cffdead 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110.cs @@ -1,4 +1,5 @@ -using System; +using JetBrains.Annotations; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -16,36 +17,34 @@ namespace WY.NewJit.MsgCheck /// /// 报文接收ID,对应报文接收表主键 /// - public virtual Guid MessageFileReceiveID { get; protected set; } + public virtual Guid? MessageFileReceiveID { get; protected set; } /// /// 流水号# /// - public virtual int? SerialNum { get; protected set; } + public virtual int? SerialNum { get; set; } /// /// 大众顺序号 /// - public virtual int? HostSN { get; protected set; } + public virtual int? HostSN { get; set; } /// - /// KNR + /// KNR订单号 /// - public virtual string KNR { get; protected set; } + public virtual string KNR { get; set; } /// /// 底牌号# /// - public virtual string VIN { get; protected set; } - + public virtual string VIN { get; set; } /// /// 总成ID /// - public virtual Guid? AssemblyID { get; protected set; } - + public virtual Guid? AssemblyID { get; set; } /// /// 上线时间 /// - public virtual DateTime? OnlineTime { get; protected set; } + public virtual DateTime? OnlineTime { get; set; } /// /// 车型代码(取通用字典) @@ -78,21 +77,79 @@ namespace WY.NewJit.MsgCheck public virtual string Description { get; set; } /// - /// 总装单据包含的零件列表 + /// 打印时间 + /// + public virtual DateTime? PrintTime { get; set; } + + /// + /// 打印单号【派格版本:不为空时表示已打印柱护板】 + /// + public virtual string PrintBillNum { get; set; } + + /// + /// 打印时间2【派格版本:柱护板打印时间】 + /// + public virtual DateTime? PrintTime2 { get; set; } + + + /// + /// 字符类型流水号 + /// + public virtual string SerialNumStr { get; set; } + + /// + /// 涂装单据包含的零件列表 /// public virtual List BillM110Parts { get; protected set; } - protected BillM110() + + /// + /// 手工操作类型:0 none,1 手工添加,2 手工修改 + /// + public virtual ManualOperationTypeEnum OperationType { get; protected set; } + + /// + /// 手工操作员 + /// + public virtual string Operator { get; protected set; } + + /// + /// 手工操作日期 + /// + public virtual DateTime? OperationTime { get; protected set; } + + /// + /// 不可打印 + /// + public virtual bool? CanNotPrint { get; set; } = false; + + /// + /// 为1时需要补打:正常打印门板时,将解析的单据设置为1 + /// + public virtual int? NeedReplenishPrint { get; set; } + + public virtual int? HostSN2 { get; set; } + + /// + /// 通过零件切换实现总成匹配时,设置为真 + /// + public virtual bool? IsPartSwitch { get; set; } + + + public BillM110() { //此构造函数是提供给ORM用来从数据库中获取实体. //无需初始化子集合 //因为它会被来自数据库的值覆盖.可能不适用于私有构造函数. } - public BillM110(Guid id, Guid messageFileReceiveID, int? serialNum, int? hostSN, string kNR, string vIN, Guid? assemblyID, DateTime? onlineTime, string vehicleModelCode, string version, DateTime? receiveTime, BillStatusEnum billStatus) + + + public BillM110(Guid id, Guid? messageFileReceiveID, int? serialNum, string serialNumStr, int? hostSN, string kNR, string vIN, Guid? assemblyID, DateTime? onlineTime, string vehicleModelCode, string version, DateTime? receiveTime, BillStatusEnum billStatus, ManualOperationTypeEnum operationType = ManualOperationTypeEnum.None, string @operator = null, DateTime? operationTime = null) : base(id) { MessageFileReceiveID = messageFileReceiveID; SerialNum = serialNum; + SerialNumStr = serialNumStr; HostSN = hostSN; KNR = kNR; VIN = vIN; @@ -103,7 +160,109 @@ namespace WY.NewJit.MsgCheck ReceiveTime = receiveTime; BillStatus = billStatus; BillM110Parts = new List(); + OperationType = operationType; + Operator = @operator; + OperationTime = operationTime; + } + + public virtual void AddChildObj(Guid id, [NotNull] string partCode, double? partNum, string description = null) + { + BillM110Parts.Add(new BillM110Part(id, partCode, partNum, description)); + } + + public virtual void AddChildObj(Guid id, [NotNull] string partCode, double? partNum, string description, string partType, string partType2, string partType3) + { + BillM110Parts.Add(new BillM110Part(id, partCode, partNum, description, partType, partType2, partType3)); } + + + public virtual void SetSerialNum(int serialNum) + { + this.SerialNum = serialNum; + } + + public virtual void SetAssemblyID(Guid? assemblyId) + { + this.AssemblyID = assemblyId; + } + + public virtual void SetBillStatus(BillStatusEnum billStatus) + { + this.BillStatus = billStatus; + } + + public virtual void SetZHBBillStatus(ZHBBillStatusEnum zhbBillStatus) + { + if (zhbBillStatus == ZHBBillStatusEnum.Print) + { + this.PrintBillNum = "柱护板已打印"; + } + else if (zhbBillStatus == ZHBBillStatusEnum.NotPrint) + { + this.PrintBillNum = null; + } + else + { + this.PrintBillNum = null; + } + } + + public virtual void SetId(Guid id) + { + this.Id = id; + } + public virtual void SetVehicleModelCode(string vehicleModelCode) + { + this.VehicleModelCode = vehicleModelCode; + } + + public virtual void SetProductLine(string productLine) + { + this.ProductLine = productLine; + } + + public virtual void SetSerialNumStr(string snStr) + { + this.SerialNumStr = snStr; + } + + //public virtual void SetSerialNumStr(DateTime? onlineTime, int? hostSN) + //{ + // if (hostSN == null) + // { + // throw new Exception("SetSerialNumStr大众顺序号不能为空:" + this.VIN); + // } + // if (onlineTime == null) + // { + // throw new Exception("SetSerialNumStr上线时间不能为空:" + this.VIN); + // } + // this.SerialNumStr = ((DateTime)onlineTime).ToString("yyyyMMddHHmm") + hostSN.ToString().PadLeft(5, '0'); + //} + + + public static BillM110 Clone(BillM110 soureObj) + { + BillM110 targetObj = new BillM110(); + targetObj.MessageFileReceiveID = soureObj.MessageFileReceiveID; + targetObj.SerialNum = soureObj.SerialNum; + targetObj.SerialNumStr = soureObj.SerialNumStr; + targetObj.HostSN = soureObj.HostSN; + targetObj.KNR = soureObj.KNR; + targetObj.VIN = soureObj.VIN; + targetObj.AssemblyID = soureObj.AssemblyID; + targetObj.OnlineTime = soureObj.OnlineTime; + targetObj.VehicleModelCode = soureObj.VehicleModelCode; + targetObj.Version = soureObj.Version; + targetObj.ReceiveTime = soureObj.ReceiveTime; + targetObj.BillStatus = soureObj.BillStatus; + targetObj.BillM110Parts = new List(); + targetObj.OperationType = soureObj.OperationType; + targetObj.Operator = soureObj.Operator; + targetObj.OperationTime = soureObj.OperationTime; + targetObj.CreationTime = soureObj.CreationTime; + return targetObj; + } + } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110Part.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110Part.cs index cd1dc45..99c9847 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110Part.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM110Part.cs @@ -1,4 +1,5 @@ -using System; +using JetBrains.Annotations; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -9,7 +10,7 @@ using Volo.Abp.Domain.Entities.Auditing; namespace WY.NewJit.MsgCheck { /// - /// 总装单据和零件关系表 + /// 涂装单据和零件关系表 /// public class BillM110Part : AuditedEntity { @@ -26,7 +27,24 @@ namespace WY.NewJit.MsgCheck /// /// 描述 /// - public virtual string Description { get; protected set; } + public virtual string Description { get; set; } + + /// + /// 零件类型:产线 + /// + public virtual string PartType { get; set; } + + /// + /// 零件类型:分组 + /// + public virtual string PartType2 { get; set; } + + /// + /// 零件类型:零件大类 + /// + public virtual string PartType3 { get; set; } + + protected BillM110Part() { //此构造函数是提供给ORM用来从数据库中获取实体. @@ -34,13 +52,36 @@ namespace WY.NewJit.MsgCheck //因为它会被来自数据库的值覆盖.可能不适用于私有构造函数. } - public BillM110Part(Guid id, string partCode, double? partNum, string description) + public BillM110Part(Guid id) + : base(id) + { + } + + + public BillM110Part(Guid id, [NotNull] string partCode, double? partNum, string description = null) : base(id) { PartCode = partCode; PartNum = partNum; Description = description; } + + public BillM110Part(Guid id, [NotNull] string partCode, double? partNum, string description, string partType, string partType2, string partType3) + : base(id) + { + PartCode = partCode; + PartNum = partNum; + Description = description; + this.PartType = partType; + this.PartType2 = partType2; + this.PartType3 = partType3; + } + + + public virtual void SetId(Guid id) + { + this.Id = id; + } } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110.cs index f87ab10..d491aab 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110.cs @@ -9,14 +9,19 @@ using Volo.Abp.Domain.Entities.Auditing; namespace WY.NewJit.MsgCheck { /// - /// 总装重复单据 + /// 涂装重复单据 /// public class RepeatM110 : AuditedAggregateRoot { /// /// 报文接收ID,对应报文接收表主键 /// - public virtual Guid MessageFileReceiveID { get; protected set; } + public virtual Guid? MessageFileReceiveID { get; protected set; } + + /// + /// 流水号# + /// + public virtual int? SerialNum { get; protected set; } /// /// 大众顺序号 @@ -31,7 +36,10 @@ namespace WY.NewJit.MsgCheck /// 底牌号# /// public virtual string VIN { get; protected set; } - + /// + /// 总成ID + /// + public virtual Guid? AssemblyID { get; protected set; } /// /// 上线时间 /// @@ -66,9 +74,10 @@ namespace WY.NewJit.MsgCheck public virtual string Description { get; set; } /// - /// 总装重复单据包含的零件列表 + /// 涂装重复单据包含的零件列表 /// - public List M110RepeatParts { get; protected set; } + public virtual List M110RepeatParts { get; protected set; } + protected RepeatM110() { //此构造函数是提供给ORM用来从数据库中获取实体. @@ -76,18 +85,37 @@ namespace WY.NewJit.MsgCheck //因为它会被来自数据库的值覆盖.可能不适用于私有构造函数. } - public RepeatM110(Guid id, Guid messageFileReceiveID, int? hostSN, string kNR, string vIN, DateTime? onlineTime, DateTime? receiveTime, string vehicleModelCode, string version) + protected RepeatM110(Guid id) + : base(id) + { } + + public RepeatM110(Guid id, Guid? messageFileReceiveID, int? serialNum, int? hostSN, string kNR, string vIN, Guid? assemblyID, DateTime? onlineTime, DateTime? receiveTime, string vehicleModelCode, string productLine, string version, BillStatusEnum billStatus) : base(id) { MessageFileReceiveID = messageFileReceiveID; + SerialNum = serialNum; HostSN = hostSN; KNR = kNR; VIN = vIN; + AssemblyID = assemblyID; OnlineTime = onlineTime; ReceiveTime = receiveTime; VehicleModelCode = vehicleModelCode; + ProductLine = productLine; Version = version; + BillStatus = billStatus; M110RepeatParts = new List(); } + + public virtual void SetSerialNum(int serialNum) + { + this.SerialNum = serialNum; + } + + public virtual void AddChildObj(Guid id, string partCode, double? partNum, string description) + { + M110RepeatParts.Add(new RepeatM110Part(id, partCode, partNum, description)); + } + } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110Part.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110Part.cs index 8f6ebe8..3dec921 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110Part.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/RepeatM110Part.cs @@ -8,7 +8,7 @@ using Volo.Abp.Domain.Entities.Auditing; namespace WY.NewJit.MsgCheck { /// - /// 总装重复单据和零件关系表 + /// 涂装重复单据和零件关系表 /// public class RepeatM110Part : AuditedEntity { @@ -26,6 +26,7 @@ namespace WY.NewJit.MsgCheck /// 描述 /// public virtual string Description { get; protected set; } + protected RepeatM110Part() { //此构造函数是提供给ORM用来从数据库中获取实体. @@ -33,6 +34,10 @@ namespace WY.NewJit.MsgCheck //因为它会被来自数据库的值覆盖.可能不适用于私有构造函数. } + public RepeatM110Part(Guid id) + : base(id) + { } + public RepeatM110Part(Guid id, string partCode, double? partNum, string description) : base(id) { @@ -40,5 +45,10 @@ namespace WY.NewJit.MsgCheck PartNum = partNum; Description = description; } + + public virtual void SetId(Guid id) + { + this.Id = id; + } } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.EntityFrameworkCore/EntityFrameworkCore/NewJitDbContextModelCreatingExtensions.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.EntityFrameworkCore/EntityFrameworkCore/NewJitDbContextModelCreatingExtensions.cs index 3eac8b3..ca9de8f 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.EntityFrameworkCore/EntityFrameworkCore/NewJitDbContextModelCreatingExtensions.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.EntityFrameworkCore/EntityFrameworkCore/NewJitDbContextModelCreatingExtensions.cs @@ -212,21 +212,43 @@ namespace WY.NewJit.EntityFrameworkCore }); + #region M110 builder.Entity(b => { b.ToTable(NewJitConsts.DbTablePrefix + nameof(BillM110)); //将Book实体映射到数据库表XXXBooks b.ConfigureByConvention();//配置/映射继承的属性,应始终对你所有的实体使用它 + b.Property(itm => itm.KNR).HasColumnType("varchar").HasMaxLength(50); + //b.HasIndex(itm => itm.KNR).HasDatabaseName("IX_BillM110_KNR"); + b.Property(itm => itm.VIN).HasColumnType("varchar").HasMaxLength(50); - b.HasIndex(itm => itm.VIN).HasDatabaseName("IX_BillM110_VIN3"); + //b.HasIndex(itm => itm.VIN).HasDatabaseName("IX_BillM110_VIN2"); + + b.Property(itm => itm.ProductLine).HasColumnType("varchar").HasMaxLength(50); + //b.HasIndex(itm => itm.ProductLine).HasDatabaseName("IX_BillM110_ProductLine2"); + + //b.HasIndex(itm => itm.SerialNum).HasDatabaseName("IX_BillM110_SerialNum"); + b.Property(itm => itm.SerialNumStr).HasColumnType("varchar").HasMaxLength(50); + //b.HasIndex(itm => itm.SerialNumStr).HasDatabaseName("IX_BillM110_SerialNumStr2"); + + //b.HasIndex(itm => itm.HostSN).HasDatabaseName("IX_BillM110_HostSN2"); + + b.Property(itm => itm.Version).HasColumnType("varchar").HasMaxLength(50); + b.Property(itm => itm.VehicleModelCode).HasColumnType("varchar").HasMaxLength(50); }); builder.Entity(b => { b.ToTable(NewJitConsts.DbTablePrefix + nameof(BillM110Part)); //将Book实体映射到数据库表XXXBooks b.ConfigureByConvention();//配置/映射继承的属性,应始终对你所有的实体使用它 b.Property(itm => itm.PartCode).HasColumnType("varchar").HasMaxLength(50); - b.HasIndex(itm => itm.PartCode).HasDatabaseName("IX_BillM110Part_PartCode3"); + //b.HasIndex(itm => itm.PartCode).HasDatabaseName("IX_BillM110Part_PartCode2"); + + b.Property(itm => itm.PartType).HasColumnType("varchar").HasMaxLength(50); + b.Property(itm => itm.PartType2).HasColumnType("varchar").HasMaxLength(50); + b.Property(itm => itm.PartType3).HasColumnType("varchar").HasMaxLength(50); }); + #endregion + builder.Entity(b => { b.ToTable(NewJitConsts.DbTablePrefix + nameof(BillR100)); //将Book实体映射到数据库表XXXBooks @@ -286,16 +308,39 @@ namespace WY.NewJit.EntityFrameworkCore b.HasIndex(itm => itm.PartCode).HasDatabaseName("IX_RepeatM100Part_PartCode"); }); + + #region RepeatM110 builder.Entity(b => { b.ToTable(NewJitConsts.DbTablePrefix + nameof(RepeatM110)); //将Book实体映射到数据库表XXXBooks b.ConfigureByConvention();//配置/映射继承的属性,应始终对你所有的实体使用它 + + b.Property(itm => itm.KNR).HasColumnType("varchar").HasMaxLength(50); + //b.HasIndex(itm => itm.KNR).HasDatabaseName("IX_RepeatM110_KNR"); + + b.Property(itm => itm.VIN).HasColumnType("varchar").HasMaxLength(50); + //b.HasIndex(itm => itm.VIN).HasDatabaseName("IX_RepeatM110_VIN"); + + b.Property(itm => itm.ProductLine).HasColumnType("varchar").HasMaxLength(50); + //b.HasIndex(itm => itm.ProductLine).HasDatabaseName("IX_RepeatM110_ProductLine"); + + //b.HasIndex(itm => itm.HostSN).HasDatabaseName("IX_RepeatM110_HostSN"); + + b.Property(itm => itm.Version).HasColumnType("varchar").HasMaxLength(50); + b.Property(itm => itm.VehicleModelCode).HasColumnType("varchar").HasMaxLength(50); + }); builder.Entity(b => { b.ToTable(NewJitConsts.DbTablePrefix + nameof(RepeatM110Part)); //将Book实体映射到数据库表XXXBooks b.ConfigureByConvention();//配置/映射继承的属性,应始终对你所有的实体使用它 + + b.Property(itm => itm.PartCode).HasColumnType("varchar").HasMaxLength(50); + //b.HasIndex(itm => itm.PartCode).HasDatabaseName("IX_RepeatM110Part_PartCode"); + }); + #endregion + builder.Entity(b => { b.ToTable(NewJitConsts.DbTablePrefix + nameof(RepeatR100)); //将Book实体映射到数据库表XXXBooks diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs index da04b39..dbb2065 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs @@ -864,8 +864,8 @@ namespace WY.NewJit.Job.ConsoleApp.Messages throw new Exception(errorMsg); } //单据配置校验:R100、M100 - string billType = locItems[2]; - if (billType != "R100" && billType != "M100") + string billType = locItems[2]?.Trim(); + if (billType != "R100" && billType != "M100" && billType != "M110") { ret = $"报文类别错误:{billType}-{fileName}"; }