diff --git a/SlnMesnac.Generate/GenerateCode.cs b/SlnMesnac.Generate/GenerateCode.cs
new file mode 100644
index 0000000..812b0f9
--- /dev/null
+++ b/SlnMesnac.Generate/GenerateCode.cs
@@ -0,0 +1,113 @@
+using SlnMesnac.Generate.Templates.Service;
+using SlnMesnac.Generate.Templates.Service.Impl;
+using SqlSugar;
+using System;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:SlnMesnac.Generate
+* 唯一标识:78595105-fab6-40f0-97b4-1272dc3e0e86
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-04-11 13:35:01
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.Generate
+{
+ ///
+ /// 生成代码
+ ///
+ public class GenerateCode
+ {
+ private readonly ISqlSugarClient _sqlSugarClient;
+
+ public GenerateCode(ISqlSugarClient sqlSugarClient)
+ {
+ _sqlSugarClient = sqlSugarClient;
+ }
+
+ public bool CreateCode(string configId,string tableName,string savePath,string nameSpace)
+ {
+ if (string.IsNullOrEmpty(configId))
+ {
+ throw new ArgumentNullException($"代码生成异常:configId参数为空");
+ }
+
+ if (string.IsNullOrEmpty(tableName))
+ {
+ throw new ArgumentNullException($"代码生成异常:表格名称参数为空");
+ }
+
+ if (string.IsNullOrEmpty(savePath))
+ {
+ throw new ArgumentNullException($"代码生成异常:文件存储路径参数为空");
+ }
+
+ if (string.IsNullOrEmpty(nameSpace))
+ {
+ throw new ArgumentNullException($"代码生成异常:命名空间参数为空");
+ }
+
+ try
+ {
+ savePath += $"\\{tableName}";
+
+ var scope = _sqlSugarClient.AsTenant().GetConnectionScope(configId);
+
+ scope.DbFirst.IsCreateAttribute()
+ .FormatPropertyName(it=> ToCamelCase(it)).Where(p => p == tableName).CreateClassFile($"{savePath}\\Entity", nameSpace);
+
+ var isc = new IServiceCreate();
+ bool iscRes = isc.Create(tableName, nameSpace, savePath);
+ if (!iscRes)
+ {
+ throw new InvalidOperationException($"Service接口生成失败");
+ }
+
+ var sc = new ServiceCreate();
+ var scRes = sc.Create(tableName, nameSpace, savePath);
+
+ if (!scRes)
+ {
+ throw new InvalidOperationException($"Service实现类生成失败");
+ }
+
+ return true;
+ }catch (Exception ex)
+ {
+ throw new InvalidOperationException($"代码生成异常:{ex.Message}");
+ }
+ }
+
+ private static string ToCamelCase(string input)
+ {
+ // 将字符串转换为驼峰格式,但保持每个单词的首字母大写
+ string[] words = input.Split('_');
+ for (int i = 0; i < words.Length; i++)
+ {
+ if (i > 0)
+ {
+ words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
+ }
+ else
+ {
+ words[i] = words[i].ToLower();
+ }
+ }
+ return string.Join("", words);
+ }
+ }
+}
diff --git a/SlnMesnac.Generate/SlnMesnac.Generate.csproj b/SlnMesnac.Generate/SlnMesnac.Generate.csproj
new file mode 100644
index 0000000..7e094ef
--- /dev/null
+++ b/SlnMesnac.Generate/SlnMesnac.Generate.csproj
@@ -0,0 +1,16 @@
+
+
+
+ netstandard2.1
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.Generate/Templates/Service/IServiceCreate.cs b/SlnMesnac.Generate/Templates/Service/IServiceCreate.cs
new file mode 100644
index 0000000..272c376
--- /dev/null
+++ b/SlnMesnac.Generate/Templates/Service/IServiceCreate.cs
@@ -0,0 +1,78 @@
+using Commons.Collections;
+using NVelocity.App;
+using NVelocity.Runtime;
+using NVelocity;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:SlnMesnac.Generate.Templates
+* 唯一标识:4dbafd45-d689-4d1a-b54d-b936dae7d17c
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-04-11 13:28:04
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.Generate.Templates.Service
+{
+ public class IServiceCreate
+ {
+ private static readonly string templateDir = @"E:\桌面\SlnMesnac\SlnMesnac.Generate\Templates\Service\";
+
+ public bool Create(string tableName, string NameSpace, string outdir)
+ {
+
+ try
+ {
+ VelocityEngine velocityEngine = new VelocityEngine();
+ ExtendedProperties props = new ExtendedProperties();
+ props.AddProperty(RuntimeConstants.RESOURCE_LOADER, @"file");
+ props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDir);
+ props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
+ props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");
+ //模板的缓存设置
+ props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, true); //是否缓存
+ props.AddProperty("file.resource.loader.modificationCheckInterval", (Int64)30); //缓存时间(秒)
+ velocityEngine.Init(props);
+ //为模板变量赋值
+ VelocityContext context = new VelocityContext();
+ context.Put("tableName", tableName);
+ context.Put("NameSpace", NameSpace);
+ context.Put("outdir", outdir);
+ //从文件中读取模板
+ Template template = velocityEngine.GetTemplate(@"\IServices.vm");
+ if (!Directory.Exists(outdir + "\\IServices"))
+ {
+ Directory.CreateDirectory(outdir + "\\IServices");
+ }
+ //合并模板
+ using (StreamWriter writer = new StreamWriter(outdir + $"\\IServices\\I{tableName.Substring(0, 1).ToUpper()}{tableName.Substring(1)}Service.cs", false))
+ {
+ template.Merge(context, writer);
+ }
+ return true;
+ }catch(Exception ex)
+ {
+ throw new InvalidOperationException($"Service接口模板创建异常:{ex.Message}");
+ }
+ }
+
+
+ }
+}
diff --git a/SlnMesnac.Generate/Templates/Service/IServices.vm b/SlnMesnac.Generate/Templates/Service/IServices.vm
new file mode 100644
index 0000000..a5b8992
--- /dev/null
+++ b/SlnMesnac.Generate/Templates/Service/IServices.vm
@@ -0,0 +1,13 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace ${NameSpace}.service
+{
+ public interface I${tableName}Services: IBaseService<${tableName}>
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Generate/Templates/Service/Impl/ServiceCreate.cs b/SlnMesnac.Generate/Templates/Service/Impl/ServiceCreate.cs
new file mode 100644
index 0000000..14830ea
--- /dev/null
+++ b/SlnMesnac.Generate/Templates/Service/Impl/ServiceCreate.cs
@@ -0,0 +1,75 @@
+using Commons.Collections;
+using NVelocity.App;
+using NVelocity.Runtime;
+using NVelocity;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:SlnMesnac.Generate.Templates
+* 唯一标识:4acc596a-6223-4156-b16c-952c225eff25
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-04-11 13:27:33
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.Generate.Templates.Service.Impl
+{
+ public class ServiceCreate
+ {
+ private static readonly string templateDir = @"E:\桌面\SlnMesnac\SlnMesnac.Generate\Templates\Service\Impl\";
+
+ public bool Create(string tableName, string NameSpace, string outdir)
+ {
+ try
+ {
+ VelocityEngine velocityEngine = new VelocityEngine();
+ ExtendedProperties props = new ExtendedProperties();
+ props.AddProperty(RuntimeConstants.RESOURCE_LOADER, @"file");
+ props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDir);
+ props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
+ props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");
+ //模板的缓存设置
+ props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, true); //是否缓存
+ props.AddProperty("file.resource.loader.modificationCheckInterval", (Int64)30); //缓存时间(秒)
+ velocityEngine.Init(props);
+ //为模板变量赋值
+ VelocityContext context = new VelocityContext();
+ context.Put("tableName", tableName);
+ context.Put("NameSpace", NameSpace);
+ context.Put("outdir", outdir);
+ //从文件中读取模板
+ Template template = velocityEngine.GetTemplate(@"\Services.vm");
+ if (!Directory.Exists(outdir + "\\Services"))
+ {
+ Directory.CreateDirectory(outdir + "\\Services");
+ }
+ //合并模板
+ using (StreamWriter writer = new StreamWriter(outdir + $"\\Services\\{tableName.Substring(0, 1).ToUpper()}{tableName.Substring(1)}ServiceImpl.cs", false))
+ {
+ template.Merge(context, writer);
+ }
+ return true;
+ }catch(Exception ex)
+ {
+ throw new InvalidOperationException($"Service实现类模板创建异常:{ex.Message}");
+ }
+ }
+ }
+}
diff --git a/SlnMesnac.Generate/Templates/Service/Impl/Services.vm b/SlnMesnac.Generate/Templates/Service/Impl/Services.vm
new file mode 100644
index 0000000..bcf9a49
--- /dev/null
+++ b/SlnMesnac.Generate/Templates/Service/Impl/Services.vm
@@ -0,0 +1,14 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+
+namespace ${NameSpace}.service.Impl
+{
+ public class ${tableName}ServiceImpl : BaseServiceImpl<${tableName}>, I${tableName}Service
+ {
+ public ${tableName}ServiceImpl(Repository<${tableName}> repository):base(repository)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Ioc/DependencyConfigurator.cs b/SlnMesnac.Ioc/DependencyConfigurator.cs
index a95ae35..77f1be8 100644
--- a/SlnMesnac.Ioc/DependencyConfigurator.cs
+++ b/SlnMesnac.Ioc/DependencyConfigurator.cs
@@ -60,6 +60,9 @@ namespace SlnMesnac.Ioc
//注入业务类
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Business.dll"));
+
+ //注入代码生成
+ RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Generate.dll"));
}
diff --git a/SlnMesnac.Model/domain/EXECUTE_PLANINFO.cs b/SlnMesnac.Model/domain/EXECUTE_PLANINFO.cs
new file mode 100644
index 0000000..3a6e1fa
--- /dev/null
+++ b/SlnMesnac.Model/domain/EXECUTE_PLANINFO.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace SlnMesnac.Repository
+{
+ ///
+ ///执行计划
+ ///
+ [SugarTable("EXECUTE_PLANINFO"), TenantAttribute("mcs")]
+ public partial class EXECUTE_PLANINFO
+ {
+ public EXECUTE_PLANINFO(){
+
+
+ }
+ ///
+ /// Desc:主键标识
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey=true)]
+ public decimal OBJ_ID {get;set;}
+
+ ///
+ /// Desc:执行计划编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string EXECUTE_PLANCODE {get;set;}
+
+ ///
+ /// Desc:生产计划编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string PRODUCT_PLANCODE {get;set;}
+
+ ///
+ /// Desc:工单编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string ORDER_CODE {get;set;}
+
+ ///
+ /// Desc:物料编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string MATERIAL_CODE {get;set;}
+
+ ///
+ /// Desc:物料名称
+ /// Default:
+ /// Nullable:True
+ ///
+ public string MATERIAL_NAME {get;set;}
+
+ ///
+ /// Desc:计划工位
+ /// Default:
+ /// Nullable:True
+ ///
+ public string PRODUCTLINE_CODE {get;set;}
+
+ ///
+ /// Desc:执行顺序
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? EXECUTE_ORDER {get;set;}
+
+ ///
+ /// Desc:执行方式:1-手动;2-自动
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? EXECUTE_METHOD {get;set;}
+
+ ///
+ /// Desc:执行状态:1-待执行;2-执行中;3-完成
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? EXECUTE_STATUS {get;set;}
+
+ ///
+ /// Desc:计划数量
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? PLAN_AMOUNT {get;set;}
+
+ ///
+ /// Desc:完成数量
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? COMPLETE_AMOUNT {get;set;}
+
+ ///
+ /// Desc:开始时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? BEGIN_TIME {get;set;}
+
+ ///
+ /// Desc:完成时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? END_TIME {get;set;}
+
+ ///
+ /// Desc:是否标识
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? IS_FLAG {get;set;}
+
+ ///
+ /// Desc:创建时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? CREATED_TIME {get;set;}
+
+ ///
+ /// Desc:计划类型(1=联合下发;2=前板下发;3=后板下发)
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? PLAN_TYPE {get;set;}
+
+ ///
+ /// Desc:计划任务执行编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string TASK_CODE {get;set;}
+
+ }
+}
diff --git a/SlnMesnac.Repository/service/IEXECUTE_PLANINFOServices.cs b/SlnMesnac.Repository/service/IEXECUTE_PLANINFOServices.cs
new file mode 100644
index 0000000..2999788
--- /dev/null
+++ b/SlnMesnac.Repository/service/IEXECUTE_PLANINFOServices.cs
@@ -0,0 +1,13 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlnMesnac.Repository.service
+{
+ public interface IEXECUTE_PLANINFOServices: IBaseService
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/service/Impl/EXECUTE_PLANINFOServices.cs b/SlnMesnac.Repository/service/Impl/EXECUTE_PLANINFOServices.cs
new file mode 100644
index 0000000..2a94ad4
--- /dev/null
+++ b/SlnMesnac.Repository/service/Impl/EXECUTE_PLANINFOServices.cs
@@ -0,0 +1,14 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+
+namespace SlnMesnac.Repository.service.Impl
+{
+ public class EXECUTE_PLANINFOServiceImpl : BaseServiceImpl, IEXECUTE_PLANINFOServices
+ {
+ public EXECUTE_PLANINFOServiceImpl(Repository repository):base(repository)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.WPF/Converter/Generate/RowToIndexConverter.cs b/SlnMesnac.WPF/Converter/Generate/RowToIndexConverter.cs
new file mode 100644
index 0000000..bfed787
--- /dev/null
+++ b/SlnMesnac.WPF/Converter/Generate/RowToIndexConverter.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:SlnMesnac.WPF.Converter.Generate
+* 唯一标识:38e34c93-1c10-4a1c-83b0-c545affdc224
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-04-11 10:27:10
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.WPF.Converter.Generate
+{
+ internal class RowToIndexConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ var item = values[0];
+ var dataGrid = values[1] as DataGrid;
+
+ if (item == null || dataGrid == null)
+ return null;
+
+ var index = dataGrid.Items.IndexOf(item) + 1;
+ return index;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml
index 6c6a0a4..150870a 100644
--- a/SlnMesnac.WPF/MainWindow.xaml
+++ b/SlnMesnac.WPF/MainWindow.xaml
@@ -62,6 +62,7 @@
+
diff --git a/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml b/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml
new file mode 100644
index 0000000..a0cb758
--- /dev/null
+++ b/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml.cs b/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml.cs
new file mode 100644
index 0000000..fd5a96e
--- /dev/null
+++ b/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml.cs
@@ -0,0 +1,30 @@
+using SlnMesnac.WPF.ViewModel.Generate;
+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 SlnMesnac.WPF.Page.Generate
+{
+ ///
+ /// GenerateControl.xaml 的交互逻辑
+ ///
+ public partial class GenerateControl : UserControl
+ {
+ public GenerateControl()
+ {
+ InitializeComponent();
+ this.DataContext = new GenerateControlViewModel();
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
index b241d67..731da9b 100644
--- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj
+++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
@@ -22,6 +22,7 @@
+
@@ -33,15 +34,12 @@
-
-
-
-
-
+
+
diff --git a/SlnMesnac.WPF/ViewModel/Generate/GenerateControlViewModel.cs b/SlnMesnac.WPF/ViewModel/Generate/GenerateControlViewModel.cs
new file mode 100644
index 0000000..e6e18cc
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/Generate/GenerateControlViewModel.cs
@@ -0,0 +1,163 @@
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Command;
+using HslCommunication.LogNet;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.WindowsAPICodePack.Dialogs;
+using SlnMesnac.Config;
+using SlnMesnac.Generate;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Windows;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:LAPTOP-E0N2L34V
+* 命名空间:SlnMesnac.WPF.ViewModel.Generate
+* 唯一标识:7f1ddac5-3ff3-4974-ac90-d6eb684167c8
+*
+* 创建者:WenJY
+* 电子邮箱:wenjy@mesnac.com
+* 创建时间:2024-04-11 09:31:46
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.WPF.ViewModel.Generate
+{
+ internal class GenerateControlViewModel : ViewModelBase
+ {
+ private readonly AppConfig _appConfig;
+
+ private readonly GenerateCode _generateCode;
+
+ public GenerateControlViewModel()
+ {
+ _appConfig = App.ServiceProvider.GetService();
+
+ _generateCode = App.ServiceProvider.GetService();
+
+ var configIds = _appConfig.sqlConfig.Select(x=>x.configId).ToList();
+
+ // 初始化选项列表
+ Options = new ObservableCollection();
+
+ foreach(var configId in configIds)
+ {
+ Options.Add(configId);
+ }
+
+ QuerySearchCommand = new RelayCommand(Query);
+
+ CreateCodeCommand = new RelayCommand(CreateCode);
+ }
+
+ #region 参数定义
+ private ObservableCollection _options;
+ public ObservableCollection Options
+ {
+ get { return _options; }
+ set
+ {
+ _options = value;
+ RaisePropertyChanged(nameof(Options));
+ }
+ }
+
+ private string _selectedOption;
+ public string SelectedOption
+ {
+ get { return _selectedOption; }
+ set
+ {
+ _selectedOption = value;
+ RaisePropertyChanged(nameof(SelectedOption));
+ }
+ }
+
+ private ObservableCollection tablesDataGrid;
+
+ public ObservableCollection TablesDataGrid
+ {
+ get { return tablesDataGrid; }
+ set { tablesDataGrid = value; RaisePropertyChanged(() => TablesDataGrid); }
+
+ }
+ #endregion
+
+ #region 事件定义
+ public RelayCommand QuerySearchCommand { get; set; }
+
+ public RelayCommand CreateCodeCommand { get;set; }
+ #endregion
+
+ ///
+ /// 查询事件
+ ///
+ ///
+ private void Query(string search)
+ {
+ var configId = _selectedOption;
+
+ if (!string.IsNullOrEmpty(configId))
+ {
+ var db = App.ServiceProvider.GetService();
+ var scope = db.AsTenant().GetConnectionScope(configId);
+
+ List tables = scope.DbMaintenance.GetTableInfoList(false);
+
+ if(tables != null)
+ {
+ TablesDataGrid = new ObservableCollection();
+ tables.ForEach(t => { TablesDataGrid.Add(t); });
+ }
+ }
+
+
+ }
+
+ private void CreateCode(string tableName)
+ {
+ var info = tableName;
+ var configId = _selectedOption;
+
+ string nameSpace = "SlnMesnac.Repository";
+
+ try
+ {
+ using (CommonOpenFileDialog dialog = new CommonOpenFileDialog())
+ {
+ dialog.IsFolderPicker = true; // 设置为选择文件夹
+ if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
+ {
+ string selectedPath = dialog.FileName;
+
+ var res = _generateCode.CreateCode(configId, tableName, selectedPath, nameSpace);
+
+ if (res)
+ {
+ MessageBox.Show($"{tableName}代码生成成功");
+ }
+ }
+ }
+ }catch(Exception ex)
+ {
+ MessageBox.Show($"{tableName}代码生成失败:{ex.Message}");
+ }
+ }
+
+ }
+}
diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
index 9b71883..104526c 100644
--- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
@@ -1,26 +1,20 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
-using HslCommunication.Enthernet;
-using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Microsoft.IdentityModel.Logging;
-using SlnMesnac.Mqtt;
-using SlnMesnac.TouchSocket;
+using SlnMesnac.WPF.Page.Generate;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
using System.Windows;
-using SlnMesnac.Rfid;
namespace SlnMesnac.WPF.ViewModel
{
public class MainWindowViewModel: ViewModelBase
{
private readonly ILogger _logger;
+
+ //代码生成
+ private readonly GenerateControl generateControl = new GenerateControl();
+
#region 参数定义
///
/// PLC设备状态
@@ -108,7 +102,9 @@ namespace SlnMesnac.WPF.ViewModel
//Environment.Exit(0);
Application.Current.Shutdown();
break;
-
+ case "Generate":
+ UserContent = generateControl;
+ break;
// 还原 或者 最大化当前窗口
case "Normal":
if (Application.Current.MainWindow.WindowState == WindowState.Normal)
diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json
index 02d4e43..f9fd88f 100644
--- a/SlnMesnac.WPF/appsettings.json
+++ b/SlnMesnac.WPF/appsettings.json
@@ -36,7 +36,7 @@
"plcIp": "127.0.0.1",
"plcPort": 6000,
"plcKey": "cwss",
- "isFlage": true
+ "isFlage": false
}
],
"RfidConfig": [
@@ -52,7 +52,7 @@
"equipIp": "127.0.0.1",
"equipPort": 6009,
"equipKey": "test2",
- "isFlage": true
+ "isFlage": false
}
]
}
diff --git a/SlnMesnac.sln b/SlnMesnac.sln
index 9013297..e80dbbe 100644
--- a/SlnMesnac.sln
+++ b/SlnMesnac.sln
@@ -29,7 +29,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Mqtt", "SlnMesnac
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Rfid", "SlnMesnac.Rfid\SlnMesnac.Rfid.csproj", "{40D23A4B-8372-4145-936C-08AE63C6D1F9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Ioc", "SlnMesnac.Ioc\SlnMesnac.Ioc.csproj", "{30A3F86B-774E-4153-9A00-FD3173C710EB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Ioc", "SlnMesnac.Ioc\SlnMesnac.Ioc.csproj", "{30A3F86B-774E-4153-9A00-FD3173C710EB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Generate", "SlnMesnac.Generate\SlnMesnac.Generate.csproj", "{00FC9358-2381-4C1B-BD45-6D31DD1DB7D3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -93,6 +95,10 @@ Global
{30A3F86B-774E-4153-9A00-FD3173C710EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30A3F86B-774E-4153-9A00-FD3173C710EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30A3F86B-774E-4153-9A00-FD3173C710EB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {00FC9358-2381-4C1B-BD45-6D31DD1DB7D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {00FC9358-2381-4C1B-BD45-6D31DD1DB7D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {00FC9358-2381-4C1B-BD45-6D31DD1DB7D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {00FC9358-2381-4C1B-BD45-6D31DD1DB7D3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE