Pārlūkot izejas kodu

Merge branch 'reconfiguration' of http://111.9.47.105:10244/bpa/BPASmartClient into reconfiguration

JXJAgvReake
ZhaoGang pirms 1 gada
vecāks
revīzija
4fddadf09d
21 mainītis faili ar 538 papildinājumiem un 11 dzēšanām
  1. +5
    -1
      BPASmartClient.Business/Plugin/MQTTMgr.cs
  2. +1
    -1
      BPASmartClient.IoT/Model/DataVReport.cs
  3. +4
    -0
      BPASmartClient.Tourism/BPASmartClient.MorkCL.csproj
  4. +1
    -0
      BPASmartClient.Tourism/Model/ControlData.cs
  5. +15
    -0
      BPASmartClient.Tourism/Model/DB/AccessoriesTB.cs
  6. +15
    -0
      BPASmartClient.Tourism/Model/DB/IngredientsTB.cs
  7. +33
    -0
      BPASmartClient.Tourism/Model/DB/MaterialBase.cs
  8. +15
    -0
      BPASmartClient.Tourism/Model/DB/SeasoningTB.cs
  9. +1
    -1
      BPASmartClient.Tourism/Model/DataInfo/AccessoriesInfo.cs
  10. +1
    -1
      BPASmartClient.Tourism/Model/DataInfo/IngredientsInfo.cs
  11. +3
    -3
      BPASmartClient.Tourism/Model/DataInfo/RawMaterial.cs
  12. +1
    -1
      BPASmartClient.Tourism/Model/DataInfo/SeasoningInfo.cs
  13. +1
    -1
      BPASmartClient.Tourism/Model/Func/EFunc.cs
  14. +1
    -1
      BPASmartClient.Tourism/Model/Func/FuncPar.cs
  15. +1
    -1
      BPASmartClient.Tourism/Model/Func/InitData.cs
  16. +34
    -0
      BPASmartClient.Tourism/Server/ISqlLIte.cs
  17. +262
    -0
      BPASmartClient.Tourism/Server/SqliteHelper.cs
  18. +25
    -0
      BPASmartClient.Tourism/View/Test.xaml
  19. +28
    -0
      BPASmartClient.Tourism/View/Test.xaml.cs
  20. +1
    -0
      BPASmartClient.Tourism/ViewModel/AddRawMaterialViewModel.cs
  21. +90
    -0
      BPASmartClient.Tourism/ViewModel/testViewModel.cs

+ 5
- 1
BPASmartClient.Business/Plugin/MQTTMgr.cs Parādīt failu

@@ -55,7 +55,11 @@ namespace BPASmartClient.Business
var MqttServerConfig = Plugin.GetInstance().GetPlugin<ConfigMgr>().MQTT_Config;
var MqttServerAccount = Plugin.GetInstance().GetPlugin<ConfigMgr>().Mqtt_Account;
var deviceConfig = Plugin.GetInstance().GetPlugin<ConfigMgr>().deviceConfigModelJsons;
string deviceId = deviceConfig[0].deviceModels[0].DeviceId;
string deviceId = "";
if (deviceConfig.Count > 0 && deviceConfig[0].deviceModels.Count > 0)
{
deviceId = deviceConfig[0].deviceModels[0].DeviceId;
}
clientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId;
//MQTT 初始化
mqttProxy.Connect(new BPA.Communication.Base.ConfigurationOptions()


+ 1
- 1
BPASmartClient.IoT/Model/DataVReport.cs Parādīt failu

@@ -199,7 +199,7 @@ namespace BPASmartDatavDeviceClient.IoT
//json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}&deviceId={deviceId}");
json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}&deviceId={deviceId}");
JsonMsg<List<DeviceTable>> jsonMsg = Tools.JsonToObjectTools<JsonMsg<List<DeviceTable>>>(json);
if (jsonMsg.obj != null && jsonMsg.obj.data != null)
if (jsonMsg != null && jsonMsg.obj != null && jsonMsg.obj.data != null)
{
device = jsonMsg.obj.data.FirstOrDefault();
if (device == null) return false;


+ 4
- 0
BPASmartClient.Tourism/BPASmartClient.MorkCL.csproj Parādīt failu

@@ -6,6 +6,10 @@
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SqlSugarCore" Version="5.1.4.84" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />


+ 1
- 0
BPASmartClient.Tourism/Model/ControlData.cs Parādīt failu

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.MorkCL.Model.Func;

namespace BPASmartClient.MorkCL.Model
{


+ 15
- 0
BPASmartClient.Tourism/Model/DB/AccessoriesTB.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model.DB
{
/// <summary>
/// 辅料数据表
/// </summary>
public class AccessoriesTB : MaterialBase
{
}
}

+ 15
- 0
BPASmartClient.Tourism/Model/DB/IngredientsTB.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model.DB
{
/// <summary>
/// 主料数据表
/// </summary>
public class IngredientsTB : MaterialBase
{
}
}

+ 33
- 0
BPASmartClient.Tourism/Model/DB/MaterialBase.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model
{
/// <summary>
/// 物料数据表
/// </summary>
public class MaterialBase
{
[SugarColumn(IsPrimaryKey = true)]//设置主键
public string Id { get; set; }

/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }

/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }

/// <summary>
/// 物料位置
/// </summary>
public int Loc { get; set; }
}
}

