diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index 6d20b540..684653fc 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -779,9 +779,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); var data = ms.ToArray(); var tupleList = this.ImportInternal(data); - - - if (tupleList.Any(o => o.Item2.Count > 0)) { using var workbook = new XLWorkbook(new MemoryStream(data)); @@ -876,18 +873,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ seDetails.Add(seDetail); } } - var result = await CheckBusinessJISLocation(seDetails,businessType).ConfigureAwait(false); if (result != "ok") { - return new JsonResult(new { code = 400, message = "发运数据有不在" + result + "库位中" }); + return new JsonResult(new { code = 400, message = result }); } - - return await BeginTran(seDetails, logList).ConfigureAwait(false); - } - if (businessType == EnumBusinessType.JisHBPO ) + if (businessType == EnumBusinessType.JisHBPO) { List seDetails = new List(); foreach (var item in logList) @@ -925,12 +918,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ seDetail.Remark = "期初初始化"; seDetails.Add(seDetail); } - } + var result = await CheckBusinessJISLocation(seDetails, businessType).ConfigureAwait(false); if (result != "ok") { - return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" }); + return new JsonResult(new { code = 400, message = result }); } return await BeginTran(seDetails, logList).ConfigureAwait(false); } @@ -973,14 +966,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ seDetails.Add(seDetail); } } + var result = await CheckBusinessJISLocation(seDetails, businessType).ConfigureAwait(false); if (result != "ok") { - return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" }); + return new JsonResult(new { code = 400, message = result }); } return await BeginTran(seDetails, logList).ConfigureAwait(false); } - if (businessType == EnumBusinessType.ZhiGongJianBBAC) { List seDetails = new List(); @@ -1021,7 +1014,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var result = await CheckBusinessPUBLocation(seDetails, businessType).ConfigureAwait(false); if (result != "ok") { - return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" }); + return new JsonResult(new { code = 400, message = result }); } return await BeginTran(seDetails, logList).ConfigureAwait(false); } @@ -1065,7 +1058,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var result = await CheckBusinessPUBLocation(seDetails, businessType).ConfigureAwait(false); if (result != "ok") { - return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" }); + return new JsonResult(new { code = 400, message = result }); } return await BeginTran(seDetails, logList).ConfigureAwait(false); } @@ -1109,10 +1102,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var result = await CheckBusinessPUBLocation(seDetails, businessType).ConfigureAwait(false); if (result != "ok") { - return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" }); + return new JsonResult(new { code = 400, message = result }); } return await BeginTran(seDetails, logList).ConfigureAwait(false); - } if (businessType == EnumBusinessType.YinDuJian) { @@ -1154,7 +1146,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var result = await CheckBusinessPUBLocation(seDetails, businessType).ConfigureAwait(false); if (result != "ok") { - return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" }); + return new JsonResult(new { code = 400, message = result }); } return await BeginTran(seDetails, logList).ConfigureAwait(false); } @@ -1176,7 +1168,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// private async Task BeginTran(List p_list, List logList) where T : SE_BASE, new() { - + //var messageList = logList.Select(log => new VmiMessage { Message = JsonSerializer.Serialize(log) }).ToList(); var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; @@ -1191,6 +1183,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { itm.Version = GetVersionByBillTime(itm.BillTime.Value, value); } + foreach (var itm in p_list) + { + itm.Version= GetVersionByBillTime(itm.ShippingDate, value); + } + await context.BulkInsertAsync(p_list).ConfigureAwait(false); await context.BulkInsertAsync(logList).ConfigureAwait(false); transaction.Commit(); @@ -1217,6 +1214,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// private async Task CheckBusinessJISLocation(List p_list, EnumBusinessType enumBusinessType) where T : JisSeBase, new() { + if (p_list.Count == 0) + { + return "符合条件记录为0,请检查记录中EDI生产码、发运类型等 是否录入正确" ; + } var locList = _codeRepository.Where(p => p.Project == "库位").ToList(); switch (enumBusinessType) { @@ -1254,7 +1255,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var locs = locList.Select(p => p.Description).ToList(); if (p_list.Any(p => !locs.Contains(p.ErpToLoc))) { - return string.Join(",", locs); + return "发运数据有不再" + string.Join(",", locs) + "库位中" ; } return "ok" ; } @@ -1267,6 +1268,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// private async Task CheckBusinessPUBLocation(List p_list, EnumBusinessType enumBusinessType) { + if (p_list.Count == 0) + { + return "符合条件记录为0,请检查记录中EDI生产码、发运类型等 是否录入正确"; + } var locList = _codeRepository.Where(p => p.Project == "库位").ToList(); switch (enumBusinessType) { @@ -1288,7 +1293,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var locs = locList.Select(p => p.Description).ToList(); if (p_list.Any(p => !locs.Contains(p.ToErpLocCode))) { - return string.Join(",",locs) ; + return "发运数据有不再" + string.Join(",", locs) + "库位中"; } return "ok"; @@ -1337,7 +1342,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //List seDetails = new List(); //List hbpo_seDetails=new List(); //List pub_seDetails=new List(); - //foreach (var item in logList) //{ // if(item.DeliverBillType== EnumDeliverBjBmpBillType.JIS件&&item.DeliverSubBillType== EnumDeliverSubBillType.保险杠BBAC) @@ -1370,12 +1374,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime= item.BillTime; - // seDetail.Remark = "期初初始化"; - // seDetails.Add(seDetail); // } - // if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && item.DeliverSubBillType == EnumDeliverSubBillType.买单件小件BBAC) // { // BBAC_SE_DETAIL seDetail = new BBAC_SE_DETAIL(); @@ -1406,12 +1407,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime = item.BillTime; - // seDetail.Remark = "期初初始化"; - // seDetails.Add(seDetail); // } - // if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && item.DeliverSubBillType == EnumDeliverSubBillType.保险杠HBPO) // { // HBPO_SE_DETAIL seDetail = new HBPO_SE_DETAIL(); @@ -1442,12 +1440,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime = item.BillTime; - // seDetail.Remark = "期初初始化"; - // hbpo_seDetails.Add(seDetail); // } - // if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && item.DeliverSubBillType == EnumDeliverSubBillType.买单件小件HBPO) // { // HBPO_SE_DETAIL seDetail = new HBPO_SE_DETAIL(); @@ -1478,12 +1473,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime = item.BillTime; - // seDetail.Remark = "期初初始化"; - // hbpo_seDetails.Add(seDetail); // } - // if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIT直供件 && item.DeliverSubBillType == EnumDeliverSubBillType.JIT直供件BBAC) // { // PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL(); @@ -1514,12 +1506,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime = item.BillTime; - // seDetail.Remark = "期初初始化"; - // pub_seDetails.Add(seDetail); // } - // if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIT直供件 && item.DeliverSubBillType == EnumDeliverSubBillType.JIT直供件HBPO) // { // PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL(); @@ -1550,12 +1539,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime = item.BillTime; - // seDetail.Remark = "期初初始化"; - // pub_seDetails.Add(seDetail); // } - // if (item.DeliverBillType == EnumDeliverBjBmpBillType.北汽4S备件 && item.DeliverSubBillType == EnumDeliverSubBillType.北汽4S备件BBAC) // { // PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL(); @@ -1586,12 +1572,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime = item.BillTime; - // seDetail.Remark = "期初初始化"; - // pub_seDetails.Add(seDetail); // } - // if (item.DeliverBillType == EnumDeliverBjBmpBillType.印度件 && item.DeliverSubBillType == EnumDeliverSubBillType.印度件BBAC) // { // PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL(); @@ -1622,15 +1605,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // seDetail.LU = item.CustPartCode; // seDetail.CustPartCode = item.CustPartCode; // seDetail.BillTime = item.BillTime; - // seDetail.Remark = "期初初始化"; - // pub_seDetails.Add(seDetail); // } - - //} - //var messageList = logList.Select(log => new VmiMessage { Message = JsonSerializer.Serialize(log) }).ToList(); var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs index 38b39d6c..ca090611 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs @@ -38,12 +38,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi { yield return new ValidationResult("客户客户订单号不能为空", new string[] { nameof(this.OrderNum) }); } - if (this.DeliverSubBillType!=null && this.DeliverSubBillType>0) + if (this.DeliverSubBillType==null && this.DeliverSubBillType>0) { yield return new ValidationResult("发货子类型", new string[] { nameof(this.DeliverSubBillType) }); } - if (this.DeliverBillType != null && this.DeliverBillType > 0) + if (this.DeliverBillType == null && this.DeliverBillType > 0) { yield return new ValidationResult("发货类型", new string[] { nameof(this.DeliverBillType) }); }