From 8f48b0735ce8048b6a8aec6470c33e9be781aec7 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Fri, 6 Jun 2025 17:32:21 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20=E6=8A=A5=E8=A1=A8=E5=92=8C=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E7=94=BB=E9=9D=A2=E4=B8=9A=E5=8A=A1=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HighWayIot.Plc/PlcHelper/TransferSingal.cs | 11 +- .../domain/ZxMesPlanTransferEntity.cs | 40 +- .../service/ZxDailyReportService.cs | 11 +- .../service/ZxMesPlanTransferService.cs | 2 +- .../service/ZxSchedulingService.cs | 18 + .../Business/MonitorDataRefreshBusiness.cs | 210 +++++--- .../Business/RecipeParaSyncBusiness.cs | 112 ----- .../Business/RecipeSendBusiness.cs | 430 ++++++++++++---- .../Business/WorkStationBusiness.cs | 1 + HighWayIot.Winform/HighWayIot.Winform.csproj | 1 - .../MainForm/BaseForm.Designer.cs | 6 + HighWayIot.Winform/MainForm/BaseForm.cs | 23 + .../EquipMaterialBindingPage.Designer.cs | 10 +- .../LogPages/DailyReportPage.Designer.cs | 265 +++++----- .../LogPages/DailyReportPage.cs | 4 + .../LogPages/ExportPreviewForm.cs | 2 +- .../MonitorMainPage.Designer.cs | 26 +- .../MonitorMainPages/MonitorMainPage.cs | 146 ++++-- .../ParamConfigPages/ProductionScheduling.cs | 8 +- .../RecipeConfigPages/AddWeightForm.cs | 2 +- .../RecipeConfigPage.Designer.cs | 212 ++++---- .../RecipeConfigPages/RecipeConfigPage.cs | 457 +----------------- .../UserControlPages/TestPage.Designer.cs | 152 +----- .../UserControlPages/TestPage.cs | 322 ++++++++++-- 24 files changed, 1236 insertions(+), 1235 deletions(-) delete mode 100644 HighWayIot.Winform/Business/RecipeParaSyncBusiness.cs diff --git a/HighWayIot.Plc/PlcHelper/TransferSingal.cs b/HighWayIot.Plc/PlcHelper/TransferSingal.cs index 62aa23b..7dc1d08 100644 --- a/HighWayIot.Plc/PlcHelper/TransferSingal.cs +++ b/HighWayIot.Plc/PlcHelper/TransferSingal.cs @@ -1,4 +1,5 @@ -using HighWayIot.Plc.PlcEntity; +using HighWayIot.Log4net; +using HighWayIot.Plc.PlcEntity; using HslCommunication; using System; using System.Collections.Generic; @@ -20,6 +21,7 @@ namespace HighWayIot.Plc.PlcHelper public byte[] ReadStationReportSignal() { OperateResult operateResult = PlcConnect.ReadByte2("D3001", 30); + //LogHelper.Instance.Info($"长度:{operateResult.Content.Length}"); if (!operateResult.IsSuccess) { return null; @@ -32,9 +34,12 @@ namespace HighWayIot.Plc.PlcHelper /// /// /// - public bool WriteStationReportSignal(int No) + public void WriteStationReportSignal(int No) { - return PlcConnect.PlcWrite2($"D301{No}", 0, DataTypeEnum.UInt16).IsSuccess; + if(!PlcConnect.PlcWrite2($"D300{No}", 0, DataTypeEnum.UInt16).IsSuccess) + { + LogHelper.Instance.Error($"工位小车报表信号复位失败 No.{No}"); + } } diff --git a/HighWayIot.Repository/domain/ZxMesPlanTransferEntity.cs b/HighWayIot.Repository/domain/ZxMesPlanTransferEntity.cs index 83b8e8e..b195fe2 100644 --- a/HighWayIot.Repository/domain/ZxMesPlanTransferEntity.cs +++ b/HighWayIot.Repository/domain/ZxMesPlanTransferEntity.cs @@ -5,13 +5,11 @@ using SqlSugar; namespace HighWayIot.Repository.domain { /// - /// + /// 配方同步中间表 /// [SugarTable("zx_mes_plan_transfer")] public class ZxMesPlanTransferEntity { - - /// /// 备 注:主键 /// 默认值: @@ -89,6 +87,13 @@ namespace HighWayIot.Repository.domain [SugarColumn(ColumnName = "material_name_1")] public string MaterialName1 { get; set; } = string.Empty; + /// + /// 备 注:物料名称1厚度 + /// 默认值: + /// + [SugarColumn(ColumnName = "material_thickness_1")] + public float? MaterialThickness1 { get; set; } + /// /// 备 注:贴合层数1基部胶 /// 默认值: @@ -132,49 +137,57 @@ namespace HighWayIot.Repository.domain public int? MaterialWidth13 { get; set; } /// - /// 备 注:物料名称2缓冲胶 + /// 备 注:物料名称2中层胶 /// 默认值: /// [SugarColumn(ColumnName = "material_name_2")] public string MaterialName2 { get; set; } = string.Empty; /// - /// 备 注:贴合层数2缓冲胶 + /// 备 注:物料名称2厚度 + /// 默认值: + /// + [SugarColumn(ColumnName = "material_thickness_2")] + public float? MaterialThickness2 { get; set; } + + + /// + /// 备 注:贴合层数2中层胶 /// 默认值: /// [SugarColumn(ColumnName = "material_layers_2")] public int? MaterialLayers2 { get; set; } /// - /// 备 注:贴合层数2缓冲胶2 + /// 备 注:贴合层数2中层胶2 /// 默认值: /// [SugarColumn(ColumnName = "material_layers_2_2")] public int? MaterialLayers22 { get; set; } /// - /// 备 注:贴合层数2缓冲胶3 + /// 备 注:贴合层数2中层胶3 /// 默认值: /// [SugarColumn(ColumnName = "material_layers_2_3")] public int? MaterialLayers23 { get; set; } /// - /// 备 注:宽度2缓冲胶 + /// 备 注:宽度2中层胶 /// 默认值: /// [SugarColumn(ColumnName = "material_width_2")] public int? MaterialWidth2 { get; set; } /// - /// 备 注:宽度2缓冲胶2 + /// 备 注:宽度2中层胶2 /// 默认值: /// [SugarColumn(ColumnName = "material_width_2_2")] public int? MaterialWidth22 { get; set; } /// - /// 备 注:宽度2缓冲胶3 + /// 备 注:宽度2中层胶3 /// 默认值: /// [SugarColumn(ColumnName = "material_width_2_3")] @@ -187,6 +200,13 @@ namespace HighWayIot.Repository.domain [SugarColumn(ColumnName = "material_name_3")] public string MaterialName3 { get; set; } = string.Empty; + /// + /// 备 注:物料名称3厚度 + /// 默认值: + /// + [SugarColumn(ColumnName = "material_thickness_3")] + public float? MaterialThickness3 { get; set; } + /// /// 备 注:贴合层数3胎面胶 /// 默认值: diff --git a/HighWayIot.Repository/service/ZxDailyReportService.cs b/HighWayIot.Repository/service/ZxDailyReportService.cs index ede15ba..5045f51 100644 --- a/HighWayIot.Repository/service/ZxDailyReportService.cs +++ b/HighWayIot.Repository/service/ZxDailyReportService.cs @@ -33,14 +33,15 @@ namespace HighWayIot.Repository.service /// 查询报表信息 /// /// - public List Get30DailyReportInfos() + public List GetOneDayDailyReportInfos() { try { + DateTime day = DateTime.Now - TimeSpan.FromDays(1); List entity = _repository.AsQueryable() + .Where(x => x.StartTime >= day) .OrderByDescending(x => x.StartTime) - .Take(30) .ToList(); return entity; } @@ -59,11 +60,11 @@ namespace HighWayIot.Repository.service { try { - ZxDailyReportEntity entity = + ZxDailyReportEntity entity = _repository.AsQueryable() .OrderByDescending(x => x.StartTime) .First(x => x.DeviceNo == rgvNo); - return entity; + return entity; } catch (Exception ex) { @@ -84,7 +85,7 @@ namespace HighWayIot.Repository.service List entity = _repository.GetList(whereExpression); return entity; } - catch(Exception ex) + catch (Exception ex) { log.Error("报表信息获取异常", ex); return null; diff --git a/HighWayIot.Repository/service/ZxMesPlanTransferService.cs b/HighWayIot.Repository/service/ZxMesPlanTransferService.cs index f2477ef..e22f370 100644 --- a/HighWayIot.Repository/service/ZxMesPlanTransferService.cs +++ b/HighWayIot.Repository/service/ZxMesPlanTransferService.cs @@ -72,7 +72,7 @@ namespace HighWayIot.Repository.service { try { - var result = _repository.Update(x => new ZxMesPlanTransferEntity() { RequestFlag = true }, x => x.Uuid == "syncsignal"); + var result = _repository.Update(x => new ZxMesPlanTransferEntity() { RequestFlag = true }, x => x.RequestFlag == false); return result; } catch (Exception ex) diff --git a/HighWayIot.Repository/service/ZxSchedulingService.cs b/HighWayIot.Repository/service/ZxSchedulingService.cs index 11ecbf9..855c0f9 100644 --- a/HighWayIot.Repository/service/ZxSchedulingService.cs +++ b/HighWayIot.Repository/service/ZxSchedulingService.cs @@ -86,5 +86,23 @@ namespace HighWayIot.Repository.service return false; } } + + /// + /// 修改排程信息 + /// + /// + /// + public bool UpdateSchedulingInfo(ZxSchedulingEntity entity) + { + try + { + return _repository.Update(entity); + } + catch (Exception ex) + { + log.Error("排程信息修改异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs b/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs index 0b38b0c..aafad04 100644 --- a/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs +++ b/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs @@ -1,4 +1,5 @@ -using HighWayIot.Plc; +using HighWayIot.Log4net; +using HighWayIot.Plc; using HighWayIot.Plc.PlcHelper; using HighWayIot.Repository.domain; using HighWayIot.Repository.service; @@ -23,7 +24,7 @@ namespace HighWayIot.Winform.Business TransferSingal transferSingal = new TransferSingal(); private Timer refreshTimer; - + public MonitorDataRefreshBusiness() { // 启动定时器,每隔1秒刷新一次报表数据 @@ -36,93 +37,130 @@ namespace HighWayIot.Winform.Business /// private void RefreshData(object o) { - byte[] signals = transferSingal.ReadStationReportSignal(); - if (signals == null) + try { - return; - } - - //解析返回的信号数据 - ushort[] rgvNo = new ushort[7]; - ushort[] rgvState = new ushort[7]; - float[] weights = new float[4]; - - for (int i = 0; i < 7; i++) - { - rgvNo[i] = BitConverter.ToUInt16(signals, i * 2); - rgvState[i] = BitConverter.ToUInt16(signals, (i * 2) + 20); - if (i > 2) + byte[] signals = transferSingal.ReadStationReportSignal(); + if (signals == null) { - weights[i - 3] = BitConverter.ToSingle(signals, ((i - 3) * 4) + 40); + return; } - } - //装圈工位 - if (rgvState[0] == 1) - { - // 监控画面信息插入 - MonitorInsert(RecipeSendBusiness.NowRecipeCode, RecipeSendBusiness.NowDeviceNo, rgvNo[0]); - MonitorMainPage.MonitorRefreshAction.Invoke(); - transferSingal.WriteStationReportSignal(1); // 复位信号 - } - //基部胶 - if (rgvState[1] == 1) - { - ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[1]); - if (entity == null) - { - goto n1; - } - entity.BaseEndTime = DateTime.Now; - ZxDailyReportService.Instance.UpdateDailyReportInfo(entity); - MonitorMainPage.MonitorRefreshAction.Invoke(); - transferSingal.WriteStationReportSignal(2); // 复位信号 - } - n1: - //中层胶 - if (rgvState[2] == 1) - { - ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[2]); - if(entity == null) - { - goto n2; - } - entity.MidEndTime = DateTime.Now; - ZxDailyReportService.Instance.UpdateDailyReportInfo(entity); - MonitorMainPage.MonitorRefreshAction.Invoke(); - transferSingal.WriteStationReportSignal(3); // 复位信号 - } - n2: + //解析返回的信号数据 + ushort[] rgvNo = new ushort[7]; + ushort[] rgvState = new ushort[7]; + float[] weights = new float[4]; - //胎面胶 - for (int i = 3; i <= 5; i++) - { - if (rgvState[i] == 1) + for (int i = 0; i < 7; i++) + { + rgvNo[i] = PlcConnect.MelsecInstance2.ByteTransform.TransUInt16(signals, (i * 2) + 20); + rgvState[i] = PlcConnect.MelsecInstance2.ByteTransform.TransUInt16(signals, i * 2); + if (i > 2) + { + weights[i - 3] = PlcConnect.MelsecInstance2.ByteTransform.TransSingle(signals, ((i - 3) * 4) + 38); + } + } + //LogHelper.Instance.Info(string.Join(", ", rgvNo)); + //LogHelper.Instance.Info(string.Join(", ", rgvState)); + + //装圈工位 + if (rgvState[0] == 1) { // 监控画面信息插入 - ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[i]); + if(MonitorInsert(RecipeSendBusiness.NowRecipeCode, RecipeSendBusiness.NowDeviceNo, rgvNo[0])) + { + MonitorMainPage.MonitorRefreshAction.Invoke(); + } + transferSingal.WriteStationReportSignal(1); // 复位信号 + } + //基部胶 + if (rgvState[1] == 1) + { + ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[1]); if (entity == null) { - continue; + transferSingal.WriteStationReportSignal(2); // 复位信号 + goto n1; } entity.BaseEndTime = DateTime.Now; - entity.RawTireWeight = (int)weights[i - 3]; - ZxDailyReportService.Instance.UpdateDailyReportInfo(entity); + if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) + { + MonitorMainPage.MonitorRefreshAction.Invoke(); + } + transferSingal.WriteStationReportSignal(2); // 复位信号 + } + n1: + + //中层胶 + if (rgvState[2] == 1) + { + ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[2]); + if (entity == null) + { + transferSingal.WriteStationReportSignal(3); // 复位信号 + goto n2; + } + entity.MidEndTime = DateTime.Now; + if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) + { + MonitorMainPage.MonitorRefreshAction.Invoke(); + } MonitorMainPage.MonitorRefreshAction.Invoke(); - transferSingal.WriteStationReportSignal(i + 1); // 复位信号 + transferSingal.WriteStationReportSignal(3); // 复位信号 + } + n2: + + //胎面胶 + for (int i = 3; i <= 5; i++) + { + if (rgvState[i] == 1) + { + // 监控画面信息插入 + ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[i]); + if (entity == null) + { + transferSingal.WriteStationReportSignal(i + 1); // 复位信号 + continue; + } + entity.FaceEndTime = DateTime.Now; + int temp = Convert.ToInt32(weights[i - 3]); + if (temp != 0) + { + entity.RawTireWeight = temp; + } + if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) + { + MonitorMainPage.MonitorRefreshAction.Invoke(); + } + transferSingal.WriteStationReportSignal(i + 1); // 复位信号 + } + } + + //结束 + if (rgvState[6] == 1) + { + ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[6]); + if (entity == null) + { + transferSingal.WriteStationReportSignal(7); // 复位信号 + return; + } + int temp = Convert.ToInt32(weights[3]); + entity.IsDone = 1; + if (temp != 0) + { + entity.RepeatWeight = temp; + } + if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) + { + MonitorMainPage.MonitorRefreshAction.Invoke(); + } + transferSingal.WriteStationReportSignal(7); // 复位信号 + } } - - //结束 - if (rgvState[6] == 1) + catch (Exception ex) { - ZxDailyReportEntity entity = ZxDailyReportService.Instance.GetNearData(rgvNo[6]); - entity.RepeatWeight = (int)weights[3]; - entity.IsDone = 1; - ZxDailyReportService.Instance.UpdateDailyReportInfo(entity); - MonitorMainPage.MonitorRefreshAction.Invoke(); - transferSingal.WriteStationReportSignal(7); // 复位信号 - + Log4net.LogHelper.Instance.Error("报表解析方法出现错误", ex); } } @@ -132,12 +170,28 @@ namespace HighWayIot.Winform.Business /// 机台号 /// 硫化机台编号 /// RGV编号 - public void MonitorInsert(string recipeCode, string deviceNo, int rgvNo) + public bool MonitorInsert(string recipeCode, string deviceNo, int rgvNo) { + DateTime judgeTime = DateTime.Now - TimeSpan.FromMinutes(30); + List judgeEntity = ZxDailyReportService.Instance + .GetDailyReportInfos(x => + x.DeviceNo == rgvNo && + x.IsDone == 0 && + x.StartTime >= judgeTime + ).ToList(); + + //要是二十分钟内有没完结的相同记录,就不插入 + if (judgeEntity.Count > 0) + { + Log4net.LogHelper.Instance.Info($"({deviceNo}车)重复插入"); + return false; + } + ZxRecipeEntity recipeEntity = ZxRecipeService.Instance.GetRecipeInfosByRecipeCode(recipeCode).FirstOrDefault(); if (recipeEntity == null) { - return; + Log4net.LogHelper.Instance.Info($"没有符合的配方数据({deviceNo}车)"); + return false; } ZxDailyReportEntity entity = new ZxDailyReportEntity() @@ -149,11 +203,11 @@ namespace HighWayIot.Winform.Business RecipeCode = recipeEntity.RecipeCode, SpecCode = recipeEntity.RecipeSpecCode, DeviceNo = rgvNo, - RawTireWeight = (int)ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault()?.TireWeight, + RawTireWeight = 0,//(int)ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault()?.TireWeight, IsDone = 0 }; - ZxDailyReportService.Instance.InsertDailyReportInfo(entity); + return ZxDailyReportService.Instance.InsertDailyReportInfo(entity); } } } diff --git a/HighWayIot.Winform/Business/RecipeParaSyncBusiness.cs b/HighWayIot.Winform/Business/RecipeParaSyncBusiness.cs deleted file mode 100644 index 6b1ce15..0000000 --- a/HighWayIot.Winform/Business/RecipeParaSyncBusiness.cs +++ /dev/null @@ -1,112 +0,0 @@ -using HighWayIot.Plc; -using HighWayIot.Plc.PlcHelper; -using HighWayIot.Repository.domain; -using HighWayIot.Repository.service; -using HighWayIot.Winform.MainForm; -using HslCommunication; -using Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using Timer = System.Threading.Timer; - -namespace HighWayIot.Winform.Business -{ - /// - /// 上位机配方同步业务类 - /// - public class RecipeParaSyncBusiness - { - //private Timer _readSignalTimer; - - //private RecipeParaHelper recipeParaHelper = new RecipeParaHelper(); - - //private ZxRecipeParaService zxRecipeParaService = ZxRecipeParaService.Instance; - - //private ZxRecipePositionParaService zxRecipePositionParaService = ZxRecipePositionParaService.Instance; - - //public RecipeParaSyncBusiness() - //{ - // _readSignalTimer = new Timer(new System.Threading.TimerCallback(ReadSignal), null, 0, 1500); - //} - - ///// - ///// 读取某个点位 - ///// - ///// - //private void ReadSignal(object o) - //{ - // OperateResult boolReault = PlcConnect.ReadBool2("B100"); - // if (!boolReault.IsSuccess) - // { - // return; - // } - // if (boolReault.Content) - // { - // PlcConnect.PlcWrite2("B100", false,DataTypeEnum.Bool); //写入完成信号 - // SyncRecipe(); - // } - //} - - ///// - ///// 配方同步 - ///// - //private void SyncRecipe() - //{ - // ZxRecipeParaEntity recipeParaEntity = new ZxRecipeParaEntity(); - // List positionParaEntities = recipeParaHelper.DownLoadFormPlc(ref recipeParaEntity); - - // //查重 - // var nowParaEntity = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeParaEntity.RecipeCode); - // var nowPositionParaEntity = zxRecipePositionParaService.GetRecipePositionParaInfoByRecipeCode(recipeParaEntity.RecipeCode); - - // //保存公共参数 - // if (nowParaEntity.Count == 0) //没有就插入 - // { - // if (!zxRecipeParaService.InsertRecipeParaInfo(recipeParaEntity)) - // { - // Log4net.LogHelper.Instance.Error("配方公共参数插入数据库失败"); - // return; - // } - // } - // else //有就更新 多条更新第一条 - // { - // recipeParaEntity.Id = nowParaEntity[0].Id; - // if (!zxRecipeParaService.UpdateRecipeParaInfo(recipeParaEntity)) - // { - // Log4net.LogHelper.Instance.Error("配方公共参数更新数据库失败"); - // return; - // } - // } - - - // //保存贴合参数 - // var flag2 = true; - // foreach (var item in positionParaEntities) - // { - // item.RecipeCode = recipeParaEntity.RecipeCode; - // var count = positionParaEntities.Count(x => x.Position == item.Position); - // //如果没有 - // if (count == 0) - // { - // flag2 = zxRecipePositionParaService.InsertRecipePositionParaInfo(item); - // } - // else //有 多条存第一条 - // { - // item.Id = positionParaEntities.FirstOrDefault(x => x.Position == item.Position).Id; - // flag2 = zxRecipePositionParaService.UpdateRecipePositionParaInfo(item); - - // if (count != 1) //多条提示 - // { - // Log4net.LogHelper.Instance.Error($"配方贴合参数重复,配方号:{recipeParaEntity.RecipeCode},工位号:{item.Position}"); - // } - // } - // if (!flag2) break; - // } - //} - } -} diff --git a/HighWayIot.Winform/Business/RecipeSendBusiness.cs b/HighWayIot.Winform/Business/RecipeSendBusiness.cs index fa5bc03..fc115cd 100644 --- a/HighWayIot.Winform/Business/RecipeSendBusiness.cs +++ b/HighWayIot.Winform/Business/RecipeSendBusiness.cs @@ -6,11 +6,13 @@ using HighWayIot.Repository.service; using Models; using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Schema; +using static Org.BouncyCastle.Math.EC.ECCurve; using Timer = System.Threading.Timer; namespace HighWayIot.Winform.Business @@ -71,6 +73,7 @@ namespace HighWayIot.Winform.Business } return; } + var schedulingInfo = zxSchedulingService.GetSchedulingInfo(); if (RecipeSendMode) //通过MES下配方 { @@ -78,106 +81,363 @@ namespace HighWayIot.Winform.Business List transferEntity = ZxMesPlanTransferService.Instance.GetRecipeInfos(x => x.RequestFlag == false).ToList(); if (transferEntity.Count > 1) { - LogHelper.Instance.Error($"标识同步数据不唯一,请检查数据库,当前数量:{transferEntity.Count}"); + LogHelper.Instance.Error($"标识同步数据不唯一,请检查是否有多选情况发生,当前数量:{transferEntity.Count}"); return; } if (transferEntity.Count == 0) { - LogHelper.Instance.Error("配方下发请求不存在,请检查数据库"); + LogHelper.Instance.Error("配方下发请求不存在,等待MES同步"); return; } - //同步到配方(配方和称量,如果是新的加字段) - //////////////////////////////更新配方表///////////////////////////////// - //var newEneitys = RecipeLists.Where(x => x.RecipeCode == newRecipes.RecipeCode).ToList(); - //if (newEneitys.Count > 0) //有就更新 - //{ - // //配方 - // newEneitys[0].RecipeSpecCode = newRecipes.SpecCode; - // newEneitys[0].RecipeSpecName = newRecipes.SpecName; - // newEneitys[0].SizeKind = newRecipes.RimInch; - // newEneitys[0].FixedWidth = newRecipes.FixRubWidth; - // if (!zxRecipeService.UpdateRecipeInfo(newEneitys[0])) - // { - // return; - // } - //} - //else //没有就插入 - //{ - // ZxRecipeEntity entity = new ZxRecipeEntity() - // { - // RecipeName = newRecipes.RecipeName, - // RecipeCode = newRecipes.RecipeCode, - // RecipeSpecCode = newRecipes.SpecCode, - // RecipeSpecName = newRecipes.SpecName, - // SizeKind = newRecipes.RimInch, - // FixedWidth = newRecipes.FixRubWidth, - // IsUse = true, - // IsDeleted = false, - // }; - // zxRecipeService.InsertRecipeInfo(entity); - //} + //同步配方 + ZxMesPlanTransferEntity newRecipes = transferEntity.First(); + SyncRecipe(newRecipes); + ZxMesPlanTransferService.Instance.SetFlagTrue(); //同步到对应硫化排程的界面 - //后续流程相同 - } - else //手动下配方 - { - var schedulingInfo = zxSchedulingService.GetSchedulingInfo(); - string recipeNo; - ZxRecipeParaEntity recipeParaInfo; - List zxRecipePositionParaEntities; - if ((destinationVulcanizationNo + 1) <= 62) + ZxSchedulingEntity schedulingEntity; + if ((destinationVulcanizationNo + 1) <= 62) //上模 { - recipeNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1).RecipeCode1; - recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); - zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); - if (recipeParaInfo == null) - { - LogHelper.Instance.Error("配方信息获取失败,请检查所选机台是否配置了相应配方"); - return; - } - if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) - { - //PlcConnect.PlcWrite2($"B{(destinationVulcanizationNo + 0x901).ToString("X")}", false, DataTypeEnum.Bool); - int deviceNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1).DeviceNo ?? 0; - //MonitorInsert(recipeNo, $"{deviceNo}上模"); - LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}上模"); - NowRecipeCode = recipeNo; - NowDeviceNo = deviceNo + "-2"; - } - else - { - LogHelper.Instance.Error("配方上传失败,检查PLC连接"); - return; - } + schedulingEntity = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1); + schedulingEntity.RecipeName2 = newRecipes.RecipeName; + schedulingEntity.RecipeCode2 = newRecipes.RecipeCode; + } + else //下模 + { + schedulingEntity = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1 - 62); + schedulingEntity.RecipeName1 = newRecipes.RecipeName; + schedulingEntity.RecipeCode1 = newRecipes.RecipeCode; + } + ZxSchedulingService.Instance.UpdateSchedulingInfo(schedulingEntity); + } + string recipeNo; + ZxRecipeParaEntity recipeParaInfo; + List zxRecipePositionParaEntities; + if ((destinationVulcanizationNo + 1) <= 62) //上模 + { + recipeNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1).RecipeCode1; + recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); + zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); + if (recipeParaInfo == null) + { + LogHelper.Instance.Error("配方信息获取失败,请检查所选机台是否配置了相应配方"); + return; + } + if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) + { + //PlcConnect.PlcWrite2($"B{(destinationVulcanizationNo + 0x901).ToString("X")}", false, DataTypeEnum.Bool); + int deviceNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1).DeviceNo ?? 0; + //MonitorInsert(recipeNo, $"{deviceNo}上模"); + LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}上模"); + NowRecipeCode = recipeNo; + NowDeviceNo = deviceNo + "-2"; } else { - recipeNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1 - 62).RecipeCode2; - recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); - zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); - if (recipeParaInfo == null) - { - LogHelper.Instance.Error("配方信息获取失败,请检查所选机台是否配置了相应配方"); - return; - } - if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) - { - //PlcConnect.PlcWrite2($"B{(destinationVulcanizationNo - 62 + 0x941).ToString("X")}", false, DataTypeEnum.Bool); - int deviceNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1 - 62).DeviceNo ?? 0; - //MonitorInsert(recipeNo, $"{deviceNo}下模"); - LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}下模"); - NowRecipeCode = recipeNo; - NowDeviceNo = deviceNo + "-1"; - } - else - { - LogHelper.Instance.Error("配方上传失败,检查PLC连接"); - return; - } + LogHelper.Instance.Error("配方上传失败,检查PLC连接"); + return; + } + } + else //下模 + { + recipeNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1 - 62).RecipeCode2; + recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); + zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); + if (recipeParaInfo == null) + { + LogHelper.Instance.Error("配方信息获取失败,请检查所选机台是否配置了相应配方"); + return; + } + if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) + { + //PlcConnect.PlcWrite2($"B{(destinationVulcanizationNo - 62 + 0x941).ToString("X")}", false, DataTypeEnum.Bool); + int deviceNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1 - 62).DeviceNo ?? 0; + //MonitorInsert(recipeNo, $"{deviceNo}下模"); + LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}下模"); + NowRecipeCode = recipeNo; + NowDeviceNo = deviceNo + "-1"; + } + else + { + LogHelper.Instance.Error("配方上传失败,检查PLC连接"); + return; } } } + + /// + /// 配方同步方法 + /// + public void SyncRecipe(ZxMesPlanTransferEntity newRecipe) + { + if (newRecipe == null) + { + return; + } + //同步到配方(配方和称量,如果是新的加字段) + List RecipeLists = ZxRecipeService.Instance.GetRecipeInfos(); + var nowEneity = RecipeLists.Where(x => x.RecipeCode == newRecipe.RecipeCode && x.IsDeleted == false).FirstOrDefault(); + if (nowEneity != null) //有就更新 只更新配方和称量信息 + { + //同步配方 + nowEneity.RecipeSpecCode = newRecipe.SpecCode; + nowEneity.RecipeSpecName = newRecipe.SpecName; + nowEneity.SizeKind = newRecipe.RimInch; + nowEneity.FixedWidth = newRecipe.FixRubWidth; + if (!ZxRecipeService.Instance.UpdateRecipeInfo(nowEneity)) + { + return; + } + + //同步称量信息 + List zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); + for (int i = 1; i <= 3; i++) + { + string typeName = string.Empty; + switch (i) + { + case 1: + typeName = "基部胶"; + break; + case 2: + typeName = "中层胶"; + break; + case 3: + typeName = "胎面胶"; + break; + default: + break; + } + string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); + if (!string.IsNullOrEmpty(MaterialName)) + { + ZxWeightEntity weight = zxWeightEntities.FirstOrDefault(x => x.MaterialCode == MaterialName); + if (weight != null) //原来就有 + { + weight.SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)); //(decimal)newRecipe.MaterialThickness1; + weight.SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)); //newRecipe.MaterialWidth1; + weight.SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)); //newRecipe.MaterialWidth12; + weight.SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)); //newRecipe.MaterialWidth13; + weight.SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)); //newRecipe.MaterialLayers1; + weight.SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)); //newRecipe.MaterialLayers12; + weight.SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)); //newRecipe.MaterialLayers13; + ZxWeightService.Instance.UpdateWeightInfo(weight); + } + else //原来没有就添加 + { + ZxWeightService.Instance.InsertWeightInfo(new ZxWeightEntity() + { + RecipeCode = newRecipe.RecipeCode, + MaterialCode = MaterialName, + MaterialName = MaterialName + typeName, + MaterialType = typeName, + SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)), + SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), + SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), + SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), + SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)), + SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)), + SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)), + SetError = 1, + IsUse = true, + IsDeleted = false, + }); + } + } + } + } + else //没有就插入 全部同步 + { + //同步配方 + ZxRecipeEntity entity = new ZxRecipeEntity() + { + RecipeName = newRecipe.RecipeName, + RecipeCode = newRecipe.RecipeCode, + RecipeSpecCode = newRecipe.SpecCode, + RecipeSpecName = newRecipe.SpecName, + SizeKind = newRecipe.RimInch, + FixedWidth = newRecipe.FixRubWidth, + IsUse = true, + IsDeleted = false, + }; + ZxRecipeService.Instance.InsertRecipeInfo(entity); + + //同步称量信息 + List zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); + for (int i = 1; i <= 3; i++) + { + string typeName = string.Empty; + switch (i) + { + case 1: + typeName = "基部胶"; + break; + case 2: + typeName = "中层胶"; + break; + case 3: + typeName = "胎面胶"; + break; + default: + break; + } + string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); + if (!string.IsNullOrEmpty(MaterialName)) + { + ZxWeightEntity weight = zxWeightEntities.FirstOrDefault(x => x.MaterialCode == MaterialName); + if (weight != null) //原来就有 + { + weight.SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)); //(decimal)newRecipe.MaterialThickness1; + weight.SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)); //newRecipe.MaterialWidth1; + weight.SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)); //newRecipe.MaterialWidth12; + weight.SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)); //newRecipe.MaterialWidth13; + weight.SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)); //newRecipe.MaterialLayers1; + weight.SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)); //newRecipe.MaterialLayers12; + weight.SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)); //newRecipe.MaterialLayers13; + ZxWeightService.Instance.UpdateWeightInfo(weight); + } + else //原来没有就添加 + { + ZxWeightService.Instance.InsertWeightInfo(new ZxWeightEntity() + { + RecipeCode = newRecipe.RecipeCode, + MaterialCode = MaterialName, + MaterialName = MaterialName + typeName, + MaterialType = typeName, + SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)), + SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), + SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), + SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), + SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)), + SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)), + SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)), + SetError = 1, + IsUse = true, + IsDeleted = false, + }); + } + } + } + + //同步公共参数 + ZxRecipeParaEntity recipeParaEntity = new ZxRecipeParaEntity(); + recipeParaEntity.RimInch = newRecipe.RimInch; + recipeParaEntity.LightWidth = newRecipe.FixRubWidth; + recipeParaEntity.SlowDistance = 0; + recipeParaEntity.StopDistance = 0; + recipeParaEntity.TireWeight = newRecipe.TireWeight; + recipeParaEntity.SpecCode = newRecipe.SpecCode; + recipeParaEntity.SpecName = newRecipe.SpecName; + recipeParaEntity.RecipeCode = newRecipe.RecipeCode; + + //自动工位选择 + zxWeightEntities.Clear(); + zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); + List openMixConfig = ZxOpenMixMaterialService.Instance.GetInfos(); + foreach (ZxWeightEntity weightEntity in zxWeightEntities) + { + var config = openMixConfig.Where(x => x.MaterialName == weightEntity.MaterialName).FirstOrDefault(); + if (config == null) + { + continue; + } + var prop = recipeParaEntity.GetType().GetProperty($"S{config.StationNo + 1}"); + if (prop != null) + { + prop.SetValue(recipeParaEntity, true); + } + //自动包边选择 + if (!(weightEntity.SetLayer2 == 0 + || weightEntity.SetLayer2 == null + || weightEntity.SetWidth2 == null + || weightEntity.SetWidth2 == 0)) + { + var propp = recipeParaEntity.GetType().GetProperty($"B{config.StationNo - 1}"); + if (propp != null) + { + propp.SetValue(recipeParaEntity, true); + } + } + if (!(weightEntity.SetLayer3 == 0 + || weightEntity.SetLayer3 == null + || weightEntity.SetWidth3 == null + || weightEntity.SetWidth3 == 0)) + { + var propp = recipeParaEntity.GetType().GetProperty($"B{config.StationNo + 4}"); + if (propp != null) + { + propp.SetValue(recipeParaEntity, true); + } + } + //设置胎体重量 + if (weightEntity.MaterialType == "胎面胶") + { + recipeParaEntity.TireWeight = Convert.ToSingle(weightEntity.SetWeight); + switch (config.StationNo) + { + case 3: + recipeParaEntity.S7 = true; + break; + case 4: + recipeParaEntity.S8 = true; + break; + case 5: + recipeParaEntity.S9 = true; + break; + default: + break; + } + } + } + ZxRecipeParaEntity nowRecipeParaEntity = ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(nowEneity.RecipeCode).FirstOrDefault(); + + if (nowRecipeParaEntity != null) //如果存在就更改 + { + recipeParaEntity.Id = nowRecipeParaEntity.Id; + ZxRecipeParaService.Instance.UpdateRecipeParaInfo(recipeParaEntity); + } + else + { + ZxRecipeParaService.Instance.InsertRecipeParaInfo(recipeParaEntity); + } + + //同步工位参数 + ZxRecipePositionParaService.Instance.DeleteRecipePositionParaInfoByRecipeCode(newRecipe.RecipeCode); //删除可能存在的脏数据 + for (int i = 1; i <= 3; i++) + { + string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); + if (string.IsNullOrEmpty(MaterialName)) + { + continue; + } + + var config = openMixConfig.Where(x => x.MaterialName.Contains(MaterialName)).FirstOrDefault(); + if (config == null) + { + continue; + } + ZxRecipePositionParaEntity positionEntity = new ZxRecipePositionParaEntity() + { + RecipeCode = newRecipe.RecipeCode, + Position = config.StationNo, + E1 = 15, + E2 = 52, + E5 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)) * 10, + E9 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), + E6 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)) * 10, + E7 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), + E3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)) * 10, + E4 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), + E10 = 800, + E8 = 300 + }; + + ZxRecipePositionParaService.Instance.InsertRecipePositionParaInfo(positionEntity); + } + + } + + } } } diff --git a/HighWayIot.Winform/Business/WorkStationBusiness.cs b/HighWayIot.Winform/Business/WorkStationBusiness.cs index 467db17..e444a4d 100644 --- a/HighWayIot.Winform/Business/WorkStationBusiness.cs +++ b/HighWayIot.Winform/Business/WorkStationBusiness.cs @@ -131,6 +131,7 @@ namespace HighWayIot.Winform.Business catch (Exception ex) { LogHelper.Instance.Error($"[{no}] 工位读写器信息获取失败!", ex); + return; } if (setting == null) diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj index a0cd5a7..91b386c 100644 --- a/HighWayIot.Winform/HighWayIot.Winform.csproj +++ b/HighWayIot.Winform/HighWayIot.Winform.csproj @@ -149,7 +149,6 @@ - diff --git a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs index 58c6d96..0c0eb67 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs @@ -270,6 +270,7 @@ namespace HighWayIot.Winform.MainForm this.UserControlTabs.SelectedIndex = 0; this.UserControlTabs.Size = new System.Drawing.Size(1905, 995); this.UserControlTabs.TabIndex = 3; + this.UserControlTabs.Selected += new TabControlEventHandler(this.TabControlChange); // // ClosePageButton // @@ -442,6 +443,11 @@ namespace HighWayIot.Winform.MainForm } + private void UserControlTabs_IndexChanged(object sender, System.EventArgs e) + { + throw new System.NotImplementedException(); + } + #endregion private MenuStrip MainMenu; private ToolStripMenuItem SysConfigStripMenuItem; diff --git a/HighWayIot.Winform/MainForm/BaseForm.cs b/HighWayIot.Winform/MainForm/BaseForm.cs index 7bf8c12..a019828 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.cs @@ -47,6 +47,11 @@ namespace HighWayIot.Winform.MainForm /// RecipeSendBusiness recipeSendBusiness = new RecipeSendBusiness(); + /// + /// 监控报表刷新类 + /// + MonitorDataRefreshBusiness monitorDataRefreshBusiness = new MonitorDataRefreshBusiness(); + /// /// 底边栏消息提示刷新 /// @@ -397,5 +402,23 @@ namespace HighWayIot.Winform.MainForm ModeSelectLabel.BackColor = Color.FromArgb(100, 255, 255, 128); } } + + /// + /// TabControl选项卡更改事件 + /// + /// + /// + private void TabControlChange(object sender, TabControlEventArgs e) + { + if(e.TabPage.Text == "硫化排程") + { + UserControl control = UserControls.Where(x => x.Tag.ToString() == "硫化排程").Single(); + if (control is ProductionScheduling) + { + ProductionScheduling productionScheduling = control as ProductionScheduling; + productionScheduling.ComboBoxBind(); + } + } + } } } diff --git a/HighWayIot.Winform/UserControlPages/EquipMaterialBindingPage.Designer.cs b/HighWayIot.Winform/UserControlPages/EquipMaterialBindingPage.Designer.cs index 2d1a103..cecb6db 100644 --- a/HighWayIot.Winform/UserControlPages/EquipMaterialBindingPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/EquipMaterialBindingPage.Designer.cs @@ -48,7 +48,7 @@ namespace HighWayIot.Winform.UserControlPages this.RoleDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.RoleDataGridView.Name = "RoleDataGridView"; this.RoleDataGridView.RowTemplate.Height = 25; - this.RoleDataGridView.Size = new System.Drawing.Size(883, 497); + this.RoleDataGridView.Size = new System.Drawing.Size(1228, 675); this.RoleDataGridView.TabIndex = 0; this.RoleDataGridView.Tag = ""; // @@ -70,10 +70,10 @@ namespace HighWayIot.Winform.UserControlPages this.ButtonPanel.Location = new System.Drawing.Point(0, 0); this.ButtonPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonPanel.Name = "ButtonPanel"; - this.ButtonPanel.Size = new System.Drawing.Size(883, 61); + this.ButtonPanel.Size = new System.Drawing.Size(1228, 61); this.ButtonPanel.TabIndex = 4; // - // OperateConfigPage + // EquipMaterialBindingPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -81,8 +81,8 @@ namespace HighWayIot.Winform.UserControlPages this.Controls.Add(this.ButtonPanel); this.Controls.Add(this.RoleDataGridView); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.Name = "OperateConfigPage"; - this.Size = new System.Drawing.Size(883, 562); + this.Name = "EquipMaterialBindingPage"; + this.Size = new System.Drawing.Size(1228, 740); ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).EndInit(); this.ButtonPanel.ResumeLayout(false); this.ResumeLayout(false); diff --git a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs index 2272d7a..4ae5582 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs @@ -33,21 +33,6 @@ namespace HighWayIot.Winform.UserControlPages { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.ReportDataGridView = new System.Windows.Forms.DataGridView(); - this.ButtonPanel = new System.Windows.Forms.Panel(); - this.ExportTableButton = new System.Windows.Forms.Button(); - this.label6 = new System.Windows.Forms.Label(); - this.VulcanizationNoCombobox = new System.Windows.Forms.ComboBox(); - this.RecipeCodeCombobox = new System.Windows.Forms.ComboBox(); - this.label2 = new System.Windows.Forms.Label(); - this.DeviceNoCombobox = new System.Windows.Forms.ComboBox(); - this.label4 = new System.Windows.Forms.Label(); - this.SelectEndTime = new System.Windows.Forms.DateTimePicker(); - this.SelectStartTime = new System.Windows.Forms.DateTimePicker(); - this.label3 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.SelectReport = new System.Windows.Forms.Button(); - this.label5 = new System.Windows.Forms.Label(); - this.DataCountLabel = new System.Windows.Forms.Label(); this.No = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.VulcanizationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.StartTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -60,6 +45,21 @@ namespace HighWayIot.Winform.UserControlPages this.MidRubTimeSpan = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.FaceRubTimeSpan = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ButtonPanel = new System.Windows.Forms.Panel(); + this.DataCountLabel = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.ExportTableButton = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.VulcanizationNoCombobox = new System.Windows.Forms.ComboBox(); + this.RecipeCodeCombobox = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.DeviceNoCombobox = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.SelectEndTime = new System.Windows.Forms.DateTimePicker(); + this.SelectStartTime = new System.Windows.Forms.DateTimePicker(); + this.label3 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.SelectReport = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.ReportDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.SuspendLayout(); @@ -102,6 +102,105 @@ namespace HighWayIot.Winform.UserControlPages this.ReportDataGridView.Size = new System.Drawing.Size(1639, 868); this.ReportDataGridView.TabIndex = 7; // + // No + // + this.No.DataPropertyName = "No"; + this.No.HeaderText = "ID"; + this.No.Name = "No"; + this.No.ReadOnly = true; + this.No.Width = 50; + // + // VulcanizationNo + // + this.VulcanizationNo.DataPropertyName = "VulcanizationNo"; + this.VulcanizationNo.HeaderText = "机位"; + this.VulcanizationNo.Name = "VulcanizationNo"; + this.VulcanizationNo.ReadOnly = true; + this.VulcanizationNo.Width = 70; + // + // StartTime + // + this.StartTime.DataPropertyName = "StartTime"; + this.StartTime.HeaderText = "开始时间"; + this.StartTime.Name = "StartTime"; + this.StartTime.ReadOnly = true; + this.StartTime.Width = 150; + // + // RecipeCode + // + this.RecipeCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RecipeCode.DataPropertyName = "RecipeCode"; + this.RecipeCode.FillWeight = 30F; + this.RecipeCode.HeaderText = "成品代号"; + this.RecipeCode.Name = "RecipeCode"; + this.RecipeCode.ReadOnly = true; + // + // RecipeName + // + this.RecipeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RecipeName.DataPropertyName = "RecipeName"; + this.RecipeName.FillWeight = 70F; + this.RecipeName.HeaderText = "标称尺度"; + this.RecipeName.Name = "RecipeName"; + this.RecipeName.ReadOnly = true; + // + // SpecCode + // + this.SpecCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.SpecCode.DataPropertyName = "SpecCode"; + this.SpecCode.FillWeight = 30F; + this.SpecCode.HeaderText = "Spec编号"; + this.SpecCode.Name = "SpecCode"; + this.SpecCode.ReadOnly = true; + // + // DeviceNo + // + this.DeviceNo.DataPropertyName = "DeviceNo"; + this.DeviceNo.HeaderText = "小车编号"; + this.DeviceNo.Name = "DeviceNo"; + this.DeviceNo.ReadOnly = true; + this.DeviceNo.Width = 80; + // + // RawTireWeight + // + this.RawTireWeight.DataPropertyName = "RawTireWeight"; + this.RawTireWeight.HeaderText = "生胎重量"; + this.RawTireWeight.Name = "RawTireWeight"; + this.RawTireWeight.ReadOnly = true; + this.RawTireWeight.Width = 80; + // + // BaseRubTimeSpan + // + this.BaseRubTimeSpan.DataPropertyName = "BaseRubTimeSpan"; + this.BaseRubTimeSpan.HeaderText = "基部胶完成时间"; + this.BaseRubTimeSpan.Name = "BaseRubTimeSpan"; + this.BaseRubTimeSpan.ReadOnly = true; + this.BaseRubTimeSpan.Width = 140; + // + // MidRubTimeSpan + // + this.MidRubTimeSpan.DataPropertyName = "MidRubTimeSpan"; + this.MidRubTimeSpan.HeaderText = "中层胶完成时间"; + this.MidRubTimeSpan.Name = "MidRubTimeSpan"; + this.MidRubTimeSpan.ReadOnly = true; + this.MidRubTimeSpan.Width = 150; + // + // FaceRubTimeSpan + // + this.FaceRubTimeSpan.DataPropertyName = "FaceRubTimeSpan"; + this.FaceRubTimeSpan.HeaderText = "生胎完成时间"; + this.FaceRubTimeSpan.Name = "FaceRubTimeSpan"; + this.FaceRubTimeSpan.ReadOnly = true; + this.FaceRubTimeSpan.Width = 140; + // + // RepeatWeight + // + this.RepeatWeight.DataPropertyName = "RepeatWeight"; + this.RepeatWeight.HeaderText = "复重重量"; + this.RepeatWeight.Name = "RepeatWeight"; + this.RepeatWeight.ReadOnly = true; + this.RepeatWeight.Width = 80; + // // ButtonPanel // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -125,6 +224,25 @@ namespace HighWayIot.Winform.UserControlPages this.ButtonPanel.Name = "ButtonPanel"; this.ButtonPanel.Size = new System.Drawing.Size(1636, 61); this.ButtonPanel.TabIndex = 6; + this.ButtonPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.ButtonPanel_Paint); + // + // DataCountLabel + // + this.DataCountLabel.AutoSize = true; + this.DataCountLabel.Location = new System.Drawing.Point(842, 38); + this.DataCountLabel.Name = "DataCountLabel"; + this.DataCountLabel.Size = new System.Drawing.Size(23, 12); + this.DataCountLabel.TabIndex = 29; + this.DataCountLabel.Text = "N/A"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(771, 38); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(65, 12); + this.label5.TabIndex = 28; + this.label5.Text = "数据条目:"; // // ExportTableButton // @@ -237,123 +355,6 @@ namespace HighWayIot.Winform.UserControlPages this.SelectReport.UseVisualStyleBackColor = true; this.SelectReport.Click += new System.EventHandler(this.SelectReport_Click); // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(771, 38); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(65, 12); - this.label5.TabIndex = 28; - this.label5.Text = "数据条目:"; - // - // DataCountLabel - // - this.DataCountLabel.AutoSize = true; - this.DataCountLabel.Location = new System.Drawing.Point(842, 38); - this.DataCountLabel.Name = "DataCountLabel"; - this.DataCountLabel.Size = new System.Drawing.Size(23, 12); - this.DataCountLabel.TabIndex = 29; - this.DataCountLabel.Text = "N/A"; - // - // No - // - this.No.DataPropertyName = "No"; - this.No.HeaderText = "ID"; - this.No.Name = "No"; - this.No.ReadOnly = true; - this.No.Width = 50; - // - // VulcanizationNo - // - this.VulcanizationNo.DataPropertyName = "VulcanizationNo"; - this.VulcanizationNo.HeaderText = "机位"; - this.VulcanizationNo.Name = "VulcanizationNo"; - this.VulcanizationNo.ReadOnly = true; - this.VulcanizationNo.Width = 70; - // - // StartTime - // - this.StartTime.DataPropertyName = "StartTime"; - this.StartTime.HeaderText = "开始时间"; - this.StartTime.Name = "StartTime"; - this.StartTime.ReadOnly = true; - this.StartTime.Width = 150; - // - // RecipeCode - // - this.RecipeCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RecipeCode.DataPropertyName = "RecipeCode"; - this.RecipeCode.FillWeight = 30F; - this.RecipeCode.HeaderText = "成品代号"; - this.RecipeCode.Name = "RecipeCode"; - this.RecipeCode.ReadOnly = true; - // - // RecipeName - // - this.RecipeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RecipeName.DataPropertyName = "RecipeName"; - this.RecipeName.FillWeight = 70F; - this.RecipeName.HeaderText = "标称尺度"; - this.RecipeName.Name = "RecipeName"; - this.RecipeName.ReadOnly = true; - // - // SpecCode - // - this.SpecCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.SpecCode.DataPropertyName = "SpecCode"; - this.SpecCode.FillWeight = 30F; - this.SpecCode.HeaderText = "Spec编号"; - this.SpecCode.Name = "SpecCode"; - this.SpecCode.ReadOnly = true; - // - // DeviceNo - // - this.DeviceNo.DataPropertyName = "DeviceNo"; - this.DeviceNo.HeaderText = "小车编号"; - this.DeviceNo.Name = "DeviceNo"; - this.DeviceNo.ReadOnly = true; - this.DeviceNo.Width = 80; - // - // RawTireWeight - // - this.RawTireWeight.DataPropertyName = "RawTireWeight"; - this.RawTireWeight.HeaderText = "生胎重量"; - this.RawTireWeight.Name = "RawTireWeight"; - this.RawTireWeight.ReadOnly = true; - this.RawTireWeight.Width = 80; - // - // BaseRubTimeSpan - // - this.BaseRubTimeSpan.DataPropertyName = "BaseRubTimeSpan"; - this.BaseRubTimeSpan.HeaderText = "基部胶完成时间"; - this.BaseRubTimeSpan.Name = "BaseRubTimeSpan"; - this.BaseRubTimeSpan.ReadOnly = true; - this.BaseRubTimeSpan.Width = 140; - // - // MidRubTimeSpan - // - this.MidRubTimeSpan.DataPropertyName = "MidRubTimeSpan"; - this.MidRubTimeSpan.HeaderText = "中层胶完成时间"; - this.MidRubTimeSpan.Name = "MidRubTimeSpan"; - this.MidRubTimeSpan.ReadOnly = true; - this.MidRubTimeSpan.Width = 150; - // - // FaceRubTimeSpan - // - this.FaceRubTimeSpan.DataPropertyName = "FaceRubTimeSpan"; - this.FaceRubTimeSpan.HeaderText = "生胎完成时间"; - this.FaceRubTimeSpan.Name = "FaceRubTimeSpan"; - this.FaceRubTimeSpan.ReadOnly = true; - this.FaceRubTimeSpan.Width = 140; - // - // RepeatWeight - // - this.RepeatWeight.DataPropertyName = "RepeatWeight"; - this.RepeatWeight.HeaderText = "复重重量"; - this.RepeatWeight.Name = "RepeatWeight"; - this.RepeatWeight.ReadOnly = true; - this.RepeatWeight.Width = 80; - // // DailyReportPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs index a4a64a1..13b8703 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs @@ -143,5 +143,9 @@ namespace HighWayIot.Winform.UserControlPages } } + private void ButtonPanel_Paint(object sender, PaintEventArgs e) + { + + } } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs index 09fd1e3..85c7c06 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs @@ -63,7 +63,7 @@ namespace HighWayIot.Winform.UserControlPages.LogPages ExportTableEntity exportTableEntity = new ExportTableEntity(); ZxRecipeEntity recipeEntity = _zxRecipeEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode).FirstOrDefault(); ZxWeightEntity baseWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "基部胶").FirstOrDefault(); - ZxWeightEntity midWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "缓冲胶").FirstOrDefault(); + ZxWeightEntity midWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "中层胶").FirstOrDefault(); ZxWeightEntity faceWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "胎面胶").FirstOrDefault(); if (recipeEntity == null) { diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs index 6210ae1..4b7aa4e 100644 --- a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs @@ -76,7 +76,6 @@ namespace HighWayIot.Winform.UserControlPages this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.MonitorDataGridView = new System.Windows.Forms.DataGridView(); - this.DataRefresh = new System.Windows.Forms.Timer(this.components); this.No = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.VulcanizationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.StartTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -90,6 +89,7 @@ namespace HighWayIot.Winform.UserControlPages this.RowTireFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.IsDone = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DataRefresh = new System.Windows.Forms.Timer(this.components); this.panel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); @@ -256,11 +256,13 @@ namespace HighWayIot.Winform.UserControlPages // NowDateProductNumTextBox // this.NowDateProductNumTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.NowDateProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F); + this.NowDateProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.NowDateProductNumTextBox.Location = new System.Drawing.Point(67, 47); this.NowDateProductNumTextBox.Name = "NowDateProductNumTextBox"; + this.NowDateProductNumTextBox.ReadOnly = true; this.NowDateProductNumTextBox.Size = new System.Drawing.Size(122, 30); this.NowDateProductNumTextBox.TabIndex = 18; + this.NowDateProductNumTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // NowDateProductNumLabel // @@ -293,19 +295,23 @@ namespace HighWayIot.Winform.UserControlPages // // NightProductNumTextBox // - this.NightProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F); + this.NightProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.NightProductNumTextBox.Location = new System.Drawing.Point(319, 47); this.NightProductNumTextBox.Name = "NightProductNumTextBox"; + this.NightProductNumTextBox.ReadOnly = true; this.NightProductNumTextBox.Size = new System.Drawing.Size(122, 30); this.NightProductNumTextBox.TabIndex = 17; + this.NightProductNumTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // DayProductNumTextBox // - this.DayProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F); + this.DayProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.DayProductNumTextBox.Location = new System.Drawing.Point(74, 47); this.DayProductNumTextBox.Name = "DayProductNumTextBox"; + this.DayProductNumTextBox.ReadOnly = true; this.DayProductNumTextBox.Size = new System.Drawing.Size(122, 30); this.DayProductNumTextBox.TabIndex = 16; + this.DayProductNumTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // NightTimeLabel // @@ -490,12 +496,6 @@ namespace HighWayIot.Winform.UserControlPages this.MonitorDataGridView.Size = new System.Drawing.Size(1905, 764); this.MonitorDataGridView.TabIndex = 1; // - // DataRefresh - // - this.DataRefresh.Enabled = true; - this.DataRefresh.Interval = 1000; - this.DataRefresh.Tick += new System.EventHandler(this.DataRefresh_Tick); - // // No // this.No.DataPropertyName = "No"; @@ -623,6 +623,12 @@ namespace HighWayIot.Winform.UserControlPages this.IsDone.ReadOnly = true; this.IsDone.Width = 80; // + // DataRefresh + // + this.DataRefresh.Enabled = true; + this.DataRefresh.Interval = 1000; + this.DataRefresh.Tick += new System.EventHandler(this.DataRefresh_Tick); + // // MonitorMainPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs index 23382d0..0874709 100644 --- a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs @@ -34,10 +34,25 @@ namespace HighWayIot.Winform.UserControlPages /// datagridview 数据源 /// 必须使用BindingList, 如果使用LIST,无法实现更改,添加、删除数据源自动更新datagridview /// - private BindingList _monitorDataSources = new BindingList(); + //private BindingList _monitorDataSources = new BindingList(); + + private List _monitorDataSources = new List(); + + private DateTime DayStartTime; + + private DateTime DayEndTine; + + private DateTime NightStartTime; + + private DateTime NightEndTime; public static Action MonitorRefreshAction; + /// + /// 前端刷新锁 + /// + private static readonly object GridRefreshLocker = new object(); + public MonitorMainPage() { InitializeComponent(); @@ -46,9 +61,6 @@ namespace HighWayIot.Winform.UserControlPages DateTimeRefresh(); - MonitorDataGridView.DataSource = null; - MonitorDataGridView.DataSource = _monitorDataSources; - MonitorRefreshAction += BindData; MonitorRefreshAction.Invoke(); } @@ -60,7 +72,7 @@ namespace HighWayIot.Winform.UserControlPages /// private void DataRefresh_Tick(object sender, EventArgs e) { - if(DateTime.Now.Second == 0) + if (DateTime.Now.Second == 0) { DateTimeRefresh(); } @@ -76,12 +88,46 @@ namespace HighWayIot.Winform.UserControlPages var midShift = timeList.Where(x => x.ShiftName == "中").FirstOrDefault(); var nightShift = timeList.Where(x => x.ShiftName == "夜").FirstOrDefault(); - if(morningShift == null || midShift == null || nightShift == null) + if (morningShift == null || midShift == null || nightShift == null) { logHelper.Error("检查班次数据库是否早中夜班配置齐全!"); return; } + DateTime Today = DateTime.Now.Date; + var startArray = morningShift.ShiftStartTime.Split(':'); + var endArray = midShift.ShiftEndTime.Split(':'); + if (startArray.Length != 3 || endArray.Length != 3) + { + return; + } + TimeSpan StartTime = new TimeSpan(Convert.ToInt32(startArray[0]), Convert.ToInt32(startArray[1]), Convert.ToInt32(startArray[2])); + TimeSpan EndTime = new TimeSpan(Convert.ToInt32(endArray[0]), Convert.ToInt32(endArray[1]), Convert.ToInt32(endArray[2])); + if (DateTime.Now.TimeOfDay > StartTime && DateTime.Now.TimeOfDay < EndTime) + {//白班 + DayStartTime = DateTime.Now.Date + StartTime; + DayEndTine = DateTime.Now.Date + EndTime; + NightStartTime = DateTime.Now.Date - TimeSpan.FromDays(1) + EndTime; + NightEndTime = DateTime.Now.Date + StartTime; + } + else + {//夜班 + if (DateTime.Now.TimeOfDay < StartTime) //前半夜 + { + DayStartTime = DateTime.Now.Date + StartTime; + DayEndTine = DateTime.Now.Date + EndTime; + NightStartTime = DateTime.Now.Date + EndTime; + NightEndTime = DateTime.Now + TimeSpan.FromDays(1) + StartTime; + } + else if (DateTime.Now.TimeOfDay > EndTime) //后半夜 + { + DayStartTime = DateTime.Now.Date - TimeSpan.FromDays(1) + StartTime; + DayEndTine = DateTime.Now.Date - TimeSpan.FromDays(1) + EndTime; + NightStartTime = DateTime.Now.Date - TimeSpan.FromDays(1) + EndTime; + NightEndTime = DateTime.Now + StartTime; + } + } + string dayString = morningShift.ShiftStartTime.Substring(0, 5) + "-" + midShift.ShiftEndTime.Substring(0, 5); string nightString = nightShift.ShiftStartTime.Substring(0, 5) + "-" + nightShift.ShiftEndTime.Substring(0, 5); DayTimeLabel.Text = dayString; @@ -95,43 +141,65 @@ namespace HighWayIot.Winform.UserControlPages /// private void BindData() { - List dailyEntity = _zxDailyReportService.Get30DailyReportInfos(); - _monitorDataSources.Clear(); - for(int i = 0; i < dailyEntity.Count; i++) + lock (GridRefreshLocker) { - _monitorDataSources.Add(new MonitorDataSource() + List dailyEntity = _zxDailyReportService.GetOneDayDailyReportInfos(); + _monitorDataSources.Clear(); + if (dailyEntity == null) { - No = i + 1, - VulcanizationNo = dailyEntity[i].VulcanizationNo, - StartTime = dailyEntity[i].StartTime.ToString("MM月dd日 HH:mm:ss"), - RecipeName = dailyEntity[i].RecipeName, - RecipeCode = dailyEntity[i].RecipeCode, - SpecCode = dailyEntity[i].SpecCode, - DeviceNo = dailyEntity[i].DeviceNo.ToString(), - RawTireWeight = dailyEntity[i].RawTireWeight ?? 0, - BaseRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].BaseEndTime), - MidRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].MidEndTime), - FaceRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].FaceEndTime), - RepeatWeight = dailyEntity[i].RepeatWeight, - IsDone = dailyEntity[i].IsDone == 1 ? "已完成" : "未完成" - }); + return; + } + for (int i = 0; i < dailyEntity.Count; i++) + { + _monitorDataSources.Add(new MonitorDataSource() + { + No = i + 1, + VulcanizationNo = dailyEntity[i].VulcanizationNo, + StartTime = dailyEntity[i].StartTime.ToString("MM月dd日 HH:mm:ss"), + RecipeName = dailyEntity[i].RecipeName, + RecipeCode = dailyEntity[i].RecipeCode, + SpecCode = dailyEntity[i].SpecCode, + DeviceNo = dailyEntity[i].DeviceNo.ToString(), + RawTireWeight = dailyEntity[i].RawTireWeight ?? 0, + BaseRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].BaseEndTime), + MidRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].MidEndTime), + FaceRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].FaceEndTime), + RepeatWeight = dailyEntity[i].RepeatWeight ?? 0, + IsDone = dailyEntity[i].IsDone == 1 ? "已完成" : "未完成" + }); + } + + MonitorDataGridView.DataSource = null; + MonitorDataGridView.DataSource = _monitorDataSources; + + int daycount = dailyEntity.Count(x => x.StartTime >= DayStartTime && x.StartTime <= DayEndTine && x.IsDone == 1); + DayProductNumTextBox.Text = daycount.ToString(); + int nightcount = dailyEntity.Count(x => x.StartTime >= NightStartTime && x.StartTime <= NightEndTime && x.IsDone == 1); + NightProductNumTextBox.Text = nightcount.ToString(); + NowDateProductNumTextBox.Text = (daycount + nightcount).ToString(); + + ZxDailyReportEntity first = dailyEntity.FirstOrDefault(); + if (first == null) + { + return; + } + RecipeCodeLabel.Text = first.RecipeCode; + SpecCodeLabel.Text = first.SpecCode; + RecipeNameLabel.Text = first.RecipeName; + ZxRecipeEntity recipeEntity = ZxRecipeService.Instance.GetRecipeInfosByRecipeCode(first.RecipeCode).FirstOrDefault(); + if (recipeEntity != null) + { + SpecNameLabel.Text = recipeEntity.RecipeName; + ZxRecipeParaEntity paraEntity = ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeEntity.RecipeCode).FirstOrDefault(); + if (paraEntity != null) + { + RawTireWeightLabel.Text = paraEntity.TireWeight.ToString(); + } + } + RgvNoLabel.Text = first.DeviceNo.ToString(); + } - ZxDailyReportEntity first = dailyEntity.FirstOrDefault(); - RecipeCodeLabel.Text = first.RecipeCode; - SpecCodeLabel.Text = first.SpecCode; - RecipeNameLabel.Text = first.RecipeName; - ZxRecipeEntity recipeEntity = ZxRecipeService.Instance.GetRecipeInfosByRecipeCode(first.RecipeCode).FirstOrDefault(); - if (recipeEntity != null) - { - SpecNameLabel.Text = recipeEntity.RecipeName; - ZxRecipeParaEntity paraEntity = ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeEntity.RecipeCode).FirstOrDefault(); - if (paraEntity != null) - { - RawTireWeightLabel.Text = paraEntity.TireWeight.ToString(); - } - } - RgvNoLabel.Text = first.DeviceNo.ToString(); } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs index 05ae10a..d857c24 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs @@ -42,7 +42,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages bindingSource.DataSource = zxSchedulingEntity; SchedulingDataGridView.DataSource = null; SchedulingDataGridView.DataSource = bindingSource; - ComboBoxBind(); + //ComboBoxBind(); } /// @@ -59,7 +59,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages /// /// 绑定下拉框数据源 /// - private void ComboBoxBind() + public void ComboBoxBind() { zxRecipeEntities = zxRecipeService.GetRecipeInfos(); RecipeName1.DataSource = null; @@ -67,11 +67,11 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages List r1 = zxRecipeEntities.Select(x => x.RecipeName).ToList(); r1.Sort(); - r1.Insert(0, ""); + r1.Insert(0, " "); RecipeName1.DataSource = r1; List r2 = zxRecipeEntities.Select(x => x.RecipeName).ToList(); r2.Sort(); - r2.Insert(0, ""); + r2.Insert(0, " "); RecipeName2.DataSource = r2; } diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs index fb63e9a..9fcde56 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs @@ -84,7 +84,7 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages { "", "基部胶", - "缓冲胶", + "中层胶", "胎面胶" }; diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs index 2a5cf4c..f978697 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs @@ -31,8 +31,8 @@ namespace HighWayIot.Winform.UserControlPages /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.WeightDataGridView = new System.Windows.Forms.DataGridView(); this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -49,7 +49,6 @@ namespace HighWayIot.Winform.UserControlPages this.SetError = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.AddRecipeButton = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); - this.SyncDataButton = new System.Windows.Forms.Button(); this.label26 = new System.Windows.Forms.Label(); this.RefreshRecipeButton = new System.Windows.Forms.Button(); this.UpdateRecipeButton = new System.Windows.Forms.Button(); @@ -57,6 +56,14 @@ namespace HighWayIot.Winform.UserControlPages this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.RecipeDataGridView = new System.Windows.Forms.DataGridView(); + this.RId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeSpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeSpecName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SizeKind = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FixedWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.WeightError = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); @@ -161,14 +168,6 @@ namespace HighWayIot.Winform.UserControlPages this.UpdateWeightButton = new System.Windows.Forms.Button(); this.AddWeightButton = new System.Windows.Forms.Button(); this.DeleteWeightButton = new System.Windows.Forms.Button(); - this.RId = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeSpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeSpecName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SizeKind = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.FixedWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.WeightError = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.WeightDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -191,13 +190,13 @@ namespace HighWayIot.Winform.UserControlPages this.WeightDataGridView.AllowUserToDeleteRows = false; this.WeightDataGridView.AllowUserToResizeColumns = false; this.WeightDataGridView.AllowUserToResizeRows = false; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - this.WeightDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + this.WeightDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; this.WeightDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.WeightDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Id, @@ -343,7 +342,6 @@ namespace HighWayIot.Winform.UserControlPages // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonPanel.Controls.Add(this.SyncDataButton); this.ButtonPanel.Controls.Add(this.label26); this.ButtonPanel.Controls.Add(this.RefreshRecipeButton); this.ButtonPanel.Controls.Add(this.UpdateRecipeButton); @@ -355,18 +353,6 @@ namespace HighWayIot.Winform.UserControlPages this.ButtonPanel.Size = new System.Drawing.Size(952, 63); this.ButtonPanel.TabIndex = 4; // - // SyncDataButton - // - this.SyncDataButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.SyncDataButton.Location = new System.Drawing.Point(728, 12); - this.SyncDataButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.SyncDataButton.Name = "SyncDataButton"; - this.SyncDataButton.Size = new System.Drawing.Size(103, 39); - this.SyncDataButton.TabIndex = 8; - this.SyncDataButton.Text = "同步数据"; - this.SyncDataButton.UseVisualStyleBackColor = true; - this.SyncDataButton.Click += new System.EventHandler(this.SyncDataButton_Click); - // // label26 // this.label26.AutoSize = true; @@ -439,14 +425,14 @@ namespace HighWayIot.Winform.UserControlPages this.RecipeDataGridView.AllowUserToAddRows = false; this.RecipeDataGridView.AllowUserToDeleteRows = false; this.RecipeDataGridView.AllowUserToResizeRows = false; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.RecipeDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.RecipeDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.RecipeDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.RecipeDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.RId, @@ -466,9 +452,80 @@ namespace HighWayIot.Winform.UserControlPages this.RecipeDataGridView.Size = new System.Drawing.Size(946, 722); this.RecipeDataGridView.TabIndex = 0; this.RecipeDataGridView.Tag = ""; - this.RecipeDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.RecipeDataGridView_CellContentClick); this.RecipeDataGridView.SelectionChanged += new System.EventHandler(this.RecipeDataGridView_SelectionChanged); // + // RId + // + this.RId.DataPropertyName = "Id"; + this.RId.HeaderText = "ID"; + this.RId.Name = "RId"; + this.RId.ReadOnly = true; + this.RId.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.RId.Width = 40; + // + // RecipeCode + // + this.RecipeCode.DataPropertyName = "RecipeCode"; + this.RecipeCode.FillWeight = 52.74404F; + this.RecipeCode.HeaderText = "成品代号"; + this.RecipeCode.Name = "RecipeCode"; + this.RecipeCode.ReadOnly = true; + this.RecipeCode.Resizable = System.Windows.Forms.DataGridViewTriState.False; + // + // RecipeName + // + this.RecipeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RecipeName.DataPropertyName = "RecipeName"; + this.RecipeName.FillWeight = 52.74404F; + this.RecipeName.HeaderText = "标称尺度"; + this.RecipeName.Name = "RecipeName"; + this.RecipeName.ReadOnly = true; + this.RecipeName.Resizable = System.Windows.Forms.DataGridViewTriState.False; + // + // RecipeSpecCode + // + this.RecipeSpecCode.DataPropertyName = "RecipeSpecCode"; + this.RecipeSpecCode.FillWeight = 52.74404F; + this.RecipeSpecCode.HeaderText = "SPEC编号"; + this.RecipeSpecCode.Name = "RecipeSpecCode"; + this.RecipeSpecCode.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.RecipeSpecCode.Width = 90; + // + // RecipeSpecName + // + this.RecipeSpecName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RecipeSpecName.DataPropertyName = "RecipeSpecName"; + this.RecipeSpecName.FillWeight = 52.74404F; + this.RecipeSpecName.HeaderText = "SPEC名称"; + this.RecipeSpecName.Name = "RecipeSpecName"; + this.RecipeSpecName.Resizable = System.Windows.Forms.DataGridViewTriState.False; + // + // SizeKind + // + this.SizeKind.DataPropertyName = "SizeKind"; + this.SizeKind.FillWeight = 52.74404F; + this.SizeKind.HeaderText = "寸别"; + this.SizeKind.Name = "SizeKind"; + this.SizeKind.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SizeKind.Width = 40; + // + // FixedWidth + // + this.FixedWidth.DataPropertyName = "FixedWidth"; + this.FixedWidth.FillWeight = 137.1345F; + this.FixedWidth.HeaderText = "固定胶宽度"; + this.FixedWidth.Name = "FixedWidth"; + this.FixedWidth.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.FixedWidth.Width = 71; + // + // WeightError + // + this.WeightError.DataPropertyName = "WeightError"; + this.WeightError.HeaderText = "重量公差"; + this.WeightError.Name = "WeightError"; + this.WeightError.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.WeightError.Width = 59; + // // tableLayoutPanel1 // this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -1535,7 +1592,7 @@ namespace HighWayIot.Winform.UserControlPages this.PositionSelectRefreshButton.Name = "PositionSelectRefreshButton"; this.PositionSelectRefreshButton.Size = new System.Drawing.Size(103, 39); this.PositionSelectRefreshButton.TabIndex = 9; - this.PositionSelectRefreshButton.Text = "工位参数更新"; + this.PositionSelectRefreshButton.Text = "成型信息一键导入工位参数"; this.PositionSelectRefreshButton.UseVisualStyleBackColor = true; this.PositionSelectRefreshButton.Click += new System.EventHandler(this.PositionSelectRefreshButton_Click); // @@ -1593,78 +1650,6 @@ namespace HighWayIot.Winform.UserControlPages this.DeleteWeightButton.UseVisualStyleBackColor = true; this.DeleteWeightButton.Click += new System.EventHandler(this.DeleteWeightButton_Click); // - // RId - // - this.RId.DataPropertyName = "Id"; - this.RId.HeaderText = "ID"; - this.RId.Name = "RId"; - this.RId.ReadOnly = true; - this.RId.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.RId.Width = 40; - // - // RecipeCode - // - this.RecipeCode.DataPropertyName = "RecipeCode"; - this.RecipeCode.FillWeight = 52.74404F; - this.RecipeCode.HeaderText = "成品代号"; - this.RecipeCode.Name = "RecipeCode"; - this.RecipeCode.ReadOnly = true; - this.RecipeCode.Resizable = System.Windows.Forms.DataGridViewTriState.False; - // - // RecipeName - // - this.RecipeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RecipeName.DataPropertyName = "RecipeName"; - this.RecipeName.FillWeight = 52.74404F; - this.RecipeName.HeaderText = "标称尺度"; - this.RecipeName.Name = "RecipeName"; - this.RecipeName.ReadOnly = true; - this.RecipeName.Resizable = System.Windows.Forms.DataGridViewTriState.False; - // - // RecipeSpecCode - // - this.RecipeSpecCode.DataPropertyName = "RecipeSpecCode"; - this.RecipeSpecCode.FillWeight = 52.74404F; - this.RecipeSpecCode.HeaderText = "SPEC编号"; - this.RecipeSpecCode.Name = "RecipeSpecCode"; - this.RecipeSpecCode.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.RecipeSpecCode.Width = 90; - // - // RecipeSpecName - // - this.RecipeSpecName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RecipeSpecName.DataPropertyName = "RecipeSpecName"; - this.RecipeSpecName.FillWeight = 52.74404F; - this.RecipeSpecName.HeaderText = "SPEC名称"; - this.RecipeSpecName.Name = "RecipeSpecName"; - this.RecipeSpecName.Resizable = System.Windows.Forms.DataGridViewTriState.False; - // - // SizeKind - // - this.SizeKind.DataPropertyName = "SizeKind"; - this.SizeKind.FillWeight = 52.74404F; - this.SizeKind.HeaderText = "寸别"; - this.SizeKind.Name = "SizeKind"; - this.SizeKind.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SizeKind.Width = 40; - // - // FixedWidth - // - this.FixedWidth.DataPropertyName = "FixedWidth"; - this.FixedWidth.FillWeight = 137.1345F; - this.FixedWidth.HeaderText = "固定胶宽度"; - this.FixedWidth.Name = "FixedWidth"; - this.FixedWidth.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.FixedWidth.Width = 71; - // - // WeightError - // - this.WeightError.DataPropertyName = "WeightError"; - this.WeightError.HeaderText = "重量公差"; - this.WeightError.Name = "WeightError"; - this.WeightError.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.WeightError.Width = 59; - // // RecipeConfigPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -1796,7 +1781,6 @@ namespace HighWayIot.Winform.UserControlPages private Label label32; private Label label16; private CheckBox S2Check; - private Button SyncDataButton; private Label label26; private Label label27; private Label Station5MaterialName; diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs index a8ae06b..d1af758 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs @@ -472,11 +472,11 @@ namespace HighWayIot.Winform.UserControlPages E1 = 15, E2 = 52, E5 = form.OutValue.SetLayer * 10, - E9 = (int)form.OutValue.SetWidth, + E9 = form.OutValue.SetWidth, E6 = form.OutValue.SetLayer2 * 10, - E7 = (int)form.OutValue.SetWidth2, + E7 = form.OutValue.SetWidth2, E3 = form.OutValue.SetLayer3 * 10, - E4 = (int)form.OutValue.SetWidth3, + E4 = form.OutValue.SetWidth3, E10 = 800, E8 = 300 }; @@ -1461,456 +1461,5 @@ namespace HighWayIot.Winform.UserControlPages #endregion - #region 配方数据同步 - - /// - /// 同步数据按钮 - /// - /// - /// - private void SyncDataButton_Click(object sender, EventArgs e) - { - // RecipeDataSync(zxMesPlanTransferService.GetRecipeInfos(x => x.Uuid != "syncsignal")); - zxMesPlanTransferService.SetFlagTrue(); - //if (zxMesPlanTransferService.GetFlagState()) - //{ - // MessageBox.Show("正在同步数据,请稍后"); - // return; - //} - //if (zxMesPlanTransferService.SetFlagTrue()) - //{ - // Task.Run(() => - // { - // while (true) - // { - // if (!zxMesPlanTransferService.GetFlagState()) - // { - // RecipeDataSync(zxMesPlanTransferService.GetRecipeInfos(x => x.Uuid != "syncsignal")); - // MessageBox.Show("同步完成"); - // return; - // } - // Task.Delay(1000); - // } - // }); - //} - } - - ///// - ///// 配方数据同步方法 - ///// - //private void RecipeDataSync(List sourceEntity) - //{ - // foreach (var newRecipes in sourceEntity) - // { - // //////////////////////////////更新配方表///////////////////////////////// - // var newEneitys = RecipeLists.Where(x => x.RecipeCode == newRecipes.RecipeCode).ToList(); - // if (newEneitys.Count > 0) //有就更新 - // { - // //配方 - // newEneitys[0].RecipeSpecCode = newRecipes.SpecCode; - // newEneitys[0].RecipeSpecName = newRecipes.SpecName; - // newEneitys[0].SizeKind = newRecipes.RimInch; - // newEneitys[0].FixedWidth = newRecipes.FixRubWidth; - // if (!zxRecipeService.UpdateRecipeInfo(newEneitys[0])) - // { - // return; - // } - // } - // else //没有就插入 - // { - // ZxRecipeEntity entity = new ZxRecipeEntity() - // { - // RecipeName = newRecipes.RecipeName, - // RecipeCode = newRecipes.RecipeCode, - // RecipeSpecCode = newRecipes.SpecCode, - // RecipeSpecName = newRecipes.SpecName, - // SizeKind = newRecipes.RimInch, - // FixedWidth = newRecipes.FixRubWidth, - // IsUse = true, - // IsDeleted = false, - // }; - // zxRecipeService.InsertRecipeInfo(entity); - // } - - // /////////////////////////////更新称量信息表//////////////////////////////// - // string recipeCode = newRecipes.RecipeCode; - // var material1 = zxMaterialService.GetMaterialInfoByMaterialName(newRecipes.MaterialName1); - // var material2 = zxMaterialService.GetMaterialInfoByMaterialName(newRecipes.MaterialName2); - // var material3 = zxMaterialService.GetMaterialInfoByMaterialName(newRecipes.MaterialName3); - // //物料1 - // if (!string.IsNullOrEmpty(newRecipes.MaterialName1)) - // { - // if (material1 != null) //有这个物料 - // { - // //查询是否有这个配方这个物料的称量 有更改 没有添加 - // var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material1.MaterialCode, "基部胶"); - // if (weightInfo == null) - // { - // bool a = zxWeightService.InsertWeightInfo(new ZxWeightEntity() - // { - // RecipeCode = recipeCode, - // MaterialCode = material1.MaterialCode, - // MaterialName = material1.MaterialName, - // MaterialType = "基部胶", - // SetWidth = (int?)newRecipes.MaterialWidth1, - // SetWeight = (int?)newRecipes.MaterialWeight1, - // SetLayer = newRecipes.MaterialLayers1, - // IsDeleted = false, - // IsUse = true - // }); - // } - // else - // { - // weightInfo.SetWidth = (int?)newRecipes.MaterialWidth1; - // weightInfo.SetWeight = (int?)newRecipes.MaterialWeight1; - // weightInfo.SetLayer = newRecipes.MaterialLayers1; - // zxWeightService.UpdateWeightInfo(weightInfo); - // } - // } - // else //没这个物料 - // { - // //先添加物料 - // material1 = new ZxMaterialEntity() - // { - // MaterialCode = DateTime.Now.ToString("yyyyMMddHHmmssffff"), - // MaterialName = newRecipes.MaterialName1, - // MaterialType = "胶料", - // IsDeleted = false, - // IsUse = true - // }; - // zxMaterialService.InsertMaterialInfo(material1); - // //查询是否有这个配方这个物料的称量 有更改 没有添加 - // var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material1.MaterialCode, "基部胶"); - // if (weightInfo == null) //没有配方数据 - // { - // zxWeightService.InsertWeightInfo(new ZxWeightEntity() - // { - // RecipeCode = recipeCode, - // MaterialCode = material1.MaterialCode, - // MaterialName = material1.MaterialName, - // MaterialType = "基部胶", - // SetWidth = (int?)newRecipes.MaterialWidth1, - // SetWeight = (int?)newRecipes.MaterialWeight1, - // SetLayer = newRecipes.MaterialLayers1, - // IsDeleted = false, - // IsUse = true - // }); - // } - // else //有配方数据 - // { - // weightInfo.SetWidth = (int?)newRecipes.MaterialWidth1; - // weightInfo.SetWeight = (int?)newRecipes.MaterialWeight1; - // weightInfo.SetLayer = newRecipes.MaterialLayers1; - // zxWeightService.UpdateWeightInfo(weightInfo); - // } - // } - // } - // //物料2 - // if (!string.IsNullOrEmpty(newRecipes.MaterialName2)) - // { - // if (material2 != null) //有这个物料 - // { - // //查询是否有这个配方这个物料的称量 有更改 没有添加 - // var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material2.MaterialCode, "缓冲胶"); - // if (weightInfo == null) - // { - // bool a = zxWeightService.InsertWeightInfo(new ZxWeightEntity() - // { - // RecipeCode = recipeCode, - // MaterialCode = material1.MaterialCode, - // MaterialName = material1.MaterialName, - // MaterialType = "缓冲胶", - // SetWidth = (int?)newRecipes.MaterialWidth2, - // SetWeight = (int?)newRecipes.MaterialWeight2, - // SetLayer = newRecipes.MaterialLayers2, - // IsDeleted = false, - // IsUse = true - // }); - // } - // else - // { - // weightInfo.SetWidth = (int?)newRecipes.MaterialWidth2; - // weightInfo.SetWeight = (int?)newRecipes.MaterialWeight2; - // weightInfo.SetLayer = newRecipes.MaterialLayers2; - // zxWeightService.UpdateWeightInfo(weightInfo); - // } - // } - // else //没这个物料 - // { - // //先添加物料 - // material2 = new ZxMaterialEntity() - // { - // MaterialCode = DateTime.Now.ToString("yyyyMMddHHmmssffff"), - // MaterialName = newRecipes.MaterialName2, - // MaterialType = "胶料", - // IsDeleted = false, - // IsUse = true - // }; - // zxMaterialService.InsertMaterialInfo(material2); - // //查询是否有这个配方这个物料的称量 有更改 没有添加 - // var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material2.MaterialCode, "缓冲胶"); - // if (weightInfo == null) //没有配方数据 - // { - // zxWeightService.InsertWeightInfo(new ZxWeightEntity() - // { - // RecipeCode = recipeCode, - // MaterialCode = material2.MaterialCode, - // MaterialName = material2.MaterialName, - // MaterialType = "缓冲胶", - // SetWidth = (int?)newRecipes.MaterialWidth2, - // SetWeight = (int?)newRecipes.MaterialWeight2, - // SetLayer = newRecipes.MaterialLayers2, - // IsDeleted = false, - // IsUse = true - // }); - // } - // else //有配方数据 - // { - // weightInfo.SetWidth = (int?)newRecipes.MaterialWidth2; - // weightInfo.SetWeight = (int?)newRecipes.MaterialWeight2; - // weightInfo.SetLayer = newRecipes.MaterialLayers2; - // zxWeightService.UpdateWeightInfo(weightInfo); - // } - // } - // } - - // //物料3 - // if (!string.IsNullOrEmpty(newRecipes.MaterialName3)) - // { - // if (material3 != null) //有这个物料 - // { - // //查询是否有这个配方这个物料的称量 有更改 没有添加 - // var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material3.MaterialCode, "胎面胶"); - // if (weightInfo == null) - // { - // bool a = zxWeightService.InsertWeightInfo(new ZxWeightEntity() - // { - // RecipeCode = recipeCode, - // MaterialCode = material3.MaterialCode, - // MaterialName = material3.MaterialName, - // MaterialType = "胎面胶", - // SetWidth = (int?)newRecipes.MaterialWidth3, - // SetWeight = (int?)newRecipes.MaterialWeight3, - // SetLayer = newRecipes.MaterialLayers3, - // IsDeleted = false, - // IsUse = true - // }); - // } - // else - // { - // weightInfo.SetWidth = (int?)newRecipes.MaterialWidth3; - // weightInfo.SetWeight = (int?)newRecipes.MaterialWeight3; - // weightInfo.SetLayer = newRecipes.MaterialLayers3; - // zxWeightService.UpdateWeightInfo(weightInfo); - // } - // } - // else //没这个物料 - // { - // //先添加物料 - // material3 = new ZxMaterialEntity() - // { - // MaterialCode = DateTime.Now.ToString("yyyyMMddHHmmssffff"), - // MaterialName = newRecipes.MaterialName3, - // MaterialType = "胶料", - // IsDeleted = false, - // IsUse = true - // }; - // zxMaterialService.InsertMaterialInfo(material3); - // //查询是否有这个配方这个物料的称量 有更改 没有添加 - // var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material3.MaterialCode, "胎面胶"); - // if (weightInfo == null) //没有配方数据 - // { - // zxWeightService.InsertWeightInfo(new ZxWeightEntity() - // { - // RecipeCode = recipeCode, - // MaterialCode = material3.MaterialCode, - // MaterialName = material3.MaterialName, - // MaterialType = "胎面胶", - // SetWidth = (int?)newRecipes.MaterialWidth3, - // SetWeight = (int?)newRecipes.MaterialWeight3, - // SetLayer = newRecipes.MaterialLayers3, - // IsDeleted = false, - // IsUse = true - // }); - // } - // else //有配方数据 - // { - // weightInfo.SetWidth = (int?)newRecipes.MaterialWidth3; - // weightInfo.SetWeight = (int?)newRecipes.MaterialWeight3; - // weightInfo.SetLayer = newRecipes.MaterialLayers3; - // zxWeightService.UpdateWeightInfo(weightInfo); - // } - // } - // } - - // /////////////////////////////////////更新配方参数////////////////////////////////////// - // ZxRecipeParaEntity recipePara = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault(); - // if (recipePara == null) //不存早 - // { - // recipePara = new ZxRecipeParaEntity() - // { - // SpecName = newRecipes.SpecName, - // SpecCode = newRecipes.SpecCode, - // RimInch = newRecipes.RimInch, - // LightWidth = newRecipes.FixRubWidth, - // TireWeight = newRecipes.TireWeight, - // RecipeCode = recipeCode - // }; - - // foreach (var config in openMixConfig) //工位选择设置 - // { - // if (config.MaterialName == material1.MaterialName - // || config.MaterialName == material2.MaterialName - // || config.MaterialName == material3.MaterialName) - // { - // try - // { - // var prop = recipePara.GetType().GetProperty($"S{config.StationNo + 1}"); - // prop.SetValue(recipePara, true); - // } - // catch - // { - // return; - // } - // } - // } - - // zxRecipeParaService.InsertRecipeParaInfo(recipePara); - // } - // else //存在 - // { - // recipePara.SpecName = newRecipes.SpecName; - // recipePara.SpecCode = newRecipes.SpecCode; - // recipePara.RimInch = newRecipes.RimInch; - // recipePara.LightWidth = newRecipes.FixRubWidth; - // recipePara.TireWeight = newRecipes.TireWeight; - - // foreach (var config in openMixConfig) //工位选择设置 - // { - // if (config.MaterialName == material1.MaterialName - // || config.MaterialName == material2.MaterialName - // || config.MaterialName == material3.MaterialName) - // { - // try - // { - // var prop = recipePara.GetType().GetProperty($"S{config.StationNo + 1}"); - // prop.SetValue(recipePara, true); - // } - // catch - // { - // return; - // } - // } - // } - - // zxRecipeParaService.UpdateRecipeParaInfo(recipePara); - // } - - // /////////////////////////////////////更新配方工位参数////////////////////////////////////// - // List positionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfoByRecipeCode(recipeCode); - - // int position = 1; - // for (int i = 0; i < 5; i++) - // { - // try - // { - // var prop = recipePara.GetType().GetProperty($"S{i + 2}"); - // object value = prop.GetValue(recipePara); - // // 处理可空类型的null值情况 - // if (value == null) - // { - // continue; - // } - // bool positionValue; - // positionValue = Convert.ToBoolean(value); - // if (positionValue == true) - // { - // ZxRecipePositionParaEntity positionPara = positionParaEntities.Where(x => x.Position == (i + 1)).FirstOrDefault(); - // if (position == 1) - // { - // if (positionPara == null)//没工位参数 - // { - // positionPara = new ZxRecipePositionParaEntity() - // { - // RecipeCode = recipeCode, - // Position = i + 1, - // E5 = newRecipes.MaterialLayers1, - // E9 = (int)newRecipes.MaterialWidth1, - // E6 = newRecipes.MaterialLayers12, - // E7 = (int)newRecipes.MaterialWidth12, - // }; - // zxRecipePositionParaService.InsertRecipePositionParaInfo(positionPara); - // } - // else//有工位参数 - // { - // positionPara.E5 = newRecipes.MaterialLayers1; - // positionPara.E9 = (int)newRecipes.MaterialWidth1; - // positionPara.E6 = newRecipes.MaterialLayers12; - // positionPara.E7 = (int)newRecipes.MaterialWidth12; - // zxRecipePositionParaService.UpdateRecipePositionParaInfo(positionPara); - // } - // } - // else if (position == 2) - // { - // if (positionPara == null)//没工位参数 - // { - // positionPara = new ZxRecipePositionParaEntity() - // { - // RecipeCode = recipeCode, - // Position = i + 1, - // E5 = newRecipes.MaterialLayers2, - // E9 = (int)newRecipes.MaterialWidth2, - // }; - // zxRecipePositionParaService.InsertRecipePositionParaInfo(positionPara); - // } - // else//有工位参数 - // { - // positionPara.E5 = newRecipes.MaterialLayers2; - // positionPara.E9 = (int)newRecipes.MaterialWidth2; - // zxRecipePositionParaService.UpdateRecipePositionParaInfo(positionPara); - // } - // } - // else - // { - // if (positionPara == null)//没工位参数 - // { - // positionPara = new ZxRecipePositionParaEntity() - // { - // RecipeCode = recipeCode, - // Position = i + 1, - // E5 = newRecipes.MaterialLayers3, - // E9 = (int)newRecipes.MaterialWidth3, - // E6 = newRecipes.MaterialLayers32, - // E7 = (int)newRecipes.MaterialWidth32, - // }; - // zxRecipePositionParaService.InsertRecipePositionParaInfo(positionPara); - // } - // else//有工位参数 - // { - // positionPara.E5 = newRecipes.MaterialLayers3; - // positionPara.E9 = (int)newRecipes.MaterialWidth3; - // positionPara.E6 = newRecipes.MaterialLayers32; - // positionPara.E7 = (int)newRecipes.MaterialWidth32; - // zxRecipePositionParaService.UpdateRecipePositionParaInfo(positionPara); - // } - // } - // position++; - // } - - // } - // catch - // { - // continue; - // } - // } - // } - //} - - #endregion - - private void RecipeDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) - { - - } } } diff --git a/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs b/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs index 51b20bd..797cff2 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs @@ -30,24 +30,15 @@ { this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); - this.ReadButton = new System.Windows.Forms.Button(); - this.WriteButton = new System.Windows.Forms.Button(); - this.PlcAddress = new System.Windows.Forms.TextBox(); - this.PlcValue = new System.Windows.Forms.TextBox(); - this.PlcType = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.PlcShowValue = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.LengthTextBox = new System.Windows.Forms.TextBox(); + this.TestButton2 = new System.Windows.Forms.Button(); + this.TestButton1 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.RFIDtext = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // button1 // - this.button1.Location = new System.Drawing.Point(382, 28); + this.button1.Location = new System.Drawing.Point(263, 32); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(93, 51); this.button1.TabIndex = 0; @@ -57,7 +48,7 @@ // // button2 // - this.button2.Location = new System.Drawing.Point(148, 28); + this.button2.Location = new System.Drawing.Point(29, 32); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(93, 51); this.button2.TabIndex = 1; @@ -65,103 +56,28 @@ this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // - // ReadButton + // TestButton2 // - this.ReadButton.Location = new System.Drawing.Point(134, 141); - this.ReadButton.Name = "ReadButton"; - this.ReadButton.Size = new System.Drawing.Size(99, 50); - this.ReadButton.TabIndex = 2; - this.ReadButton.Text = "读"; - this.ReadButton.UseVisualStyleBackColor = true; - this.ReadButton.Click += new System.EventHandler(this.ReadButton_Click); + this.TestButton2.Location = new System.Drawing.Point(134, 141); + this.TestButton2.Name = "TestButton2"; + this.TestButton2.Size = new System.Drawing.Size(99, 50); + this.TestButton2.TabIndex = 2; + this.TestButton2.Text = "读"; + this.TestButton2.UseVisualStyleBackColor = true; // - // WriteButton + // TestButton1 // - this.WriteButton.Location = new System.Drawing.Point(29, 141); - this.WriteButton.Name = "WriteButton"; - this.WriteButton.Size = new System.Drawing.Size(99, 50); - this.WriteButton.TabIndex = 3; - this.WriteButton.Text = "写"; - this.WriteButton.UseVisualStyleBackColor = true; - // - // PlcAddress - // - this.PlcAddress.Location = new System.Drawing.Point(292, 118); - this.PlcAddress.Name = "PlcAddress"; - this.PlcAddress.Size = new System.Drawing.Size(100, 21); - this.PlcAddress.TabIndex = 4; - // - // PlcValue - // - this.PlcValue.Location = new System.Drawing.Point(292, 145); - this.PlcValue.Name = "PlcValue"; - this.PlcValue.Size = new System.Drawing.Size(100, 21); - this.PlcValue.TabIndex = 5; - // - // PlcType - // - this.PlcType.FormattingEnabled = true; - this.PlcType.Location = new System.Drawing.Point(292, 172); - this.PlcType.Name = "PlcType"; - this.PlcType.Size = new System.Drawing.Size(121, 20); - this.PlcType.TabIndex = 6; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(245, 121); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(29, 12); - this.label1.TabIndex = 7; - this.label1.Text = "地址"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(245, 148); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(17, 12); - this.label2.TabIndex = 9; - this.label2.Text = "值"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(245, 175); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(29, 12); - this.label3.TabIndex = 10; - this.label3.Text = "类型"; - // - // PlcShowValue - // - this.PlcShowValue.AutoSize = true; - this.PlcShowValue.Font = new System.Drawing.Font("宋体", 18F); - this.PlcShowValue.Location = new System.Drawing.Point(33, 216); - this.PlcShowValue.Name = "PlcShowValue"; - this.PlcShowValue.Size = new System.Drawing.Size(46, 24); - this.PlcShowValue.TabIndex = 11; - this.PlcShowValue.Text = "N/A"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(245, 201); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(29, 12); - this.label4.TabIndex = 13; - this.label4.Text = "长度"; - // - // LengthTextBox - // - this.LengthTextBox.Location = new System.Drawing.Point(292, 198); - this.LengthTextBox.Name = "LengthTextBox"; - this.LengthTextBox.Size = new System.Drawing.Size(100, 21); - this.LengthTextBox.TabIndex = 12; + this.TestButton1.Location = new System.Drawing.Point(29, 141); + this.TestButton1.Name = "TestButton1"; + this.TestButton1.Size = new System.Drawing.Size(99, 50); + this.TestButton1.TabIndex = 3; + this.TestButton1.Text = "写"; + this.TestButton1.UseVisualStyleBackColor = true; + this.TestButton1.Click += new System.EventHandler(this.TestButton1_Click); // // button3 // - this.button3.Location = new System.Drawing.Point(269, 28); + this.button3.Location = new System.Drawing.Point(150, 32); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(93, 51); this.button3.TabIndex = 14; @@ -171,7 +87,7 @@ // // RFIDtext // - this.RFIDtext.Location = new System.Drawing.Point(148, 85); + this.RFIDtext.Location = new System.Drawing.Point(29, 89); this.RFIDtext.Name = "RFIDtext"; this.RFIDtext.Size = new System.Drawing.Size(93, 21); this.RFIDtext.TabIndex = 15; @@ -183,17 +99,8 @@ this.BackColor = System.Drawing.SystemColors.ControlLight; this.Controls.Add(this.RFIDtext); this.Controls.Add(this.button3); - this.Controls.Add(this.label4); - this.Controls.Add(this.LengthTextBox); - this.Controls.Add(this.PlcShowValue); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.PlcType); - this.Controls.Add(this.PlcValue); - this.Controls.Add(this.PlcAddress); - this.Controls.Add(this.WriteButton); - this.Controls.Add(this.ReadButton); + this.Controls.Add(this.TestButton1); + this.Controls.Add(this.TestButton2); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "TestPage"; @@ -207,17 +114,8 @@ private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; - private System.Windows.Forms.Button ReadButton; - private System.Windows.Forms.Button WriteButton; - private System.Windows.Forms.TextBox PlcAddress; - private System.Windows.Forms.TextBox PlcValue; - private System.Windows.Forms.ComboBox PlcType; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label PlcShowValue; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox LengthTextBox; + private System.Windows.Forms.Button TestButton2; + private System.Windows.Forms.Button TestButton1; private System.Windows.Forms.Button button3; private System.Windows.Forms.TextBox RFIDtext; } diff --git a/HighWayIot.Winform/UserControlPages/TestPage.cs b/HighWayIot.Winform/UserControlPages/TestPage.cs index 82e13df..767e709 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.cs @@ -52,9 +52,6 @@ namespace HighWayIot.Winform.UserControlPages { list.Add(kv); } - PlcType.DataSource = list; - PlcType.DisplayMember = "Key"; - PlcType.ValueMember = "Value"; //PlcType.DataSource = //PlcType.DataSource = ; } @@ -123,64 +120,283 @@ namespace HighWayIot.Winform.UserControlPages } /// - /// PLC读取按钮 + /// 配方同步方法 /// - /// - /// - private void ReadButton_Click(object sender, EventArgs e) + public void SyncRecipe(ZxMesPlanTransferEntity newRecipe) { - //DataTypeEnum en = (DataTypeEnum)Convert.ToInt32(PlcType.SelectedValue); + if(newRecipe == null) + { + return; + } + //同步到配方(配方和称量,如果是新的加字段) + List RecipeLists = ZxRecipeService.Instance.GetRecipeInfos(); + var nowEneity = RecipeLists.Where(x => x.RecipeCode == newRecipe.RecipeCode && x.IsDeleted == false).FirstOrDefault(); + if (nowEneity != null) //有就更新 只更新配方和称量信息 + { + //同步配方 + nowEneity.RecipeSpecCode = newRecipe.SpecCode; + nowEneity.RecipeSpecName = newRecipe.SpecName; + nowEneity.SizeKind = newRecipe.RimInch; + nowEneity.FixedWidth = newRecipe.FixRubWidth; + if (!ZxRecipeService.Instance.UpdateRecipeInfo(nowEneity)) + { + return; + } - //string res = string.Empty; + //同步称量信息 + List zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); + for (int i = 1; i <= 3; i++) + { + string typeName = string.Empty; + switch (i) + { + case 1: + typeName = "基部胶"; + break; + case 2: + typeName = "中层胶"; + break; + case 3: + typeName = "胎面胶"; + break; + default: + break; + } + string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); + if (!string.IsNullOrEmpty(MaterialName)) + { + ZxWeightEntity weight = zxWeightEntities.FirstOrDefault(x => x.MaterialCode == MaterialName); + if (weight != null) //原来就有 + { + weight.SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)); //(decimal)newRecipe.MaterialThickness1; + weight.SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)); //newRecipe.MaterialWidth1; + weight.SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)); //newRecipe.MaterialWidth12; + weight.SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)); //newRecipe.MaterialWidth13; + weight.SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)); //newRecipe.MaterialLayers1; + weight.SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)); //newRecipe.MaterialLayers12; + weight.SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)); //newRecipe.MaterialLayers13; + ZxWeightService.Instance.UpdateWeightInfo(weight); + } + else //原来没有就添加 + { + ZxWeightService.Instance.InsertWeightInfo(new ZxWeightEntity() + { + RecipeCode = newRecipe.RecipeCode, + MaterialCode = MaterialName, + MaterialName = MaterialName + typeName, + MaterialType = typeName, + SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)), + SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), + SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), + SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), + SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)), + SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)), + SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)), + SetError = 1, + IsUse = true, + IsDeleted = false, + }); + } + } + } + } + else //没有就插入 全部同步 + { + //同步配方 + ZxRecipeEntity entity = new ZxRecipeEntity() + { + RecipeName = newRecipe.RecipeName, + RecipeCode = newRecipe.RecipeCode, + RecipeSpecCode = newRecipe.SpecCode, + RecipeSpecName = newRecipe.SpecName, + SizeKind = newRecipe.RimInch, + FixedWidth = newRecipe.FixRubWidth, + IsUse = true, + IsDeleted = false, + }; + ZxRecipeService.Instance.InsertRecipeInfo(entity); - //switch (en) - //{ - // case DataTypeEnum.Bool: - // res = PlcConnect.ReadBool1(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.Int16: - // res = PlcConnect.ReadInt161(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.UInt16: - // res = PlcConnect.ReadUInt161(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.Int32: - // res = PlcConnect.ReadInt321(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.UInt32: - // res = PlcConnect.ReadUInt321(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.Int64: - // res = PlcConnect.ReadInt641(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.UInt64: - // res = PlcConnect.ReadUInt641(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.Float: - // res = PlcConnect.ReadFloat1(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.Double: - // res = PlcConnect.ReadDouble1(PlcAddress.Text).ToString(); - // break; - // case DataTypeEnum.String: - // res = PlcConnect.ReadString1(PlcAddress.Text, (ushort)(GeneralUtils.StringNullOrToInt(LengthTextBox.Text) ?? 0)).ToString(); - // break; - // default: - // res = "不对劲儿奥"; - // break; - //} + //同步称量信息 + List zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); + for (int i = 1; i <= 3; i++) + { + string typeName = string.Empty; + switch (i) + { + case 1: + typeName = "基部胶"; + break; + case 2: + typeName = "中层胶"; + break; + case 3: + typeName = "胎面胶"; + break; + default: + break; + } + string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); + if (!string.IsNullOrEmpty(MaterialName)) + { + ZxWeightEntity weight = zxWeightEntities.FirstOrDefault(x => x.MaterialCode == MaterialName); + if (weight != null) //原来就有 + { + weight.SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)); //(decimal)newRecipe.MaterialThickness1; + weight.SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)); //newRecipe.MaterialWidth1; + weight.SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)); //newRecipe.MaterialWidth12; + weight.SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)); //newRecipe.MaterialWidth13; + weight.SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)); //newRecipe.MaterialLayers1; + weight.SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)); //newRecipe.MaterialLayers12; + weight.SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)); //newRecipe.MaterialLayers13; + ZxWeightService.Instance.UpdateWeightInfo(weight); + } + else //原来没有就添加 + { + ZxWeightService.Instance.InsertWeightInfo(new ZxWeightEntity() + { + RecipeCode = newRecipe.RecipeCode, + MaterialCode = MaterialName, + MaterialName = MaterialName + typeName, + MaterialType = typeName, + SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)), + SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), + SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), + SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), + SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)), + SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)), + SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)), + SetError = 1, + IsUse = true, + IsDeleted = false, + }); + } + } + } + + //同步公共参数 + ZxRecipeParaEntity recipeParaEntity = new ZxRecipeParaEntity(); + recipeParaEntity.RimInch = newRecipe.RimInch; + recipeParaEntity.LightWidth = newRecipe.FixRubWidth; + recipeParaEntity.SlowDistance = 0; + recipeParaEntity.StopDistance = 0; + recipeParaEntity.TireWeight = newRecipe.TireWeight; + recipeParaEntity.SpecCode = newRecipe.SpecCode; + recipeParaEntity.SpecName = newRecipe.SpecName; + recipeParaEntity.RecipeCode = newRecipe.RecipeCode; + + //自动工位选择 + zxWeightEntities.Clear(); + zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); + List openMixConfig = ZxOpenMixMaterialService.Instance.GetInfos(); + foreach (ZxWeightEntity weightEntity in zxWeightEntities) + { + var config = openMixConfig.Where(x => x.MaterialName == weightEntity.MaterialName).FirstOrDefault(); + if (config == null) + { + continue; + } + var prop = recipeParaEntity.GetType().GetProperty($"S{config.StationNo + 1}"); + if (prop != null) + { + prop.SetValue(recipeParaEntity, true); + } + //自动包边选择 + if (!(weightEntity.SetLayer2 == 0 + || weightEntity.SetLayer2 == null + || weightEntity.SetWidth2 == null + || weightEntity.SetWidth2 == 0)) + { + var propp = recipeParaEntity.GetType().GetProperty($"B{config.StationNo - 1}"); + if (propp != null) + { + propp.SetValue(recipeParaEntity, true); + } + } + if (!(weightEntity.SetLayer3 == 0 + || weightEntity.SetLayer3 == null + || weightEntity.SetWidth3 == null + || weightEntity.SetWidth3 == 0)) + { + var propp = recipeParaEntity.GetType().GetProperty($"B{config.StationNo + 4}"); + if (propp != null) + { + propp.SetValue(recipeParaEntity, true); + } + } + //设置胎体重量 + if (weightEntity.MaterialType == "胎面胶") + { + recipeParaEntity.TireWeight = Convert.ToSingle(weightEntity.SetWeight); + switch (config.StationNo) + { + case 3: + recipeParaEntity.S7 = true; + break; + case 4: + recipeParaEntity.S8 = true; + break; + case 5: + recipeParaEntity.S9 = true; + break; + default: + break; + } + } + } + ZxRecipeParaEntity nowRecipeParaEntity = ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(nowEneity.RecipeCode).FirstOrDefault(); + + if (nowRecipeParaEntity != null) //如果存在就更改 + { + recipeParaEntity.Id = nowRecipeParaEntity.Id; + ZxRecipeParaService.Instance.UpdateRecipeParaInfo(recipeParaEntity); + } + else + { + ZxRecipeParaService.Instance.InsertRecipeParaInfo(recipeParaEntity); + } + + //同步工位参数 + ZxRecipePositionParaService.Instance.DeleteRecipePositionParaInfoByRecipeCode(newRecipe.RecipeCode); //删除可能存在的脏数据 + for (int i = 1; i <= 3; i++) + { + string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); + if (string.IsNullOrEmpty(MaterialName)) + { + continue; + } + + var config = openMixConfig.Where(x => x.MaterialName.Contains(MaterialName)).FirstOrDefault(); + if (config == null) + { + continue; + } + ZxRecipePositionParaEntity positionEntity = new ZxRecipePositionParaEntity() + { + RecipeCode = newRecipe.RecipeCode, + Position = config.StationNo, + E1 = 15, + E2 = 52, + E5 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)) * 10, + E9 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), + E6 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)) * 10, + E7 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), + E3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)) * 10, + E4 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), + E10 = 800, + E8 = 300 + }; + + ZxRecipePositionParaService.Instance.InsertRecipePositionParaInfo(positionEntity); + } + + } - //PlcShowValue.Text = res; } - /// - /// PLC写入按钮 - /// - /// - /// - private void WriteButton_Click(object sender, EventArgs e) + private void TestButton1_Click(object sender, EventArgs e) { - + var a = ZxMesPlanTransferService.Instance.GetRecipeInfos(x => x.RequestFlag == false).FirstOrDefault(); + SyncRecipe(a); } } }