Parcourir la source

提交

master^2
gwbvipvip il y a 7 mois
Parent
révision
edf0f5b9a0
27 fichiers modifiés avec 815 ajouts et 31 suppressions
  1. +16
    -0
      BPA.KitChen.StoreManagement.Application/BaseDto/ResponDataBase.cs
  2. +3
    -4
      BPA.KitChen.StoreManagement.Application/Service/Device/DevicePushRecodeServices.cs
  3. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs
  4. +1
    -1
      BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/PushData.cs
  5. +71
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingDto.cs
  6. +19
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingInfoDto.cs
  7. +22
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingTypeDto.cs
  8. +22
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingUintDto.cs
  9. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/Class1.cs
  10. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/Class1.cs
  11. +35
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsAttributeDto.cs
  12. +27
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsInfoDto.cs
  13. +15
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsTypeDto.cs
  14. +14
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsUintDto.cs
  15. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/GoodsTechnology/Class1.cs
  16. +23
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/GoodsTechnology/GoodsTechnologysDto.cs
  17. +33
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/GoodsTechnology/TechnologyDto.cs
  18. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/ProductFunction/Class1.cs
  19. +91
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/ProductFunction/ProductFunctionDto.cs
  20. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Device/Services/Class1.cs
  21. +28
    -24
      BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs
  22. +3
    -2
      BPA.KitChen.StoreManagement.Application/Service/Device/Services/IDevicePushRecodeService.cs
  23. +264
    -0
      BPA.KitChen.StoreManagement.Application/Service/RequestParmsHeadlen.cs
  24. +18
    -0
      BPA.KitChen.StoreManagement.Core/Common/Const/ProductParametersConst_Batching.cs
  25. +19
    -0
      BPA.KitChen.StoreManagement.Core/Common/Const/ProductParametersConst_Goods.cs
  26. +17
    -0
      BPA.KitChen.StoreManagement.Core/Common/Const/ProductParametersConst_Technology.cs
  27. +2
    -0
      BPA.KitChen.StoreManagement/Program.cs

+ 16
- 0
BPA.KitChen.StoreManagement.Application/BaseDto/ResponDataBase.cs Voir le fichier

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.BaseDto
{
public class ResponDataBase
{
public string statusCode { get; set; }
public object data { get; set; }
public string succeeded { get; set; }
public string errors { get; set; }
}
}

+ 3
- 4
BPA.KitChen.StoreManagement.Application/Service/Device/DevicePushRecodeServices.cs Voir le fichier

@@ -1,7 +1,6 @@

