From 28152ce6526d842a0c262e6d1b0a13aa01d343b8 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Wed, 6 Mar 2024 16:22:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AExternalPlatform/Enum/ErrorCodeEnum.cs | 6 +++ .../Material/Services/MaterialService.cs | 43 ++++++++++++++++--- .../Properties/launchSettings.json | 2 +- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs index a4b540d..9d5a9b5 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs @@ -108,5 +108,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Enum /// [ErrorCodeItemMetadata("操作成功,下发错误")] Code10016, + + /// + /// 名称或编码重复 + /// + [ErrorCodeItemMetadata("名称或编码重复")] + Code10017, } } diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs index 6526add..86a6f94 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs @@ -104,7 +104,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); } //3.物料查询 - var materialData = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Batching_Name == inputDto.DataInfo.Name); + var materialData = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Batching_Name == inputDto.DataInfo.Name || x.Code == inputDto.DataInfo.Code); if (materialData == null) { materialData = new BPA_Batching() @@ -157,7 +157,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service await _thirdpartyPushService.AddPushRecordAndPushDevice(inputDto, 2, materialData.Id, JsonConvert.SerializeObject(data)); } - + #endregion @@ -204,8 +204,6 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service { try { - - SqlSugarDb.Db.Ado.BeginTran(); //1.物料单位查询 var typeData = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Name == inputDto.DataInfo.TypeName); @@ -235,13 +233,21 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); } //3.物料查询 - var materialData = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Code == inputDto.DataInfo.Code); + var material = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Code == inputDto.DataInfo.Code || x.Batching_Name == inputDto.DataInfo.Name); + + var materialData = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Id == inputDto.DataInfo.Id); + if (materialData == null) { throw Oops.Oh(ErrorCodeEnum.Code1003); } else { + if (material != null && material.Id == materialData.Id) + { + throw Oops.Oh(ErrorCodeEnum.Code10017); + } + materialData = new BPA_Batching() { Id = Guid.NewGuid().ToString(), @@ -260,9 +266,34 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service }; SqlSugarDb.Db.Updateable(materialData).ExecuteCommand(); } + SqlSugarDb.Db.Ado.CommitTran(); + #region 下发数据到设备 + var data = new PushDataBatchingDto() + { + Aittribute = materialData.Aittribute, + AutoKey = materialData.AutoKey, + Code = materialData.Code, + ForeignKeyRe = materialData.ForeignKeyRe, + Id = materialData.Id, + Name = materialData.Batching_Name, + netrecovery = materialData.netrecovery, + outstockUint = materialData.outstockUint, + Price = materialData.Price, + proportion = materialData.proportion, + Specs = materialData.Specs, + StockUint = materialData.StockUint, + StockUintName = materialData.StockUint, + TypeID = materialData.TypeID, + }; + if (inputDto.IsPush) + { + await _thirdpartyPushService.AddPushRecordAndPushDevice(inputDto, 2, materialData.Id, + JsonConvert.SerializeObject(data)); + } - SqlSugarDb.Db.Ado.CommitTran(); + + #endregion return true; } catch (Exception e) diff --git a/BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json b/BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json index 86506d1..9571557 100644 --- a/BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json +++ b/BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json @@ -14,7 +14,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "dotnetRunMessages": true, - "applicationUrl": "http://192.168.1.17:5006" + "applicationUrl": "http://localhost:5006" }, "Docker": { "commandName": "Docker", From 7da09fcd13539ae92da56206af19e4d7782f6861 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Wed, 6 Mar 2024 16:51:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AExternalPlatform/Service/Material/MaterialServices.cs | 2 +- .../Service/Material/Services/IMaterialServices.cs | 2 +- .../Service/Material/Services/MaterialService.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/MaterialServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/MaterialServices.cs index 3c457ae..63d3d75 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/MaterialServices.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/MaterialServices.cs @@ -53,7 +53,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service /// /// [HttpPost("/api/ExternalPlatform/Material/DelMaterial")] - public async Task DelMaterial(BaseRequestDto inputDto) + public async Task DelMaterial(DelMaterialDto inputDto) { return await _materialServices.DelMaterial(inputDto); } diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/IMaterialServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/IMaterialServices.cs index f931d70..b4948a6 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/IMaterialServices.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/IMaterialServices.cs @@ -35,7 +35,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service /// /// /// - Task DelMaterial(BaseRequestDto inputDto); + Task DelMaterial(DelMaterialDto inputDto); /// diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs index 86a6f94..7b6dcd0 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs @@ -175,11 +175,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service /// /// /// - public async Task DelMaterial(BaseRequestDto inputDto) + public async Task DelMaterial(DelMaterialDto inputDto) { try { - var materialData = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Id == inputDto.DataInfo.MaterialId); + var materialData = await SqlSugarDb.Db.Queryable().FirstAsync(x => x.Id == inputDto.MaterialId); if (materialData == null) { throw Oops.Oh(ErrorCodeEnum.Code1003);