From 56cfc7cf9b3fa67722c5ed0f36d04fc9192570d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83?= <15095123350@163.com> Date: Wed, 14 Aug 2024 13:12:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=B7=A5=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DBService/FormingMachineService.cs | 48 +++++++++++++------ shangjian/XGLFinishPro/LoginPage.xaml.cs | 2 +- .../XGLFinishPro/Views/LanJu_Operator.xaml | 2 +- .../XGLFinishPro/Views/LanJu_Operator.xaml.cs | 11 ++++- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/shangjian/XGL.Data/DBService/FormingMachineService.cs b/shangjian/XGL.Data/DBService/FormingMachineService.cs index 3e4fabb..b44f96b 100644 --- a/shangjian/XGL.Data/DBService/FormingMachineService.cs +++ b/shangjian/XGL.Data/DBService/FormingMachineService.cs @@ -21,7 +21,7 @@ namespace XGL.Data.DBService /// /// public DataTable GetFormingMachineInfo(string devicecode, string workDate) - { + { //过于复杂,给数据库造成了压力,经常死锁 // string sql = $@"SELECT DISTINCT // ord.workorder_id, @@ -67,7 +67,7 @@ namespace XGL.Data.DBService pro_order_workorder ord WITH (NOLOCK) LEFT JOIN base_shifts_t shift WITH (NOLOCK) on ord.shift_id = shift.Shift_Id WHERE - CONVERT(VARCHAR(10), ord.product_date , 120) = CONVERT(VARCHAR(10), '{workDate+ " 0:00:00"}', 120 ) + CONVERT(VARCHAR(10), ord.product_date , 120) = CONVERT(VARCHAR(10), '{workDate + " 0:00:00"}', 120 ) And ord.prod_line_code like '%{devicecode}%' AND ord.del_flag='0'"; DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) @@ -78,8 +78,8 @@ namespace XGL.Data.DBService string totalsql = $"SELECT count(*) FROM mes_material_transfer_result result WHERE result.equipmentCode =" + $" '{devicecode}' AND result.update_time >= ( SELECT TOP 1 create_time FROM mes_changeshift_info WHERE device_code" + $" = '{devicecode}' ORDER BY create_time DESC ) AND result.rfid_status='1' ;"; - // string totalcountSql = $@" select count(*) as totalCount from mes_material_transfer_result WITH (NOLOCK) - //where CONVERT(VARCHAR(10), work_date , 120) = CONVERT(VARCHAR(10),'{workDate}', 120) and equipmentCode = '{devicecode}' and OrderCode = '{work0rderID}' group by OrderCode "; + // string totalcountSql = $@" select count(*) as totalCount from mes_material_transfer_result WITH (NOLOCK) + //where CONVERT(VARCHAR(10), work_date , 120) = CONVERT(VARCHAR(10),'{workDate}', 120) and equipmentCode = '{devicecode}' and OrderCode = '{work0rderID}' group by OrderCode "; DataSet dtsetTotalCount = Utils.netClientDBHelper.getDataSet(totalsql); if (dtsetTotalCount != null && dtsetTotalCount.Tables.Count > 0 && dtsetTotalCount.Tables[0].Rows.Count > 0) { @@ -143,7 +143,7 @@ namespace XGL.Data.DBService /// /// /// - public string InterfaceUrl( string url_type) + public string InterfaceUrl(string url_type) { string sql = $@"select url FROM mes_interface_url WHERE url_type='{url_type}'"; @@ -595,7 +595,7 @@ VALUES /// /// public List GetExecuteReportWorkSql(DataRowView selectRow, string orderQuntity, string workCount, string reportCode, string workTime, string userCount, string costCenter, string batchCode, - string isEndReport, string deviceCode, Dictionary workTimeDic, Dictionary userCountDic,string xiaolv,string shijian) + string isEndReport, string deviceCode, Dictionary workTimeDic, Dictionary userCountDic, string xiaolv, string shijian) { string getReportCodeSql = $@"SELECT equipment_code,equipment_name FROM [dbo].[base_equipment] WHERE equipment_code='{deviceCode}'"; string lineName = ""; @@ -607,7 +607,10 @@ VALUES #region 生成报工数据 //获取子工单的信息 - string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{selectRow["workorder_code"]}'"; + #region 订单不能是已经被删除的 + string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{selectRow["workorder_code"]}' and del_flag=0"; + #endregion + //string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{selectRow["workorder_code"]}'"; string subOrder = ""; //string subProductCode = ""; //string subProductName = ""; @@ -747,7 +750,7 @@ VALUES //添加批次报工状态更新--2023-12-26 string updateBatchOrderStatusSql = $@"update pro_order_workorder_batch set status = '0', update_by = '{LoginUser.UserName}',update_time = GETDATE() where workorder_id = '{selectRow["workorder_id"]}' and batch_code = '{batchCode}' "; sqlList.Add(updateBatchOrderStatusSql); - } + } #endregion @@ -779,7 +782,9 @@ VALUES { //获取子工单的信息 - string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{orderId}'"; + #region 子单不能是已经被删除的 + string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{orderId}' and del_flag=0"; + #endregion string subOrder = ""; string subProductCode = ""; string subProductName = ""; @@ -791,9 +796,9 @@ VALUES subOrder = dtSubOrder.Tables[0].Rows[0]["workorder_code"].ToString(); subProductCode = dtSubOrder.Tables[0].Rows[0]["product_code"].ToString(); subProductName = dtSubOrder.Tables[0].Rows[0]["product_name"].ToString(); - subQuntity = dtSubOrder.Tables[0].Rows[0]["quantity_split"].ToString(); + subQuntity = dtSubOrder.Tables[0].Rows[0]["quantity_split"].ToString();//子单数量 subUnit = dtSubOrder.Tables[0].Rows[0]["unit"].ToString(); - double rate = Convert.ToDouble(workCount) / Convert.ToDouble(orderQuntity); + double rate = Convert.ToDouble(workCount) / Convert.ToDouble(orderQuntity);//workCount是报工数量,orderQuntity是母单数量 double subOrderQty = 0; LogHelper.instance.log.Info("rate>>>" + rate); //根据base_product_attach表里的报工比例,计算子单数量,又取消了 @@ -873,7 +878,7 @@ VALUES int ret = Utils.netClientDBHelper.executeUpdate(sql); return ret > 0 ? true : false; } - public bool ChangeShiftsInfo(string deviceCode ,string data,string shift) + public bool ChangeShiftsInfo(string deviceCode, string data, string shift) { // string sql = $@"UPDATE mes_changeshift_info SET last_update=GetDate( ) WHERE device_code='{deviceCode}' AND CONVERT(VARCHAR, create_time, 23) = '{data}' AND shift_code='{shift}';"; @@ -1171,7 +1176,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; { } - for(int i = reportList.Count; i < 6; i++) + for (int i = reportList.Count; i < 6; i++) { reportList.Add(new report()); } @@ -1180,7 +1185,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; public int EditReport(report report) { - string sql= $@"update [dbo].[report] set team='{report.team}',OpenLineCheckBox='{report.OpenLineCheckBox}',ReplaceLineCheckBox='{report.ReplaceLineCheckBox}',unqualified='{report.unqualified}',clear='{report.clear}',residue='{report.residue}',lineClear='{report.lineClear}',UserKnow='{report.UserKnow}',qualified='{report.qualified}',equipStatus='{report.equipStatus}',StampCorrect='{report.StampCorrect}',isClear='{report.isClear}',positionCorrect='{report.positionCorrect}',isLineClear='{report.isLineClear}',create_time=GETDATE() where Id='{report.Id}'"; + string sql = $@"update [dbo].[report] set team='{report.team}',OpenLineCheckBox='{report.OpenLineCheckBox}',ReplaceLineCheckBox='{report.ReplaceLineCheckBox}',unqualified='{report.unqualified}',clear='{report.clear}',residue='{report.residue}',lineClear='{report.lineClear}',UserKnow='{report.UserKnow}',qualified='{report.qualified}',equipStatus='{report.equipStatus}',StampCorrect='{report.StampCorrect}',isClear='{report.isClear}',positionCorrect='{report.positionCorrect}',isLineClear='{report.isLineClear}',create_time=GETDATE() where Id='{report.Id}'"; return Utils.netClientDBHelper.executeUpdate(sql); } @@ -1189,5 +1194,20 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; string sql = $@"insert into [dbo].[report] (Id,team,OpenLineCheckBox,ReplaceLineCheckBox,unqualified,clear,residue,lineClear,UserKnow,qualified,equipStatus,StampCorrect,isClear,positionCorrect,isLineClear,create_time) values ('{report.Id}','{report.team}','{report.OpenLineCheckBox}','{report.ReplaceLineCheckBox}','{report.unqualified}','{report.clear}','{report.residue}','{report.lineClear}','{report.UserKnow}','{report.qualified}','{report.equipStatus}','{report.StampCorrect}','{report.isClear}','{report.positionCorrect}','{report.isLineClear}',GETDATE())"; return Utils.netClientDBHelper.executeUpdate(sql); } + + public bool GetProOrderWorkOrder(string workorderId) + { + string sql = "select del_flag from pro_order_workorder where workorder_id = '" + workorderId + "'"; + DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); + if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) + { + object value = dtset.Tables[0].Rows[0]["del_flag"]; + if (value != null && value.ToString() == "0") + { + return true; + } + } + return false; + } } } diff --git a/shangjian/XGLFinishPro/LoginPage.xaml.cs b/shangjian/XGLFinishPro/LoginPage.xaml.cs index 7cde771..c165123 100644 --- a/shangjian/XGLFinishPro/LoginPage.xaml.cs +++ b/shangjian/XGLFinishPro/LoginPage.xaml.cs @@ -44,7 +44,7 @@ namespace XGLFinishPro //this.Hide(); //Main mainWindow = new Main(); //mainWindow.Show(); - //InitVersion(); + InitVersion(); //InitTeamInfo(); InitShiftInfo(); } diff --git a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml index eb87827..a4ac785 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml +++ b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml @@ -678,7 +678,7 @@ Background="#F2F3F5"