From 06538be2a70783ed6d20ae896451d125918bcde2 Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Thu, 7 Mar 2024 13:15:42 +0800 Subject: [PATCH] z --- .../AExternalPlatform/Enum/ErrorCodeEnum.cs | 10 ++++++ .../Service/Device/Dtos/DeviceInsertDto.cs | 4 +-- .../Service/Device/Dtos/DeviceUpateDto.cs | 2 +- .../Service/Device/Services/DeviceService.cs | 36 ++++++++++--------- .../Services/WarehouseTemplateService.cs | 2 +- .../Device/Dtos/Device/DeviceInfoBaseDto.cs | 9 +++-- .../Device/Services/DeviceService.cs | 14 ++++---- BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs | 4 +-- BPA.SAAS.Manage.Web.Core/Startup.cs | 1 + .../Properties/launchSettings.json | 2 +- 10 files changed, 48 insertions(+), 36 deletions(-) diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs index 20bc9e5..1de6d99 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs @@ -129,5 +129,15 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Enum /// [ErrorCodeItemMetadata("模板名称不能为空")] Code10020, + /// + /// 获取场景数据失败 + /// + [ErrorCodeItemMetadata("获取场景数据失败")] + Code10021, + /// + /// 场景不存在 + /// + [ErrorCodeItemMetadata("场景不存在")] + Code10022, } } diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceInsertDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceInsertDto.cs index f96a037..d320ea0 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceInsertDto.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceInsertDto.cs @@ -27,9 +27,9 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos /// public string ProductId { get; set; } /// - /// 产品标签 + /// 设备标签名称 /// - public string ProductCode { get; set; } + public string DeviceTypeName { get; set; } /// /// 产品版本 /// diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceUpateDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceUpateDto.cs index a9ab1a0..b2ea614 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceUpateDto.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceUpateDto.cs @@ -29,7 +29,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos /// /// 产品标签 /// - public string ProductCode { get; set; } + public string DeviceTypeName { get; set; } /// /// 产品版本 /// diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs index 8c0f0c2..dfd245c 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs @@ -1,4 +1,5 @@ using BPA.KitChen.GroupMeal.SqlSugar; +using BPA.SAAS.KitChenManage.Core; using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos; @@ -32,7 +33,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services /// public async Task>> GetDevicePageList(DevicePageInputDto inputDto) { - int total = new RefAsync(); + RefAsync total = 0; var data =await SqlSugarDb.Db.Queryable((a, b,c) => new JoinQueryInfos(JoinType.Left, a.ProductId == b.Id, JoinType.Left, a.ProductVersionId == c.Id)) .WhereIF(!string.IsNullOrEmpty(inputDto.ProductName), (a, b, c) => b.Name.Contains(inputDto.ProductName)) @@ -67,7 +68,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services resEntity.StopId = dto.StopId; resEntity.ProductId = dto.ProductId; resEntity.ProductVersionId = dto.ProductVersionId; - var check = SqlSugarDb.Db.Queryable().Where(x => x.Name == dto.ProductCode).First(); + var check = SqlSugarDb.Db.Queryable().Where(x => x.Name == dto.DeviceTypeName).First(); if (check != null) { resEntity.DeviceTypeId = check.Id; @@ -89,10 +90,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services SqlSugarDb.Db.CommitTran(); return res > 0; } - catch (Exception) + catch (Exception ex) { SqlSugarDb.Db.RollbackTran(); - throw Oops.Oh(ErrorCodeEnum.Code1007); + throw Oops.Oh(ErrorCodeEnum.Code1007+","+ex.Message); } } @@ -109,9 +110,9 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services resEntity.StopId = dto.StopId; resEntity.ProductId = dto.ProductId; resEntity.ProductVersionId = dto.ProductVersionId; - if (!string.IsNullOrWhiteSpace(dto.ProductCode)) + if (!string.IsNullOrWhiteSpace(dto.DeviceTypeName)) { - var check = SqlSugarDb.Db.Queryable().Where(x => x.Name == dto.ProductCode).First(); + var check = SqlSugarDb.Db.Queryable().Where(x => x.Name == dto.DeviceTypeName).First(); if (check != null) { resEntity.DeviceTypeId = check.Id; @@ -161,13 +162,14 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services var getStopurl = BaseServerUrl + "api/store/getbyIdstorelist_alm?id=" + dto.StopId; var responseStop = await getStopurl.SetHeaders(new { - groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value + groupId = CurrentUser.GroupId }).SetHttpMethod(HttpMethod.Get).GetAsStringAsync(); - var resStop = JsonConvert.DeserializeObject(responseStop); - if (resStop.statusCode != "200") throw Oops.Oh("获取场景数据失败"); - var dataStop = JsonConvert.DeserializeObject>(resStop.data.ToString()); - if (dataStop.Count==0) throw Oops.Oh("获取场景数据失败"); - if(!dataStop.Where(x=>x.Id == dto.StopId).Any()) throw Oops.Oh("场景不存在"); + var responData = JsonConvert.DeserializeObject(responseStop); + var resStop = JsonConvert.DeserializeObject (responData.data.ToString()); + if (responData.statusCode != "200") throw Oops.Oh(ErrorCodeEnum.Code10021); + //var dataStop = responData?.data; + if (resStop == null) throw Oops.Oh(ErrorCodeEnum.Code10022); + // if(!dataStop.Where(x=>x.Id == dto.StopId).Any()) throw Oops.Oh(ErrorCodeEnum.Code10022); var checkProduct = SqlSugarDb.Db.Queryable().Where(x => x.Id == dto.ProductId).Any(); if (!checkProduct) throw Oops.Oh(ErrorCodeEnum.Code10010); @@ -187,11 +189,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services { groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value }).SetHttpMethod(HttpMethod.Get).GetAsStringAsync(); - var resStop = JsonConvert.DeserializeObject(responseStop); - if (resStop.statusCode != "200") throw Oops.Oh("获取场景数据失败"); - var dataStop = JsonConvert.DeserializeObject>(resStop.data.ToString()); - if (dataStop.Count == 0) throw Oops.Oh("获取场景数据失败"); - if (!dataStop.Where(x => x.Id == dto.StopId).Any()) throw Oops.Oh("场景不存在"); + var responData = JsonConvert.DeserializeObject(responseStop); + var resStop = JsonConvert.DeserializeObject(responData.data.ToString()); + if (responData.statusCode != "200") throw Oops.Oh(ErrorCodeEnum.Code10021); + //var dataStop = responData?.data; + if (resStop == null) throw Oops.Oh(ErrorCodeEnum.Code10022); var checkProduct = SqlSugarDb.Db.Queryable().Where(x => x.Id == dto.ProductId).Any(); if (!checkProduct) throw Oops.Oh(ErrorCodeEnum.Code10010); diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs index bb82c63..c6358f2 100644 --- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs +++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs @@ -19,7 +19,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplat { public async Task GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto) { - var total = new RefAsync(); + RefAsync total = 0; var data = await SqlSugarDb.Db.Queryable((a, b, c) => new JoinQueryInfos(JoinType.Left, a.DeviceId == b.Id, JoinType.Left, b.ProductVersionId == c.Id)) .WhereIF(!string.IsNullOrWhiteSpace(inputDto.TemplateName), (a, b, c) => a.TemplateName.Contains(inputDto.TemplateName)) .WhereIF(!string.IsNullOrWhiteSpace(inputDto.DeviceName), (a, b, c) => a.DeviceId.Contains(inputDto.DeviceName)) diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceInfoBaseDto.cs b/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceInfoBaseDto.cs index 2717cb1..603cfaa 100644 --- a/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceInfoBaseDto.cs +++ b/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceInfoBaseDto.cs @@ -27,15 +27,14 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.Device /// 所属产品 /// public string ProductId { get; set; } - /// - /// 产品标签 - /// - public string ProductCode { get; set; } + ///// + ///// 产品标签 + ///// + //public string ProductCode { get; set; } /// /// 产品版本 /// public string ProductVersionId { get; set; } public CommonStatus Status { get; set; } - public int TechnologyOrBom { get; set; } } } diff --git a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs index e078d08..82add76 100644 --- a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs +++ b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs @@ -57,7 +57,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services { var Vesion = _db.Queryable().Where(c => c.Id == x.ProductVersionId).First(); x.ProductVersionName = Vesion?.Vesion; - //x.StopName= dataStore?.Where(f=>f.Id==x.StopId).First()?.Name; + // x.StopName= dataStore?.Where(f=>f.Id==x.StopId).First()?.Name; }) .ToPageListAsync(inputDto.Current, inputDto.PageSize, total); return new PageUtil() @@ -129,9 +129,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services BPA_DeviceInfo bPA_DeviceInfo = inputDto.Adapt(); var product=_db.Queryable().Where(x => x.Id == inputDto.ProductId).First(); bPA_DeviceInfo.Status = CommonStatus.ENABLE; - bPA_DeviceInfo.ProductCode= product?.Code; + //bPA_DeviceInfo.ProductCode= product?.Code; var res =await _db.Insertable(bPA_DeviceInfo) .CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); - mqttsub(res.AutoKey, res.ProductCode); + //mqttsub(res.AutoKey, product?.Code); return res != null; } /// @@ -145,10 +145,10 @@ namespace BPA.SAAS.Manage.Application.Device.Services if (data != null) { - mqttsub(data.AutoKey, data.ProductCode); + //mqttsub(data.AutoKey, data.ProductCode); var product = _db.Queryable().Where(x => x.Id == inputDto.ProductId).First(); var inputData = inputDto.Adapt(); - inputData.ProductCode = product?.Code; + //inputData.ProductCode = product?.Code; var res = await _db.Updateable(inputData) .UpdateColumns(x => new { @@ -156,10 +156,10 @@ namespace BPA.SAAS.Manage.Application.Device.Services x.DeviceTypeId, x.StopId, x.ProductId, - x.ProductCode, + //x.ProductCode, x.Status, x.ProductVersionId, - x.TechnologyOrBom + // x.TechnologyOrBom }) .Where(x => x.Id == inputDto.Id).ExecuteCommandAsync(); diff --git a/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs b/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs index fd99008..d6f63b5 100644 --- a/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs +++ b/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs @@ -35,7 +35,7 @@ namespace BPA.SAAS.Manage.Core.Device /// /// 产品标签 /// - public string ProductCode { get; set; } + //public string ProductCode { get; set; } /// /// 状态 【正常 停用】默认 正常 /// @@ -54,6 +54,6 @@ namespace BPA.SAAS.Manage.Core.Device /// /// 支持工艺还是配方 0工艺 1配方 /// - public int TechnologyOrBom { get; set; } + //public int TechnologyOrBom { get; set; } } } diff --git a/BPA.SAAS.Manage.Web.Core/Startup.cs b/BPA.SAAS.Manage.Web.Core/Startup.cs index 01382fe..bcfaaa4 100644 --- a/BPA.SAAS.Manage.Web.Core/Startup.cs +++ b/BPA.SAAS.Manage.Web.Core/Startup.cs @@ -64,6 +64,7 @@ namespace BPA.SAAS.Manage.Web.Core }); }); + services.AddRemoteRequest(); services.AddCorsAccessor(); services.AddSqlsugarSetup(App.Configuration); services.AddControllers() diff --git a/BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json b/BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json index 86506d1..7a77227 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://192.168.1.19:5006" }, "Docker": { "commandName": "Docker",