From 31600e9c934dec54e696b233e26363f4de81608a Mon Sep 17 00:00:00 2001
From: 18923810322 <1666941798@qq.com>
Date: Wed, 11 Feb 2026 16:03:50 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../wwwroot/BarCode.Web.Domain.xml | 21 ++++++
.../Dto/Erp/Material/ErpMaterialDto.cs | 4 +-
src/BarCode.Web.Domain/Entitys/Materials.cs | 15 +++++
.../Infrastructure/IMaterialsRepositories.cs | 7 ++
.../Services/Public/ErpService.cs | 1 +
.../Services/Public/MaterialService.cs | 64 +++++++++++++------
.../MaterialsRepositories.cs | 10 +++
7 files changed, 100 insertions(+), 22 deletions(-)
diff --git a/src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml
index cc5f307..ccfbebe 100644
--- a/src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml
+++ b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml
@@ -456,6 +456,21 @@
物料Id 32进制字符串
+
+
+ 物料创建时间
+
+
+
+
+ 物料修改时间
+
+
+
+
+ 物料修改时间
+
+
防伪码生成记录
@@ -1220,6 +1235,12 @@
+
+
+ 跟据规格获取物料
+
+
+
修改物料
diff --git a/src/BarCode.Web.Core/Dto/Erp/Material/ErpMaterialDto.cs b/src/BarCode.Web.Core/Dto/Erp/Material/ErpMaterialDto.cs
index 60915a8..f42f369 100644
--- a/src/BarCode.Web.Core/Dto/Erp/Material/ErpMaterialDto.cs
+++ b/src/BarCode.Web.Core/Dto/Erp/Material/ErpMaterialDto.cs
@@ -68,12 +68,12 @@ namespace BarCode.Web.Core.Dto.Erp
///
/// 修改日期
///
- public DateTime? FModifyDate { get; set; }
+ public DateTime FModifyDate { get; set; }
///
/// 创建日期
///
- public DateTime? FCreateDate { get; set; }
+ public DateTime FCreateDate { get; set; }
///
/// 产品线(1级)
diff --git a/src/BarCode.Web.Domain/Entitys/Materials.cs b/src/BarCode.Web.Domain/Entitys/Materials.cs
index 16b1091..a2f270e 100644
--- a/src/BarCode.Web.Domain/Entitys/Materials.cs
+++ b/src/BarCode.Web.Domain/Entitys/Materials.cs
@@ -74,6 +74,21 @@ namespace BarCode.Web.Domain.Entitys
///
public string IdConvertBar { get; set; }
+ ///
+ /// 物料创建时间
+ ///
+ public DateTime FCreateDate { get; set; }
+
+ ///
+ /// 物料修改时间
+ ///
+ public DateTime FModifyDate { get; set; }
+
+ ///
+ /// 物料修改时间
+ ///
+ public string isDis { get; set; }
+
/////
///// 产品线(1级)
/////
diff --git a/src/BarCode.Web.Domain/Infrastructure/IMaterialsRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/IMaterialsRepositories.cs
index bd62ff1..bb85777 100644
--- a/src/BarCode.Web.Domain/Infrastructure/IMaterialsRepositories.cs
+++ b/src/BarCode.Web.Domain/Infrastructure/IMaterialsRepositories.cs
@@ -67,6 +67,13 @@ namespace BarCode.Web.Domain.Infrastructure
///
Task> GetEntityListByNoBar();
+
+ ///
+ /// 跟据规格获取物料
+ ///
+ ///
+ Task> GetEntityListByGuiGe(List materGuiGes, DateTime dt);
+
///
/// 修改物料
///
diff --git a/src/BarCode.Web.Domain/Services/Public/ErpService.cs b/src/BarCode.Web.Domain/Services/Public/ErpService.cs
index 780a976..f2b6fa6 100644
--- a/src/BarCode.Web.Domain/Services/Public/ErpService.cs
+++ b/src/BarCode.Web.Domain/Services/Public/ErpService.cs
@@ -434,6 +434,7 @@ namespace BarCode.Web.Domain.Services.Public
_logger.LogInformation($"物料拉取-结束时间:{endTime}");
//5.物料集合进行缓存-当前缓存时间到当天晚上的0点,后面定时任务执行重新放入缓存
_memoryCache.Set(_erpOptions.cache_materail_key, erp_materials_list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan())));
+
_logger.LogInformation($"物料拉取-总条数:{erp_materials_list.Count}");
return ResultList.ReSuccess(erp_materials_list);
}
diff --git a/src/BarCode.Web.Domain/Services/Public/MaterialService.cs b/src/BarCode.Web.Domain/Services/Public/MaterialService.cs
index c57b1ee..aa45211 100644
--- a/src/BarCode.Web.Domain/Services/Public/MaterialService.cs
+++ b/src/BarCode.Web.Domain/Services/Public/MaterialService.cs
@@ -124,7 +124,7 @@ namespace BarCode.Web.Domain.Services
//修改有更新的数据
if (mats.Count != 0)
{
- var isFModifyDateMatNumbs = mats.Where(x => x.FModifyDate >= DateTime.Now.AddDays(-5)).Select(x => new { MaterialNumber = x.MaterialNumber, Specifications = x.Specifications, MaterialName = x.MaterialName, BarCode = x.BarCode, OrgId = x.OrgId, FProductLines1 = x.FProductLines1, FProductCATs1 = x.FProductCATs1, FMaterialGroup = x.FMaterialGroup, F_Product = x.F_Product, FProductLines1FName = x.FProductLines1FName, FProductCATs1FName = x.FProductCATs1FName, FMaterialGroupFName = x.FMaterialGroupFName, MaterialId = x.MaterialId, FProductIDS = x.FProductIDS }).ToList();
+ var isFModifyDateMatNumbs = mats.Where(x => x.FModifyDate >= DateTime.Now.AddDays(-5)).Select(x => new { MaterialNumber = x.MaterialNumber, Specifications = x.Specifications, MaterialName = x.MaterialName, BarCode = x.BarCode, OrgId = x.OrgId, FCreateDate=x.FCreateDate, FModifyDate=x.FModifyDate, FProductLines1 = x.FProductLines1, FProductCATs1 = x.FProductCATs1, FMaterialGroup = x.FMaterialGroup, F_Product = x.F_Product, FProductLines1FName = x.FProductLines1FName, FProductCATs1FName = x.FProductCATs1FName, FMaterialGroupFName = x.FMaterialGroupFName, MaterialId = x.MaterialId, FProductIDS = x.FProductIDS }).ToList();
//
_logger.LogInformation("取到需要同步的金蝶修改物料规格yzh(20260209):" + isFModifyDateMatNumbs.Count + "个");
@@ -149,6 +149,9 @@ namespace BarCode.Web.Domain.Services
entity.Specifications = mat.Specifications;
entity.MaterialName = mat.MaterialName;
entity.BarCode = mat.BarCode;
+ entity.FCreateDate = DateTime.Now;
+ entity.FModifyDate = mat.FModifyDate;
+ entity.isDis = "1";
//entity.OrgId = mat.OrgId;
//entity.FProductLines1 = mat.FProductLines1;
//entity.FProductCATs1 = mat.FProductCATs1;
@@ -162,6 +165,7 @@ namespace BarCode.Web.Domain.Services
continue;
}
}
+
}
var isSuccess = await _materialsRepositories.UpdateRange(updateList);
@@ -169,28 +173,48 @@ namespace BarCode.Web.Domain.Services
_logger.LogInformation("同步金蝶修改物料-修改物料规格yzh:失败");
else
_logger.LogInformation("同步金蝶修改物料-修改物料规格yzh:成功->" + updateList.Count + "条");
+
+
}
-
-
-
- // List s = new List();
- //foreach (var ismat in isFModifyDateMatNumbs)
- // {
- // s.Add(ismat.MaterialNumber);
- // }
-
- // var updateList = await _materialsRepositories.GetEntityListAddMaterial(s);
- // if (updateList.Count != 0)
- // {
- // updateList.ForEach(x => { x.Specifications = ; });
- // var isSuccess = await _materialsRepositories.UpdateRange(updateList);
- // if (!isSuccess)
- // _logger.LogInformation("同步金蝶新物料-修改物料:失败");
- // else
- // _logger.LogInformation("同步金蝶新物料-修改物料:成功->" + updateList.Count + "条");
- // }
}
+
+
+ //修改后把如果有两个或以上的,之前的进行禁用
+ if (mats.Count != 0)
+ {
+ var isFModifyDateMatNumbs = mats.Where(x => x.FModifyDate >= DateTime.Now.AddDays(-5)).Select(x => new { MaterialNumber = x.MaterialNumber, Specifications = x.Specifications, MaterialName = x.MaterialName, BarCode = x.BarCode, OrgId = x.OrgId, FCreateDate = x.FCreateDate, FModifyDate = x.FModifyDate, FProductLines1 = x.FProductLines1, FProductCATs1 = x.FProductCATs1, FMaterialGroup = x.FMaterialGroup, F_Product = x.F_Product, FProductLines1FName = x.FProductLines1FName, FProductCATs1FName = x.FProductCATs1FName, FMaterialGroupFName = x.FMaterialGroupFName, MaterialId = x.MaterialId, FProductIDS = x.FProductIDS }).ToList();
+ //
+
+ _logger.LogInformation("取到需要同步的金蝶修改物料规格yzh(第二次)(20260209):" + isFModifyDateMatNumbs.Count + "个");
+ List s = new List();
+ foreach (var ismat in isFModifyDateMatNumbs)
+ {
+ s.Add(ismat.Specifications);
+ }
+
+ var updateList = await _materialsRepositories.GetEntityListByGuiGe(s,DateTime.Now);
+ if (isFModifyDateMatNumbs.Count != 0)
+ {
+ //updateList.ForEach(x => { x.Specifications = ; });
+
+ foreach (var entity in updateList)
+ {
+
+ entity.isDis = "0";
+
+ }
+
+
+ var isSuccess = await _materialsRepositories.UpdateRange(updateList);
+ if (!isSuccess)
+ _logger.LogInformation("同步金蝶修改物料-修改物料规格yzh:失败");
+ else
+ _logger.LogInformation("同步金蝶修改物料-修改物料规格yzh:成功->" + updateList.Count + "条");
+ }
+
+
+ }
//5.修改物料数据
if (mats.Count != 0)
{
diff --git a/src/BarCode.Web.Repositories/MaterialsRepositories.cs b/src/BarCode.Web.Repositories/MaterialsRepositories.cs
index c094cad..0359ba3 100644
--- a/src/BarCode.Web.Repositories/MaterialsRepositories.cs
+++ b/src/BarCode.Web.Repositories/MaterialsRepositories.cs
@@ -178,6 +178,16 @@ namespace BarCode.Web.Repositories
return entitys;
}
+ ///
+ /// 获取物料按规格
+ ///
+ ///
+ public async Task> GetEntityListByGuiGe(List materGuiGes,DateTime dt)
+ {
+ var entitys = await _context.Materials.Where(x => materGuiGes.Contains(x.Specifications) && x.FCreateDate > GetEntityList(List materNumbers)
{
var entitys = await _context.Materials.Where(x => materNumbers.Contains(x.MaterialNumber)).ToListAsync();