diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPrintInputDto.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPrintInputDto.cs
index 52e931e..8db7403 100644
--- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPrintInputDto.cs
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/MenBanReports/MenBanPrintInputDto.cs
@@ -9,7 +9,7 @@ namespace WY.NewJit.Extends
{
///
- /// 打印类型:提供初次打印、重新打印、针对重新解析后单据的补打功能
+ /// 打印类型:0 顺序打印 1 补账打印 3 重新打印
///
public PrintTypeEnum PrintType { get; set; }
@@ -30,14 +30,14 @@ namespace WY.NewJit.Extends
#region 重新打印、补打时使用
///
- /// 装箱单主表ID列表,报废时传入一个,重打时可传入多个
+ /// 重新打印时使用。装箱单主表ID列表,报废时传入一个,重打时可传入多个
///
public virtual List ReportIdList { get; set; }
///
/// 补打时使用
///
- public virtual List M100IdList { get; set; }
+ public virtual List WaitPrintIdList { get; set; }
#endregion
}
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/ZhuHuBanReports/ZhuHuBanPrintInputDto.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/ZhuHuBanReports/ZhuHuBanPrintInputDto.cs
index 1d9c4c4..bb2e0e3 100644
--- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/ZhuHuBanReports/ZhuHuBanPrintInputDto.cs
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/Extends/ZhuHuBanReports/ZhuHuBanPrintInputDto.cs
@@ -42,8 +42,11 @@ namespace WY.NewJit.Extends
///
/// 补打时使用
///
- public virtual List M100IdList { get; set; }
+ public virtual List WaitPrintIdList { get; set; }
+ ///
+ /// 1 门板 2 其它柱护板 3 柱护板
+ ///
public virtual string GroupName { get; set; }
}
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM100s/Interfaces/IBillM100AppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM100s/Interfaces/IBillM100AppService.cs
index a4b691f..e879029 100644
--- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM100s/Interfaces/IBillM100AppService.cs
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/BillM100s/Interfaces/IBillM100AppService.cs
@@ -62,40 +62,34 @@ namespace WY.NewJit.MsgCheck
/// 执行成功返回真
Task ImportAsync(Byte[] input);
- ///
- /// 根据生产线获取正常打印单据的起始大众顺序号
- ///
- /// 生产线
- /// 起始大众顺序号
- Task> GetPrintStartHostSN2(string productLine, string isZhuHuBan,string GroupName = null);
///
/// 打印前检查门板大众顺序号是否断号
///
///
/// 断号时Item不为空
- Task> CheckMBHostSNBreakNum(MenBanPrintInputDto input);
+ //Task> CheckMBHostSNBreakNum(MenBanPrintInputDto input);
///
/// 打印前检查柱护板大众顺序号是否断号
///
///
/// 断号时Item不为空
- Task> CheckZHBHostSNBreakNum(ZhuHuBanPrintInputDto input);
+ //Task> CheckZHBHostSNBreakNum(ZhuHuBanPrintInputDto input);
///
/// 打印门板装箱单
///
///
/// 执行成功返回真
- Task> PrintMenBanPackingList(MenBanPrintInputDto input);
+ //Task> PrintMenBanPackingList(MenBanPrintInputDto input);
///
/// 打印柱护板装箱单
///
///
/// 执行成功返回真
- Task> PrintZhuHuBanPackingList(ZhuHuBanPrintInputDto input);
+ //Task> PrintZhuHuBanPackingList(ZhuHuBanPrintInputDto input);
#endregion
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Dtos/QueryWaitPrintDto.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Dtos/QueryWaitPrintDto.cs
new file mode 100644
index 0000000..5dc32a9
--- /dev/null
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Dtos/QueryWaitPrintDto.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+using Volo.Abp.Application.Dtos;
+using WY.NewJit.Common;
+using WY.NewJit.MsgCheck;
+
+namespace WY.NewJit.PrintTable.Dtos
+{
+ [Serializable]
+ public class QueryWaitPrintDto : 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 DateTime? ReceiveTimeBegin { get; set; }
+
+ ///
+ /// 接收时间止
+ ///
+ public DateTime? ReceiveTimeEnd { get; set; }
+
+ ///
+ /// 单据状态(0 空;1 未匹配;2 未打印;3 已打印 4 断号)
+ ///
+ public BillStatusEnum? BillStatus { get; set; }
+
+ ///
+ /// 打印类型: 1 顺序打印 2 补账打印
+ ///
+ public PrintTypeEnum? PrintType { get; set; }
+
+ ///
+ /// 业务类型:1 门板 2 其它柱护板 3 柱护板
+ ///
+ public BusinessTypeEnum? BusinessType { get; set; }
+ }
+}
+
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Dtos/WaitPrintDto.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Dtos/WaitPrintDto.cs
index d301970..2639c20 100644
--- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Dtos/WaitPrintDto.cs
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Dtos/WaitPrintDto.cs
@@ -138,5 +138,19 @@ namespace WY.NewJit.PrintTable
[ExporterHeader(DisplayName = "最后修改人")]
[ImporterHeader(Name = "最后修改人")]
public Guid? LastModifierId { get; set; }
+
+ ///
+ /// R100上线时间
+ ///
+ [ExporterHeader(DisplayName = "R100上线时间")]
+ [ImporterHeader(Name = "R100上线时间")]
+ public DateTime R100OnlineTime { get; set; }
+
+ ///
+ /// R100接收时间
+ ///
+ [ExporterHeader(DisplayName = "R100接收时间")]
+ [ImporterHeader(Name = "R100接收时间")]
+ public DateTime? R100ReceiveTime { get; set; }
}
}
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Interfaces/IAlreadyPrintAppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Interfaces/IAlreadyPrintAppService.cs
new file mode 100644
index 0000000..e457e76
--- /dev/null
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Interfaces/IAlreadyPrintAppService.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WY.NewJit.PrintTable
+{
+ public interface IAlreadyPrintAppService
+ {
+ }
+}
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Interfaces/IWaitPrintAppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Interfaces/IWaitPrintAppService.cs
new file mode 100644
index 0000000..f96ddbe
--- /dev/null
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/PrintTable/Interfaces/IWaitPrintAppService.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WY.NewJit.PrintTable
+{
+ public interface IWaitPrintAppService
+ {
+ ///
+ /// 根据生产线获取正常打印单据的起始大众顺序号
+ ///
+ /// 生产线
+ /// 起始大众顺序号
+ Task> GetPrintStartHostSN2(string productLine, string isZhuHuBan, string GroupName = null);
+
+ }
+}
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.csproj b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.csproj
index 96740e1..1525bc8 100644
--- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.csproj
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.csproj
@@ -31,8 +31,4 @@
-
-
-
-
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml
index e42241c..8306222 100644
--- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml
@@ -186,7 +186,7 @@
- 打印类型:提供初次打印、重新打印、针对重新解析后单据的补打功能
+ 打印类型:0 顺序打印 1 补账打印 3 重新打印
@@ -206,10 +206,10 @@
- 装箱单主表ID列表,报废时传入一个,重打时可传入多个
+ 重新打印时使用。装箱单主表ID列表,报废时传入一个,重打时可传入多个
-
+
补打时使用
@@ -558,11 +558,16 @@
数据结果类型 1 全部数据, 2 选中数据(仅重新打印时使用)
-
+
补打时使用
+
+
+ 1 门板 2 其它柱护板 3 柱护板
+
+
柱护板主实体列表 A上C上
@@ -1910,41 +1915,6 @@
导入文件流
执行成功返回真
-
-
- 根据生产线获取正常打印单据的起始大众顺序号
-
- 生产线
- 起始大众顺序号
-
-
-
- 打印前检查门板大众顺序号是否断号
-
-
- 断号时Item不为空
-
-
-
- 打印前检查柱护板大众顺序号是否断号
-
-
- 断号时Item不为空
-
-
-
- 打印门板装箱单
-
-
- 执行成功返回真
-
-
-
- 打印柱护板装箱单
-
-
- 执行成功返回真
-
生产线超时提醒
@@ -3522,6 +3492,86 @@
最后修改人
+
+
+ 大众顺序号起
+
+
+
+
+ 大众顺序号止
+
+
+
+
+ KNR起
+
+
+
+
+ KNR止
+
+
+
+
+ 底牌号起
+
+
+
+
+ 底牌号止
+
+
+
+
+ 总成ID
+
+
+
+
+ 上线时间起
+
+
+
+
+ 上线时间止
+
+
+
+
+ 车型代码(取通用字典)
+
+
+
+
+ 生产线(派格按生产线分类)
+
+
+
+
+ 接收时间起
+
+
+
+
+ 接收时间止
+
+
+
+
+ 单据状态(0 空;1 未匹配;2 未打印;3 已打印 4 断号)
+
+
+
+
+ 打印类型: 1 顺序打印 2 补账打印
+
+
+
+
+ 业务类型:1 门板 2 其它柱护板 3 柱护板
+
+
零件查询结果DTO
@@ -3617,5 +3667,22 @@
最后修改人
+
+
+ R100上线时间
+
+
+
+
+ R100接收时间
+
+
+
+
+ 根据生产线获取正常打印单据的起始大众顺序号
+
+ 生产线
+ 起始大众顺序号
+
diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs
index 5bf0756..a8e7dbf 100644
--- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs
+++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs
@@ -44,9 +44,8 @@ namespace WY.NewJit.MsgCheck
private readonly IRepository _billM100PartRepository;
- private readonly IRepository _printTemplateConfigurationRepository;
- private readonly IRepository _zHBPrintStatusRepository;
+ //private readonly IRepository _zHBPrintStatusRepository;
///
/// 日志
///
@@ -62,20 +61,12 @@ namespace WY.NewJit.MsgCheck
///
private readonly IBlobContainer _blobContainer;
- ///
- /// 门板装箱单仓储
- ///
- private readonly IRepository _menBanPackingListRepository;
///
/// 门板装箱单仓储明细
///
private readonly IRepository _menBanPackingRecRepository;
- ///
- /// 柱护板装箱单仓储
- ///
- private readonly IRepository _zhuHuBanPackingListRepository;
///
/// 柱护板装箱单仓储明细
@@ -83,10 +74,6 @@ namespace WY.NewJit.MsgCheck
private readonly IRepository _zhuHuBanPackingRecRepository;
- ///
- /// ERP总成仓储
- ///
- private readonly IRepository _assemblyCfgErpRepository;
///
/// 整车总成配置仓库
@@ -118,7 +105,7 @@ namespace WY.NewJit.MsgCheck
/// 序列领域服务
///
private readonly SequenceDomainService _sequenceDomainService;
- private readonly BillNumberRecordDomainService _aaa;
+
///
/// 配置
///
@@ -126,8 +113,6 @@ namespace WY.NewJit.MsgCheck
private readonly IUnitOfWorkManager _unitOfWorkManager;
- private readonly IRepository _tbBillRepository;
- private readonly IRepository _tsSortDetailRepository;
private readonly IRepository _tbBillHisRepository;
private readonly IRepository _tsSortDetailHisRepository;
@@ -142,8 +127,6 @@ namespace WY.NewJit.MsgCheck
}
}
- private const string _providerCode = "0709FAW-VW7XH";
-
private const int _hostSNMaxVal = 1999;
///
@@ -162,9 +145,6 @@ namespace WY.NewJit.MsgCheck
ILogger logger,
NewJitDapperRepository newJitDapperRepository,
IBlobContainer blobContainer,
- IRepository menBanPackingListRepository,
- IRepository zhuHuBanPackingListRepository,
- IRepository assemblyCfgErpRepository,
IRepository assemblyCfgVehicleRepository,
IRepository partCfgRepository,
IRepository materialExtRepository,
@@ -175,25 +155,19 @@ namespace WY.NewJit.MsgCheck
SequenceDomainService sequenceDomainService,
Microsoft.Extensions.Configuration.IConfiguration configuration,
IUnitOfWorkManager unitOfWorkManager,
- IRepository tbBillRepository,
- IRepository tsSortDetailRepository,
IRepository tbBillHisRepository,
- IRepository tsSortDetailHisRepository,
- IRepository printTemplateConfigurationRepository,
- IRepository zHBPrintStatusRepository,
- BillNumberRecordDomainService aaa
+ IRepository tsSortDetailHisRepository
+ //IRepository printTemplateConfigurationRepository,
+ //IRepository zHBPrintStatusRepository
+
)
{
- _aaa = aaa;
_billM100Repository = BillM100Repository;
_billM100PartRepository = BillM100PartRepository;
_logger = logger;
_newJitDapperRepository = newJitDapperRepository;
_blobContainer = blobContainer;
- _menBanPackingListRepository = menBanPackingListRepository;
- _zhuHuBanPackingListRepository = zhuHuBanPackingListRepository;
- _assemblyCfgErpRepository = assemblyCfgErpRepository;
_assemblyCfgVehicleRepository = assemblyCfgVehicleRepository;
_partCfgRepository = partCfgRepository;
_materialExtRepository = materialExtRepository;
@@ -204,38 +178,14 @@ namespace WY.NewJit.MsgCheck
_sequenceDomainService = sequenceDomainService;
_configuration = configuration;
_unitOfWorkManager = unitOfWorkManager;
- _tbBillRepository = tbBillRepository;
- _tsSortDetailRepository = tsSortDetailRepository;
_tbBillHisRepository = tbBillHisRepository;
_tsSortDetailHisRepository = tsSortDetailHisRepository;
- _printTemplateConfigurationRepository = printTemplateConfigurationRepository;
- _zHBPrintStatusRepository = zHBPrintStatusRepository;
+ //_printTemplateConfigurationRepository = printTemplateConfigurationRepository;
+ //_zHBPrintStatusRepository = zHBPrintStatusRepository;
}
#endregion
#region 私有方法
- [UnitOfWork]
- [HttpPost]
- [Route("get-billnumber")]
- public async Task GetBillNumber(int number, string productLine,bool t)
- {
- if (t)
- {
- _aaa.CleanBillNumberRecordCache();
- }
-
- var res=await _aaa.GetBillNumber(number, productLine);
- return res;
- }
- [UnitOfWork]
- [HttpPost]
- [Route("get-billnumberrec")]
- public async Task GetBillNumberRec(bool isupdate)
- {
-
- var ret = await _aaa.GetOrUpDateBillNumberRecordCache(isupdate);
- return ret.Status;
- }
///
/// 查询柱护板
///
@@ -603,29 +553,6 @@ select * from
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
@@ -708,7 +635,7 @@ select * from
return ret;
}
}
- else if (input.PrintType == PrintTypeEnum.补打)
+ else if (input.PrintType == PrintTypeEnum.补账打印)
{
//string beginVin = input.BeginVin.TryToRight(6);
//string endVin = input.EndVin.TryToRight(6);
@@ -732,7 +659,7 @@ select * from
}
# region 断号处理
- if (isFillBreakNum == true && billLst.Count > 1 && input.PrintType != PrintTypeEnum.补打)
+ if (isFillBreakNum == true && billLst.Count > 1 && input.PrintType != PrintTypeEnum.补账打印)
{
billLst = DoBreakNumOperation(input.BeginHostSN, input.EndHostSN, billLst);
}
@@ -871,4313 +798,2401 @@ select * from
///
/// 加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 List DoMBPrint(MenBanPrintInputDto input, int pageIdx, ref double maxBillNum, double maxSN, DateTime printTime, List billLst, string rightOrLeft)
- {
- const int _colNumberPerPage = 12;
- List retLst = new List();
-
- //取当前页内容
- List curPageLst = billLst.Skip(pageIdx * _colNumberPerPage).Take(_colNumberPerPage).ToList();
- //取车型 C8,Q5
- var vmLst = curPageLst.Select(itm => itm.VehicleModelCode).Distinct().ToList();
- string vmStr = "";
- foreach (var item in vmLst)
- {
- vmStr += item + ",";
- }
- if (vmStr.Length >0)
- {
- vmStr = vmStr.Substring(0, vmStr.Length - 1);
- }
-
- //填充门板装箱单主实体
- MenBanPackingList mbObj = new MenBanPackingList();
- mbObj.SetId(GuidGenerator.Create());
-
- long maxBillNum2 = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号);
- mbObj.BillNum = GetBillNum(maxBillNum2);
- mbObj.BillSerialNum = maxSN.ToString().PadLeft(2, '0');
-
-
- mbObj.BillLocation = rightOrLeft; //右或左
- mbObj.ProviderCode = _providerCode; //供应商厂家代码
- mbObj.PartType = vmStr + " DP"; //零件类型
- mbObj.Capacity = curPageLst.Count(itm => itm.BillStatus == BillStatusEnum.Match || itm.BillStatus == BillStatusEnum.Publish).ToString(); //器具容量
- mbObj.PrintDate = printTime; //打印日期
- mbObj.PrintType = input.PrintType;
- mbObj.ProductLine = input.ProductLine;
-
- var tempLst = curPageLst.Where(itm => string.IsNullOrEmpty(itm.VIN) == false).OrderBy(itm => itm.OnlineTime).ThenBy(itm => itm.HostSN).ToList();
- if (tempLst.Count > 0)
- {
- mbObj.BeginVin = tempLst[0].VIN;
- mbObj.EndVin = tempLst[tempLst.Count - 1].VIN;
- mbObj.BeginHostSN = tempLst[0].HostSN.ToString();
- mbObj.EndHostSN = tempLst[tempLst.Count - 1].HostSN.ToString();
- }
- mbObj.MinOnlineTime = tempLst.Min(itm => itm.OnlineTime); //本单据最早的上线时间
-
- int posNum = 0;
- string promMsg; //报表数据异常提示信息
- foreach (BillM100 billObj in curPageLst)
- {
- posNum++;
- promMsg = "";
- //取物料信息
- MaterialExt leftObj = null;
- MaterialExt rightObj = null;
- if (billObj.AssemblyID != null)
- {
- //取单据包含的ERP总成列表
- List erpAssemblyLst = GetErpAssemblyListByBill((Guid)billObj.AssemblyID);
- List erpCodeLst = erpAssemblyLst.Select(itm => itm.ErpAssemblyCode).ToList();
- //根据ERP总成编码取对应的物料扩展信息
- List materialExtLst = _materialExtRepository.Where(itm => erpCodeLst.Contains(itm.RelationKey)).ToList();
- if (erpCodeLst.Count != 4)
- {
- promMsg += $"*总成数量是{erpCodeLst.Count}*";
- }
- if (erpCodeLst.Count == 4 && materialExtLst.Count == 0)
- {
- promMsg += $"*物料表没数据*";
- }
-
- //车型C8的第一二页分为左后, 右前,第三四页分为右后、左前;其它车型 第一二页分为左后、左前,第三四页分为右后、右前
- if (curPageLst[0].VehicleModelCode == "C8")
- {
- //C8 分为左前、右后 一组 右前、左后 一组,以前门为主,前门是右, 单子是右
- if (rightOrLeft == "右")
- {
- rightObj = materialExtLst.FirstOrDefault(itm => itm.MaterialDescription.Contains("右前"));
- leftObj = materialExtLst.FirstOrDefault(itm => itm.MaterialDescription.Contains("左后"));
- }
- else //左
- {
- rightObj = materialExtLst.FirstOrDefault(itm => itm.MaterialDescription.Contains("左前"));
- leftObj = materialExtLst.FirstOrDefault(itm => itm.MaterialDescription.Contains("右后"));
- }
- }
- else
- {
- leftObj = materialExtLst.FirstOrDefault(itm => itm.MaterialDescription.Contains(rightOrLeft + "后"));
- rightObj = materialExtLst.FirstOrDefault(itm => itm.MaterialDescription.Contains(rightOrLeft + "前"));
- }
- }
-
- //填充门板装箱单明细
- MenBanPackingRec mbRec = new MenBanPackingRec();
- mbRec.SetId(GuidGenerator.Create());
- mbRec.M100BillId = billObj.Id;
- mbRec.KNR = billObj.KNR; //KNR订单号
- mbRec.VIN = billObj.VIN; //底牌号
- mbRec.HostSN = billObj.HostSN.ToString(); //大众顺序号
- mbRec.TopBoxPositionNum = posNum.ToString().PadLeft(2, '0'); //上箱位号
- if (leftObj != null) //右后
- {
- mbRec.VehicleModel_DoorPlankCode = leftObj.MaterialMemo; //车型门板代码
- mbRec.TopSAPMaterialNum = leftObj.MaterialNum; //上箱位 SAP物料号
- mbRec.TopMaterialDescription = leftObj.MaterialDescription2.IsNullOrEmpty() ? leftObj.MaterialDescription : leftObj.MaterialDescription2; //上箱位 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
- }
- else
- {
- if (billObj.VIN == null)
- {
- mbRec.TopMaterialDescription += "*断号*";
- }
- else if (billObj.AssemblyID == null)
- {
- mbRec.TopMaterialDescription += "*未知总成*";
- }
- else
- {
- mbRec.TopMaterialDescription += "*leftObj为空*";
- }
- }
-
- if (rightObj != null) //右前
- {
- mbRec.BelowSAPMaterialNum = rightObj.MaterialNum; //下箱位 SAP物料号
- mbRec.BelowMaterialDescription = rightObj.MaterialDescription2.IsNullOrEmpty() ? rightObj.MaterialDescription : rightObj.MaterialDescription2; //下箱位 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
- }
- else
- {
- if (billObj.VIN == null)
- {
- mbRec.TopMaterialDescription += "*断号*";
- }
- else if (billObj.AssemblyID == null)
- {
- mbRec.BelowMaterialDescription += "*未知总成*";
- }
- else
- {
- mbRec.BelowMaterialDescription += "*rightObj为空*";
- }
- }
-
- if (string.IsNullOrEmpty(mbRec.KNR) == false && mbRec.KNR.Length == 10 && mbRec.KNR.Substring(4, 1) == "7" && string.IsNullOrEmpty(mbRec.VehicleModel_DoorPlankCode) == true)
- {
- mbRec.VehicleModel_DoorPlankCode += "*预批量*";
- }
-
- if (!String.IsNullOrEmpty(promMsg))
- {
- mbRec.VehicleModel_DoorPlankCode += promMsg;
- }
- mbObj.Details.Add(mbRec);
- } //foreach
- retLst.Add(mbObj); //有用
- return retLst;
- }
///
/// 打印门板装箱单时调用库存系统接口
///
///
- private void CallWMSInterface_MB(List input)
- {
+ //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.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 idx2 = 0;
- foreach (MenBanPackingRec sourceRec in sourceObj.Details)
- {
- idx2++;
- if (sourceRec.TopSAPMaterialNum.IsNullOrEmpty() == false)
- {
- var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.TopSAPMaterialNum && 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.TopSAPMaterialNum; //物料号
- //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.BelowSAPMaterialNum.IsNullOrEmpty() == false)
- {
- var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.BelowSAPMaterialNum && itm.MaterialType == "1");
-
- idx++;
- TS_SORT_DETAIL targetDetail = new TS_SORT_DETAIL();
- targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接
- targetDetail.VinCode = sourceRec.VIN; //VIN码
- targetDetail.PartCode = sourceRec.BelowSAPMaterialNum; //物料号
- 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; //添加车型
+ // 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.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 idx2 = 0;
+ // foreach (MenBanPackingRec sourceRec in sourceObj.Details)
+ // {
+ // idx2++;
+ // if (sourceRec.TopSAPMaterialNum.IsNullOrEmpty() == false)
+ // {
+ // var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.TopSAPMaterialNum && 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.TopSAPMaterialNum; //物料号
+ // //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.BelowSAPMaterialNum.IsNullOrEmpty() == false)
+ // {
+ // var materialObj = _materialExtRepository.FirstOrDefault(itm => itm.MaterialNum == sourceRec.BelowSAPMaterialNum && itm.MaterialType == "1");
+
+ // idx++;
+ // TS_SORT_DETAIL targetDetail = new TS_SORT_DETAIL();
+ // targetDetail.BillNum = sourceObj.BillNum; //单据编号 通过该字段和主表弱连接
+ // targetDetail.VinCode = sourceRec.VIN; //VIN码
+ // targetDetail.PartCode = sourceRec.BelowSAPMaterialNum; //物料号
+ // 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", ""); //添加车型
- }
+ // 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("插入或更新库存系统接口表记录数为零!");
- }
- }
+ // }
+ // 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)
+ //}
+ //private int InsertOrUpdateWMSMain(TB_BILL targetMain)
//{
- // //重新打印时,库存系统接口如果存在已发运的正常打印单据,则不允许重新打印;如果存在未发运的正常打印单据则删除该单据
- // string oldBillNum = billNum;
- // TB_BILL oldBillObj = _wmsDapperRepository.GetSingleBySql($"select top 1 * from TB_BILL where BillNum = '{oldBillNum}'", true);
- // if (oldBillObj != null)
+ // 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 (oldBillObj.State == 0)
+ // 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)
// {
- // string sqlMain = $"delete from TS_SORT_DETAIL where BillNum = '{oldBillNum}'";
- // _wmsDapperRepository.ExecuteSql(sqlMain, null, true);
+ // throw new Exception("调用InsertOrUpdateWMSMain方法时报错:" + ex.Message + "SQL:" + sqlUpdateMain + "单据号:" + targetMain.BillNum);
+ // }
- // string sqlDetail = $"delete from TB_BILL where BillNum = '{oldBillNum}'";
- // _wmsDapperRepository.ExecuteSql(sqlDetail, null, true);
+ // }
+ // 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);
// }
- // else
+ // 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 BusinessException("1001", $"该单据{oldBillNum}在库存系统中已经排序或发运,不允许删除!");
+ // throw new Exception("调用InsertOrUpdateWMSDetail方法时报错:" + ex.Message + "SQL:" + sqlUpdateDetail);
// }
// }
+ // return ret;
//}
- ///
- /// 根据条件取用于打印的柱护板单据列表
- ///
- ///
- ///
- ///
- private async Task> GetZHBReportDetailList(ZhuHuBanPrintInputDto input, bool isFillBreakNum = false)
- {
- List billLst = new List();
- ListResultDto ret = new ListResultDto(billLst);
+ #endregion
- 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;
+ #region 报表公共方法
- var query = from a in _billM100Repository.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 _billM100Repository.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 _billM100Repository.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 _billM100Repository.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 _billM100Repository.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 _billM100Repository.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 FisBillM100 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 _billM100Repository.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
+ ///
+ /// 根据生产线获取正常打印单据的起始大众顺序号
+ ///
+ /// 生产线
+ /// 起始大众顺序号
+ //[UnitOfWork]
+ //[HttpGet]
+ //[Route("get-print-start-hostsn")]
+ //public virtual async Task> GetPrintStartHostSN(string productLine)
+ //{
+ // int? beginHostSN = null;
+ // try
+ // {
+ // //存在已打印单据
+ // var publishQry = _billM100Repository.Where(itm => itm.ProductLine == productLine && itm.BillStatus == BillStatusEnum.Publish);
+ // if (publishQry.Any() == true)
+ // {
+ // //取已打印最后一个单据
+ // DateTime publishMaxCreateTime = publishQry.Max(itm => itm.CreationTime);
+ // //取指定生产线、不等于已打印状态、大于已打印最后一个单据、最小的CreationTime
+ // var query = _billM100Repository.Where(itm =>
+ // itm.ProductLine == productLine
+ // && (itm.BillStatus != BillStatusEnum.Publish)
+ // && itm.CreationTime > publishMaxCreateTime);
+ // if (query.Any())
+ // {
+ // DateTime minCreateTime = query.Min(itm => itm.CreationTime);
+ // //根据CreationTime取大众顺序号
+ // var obj = await _billM100Repository.FirstOrDefaultAsync(itm => itm.ProductLine == productLine && itm.CreationTime == minCreateTime);
+ // if (obj != null)
+ // {
+ // beginHostSN = obj.HostSN;
+ // }
+ // }
+ // }
+ // else
+ // {
+ // //取指定生产线、不等于已打印状态、最小的CreationTime
+ // var query2 = _billM100Repository.Where(itm =>
+ // itm.ProductLine == productLine
+ // && itm.BillStatus != BillStatusEnum.Publish);
+ // if (query2.Any())
+ // {
+ // DateTime minCreateTime2 = query2.Min(itm => itm.CreationTime);
+ // //根据流水号取大众顺序号
+ // var obj = await _billM100Repository.FirstOrDefaultAsync(itm => itm.ProductLine == productLine && itm.CreationTime == minCreateTime2);
+ // if (obj != null)
+ // {
+ // beginHostSN = obj.HostSN;
+ // }
+ // }
+ // }
+ // return new ObjectResultDto(beginHostSN);
+ // }
+ // catch (Exception ex)
+ // {
+ // ObjectResultDto ret = new ObjectResultDto();
+ // ret.Status = false;
+ // ret.Message = _errorMessagePrefix + "GetPrintStartHostSN 执行出错:" + ex.Message;
+ // _logger.LogError(ret.Message);
+ // return ret;
+ // }
+ //}
- 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); //取最早上线时间,库存接口用
+ /// 执行成功返回真
+ //[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();
- //取当前页的详细信息
- foreach (BillM100 billObj in billLst)
- {
- ZhuHuBanPackingRec zhbRec = new ZhuHuBanPackingRec();
- zhbRec.SetId(GuidGenerator.Create());
- zhbRec.M100BillId = billObj.Id;
- zhbRec.KNR = billObj.KNR;
- zhbRec.VIN = billObj.VIN;
- zhbRec.HostSN = billObj.HostSN;
- if (billObj.BillM100Parts != null && billObj.BillM100Parts.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;
- }
+ // 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;
+ // }
- MaterialExt materialObj2 = GetZhuHuBanByType("C柱上", rightOrLeft + "侧", billObj);
- if (materialObj2 != null)
- {
- zhbRec.MaterialDescription2 = materialObj2.MaterialDescription;
- zhbRec.PartCode2 = materialObj2.RelationKey;
- }
+ // int pageCnt = (int)Math.Ceiling(billLst.Count / 12.0); //每页打印12列,取打印页数
- } //A上C上
- }
- zhbObj.Details.Add(zhbRec);
- } //foreach
- retLst.Add(zhbObj);
- return retLst;
- } //DoZHBPrint
+ // double maxBillNum = 0;
+
+ // DateTime printTime = ServerHelper.CurrentDateTime;
- ///
- /// 打印柱护板(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); //取最早上线时间,库存接口用
+ // 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);
+ // }
- //取当前页的详细信息
- foreach (BillM100 billObj in billLst)
- {
- ZhuHuBanPackingRec zhbRec = new ZhuHuBanPackingRec();
- zhbRec.SetId(GuidGenerator.Create());
- zhbRec.M100BillId = billObj.Id;
- zhbRec.KNR = billObj.KNR;
- zhbRec.VIN = billObj.VIN;
- zhbRec.HostSN = billObj.HostSN;
- if (billObj.BillM100Parts != null && billObj.BillM100Parts.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;
- }
+ // //调用派格版库存接口
+ // CallWMSInterface_MB(reportMainLst);
- MaterialExt materialObj2 = GetZhuHuBanByType("A柱中", rightOrLeft + "侧", billObj);
- if (materialObj2 != null)
- {
- zhbRec.MaterialDescription2 = materialObj2.MaterialDescription;
- zhbRec.PartCode2 = materialObj2.RelationKey;
- }
+ // //插入门板打印记录表
+ // await _menBanPackingListRepository.InsertManyAsync(reportMainLst, true);
- }//if A柱下A中
- }
- zhbObj.Details.Add(zhbRec);
- } //foreach
- retLst.Add(zhbObj);
- return retLst;
- } //DoZHBPrint
+ // //更新M100的门板打印标志:BillStatus=3
+ // foreach (BillM100 billObj in billLst)
+ // {
+ // if (billObj.BillStatus == BillStatusEnum.Match)
+ // {
+ // billObj.SetBillStatus(BillStatusEnum.Publish);
+ // billObj.PrintTime = ServerHelper.CurrentDateTime;
+ // billObj.NeedReplenishPrint = 0; //不需要补打
+ // await _billM100Repository.UpdateAsync(billObj, true);
+ // }
+ // else if (billObj.BillStatus == BillStatusEnum.NotMatch)
+ // {
+ // //billObj.PrintTime = ServerHelper.CurrentDateTime;
+ // billObj.NeedReplenishPrint = 1; //需要补打
+ // await _billM100Repository.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 = _billM100Repository.Where(itm => input.M100IdList.Contains(itm.Id)).OrderBy(itm => itm.SerialNumStr).ToList();
+ // if (billLst.Count == 0)
+ // {
+ // ret.Message = "没有补打的单据,请先选择要补打的单据!";
+ // ret.Status = false;
+ // return ret;
+ // }
- ///
- /// 打印柱护板(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();
+ // int pageCnt = (int)Math.Ceiling(billLst.Count / 12.0); //每页打印12列,取打印页数
- //填充柱护板装箱单主实体
- ZhuHuBanPackingList zhbObj = new ZhuHuBanPackingList();
- zhbObj.SetId(GuidGenerator.Create());
+ // double maxBillNum = 0;
- long maxBillNum2 = _sequenceDomainService.GetSequence(SequenceTypeEnum.门板及柱护板装箱单号);
- zhbObj.BillNum = GetBillNum(maxBillNum2);
- zhbObj.BillSerialNum = maxSN.ToString().PadLeft(2, '0');
+ // DateTime printTime = ServerHelper.CurrentDateTime;
- 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); //取最早上线时间,库存接口用
+ // 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.TopSAPMaterialNum);
+ // string checkVinPartRepeatBillNum1 = _newJitDapperRepository.GetSingleBySql(sql1, true);
+ // if (string.IsNullOrEmpty(checkVinPartRepeatBillNum1) == false)
+ // {
+ // throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum1}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.TopSAPMaterialNum}之间重复!");
+ // }
+
+ // string sql2 = string.Format(checkVinPartRepeatSql, reportRecObj.VIN, reportRecObj.BelowSAPMaterialNum);
+ // string checkVinPartRepeatBillNum2 = _newJitDapperRepository.GetSingleBySql(sql2, true);
+ // if (string.IsNullOrEmpty(checkVinPartRepeatBillNum2) == false)
+ // {
+ // throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum2}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.BelowSAPMaterialNum}之间重复!");
+ // }
+ // }
+ // }
- //取当前页的详细信息
- foreach (BillM100 billObj in billLst)
- {
- ZhuHuBanPackingRec zhbRec;
- if (billObj.BillM100Parts != null && billObj.BillM100Parts.Count > 0)
- {
- if (zhbPartType == "B柱上")
- {
- zhbRec = new ZhuHuBanPackingRec();
- zhbRec.SetId(GuidGenerator.Create());
- zhbRec.M100BillId = 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.M100BillId = 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.M100BillId = 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;
- }
+ // //调用派格版库存接口
+ // CallWMSInterface_MB(reportMainLst);
- MaterialExt materialObj2 = GetZhuHuBanByType("上装饰板", rightOrLeft + "侧", billObj);
- if (materialObj2 != null)
- {
- zhbRec.MaterialDescription2 = materialObj2.MaterialDescription;
- zhbRec.PartCode2 = materialObj2.RelationKey;
- }
- zhbObj.Details.Add(zhbRec);
+ // //插入门板打印记录表
+ // await _menBanPackingListRepository.InsertManyAsync(reportMainLst);
- } //if 后轮上装饰板
- }
- else
- {
- //没有柱护板字典时,用空白单元格填充(之前不填充,造成后面空行)
- zhbRec = new ZhuHuBanPackingRec();
- zhbRec.SetId(GuidGenerator.Create());
- zhbRec.M100BillId = billObj.Id;
- zhbRec.KNR = billObj.KNR;
- zhbRec.VIN = billObj.VIN;
- zhbRec.HostSN = billObj.HostSN;
- zhbObj.Details.Add(zhbRec);
- }
+ // //更新M100的门板打印标志:BillStatus=3
+ // foreach (BillM100 billObj in billLst)
+ // {
+ // if (billObj.BillStatus == BillStatusEnum.Match)
+ // {
+ // billObj.SetBillStatus(BillStatusEnum.Publish);
+ // billObj.PrintTime = ServerHelper.CurrentDateTime;
+ // await _billM100Repository.UpdateAsync(billObj);
+ // }
+ // }
+ // }
- } //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); //取最早上线时间,库存接口用
+ // #region 格式转换
+ // //实体 转 DTO
+ // List targetLst = ObjectMapper.Map, List>(reportMainLst);
+ // targetLst = targetLst.OrderBy(itm => itm.BillNum).ToList();
- //取当前页的详细信息
- foreach (BillM100 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.M100BillId = billObj.Id;
- zhbRec.KNR = billObj.KNR;
- zhbRec.VIN = billObj.VIN;
- zhbRec.HostSN = billObj.HostSN;
- if (billObj.BillM100Parts != null && billObj.BillM100Parts.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("插入或更新库存系统接口表记录数为零!");
- }
- }
- }
+ // //补充空行
+ // 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;
+ // }
+ //}
- private static string GetTrueString(string str)
- {
- return str == null ? " " : str.Trim(); ;
- }
- ///
- /// 查找M100结算件中是否包含指定类型(如D柱)的柱护板
- ///
- ///
- ///
- ///
- ///
- private MaterialExt GetZhuHuBanByType(string p_materialType2, string p_materialType3, BillM100 p_billM100)
- {
- //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 (BillM100Part billObj in p_billM100.BillM100Parts)
- {
- 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);
- int newNum = lastNum + 1;
- if ((lastNum % 10000) == 1999)
- {
- if ((input.BeginHostSN % 10000) != 1)
- {
- string msg = $"单据之间断号,上次打印的最后大众顺序号为【{lastNum}】,与本次打印开始号【{input.BeginHostSN}】中间存在断号!";
- retLst.Add(msg);
- _logger.LogDebug(msg);
- }
- }
- else
- {
- if(newNum!= 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++)
- {
- BillM100 priorObj = billLst[i - 1];
- BillM100 curObj = billLst[i];
- int priorHostSN = (int)billLst[i - 1].HostSN;
- int curHostSN = (int)billLst[i].HostSN;
+ /// 执行成功返回真
+ //[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 (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;
- }
+ // 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(); //取柱护板零件
- ///
- /// 打印前检查大众顺序号是否断号
- ///
- ///
- /// 是否柱护板
- /// 断号时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++)
- {
- BillM100 priorObj = billLst[i - 1];
- BillM100 curObj = billLst[i];
- int priorHostSN = (int)billLst[i - 1].HostSN;
- int curHostSN = (int)billLst[i].HostSN;
+ // 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);
+ // }
- 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;
- }
- }
+ // ////更新M100的柱护板打印标志: PrintBillNum不为空时表示已打印
+ // var updIdLst = billLst.Select(itm => itm.Id).ToList();
+ // var updLst = await _billM100Repository.GetListAsync(itm => updIdLst.Contains(itm.Id));
+ // foreach (var updObj in updLst)
+ // {
+ // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印"
+ // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板
+ // }
+ // await _billM100Repository.UpdateManyAsync(updLst, true);
- ///
- /// 根据生产线获取正常打印单据的起始大众顺序号
- ///
- /// 生产线
- /// 起始大众顺序号
- //[UnitOfWork]
- //[HttpGet]
- //[Route("get-print-start-hostsn")]
- //public virtual async Task> GetPrintStartHostSN(string productLine)
- //{
- // int? beginHostSN = null;
- // try
- // {
- // //存在已打印单据
- // var publishQry = _billM100Repository.Where(itm => itm.ProductLine == productLine && itm.BillStatus == BillStatusEnum.Publish);
- // if (publishQry.Any() == true)
+ // }
+ // else if (input.PrintType == PrintTypeEnum.重新打印) //和正常打印单据完全一样,可以打印部分单据
// {
- // //取已打印最后一个单据
- // DateTime publishMaxCreateTime = publishQry.Max(itm => itm.CreationTime);
- // //取指定生产线、不等于已打印状态、大于已打印最后一个单据、最小的CreationTime
- // var query = _billM100Repository.Where(itm =>
- // itm.ProductLine == productLine
- // && (itm.BillStatus != BillStatusEnum.Publish)
- // && itm.CreationTime > publishMaxCreateTime);
- // if (query.Any())
+ // if (input.DataResultType == "1") //全部11条数据
// {
- // DateTime minCreateTime = query.Min(itm => itm.CreationTime);
- // //根据CreationTime取大众顺序号
- // var obj = await _billM100Repository.FirstOrDefaultAsync(itm => itm.ProductLine == productLine && itm.CreationTime == minCreateTime);
- // if (obj != null)
+ // var firObj = await _zhuHuBanPackingListRepository.FirstOrDefaultAsync(itm => input.ReportIdList.Contains(itm.Id));
+ // if (firObj != null)
// {
- // beginHostSN = obj.HostSN;
+ // Guid? sortId = firObj.SortId;
+ // reportMainLst = await _zhuHuBanPackingListRepository.GetListAsync(itm => itm.SortId == sortId, true);
// }
// }
- // }
- // else
- // {
- // //取指定生产线、不等于已打印状态、最小的CreationTime
- // var query2 = _billM100Repository.Where(itm =>
- // itm.ProductLine == productLine
- // && itm.BillStatus != BillStatusEnum.Publish);
- // if (query2.Any())
+ // else
// {
- // DateTime minCreateTime2 = query2.Min(itm => itm.CreationTime);
- // //根据流水号取大众顺序号
- // var obj = await _billM100Repository.FirstOrDefaultAsync(itm => itm.ProductLine == productLine && itm.CreationTime == minCreateTime2);
- // if (obj != null)
+ // 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)
// {
- // beginHostSN = obj.HostSN;
+ // 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();
// }
// }
// }
- // return new ObjectResultDto(beginHostSN);
- // }
- // catch (Exception ex)
- // {
- // ObjectResultDto ret = new ObjectResultDto();
- // ret.Status = false;
- // ret.Message = _errorMessagePrefix + "GetPrintStartHostSN 执行出错:" + ex.Message;
- // _logger.LogError(ret.Message);
- // return ret;
- // }
- //}
+ // else if (input.PrintType == PrintTypeEnum.补账打印)
+ // {
+ // if (input.M100IdList.Count > 24)
+ // {
+ // throw new BusinessException("1001", $"选中的柱护板补打不能超过24个底盘!");
+ // }
- ///
- /// 根据生产线获取正常打印单据的起始大众顺序号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 _billM100Repository.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}'
-)
+ // List billLst = _billM100Repository.GetListAsync(itm => input.M100IdList.Contains(itm.Id), true).GetAwaiter().GetResult();
+ // if (billLst.Count == 0)
+ // {
+ // ret.Message = "没有补打的柱护板,请先选择要补打的柱护板!";
+ // ret.Status = false;
+ // return ret;
+ // }
+ // billLst = billLst.OrderBy(itm => itm.SerialNumStr).ToList();
-select min(SerialNumStr) from FisBillM100 a left join d on a.VIN=d.VIN
+ // //加载柱护板缓存列表
+ // _zhbCacheList = _materialExtRepository.Where(itm => itm.MaterialType == "2").ToList(); //取柱护板零件
- 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";
+ // long maxBillNum = 0; //全局唯一装箱单号
+ // DateTime printTime = ServerHelper.CurrentDateTime;
+ // double maxSN; //右上角顺序号01-99
- sql = string.Format(sql, productLine, GroupName);
- var minSNStr = await _newJitDapperRepository.GetSingleBySqlAsync(sql);
+ // //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);
+ // }
+ // ////更新M100的柱护板打印标志: PrintBillNum不为空时表示已打印
+ // var updIdLst = billLst.Select(itm => itm.Id).ToList();
+ // var updLst = await _billM100Repository.GetListAsync(itm => updIdLst.Contains(itm.Id));
+ // foreach (var updObj in updLst)
+ // {
+ // updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印"
+ // updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板
+ // }
+ // await _billM100Repository.UpdateManyAsync(updLst, true);
+ // }
- beginHostSN = await _billM100Repository.Where(itm =>
- itm.ProductLine == productLine //指定生产线
- && itm.CanNotPrint != true //能打印
- && string.IsNullOrEmpty(itm.PrintBillNum) == true //等于 未打印
- && itm.SerialNumStr == minSNStr
- ).MinAsync(itm => itm.HostSN);
- }
- else //---------------门板-----------------------------------------------------------------------------------
- {
- string minSNStr2 = await _billM100Repository.Where(itm =>
- itm.ProductLine == productLine //指定生产线
- && itm.CanNotPrint != true //能打印
- //&& itm.BillStatus == BillStatusEnum.Match //等于 未打印(和M100上线信息匹配)
- && itm.BillStatus != BillStatusEnum.Publish //未知总成也显示在装箱单
- && itm.NeedReplenishPrint != 1 //排除补打
- ).MinAsync(itm => itm.SerialNumStr);
-
- beginHostSN = await _billM100Repository.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);
-
- //更新M100的门板打印标志:BillStatus=3
- foreach (BillM100 billObj in billLst)
- {
- if (billObj.BillStatus == BillStatusEnum.Match)
- {
- billObj.SetBillStatus(BillStatusEnum.Publish);
- billObj.PrintTime = ServerHelper.CurrentDateTime;
- billObj.NeedReplenishPrint = 0; //不需要补打
- await _billM100Repository.UpdateAsync(billObj, true);
- }
- else if (billObj.BillStatus == BillStatusEnum.NotMatch)
- {
- //billObj.PrintTime = ServerHelper.CurrentDateTime;
- billObj.NeedReplenishPrint = 1; //需要补打
- await _billM100Repository.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 = _billM100Repository.Where(itm => input.M100IdList.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.TopSAPMaterialNum);
- string checkVinPartRepeatBillNum1 = _newJitDapperRepository.GetSingleBySql(sql1, true);
- if (string.IsNullOrEmpty(checkVinPartRepeatBillNum1) == false)
- {
- throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum1}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.TopSAPMaterialNum}之间重复!");
- }
-
- string sql2 = string.Format(checkVinPartRepeatSql, reportRecObj.VIN, reportRecObj.BelowSAPMaterialNum);
- string checkVinPartRepeatBillNum2 = _newJitDapperRepository.GetSingleBySql(sql2, true);
- if (string.IsNullOrEmpty(checkVinPartRepeatBillNum2) == false)
- {
- throw new BusinessException("1001", $"与装箱单号{checkVinPartRepeatBillNum2}中的底盘号{reportRecObj.VIN}、零件号{reportRecObj.BelowSAPMaterialNum}之间重复!");
- }
- }
- }
-
- //调用派格版库存接口
- CallWMSInterface_MB(reportMainLst);
-
- //插入门板打印记录表
- await _menBanPackingListRepository.InsertManyAsync(reportMainLst);
-
- //更新M100的门板打印标志:BillStatus=3
- foreach (BillM100 billObj in billLst)
- {
- if (billObj.BillStatus == BillStatusEnum.Match)
- {
- billObj.SetBillStatus(BillStatusEnum.Publish);
- billObj.PrintTime = ServerHelper.CurrentDateTime;
- await _billM100Repository.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);
- }
-
- ////更新M100的柱护板打印标志: PrintBillNum不为空时表示已打印
- var updIdLst = billLst.Select(itm => itm.Id).ToList();
- var updLst = await _billM100Repository.GetListAsync(itm => updIdLst.Contains(itm.Id));
- foreach (var updObj in updLst)
- {
- updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印"
- updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板
- }
- await _billM100Repository.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.M100IdList.Count > 24)
- {
- throw new BusinessException("1001", $"选中的柱护板补打不能超过24个底盘!");
- }
-
- List billLst = _billM100Repository.GetListAsync(itm => input.M100IdList.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);
- }
-
- ////更新M100的柱护板打印标志: PrintBillNum不为空时表示已打印
- var updIdLst = billLst.Select(itm => itm.Id).ToList();
- var updLst = await _billM100Repository.GetListAsync(itm => updIdLst.Contains(itm.Id));
- foreach (var updObj in updLst)
- {
- updObj.SetZHBBillStatus(ZHBBillStatusEnum.Print); //PrintBillNum = "柱护板已打印"
- updObj.PrintTime2 = ServerHelper.CurrentDateTime; //PrintTime只适用于门板
- }
- await _billM100Repository.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;
- }
- }
+ // #region 返回结果格式转换
+ // //实体 转 DTO
+ // List targetLst = ObjectMapper.Map, List>(reportMainLst);
+ // //补充空行
+ // foreach (var masterObj in targetLst)
+ // {
+ // int trueCnt = masterObj.Details.Count;
- ///
- /// 相同VIN的左右SortId相同,用于作废
- ///
- ///
- ///
- //private void ModifySortId(List lst1, List lst2 = null)
- //{
- // Guid sortId = GuidGenerator.Create();
- // foreach (var itm in lst1)
- // {
- // itm.SortId = sortId;
- // }
- // if (lst2 != null)
- // {
- // foreach (var itm in lst2)
+ // 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)
// {
- // itm.SortId = sortId;
+ // 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;
+ // }
// }
- // }
- //}
-
- #endregion
- #region 补打
- ///