| | |
| | | using System.Net; |
| | | using System.Net.Http.Headers; |
| | | using System.Text; |
| | | using System.Data.SqlClient; |
| | | using System.Data; |
| | | using NewPdaSqlServer.Dto.Xky; |
| | | using static NewPdaSqlServer.Controllers.Warehouse.MesXkyController; |
| | | |
| | | namespace NewPdaSqlServer.service.QC; |
| | |
| | | // 新增列表空值检查 |
| | | if (noticeList == null || !noticeList.Any() || noticeList.Count < 1) |
| | | { |
| | | _logMessageDhdBar += $"本次获取收货单数据为空"; |
| | | _logMessageDHD += $"本次获取收货单数据为空"; |
| | | return result; |
| | | } |
| | | |
| | |
| | | private int SaveDeliveryNoticeBar(dynamic responseJson,string deliveryNo) |
| | | { |
| | | var result = 1; |
| | | List<TblBarcodeInformation> noticeList = JsonConvert.DeserializeObject<List<TblBarcodeInformation>>(responseJson.dataList.ToString()); |
| | | |
| | | // 新增列表空值检查 |
| | | if (noticeList == null || !noticeList.Any() || noticeList.Count < 1) |
| | | List<XkyBarcodeDataDto> noticeList = JsonConvert.DeserializeObject<List<XkyBarcodeDataDto>>(responseJson.dataList.ToString()); |
| | | |
| | | if (noticeList == null || !noticeList.Any()) |
| | | { |
| | | _logMessageDhdBar += $"条码数据为空,送货单号:{deliveryNo}"; |
| | | return result; |
| | | } |
| | | |
| | | // 赋值guid和到货单号 |
| | | noticeList.ForEach(n => n.Id = Guid.NewGuid()); |
| | | noticeList.ForEach(n => n.DeliveryNo = deliveryNo); |
| | | noticeList.ForEach(n => n.SynchronousDate = DateTime.Now); |
| | | var barcodeList = noticeList.Select(n => new TblBarcodeInformation |
| | | { |
| | | Id = Guid.NewGuid(), |
| | | DeliveryNo = deliveryNo, |
| | | SynchronousDate = DateTime.Now, |
| | | |
| | | // 直接映射字段 |
| | | ProductCode = n.ProductCode, |
| | | SmallBarcode = n.SmallBarcode, |
| | | BigBarcode = n.BigBarcode, |
| | | OuterBarcode = n.OuterBarcode, |
| | | IncludeQty = n.IncludeQty.ToString(), |
| | | SmallPackageSn = n.SmallPackageSn, |
| | | BigPackageSn = n.BigPackageSn, |
| | | OutPackageSn = n.OuterPackageSn, |
| | | PackLevel = n.PackLevel.ToString(), |
| | | |
| | | Db.Ado.UseTran(() => |
| | | // 尺寸字段映射 |
| | | SmallPackageLength = n.SmallPackageLength?.ToString(), |
| | | SmallPackageWidth = n.SmallPackageWidth?.ToString(), |
| | | SmallPackageHeight = n.SmallPackageHeight?.ToString(), |
| | | BigPackageLength = n.BigPackageLength?.ToString(), |
| | | BigPackageWidth = n.BigPackageWidth?.ToString(), |
| | | BigPackageHeight = n.BigPackageHeight?.ToString(), |
| | | OuterPackageLength = n.OuterPackageLength?.ToString(), |
| | | OuterPackageWidth = n.OuterPackageWidth?.ToString(), |
| | | OuterPackageHeight = n.OuterPackageHeight?.ToString(), |
| | | |
| | | // 动态字段映射 |
| | | PoErpNo = n.DynamicData?.PoErpNo ?? n.PoErpNo, |
| | | PoLineNo = n.DynamicData?.PoLineNo ?? n.PoLineNo, |
| | | InnerVendorCode = n.DynamicData?.InnerVendorCode, |
| | | Customize1 = n.DynamicData?.Customize1, |
| | | Customize2 = n.DynamicData?.Customize2, |
| | | Customize3 = n.DynamicData?.Customize3, |
| | | |
| | | // 其他字段 |
| | | DnLines = n.DnLines // 根据数据库注释,ExtendN01对应项目(单身extendN01),这里映射dnLines |
| | | }).ToList(); |
| | | |
| | | Db.Ado.UseTran(() => |
| | | { |
| | | // 删除关联送货明细数据 |
| | | Db.Deleteable<TblBarcodeInformation>() |
| | | .Where(d => d.DeliveryNo == deliveryNo) |
| | | .ExecuteCommand(); |
| | | .ExecuteCommand(); |
| | | |
| | | // 批量插入优化 |
| | | result = Db.Fastest<TblBarcodeInformation>().BulkCopy(noticeList); |
| | | // 批量插入优化(使用正确的barcodeList) |
| | | result = Db.Fastest<TblBarcodeInformation>().BulkCopy(barcodeList); |
| | | }, |
| | | ex => { |
| | | // 增强异常信息 |