@ -1,5 +1,6 @@
using CommonFunc ;
using CommonFunc.Tools ;
using HandyControl.Tools.Extension ;
using Newtonsoft.Json ;
using System ;
using System.Collections.Generic ;
@ -42,7 +43,6 @@ namespace XGLFinishPro.Views
{
InitializeComponent ( ) ;
WindowChange ( WindowID . frame ) ;
}
@ -186,33 +186,32 @@ namespace XGLFinishPro.Views
DataTable dt = userDbWareHouse . GetWetPlanInfo ( deviceCode , LoginUser . WorkDate ) ; //formingMachineService.GetFormingMachineInfo(deviceCode, currShiftDate.ToString());
if ( dt = = null ) return ;
//if (dt != null && dt.Rows.Count > 0 )
// {
// foreach (DataRow row in dt.Rows)
// {
// // 获取当前行的 check_status 字段的值
// string checkStatus = row["check_status"] as string;
if ( dt ! = null & & dt . Rows . Count > 0 )
{
foreach ( DataRow row in dt . Rows )
{
// 获取当前行的 check_status 字段的值
string checkStatus = row [ "check_status" ] as string ;
// // 根据不同的情况修改值
// if (checkStatus == "Y")
// {
// row["check_status"] = "合格";
// }
// else if (checkStatus == "N")
// {
// row["check_status"] = "不合格";
// }
// else if (string.IsNullOrEmpty(checkStatus))
// {
// row["check_status"] = "无";
// }
// // 如果还有其他情况需要处理,可以继续添加 elseif 分支
// // 更新当前行的值
// dt.AcceptChanges();
// }
//}
// 根据不同的情况修改值
if ( checkStatus = = "Y" )
{
row [ "check_status" ] = "合格" ;
}
else if ( checkStatus = = "N" )
{
row [ "check_status" ] = "不合格" ;
}
else if ( string . IsNullOrEmpty ( checkStatus ) )
{
row [ "check_status" ] = "无" ;
}
// 如果还有其他情况需要处理,可以继续添加 elseif 分支
// 更新当前行的值
dt . AcceptChanges ( ) ;
}
}
if ( orderList ! = null )
{
//使用Dispatcher来在UI线程上更新UI
@ -310,32 +309,32 @@ namespace XGLFinishPro.Views
DataTable dt = userDbWareHouse . GetWetPlanInfo ( deviceCode , LoginUser . WorkDate ) ;
if ( dt = = null ) return ;
//if (dt != null && dt.Rows.Count > 0 )
// {
// foreach (DataRow row in dt.Rows)
// {
// // 获取当前行的 check_status 字段的值
// string checkStatus = row["check_status"] as string;
if ( dt ! = null & & dt . Rows . Count > 0 )
{
foreach ( DataRow row in dt . Rows )
{
// 获取当前行的 check_status 字段的值
string checkStatus = row [ "check_status" ] as string ;
// // 根据不同的情况修改值
// if (checkStatus == "Y")
// {
// row["check_status"] = "合格";
// }
// else if (checkStatus == "N")
// {
// row["check_status"] = "不合格";
// }
// else if (string.IsNullOrEmpty(checkStatus))
// {
// row["check_status"] = "无";
// }
// // 如果还有其他情况需要处理,可以继续添加 elseif 分支
// 根据不同的情况修改值
if ( checkStatus = = "Y" )
{
row [ "check_status" ] = "合格" ;
}
else if ( checkStatus = = "N" )
{
row [ "check_status" ] = "不合格" ;
}
else if ( string . IsNullOrEmpty ( checkStatus ) )
{
row [ "check_status" ] = "无" ;
}
// 如果还有其他情况需要处理,可以继续添加 elseif 分支
// // 更新当前行的值
// dt.AcceptChanges();
// }
// }
// 更新当前行的值
dt . AcceptChanges ( ) ;
}
}
if ( dt = = null ) return ;
this . dgWorkOrderInfo . ItemsSource = null ;
@ -621,57 +620,64 @@ namespace XGLFinishPro.Views
private async void btnPause1_Click ( object sender , RoutedEventArgs e )
{
//陈恒杰在2024-01-07日与榄菊的苏振华确认, 不需要用户验证
//CheckUserWin checkUserWin = new CheckUserWin();
//checkUserWin.ShowDialog();
//if (!checkUserWin.loginFlag)
//{
// CustomMessageBox.Show("请先校验用户!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
// return;
//}
if ( dgWorkOrderInfo . SelectedItems . Count = = 0 )
try
{
CustomMessageBox . Show ( "请选择要开始的工单!" , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
return ;
}
string workorderID = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "workorder_code" ] . ToString ( ) ;
string status = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "status" ] . ToString ( ) ;
if ( ! status . Equals ( "w1" ) )
{
if ( status ! = "" )
//陈恒杰在2024-01-07日与榄菊的苏振华确认, 不需要用户验证
//CheckUserWin checkUserWin = new CheckUserWin();
//checkUserWin.ShowDialog();
//if (!checkUserWin.loginFlag)
//{
// CustomMessageBox.Show("请先校验用户!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
// return;
//}
if ( dgWorkOrderInfo . SelectedItems . Count = = 0 )
{
string st = status . Equals ( "w1" ) ? "未派发" : status . Equals ( "w3" ) ? "已报工" : status . Equals ( "w0" ) ? "未派发" : "已暂停" ;
CustomMessageBox . Show ( "该工单不符合条件,请检查工单状态,当前工单状态为:" + st , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
CustomMessageBox . Show ( "请选择要开始的工单!" , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
return ;
}
string workorderID = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "workorder_code" ] . ToString ( ) ;
string status = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "status" ] . ToString ( ) ;
LogHelper . instance . log . Info ( "记录工单状态:" + status + ", 工单号为:" + workorderID ) ;
if ( ! status . Equals ( "w1" ) )
{
if ( status ! = "" )
{
string st = status . Equals ( "w1" ) ? "未派发" : status . Equals ( "w3" ) ? "已报工" : status . Equals ( "w0" ) ? "未派发" : "已暂停" ;
CustomMessageBox . Show ( "该工单不符合条件,请检查工单状态,当前工单状态为:" + st , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
return ;
}
}
CustomMessageBoxResult result = CustomMessageBox . Show ( "你确定要开始工单么?" , CustomMessageBoxButton . OKCancel , CustomMessageBoxIcon . Warning ) ;
if ( result = = CustomMessageBoxResult . Cancel )
return ;
//2024-04-23赵啸林要求添加一条产线同一天只能有一个活动状态下的工单, 如果有未报工的则不允许开始新的工单
int orderCount = GetActivedOrdersCount ( this . deviceCode , LoginUser . WorkDate ) ;
if ( orderCount > = 1 )
{
CustomMessageBox . Show ( "已有活动中的工单,请先报工再开始下一个工单!" , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
return ;
}
//更新工单状态
if ( ! UpdateOrderStatus ( workorderID ) )
{
CustomMessageBox . Show ( "开始工单失败!" , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
}
else
{
//巡检
string materialCode = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "product_code" ] . ToString ( ) ;
string materialDesc = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "product_name" ] . ToString ( ) ;
userDbWareHouse . InsertOperationLog ( workorderID , "w2" , "" , "开始工单" , deviceCode , materialCode , materialDesc ) ;
// await CallCheckApi("checkTypeSCXJ");20240403赵啸林因为切线方案调整, 要求取消上位机生成巡检任务的功能;
TimerDeciveState_Elapsed ( null , null ) ;
}
}
CustomMessageBoxResult result = CustomMessageBox . Show ( "你确定要开始工单么?" , CustomMessageBoxButton . OKCancel , CustomMessageBoxIcon . Warning ) ;
if ( result = = CustomMessageBoxResult . Cancel )
return ;
//2024-04-23赵啸林要求添加一条产线同一天只能有一个活动状态下的工单, 如果有未报工的则不允许开始新的工单
int orderCount = GetActivedOrdersCount ( this . deviceCode , LoginUser . WorkDate ) ;
if ( orderCount > = 1 )
catch ( Exception ex )
{
CustomMessageBox . Show ( "已有活动中的工单,请先报工再开始下一个工单!" , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
return ;
}
//更新工单状态
if ( ! UpdateOrderStatus ( workorderID ) )
{
CustomMessageBox . Show ( "开始工单失败!" , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;
}
else
{
//巡检
string materialCode = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "product_code" ] . ToString ( ) ;
string materialDesc = ( dgWorkOrderInfo . SelectedItem as DataRowView ) [ "product_name" ] . ToString ( ) ;
userDbWareHouse . InsertOperationLog ( workorderID , "w2" , "" , "开始工单" , deviceCode , materialCode , materialDesc ) ;
// await CallCheckApi("checkTypeSCXJ");20240403赵啸林因为切线方案调整, 要求取消上位机生成巡检任务的功能;
TimerDeciveState_Elapsed ( null , null ) ;
LogHelper . instance . log . Error ( "开始工单异常:" + ex . Message ) ;
}
}
private int GetActivedOrdersCount ( string deviceCode , string workDate )
@ -685,8 +691,13 @@ namespace XGLFinishPro.Views
private bool UpdateOrderStatus ( string workorderID )
{
string name = LoginUser . UserName + "-" + LoginUser . UserId ;
if ( name . IsNullOrEmpty ( ) )
{
name = "无-0" ;
}
//更新工单状态
var updatestatus = userDbWareHouse . UpdateSycnFlag ( workorderID , deviceCode ) ;
var updatestatus = userDbWareHouse . UpdateSycnFlag ( workorderID , deviceCode , name );
if ( ! updatestatus )
{
CustomMessageBox . Show ( "开始工单失败!" , CustomMessageBoxButton . OK , CustomMessageBoxIcon . Warning ) ;