From 67ab37d415e89b8c8f4432aeca0d259b57e4e727 Mon Sep 17 00:00:00 2001 From: wangsr Date: Mon, 25 Sep 2023 17:44:03 +0800 Subject: [PATCH] =?UTF-8?q?Add=20-=20LJPlanning-TestAction=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E5=AE=9E=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DBEntity/LjFormulaDetailDownEntity.cs | 121 ++++++++++++++++ .../FreeDb/DBEntity/LjFormulaDetailEntity.cs | 129 ++++++++++++++++++ .../FreeDb/DBEntity/LjFormulaDownEntity.cs | 85 ++++++++++++ .../FreeDb/DBEntity/LjFormulaEntity.cs | 79 +++++++++++ .../FreeDb/DBEntity/LjPlanningEntity.cs | 89 ++++++++++++ .../FreeDb/FreeSqlUnit.cs | 8 +- .../LjPlanning/TestAction.cs | 106 ++++++++++++++ .../LoadingHelper.cs | 4 +- .../Mesnac.Action.ChemicalWeighing.csproj | 6 + .../小料称量/榄菊生产计划管理.xml | 10 ++ 10 files changed, 632 insertions(+), 5 deletions(-) create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailDownEntity.cs create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailEntity.cs create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDownEntity.cs create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaEntity.cs create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjPlanningEntity.cs create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/TestAction.cs diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailDownEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailDownEntity.cs new file mode 100644 index 0000000..059babb --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailDownEntity.cs @@ -0,0 +1,121 @@ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using FreeSql.DataAnnotations; + +namespace Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity +{ + + [Table(Name = "Lj_Formula_Detail_Down")] + public partial class LjFormulaDetailDownEntity + { + + [Column(IsPrimary = true, IsIdentity = true)] + public int Id { get; set; } + + + public int? ActionCode { get; set; } + + /// + /// 动作Id + /// + + public int? ActionId { get; set; } + + /// + /// 动作名称 + /// + [Column(DbType = "nvarchar(50)")] + public string ActionName { get; set; } = string.Empty; + + + public int BinNo { get; set; } + + /// + /// 糊化机称量Copy + /// + + public int? CbCopyC { get; set; } + + /// + /// 湿混机混合配方copy + /// + + public int? CbCopyH { get; set; } + + /// + /// 糊化机混合配方copy + /// + + public int? CpSiloH { get; set; } + + + public int FormulaId { get; set; } + + /// + /// 1 称量 2 混合 + /// + + public int FormulaType { get; set; } + + /// + /// 机台 + /// + [Column(DbType = "nvarchar(2)")] + public string Machine { get; set; } = string.Empty; + + [Column(DbType = "nvarchar(50)")] + public string MachineType { get; set; } = string.Empty; + + /// + /// 物料编码 + /// + + public int MId { get; set; } + + [Column(DbType = "nvarchar(50)")] + public string MName { get; set; } = string.Empty; + + + public double? SetTolerance { get; set; } + + + public double? SetValue { get; set; } + + /// + /// 速度 + /// + + public double? Speed { get; set; } + + /// + /// 物料Id + /// + + public int? StockMaterialId { get; set; } + + /// + /// 温度 + /// + + public double? Temp { get; set; } + + + public double? TimeInfo { get; set; } + + + public double Tolerance { get; set; } + + /// + /// 重量 + /// + + public double Weight { get; set; } + + } + +} \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailEntity.cs new file mode 100644 index 0000000..4408294 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDetailEntity.cs @@ -0,0 +1,129 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// Website: http://www.freesql.net +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using FreeSql.DataAnnotations; + +namespace Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity +{ + + [Table(Name = "Lj_Formula_Detail")] + public partial class LjFormulaDetailEntity + { + + [Column(IsPrimary = true, IsIdentity = true)] + public int Id { get; set; } + + + public int? ActionCode { get; set; } + + /// + /// 动作Id + /// + + public int? ActionId { get; set; } + + /// + /// 动作名称 + /// + [Column(DbType = "nvarchar(50)")] + public string ActionName { get; set; } = string.Empty; + + + public int BinNo { get; set; } + + /// + /// 糊化机称量Copy + /// + + public int? CbCopyC { get; set; } + + /// + /// 湿混机混合配方copy + /// + + public int? CbCopyH { get; set; } + + /// + /// 糊化机混合配方copy + /// + + public int? CpSiloH { get; set; } + + + public int FormulaId { get; set; } + + /// + /// 1 称量 2 混合 + /// + + public int FormulaType { get; set; } + + /// + /// 机台 + /// + [Column(DbType = "nvarchar(2)")] + public string Machine { get; set; } = string.Empty; + + [Column(DbType = "nvarchar(50)")] + public string MachineType { get; set; } = string.Empty; + + /// + /// 物料编码 + /// + + public int MId { get; set; } + + [Column(DbType = "nvarchar(50)")] + public string MName { get; set; } = string.Empty; + + + public double? SetTolerance { get; set; } + + + public double? SetValue { get; set; } + + /// + /// 速度 + /// + + public double? Speed { get; set; } + + /// + /// 物料Id + /// + + public int? StockMaterialId { get; set; } + + /// + /// 温度 + /// + + public double? Temp { get; set; } + + + public double? TimeInfo { get; set; } + + + public double Tolerance { get; set; } + + /// + /// 重量 + /// + + public double Weight { get; set; } + + } + +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDownEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDownEntity.cs new file mode 100644 index 0000000..8d84cd5 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaDownEntity.cs @@ -0,0 +1,85 @@ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using FreeSql.DataAnnotations; + +namespace Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity +{ + + [Table(Name = "Lj_Formula_Down")] + public partial class LjFormulaDownEntity + { + + [Column(IsPrimary = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 糊化机copy称量配方 + /// + + public int? CbSiloC { get; set; } + + /// + /// 糊化机copy混合配方 + /// + + public int? CbSiloH { get; set; } + + /// + /// 湿混机copy混合配方 + /// + + public int? CbWeterH { get; set; } + + + public DateTime CreateTime { get; set; } + + + public int? FormulaId { get; set; } + + [Column(DbType = "nvarchar(50)")] + public string FormulaName { get; set; } = string.Empty; + + /// + /// 编号 + /// + [Column(DbType = "nvarchar(50)")] + public string FormulaNo { get; set; } = string.Empty; + + [Column(DbType = "nvarchar(50)")] + public string FormulaVersion { get; set; } = string.Empty; + + + public int? IsEnable { get; set; } + + + public int? PlanId { get; set; } + + + public int? RecipeTypeId { get; set; } + + [Column(DbType = "nvarchar(50)")] + public string RecipeTypeName { get; set; } = string.Empty; + + /// + /// 状态 + /// + + public int? Status { get; set; } + + /// + /// 生产单元 + /// + + public int? Unit { get; set; } + + + public DateTime? UpdateTime { get; set; } + + } + +} \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaEntity.cs new file mode 100644 index 0000000..d2d3560 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjFormulaEntity.cs @@ -0,0 +1,79 @@ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using FreeSql.DataAnnotations; + +namespace Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity +{ + + [Table(Name = "Lj_Formula")] + public partial class LjFormulaEntity + { + + [Column(IsPrimary = true)] + public int Id { get; set; } + + /// + /// 糊化机copy称量配方 + /// + + public int? CbSiloC { get; set; } + + /// + /// 糊化机copy混合配方 + /// + + public int? CbSiloH { get; set; } + + /// + /// 湿混机copy混合配方 + /// + + public int? CbWeterH { get; set; } + + + public DateTime CreateTime { get; set; } + + [Column(DbType = "nvarchar(50)")] + public string FormulaName { get; set; } = string.Empty; + + /// + /// 编号 + /// + [Column(DbType = "nvarchar(50)")] + public string FormulaNo { get; set; } = string.Empty; + + [Column(DbType = "nvarchar(50)")] + public string FormulaVersion { get; set; } = string.Empty; + + + public int? IsEnable { get; set; } + + + public int? RecipeTypeId { get; set; } + + [Column(DbType = "nvarchar(50)")] + public string RecipeTypeName { get; set; } = string.Empty; + + /// + /// 状态 + /// + + public int? Status { get; set; } + + /// + /// 生产单元 + /// + + public int? Unit { get; set; } + + + public DateTime? UpdateTime { get; set; } + + } + +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjPlanningEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjPlanningEntity.cs new file mode 100644 index 0000000..ca1f423 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/DBEntity/LjPlanningEntity.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using FreeSql.DataAnnotations; + +namespace Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity +{ + + [Table(Name = "lj_planning")] + public partial class LjPlanningEntity { + + /// + /// 主键 + /// + [Column(IsPrimary = true, IsIdentity = true)] + public int Id { get; set; } + + [Column(DbType = "nvarchar(10)")] + public string BegTime { get; set; } = string.Empty; + + /// + /// 班次名称 + /// + [Column(DbType = "nvarchar(2)")] + public string ClassName { get; set; } = string.Empty; + + + public DateTime? CreateTime { get; set; } + + [Column(DbType = "nvarchar(10)")] + public string EndTime { get; set; } = string.Empty; + + /// + /// 配料Id + /// + + public int? FormulaId { get; set; } + + /// + /// 配料名称 + /// + [Column(DbType = "nvarchar(50)")] + public string FormulaName { get; set; } = string.Empty; + + /// + /// 是否启用 删除标记 + /// + + public int? IsEnable { get; set; } + + + public int? NumCar { get; set; } + + /// + /// 计划名称 + /// + [Column(DbType = "nvarchar(50)")] + public string PlanName { get; set; } = string.Empty; + + /// + /// 编号 + /// + [Column(DbType = "nvarchar(50)")] + public string PlanNo { get; set; } = string.Empty; + + [Column(DbType = "nvarchar(50)")] + public string Remark { get; set; } = string.Empty; + + /// + /// 计划状态 0 新建 1下发 2暂停 3执行中 4 异常 10结束 11重发 + /// + [Column(DbType = "nvarchar(50)")] + public string Status { get; set; } = string.Empty; + + /// + /// 工作单元 1 2 3 4 共4条线 + /// + + public int? Unit { get; set; } + + + public DateTime? UpdateTime { get; set; } + + } + +} \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/FreeSqlUnit.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/FreeSqlUnit.cs index 58e9c1e..bfb064b 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/FreeSqlUnit.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/FreeSqlUnit.cs @@ -23,10 +23,10 @@ namespace Mesnac.Action.ChemicalWeighing.FreeDb { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); return new FreeSql.FreeSqlBuilder() - .UseMonitorCommand(cmd => Trace.WriteLine($"Sql:{cmd.CommandText}"))//监听SQL语句,Trace在输出选项卡中查看 - .UseConnectionString(FreeSql.DataType.SqlServer, dbHelper.DbSession.ConnectionString) - .UseAutoSyncStructure(false) //自动同步实体结构到数据库,FreeSql不会扫描程序集,只有CRUD时才会生成表。 - .Build(); + .UseMonitorCommand(cmd => Trace.WriteLine($"Sql:{cmd.CommandText}"))//监听SQL语句,Trace在输出选项卡中查看 + .UseConnectionString(FreeSql.DataType.SqlServer, dbHelper.DbSession.ConnectionString) + .UseAutoSyncStructure(false) //自动同步实体结构到数据库,FreeSql不会扫描程序集,只有CRUD时才会生成表。 + .Build(); }); diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/TestAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/TestAction.cs new file mode 100644 index 0000000..4f270dd --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/TestAction.cs @@ -0,0 +1,106 @@ +using Mesnac.Action.Base; +using Mesnac.Action.ChemicalWeighing.FreeDb; +using Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Mesnac.Action.ChemicalWeighing.LjPlanning +{ + public class TestAction: ChemicalWeighingAction, IAction + { + public static event EventHandler OnAdd; + private DbMCControl _materialGridControl = null; //物料列表控件 + private RuntimeParameter _runtime; + public void Run(RuntimeParameter runtime) + { + base.RunIni(runtime); //必须调用 + this._runtime = runtime; + + DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_planning").FirstOrDefault(); + + this._materialGridControl = materialGridControl; + + + DataGridView clientGridView = this._materialGridControl.BaseControl as DataGridView; + + //验证是否选中某物料 + if (clientGridView.SelectedRows.Count != 1) + { + //MessageBox.Show("请选择要修改的数据", Mesnac.Basic.LanguageHelper.Caption, + // MessageBoxButtons.OK, MessageBoxIcon.Information); + //this._runtime.IsReturn = true; + return; + } + + var dataGridViewRow = clientGridView.SelectedRows[0]; + var id = Convert.ToInt32(dataGridViewRow.Cells["Id"].Value); + + LjPlanningEntity ljPlanningEntity = FreeSqlUnit.Instance.Select().Where(x => x.Id == id).ToOne(); + LjFormulaEntity ljFormulaEntity = FreeSqlUnit.Instance.Select().Where(x => x.Id == ljPlanningEntity.FormulaId).ToOne(); + List ljFormulaDetailEntity = FreeSqlUnit.Instance.Select().Where(x => x.FormulaId == ljFormulaEntity.Id).ToList(); + + FreeSqlUnit.Instance.Delete().Where(x => x.PlanId == ljPlanningEntity.Id && x.FormulaId == ljFormulaEntity.Id).ExecuteDeleted(); + + LjFormulaDownEntity ljFormulaDownEntity = new LjFormulaDownEntity() + { + CbSiloC = ljFormulaEntity.CbSiloC, + CbSiloH = ljFormulaEntity.CbSiloH, + CbWeterH = ljFormulaEntity.CbWeterH, + CreateTime = ljFormulaEntity.CreateTime, + FormulaId = ljFormulaEntity.Id, + FormulaName = ljFormulaEntity.FormulaName, + FormulaNo = ljFormulaEntity.FormulaNo, + FormulaVersion = ljFormulaEntity.FormulaVersion, + IsEnable = ljFormulaEntity.IsEnable, + PlanId = ljPlanningEntity.Id, + RecipeTypeId = ljFormulaEntity.RecipeTypeId, + RecipeTypeName = ljFormulaEntity.RecipeTypeName, + Status = ljFormulaEntity.Status, + Unit = ljFormulaEntity.Unit, + UpdateTime = ljFormulaEntity.UpdateTime + }; + + FreeSqlUnit.Instance.Insert(ljFormulaDownEntity).ExecuteIdentity(); + + List ljFormulaDetailDownEntity = new List(); + + LjFormulaDetailDownEntity singleEntity; + + foreach (LjFormulaDetailEntity Entity in ljFormulaDetailEntity) + { + singleEntity = new LjFormulaDetailDownEntity() + { + ActionCode = Entity.ActionCode, + ActionId = Entity.ActionId, + ActionName = Entity.ActionName, + BinNo = Entity.BinNo, + CbCopyC = Entity.CbCopyC, + CbCopyH = Entity.CbCopyH, + CpSiloH = Entity.CpSiloH, + FormulaId = Entity.FormulaId, + FormulaType = Entity.FormulaType, + Machine = Entity.Machine, + MachineType = Entity.MachineType, + MId = Entity.MId, + MName = Entity.MName, + SetTolerance = Entity.SetTolerance, + SetValue = Entity.SetValue, + Speed = Entity.Speed, + StockMaterialId = Entity.StockMaterialId, + Temp = Entity.Temp, + TimeInfo = Entity.TimeInfo, + Tolerance = Entity.Tolerance, + Weight = Entity.Weight + }; + ljFormulaDetailDownEntity.Add(singleEntity); + } + + FreeSqlUnit.Instance.Insert(ljFormulaDetailDownEntity).ExecuteIdentity(); + + } + } +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LoadingHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LoadingHelper.cs index f957d38..fb79032 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LoadingHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LoadingHelper.cs @@ -1,4 +1,5 @@ -using System; +using Mesnac.Action.ChemicalWeighing.FreeDb; +using System; using System.Threading; namespace Mesnac.Action.ChemicalWeighing @@ -60,6 +61,7 @@ namespace Mesnac.Action.ChemicalWeighing { Thread.Sleep(50); //通过三次延时,确保可以彻底关闭窗口 loadingForm.Invoke(new CloseDelegate(LoadingHelper.CloseFormInternal)); + } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 0e15462..1f6383c 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -319,6 +319,11 @@ + + + + + @@ -441,6 +446,7 @@ + diff --git a/Main/MCEdit/Data/EventConfig/小料称量/榄菊生产计划管理.xml b/Main/MCEdit/Data/EventConfig/小料称量/榄菊生产计划管理.xml index 47467ad..483d291 100644 --- a/Main/MCEdit/Data/EventConfig/小料称量/榄菊生产计划管理.xml +++ b/Main/MCEdit/Data/EventConfig/小料称量/榄菊生产计划管理.xml @@ -35,6 +35,11 @@ 查询计划管理 查询计划管理 + + + 测试 + 测试 + @@ -71,6 +76,10 @@ + + + + @@ -82,6 +91,7 @@ +