diff --git a/shangjian/XGL.Data/DBService/FormingMachineService.cs b/shangjian/XGL.Data/DBService/FormingMachineService.cs index 2018d53..2cef18e 100644 --- a/shangjian/XGL.Data/DBService/FormingMachineService.cs +++ b/shangjian/XGL.Data/DBService/FormingMachineService.cs @@ -1222,7 +1222,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; string date = DateTime.Parse(workDate).ToString("yyyy-MM-dd"); string sql = $@"select workorder_id,product_name,product_code from pro_order_workorder - where prod_line_code like '%{deviceCode}%' and product_date='{date}' and parent_order=0"; + where prod_line_code like '%{deviceCode}%' and product_date='{date}' and parent_order='0' order by parent_order"; //string sql = $@"select workorder_id,product_name // from pro_order_workorder // where prod_line_code like '%{deviceCode}% and status='w2''"; @@ -1234,6 +1234,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; return null; } + public DataTable GetProOrderWorkorder(string id) { string sql = $@"select workorder_id,product_name,product_code @@ -1457,7 +1458,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; - return new MesTableSelf() + MesTableSelf mesTableSelf = new MesTableSelf() { id = dr["id"].ToString(), line_code = dr["line_code"].ToString(), @@ -1475,6 +1476,8 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; del_flag = dr["del_flag"].ToString(), report_name = dr["report_name"].ToString(), }; + mesTableSelf.IsFinal = dr["is_final"].ToString() == "1"; + return mesTableSelf; } return null; } @@ -1544,7 +1547,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; public MesTableSelfDetialModel GetMesTableSelfDetialById(string id) { - string sql = $@"select check_result,check_time_s,check_time_e from [dbo].[mes_table_self_detial] where id='{id}'"; + string sql = $@"select check_result,check_time_s,check_time_e,is_final from [dbo].[mes_table_self_detial] where id='{id}'"; DataSet ds = Utils.netClientDBHelper.getDataSet(sql); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { @@ -1558,9 +1561,9 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; return null; } - public void UpdateMesTableSelf(string id, string text, string text1) + public void UpdateMesTableSelf(string id, string text, string text1,string isFinal) { - string sql = $@"update [dbo].[mes_table_self] set bz='{text}',create_by='{text1}' where id='{id}'"; + string sql = $@"update [dbo].[mes_table_self] set bz='{text}',create_by='{text1}',is_final='{isFinal}' where id='{id}'"; Utils.netClientDBHelper.executeUpdate(sql); } @@ -1585,6 +1588,19 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC"; values ('{Guid.NewGuid().ToString().Substring(0, 32)}','{workorder_code}','{workorder_code_sap}','{product_name}','{product_code}','{childprocess_code}','{childprocess_name}','{user_name}','{nick_name}',GetDate(),'{deviceCode}','{post}',{kk},'{gs}','{remark}','{workDate}','{attr1}','f')"; return Utils.netClientDBHelper.executeUpdate(sql); } + + public string GetProOrderWorkorderBatchStatusById(string workorderId,string batch_code) + { + string sql = $@"select qc_status from [dbo].[pro_order_workorder_batch] where workorder_id='{workorderId}' and batch_code='{batch_code}' and del_flag='0'"; + DataSet ds = Utils.netClientDBHelper.getDataSet(sql); + if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) + { + return ds.Tables[0].Rows[0]["qc_status"].ToString(); + }else + { + return ""; + } + } } public class MesTableSelfDetialModel { diff --git a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs index c3133f7..b6c601a 100644 --- a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs +++ b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs @@ -698,11 +698,37 @@ select a.TrayCode,a.ProductBarNo,a.carcode,a.createtime,a.lineno,b.HadNumber //left join (SELECT sum(quantity_feedback) as batchQty,workorder_code,batch FROM [dbo].[mes_report_work] where del_flag = 0 GROUP BY workorder_code,batch) qty on qty.workorder_code = workorder.workorder_code and batch.batch_code = qty.batch //where 1=1 and batch.del_flag = 0 and workorder.del_flag = 0 and // workorder.parent_order ='0' and CONVERT(VARCHAR(10), workorder.product_date , 120)= CONVERT(VARCHAR(10), '{date}' , 120) and workorder.prod_line_code like '%{deviceCode}%' order by sort_no,batch_code"; - string sql = $"WITH LatestCheck AS (\r\n SELECT \r\n *,\r\n ROW_NUMBER() OVER (PARTITION BY order_no, income_batch_no ORDER BY create_time DESC) AS rn\r\n FROM \r\n qc_check_task\r\n WHERE \r\n check_type = 'checkTypeCPPC' \r\n AND del_flag = 0\r\n)\r\nSELECT \r\n workorder.factory_code,\r\n workorder.product_date AS plan_time,\r\n workorder.workorder_id,\r\n workorder.workorder_code,\r\n product_code,\r\n product_name,\r\n product_spc,\r\n shifts.shift_desc,\r\n prod_line_code,\r\n workorder.status,\r\n route_code,\r\n quantity_split,\r\n workorder.unit,\r\n workorder.shift_id,\r\n batch.batch_code,\r\n batch.batch_quantity,\r\n sort_no,\r\n workorder.parent_order,\r\n batch.qc_status,\r\n ISNULL(batch.qc_result, '') AS qc_result,\r\n batch.status AS batchStatus,\r\n workorder_code_sap,\r\n salary_flag,\r\n qty.batchQty,\r\n batch.batch_quantity - qty.batchQty AS diffQty,\r\n chack.create_time,\r\n chack.check_status\r\nFROM \r\n pro_order_workorder workorder WITH (NOLOCK)\r\nLEFT JOIN \r\n base_shifts_t shifts WITH (NOLOCK) ON workorder.shift_id = shifts.shift_id\r\nLEFT JOIN \r\n pro_order_workorder_batch batch WITH (NOLOCK) ON workorder.workorder_id = batch.workorder_id\r\nOUTER APPLY \r\n (SELECT TOP 1 * \r\n FROM LatestCheck \r\n WHERE rn = 1 \r\n AND workorder.workorder_code = LatestCheck.order_no \r\n AND batch.batch_code = LatestCheck.income_batch_no) chack\r\nLEFT JOIN \r\n (SELECT sum(quantity_feedback) AS batchQty, workorder_code, batch \r\n FROM [dbo].[mes_report_work] \r\n WHERE del_flag = 0 \r\n GROUP BY workorder_code, batch) qty \r\n ON qty.workorder_code = workorder.workorder_code AND batch.batch_code = qty.batch\r\nWHERE \r\n 1 = 1 \r\n AND batch.del_flag = 0 \r\n AND workorder.del_flag = 0 \r\n AND workorder.parent_order = '0' \r\n AND CONVERT(VARCHAR(10), workorder.product_date, 120) = CONVERT(VARCHAR(10), '{date}', 120) \r\n AND workorder.prod_line_code LIKE '%{deviceCode}%'\r\nORDER BY \r\n sort_no, batch_code;\r\n"; + + ////string sql = $"WITH LatestCheck AS (\r\n SELECT \r\n *,\r\n ROW_NUMBER() OVER (PARTITION BY order_no, income_batch_no ORDER BY create_time DESC) AS rn\r\n FROM \r\n qc_check_task\r\n WHERE \r\n check_type = 'checkTypeCPPC' \r\n AND del_flag = 0\r\n)\r\nSELECT \r\n workorder.factory_code,\r\n workorder.product_date AS plan_time,\r\n workorder.workorder_id,\r\n workorder.workorder_code,\r\n product_code,\r\n product_name,\r\n product_spc,\r\n shifts.shift_desc,\r\n prod_line_code,\r\n workorder.status,\r\n route_code,\r\n quantity_split,\r\n workorder.unit,\r\n workorder.shift_id,\r\n batch.batch_code,\r\n batch.batch_quantity,\r\n sort_no,\r\n workorder.parent_order,\r\n batch.qc_status,\r\n ISNULL(batch.qc_result, '') AS qc_result,\r\n batch.status AS batchStatus,\r\n workorder_code_sap,\r\n salary_flag,\r\n qty.batchQty,\r\n batch.batch_quantity - qty.batchQty AS diffQty,\r\n chack.create_time,\r\n chack.check_status\r\nFROM \r\n pro_order_workorder workorder WITH (NOLOCK)\r\nLEFT JOIN \r\n base_shifts_t shifts WITH (NOLOCK) ON workorder.shift_id = shifts.shift_id\r\nLEFT JOIN \r\n pro_order_workorder_batch batch WITH (NOLOCK) ON workorder.workorder_id = batch.workorder_id\r\nOUTER APPLY \r\n (SELECT TOP 1 * \r\n FROM LatestCheck \r\n WHERE rn = 1 \r\n AND workorder.workorder_code = LatestCheck.order_no \r\n AND batch.batch_code = LatestCheck.income_batch_no) chack\r\nLEFT JOIN \r\n (SELECT sum(quantity_feedback) AS batchQty, workorder_code, batch \r\n FROM [dbo].[mes_report_work] \r\n WHERE del_flag = 0 \r\n GROUP BY workorder_code, batch) qty \r\n ON qty.workorder_code = workorder.workorder_code AND batch.batch_code = qty.batch\r\nWHERE \r\n 1 = 1 \r\n AND batch.del_flag = 0 \r\n AND workorder.del_flag = 0 \r\n AND workorder.parent_order = '0' \r\n AND CONVERT(VARCHAR(10), workorder.product_date, 120) = CONVERT(VARCHAR(10), '{date}', 120) \r\n AND workorder.prod_line_code LIKE '%{deviceCode}%'\r\nORDER BY \r\n sort_no, batch_code;\r\n"; + string sql = $"WITH LatestCheck AS (\r\n SELECT \r\n *,\r\n ROW_NUMBER() OVER (PARTITION BY order_no, income_batch_no ORDER BY create_time DESC) AS rn\r\n FROM \r\n qc_check_task\r\n WHERE \r\n check_type = 'checkTypeCPPC' \r\n AND del_flag = 0\r\n)\r\nSELECT \r\n workorder.factory_code,\r\n workorder.product_date AS plan_time,\r\n workorder.workorder_id,\r\n workorder.workorder_code,\r\n product_code,\r\n product_name,\r\n product_spc,\r\n shifts.shift_desc,\r\n prod_line_code,\r\n workorder.status,\r\n route_code,\r\n quantity_split,\r\n workorder.unit,\r\n workorder.shift_id,\r\n batch.batch_code,\r\n batch.batch_quantity,\r\n sort_no,\r\n workorder.parent_order,\r\n batch.qc_status,\r\n ISNULL(batch.qc_result, '') AS qc_result,\r\n batch.status AS batchStatus,\r\n workorder_code_sap,\r\n salary_flag,\r\n qty.batchQty,\r\n batch.batch_quantity - qty.batchQty AS diffQty,\r\n chack.create_time,\r\n chack.check_status,CASE\r\n WHEN batch.attr1 = '1' THEN 'false'\r\n ELSE 'true'\r\n END AS IsEnabled,\r\n CASE\r\n WHEN batch.attr1 = '1' THEN '结束'\r\n ELSE '开始'\r\n END AS BtnTest ,\r\n batch.batch_id AS batchId \r\nFROM \r\n pro_order_workorder workorder WITH (NOLOCK)\r\nLEFT JOIN \r\n base_shifts_t shifts WITH (NOLOCK) ON workorder.shift_id = shifts.shift_id\r\nLEFT JOIN \r\n pro_order_workorder_batch batch WITH (NOLOCK) ON workorder.workorder_id = batch.workorder_id\r\nOUTER APPLY \r\n (SELECT TOP 1 * \r\n FROM LatestCheck \r\n WHERE rn = 1 \r\n AND workorder.workorder_code = LatestCheck.order_no \r\n AND batch.batch_code = LatestCheck.income_batch_no) chack\r\nLEFT JOIN \r\n (SELECT sum(quantity_feedback) AS batchQty, workorder_code, batch \r\n FROM [dbo].[mes_report_work] \r\n WHERE del_flag = 0 \r\n GROUP BY workorder_code, batch) qty \r\n ON qty.workorder_code = workorder.workorder_code AND batch.batch_code = qty.batch\r\nWHERE \r\n 1 = 1 \r\n AND batch.del_flag = 0 \r\n AND workorder.del_flag = 0 \r\n AND workorder.parent_order = '0' \r\n AND CONVERT(VARCHAR(10), workorder.product_date, 120) = CONVERT(VARCHAR(10), '2024-05-22', 120) \r\n AND workorder.prod_line_code LIKE '%XL01%'\r\nORDER BY \r\n sort_no, batch_code;\r\n"; DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) { - return dtset.Tables[0]; + DataTable dataTable = dtset.Tables[0]; + bool isStart = false; + foreach (DataRow dr in dataTable.Rows) + { + if (dr["BtnTest"].ToString() == "结束") + { + isStart = true; + break; + } + } + if (isStart) + { + foreach (DataRow dr in dataTable.Rows) + { + if (dr["BtnTest"].ToString() == "开始") + { + dr["IsEnabled"] = false; + } + else + { + dr["IsEnabled"] = true; + } + } + } + return dataTable; } return null; } @@ -805,20 +831,20 @@ 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, string credata, string attr2, string post,string attr3="") + 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 attr2, string post,string attr3="", decimal total = 0) { string sql = $@"INSERT INTO [dbo].[mes_unitprice_report] ( [id],[workorder_code], [workorder_code_sap], [product_name], [product_code], [user_name], [nick_name], [childprocess_code], [childprocess_name], [attr1], [attr2], [attr3], [create_by], [create_time], [update_by], - [update_time], [remark] ,[post],[line_code],[work_order_product_date] + [update_time], [remark] ,[post],[line_code],[work_order_product_date],[total] ) VALUES ( '{Common.GetUUID()}', '{workorderCode}','{sapWorkorderCode}', '{productName}', '{productCode}', N'{item.user_name}', N'{item.nick_name}', N'{childProcessCode}', N'{childProcessName}',' {number}', {attr2}, '{attr3}', '{LoginUser.UserName}', '{DateTime.Now.ToString("G")}', NULL, - NULL, NULL,'{post}','{deviceCode}','{credata} 00:00:00' );"; + NULL, NULL,'{post}','{deviceCode}','{credata} 00:00:00',{total} );"; return sql; } @@ -3617,7 +3643,13 @@ left join basedata_plcsetting f on a.PlcId5=f.Id return result; } - + public void UpdateProWorkOrderBatch(string batchId, string attr1) + { + string sql = $"update pro_order_workorder_batch set attr1='{attr1}' where batch_id='{batchId}'"; + Utils.netClientDBHelper.executeUpdate(sql); + } + + // /// // /// 获取物料bom列表 diff --git a/shangjian/XGL.Data/userDB.cs b/shangjian/XGL.Data/userDB.cs index 2fd154c..8f4467c 100644 --- a/shangjian/XGL.Data/userDB.cs +++ b/shangjian/XGL.Data/userDB.cs @@ -334,6 +334,7 @@ namespace XGL.Data LoginUser.End_Time = endTime; LoginUser.CurrDeviceIP = Common.GetLocationHostAddress(); } + issuccess = true; return issuccess;//lst.Count > 0 ? true : false; } diff --git a/shangjian/XGL.Model/report.cs b/shangjian/XGL.Model/report.cs index 8465613..9ef4475 100644 --- a/shangjian/XGL.Model/report.cs +++ b/shangjian/XGL.Model/report.cs @@ -168,5 +168,6 @@ namespace XGL.Models public string update_time { get; set; } public string factory_code { get; set; } public string del_flag { get; set; } + public bool IsFinal { get; set; } } } diff --git a/shangjian/XGLFinishPro/Tools/SerialHelper.cs b/shangjian/XGLFinishPro/Tools/SerialHelper.cs index 1edc41e..22d8cf6 100644 --- a/shangjian/XGLFinishPro/Tools/SerialHelper.cs +++ b/shangjian/XGLFinishPro/Tools/SerialHelper.cs @@ -132,7 +132,7 @@ namespace XGLFinishPro.Tools public void DOControl(DOName dOName, DOOnOff dOOnOff) { //ComOn(); - serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); + //serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); } /// diff --git a/shangjian/XGLFinishPro/Views/LanJu_Check_Report.xaml b/shangjian/XGLFinishPro/Views/LanJu_Check_Report.xaml index 527a553..92c7454 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_Check_Report.xaml +++ b/shangjian/XGLFinishPro/Views/LanJu_Check_Report.xaml @@ -97,6 +97,15 @@ + @@ -118,8 +127,9 @@