+ 15
- 0
BPASmartClient.Tourism/Model/DB/SeasoningTB.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model.DB
{
/// <summary>
/// 调料数据表
/// </summary>
public class SeasoningTB : MaterialBase
{
}
}

BPASmartClient.Tourism/Model/AccessoriesInfo.cs → BPASmartClient.Tourism/Model/DataInfo/AccessoriesInfo.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.DataInfo
{
/// <summary>
/// 辅料信息

BPASmartClient.Tourism/Model/IngredientsInfo.cs → BPASmartClient.Tourism/Model/DataInfo/IngredientsInfo.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.DataInfo
{
/// <summary>
/// 主料信息

BPASmartClient.Tourism/Model/RawMaterial.cs → BPASmartClient.Tourism/Model/DataInfo/RawMaterial.cs Parādīt failu

@@ -4,17 +4,17 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.DataInfo
{
public class RawMaterial : NotifyBase
{
/// <summary>
/// 原料ID
/// ID
/// </summary>
public string Id { get; set; }

/// <summary>
/// 原料名称
/// 名称
/// </summary>
public string Name { get; set; }
}

BPASmartClient.Tourism/Model/SeasoningInfo.cs → BPASmartClient.Tourism/Model/DataInfo/SeasoningInfo.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.DataInfo
{
/// <summary>
/// 调料信息

BPASmartClient.Tourism/Model/EFunc.cs → BPASmartClient.Tourism/Model/Func/EFunc.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.Func
{
/// <summary>
/// 功能枚举列表

BPASmartClient.Tourism/Model/FuncPar.cs → BPASmartClient.Tourism/Model/Func/FuncPar.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.Func
{
/// <summary>
/// 功能参数信息

BPASmartClient.Tourism/Model/InitData.cs → BPASmartClient.Tourism/Model/Func/InitData.cs Parādīt failu

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

namespace BPASmartClient.MorkCL.Model
namespace BPASmartClient.MorkCL.Model.Func
{
public class InitData
{

+ 34
- 0
BPASmartClient.Tourism/Server/ISqlLIte.cs Parādīt failu

@@ -0,0 +1,34 @@
using BPASmartClient.MorkCL.Model.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Server
{
internal interface ISqlLIte : IServer
{
//主料
bool AddIngredients(IngredientsTB mb);
bool EditIngredients(IngredientsTB req);
bool DelIngredients(string id);
IngredientsTB GetIngredientsInfo(string id);
List<IngredientsTB> GetIngredients();

//辅料
bool AddAccessories(AccessoriesTB mb);
bool EditAccessories(AccessoriesTB req);
bool DelAccessories(string id);
AccessoriesTB GetAccessoriesInfo(string id);
List<AccessoriesTB> GetAccessories();


//调料
bool AddSeasoning(SeasoningTB mb);
bool EditSeasoning(SeasoningTB req);
bool DelSeasoning(string id);
SeasoningTB GetSeasoningInfo(string id);
List<SeasoningTB> GetSeasoning();
}
}

+ 262
- 0
BPASmartClient.Tourism/Server/SqliteHelper.cs Parādīt failu

@@ -0,0 +1,262 @@
using BPASmartClient.MorkCL.Model.DB;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.Server
{
internal class SqliteHelper : ISqlLIte
{

private volatile static SqliteHelper _Instance;
public static SqliteHelper GetInstance => _Instance ?? (_Instance = new SqliteHelper());
private SqliteHelper() { }

static string path
{
get
{
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory);
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB\\Material.db");
}
}

public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = $"Data Source={path}",
DbType = DbType.Sqlite,
IsAutoCloseConnection = true,//设置自动关闭连接
});

/// <summary>
/// 初始化
/// </summary>
public void Init()
{
try
{
if (!File.Exists(path))
{
//创建数据库
Db.DbMaintenance.CreateDatabase();

//创建数据表
string spnaName = "BPASmartClient.MorkCL.Model.DB";//实体类的命名空间
Type[] ass = Assembly.LoadFrom(AppContext.BaseDirectory + "BPASmartClient.MorkCL.dll").GetTypes().Where(p => p.Namespace == spnaName).ToArray();
Db.CodeFirst.SetStringDefaultLength(200).InitTables(ass);
//Db.Insertable(new IngredientsTB()).ExecuteCommand();
//Db.Insertable(new AccessoriesTB()).ExecuteCommand();
//Db.Insertable(new SeasoningTB()).ExecuteCommand();
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}

#region 主料数据操作
/// <summary>
/// 添加主料
/// </summary>
/// <param name="mb"></param>
/// <returns></returns>
public bool AddIngredients(IngredientsTB mb)
{
IngredientsTB tempMB = new IngredientsTB()
{
Id = Guid.NewGuid().ToString(),
Name = mb.Name,
Description = mb.Description,
Loc = mb.Loc,
};
if (Db.Queryable<IngredientsTB>().Any(p => p.Name == mb.Name)) return false;
return Db.Insertable(tempMB).ExecuteCommand() > 0;
}

/// <summary>
/// 编辑主料
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public bool EditIngredients(IngredientsTB req)
{
IngredientsTB tempMB = Db.Queryable<IngredientsTB>().First(p => p.Id == req.Id);
if (tempMB == null) return false;
tempMB.Name = req.Name;
tempMB.Loc = req.Loc;
tempMB.Description = req.Description;
return Db.Updateable(tempMB).ExecuteCommand() > 0;
}

/// <summary>
/// 删除主料
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool DelIngredients(string id)
{
return Db.Ado.ExecuteCommand($"DELETE [IngredientsTB] WHERE Id IN({id})") > 0;
}

/// <summary>
/// 获取所有主料
/// </summary>
/// <returns></returns>
public List<IngredientsTB> GetIngredients()
{
return Db.Queryable<IngredientsTB>().ToList();
}

/// <summary>
/// 获取指定主料信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public IngredientsTB GetIngredientsInfo(string id)
{
return Db.Queryable<IngredientsTB>().First(p => p.Id == id);
}

#endregion


#region 辅料数据操作
/// <summary>
/// 添加辅料
/// </summary>
/// <param name="mb"></param>
/// <returns></returns>
public bool AddAccessories(AccessoriesTB mb)
{
AccessoriesTB tempMB = new AccessoriesTB()
{
Id = Guid.NewGuid().ToString(),
Name = mb.Name,
Description = mb.Description,
Loc = mb.Loc,
};
if (Db.Queryable<AccessoriesTB>().Any(p => p.Name == mb.Name)) return false;
return Db.Insertable(tempMB).ExecuteCommand() > 0;
}

/// <summary>
/// 编辑辅料
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public bool EditAccessories(AccessoriesTB req)
{
AccessoriesTB tempMB = Db.Queryable<AccessoriesTB>().First(p => p.Id == req.Id);
if (tempMB == null) return false;
tempMB.Name = req.Name;
tempMB.Loc = req.Loc;
tempMB.Description = req.Description;
return Db.Updateable(tempMB).ExecuteCommand() > 0;
}

/// <summary>
/// 删除辅料
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool DelAccessories(string id)
{
return Db.Ado.ExecuteCommand($"DELETE [AccessoriesTB] WHERE Id IN({id})") > 0;
}

/// <summary>
/// 获取所有辅料
/// </summary>
/// <returns></returns>
public List<AccessoriesTB> GetAccessories()
{
return Db.Queryable<AccessoriesTB>().ToList();
}

/// <summary>
/// 获取指定的辅料
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public AccessoriesTB GetAccessoriesInfo(string id)
{
return Db.Queryable<AccessoriesTB>().First(p => p.Id == id);
}

#endregion

#region 调料数据操作
/// <summary>
/// 添加调料
/// </summary>
/// <param name="mb"></param>
/// <returns></returns>
public bool AddSeasoning(SeasoningTB mb)
{
SeasoningTB tempMB = new SeasoningTB()
{
Id = Guid.NewGuid().ToString(),
Name = mb.Name,
Description = mb.Description,
Loc = mb.Loc,
};
if (Db.Queryable<SeasoningTB>().Any(p => p.Name == mb.Name)) return false;
return Db.Insertable(tempMB).ExecuteCommand() > 0;
}

/// <summary>
/// 编辑调料
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public bool EditSeasoning(SeasoningTB req)
{
SeasoningTB tempMB = Db.Queryable<SeasoningTB>().First(p => p.Id == req.Id);
if (tempMB == null) return false;
tempMB.Name = req.Name;
tempMB.Loc = req.Loc;
tempMB.Description = req.Description;
return Db.Updateable(tempMB).ExecuteCommand() > 0;
}

/// <summary>
/// 删除调料
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool DelSeasoning(string id)
{
return Db.Ado.ExecuteCommand($"DELETE [SeasoningTB] WHERE Id IN({id})") > 0;
}

/// <summary>
/// 获取所有调料
/// </summary>
/// <returns></returns>
public List<SeasoningTB> GetSeasoning()
{
return Db.Queryable<SeasoningTB>().ToList();
}

/// <summary>
/// 获取指定的调料信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public SeasoningTB GetSeasoningInfo(string id)
{
return Db.Queryable<SeasoningTB>().First(p => p.Id == id);
}
#endregion




}
}

+ 25
- 0
BPASmartClient.Tourism/View/Test.xaml Parādīt failu

@@ -0,0 +1,25 @@
<UserControl
x:Class="BPASmartClient.MorkCL.View.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel"
Name="测试"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:testViewModel />
</UserControl.DataContext>

<Grid>
<Button
Width="100"
Height="30"
Command="{Binding testCommand}"
Content="Init" />
</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.Tourism/View/Test.xaml.cs Parādīt failu

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.MorkCL.View
{
/// <summary>
/// Test.xaml 的交互逻辑
/// </summary>
public partial class Test : UserControl
{
public Test()
{
InitializeComponent();
}
}
}

+ 1
- 0
BPASmartClient.Tourism/ViewModel/AddRawMaterialViewModel.cs Parādīt failu

@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.MorkCL.Model.DataInfo;

namespace BPASmartClient.MorkCL.ViewModel
{


+ 90
- 0
BPASmartClient.Tourism/ViewModel/testViewModel.cs Parādīt failu

@@ -0,0 +1,90 @@
using BPASmartClient.MorkCL.Model.DB;
using BPASmartClient.MorkCL.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.ViewModel
{
public class testViewModel : NotifyBase
{
public testViewModel()
{
testCommand = new BPARelayCommand(() =>
{
SqliteHelper.GetInstance.Init();

for (int i = 0; i < 10; i++)
{
SqliteHelper.GetInstance.AddAccessories(new Model.DB.AccessoriesTB()
{
Description = "AccessoriesTB",
Loc = 1,
Name = $"AccessoriesTB{i}"
});

SqliteHelper.GetInstance.AddIngredients(new Model.DB.IngredientsTB()
{
Description = "IngredientsTB",
Loc = 1,
Name = $"IngredientsTB{i}"
});

SqliteHelper.GetInstance.AddSeasoning(new Model.DB.SeasoningTB()
{
Description = "SeasoningTB",
Loc = 1,
Name = $"SeasoningTB{i}"
});
}

var Accessories = SqliteHelper.GetInstance.GetAccessories();
var Ingredients = SqliteHelper.GetInstance.GetIngredients();
var Seasoning = SqliteHelper.GetInstance.GetSeasoning();

Accessories?.ForEach(x =>
{
SqliteHelper.GetInstance.EditAccessories(new Model.DB.AccessoriesTB()
{
Description = "AccessoriesTB1111",
Loc = x.Loc,
Name = x.Name,
Id = x.Id
});
});

Ingredients?.ForEach(x =>
{
SqliteHelper.GetInstance.EditIngredients(new Model.DB.IngredientsTB()
{
Description = "IngredientsTB1111",
Loc = x.Loc,
Name = x.Name,
Id = x.Id
});
});

Seasoning?.ForEach(x =>
{
SqliteHelper.GetInstance.EditSeasoning(new Model.DB.SeasoningTB()
{
Description = "SeasoningTB1111",
Loc = x.Loc,
Name = x.Name,
Id = x.Id
});
});

var Accessories1 = SqliteHelper.GetInstance.GetAccessories();
var Ingredients1 = SqliteHelper.GetInstance.GetIngredients();
var Seasoning1 = SqliteHelper.GetInstance.GetSeasoning();


});
}

public BPARelayCommand testCommand { get; set; }
}
}

Notiek ielāde…
Atcelt
Saglabāt