mengshunguo 1 month ago
parent
commit
95a2d856a9
1 changed files with 9 additions and 6 deletions
  1. 9 6
      SCADA_DAQ/Customer/Machines/SampleMachine.cs

+ 9 - 6
SCADA_DAQ/Customer/Machines/SampleMachine.cs

@@ -204,9 +204,9 @@ namespace SCADA_DAQ.Customer.Machines
                     if (ServerConncetStatus)
                     {
                         NotConnctNumberOfTimes++;
-                        bool toBeProduced;
-                        bool inProduction;
-                        bool produced;
+                        bool toBeProduced = false;
+                        bool inProduction = false;
+                        bool produced = false;
                         var taskInfoItem = DAL.APP_TaiLing_TaskManagement.GetData<TaskManagementModel>()?
                        .Where(t => t.WorkShopId == CustomerEnv.ProductionLineConfigValue.WorkShopId
                            && t.ProductionLineId == CustomerEnv.ProductionLineConfigValue.ProductionLineId && t.OrderState != "已生产")
@@ -224,7 +224,7 @@ namespace SCADA_DAQ.Customer.Machines
                                  );
                                 Log.Info($"订单{taskInfoItem.OrderId}开始生产");
                             }
-                            else if (taskInfoItem.CurrentProduction >= taskInfoItem.ScheduledProduction)
+                            else if (taskInfoItem.CurrentProduction + 1 >= taskInfoItem.ScheduledProduction)
                             {
                                 // 结束生产 
                                 var dateDiff = (DateTime.Now - taskInfoItem.WorkStartTime).TotalSeconds.ToInt();  // 时间差/s
@@ -239,11 +239,14 @@ namespace SCADA_DAQ.Customer.Machines
                             else if (taskInfoItem.WorkStartTime != new DateTime() && taskInfoItem.OrderState == "生产中")
                             {
                                 inProduction = DAL.APP_TaiLing_TaskManagement.Update($"ID={taskInfoItem.ID}",
-                               new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction + 1 + NotConnctNumberOfTimes)
+                               new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction + NotConnctNumberOfTimes)
                                  );
                             }
                             NumberOfTimes = 0;
-                            NotConnctNumberOfTimes = 0;
+                            if (toBeProduced || produced || inProduction)
+                            {
+                                NotConnctNumberOfTimes = 0;
+                            }
                         }
                     }
                     else