|
@@ -60,6 +60,16 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
/// </summary>
|
|
|
private int NumberOfTimes;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 产量暂存
|
|
|
+ /// </summary>
|
|
|
+ private int Qty;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 断开服务器的时间
|
|
|
+ /// </summary>
|
|
|
+ private DateTime NotConnectTime;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 服务器连接状态
|
|
|
/// </summary>
|
|
@@ -129,6 +139,14 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
var connectStatus = GetInternetConStatus.GetNetConStatus(Env.ServerIP.Value);
|
|
|
ServerConncetStatus = (connectStatus == 2 || connectStatus == 3) ? true : false;
|
|
|
+ if (!ServerConncetStatus)
|
|
|
+ {
|
|
|
+ NotConnectTime = DateTime.Now;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NotConnectTime = DateTime.Now;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -185,8 +203,11 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
NumberOfTimes++;
|
|
|
FirstTime = DateTime.Now;
|
|
|
}
|
|
|
- else if (NumberOfTimes == 1 && (int)(DateTime.Now - FirstTime).TotalSeconds < 7 && ServerConncetStatus)
|
|
|
+ else if (NumberOfTimes == 1 && (int)(DateTime.Now - FirstTime).TotalSeconds < 7)
|
|
|
{
|
|
|
+ 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 != "已生产")
|
|
@@ -194,42 +215,44 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
if (taskInfoItem == null) { return; }
|
|
|
else
|
|
|
{
|
|
|
- taskInfoItem.CurrentProduction++;
|
|
|
if (taskInfoItem.WorkStartTime == new DateTime() && taskInfoItem.OrderState == "待生产")
|
|
|
{
|
|
|
taskInfoItem.WorkStartTime = DateTime.Now;
|
|
|
- DAL.APP_TaiLing_TaskManagement.Update($"ID={taskInfoItem.ID}",
|
|
|
+ toBeProduced = DAL.APP_TaiLing_TaskManagement.Update($"ID={taskInfoItem.ID}",
|
|
|
new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "生产中"),
|
|
|
new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt, taskInfoItem.WorkStartTime.Format()),
|
|
|
- new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction)
|
|
|
+ new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction + 1)
|
|
|
);
|
|
|
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
|
|
|
- DAL.APP_TaiLing_TaskManagement.Update($"ID={taskInfoItem.ID}",
|
|
|
+ produced = DAL.APP_TaiLing_TaskManagement.Update($"ID={taskInfoItem.ID}",
|
|
|
new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt, DateTime.Now.Format()),
|
|
|
new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int, dateDiff),
|
|
|
new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产"),
|
|
|
- new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction)
|
|
|
+ new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction + 1)
|
|
|
);
|
|
|
Log.Info($"订单{taskInfoItem.OrderId}生产完成");
|
|
|
}
|
|
|
- else if(taskInfoItem.WorkStartTime != new DateTime() && taskInfoItem.OrderState == "生产中")
|
|
|
+ else if (taskInfoItem.WorkStartTime != new DateTime() && taskInfoItem.OrderState == "生产中")
|
|
|
{
|
|
|
- DAL.APP_TaiLing_TaskManagement.Update($"ID={taskInfoItem.ID}",
|
|
|
- new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction)
|
|
|
- );
|
|
|
+ inProduction = DAL.APP_TaiLing_TaskManagement.Update($"ID={taskInfoItem.ID}",
|
|
|
+ new UpdateItem(SqlSchema.DBNames.T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, taskInfoItem.CurrentProduction + 1)
|
|
|
+ );
|
|
|
}
|
|
|
NumberOfTimes = 0;
|
|
|
+ //if (toBeProduced || produced || inProduction)
|
|
|
+ //{
|
|
|
+ // Qty = 0;
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
else if (NumberOfTimes == 1 && (int)(DateTime.Now - FirstTime).TotalSeconds > 5)
|
|
|
{
|
|
|
NumberOfTimes = 0;
|
|
|
- FirstTime = DateTime.Now;
|
|
|
}
|
|
|
}
|
|
|
//log.Debug($"{DeviceConfig.DeviceID} {reg.RegName} Value Changed:{reg.OldValue}->{reg.Value}");
|