|
@@ -1,5 +1,7 @@
|
|
|
using Microsoft.DwayneNeed.Numerics;
|
|
|
using Microsoft.DwayneNeed.Win32.Gdi32;
|
|
|
+using Mysqlx.Crud;
|
|
|
+using Mysqlx.Session;
|
|
|
using NPOI.SS.Formula.Eval;
|
|
|
using SCADA.CommonCtrl.WpfControl;
|
|
|
using SCADA.CommonLib;
|
|
@@ -47,9 +49,9 @@ namespace SCADA_DAQ.Customer
|
|
|
FrmQuery.QueryModel = QueryModel;
|
|
|
//DAL = Env.DAL;
|
|
|
DAL = Env.SgIDAL;
|
|
|
- //MainGrid.IsAutoUpdate = true; //表格更新时允许更新到数据库
|
|
|
MainGrid.SourceTable = QueryModel.SourceTable; //指定绑定更新的表
|
|
|
MainGrid.DataTableColumnLables = SmartGridHeaderMapping.CreateMapping<TaskManagementModel>();
|
|
|
+
|
|
|
// 给字段设置下拉选项
|
|
|
MainGrid.DataTableColumnLables[T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str].OptionItems
|
|
|
= new Dictionary<string, string>() { { "待生产", "待生产" }, { "生产中", "生产中" }, { "已生产", "已生产" } };
|
|
@@ -62,65 +64,66 @@ namespace SCADA_DAQ.Customer
|
|
|
MainGrid.DataTableColumnLables[T_Col_Name.APP_TaiLing_TaskManagement.MotorcycleTypeName_Str].SelectedValuePath
|
|
|
= "MotorcycleTypeName";
|
|
|
|
|
|
+ //MainGrid.CellEditEnding += MainGrid_CellEditEnding;
|
|
|
|
|
|
- MainGrid.CellEditEnding += MainGrid_CellEditEnding;
|
|
|
}
|
|
|
|
|
|
- private void MainGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 完成生产
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void IconButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- string newValue = (e.EditingElement as TextBox).Text; // 新编辑的值
|
|
|
- var item = (DataRowView)((SmartGrid)sender).CurrentItem;
|
|
|
- //var cell = ((SmartGrid)sender).CurrentCell;
|
|
|
- //var x = cell.Column;
|
|
|
- //var y = cell.Item;
|
|
|
- //var column = ((SmartGrid)sender).CurrentCell.Column.Header;
|
|
|
-
|
|
|
+ var item = MainGrid.CurrentItem as DataRowView;
|
|
|
+ if (item == null) return;
|
|
|
+ var id = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.ID]?.ToString());
|
|
|
var orderId = Convert.ToString(item[T_Col_Name.APP_TaiLing_TaskManagement.OrderId_Str]);
|
|
|
- var scheduledProduction = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.ScheduledProduction_Int]);
|
|
|
- var currentProduction = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int]);
|
|
|
var workStartTime = item[T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt];
|
|
|
var orderDatetime = Convert.ToDateTime(item[T_Col_Name.APP_TaiLing_TaskManagement.OrderDatetime_Dt]);
|
|
|
- var workShopId = CustomerEnv.ProductionLineConfigValue.WorkShopId;
|
|
|
- var productionLineId = CustomerEnv.ProductionLineConfigValue.ProductionLineId;
|
|
|
-
|
|
|
- //if (e.Column.Header.ToString() == "计划产量")
|
|
|
- // return;
|
|
|
+ var scheduledProduction = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.ScheduledProduction_Int]);
|
|
|
|
|
|
- if (e.Column.Header.ToString() == "当前产量")
|
|
|
- {
|
|
|
- currentProduction = Convert.ToInt32(newValue);
|
|
|
- }
|
|
|
- if (scheduledProduction > currentProduction)
|
|
|
- return;
|
|
|
- var taskInfo = Env.SgIDAL.APP_TaiLing_TaskManagement?.GetData<TaskManagementModel>()?
|
|
|
- .Where(t => t.OrderId == orderId && t.WorkShopId == workShopId
|
|
|
- && t.ProductionLineId == productionLineId)
|
|
|
- .OrderBy(t => t.ID).LastOrDefault();
|
|
|
- if (taskInfo == null)
|
|
|
+ if (MessageBox.Show($"是否确认已完成 {orderId} ?", "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
|
|
|
return;
|
|
|
|
|
|
+ var res = false;
|
|
|
if (workStartTime is DBNull)
|
|
|
{
|
|
|
var dateDiff = (DateTime.Now - orderDatetime).TotalSeconds.ToInt(); // 时间差/s
|
|
|
- Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"OrderId_Str='{orderId}' AND WorkShopId_Str='{workShopId}' AND ProductionLineId_Str='{productionLineId}'",
|
|
|
+ res = Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"ID={id}",
|
|
|
+ new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, scheduledProduction),
|
|
|
new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt, orderDatetime),
|
|
|
new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt, DateTime.Now.Format()),
|
|
|
new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int, dateDiff),
|
|
|
- new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产")
|
|
|
+ new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产"),
|
|
|
+ new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.ModifyTime_Dt, DateTime.Now.Format())
|
|
|
);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var dateDiff = (DateTime.Now - taskInfo.WorkStartTime).TotalSeconds.ToInt(); // 时间差/s
|
|
|
- Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"OrderId_Str='{orderId}' AND WorkShopId_Str='{workShopId}' AND ProductionLineId_Str='{productionLineId}'",
|
|
|
+ var dateDiff = (DateTime.Now - Convert.ToDateTime(workStartTime)).TotalSeconds.ToInt(); // 时间差/s
|
|
|
+ res = Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"ID={id}",
|
|
|
+ new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int, scheduledProduction),
|
|
|
new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt, DateTime.Now.Format()),
|
|
|
new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int, dateDiff),
|
|
|
- new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产")
|
|
|
+ new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产"),
|
|
|
+ new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.ModifyTime_Dt, DateTime.Now.Format())
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ if (res)
|
|
|
+ {
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast("操作成功!", ControlStyle.Success);
|
|
|
+ Query();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast("操作失败,请重试!", ControlStyle.Warning);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
|
|
|
{
|
|
|
if (e.ChangeType == DateTimeChangeType.MinuteChanged && e.TimeFlag.Minute % 10 == 0)
|
|
@@ -136,6 +139,60 @@ namespace SCADA_DAQ.Customer
|
|
|
Query();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //private void MainGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
|
+ //{
|
|
|
+ // string newValue = (e.EditingElement as TextBox).Text; // 新编辑的值
|
|
|
+ // var item = (DataRowView)((SmartGrid)sender).CurrentItem;
|
|
|
+ // //var cell = ((SmartGrid)sender).CurrentCell;
|
|
|
+ // //var x = cell.Column;
|
|
|
+ // //var y = cell.Item;
|
|
|
+ // //var column = ((SmartGrid)sender).CurrentCell.Column.Header;
|
|
|
+
|
|
|
+ // var orderId = Convert.ToString(item[T_Col_Name.APP_TaiLing_TaskManagement.OrderId_Str]);
|
|
|
+ // var scheduledProduction = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.ScheduledProduction_Int]);
|
|
|
+ // var currentProduction = Convert.ToInt32(item[T_Col_Name.APP_TaiLing_TaskManagement.CurrentProduction_Int]);
|
|
|
+ // var workStartTime = item[T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt];
|
|
|
+ // var orderDatetime = Convert.ToDateTime(item[T_Col_Name.APP_TaiLing_TaskManagement.OrderDatetime_Dt]);
|
|
|
+ // var workShopId = CustomerEnv.ProductionLineConfigValue.WorkShopId;
|
|
|
+ // var productionLineId = CustomerEnv.ProductionLineConfigValue.ProductionLineId;
|
|
|
+
|
|
|
+ // //if (e.Column.Header.ToString() == "计划产量")
|
|
|
+ // // return;
|
|
|
+
|
|
|
+ // if (e.Column.Header.ToString() == "当前产量")
|
|
|
+ // {
|
|
|
+ // currentProduction = Convert.ToInt32(newValue);
|
|
|
+ // }
|
|
|
+ // if (scheduledProduction > currentProduction)
|
|
|
+ // return;
|
|
|
+ // var taskInfo = Env.SgIDAL.APP_TaiLing_TaskManagement?.GetData<TaskManagementModel>()?
|
|
|
+ // .Where(t => t.OrderId == orderId && t.WorkShopId == workShopId
|
|
|
+ // && t.ProductionLineId == productionLineId)
|
|
|
+ // .OrderBy(t => t.ID).LastOrDefault();
|
|
|
+ // if (taskInfo == null)
|
|
|
+ // return;
|
|
|
+
|
|
|
+ // if (workStartTime is DBNull)
|
|
|
+ // {
|
|
|
+ // var dateDiff = (DateTime.Now - orderDatetime).TotalSeconds.ToInt(); // 时间差/s
|
|
|
+ // Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"OrderId_Str='{orderId}' AND WorkShopId_Str='{workShopId}' AND ProductionLineId_Str='{productionLineId}'",
|
|
|
+ // new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkStartTime_Dt, orderDatetime),
|
|
|
+ // new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt, DateTime.Now.Format()),
|
|
|
+ // new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int, dateDiff),
|
|
|
+ // new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产")
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // var dateDiff = (DateTime.Now - taskInfo.WorkStartTime).TotalSeconds.ToInt(); // 时间差/s
|
|
|
+ // Env.SgIDAL.APP_TaiLing_TaskManagement.Update($"OrderId_Str='{orderId}' AND WorkShopId_Str='{workShopId}' AND ProductionLineId_Str='{productionLineId}'",
|
|
|
+ // new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.WorkEndTime_Dt, DateTime.Now.Format()),
|
|
|
+ // new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.DurationSec_Int, dateDiff),
|
|
|
+ // new UpdateItem(T_Col_Name.APP_TaiLing_TaskManagement.OrderState_Str, "已生产")
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
|