using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.Service.Device;
using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos;
using BPA.KitChen.StoreManagement.Application.Service.Device.Services;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using System;
@@ -10,7 +9,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service
namespace BPA.SAAS.KitChenManage.Application.Device
{
[ApiDescriptionSettings("DevicePushRecode", Tag = "设备下发")]
public class DevicePushRecodeServices: IDynamicApiController


+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs Voir le fichier

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos
{
internal class Class1
{
}
}

BPA.KitChen.StoreManagement.Application/BaseDto/PushData.cs → BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/PushData.cs Voir le fichier

@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.BaseDto
namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos
{
public class PushData: IMessage
{

+ 71
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingDto.cs Voir le fichier

@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Batching
{
public class BatchingDto
{
public string Id { get; set; }
/// <summary>
/// 原料编码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 商品属性 (0成品,1半成品,2,易耗品)
/// </summary>
public int Aittribute { get; set; } = 0;
/// <summary>
/// 原料名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 配料类型
/// </summary>
public string TypeName { get; set; }
/// <summary>
/// 原料类型
/// </summary>
public string TypeID { get; set; }

/// <summary>
/// 库存单位
/// </summary>
public string StockUintName { get; set; }
public string StockUint { get; set; }
/// <summary>
/// 规格属性
/// </summary>
public string Specs { get; set; }


/// <summary>
/// 成本价
/// </summary>
public decimal Price { get; set; }

/// <summary>
/// 净料率
/// </summary>
public decimal netrecovery { get; set; }

/// <summary>
/// 出库单位
/// </summary>
public string outstockUint { get; set; }


/// <summary>
/// 换算比例
/// </summary>
public decimal proportion { get; set; }


public int AutoKey { get; set; }
public string ForeignKeyRe { get; set; }
public string CreateAt { get; set; }
}
}

+ 19
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingInfoDto.cs Voir le fichier

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Batching
{
public class BatchingInfoDto
{
public string id { get; set; }
public string name { get; set; }
public string typeId { get; set; }
public string typeName { get; set; }
public string stockUintName { get; set; }
public string stockUint { get; set; }
public string createAt { get; set; }
}
}

+ 22
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingTypeDto.cs Voir le fichier

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Batching
{
public class BatchingTypeDto
{
public string Id { get; set; }
/// <summary>
/// 单位名称
/// </summary>

public string Name { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

+ 22
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/BatchingUintDto.cs Voir le fichier

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Batching
{
public class BatchingUintDto
{
public string Id { get; set; }
/// <summary>
/// 单位名称
/// </summary>

public string Name { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Batching/Class1.cs Voir le fichier

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Batching
{
internal class Class1
{
}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/Class1.cs Voir le fichier

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Goods
{
internal class Class1
{
}
}

+ 35
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsAttributeDto.cs Voir le fichier

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Goods
{
public class GoodsAttributeDto
{
public string Id { get; set; }
/// <summary>
/// 属性名称
/// </summary>
public string AttributeName { get; set; }
/// <summary>
/// 商品小类id
/// </summary>
public string GoodsTypeId { get; set; }
public List<GoodsAttributeValue> AttributeValueList { get; set; }
public int Sort { get; set; }
}
public class GoodsAttributeValue
{
public string Id { get; set; }
/// <summary>
///商品属性id
/// </summary>
public string GoodsAttributeId { get; set; }
/// <summary>
/// 属性值
/// </summary>
public string AttributeValue { get; set; }
}
}

+ 27
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsInfoDto.cs Voir le fichier

@@ -0,0 +1,27 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Goods
{
public class GoodsInfoDto
{
public string Id { get; set; }
public string Name { get; set; }
public string Descritption { get; set; }
public string ImgUrl { get; set; }
public int Sort { get; set; }
public decimal Price { get; set; }
public string GoodsUintId { get; set; }
public string GoodsUintName { get; set; }
public bool IsWeigh { get; set; }
public string Design { get; set; }
public string DefaultMate { get; set; }
public bool IsAttrubute { get; set; }
public string GoodsTypeId { get; set; }
public string GoodsTypeName { get; set; }
}
}

+ 15
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsTypeDto.cs Voir le fichier

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Goods
{
public class GoodsTypeDto
{
public string Id { get; set; }
public string Pid { get; set; }
public string Name { get; set; }
}
}

+ 14
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/Goods/GoodsUintDto.cs Voir le fichier

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Goods
{
public class GoodsUintDto
{
public string Id { get; set; }
public string Name { get; set; }
}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/GoodsTechnology/Class1.cs Voir le fichier

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.GoodsTechnology
{
internal class Class1
{
}
}

+ 23
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/GoodsTechnology/GoodsTechnologysDto.cs Voir le fichier

@@ -0,0 +1,23 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.GoodsTechnology
{
public class GoodsTechnologysDto
{
public string Id { get; set; }
public string StepName { get; set; }
//[JsonIgnore]
public string ActionJson { get; set; }
public string GoodsAttributeId { get; set; }
public string GoodsId { get; set; }
public string DeviceId { get; set; }
public string ChnologyId { get; set; }
public string Sort { get; set; }
public string CreateBy { get; set; }
}
}

+ 33
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/GoodsTechnology/TechnologyDto.cs Voir le fichier

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.GoodsTechnology
{
public class TechnologyDto
{
public string Id { get; set; }
public string Name { get; set; }
public string DeviceVersionId { get; set; }
public string ForeignKeyRe { get; set; }
public DateTime CreateAt { get; set; }
public List<TechnologyAction> TechnologyActionInfo { get; set; }
}
public class TechnologyAction
{
public string Id { get; set; }
public string TechnologyId { get; set; }
public string ActionName { get; set; }
public string ActionValue { get; set; }
public string ActionType { get; set; }
public string Unit { get; set; }
/// <summary>
/// 工艺模型类型(标识是否物料 1标识物料 0标识其他)
/// </summary>
public int TechnologyType { get; set; }
public DateTime CreateAt { get; set; }
public int Sort { get; set; }
}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/ProductFunction/Class1.cs Voir le fichier

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.ProductFunction
{
internal class Class1
{
}
}

+ 91
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/PushDto/ProductFunction/ProductFunctionDto.cs Voir le fichier

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.ProductFunction
{
public class ProductFunctionDto
{
public string Id { get; set; }
/// <summary>
/// 功能名称
/// </summary>
public string Name { get; set; }
public string DeviceVersionKey { get; set; }
/// <summary>
/// 功能类型 0属性1服务2事件
/// </summary>
public string Type { get; set; }
/// <summary>
/// 数据类型
/// </summary>
public string DataType { get; set; }
/// <summary>
/// 取值范围
/// </summary>
public string DataRange { get; set; }
/// <summary>
/// 单位
/// </summary>
public string Unit { get; set; }
/// <summary>
/// 步长
/// </summary>
public decimal StepSize { get; set; }
/// <summary>
/// 枚举值
/// </summary>
public string EnumValue { get; set; }
/// <summary>
/// 数据长度
/// </summary>
public string DataLength { get; set; }
/// <summary>
/// 数据类型bool的描述
/// </summary>
public string BoolLabel { get; set; }
/// <summary>
/// 读写类型0读写 1只读
/// </summary>
public int ReadWrite { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
public string ProductId { get; set; }
public string DataJson { get; set; }
public bool IsDefault { get; set; }
public List<ProductFunctionAction> ProductFunctionValue { get; set; }
}
public class ProductFunctionAction
{
public string Id { get; set; }
/// <summary>
/// 功能id
/// </summary>
public string ProductFunctionId { get; set; }
/// <summary>
/// 动作名称
/// </summary>
public string ActionName { get; set; }
/// <summary>
/// 类型 (1 输入框 2下拉框)
/// </summary>
public string ActionType { get; set; }
/// <summary>
/// 类型值(jsong格式)
/// </summary>
public string ActionValue { get; set; }
/// <summary>
/// 单位
/// </summary>
public string Unit { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
public bool IsDefault { get; set; }
}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Device/Services/Class1.cs Voir le fichier

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device.Services
{
internal class Class1
{
}
}

+ 28
- 24
BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs Voir le fichier

@@ -2,11 +2,13 @@
using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos;
using BPA.KitChen.StoreManagement.Core.Entity;
using BPA.KitChen.StoreManagement.Core.Enum;
using BPA.KitChen.StoreManagement.SqlSugar;
using BPA.Message;
using BPA.Message.IOT;
using Furion.DependencyInjection;
using Furion.FriendlyException;
using Furion.LinqBuilder;
using Furion.RemoteRequest.Extensions;
using Mapster;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.Extensions.Hosting;
@@ -21,16 +23,17 @@ using System.Net.Http.Json;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device
namespace BPA.KitChen.StoreManagement.Application.Service.Device.Services
{
public class DevicePushRecodeService: IDevicePushRecodeService, ITransient
{
private readonly ISqlSugarClient _db;
private readonly SqlSugarScope _db;
private readonly IMqttClient _mqttClient;
public DevicePushRecodeService(ISqlSugarClient db, IMqttClient mqttClient)
RequestParmsHeadlen requestParmsHeadlen = new();
public DevicePushRecodeService( IMqttClient mqttClient)
{
_db = db;
_mqttClient=mqttClient;
_db = SqlSugarDb.Db;
_mqttClient =mqttClient;
}
/// <summary>
/// 分页
@@ -40,23 +43,22 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device
public async Task<PageUtil> Page(DevicePushRecodeDtoPageInput input)
{
RefAsync<int> total = 0;
var res = await _db.Queryable<BPA_DevicePushRecode>().Where(x => x.Type == input.Type)
.WhereIF(!string.IsNullOrWhiteSpace(input.DeviceName), x => x.DeviceName.Contains(input.DeviceName))
.WhereIF(!string.IsNullOrWhiteSpace(input.Status), x => x.Status == (CommonStatus)Convert.ToInt32(input.Status))
.Select(t => new
{
CreateAt = t.CreateAt,
CreateBy = t.CreateBy,
Id = t.Id,
DeviceId = t.DeviceId,
DeviceName = t.DeviceName,
Type = t.Type,
Topic = t.Topic,
DataResore = t.DataResore,
Status = t.Status,
Description = t.Description,
}).OrderBy(x => x.CreateAt, OrderByType.Desc)
.ToPageListAsync(input.Current, input.PageSize, total);
var res = await _db.Queryable<BPA_DevicePushRecode>().Where(x=>x.Type== input.Type)
.WhereIF(!string.IsNullOrWhiteSpace(input.DeviceName),x=>x.DeviceName.Contains(input.DeviceName))
.WhereIF(!string.IsNullOrWhiteSpace(input.Status), x => x.Status == (CommonStatus)Convert.ToInt32(input.Status))
.Select(t => new
{
CreateAt = t.CreateAt,
CreateBy = t.CreateBy,
Id = t.Id,
DeviceId = t.DeviceId,
DeviceName= t.DeviceName,
Type =t.Type,
Topic=t.Topic,
DataResore=t.DataResore,
Status=t.Status,
Description=t.Description,
}).OrderBy(x => x.CreateAt, OrderByType.Desc).ToPageListAsync(input.Current, input.PageSize, total);
PageUtil util = new PageUtil()
{
Total = total,
@@ -72,6 +74,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device
/// <returns></returns>
public async Task<bool> Add(DevicePushRecodeDtoInput input)
{
var DataResore =await requestParmsHeadlen.GetParm(input.Type, input.Data.ToString(), input.DeviceId);
var data = input.Adapt<BPA_DevicePushRecode>();
string topstr = "";
string Topic = GetTopic(input.Type, input.DeviceAutoKey.ToString(), input.ProductVersion, input.ProductKey, out topstr);
@@ -79,7 +82,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device
data.Topic= Topic;
data.Status = CommonStatus.ENABLE;
data.DataResore = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<dynamic>(input.Data.ToString()));
data.DataResore = JsonConvert.SerializeObject(DataResore);
data.DeviceAutoKey= input.DeviceAutoKey;
data.Description = "成功";
if (input.TopicsData.Count > 0)
@@ -102,9 +105,10 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device
if (respush != "success")
{
data.Description = respush;
data.Status = CommonStatus.DISABLE;
data.Status = CommonStatus.ENABLE;
}
}
// return true;
var res = await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();
return res>0;
}


+ 3
- 2
BPA.KitChen.StoreManagement.Application/Service/Device/Services/IDevicePushRecodeService.cs Voir le fichier

@@ -1,4 +1,5 @@
using BPA.KitChen.StoreManagement.Application.BaseDto;

using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos;
using System;
using System.Collections.Generic;
@@ -6,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Application.Service.Device
namespace BPA.KitChen.StoreManagement.Application.Service.Device.Services
{
public interface IDevicePushRecodeService
{


+ 264
- 0
BPA.KitChen.StoreManagement.Application/Service/RequestParmsHeadlen.cs Voir le fichier

@@ -0,0 +1,264 @@
using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Batching;
using BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.Goods;
using BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.GoodsTechnology;
using BPA.KitChen.StoreManagement.Application.Service.Device.PushDto.ProductFunction;
using BPA.KitChen.StoreManagement.Core.Common.Const;
using Furion;
using Furion.FriendlyException;
using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json;
using System.Reflection;

namespace BPA.KitChen.StoreManagement.Application.Service
{
public class RequestParmsHeadlen
{
private string BaseServerUrl = App.GetConfig<string>("SAAS_Manage");
public async Task<dynamic> GetParm(int type, string data, string deviceId)
{
var getProductFunctionurl = BaseServerUrl + "api/productfunction/getproductfunction_alm?deviceId=" + deviceId;//获取商品属性
var responseProductFunction = await getProductFunctionurl.SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resProductFunction = JsonConvert.DeserializeObject<ResponDataBase>(responseProductFunction);
if (resProductFunction.statusCode != "200") throw Oops.Oh("获取该设备的物模型数据失败");
if (resProductFunction.data == null) throw Oops.Oh("找不到设备的物模型配置,请配置相关参数后再试");
var dataProductFunction = JsonConvert.DeserializeObject<List<ProductFunctionDto>>(resProductFunction.data.ToString());
dynamic obj = null;
switch (type)
{
case 1: //商品下发
var GoodsFunction = dataProductFunction.Where(x => x.Name == "商品数据下发" && x.Type == "1").FirstOrDefault();
if (GoodsFunction == null) throw Oops.Oh("该设备的物模型还没配置对应功能,请配置相关参数后再试");
var GoodsFunctionValue = GoodsFunction.ProductFunctionValue.Where(x => x.IsDefault == true && x.ActionName == "DataSoure").First();
if (string.IsNullOrEmpty(GoodsFunctionValue.ActionValue)) throw Oops.Oh("该设备的物模型配置对应功能参数没有配置,请配置相关参数后再试");
obj = await GetGoods(data, GoodsFunctionValue.ActionValue);
break;
case 2://物料下发
var BatchingFunction = dataProductFunction.Where(x => x.Name == "物料数据下发" && x.Type == "1").FirstOrDefault();
if (BatchingFunction == null) throw Oops.Oh("该设备的物模型还没配置对应功能,请配置相关参数后再试");
var BatchingFunctionValue = BatchingFunction.ProductFunctionValue.Where(x => x.IsDefault == true && x.ActionName == "DataSoure").First();
if (string.IsNullOrEmpty(BatchingFunctionValue.ActionValue)) throw Oops.Oh("该设备的物模型配置对应功能参数没有配置,请配置相关参数后再试");
obj = await GetBatching(data, BatchingFunctionValue.ActionValue);
break;
case 4:
var TechnologyFunction = dataProductFunction.Where(x => x.Name == "工艺数据下发" && x.Type == "1").FirstOrDefault();
if (TechnologyFunction == null) throw Oops.Oh("该设备的物模型还没配置对应功能,请配置相关参数后再试");
var TechnologyFunctionValue = TechnologyFunction.ProductFunctionValue.Where(x => x.IsDefault == true && x.ActionName == "DataSoure").First();
if (string.IsNullOrEmpty(TechnologyFunctionValue.ActionValue)) throw Oops.Oh("该设备的物模型配置对应功能参数没有配置,请配置相关参数后再试");
obj = await GetGoodsTechnology(data, deviceId, TechnologyFunctionValue.ActionValue);
break;
}
return obj;

}
private async Task<dynamic> GetGoods(string data, string productFunctionData)
{
try
{
//商品信息
var goodsData = JsonConvert.DeserializeObject<List<GoodsInfoDto>>(data);

var cpjson = productFunctionData.Replace("\r", "").Replace("\n", "").Replace("\t", "");
var DynamicObject = JsonConvert.DeserializeObject<dynamic>(cpjson);
//商品信息
if (IsPropertyExist(DynamicObject, ProductParametersConst_Goods.goodsinfo))
{
var goodsinfo = GetDynamic(goodsData, DynamicObject.goodsinfo[0]);
DynamicObject.goodsinfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(goodsinfo));
}
//商品属性
if (IsPropertyExist(DynamicObject, ProductParametersConst_Goods.goodsAttribute))
{
//获取商品属性
var getGoodsAttributeurl = BaseServerUrl + "api/goodsattribute/getgoodsattributelist_alm";//获取商品属性
var responseGoodsAttribute = await getGoodsAttributeurl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resGoodsAttribute = JsonConvert.DeserializeObject<ResponDataBase>(responseGoodsAttribute);
if (resGoodsAttribute.statusCode != "200") throw Oops.Oh("获取商品属性数据失败");
var dataGoodsAttribute = JsonConvert.DeserializeObject<List<GoodsAttributeDto>>(resGoodsAttribute.data.ToString());
var goodsAttribute = GetDynamic(dataGoodsAttribute, DynamicObject.goodsAttribute[0]);
DynamicObject.goodsAttribute = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(goodsAttribute));
}
//商品单位
if (IsPropertyExist(DynamicObject, ProductParametersConst_Goods.goodsUnitInfo))
{
//获商品单位
var getGoodsUinturl = BaseServerUrl + "api/goods/getgoodsuintlist_alm";//获商品单位
var responseGoodsUint = await getGoodsUinturl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resGoodsUint = JsonConvert.DeserializeObject<ResponDataBase>(responseGoodsUint);
if (resGoodsUint.statusCode != "200") throw Oops.Oh("获取商品单位数据失败");
var dataGoodsUint = JsonConvert.DeserializeObject<List<GoodsUintDto>>(resGoodsUint.data.ToString());
var goodsUnitInfo = GetDynamic(dataGoodsUint, DynamicObject.goodsUnitInfo[0]);
DynamicObject.goodsUnitInfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(goodsUnitInfo));
}
//商品分类
if (IsPropertyExist(DynamicObject, ProductParametersConst_Goods.goodsTypeInfo))
{
//获取商品分类
var getGoodsTypeturl = BaseServerUrl + "api/goodstype/getgoodstypelist_alm";//获取商品分类
var responseGoodsType = await getGoodsTypeturl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resGoodsType = JsonConvert.DeserializeObject<ResponDataBase>(responseGoodsType);
if (resGoodsType.statusCode != "200") throw Oops.Oh("获取商品分类数据失败");
var dataGoodsType = JsonConvert.DeserializeObject<List<GoodsTypeDto>>(resGoodsType.data.ToString());
var goodsTypeInfo = GetDynamic(dataGoodsType, DynamicObject.goodsTypeInfo[0]);
DynamicObject.goodsTypeInfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(goodsTypeInfo));
}
return DynamicObject;
}
catch (Exception e)
{
throw Oops.Oh("解析数据失败");
}

}
private async Task<dynamic> GetBatching(string data, string productFunctionData)
{
try
{
var cpjson = productFunctionData.Replace("\r", "").Replace("\n", "").Replace("\t", "");
var DynamicObject = JsonConvert.DeserializeObject<dynamic>(cpjson);
if (IsPropertyExist(DynamicObject, ProductParametersConst_Batching.batchinginfo))
{
//物料信息
var batchingData = JsonConvert.DeserializeObject<List<BatchingDto>>(data);
var batchinginfo = GetDynamic(batchingData, DynamicObject.batchinginfo[0]);
DynamicObject.batchinginfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(batchinginfo));
}
if (IsPropertyExist(DynamicObject, ProductParametersConst_Batching.batchingTypeinfo))
{
//获取物料分类
var getTypeurl = BaseServerUrl + "api/batching/getbatchingtypelist_alm";//获取物料分类
var responseType = await getTypeurl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resType = JsonConvert.DeserializeObject<ResponDataBase>(responseType);
if (resType.statusCode != "200") throw Oops.Oh("获取物料分类数据失败");
var dataType = JsonConvert.DeserializeObject<List<BatchingTypeDto>>(resType.data.ToString());
var batchingTypeinfo = GetDynamic(dataType, DynamicObject.batchingTypeinfo[0]);
DynamicObject.batchingTypeinfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(batchingTypeinfo));
}
if (IsPropertyExist(DynamicObject, ProductParametersConst_Batching.batchingUnitinfo))
{
//获取物料单位
var getuinurl = BaseServerUrl + "api/batching/getbatchinguintList_alm";//获取物料单位
var responseUnit = await getuinurl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resUnit = JsonConvert.DeserializeObject<ResponDataBase>(responseUnit);
if (resUnit.statusCode != "200") throw Oops.Oh("获取物料单位数据失败");
var dataUnit = JsonConvert.DeserializeObject<List<BatchingUintDto>>(resUnit.data.ToString());
var batchingUnitinfo = GetDynamic(dataUnit, DynamicObject.batchingUnitinfo[0]);
DynamicObject.batchingUnitinfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(batchingUnitinfo));
}
return DynamicObject;
}
catch (Exception)
{
throw Oops.Oh("解析数据失败");
}

}
private async Task<dynamic> GetGoodsTechnology(string data, string deviceId, string productFunctionData)
{
try
{
//商品工艺信息
var goodsTechnologData = JsonConvert.DeserializeObject<List<GoodsTechnologysDto>>(data);

var cpjson = productFunctionData.Replace("\r", "").Replace("\n", "").Replace("\t", "");
var DynamicObject = JsonConvert.DeserializeObject<dynamic>(cpjson);
if (IsPropertyExist(DynamicObject, ProductParametersConst_Technology.technologysInfo))
{
//获取工艺基础信息
var gettechnologurl = BaseServerUrl + "api/technology/gettechnologylist_alm?deviceId=" + deviceId;//获取工艺基础信息
var responsegetTechnologurl = await gettechnologurl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resTechnolog = JsonConvert.DeserializeObject<ResponDataBase>(responsegetTechnologurl);
if (resTechnolog.statusCode != "200") throw Oops.Oh("获取工艺基础信息数据失败");
var dataTechnolog = JsonConvert.DeserializeObject<List<TechnologyDto>>(resTechnolog.data.ToString());
var technologysInfo = GetDynamic(dataTechnolog, DynamicObject.technologysInfo[0]);
DynamicObject.technologysInfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(technologysInfo));
}
if (IsPropertyExist(DynamicObject, ProductParametersConst_Technology.goodsTechnologysInfo))
{
var goodsTechnologysInfo = GetDynamic(goodsTechnologData, DynamicObject.goodsTechnologysInfo[0]);
DynamicObject.goodsTechnologysInfo = JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(goodsTechnologysInfo));
}
return DynamicObject;
}
catch (Exception)
{
throw Oops.Oh("解析数据失败");
}

}
/// <summary>
/// 映射数据
/// </summary>
/// <param name="data1"></param>
/// <param name="data2"></param>
/// <returns></returns>
private List<Dictionary<string, object>> GetDynamic(dynamic data1, dynamic data2)
{
List<Dictionary<string, object>> objws = new();
foreach (var item in data1)
{
PropertyInfo[] properties = item.GetType().GetProperties(); // 获取所有公共属性
Dictionary<string, object> objw = new();
foreach (var property in properties)
{
object value = property.GetValue(item);


foreach (var property1 in data2)
{

if (property.Name.ToLower() == property1?.Name?.ToLower())
{
Type dataType = property.PropertyType;
if (dataType.IsGenericType)
{
var sd = data2[property1.Name][0];
objw.Add(property1.Name, GetDynamic(value, sd));
}
else
{
objw.Add(property1.Name, value);
}
}
}
}
objws.Add(objw);
}
return objws;
}
/// <summary>
/// 验证属性是否存在
/// </summary>
/// <param name="data"></param>
/// <param name="propertyname"></param>
/// <returns></returns>
private bool IsPropertyExist(dynamic data, string propertyname)
{
var check = false;
var sd = data.GetType().GetProperty(propertyname);
foreach (var property1 in data)
{
if (property1.Name == propertyname) check = true;
}
return check;
}
}
}

+ 18
- 0
BPA.KitChen.StoreManagement.Core/Common/Const/ProductParametersConst_Batching.cs Voir le fichier

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Core.Common.Const
{
/// <summary>
/// 产品物模型对应的服务参数常量
/// </summary>
public class ProductParametersConst_Batching
{
public const string batchinginfo = "batchinginfo";
public const string batchingTypeinfo = "batchingTypeinfo";
public const string batchingUnitinfo = "batchingUnitinfo";
}
}

+ 19
- 0
BPA.KitChen.StoreManagement.Core/Common/Const/ProductParametersConst_Goods.cs Voir le fichier

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Core.Common.Const
{
/// <summary>
/// 产品物模型对应的服务参数常量
/// </summary>
public class ProductParametersConst_Goods
{
public const string goodsinfo = "goodsinfo";
public const string goodsAttribute = "goodsAttribute";
public const string goodsUnitInfo = "goodsUnitInfo";
public const string goodsTypeInfo = "goodsTypeInfo";
}
}

+ 17
- 0
BPA.KitChen.StoreManagement.Core/Common/Const/ProductParametersConst_Technology.cs Voir le fichier

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.StoreManagement.Core.Common.Const
{
/// <summary>
/// 产品物模型对应的服务参数常量
/// </summary>
public class ProductParametersConst_Technology
{
public const string technologysInfo = "technologysInfo";
public const string goodsTechnologysInfo = "goodsTechnologysInfo";
}
}

+ 2
- 0
BPA.KitChen.StoreManagement/Program.cs Voir le fichier

@@ -7,6 +7,7 @@ using Furion;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using Newtonsoft.Json.Linq;
using ProtoBuf.Meta;
using SqlSugar;

var builder = WebApplication.CreateBuilder(args).Inject();
@@ -53,6 +54,7 @@ CosConfig.cosInfoOptions = new CosInfoOptions(App.Configuration["cos_config:AppI
builder.Services.AddUnifyResult();

builder.Services.AddControllers().AddInject();
builder.Services.AddRemoteRequest();
builder.Services.AddSqlsugarSetup();




Chargement…
Annuler
Enregistrer