From 5870e51dcc0a792acd7281ba440292a979f79d74 Mon Sep 17 00:00:00 2001 From: zhaojian Date: Wed, 5 Jun 2024 09:13:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A6=84=E8=8F=8A=E4=B8=8A=E4=BD=8D=E6=9C=BA?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinishProdDBService.cs | 60 ++---- shangjian/XGLFinishPro/App.config | 2 +- .../XGLFinishPro/Views/ExecReportWorkWin.xaml | 2 +- .../Views/ExecReportWorkWin.xaml.cs | 108 +++++----- .../XGLFinishPro/Views/LanJu_Operator.xaml | 6 +- .../XGLFinishPro/Views/LanJu_Operator.xaml.cs | 201 +++++++++--------- .../XGLFinishPro/Views/LanJu_Prepare.xaml.cs | 8 +- .../XGLFinishPro/Views/PieceSalaryCalWin.xaml | 6 +- .../Views/PieceSalaryCalWin.xaml.cs | 82 +++++-- .../XGLFinishPro/Views/weighWindows.xaml.cs | 58 +++-- 10 files changed, 299 insertions(+), 234 deletions(-) diff --git a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs index 4693537..09a8a80 100644 --- a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs +++ b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs @@ -13,6 +13,7 @@ using MySql.Data.MySqlClient; using CommonFunc.Tools; using XGL.Models.Model; using XGL.Models; +using XGL.Models.Model.OrderPrepare; namespace XGL.Dats.DBServiceFinishProd { @@ -663,11 +664,11 @@ where 1=1 and /// /// /// - public DataTable GetUnitPriceData(string deviceCode) + public DataTable GetUnitPriceData(string deviceCode ,string sheredata) { string sql = $@"select [workorder_code], [workorder_code_sap], [product_name], SUBSTRING([product_code], 8, LEN(product_code)) as product_code, [user_name], [nick_name], [childprocess_code], [childprocess_name] ,[create_by], [create_time], [line_code] ,[attr1] from mes_unitprice_report -where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = CONVERT(VARCHAR(10),GETDATE(), 120) ORDER BY childprocess_code,create_time"; +where line_code = '{deviceCode}' AND create_time BETWEEN '{sheredata} 00:00:00' AND '{sheredata} 23:59:59' ORDER BY childprocess_code,create_time"; DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) @@ -680,8 +681,10 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C public string GetUsernumbereData(string deviceCode) { - string sql = $@"SELECT SUM(quantity_feedback) as total_quantity FROM mes_report_work WHERE workorder_code='{deviceCode}'"; - + string sql = $@"SELECT COALESCE(CAST(SUM(quantity_feedback) / SUM(use_man) AS INT), 0) as total_quantity +FROM mes_report_work +WHERE parent_order = '{deviceCode}' and del_flag='0'; + "; DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) { @@ -717,7 +720,7 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C /// /// /// - public string GetCreateUnitPriceInfo(sys_user item,string workorderCode, string sapWorkorderCode,string productCode,string productName,string childProcessCode,string childProcessName,string deviceCode,string number) + public string GetCreateUnitPriceInfo(sys_user item,string workorderCode, string sapWorkorderCode,string productCode,string productName,string childProcessCode,string childProcessName,string deviceCode,string number,string credata) { string sql = $@"INSERT INTO [dbo].[mes_unitprice_report] ( [id],[workorder_code], [workorder_code_sap], [product_name], [product_code], @@ -729,7 +732,7 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C ( '{Common.GetUUID()}', '{workorderCode}','{sapWorkorderCode}', '{productName}', '{productCode}', N'{item.user_name}', N'{item.nick_name}', N'{childProcessCode}', N'{childProcessName}',' {number}', - NULL, NULL, '{LoginUser.UserName}', getdate(), NULL, + NULL, NULL, '{LoginUser.UserName}', '{credata} 00:00:00', NULL, NULL, NULL,'{deviceCode}' );"; return sql; @@ -748,9 +751,9 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C return null; } - public List GetOnWorkUserList(string deviceCode) + public List GetOnWorkUserList(string deviceCode,string shereDate) { - string sql = $"SELECT user_id as user_name,user_name as nick_name,sex,age FROM [dbo].[mes_attendance_records] where start_addr = '{deviceCode}' and CONVERT(VARCHAR(10), create_time , 120) = CONVERT(VARCHAR(10), GETDATE() , 120) order by create_time desc ;"; + string sql = $"WITH RankedRecords AS (\r\n SELECT \r\n user_id as user_name,\r\n user_name as nick_name,\r\n sex,\r\n age,\r\n create_time,\r\n ROW_NUMBER() OVER (PARTITION BY user_name ORDER BY create_time DESC) as rn\r\n FROM [dbo].[mes_attendance_records]\r\n WHERE start_addr = '{deviceCode}' \r\n AND create_time BETWEEN '{shereDate} 00:00:00' AND '{shereDate} 23:59:59'\r\n)\r\nSELECT \r\n user_name,\r\n nick_name,\r\n sex,\r\n age,\r\n create_time\r\nFROM RankedRecords\r\nWHERE rn = 1\r\nORDER BY create_time DESC;"; DataTable dt = Utils.netClientDBHelper.getDataSet(sql).Tables[0]; @@ -991,9 +994,9 @@ where detail.parent_work_order = '{processid}'"; //where CONVERT(VARCHAR(10), w /// 更新湿料计划同步状态、工单状态 /// /// - public bool UpdateSycnFlag(string workOrderID,string deviceCode) + public bool UpdateSycnFlag(string workOrderID,string deviceCode,string user) { - string sql1 = $@"update pro_order_workorder set status = 'w2',workorder_name = '{deviceCode}', update_by = '{LoginUser.UserName}',update_time = GETDATE() where workorder_code = '{workOrderID}' "; + string sql1 = $@"update pro_order_workorder set status = 'w2',workorder_name = '{deviceCode}', update_by = '{LoginUser.UserName}',attr3='{user}',update_time = GETDATE() where workorder_code = '{workOrderID}' "; return Utils.netClientDBHelper.executeUpdate(sql1) > 0 ? true : false; @@ -3498,39 +3501,8 @@ left join basedata_plcsetting f on a.PlcId5=f.Id return null; } - public void InsertCheckTaskDetail(string value,string where) + public int InsertCheckTaskDetail(string value,string where) { - - - //StringBuilder strSql = new StringBuilder(); - //strSql.Append("UPDATE qc_check_task_detail "); - //strSql.Append("SET actual_value ="); - //if (value == null) - - //StringBuilder strSql = new StringBuilder(); - //strSql.Append("UPDATE qc_check_task_detail "); - //strSql.Append("SET actual_value ="); - //if (value==null) - - //{ - // strSql.Append("NULL"); - //} - //else - //{ - // strSql.Append($"'{value}'"); - //} - - - //strSql.Append(" WHERE record_id ="); - //strSql.Append($"'{where}'"); - //Utils.netClientDBHelper.executeUpdate(strSql.ToString()); - - - //strSql.Append(" WHERE record_id ="); - //strSql.Append($"'{where}'"); - //int rowsAffected = Utils.netClientDBHelper.executeUpdate(strSql.ToString()); - - StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE qc_check_task_detail "); strSql.Append("SET actual_value ="); @@ -3545,8 +3517,8 @@ left join basedata_plcsetting f on a.PlcId5=f.Id strSql.Append(" WHERE record_id ="); strSql.Append($"'{where}'"); - Utils.netClientDBHelper.executeUpdate(strSql.ToString()); - + int result= Utils.netClientDBHelper.executeUpdate(strSql.ToString()); + return result; } // /// diff --git a/shangjian/XGLFinishPro/App.config b/shangjian/XGLFinishPro/App.config index a50ba33..2de7c83 100644 --- a/shangjian/XGLFinishPro/App.config +++ b/shangjian/XGLFinishPro/App.config @@ -10,7 +10,7 @@ - + diff --git a/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml b/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml index 4cbf8ed..e1ac715 100644 --- a/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml +++ b/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:local="clr-namespace:XGLFinishPro.Views" xmlns:convert="clr-namespace:XGLFinishPro.Tools" mc:Ignorable="d" diff --git a/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml.cs b/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml.cs index 64196a3..1ab767f 100644 --- a/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml.cs +++ b/shangjian/XGLFinishPro/Views/ExecReportWorkWin.xaml.cs @@ -382,62 +382,62 @@ namespace XGLFinishPro.Views //createCheckProductTask createCheckProductTask = new createCheckProductTask(); //createCheckProductTask.checkLoc = deviceCode; //createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode"); - //if (comboBoxBatch.SelectedIndex != 0) - //{ - // try - // { - // var getorder = formingMachineService.Getorderworkorder(lbCurrOrderNo.Content.ToString()); - // var eqment = formingMachineService.GetWorkShop(Utils.GetAppSetting("DeviceCode")); - // createCheckProductTask createCheckProductTask = new createCheckProductTask(); - // createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");//工厂编码 - // createCheckProductTask.incomeBatchNo = comboBoxBatch.Text.ToString();//批次号 - // createCheckProductTask.orderNo = lbCurrOrderNo.Content.ToString();//订单号 - // if (getorder != null && getorder.Rows.Count > 0) - // { - // createCheckProductTask.materialCode = getorder.Rows[0]["product_code"].ToString(); ;//物料编码 - // createCheckProductTask.materialName = getorder.Rows[0]["product_name"].ToString();//物料名称 - // createCheckProductTask.unit = getorder.Rows[0]["unit"].ToString();//单位,(字典表) - // } - // createCheckProductTask.checkType = "checkTypeCPPC";//批次成品检验固定值 - // createCheckProductTask.typeCode = "product";//product - // createCheckProductTask.quality = txtQuantity.Text;//数量 + if (comboBoxBatch.SelectedIndex != 0) + { + try + { + var getorder = formingMachineService.Getorderworkorder(lbCurrOrderNo.Content.ToString()); + var eqment = formingMachineService.GetWorkShop(Utils.GetAppSetting("DeviceCode")); + createCheckProductTask createCheckProductTask = new createCheckProductTask(); + createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");//工厂编码 + createCheckProductTask.incomeBatchNo = comboBoxBatch.Text.ToString();//批次号 + createCheckProductTask.orderNo = lbCurrOrderNo.Content.ToString();//订单号 + if (getorder != null && getorder.Rows.Count > 0) + { + createCheckProductTask.materialCode = getorder.Rows[0]["product_code"].ToString(); ;//物料编码 + createCheckProductTask.materialName = getorder.Rows[0]["product_name"].ToString();//物料名称 + createCheckProductTask.unit = getorder.Rows[0]["unit"].ToString();//单位,(字典表) + } + createCheckProductTask.checkType = "checkTypeCPPC";//批次成品检验固定值 + createCheckProductTask.typeCode = "product";//product + createCheckProductTask.quality = txtQuantity.Text;//数量 - // if (eqment != null && eqment.Rows.Count > 0) - // { - // createCheckProductTask.carName = eqment.Rows[0]["workshop_name"].ToString();//车间名称 - // createCheckProductTask.carName = eqment.Rows[0]["workshop_code"].ToString();//车间编码 - // } - // createCheckProductTask.produceDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//生产时间格式yyyy-MM-dd HH:mm:ss - // createCheckProductTask.checkLoc = Utils.GetAppSetting("DeviceCode");//检测地点 - // // 接口地址 - // string apiUrl = formingMachineService.InterfaceUrl("BatcInspection"); - // // 将请求参数序列化为 JSON 格式 - // string requestBodyJson = Newtonsoft.Json.JsonConvert.SerializeObject(createCheckProductTask); - // // 发送 HTTP POST 请求 - // using (var httpClient = new HttpClient()) - // { - // var content = new StringContent(requestBodyJson, Encoding.UTF8, "application/json"); - // var response = httpClient.PostAsync(apiUrl, content).Result; // 或者 .Wait(); + if (eqment != null && eqment.Rows.Count > 0) + { + createCheckProductTask.carName = eqment.Rows[0]["workshop_name"].ToString();//车间名称 + createCheckProductTask.carName = eqment.Rows[0]["workshop_code"].ToString();//车间编码 + } + createCheckProductTask.produceDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//生产时间格式yyyy-MM-dd HH:mm:ss + createCheckProductTask.checkLoc = Utils.GetAppSetting("DeviceCode");//检测地点 + // 接口地址 + string apiUrl = formingMachineService.InterfaceUrl("BatcInspection"); + // 将请求参数序列化为 JSON 格式 + string requestBodyJson = Newtonsoft.Json.JsonConvert.SerializeObject(createCheckProductTask); + // 发送 HTTP POST 请求 + using (var httpClient = new HttpClient()) + { + var content = new StringContent(requestBodyJson, Encoding.UTF8, "application/json"); + var response = httpClient.PostAsync(apiUrl, content).Result; // 或者 .Wait(); - // // 判断响应状态码是否为成功 - // if (response.IsSuccessStatusCode) - // { - // // 获取响应内容 - // string responseBody = response.Content.ReadAsStringAsync().Result; // 或者 .Wait(); - // } - // else - // { - // // 输出失败信息 - // CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 3000); - // } - // } - // } - // catch (Exception ex) - // { - // LogHelper.instance.log.Error("批次成品入库检验任务创建接口调用失败>>" + ex.Message); - // CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error); - // } - //} + // 判断响应状态码是否为成功 + if (response.IsSuccessStatusCode) + { + // 获取响应内容 + string responseBody = response.Content.ReadAsStringAsync().Result; // 或者 .Wait(); + } + else + { + // 输出失败信息 + CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 3000); + } + } + } + catch (Exception ex) + { + LogHelper.instance.log.Error("批次成品入库检验任务创建接口调用失败>>" + ex.Message); + CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error); + } + } //if (result.code == 200) //{ return AddConsumInfo(reportWorkSqlList, newReportCode); diff --git a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml index 28ac5d9..04ac24a 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml +++ b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml @@ -539,12 +539,12 @@ Background="#F2F3F5" - + - + + diff --git a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs index 79ebb5f..097bb91 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs +++ b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs @@ -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); diff --git a/shangjian/XGLFinishPro/Views/LanJu_Prepare.xaml.cs b/shangjian/XGLFinishPro/Views/LanJu_Prepare.xaml.cs index ae8ba5b..b7b70b5 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_Prepare.xaml.cs +++ b/shangjian/XGLFinishPro/Views/LanJu_Prepare.xaml.cs @@ -1,6 +1,7 @@ using CentralControl.BaseData; using CommonFunc; using CommonFunc.Tools; +using HandyControl.Tools.Extension; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -414,8 +415,13 @@ namespace XGLFinishPro.Views private bool UpdateOrderStatus(string workorderID) { + string name = LoginUser.UserName + "-" + LoginUser.UserCode; + 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); diff --git a/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml b/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml index d612724..41eb2f4 100644 --- a/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml +++ b/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml @@ -325,8 +325,9 @@