From c2ed98d52dfd18d50411af45dcbbefb3df7230e8 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 31 Aug 2026 13:54:07 +0800 Subject: [PATCH] =?UTF-8?q?20260831=E5=8A=9F=E8=83=BD=E5=90=8C=E6=AD=A5:?= =?UTF-8?q?=201.=20=E4=B8=8D=E5=90=8C=E8=BD=A6=E9=97=B4=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E6=96=99=E6=A1=86=E6=9F=A5=E8=AF=A2=E3=80=81=E6=96=99=E6=A1=86?= =?UTF-8?q?=E8=A7=A3=E7=BB=91=E6=8E=A5=E5=8F=A3=202.=20=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E7=94=B5=E6=B1=A0=E5=9E=8B=E5=8F=B7=E9=80=BB=E8=BE=91=203.=20?= =?UTF-8?q?=E6=89=93=E5=BC=80=E7=94=B5=E6=B1=A0=E7=8A=B6=E5=86=B5=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1257-18A.sln | 16 +- JinYuan.ControlCenter/ControlCenter_Plc.cs | 27 +- JinYuan.DAL/JinYuan.DAL.csproj | 8 + JinYuan.DAL/Models/MaterialFrameRule.cs | 47 +++ JinYuan.DAL/Models/ModelExtension.cs | 31 ++ JinYuan.DAL/Models/WorkshopInterfaceConfig.cs | 58 +++ JinYuan.DAL/Service/BaseService.cs | 42 ++ JinYuan.DAL/Service/IBaseService.cs | 21 + .../Service/MaterialFrameRuleService.cs | 91 +++++ JinYuan.DAL/Service/MesUrlService.cs | 43 ++ .../Service/WorkshopInterCfgService.cs | 87 ++++ JinYuan.Models/ConstValue.cs | 22 +- JinYuan.VirtualDataLibrary/CommonMethods.cs | 2 +- JinYuan.VirtualDataLibrary/MesConfig.cs | 23 ++ LargeSquareOne/FrmInterCfg.Designer.cs | 382 +++++++++++++++++ LargeSquareOne/FrmInterCfg.cs | 386 ++++++++++++++++++ LargeSquareOne/FrmInterCfg.resx | 126 ++++++ LargeSquareOne/FrmMain.cs | 12 +- LargeSquareOne/FrmParamSet.Designer.cs | 19 + LargeSquareOne/FrmParamSet.cs | 5 + LargeSquareOne/LargeSquareOne.csproj | 9 + UnitTestProject/Properties/AssemblyInfo.cs | 20 + UnitTestProject/UnitTest1.cs | 45 ++ UnitTestProject/UnitTestProject.csproj | 82 ++++ UnitTestProject/packages.config | 5 + 数据库/workshop_materialFrame.sql | 50 +++ 26 files changed, 1646 insertions(+), 13 deletions(-) create mode 100644 JinYuan.DAL/Models/MaterialFrameRule.cs create mode 100644 JinYuan.DAL/Models/ModelExtension.cs create mode 100644 JinYuan.DAL/Models/WorkshopInterfaceConfig.cs create mode 100644 JinYuan.DAL/Service/BaseService.cs create mode 100644 JinYuan.DAL/Service/IBaseService.cs create mode 100644 JinYuan.DAL/Service/MaterialFrameRuleService.cs create mode 100644 JinYuan.DAL/Service/MesUrlService.cs create mode 100644 JinYuan.DAL/Service/WorkshopInterCfgService.cs create mode 100644 LargeSquareOne/FrmInterCfg.Designer.cs create mode 100644 LargeSquareOne/FrmInterCfg.cs create mode 100644 LargeSquareOne/FrmInterCfg.resx create mode 100644 UnitTestProject/Properties/AssemblyInfo.cs create mode 100644 UnitTestProject/UnitTest1.cs create mode 100644 UnitTestProject/UnitTestProject.csproj create mode 100644 UnitTestProject/packages.config create mode 100644 数据库/workshop_materialFrame.sql diff --git a/1257-18A.sln b/1257-18A.sln index 522366a..2107240 100644 --- a/1257-18A.sln +++ b/1257-18A.sln @@ -32,6 +32,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决 TextFile1.txt = TextFile1.txt EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject", "UnitTestProject\UnitTestProject.csproj", "{DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -128,14 +130,22 @@ Global {242400F4-9B01-4AEE-A6F7-05083757FCDD}.Release|Any CPU.Build.0 = Release|Any CPU {242400F4-9B01-4AEE-A6F7-05083757FCDD}.Release|x64.ActiveCfg = Release|Any CPU {242400F4-9B01-4AEE-A6F7-05083757FCDD}.Release|x64.Build.0 = Release|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Debug|x64.ActiveCfg = Debug|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Debug|x64.Build.0 = Debug|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Release|Any CPU.Build.0 = Release|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Release|x64.ActiveCfg = Release|Any CPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - RESX_AutoCreateNewLanguageFiles = False - RESX_SortFileContentOnSave = True - RESX_NeutralResourcesLanguage = zh-Hans SolutionGuid = {E8421996-BAC4-4509-9C3E-BC424197F2D8} + RESX_NeutralResourcesLanguage = zh-Hans + RESX_SortFileContentOnSave = True + RESX_AutoCreateNewLanguageFiles = False EndGlobalSection EndGlobal diff --git a/JinYuan.ControlCenter/ControlCenter_Plc.cs b/JinYuan.ControlCenter/ControlCenter_Plc.cs index 85cdc82..779028b 100644 --- a/JinYuan.ControlCenter/ControlCenter_Plc.cs +++ b/JinYuan.ControlCenter/ControlCenter_Plc.cs @@ -1,4 +1,6 @@  +using JinYuan.DAL.Models; +using JinYuan.DAL.Service; using JinYuan.Helper; using JinYuan.MES.Enums; using JinYuan.MES.Models; @@ -312,9 +314,16 @@ namespace JinYuan.ControlCenters /// private async Task FeedBackToPLC(PlcGroup pf, TrayInfo trayInfo, string grade) { + MaterialFrameRuleService service = new MaterialFrameRuleService(CommonMethods.db.Db); + MaterialFrameRule rule = service.GetRuleByCode(trayInfo.trayNo); + short model = (short)CommonMethods.mesConfig.GetModel(trayInfo?.productCode ?? CommonMethods.mesConfig.ModelName); if (model == 0) model = 1; + // TODO 注释电池型号自动选择逻辑 by clm 20260831 + //string modelName = trayInfo?.productCode; + //short model = CommonMethods.mesConfig.GetModelNum(modelName, rule?.Workshop_Code ?? string.Empty); + short gradeCode = 99; if (!string.IsNullOrEmpty(grade)) gradeCode = (short)CommonMethods.GetGradeNo(grade); @@ -364,8 +373,15 @@ namespace JinYuan.ControlCenters try { + MesUrlService service = new MesUrlService(CommonMethods.db.Db); + string url = service.GetMesUrl(trayID, ConstValue.INTER_QueryTray); + if (string.IsNullOrEmpty(url)) + { + throw new ArgumentException($"未找到{ConstValue.INTER_QueryTray}对应的MES接口地址"); + } + var (success, mesMessage, mesResType, trayinfo) = await CommonMethods.hbgMes.QueryMesTrayInfosAsync( - CommonMethods.mesConfig.queryTrayUrl, + url, CommonMethods.mesConfig.siteCode, CommonMethods.mesConfig.lineCode, CommonMethods.mesConfig.equipNum, @@ -2029,8 +2045,15 @@ namespace JinYuan.ControlCenters //} try { + MesUrlService service = new MesUrlService(CommonMethods.db.Db); + string url = service.GetMesUrl(trayID, ConstValue.INTER_UnBindTray); + if (string.IsNullOrEmpty(url)) + { + throw new ArgumentException($"未找到{ConstValue.INTER_UnBindTray}对应的MES接口地址"); + } + var (success, mesMessage) = await CommonMethods.hbgMes.UnbindTrayInfosAsync( - CommonMethods.mesConfig.unbindTrayUrl, + url, CommonMethods.mesConfig.equipNum, trayID ).ConfigureAwait(false); diff --git a/JinYuan.DAL/JinYuan.DAL.csproj b/JinYuan.DAL/JinYuan.DAL.csproj index 564e64a..ff16ff2 100644 --- a/JinYuan.DAL/JinYuan.DAL.csproj +++ b/JinYuan.DAL/JinYuan.DAL.csproj @@ -116,10 +116,18 @@ + + + + + + + + diff --git a/JinYuan.DAL/Models/MaterialFrameRule.cs b/JinYuan.DAL/Models/MaterialFrameRule.cs new file mode 100644 index 0000000..830b554 --- /dev/null +++ b/JinYuan.DAL/Models/MaterialFrameRule.cs @@ -0,0 +1,47 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Models +{ + /// + /// 料框码规则表 + /// + [SugarTable("material_frame_rule")] + public class MaterialFrameRule + { + /// + /// 主键ID + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 料框码规则起始匹配编码(第4-7位) + /// + [SugarColumn(ColumnName = "start_code", Length = 20, IsNullable = false)] + public string Start_Code { get; set; } + + /// + /// 车间编码 (如 601) + /// + [SugarColumn(ColumnName = "workshop_code", Length = 10, IsNullable = false)] + public string Workshop_Code { get; set; } = string.Empty; + + /// + /// 逻辑删除标识 (0:正常, 1:已删除) + /// 注意:建议在Service层统一过滤此字段,不直接参与常规业务查询映射 + /// + [SugarColumn(ColumnName = "is_deleted")] + public bool Is_Deleted { get; set; } + + /// + /// 最后更新时间 + /// + [SugarColumn(ColumnName = "update_time", IsOnlyIgnoreUpdate = true)] // 插入时由数据库默认值处理,更新时自动更新 + public DateTime Update_Time { get; set; } + } +} diff --git a/JinYuan.DAL/Models/ModelExtension.cs b/JinYuan.DAL/Models/ModelExtension.cs new file mode 100644 index 0000000..976333b --- /dev/null +++ b/JinYuan.DAL/Models/ModelExtension.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Models +{ + public static class ModelExtension + { + public static T ToModel(this System.Data.DataRow row) where T : class, new() + { + if (row == null) return null; + T model = new T(); + var type = typeof(T); + var properties = type.GetProperties(); + foreach (var prop in properties) + { + if (row.Table.Columns.Contains(prop.Name)) + { + var value = row[prop.Name]; + if (value != DBNull.Value) + { + prop.SetValue(model, Convert.ChangeType(value, prop.PropertyType)); + } + } + } + return model; + } + } +} diff --git a/JinYuan.DAL/Models/WorkshopInterfaceConfig.cs b/JinYuan.DAL/Models/WorkshopInterfaceConfig.cs new file mode 100644 index 0000000..226cd84 --- /dev/null +++ b/JinYuan.DAL/Models/WorkshopInterfaceConfig.cs @@ -0,0 +1,58 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Models +{ + /// + /// 车间接口配置表 + /// + [SugarTable("workshop_interface_config")] + public class WorkshopInterfaceConfig + { + /// + /// 主键ID + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 车间编码 + /// + [SugarColumn(ColumnName = "workshop_code", Length = 10, IsNullable = false)] + public string Workshop_Code { get; set; } + + /// + /// 接口标识 (如 QueryTrayUrl) + /// + [SugarColumn(ColumnName = "interface_flag", Length = 50, IsNullable = false)] + public string Interface_Flag { get; set; } + + /// + /// 接口名称 (如 料框查询) + /// + [SugarColumn(ColumnName = "interface_name", Length = 100, IsNullable = true)] + public string Interface_Name { get; set; } + + /// + /// 接口URL地址 + /// + [SugarColumn(ColumnName = "interface_url", Length = 500, IsNullable = true)] + public string Interface_Url { get; set; } + + /// + /// 逻辑删除标识 (0:正常, 1:已删除) + /// + [SugarColumn(ColumnName = "is_deleted", IsIgnore = true)] + public bool Is_Deleted { get; set; } + + /// + /// 最后更新时间 + /// + [SugarColumn(ColumnName = "update_time", IsOnlyIgnoreUpdate = true)] + public DateTime Update_Time { get; set; } + } +} diff --git a/JinYuan.DAL/Service/BaseService.cs b/JinYuan.DAL/Service/BaseService.cs new file mode 100644 index 0000000..014868c --- /dev/null +++ b/JinYuan.DAL/Service/BaseService.cs @@ -0,0 +1,42 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Service +{ + public class BaseService : IBaseService where T : class, new() + { + protected readonly ISqlSugarClient _db; + public BaseService(ISqlSugarClient db) { _db = db; } + + public virtual bool Add(T model) + { + return _db.Insertable(model).ExecuteCommand() > 0; + } + + public virtual DataTable GetDataTable() + { + return _db.Queryable().ToDataTable(); + } + + public virtual List GetList() + { + return _db.Queryable().ToList(); + } + + public virtual bool SoftDelete(int id) + { + return _db.Deleteable().In(id).ExecuteCommand() > 0; + } + + public virtual bool Update(T model) + { + return _db.Updateable(model).ExecuteCommand() > 0; + } + } +} diff --git a/JinYuan.DAL/Service/IBaseService.cs b/JinYuan.DAL/Service/IBaseService.cs new file mode 100644 index 0000000..3418f8b --- /dev/null +++ b/JinYuan.DAL/Service/IBaseService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Service +{ + public interface IBaseService where T : class, new() + { + List GetList(); + + DataTable GetDataTable(); + + bool Add(T model); + bool Update(T model); + bool SoftDelete(int id); + } +} diff --git a/JinYuan.DAL/Service/MaterialFrameRuleService.cs b/JinYuan.DAL/Service/MaterialFrameRuleService.cs new file mode 100644 index 0000000..422fe02 --- /dev/null +++ b/JinYuan.DAL/Service/MaterialFrameRuleService.cs @@ -0,0 +1,91 @@ +using JinYuan.DAL.Models; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Service +{ + public interface IMaterialFrameRuleService : IBaseService + { + MaterialFrameRule GetRuleByCode(string code); + } + public class MaterialFrameRuleService : BaseService, IMaterialFrameRuleService + { + public MaterialFrameRuleService(ISqlSugarClient db) : base(db) + { } + + public override List GetList() + { + return _db.Queryable() + .Where(x => !x.Is_Deleted) + .OrderBy(x => x.Start_Code) + .ToList(); + } + + public override DataTable GetDataTable() + { + return _db.Queryable() + .Where(x => !x.Is_Deleted) + .OrderBy(x => x.Start_Code) + .ToDataTable(); + } + + public override bool Add(MaterialFrameRule model) + { + // 车间 + 匹配编码 + isdelete = 0 的唯一性校验 + bool isExist = _db.Queryable() + .Where(x => x.Workshop_Code == model.Workshop_Code + && x.Start_Code == model.Start_Code + && !x.Is_Deleted) + .Any(); + if (isExist) + { + throw new ArgumentException($"该车间{model.Workshop_Code}已存在该匹配编码{model.Start_Code}"); + } + + return base.Add(model); + } + + public override bool Update(MaterialFrameRule model) + { + // 车间 + 匹配编码 + isdelete = 0 的唯一性校验 + bool isExist = _db.Queryable() + .Where(x => x.Workshop_Code == model.Workshop_Code + && x.Start_Code == model.Start_Code + && !x.Is_Deleted) + .Any(); + if (isExist) + { + return false; + } + + return base.Update(model); + } + + public MaterialFrameRule GetRuleByCode(string code) + { + if (string.IsNullOrEmpty(code)) + { + return null; + } + + string matchStr = code.Substring(3, 4); + return _db.Queryable() + .Where(x => matchStr.StartsWith(x.Start_Code) && !x.Is_Deleted) + .First(); + } + + public override bool SoftDelete(int id) + { + return _db.Updateable() + .SetColumns(x => x.Is_Deleted == true) + .SetColumns(x => x.Update_Time == DateTime.Now) + .Where(x => x.Id == id) + .ExecuteCommand() > 0; + } + } +} diff --git a/JinYuan.DAL/Service/MesUrlService.cs b/JinYuan.DAL/Service/MesUrlService.cs new file mode 100644 index 0000000..237c20a --- /dev/null +++ b/JinYuan.DAL/Service/MesUrlService.cs @@ -0,0 +1,43 @@ +using JinYuan.DAL.Models; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Service +{ + public interface IMesUrlService + { + string GetMesUrl(string trayCode, string interfaceKey); + } + + public class MesUrlService : IMesUrlService + { + protected readonly ISqlSugarClient _db; + private MaterialFrameRuleService _ruleService; + private WorkshopInterCfgService _cfgService; + + public MesUrlService(ISqlSugarClient db) + { + _db = db; + _ruleService = new MaterialFrameRuleService(_db); + _cfgService = new WorkshopInterCfgService(_db); + } + + public string GetMesUrl(string trayCode, string interfaceKey) + { + if (string.IsNullOrEmpty(trayCode) || string.IsNullOrEmpty(interfaceKey)) + return string.Empty; + + var rule = _ruleService.GetRuleByCode(trayCode); + if (rule == null) + return string.Empty; + + var url = _cfgService.GetUrl(rule.Workshop_Code, interfaceKey); + + return url; + } + } +} diff --git a/JinYuan.DAL/Service/WorkshopInterCfgService.cs b/JinYuan.DAL/Service/WorkshopInterCfgService.cs new file mode 100644 index 0000000..c10666e --- /dev/null +++ b/JinYuan.DAL/Service/WorkshopInterCfgService.cs @@ -0,0 +1,87 @@ +using JinYuan.DAL.Models; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JinYuan.DAL.Service +{ + public interface IWorkshopInterCfgService : IBaseService + { + string GetUrl(string workshopCode, string interfaceKey); + } + + public class WorkshopInterCfgService : BaseService, IWorkshopInterCfgService + { + public WorkshopInterCfgService(ISqlSugarClient db) : base(db) + { + } + + public override List GetList() + { + return _db.Queryable() + .Where(x => !x.Is_Deleted) + .OrderBy(x => x.Workshop_Code) + .OrderBy(x => x.Interface_Flag) + .ToList(); + } + + public override DataTable GetDataTable() + { + return _db.Queryable() + .Where(x => !x.Is_Deleted) + .OrderBy(x => x.Workshop_Code) + .OrderBy(x => x.Interface_Flag) + .ToDataTable(); + } + + public override bool Add(WorkshopInterfaceConfig model) + { + // 车间 + 接口标识 + isDeleted = 0 的唯一性校验 + bool isExist = _db.Queryable() + .Where(x => x.Workshop_Code == model.Workshop_Code && x.Interface_Flag == model.Interface_Flag && !x.Is_Deleted) + .Any(); + if (isExist) + { + throw new ArgumentException($"该车间{model.Workshop_Code}已存在该接口{model.Interface_Flag}"); + } + + return base.Add(model); + } + + public override bool Update(WorkshopInterfaceConfig model) + { + // 车间 + 接口标识 + isDeleted = 0 的唯一性校验 + bool isExist = _db.Queryable() + .Where(x => x.Workshop_Code == model.Workshop_Code && x.Interface_Flag == model.Interface_Flag && !x.Is_Deleted) + .Any(); + if (isExist) + { + return false; + } + + return base.Update(model); + } + + public override bool SoftDelete(int id) + { + return _db.Updateable() + .SetColumns(x => x.Is_Deleted == true) + .SetColumns(x => x.Update_Time == DateTime.Now) + .Where(x => x.Id == id) + .ExecuteCommand() > 0; + } + + + public string GetUrl(string workshopCode, string interfaceKey) + { + return _db.Queryable() + .Where(x => x.Workshop_Code == workshopCode && x.Interface_Flag == interfaceKey && !x.Is_Deleted) + .Select(x => x.Interface_Url) + .First(); + } + } +} diff --git a/JinYuan.Models/ConstValue.cs b/JinYuan.Models/ConstValue.cs index 7a8720b..6cdc886 100644 --- a/JinYuan.Models/ConstValue.cs +++ b/JinYuan.Models/ConstValue.cs @@ -8,10 +8,30 @@ namespace JinYuan.Models { public class ConstValue { - #region 日志文件夹名称 + /// + /// 料框查询接口标识 + /// + public const string INTER_QueryTray = "QueryTrayUrl"; + + /// + /// 料框解绑接口标识 + /// + public const string INTER_UnBindTray = "unBindTrayUrl"; + + /// + /// 定义车间偏移编号 /// 操作日志存储 /// + public static readonly Dictionary WorkshopMap = new Dictionary + { + { "601", 1 }, + { "602", 2 }, + { "603", 3 }, + { "604", 4 } + }; + + #region 日志文件夹名称 public const string USER_LOG = "OperaLog"; #endregion } diff --git a/JinYuan.VirtualDataLibrary/CommonMethods.cs b/JinYuan.VirtualDataLibrary/CommonMethods.cs index 736c498..adcd01b 100644 --- a/JinYuan.VirtualDataLibrary/CommonMethods.cs +++ b/JinYuan.VirtualDataLibrary/CommonMethods.cs @@ -26,7 +26,7 @@ namespace JinYuan.VirtualDataLibrary /// /// 本地数据库 /// - public static ISugarHelper db = new SQLSugarService(); + public static SQLSugarService db = new SQLSugarService(); /// /// 远程服务段数据库 /// diff --git a/JinYuan.VirtualDataLibrary/MesConfig.cs b/JinYuan.VirtualDataLibrary/MesConfig.cs index fec28ae..90d2431 100644 --- a/JinYuan.VirtualDataLibrary/MesConfig.cs +++ b/JinYuan.VirtualDataLibrary/MesConfig.cs @@ -182,6 +182,29 @@ namespace JinYuan.VirtualDataLibrary return 0; } + /// + /// 将电池型号+车间转换成下发PLC的型号编号 + /// + /// + public short GetModelNum(string modelName, string workshopCode) + { + short defVal = 0; + bool existModel = modelMapping.TryGetValue(modelName, out int resModel); + if (!existModel) + { + return defVal; // 键存在,返回对应值 + } + + bool existCode = ConstValue.WorkshopMap.TryGetValue(workshopCode, out short workshopOffset); + if (!existCode) + { + workshopOffset = 0; + } + + defVal = (short)(resModel * 10 + workshopOffset); + return defVal; + } + // 物流线各工位,生产型号写PLC地址 private Dictionary modelPLCAddr_Mapping = new Dictionary() { diff --git a/LargeSquareOne/FrmInterCfg.Designer.cs b/LargeSquareOne/FrmInterCfg.Designer.cs new file mode 100644 index 0000000..c9f7d61 --- /dev/null +++ b/LargeSquareOne/FrmInterCfg.Designer.cs @@ -0,0 +1,382 @@ +namespace LargeSquareOne +{ + partial class FrmInterCfg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); + this.panelEnhanced1 = new System.Windows.Forms.Panel(); + this.panel_mid = new System.Windows.Forms.Panel(); + this.btn_interSave = new System.Windows.Forms.Button(); + this.btn_interDelete = new System.Windows.Forms.Button(); + this.btn_interAdd = new System.Windows.Forms.Button(); + this.dgv_workInterface = new System.Windows.Forms.DataGridView(); + this.label2 = new AntdUI.Label(); + this.panel_bottom = new System.Windows.Forms.Panel(); + this.btn_test = new System.Windows.Forms.Button(); + this.btn_exit = new System.Windows.Forms.Button(); + this.panel_top = new System.Windows.Forms.Panel(); + this.btn_codeDelete = new System.Windows.Forms.Button(); + this.btn_codeSave = new System.Windows.Forms.Button(); + this.btn_codeAdd = new System.Windows.Forms.Button(); + this.label1 = new AntdUI.Label(); + this.dgv_materialRul = new System.Windows.Forms.DataGridView(); + this.bindingSource_frameRule = new System.Windows.Forms.BindingSource(this.components); + this.bindingSource_workInterface = new System.Windows.Forms.BindingSource(this.components); + this.panelEnhanced1.SuspendLayout(); + this.panel_mid.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_workInterface)).BeginInit(); + this.panel_bottom.SuspendLayout(); + this.panel_top.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_materialRul)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource_frameRule)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource_workInterface)).BeginInit(); + this.SuspendLayout(); + // + // panelEnhanced1 + // + this.panelEnhanced1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38))))); + this.panelEnhanced1.Controls.Add(this.panel_mid); + this.panelEnhanced1.Controls.Add(this.panel_bottom); + this.panelEnhanced1.Controls.Add(this.panel_top); + this.panelEnhanced1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelEnhanced1.Location = new System.Drawing.Point(0, 0); + this.panelEnhanced1.Name = "panelEnhanced1"; + this.panelEnhanced1.Size = new System.Drawing.Size(1207, 766); + this.panelEnhanced1.TabIndex = 0; + // + // panel_mid + // + this.panel_mid.BackColor = System.Drawing.Color.Transparent; + this.panel_mid.Controls.Add(this.btn_interSave); + this.panel_mid.Controls.Add(this.btn_interDelete); + this.panel_mid.Controls.Add(this.btn_interAdd); + this.panel_mid.Controls.Add(this.dgv_workInterface); + this.panel_mid.Controls.Add(this.label2); + this.panel_mid.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel_mid.Location = new System.Drawing.Point(0, 327); + this.panel_mid.Name = "panel_mid"; + this.panel_mid.Size = new System.Drawing.Size(1207, 339); + this.panel_mid.TabIndex = 1; + // + // btn_interSave + // + this.btn_interSave.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_interSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_interSave.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_interSave.ForeColor = System.Drawing.Color.White; + this.btn_interSave.Location = new System.Drawing.Point(1032, 230); + this.btn_interSave.Name = "btn_interSave"; + this.btn_interSave.Size = new System.Drawing.Size(103, 42); + this.btn_interSave.TabIndex = 6; + this.btn_interSave.Text = "保存"; + this.btn_interSave.UseVisualStyleBackColor = false; + this.btn_interSave.Click += new System.EventHandler(this.btn_interSave_Click); + // + // btn_interDelete + // + this.btn_interDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_interDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_interDelete.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_interDelete.ForeColor = System.Drawing.Color.White; + this.btn_interDelete.Location = new System.Drawing.Point(1032, 145); + this.btn_interDelete.Name = "btn_interDelete"; + this.btn_interDelete.Size = new System.Drawing.Size(103, 42); + this.btn_interDelete.TabIndex = 5; + this.btn_interDelete.Text = "删除"; + this.btn_interDelete.UseVisualStyleBackColor = false; + this.btn_interDelete.Click += new System.EventHandler(this.btn_interDelete_Click); + // + // btn_interAdd + // + this.btn_interAdd.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_interAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_interAdd.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_interAdd.ForeColor = System.Drawing.Color.White; + this.btn_interAdd.Location = new System.Drawing.Point(1032, 61); + this.btn_interAdd.Name = "btn_interAdd"; + this.btn_interAdd.Size = new System.Drawing.Size(103, 42); + this.btn_interAdd.TabIndex = 4; + this.btn_interAdd.Text = "增加"; + this.btn_interAdd.UseVisualStyleBackColor = false; + this.btn_interAdd.Click += new System.EventHandler(this.btn_interAdd_Click); + // + // dgv_workInterface + // + this.dgv_workInterface.AllowUserToAddRows = false; + this.dgv_workInterface.AllowUserToDeleteRows = false; + this.dgv_workInterface.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + this.dgv_workInterface.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_workInterface.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + dataGridViewCellStyle7.Font = new System.Drawing.Font("微软雅黑", 10.5F); + dataGridViewCellStyle7.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgv_workInterface.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7; + this.dgv_workInterface.ColumnHeadersHeight = 29; + this.dgv_workInterface.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 10.5F); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(20)))), ((int)(((byte)(80))))); + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgv_workInterface.DefaultCellStyle = dataGridViewCellStyle8; + this.dgv_workInterface.EnableHeadersVisualStyles = false; + this.dgv_workInterface.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(21)))), ((int)(((byte)(77)))), ((int)(((byte)(147))))); + this.dgv_workInterface.Location = new System.Drawing.Point(29, 47); + this.dgv_workInterface.Name = "dgv_workInterface"; + this.dgv_workInterface.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(40)))), ((int)(((byte)(86))))); + dataGridViewCellStyle9.Font = new System.Drawing.Font("微软雅黑", 10.5F); + dataGridViewCellStyle9.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(20)))), ((int)(((byte)(80))))); + dataGridViewCellStyle9.SelectionForeColor = System.Drawing.Color.White; + dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgv_workInterface.RowHeadersDefaultCellStyle = dataGridViewCellStyle9; + this.dgv_workInterface.RowHeadersWidth = 51; + this.dgv_workInterface.RowTemplate.Height = 27; + this.dgv_workInterface.Size = new System.Drawing.Size(942, 269); + this.dgv_workInterface.TabIndex = 3; + // + // label2 + // + this.label2.Font = new System.Drawing.Font("微软雅黑", 12F); + this.label2.ForeColor = System.Drawing.Color.White; + this.label2.Location = new System.Drawing.Point(29, 18); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(132, 23); + this.label2.TabIndex = 2; + this.label2.Text = "车间与接口"; + // + // panel_bottom + // + this.panel_bottom.BackColor = System.Drawing.Color.Transparent; + this.panel_bottom.Controls.Add(this.btn_test); + this.panel_bottom.Controls.Add(this.btn_exit); + this.panel_bottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel_bottom.Location = new System.Drawing.Point(0, 666); + this.panel_bottom.Name = "panel_bottom"; + this.panel_bottom.Size = new System.Drawing.Size(1207, 100); + this.panel_bottom.TabIndex = 2; + // + // btn_test + // + this.btn_test.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_test.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_test.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_test.ForeColor = System.Drawing.Color.White; + this.btn_test.Location = new System.Drawing.Point(1092, 29); + this.btn_test.Name = "btn_test"; + this.btn_test.Size = new System.Drawing.Size(103, 42); + this.btn_test.TabIndex = 5; + this.btn_test.Text = "For Test"; + this.btn_test.UseVisualStyleBackColor = false; + this.btn_test.Visible = false; + this.btn_test.Click += new System.EventHandler(this.btn_test_Click); + // + // btn_exit + // + this.btn_exit.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_exit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_exit.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_exit.ForeColor = System.Drawing.Color.White; + this.btn_exit.Location = new System.Drawing.Point(552, 29); + this.btn_exit.Name = "btn_exit"; + this.btn_exit.Size = new System.Drawing.Size(103, 42); + this.btn_exit.TabIndex = 4; + this.btn_exit.Text = "退出"; + this.btn_exit.UseVisualStyleBackColor = false; + this.btn_exit.Click += new System.EventHandler(this.btn_exit_Click); + // + // panel_top + // + this.panel_top.BackColor = System.Drawing.Color.Transparent; + this.panel_top.Controls.Add(this.btn_codeDelete); + this.panel_top.Controls.Add(this.btn_codeSave); + this.panel_top.Controls.Add(this.btn_codeAdd); + this.panel_top.Controls.Add(this.label1); + this.panel_top.Controls.Add(this.dgv_materialRul); + this.panel_top.Dock = System.Windows.Forms.DockStyle.Top; + this.panel_top.Location = new System.Drawing.Point(0, 0); + this.panel_top.Name = "panel_top"; + this.panel_top.Size = new System.Drawing.Size(1207, 327); + this.panel_top.TabIndex = 0; + // + // btn_codeDelete + // + this.btn_codeDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_codeDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_codeDelete.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_codeDelete.ForeColor = System.Drawing.Color.White; + this.btn_codeDelete.Location = new System.Drawing.Point(798, 136); + this.btn_codeDelete.Name = "btn_codeDelete"; + this.btn_codeDelete.Size = new System.Drawing.Size(103, 42); + this.btn_codeDelete.TabIndex = 4; + this.btn_codeDelete.Text = "删除"; + this.btn_codeDelete.UseVisualStyleBackColor = false; + this.btn_codeDelete.Click += new System.EventHandler(this.btn_codeDelete_Click); + // + // btn_codeSave + // + this.btn_codeSave.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_codeSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_codeSave.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_codeSave.ForeColor = System.Drawing.Color.White; + this.btn_codeSave.Location = new System.Drawing.Point(798, 200); + this.btn_codeSave.Name = "btn_codeSave"; + this.btn_codeSave.Size = new System.Drawing.Size(103, 42); + this.btn_codeSave.TabIndex = 3; + this.btn_codeSave.Text = "保存"; + this.btn_codeSave.UseVisualStyleBackColor = false; + this.btn_codeSave.Click += new System.EventHandler(this.btn_codeSave_Click); + // + // btn_codeAdd + // + this.btn_codeAdd.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_codeAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_codeAdd.Font = new System.Drawing.Font("微软雅黑", 11.5F); + this.btn_codeAdd.ForeColor = System.Drawing.Color.White; + this.btn_codeAdd.Location = new System.Drawing.Point(798, 67); + this.btn_codeAdd.Name = "btn_codeAdd"; + this.btn_codeAdd.Size = new System.Drawing.Size(103, 42); + this.btn_codeAdd.TabIndex = 2; + this.btn_codeAdd.Text = "增加"; + this.btn_codeAdd.UseVisualStyleBackColor = false; + this.btn_codeAdd.Click += new System.EventHandler(this.btn_codeAdd_Click); + // + // label1 + // + this.label1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(29, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(132, 23); + this.label1.TabIndex = 1; + this.label1.Text = "料框码与车间"; + // + // dgv_materialRul + // + this.dgv_materialRul.AllowUserToAddRows = false; + this.dgv_materialRul.AllowUserToDeleteRows = false; + this.dgv_materialRul.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + this.dgv_materialRul.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_materialRul.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + dataGridViewCellStyle10.Font = new System.Drawing.Font("微软雅黑", 10.5F); + dataGridViewCellStyle10.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgv_materialRul.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle10; + this.dgv_materialRul.ColumnHeadersHeight = 29; + this.dgv_materialRul.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(20)))), ((int)(((byte)(36))))); + dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F); + dataGridViewCellStyle11.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle11.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(20)))), ((int)(((byte)(80))))); + dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgv_materialRul.DefaultCellStyle = dataGridViewCellStyle11; + this.dgv_materialRul.EnableHeadersVisualStyles = false; + this.dgv_materialRul.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(21)))), ((int)(((byte)(77)))), ((int)(((byte)(147))))); + this.dgv_materialRul.Location = new System.Drawing.Point(29, 51); + this.dgv_materialRul.Name = "dgv_materialRul"; + this.dgv_materialRul.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle12.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(40)))), ((int)(((byte)(86))))); + dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 10.5F); + dataGridViewCellStyle12.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(20)))), ((int)(((byte)(80))))); + dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.White; + dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgv_materialRul.RowHeadersDefaultCellStyle = dataGridViewCellStyle12; + this.dgv_materialRul.RowHeadersWidth = 51; + this.dgv_materialRul.RowTemplate.Height = 27; + this.dgv_materialRul.Size = new System.Drawing.Size(731, 245); + this.dgv_materialRul.TabIndex = 0; + // + // FrmInterCfg + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 23F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1207, 766); + this.Controls.Add(this.panelEnhanced1); + this.Font = new System.Drawing.Font("微软雅黑", 10.5F); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.Name = "FrmInterCfg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "FrmInterCfg"; + this.Load += new System.EventHandler(this.FrmInterCfg_Load); + this.panelEnhanced1.ResumeLayout(false); + this.panel_mid.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dgv_workInterface)).EndInit(); + this.panel_bottom.ResumeLayout(false); + this.panel_top.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dgv_materialRul)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource_frameRule)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource_workInterface)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panelEnhanced1; + private System.Windows.Forms.Panel panel_bottom; + private System.Windows.Forms.Panel panel_mid; + private System.Windows.Forms.Panel panel_top; + private AntdUI.Label label1; + private System.Windows.Forms.DataGridView dgv_materialRul; + private System.Windows.Forms.Button btn_codeSave; + private System.Windows.Forms.Button btn_codeAdd; + private System.Windows.Forms.BindingSource bindingSource_frameRule; + private System.Windows.Forms.Button btn_exit; + private System.Windows.Forms.Button btn_codeDelete; + private System.Windows.Forms.Button btn_interSave; + private System.Windows.Forms.Button btn_interDelete; + private System.Windows.Forms.Button btn_interAdd; + private System.Windows.Forms.DataGridView dgv_workInterface; + private AntdUI.Label label2; + private System.Windows.Forms.BindingSource bindingSource_workInterface; + private System.Windows.Forms.Button btn_test; + } +} \ No newline at end of file diff --git a/LargeSquareOne/FrmInterCfg.cs b/LargeSquareOne/FrmInterCfg.cs new file mode 100644 index 0000000..65259ff --- /dev/null +++ b/LargeSquareOne/FrmInterCfg.cs @@ -0,0 +1,386 @@ +using JinYuan.ControlCenters; +using JinYuan.DAL.Models; +using JinYuan.DAL.Service; +using JinYuan.MES.Models; +using JinYuan.Models; +using JinYuan.VirtualDataLibrary; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LargeSquareOne +{ + public partial class FrmInterCfg : Form + { + public FrmInterCfg() + { + InitializeComponent(); + + InitDgv(); + } + + private void InitDgv() + { + #region 料框码与车间 + DataGridViewTextBoxColumn column_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + column_ID.HeaderText = "ID"; + column_ID.MinimumWidth = 6; + column_ID.Name = "Column_ID"; + column_ID.Visible = false; + column_ID.Width = 125; + column_ID.DataPropertyName = "ID"; + + DataGridViewTextBoxColumn column_StartCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + column_StartCode.HeaderText = "料框码匹配编码(第4-7位)"; + column_StartCode.MinimumWidth = 6; + column_StartCode.Name = "Column_StartCode"; + column_StartCode.Width = 225; + column_StartCode.DataPropertyName = "start_code"; + column_StartCode.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; + column_StartCode.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + + DataGridViewTextBoxColumn column_WorkshopCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + column_WorkshopCode.HeaderText = "车间"; + column_WorkshopCode.MinimumWidth = 6; + column_WorkshopCode.Name = "Column_WorkshopCode"; + column_WorkshopCode.Width = 225; + column_WorkshopCode.DataPropertyName = "workshop_code"; + column_WorkshopCode.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; + column_WorkshopCode.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + + DataGridViewTextBoxColumn column_IsDeleted = new System.Windows.Forms.DataGridViewTextBoxColumn(); + column_IsDeleted.HeaderText = "是否删除"; + column_IsDeleted.MinimumWidth = 6; + column_IsDeleted.Name = "Column_IsDeleted"; + column_IsDeleted.Visible = false; + column_IsDeleted.Width = 125; + column_IsDeleted.DataPropertyName = "is_deleted"; + + DataGridViewTextBoxColumn column_updateTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + column_updateTime.HeaderText = "更新时间"; + column_updateTime.MinimumWidth = 6; + column_updateTime.Name = "Column_updateTime"; + column_updateTime.Visible = false; + column_updateTime.Width = 125; + column_updateTime.DataPropertyName = "update_time"; + + dgv_materialRul.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + column_ID, + column_StartCode, + column_WorkshopCode, + column_IsDeleted, + column_updateTime + }); + #endregion + + #region 车间与接口 + DataGridViewTextBoxColumn colInter_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colInter_ID.HeaderText = "ID"; + colInter_ID.MinimumWidth = 6; + colInter_ID.Name = "colInter_ID"; + colInter_ID.Visible = false; + colInter_ID.Width = 125; + colInter_ID.DataPropertyName = "ID"; + + DataGridViewTextBoxColumn colInter_workShopCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colInter_workShopCode.HeaderText = "车间编码"; + colInter_workShopCode.MinimumWidth = 6; + colInter_workShopCode.Name = "colInter_workShopCode"; + colInter_workShopCode.Width = 225; + colInter_workShopCode.DataPropertyName = "workshop_code"; + colInter_workShopCode.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; + colInter_workShopCode.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + + DataGridViewTextBoxColumn colInter_interFlag = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colInter_interFlag.HeaderText = "接口标识"; + colInter_interFlag.MinimumWidth = 6; + colInter_interFlag.Name = "colInter_interFlag"; + colInter_interFlag.Width = 225; + colInter_interFlag.DataPropertyName = "interface_flag"; + colInter_interFlag.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader; + colInter_interFlag.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + + DataGridViewTextBoxColumn colInter_interName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colInter_interName.HeaderText = "接口名称"; + colInter_interName.MinimumWidth = 6; + colInter_interName.Name = "colInter_interName"; + colInter_interName.Width = 225; + colInter_interName.DataPropertyName = "interface_name"; + colInter_interName.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; + colInter_interName.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + + DataGridViewTextBoxColumn colInter_interUrl = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colInter_interUrl.HeaderText = "接口URL地址"; + colInter_interUrl.MinimumWidth = 6; + colInter_interUrl.Name = "colInter_interUrl"; + colInter_interUrl.Width = 225; + colInter_interUrl.DataPropertyName = "interface_url"; + colInter_interUrl.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; + colInter_interUrl.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; + + DataGridViewTextBoxColumn colInter_IsDeleted = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colInter_IsDeleted.HeaderText = "是否删除"; + colInter_IsDeleted.MinimumWidth = 6; + colInter_IsDeleted.Name = "colInter_IsDeleted"; + colInter_IsDeleted.Visible = false; + colInter_IsDeleted.Width = 125; + colInter_IsDeleted.DataPropertyName = "is_deleted"; + + DataGridViewTextBoxColumn colInter_updateTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colInter_updateTime.HeaderText = "更新时间"; + colInter_updateTime.MinimumWidth = 6; + colInter_updateTime.Name = "colInter_updateTime"; + colInter_updateTime.Visible = false; + colInter_updateTime.Width = 125; + colInter_updateTime.DataPropertyName = "update_time"; + + dgv_workInterface.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + colInter_ID, + colInter_workShopCode, + colInter_interFlag, + colInter_interName, + colInter_interUrl, + colInter_IsDeleted, + colInter_updateTime + }); + #endregion + } + + private MaterialFrameRuleService ruleService; + private WorkshopInterCfgService interService; + + private void InitDgvData() + { + ruleService = new MaterialFrameRuleService(CommonMethods.db.Db); + DataTable ruleDt = ruleService.GetDataTable(); + + bindingSource_frameRule.DataSource = ruleDt; + dgv_materialRul.DataSource = bindingSource_frameRule; + dgv_materialRul.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); + + interService = new WorkshopInterCfgService(CommonMethods.db.Db); + DataTable interDt = interService.GetDataTable(); + + bindingSource_workInterface.DataSource = interDt; + dgv_workInterface.DataSource = bindingSource_workInterface; + dgv_workInterface.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); + } + + private void FrmInterCfg_Load(object sender, EventArgs e) + { + InitDgvData(); + } + + private void btn_exit_Click(object sender, EventArgs e) + { + this.Close(); + } + + #region 料框码与车间 + private void btn_codeAdd_Click(object sender, EventArgs e) + { + bindingSource_frameRule.AddNew(); + } + + private void btn_codeSave_Click(object sender, EventArgs e) + { + DataTable dt = bindingSource_frameRule.DataSource as DataTable; + + StringBuilder sb = new StringBuilder(); + MaterialFrameRule model = null; + foreach (DataRow row in dt.Rows) + { + if (row.RowState == DataRowState.Deleted) + { + continue; + } + + try + { + model = row.ToModel(); + + switch (row.RowState) + { + case DataRowState.Added: + // 调用新增方法 + ruleService.Add(model); + break; + case DataRowState.Modified: + // 调用修改方法 + ruleService.Update(model); + break; + //case DataRowState.Deleted: + // // 调用删除方法 + // ruleService.SoftDelete(model.Id); + // break; + case DataRowState.Unchanged: + // 未更改,不处理 + break; + default: + break; + } + } + catch (Exception ex) + { + // 收集错误信息 + sb.AppendLine($"处理行时发生错误: {ex.Message}"); + } + } + + // 如果有错误信息,一起展示 + if (sb.Length > 0) + { + MessageBox.Show(sb.ToString(), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + DataTable ruleDt = ruleService.GetDataTable(); + bindingSource_frameRule.DataSource = ruleDt; + } + + private void btn_codeDelete_Click(object sender, EventArgs e) + { + // 获取选中的行删除 + foreach (DataGridViewRow row in dgv_materialRul.SelectedRows) + { + object colVal = row.Cells["Column_ID"].Value; + + if (colVal == null) + { + bindingSource_frameRule.RemoveAt(row.Index); + continue; + } + + int id = Convert.ToInt32(colVal); + bindingSource_frameRule.RemoveAt(row.Index); + ruleService.SoftDelete(id); + } + } + + #endregion + + #region 车间与接口 + private void btn_interAdd_Click(object sender, EventArgs e) + { + bindingSource_workInterface.AddNew(); + } + + private void btn_interDelete_Click(object sender, EventArgs e) + { + // 获取选中的行删除 + foreach (DataGridViewRow row in dgv_workInterface.SelectedRows) + { + object colVal = row.Cells["colInter_ID"].Value; + + if (colVal == null) + { + bindingSource_workInterface.RemoveAt(row.Index); + continue; + } + + int id = Convert.ToInt32(colVal); + bindingSource_workInterface.RemoveAt(row.Index); + interService.SoftDelete(id); + } + } + + private void btn_interSave_Click(object sender, EventArgs e) + { + DataTable dt = bindingSource_workInterface.DataSource as DataTable; + + StringBuilder sb = new StringBuilder(); + WorkshopInterfaceConfig model = null; + foreach (DataRow row in dt.Rows) + { + if (row.RowState == DataRowState.Deleted) + { + continue; + } + + try + { + model = row.ToModel(); + + switch (row.RowState) + { + case DataRowState.Added: + // 调用新增方法 + interService.Add(model); + break; + case DataRowState.Modified: + // 调用修改方法 + interService.Update(model); + break; + //case DataRowState.Deleted: + // // 调用删除方法 + // ruleService.SoftDelete(model.Id); + // break; + case DataRowState.Unchanged: + // 未更改,不处理 + break; + default: + break; + } + } + catch (Exception ex) + { + // 收集错误信息 + sb.AppendLine($"处理行时发生错误: {ex.Message}"); + } + } + + // 如果有错误信息,一起展示 + if (sb.Length > 0) + { + MessageBox.Show(sb.ToString(), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + DataTable ruleDt = ruleService.GetDataTable(); + bindingSource_frameRule.DataSource = ruleDt; + } + #endregion + + private void btn_test_Click(object sender, EventArgs e) + { + string trayId = "PLT60I10032567"; + string modelName = "LF350S"; + //UnbindTrayInfo(trayId).ConfigureAwait(false); + + MaterialFrameRuleService service = new MaterialFrameRuleService(CommonMethods.db.Db); + MaterialFrameRule rule = service.GetRuleByCode(trayId); + + short model = CommonMethods.mesConfig.GetModelNum(modelName, rule?.Workshop_Code ?? string.Empty); + + } + + private async Task<(bool success, string mesMessage)> UnbindTrayInfo(string trayID) + { + try + { + MesUrlService service = new MesUrlService(CommonMethods.db.Db); + string url = service.GetMesUrl(trayID, ConstValue.INTER_UnBindTray); + if (string.IsNullOrEmpty(url)) + { + throw new ArgumentException($"未找到{ConstValue.INTER_UnBindTray}对应的MES接口地址"); + } + + var (success, mesMessage) = await CommonMethods.hbgMes.UnbindTrayInfosAsync( + url, + CommonMethods.mesConfig.equipNum, + trayID + ).ConfigureAwait(false); + + return (success, mesMessage); + } + catch (Exception ex) + { + return (false, $"MES解绑失败{ex.Message}"); + } + } + } +} diff --git a/LargeSquareOne/FrmInterCfg.resx b/LargeSquareOne/FrmInterCfg.resx new file mode 100644 index 0000000..3222aa0 --- /dev/null +++ b/LargeSquareOne/FrmInterCfg.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 265, 17 + + \ No newline at end of file diff --git a/LargeSquareOne/FrmMain.cs b/LargeSquareOne/FrmMain.cs index 0ae6e61..4a472a1 100644 --- a/LargeSquareOne/FrmMain.cs +++ b/LargeSquareOne/FrmMain.cs @@ -1181,12 +1181,12 @@ namespace LargeSquareOne case FormNames.用户管理: frm = new FrmUserManage(); break; - //case FormNames.电池状况: - // frm = new FrmBatteryStatus(); - // CommonMethods.ShowBatteryStatusDelegate += ((FrmBatteryStatus)frm).ShowBatteryStatus;//电池状态显示 - // CommonMethods.ShowBatteryNGRsnDelegate += ((FrmBatteryStatus)frm).ShowBatteryNGRsn;//档位NG原因显示 - // CommonMethods.ShowBatteryReplaceDelegate += ((FrmBatteryStatus)frm).ShowBatteryReplace; - // break; + case FormNames.电池状况: + frm = new FrmBatteryStatus(); + CommonMethods.ShowBatteryStatusDelegate += ((FrmBatteryStatus)frm).ShowBatteryStatus;//电池状态显示 + CommonMethods.ShowBatteryNGRsnDelegate += ((FrmBatteryStatus)frm).ShowBatteryNGRsn;//档位NG原因显示 + CommonMethods.ShowBatteryReplaceDelegate += ((FrmBatteryStatus)frm).ShowBatteryReplace; + break; //case FormNames.二维码: // frm = new FrmQRCoder(); // CommonMethods.ShowBatteryQRCoderDelegate += ((FrmQRCoder)frm).ShowBatteryQRCoder; diff --git a/LargeSquareOne/FrmParamSet.Designer.cs b/LargeSquareOne/FrmParamSet.Designer.cs index 161f30d..8f1949f 100644 --- a/LargeSquareOne/FrmParamSet.Designer.cs +++ b/LargeSquareOne/FrmParamSet.Designer.cs @@ -124,6 +124,7 @@ this.txtQueryGrade = new System.Windows.Forms.TextBox(); this.lblUpResultParam = new System.Windows.Forms.Label(); this.txtUpResultParam = new System.Windows.Forms.TextBox(); + this.btn_cfgUrl = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dgvPlcConfigs)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvFdConfigs)).BeginInit(); this.capacityGroupBox.SuspendLayout(); @@ -468,6 +469,7 @@ // // txtQueryTray // + this.txtQueryTray.Enabled = false; this.txtQueryTray.Font = new System.Drawing.Font("Cambria", 10.5F, System.Drawing.FontStyle.Bold); this.txtQueryTray.Location = new System.Drawing.Point(64, 618); this.txtQueryTray.Name = "txtQueryTray"; @@ -1199,6 +1201,7 @@ // // txtUnbind // + this.txtUnbind.Enabled = false; this.txtUnbind.Font = new System.Drawing.Font("Cambria", 10.5F, System.Drawing.FontStyle.Bold); this.txtUnbind.Location = new System.Drawing.Point(64, 795); this.txtUnbind.Name = "txtUnbind"; @@ -1293,12 +1296,27 @@ this.txtUpResultParam.Size = new System.Drawing.Size(580, 24); this.txtUpResultParam.TabIndex = 111; // + // btn_cfgUrl + // + this.btn_cfgUrl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(27)))), ((int)(((byte)(78))))); + this.btn_cfgUrl.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_cfgUrl.Font = new System.Drawing.Font("Cambria", 10.5F, System.Drawing.FontStyle.Bold); + this.btn_cfgUrl.ForeColor = System.Drawing.Color.White; + this.btn_cfgUrl.Location = new System.Drawing.Point(674, 784); + this.btn_cfgUrl.Name = "btn_cfgUrl"; + this.btn_cfgUrl.Size = new System.Drawing.Size(137, 44); + this.btn_cfgUrl.TabIndex = 113; + this.btn_cfgUrl.Text = "其它接口配置"; + this.btn_cfgUrl.UseVisualStyleBackColor = false; + this.btn_cfgUrl.Click += new System.EventHandler(this.btn_cfgUrl_Click); + // // FrmSystemSet // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38))))); this.ClientSize = new System.Drawing.Size(1874, 868); + this.Controls.Add(this.btn_cfgUrl); this.Controls.Add(this.lblUpResultParam); this.Controls.Add(this.txtUpResultParam); this.Controls.Add(this.lblQueryGrade); @@ -1486,5 +1504,6 @@ private System.Windows.Forms.TextBox txtQueryGrade; private System.Windows.Forms.Label lblUpResultParam; private System.Windows.Forms.TextBox txtUpResultParam; + private System.Windows.Forms.Button btn_cfgUrl; } } \ No newline at end of file diff --git a/LargeSquareOne/FrmParamSet.cs b/LargeSquareOne/FrmParamSet.cs index 494c79c..3fa3f56 100644 --- a/LargeSquareOne/FrmParamSet.cs +++ b/LargeSquareOne/FrmParamSet.cs @@ -1921,5 +1921,10 @@ namespace LargeSquareOne } } + private void btn_cfgUrl_Click(object sender, EventArgs e) + { + FrmInterCfg frm = new FrmInterCfg(); + frm.ShowDialog(); + } } } diff --git a/LargeSquareOne/LargeSquareOne.csproj b/LargeSquareOne/LargeSquareOne.csproj index 1726a2a..aa266f1 100644 --- a/LargeSquareOne/LargeSquareOne.csproj +++ b/LargeSquareOne/LargeSquareOne.csproj @@ -239,6 +239,12 @@ FrmHelper.cs + + Form + + + FrmInterCfg.cs + Form @@ -375,6 +381,9 @@ FrmHelper.cs + + FrmInterCfg.cs + FrmLogin.cs diff --git a/UnitTestProject/Properties/AssemblyInfo.cs b/UnitTestProject/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..41f8d10 --- /dev/null +++ b/UnitTestProject/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("UnitTestProject")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTestProject")] +[assembly: AssemblyCopyright("Copyright © 2026")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("dd9ebab8-7a56-470d-92a6-60ceede963f7")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTestProject/UnitTest1.cs b/UnitTestProject/UnitTest1.cs new file mode 100644 index 0000000..dd7936b --- /dev/null +++ b/UnitTestProject/UnitTest1.cs @@ -0,0 +1,45 @@ +using JinYuan.DAL.Models; +using JinYuan.DAL.Service; +using JinYuan.VirtualDataLibrary; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; + +namespace UnitTestProject +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + string modelName = "LF350S"; + string workshopCode = "601"; + + short model = CommonMethods.mesConfig.GetModelNum(modelName, workshopCode); + + Assert.IsTrue(model == 11); + } + + [TestMethod] + public void TestMethod2() + { + string modelName = "LF350X"; + string workshopCode = "601"; + + short model = CommonMethods.mesConfig.GetModelNum(modelName, workshopCode); + + Assert.IsTrue(model == 0); + } + + [TestMethod] + public void TestMethod3() + { + string modelName = "LF350S"; + string workshopCode = "609"; + + short model = CommonMethods.mesConfig.GetModelNum(modelName, workshopCode); + + Assert.IsTrue(model == 10); + } + } +} diff --git a/UnitTestProject/UnitTestProject.csproj b/UnitTestProject/UnitTestProject.csproj new file mode 100644 index 0000000..b000d3e --- /dev/null +++ b/UnitTestProject/UnitTestProject.csproj @@ -0,0 +1,82 @@ + + + + + + Debug + AnyCPU + {DD9EBAB8-7A56-470D-92A6-60CEEDE963F7} + Library + Properties + UnitTestProject + UnitTestProject + v4.8 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + False + ..\LargeSquareOne\bin\Debug\SqlSugar.dll + + + + + + + + + + + + + + {114AA012-29C9-418C-A2D6-3173C5341F51} + JinYuan.DAL + + + {2AB7E380-7795-448A-933C-0F6A081B5E7E} + JinYuan.VirtualDataLibrary + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + + \ No newline at end of file diff --git a/UnitTestProject/packages.config b/UnitTestProject/packages.config new file mode 100644 index 0000000..2369fb2 --- /dev/null +++ b/UnitTestProject/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/数据库/workshop_materialFrame.sql b/数据库/workshop_materialFrame.sql new file mode 100644 index 0000000..1867b91 --- /dev/null +++ b/数据库/workshop_materialFrame.sql @@ -0,0 +1,50 @@ +-- ---------------------------- +-- 1. 料框码规则表(存储料框码起始编码与车间的对应关系) +-- ---------------------------- +DROP TABLE IF EXISTS `material_frame_rule`; +CREATE TABLE `material_frame_rule` ( + `id` INT NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `start_code` VARCHAR(20) NOT NULL COMMENT '料框码规则匹配编码(第4-7位)', + `workshop_code` VARCHAR(10) NOT NULL COMMENT '车间编码', + `is_deleted` TINYINT(1) DEFAULT 0 COMMENT '0:正常, 1:已删除(误删可恢复)', + `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_start_code` (`start_code`) -- 起始编码唯一约束 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='料框码规则表'; + +-- ---------------------------- +-- 2. 车间接口配置表(存储车间与接口的映射关系) +-- ---------------------------- +DROP TABLE IF EXISTS `workshop_interface_config`; +CREATE TABLE `workshop_interface_config` ( + `id` INT NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `workshop_code` VARCHAR(10) NOT NULL COMMENT '车间编码', + `interface_flag` VARCHAR(50) NOT NULL COMMENT '接口标识', + `interface_name` VARCHAR(100) NOT NULL COMMENT '接口名称', + `interface_url` VARCHAR(255) NOT NULL COMMENT '接口URL', + `is_deleted` TINYINT(1) DEFAULT 0 COMMENT '0:正常, 1:已删除(误删可恢复)', + `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_workshop_interface` (`workshop_code`, `interface_flag`) -- 车间+接口标识唯一约束 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='车间接口配置表'; + +-- ---------------------------- +-- 3. 初始化示例数据(根据业务需求调整) +-- ---------------------------- +INSERT INTO `material_frame_rule` (`start_code`, `workshop_code`) VALUES +('60I1', '601'), +('60I2', '602'), +('60I3', '603'), +('60I4', '604'); + +INSERT INTO `workshop_interface_config` (`workshop_code`, `interface_flag`, `interface_name`, `interface_url`) VALUES +('601', 'QueryTrayUrl', '料框查询', 'http://10.22.160.9/prod-api/produce/trayQuery/trayComposeInfo'), +('601', 'unBindTrayUrl', '料框解绑', 'http://10.22.160.9/prod-api/api/fms/mp/unbindWholeTray'), +('602', 'QueryTrayUrl', '料框查询', 'http://10.22.160.84/prod-api/produce/trayQuery/trayComposeInfo'), +('602', 'unBindTrayUrl', '料框解绑', 'http://10.22.160.84/prod-api/api/fms/mp/unbindWholeTray'), +('603', 'QueryTrayUrl', '料框查询', 'http://10.22.160.7/prod-api/produce/trayQuery/trayComposeInfo'), +('603', 'unBindTrayUrl', '料框解绑', 'http://10.22.160.7/prod-api/api/fms/mp/unbindWholeTray'), +('604', 'QueryTrayUrl', '料框查询', 'http://10.22.160.160/prod-api/produce/trayQuery/trayComposeInfo'), +('604', 'unBindTrayUrl', '料框解绑', 'http://10.22.160.160/prod-api/api/fms/mp/unbindWholeTray'); \ No newline at end of file