20260122 生产过程检

20260122
019188 4 months ago
parent 7aa3c17413
commit c6710400aa

@ -1833,7 +1833,136 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC";
}
return null;
}
public List<ProductProcessListData> GetProductProcessListCheckInfo(String recordId)
{
List<ProductProcessListData> list = new List<ProductProcessListData>();
string sql = $@" select td.record_id recordId,
td.project_id projectId,
td.material_batch material_batch,
td.project_no projectNo,
td.rule_name ruleName,
td.property_code propertyCode,
td.status,
td.create_by createBy,
td.create_time createTime,
td.update_by updateBy,
td.update_time updateTime,
td.belong_to belongTo
from qc_check_task_detail td
LEFT JOIN qc_check_task qct ON td.belong_to= qct.record_id
left join lanju_op_cloud.dbo.sys_dict_data dic on dic.dict_value = td.unit_code and dic.status ='0' and dic.dict_type = 'unit'
where td.belong_to = '{recordId}' and td.del_flag='0' and td.rule_name is not null
order by td.property_code desc, td.project_id";
/* string sql = $@"SELECT * from test_product_check_list where belongTo ='{recordId}'";*/
DataSet ds = Utils.netClientDBHelper.getDataSet(sql);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
list.Add(new ProductProcessListData()
{
recordId = dr["recordId"]?.ToString() ?? "",
projectId = dr["projectId"]?.ToString() ?? "",
projectNo = dr["projectNo"]?.ToString() ?? "",
ruleName = dr["ruleName"]?.ToString() ?? "",
propertyCode = dr["propertyCode"]?.ToString() ?? "",
status = dr["status"]?.ToString() ?? "",
material_batch = dr["material_batch"]?.ToString() ?? "",
});
}
}
return list;
}
//by 019188 加载生产过程检 2025-12-19
public List<ProductProcessData> GetProductProcessCheckInfo(string deviceCode)
{
List<ProductProcessData> list = new List<ProductProcessData>();
string sql = $@"SELECT qct.record_id,qct.check_no,qct.income_batch_no,qct.order_no,qct.material_code,qct.material_name,
qct.quality,qct.unit,qct.supplier_code,qct.supplier_name,qct.income_time,qct.check_loc,qct.check_status,
qct.check_man_code,qct.check_man_name,qct.check_time,qct.check_result,qct.bz,qct.remark_code,qct.status,qct.create_by,qct.create_time,
qct.update_by,qct.update_time,qct.check_type,qct.sample_quality,qct.noOk_quality,bpa.cpk_type,
sdd.dict_label cpkTypeName,q.type_code,q.check_name,SUBSTRING (pow.workorder_code_sap,4,12) workorderCodeSap
FROM qc_check_task qct
LEFT JOIN qc_check_type q ON q.id = qct.check_type
LEFT JOIN pro_order_workorder pow ON pow.workorder_code = qct.order_no
LEFT JOIN base_product_attached bpa ON concat ( '0000000', bpa.product_code ) = qct.material_code
LEFT JOIN lanju_op_cloud.dbo.sys_dict_data sdd ON sdd.dict_type = 'qms_category'
AND sdd.dict_value = bpa.cpk_type
WHERE qct.check_type = 'checkTypeSCXJ' and qct.check_loc ='{deviceCode}' and CONVERT(date, qct.create_time) = CONVERT(date, GETDATE())";
/* string sql = $@"SELECT * from test_product_check where check_loc ='{deviceCode}'";*/
DataSet ds = Utils.netClientDBHelper.getDataSet(sql);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
list.Add(new ProductProcessData()
{
check_no = dr["check_no"].ToString(),//任务编号
workorderCodeSap = dr["workorderCodeSap"].ToString(),//订单号
record_id = dr["record_id"].ToString(),
order_no = dr["order_no"].ToString(),//工单号
material_code = dr["material_code"].ToString(),//产品号
material_name = dr["material_name"].ToString(),//产品名称
cpk_type = dr["cpk_type"].ToString(),//CPK品类
quality = dr["quality"].ToString(),//数量
sample_quality = dr["sample_quality"].ToString(),//抽样数量
noOk_quality = dr["noOk_quality"].ToString(),//不合格数量
unit = dr["unit"].ToString(),//单位
supplier_name = dr["supplier_name"].ToString(),
income_time = dr["income_time"].ToString(),
check_loc = dr["check_loc"].ToString(),
check_status = dr["check_status"].ToString(),
check_result = dr["check_result"].ToString(),
bz = dr["bz"].ToString(),
remark_code = dr["remark_code"].ToString(),
});
}
}
return list;
}
public int UpdateProductProcessCheckTask(ProductProcessData model, string finalResult, string defectCategory, string remark, string isFinal)
{
string formattedDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
//测试
// string testsql = $@"update [dbo].[test_product_check] set update_time= '{formattedDateTime}',check_result='{finalResult}',remark_code='{defectCategory}',bz='{remark}' where record_id='{model.record_id}'";
//正式
string sql = $@"update [dbo].[qc_check_task] set update_by='{LoginUser.UserName}',update_time= '{formattedDateTime}',check_result='{finalResult}',remark_code='{defectCategory}',bz='{remark}' where record_id='{model.record_id}'";
if (isFinal == "1")//if isFinal = "1"(最终提交按钮) check_status="1" else 不处理check_status
{
sql = $@"update [dbo].[qc_check_task] set update_by='{LoginUser.UserName}',update_time= '{formattedDateTime}',check_result='{finalResult}',remark_code='{defectCategory}',bz='{remark}' ,check_status='1' where record_id='{model.record_id}'";
}
//正式
return Utils.netClientDBHelper.executeUpdate(sql);
}
public int UpdateProductProcessCheckTaskDetial(List<ProductProcessListData> model, string belongto)
{
string formattedDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
int totalAffectedRows = 0;
//正式 qc_check_task 结果check_result 缺陷分类remark_code 备注bz
foreach (var item in model)
{
//测试
// string testsql = $@"update [dbo].[test_product_check_list] set updatetime= '{formattedDateTime}',status='{item.status}',material_batch='{item.material_batch}' where recordId='{item.recordId}' and belongto = '{belongto}'";
string sql = $@"update [dbo].[qc_check_task_detail] set update_by='{LoginUser.UserName}',material_batch = '{item.material_batch}',update_time= '{formattedDateTime}',status='{item.status}' where record_id='{item.recordId}' and belong_to = '{belongto}'";
totalAffectedRows += Utils.netClientDBHelper.executeUpdate(sql);
}
return totalAffectedRows;
}
}
}
public class MesTableSelfDetialModel
{
public string id { get; set; }
@ -1867,4 +1996,3 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC";
public int table_line { get; set; }
public int index { get; set; }
}
}

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,176 @@
<Window x:Class="XGLFinishPro.Views.Lanju_Product_Process_Check_Report_List"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:XGLFinishPro.Views"
mc:Ignorable="d"
WindowState="Maximized"
WindowStyle="None"
Loaded="Window_Loaded"
Height="1000" Width="1900">
<!--Loaded="Window_Loaded"-->
<Window.Resources>
<ResourceDictionary>
<Style BasedOn="{x:Null}" TargetType="ComboBox">
<Setter Property="Width" Value="50" />
<Setter Property="Height" Value="30" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid x:Name="TogGrid">
<ToggleButton
x:Name="ToggleButton"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Click="ToggleButton_Click"
ClickMode="Press"
Focusable="false"
FontSize="{TemplateBinding FontSize}">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ToggleButton>
<Popup
x:Name="Popup"
AllowsTransparency="True"
Focusable="False"
IsOpen="{TemplateBinding IsDropDownOpen}"
Placement="Bottom"
PopupAnimation="Slide">
<Grid
x:Name="DropDown"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="200"
SnapsToDevicePixels="True">
<Border
x:Name="DropDownBorder"
Background="White"
BorderBrush="Gray"
BorderThickness="1" />
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="true">
<Setter TargetName="ToggleButton" Property="Background" Value="Gray" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="ToggleButton" Property="Background" Value="Gray" />
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="Gray" />
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</Trigger>
<!-- 新增的Trigger用于在选择完成后将按钮颜色变回原来的颜色 -->
<Trigger Property="IsDropDownOpen" Value="false">
<Setter TargetName="ToggleButton" Property="Background" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="25" />
<Setter Property="Margin" Value="10,0,8,0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style x:Key="CheckBoxStyle" TargetType="{x:Type CheckBox}">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.5" ScaleY="1.5" />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="317*" />
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="1047*" />
<ColumnDefinition Width="528*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="2"
VerticalAlignment="Bottom"
Content="生产过程检列表"
FontSize="40"
FontWeight="Bold" Margin="363,0,359,4" Height="61" />
<StackPanel
Grid.Column="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal" Margin="203,0,79,0" Height="70" Width="246">
<Button
Width="100"
Height="50"
Margin="10"
Background="#2B7EE6"
Click="Close_Click"
Content="关闭"
FontSize="20"
Foreground="White" />
<Button
Width="100"
Height="50"
Margin="10"
Background="#2B7EE6"
Click="Refresh_Click"
Content="刷新"
FontSize="20"
Foreground="White" />
</StackPanel>
</Grid>
<Grid
x:Name="MainGrid"
Grid.Row="1"
Margin="0,5,20,5" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="449*"/>
</Grid.ColumnDefinitions>
</Grid>
</Grid>
</Window>

@ -0,0 +1,684 @@
using CentralControl.App_Code;
using CommonFunc;
using CommonFunc.Tools;
using HandyControl.Tools.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using XGL.Data.DBService;
using XGL.Models;
namespace XGLFinishPro.Views
{
public partial class Lanju_Product_Process_Check_Report_List : Window
{
private string belong_to = string.Empty;
private List<MesTableSelfDetialModel> data;
private ProductProcessData _taskData;
FormingMachineService dbService = new FormingMachineService();
private static double LineWidth = 30;
private static double LineHeight = 30;
private static double MainLineHeight = 50;
string deviceCode = Utils.GetAppSetting("DeviceCode");//获取产线
string productName = string.Empty;
private string shiftCode = "";
private string shiftName = "";
private string product_code = string.Empty;
private bool isUpdate = false;
private string LineStr = "";
private readonly List<string> _DefectClassification = new List<string>() { "", "", "" };
public Lanju_Product_Process_Check_Report_List()
{
InitializeComponent(); //用于加载和初始化 XAML 文件, // 必须在构造函数中调用
this.date = LoginUser.WorkDate;
shiftCode = LoginUser.ShiftCode;//班次
/* 2 夜班 5 白班*/
shiftName = dbService.GetShiftById(shiftCode);
}
private List<ConveterData> list = new List<ConveterData>();
private string date;
private MesTableSelf mesTableSelf;
private List<MesTableSelfDetialModel> mesTableSelfDetialList;
public List<BaseDictData> DictDatas { get; private set; }
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//this.NickName.Text = LoginUser.UserName;
//包装线05
LineStr = dbService.GetBaseEquipment(Utils.GetAppSetting("DeviceCode"));
LoadData();
}
//加载数据
private void LoadData(bool addLine = false)
{
isUpdate = true;
list.Clear();
this.MainGrid.Children.Clear();
this.MainGrid.RowDefinitions.Clear();
this.MainGrid.ColumnDefinitions.Clear();
DictDatas = dbService.GetConversionReportType();
var baseDictDatas = dbService.GetProductProcessCheckInfo(deviceCode).ToList();
if (baseDictDatas == null || baseDictDatas.Count == 0)
{
Console.WriteLine("[Error] 未获取到产品过程检信息。");
LogHelper.instance.log.Error("[Error] 未获取到产品过程检信息。");
}
// 创建列表标题行
CreateGridHeader();
// 遍历数据并添加到Grid中
for (int i = 0; i < baseDictDatas.Count; i++)
{
var data = baseDictDatas[i];
AddDataRowToGrid(data, i + 1); // i+1是因为第0行是标题
}
}
// 创建表格标题行
private void CreateGridHeader()
{
// 创建列定义共12列根据查询字段
for (int i = 0; i < 12; i++)
{
this.MainGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
// 添加标题行
this.MainGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
// 创建标题单元格 - 根据查询字段定义表头
string[] headers = new string[]
{
"任务编号", "订单号", "工单号", "产品号", "产品名称", "CPK品类",
"数量", "抽样数量", "不合格数量", "单位", "车间名称", "检验时间", "检验节点", "检验状态"
};
for (int col = 0; col < headers.Length; col++)
{
Border border = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = new Thickness(1),
Background = Brushes.LightGray,
Padding = new Thickness(5)
};
TextBlock textBlock = new TextBlock
{
Text = headers[col],
FontWeight = FontWeights.Bold,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
border.Child = textBlock;
Grid.SetRow(border, 0);
Grid.SetColumn(border, col);
this.MainGrid.Children.Add(border);
}
}
// 添加数据行到Grid
private void AddDataRowToGrid(ProductProcessData data, int rowIndex)
{
// 为数据行添加行定义
this.MainGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
// 第1列任务编号 (check_no) - 添加点击事件
AddClickableCell(data.check_no ?? "", rowIndex, 0, data);
// 第2列订单号 (workorderCodeSap)
AddCell(data.workorderCodeSap ?? "", rowIndex, 1);
// 第3列工单号 (order_no)
AddCell(data.order_no ?? "", rowIndex, 2);
// 第4列产品号 (material_code)
AddCell(data.material_code ?? "", rowIndex, 3);
// 第5列产品名称 (material_name)
AddCell(data.material_name ?? "", rowIndex, 4);
// 第6列CPK品类 (cpk_type)
AddCell(data.cpk_type ?? "", rowIndex, 5);
// 第7列数量 (quality)
AddCell(data.quality ?? "0", rowIndex, 6);
// 第8列抽样数量 (sample_quality)
AddCell(data.sample_quality ?? "0", rowIndex, 7);
// 第9列不合格数量 (noOk_quality)
AddCell(data.noOk_quality ?? "0", rowIndex, 8);
// 第10列单位 (unit)
AddCell(data.unit ?? "", rowIndex, 9);
// 第11列供应商 (supplier_name)
AddCell(data.supplier_name ?? "", rowIndex, 10);
// 第12列检验时间 (income_time)
AddCell(data.income_time ?? "", rowIndex, 11);
// 第13列检验节点 (check_name)
AddCell(data.check_name ?? "", rowIndex, 12);
// 第14列检验状态 (check_status)
string statusText = "";
switch (data.check_status)
{
case "0":
statusText = "待检验";
break;
case "1":
statusText = "已检验";
break;
default:
statusText = data.check_status ?? "未知";
break;
}
AddCell(statusText, rowIndex, 13);
}
// 添加可点击的单元格(用于任务编号)
private void AddClickableCell(string content, int row, int column, ProductProcessData data)
{
Border border = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = new Thickness(0.5),
Padding = new Thickness(5),
Cursor = Cursors.Hand
};
border.Background = Brushes.White;
TextBlock textBlock = new TextBlock
{
Text = content,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
TextWrapping = TextWrapping.Wrap,
TextDecorations = TextDecorations.Underline,
Foreground = Brushes.Blue
};
border.Child = textBlock;
Grid.SetRow(border, row);
Grid.SetColumn(border, column);
// 添加点击事件
border.MouseLeftButtonDown += (sender, e) =>
{
OnTaskNumberClicked(data);
};
// 添加鼠标悬停效果
border.MouseEnter += (sender, e) =>
{
border.Background = Brushes.LightYellow;
};
border.MouseLeave += (sender, e) =>
{
border.Background = Brushes.White;
};
this.MainGrid.Children.Add(border);
}
private void OnTaskNumberClicked(ProductProcessData data)
{
try
{
Console.WriteLine($"打开任务详情窗口: {data.check_no}");
LogHelper.instance.log.Info($"打开任务详情窗口,任务编号: {data.check_no}");
// 创建并显示任务详情窗口
Lanju_Product_Process_Check_Task_Detail detailWindow = new Lanju_Product_Process_Check_Task_Detail(data);
// 设置为模态窗口
detailWindow.ShowDialog();
}
catch (Exception ex)
{
Console.WriteLine($"[Error] 打开任务详情窗口时出错: {ex.Message}");
LogHelper.instance.log.Error($"[Error] 打开任务详情窗口时出错: {ex.Message}");
// 显示错误提示
MessageBox.Show($"打开任务详情窗口时出错:\n{ex.Message}", "错误",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void AddCell(string content, int row, int column)
{
Border border = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = new Thickness(0.5),
Padding = new Thickness(5)
};
TextBlock textBlock = new TextBlock
{
Text = content,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
TextWrapping = TextWrapping.Wrap
};
// 根据行号设置背景色(奇偶行不同颜色)
border.Background = Brushes.White;
border.Child = textBlock;
Grid.SetRow(border, row);
Grid.SetColumn(border, column);
this.MainGrid.Children.Add(border);
}
private void MakeHeaderData()
{
#region 画线
for (int i = 0; i < 11; i++)
{
double width = 1.0;
if (i == 0)
{
width = 1.2;
}
if (i == 1)
{
width = 1.5;
}
if (i == 2)
{
width = 6.0;
}
if (i == 3)
{
width = 0.8;
}
if (i == 4)
{
width = 0.8;
}
this.MainGrid.ColumnDefinitions.Add(new ColumnDefinition()
{
Width = new GridLength(width, GridUnitType.Star)
});
}
#region 画表格竖线
for (int i = 0; i < 11; i++)
{
// ✅ 跳过第3行索引2第6~11列索引6~11之间的竖线
if ((i < 4 || i % 2 == 1) && !(i >= 6 && i <= 11))
{
Line line = new Line()
{
Name = $"YLine{i}",
Stroke = Brushes.Black,
StrokeThickness = 1,
Y1 = 1,
Stretch = Stretch.Fill,
HorizontalAlignment = HorizontalAlignment.Left,
};
Grid.SetColumn(line, i);
Grid.SetRow(line, 0);
if (i >= 4 && i % 2 == 0)
{
Grid.SetRowSpan(line, 1);
}
else
{
Grid.SetRowSpan(line, 99);
}
this.MainGrid.Children.Add(line);
}
}
// 添加最后一列右边的边界线
Line boundaryLine = new Line()
{
Name = "BoundaryLine",
Stroke = Brushes.Black,
StrokeThickness = 1,
Y1 = 1,
Stretch = Stretch.Fill,
HorizontalAlignment = HorizontalAlignment.Right, // 让它靠右对齐
};
// 设置它在第 11 列(超出当前最大列)
Grid.SetColumn(boundaryLine, 11);
Grid.SetRow(boundaryLine, 0);
Grid.SetRowSpan(boundaryLine, 99); // 让它跨 99 行,确保足够高
this.MainGrid.Children.Add(boundaryLine);
#endregion
#region 画表格横线
for (int i = 0; i <= 2; i++)
{
this.MainGrid.RowDefinitions.Add(new RowDefinition()
{
Height = new GridLength(1, GridUnitType.Star)
});
// 跳过第 1 行,不画线
if (i == 1)
continue;
Line line = new Line()
{
Name = $"XLine{i}",
Stroke = Brushes.Black,
StrokeThickness = 1,
X1 = 1,
Stretch = Stretch.Fill,
VerticalAlignment = VerticalAlignment.Top,
};
Grid.SetColumn(line, 0);
Grid.SetRow(line, i);
Grid.SetColumnSpan(line, 11);
this.MainGrid.Children.Add(line);
// 仅在最后一行i == 2添加底部边界线
if (i == 2)
{
Line line1 = new Line()
{
Stroke = Brushes.Black,
StrokeThickness = 1,
X1 = 1,
Stretch = Stretch.Fill,
VerticalAlignment = VerticalAlignment.Bottom,
};
Grid.SetColumn(line1, 0);
Grid.SetRow(line1, i);
Grid.SetColumnSpan(line1, 15);
this.MainGrid.Children.Add(line1);
}
}
#endregion
#endregion
#region 画表头
TextBlock textBlock = new TextBlock()
{
Text = "产线名称",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 0);
Grid.SetRow(textBlock, 0);
Grid.SetRowSpan(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
textBlock = new TextBlock()
{
Text = "序号",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 0);
Grid.SetRow(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
textBlock = new TextBlock()
{
Text = "检查项目",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 1);
Grid.SetRow(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
textBlock = new TextBlock()
{
Text = LineStr,
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 1);
Grid.SetRow(textBlock, 0);
Grid.SetRowSpan(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
StackPanel stackPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
};
TextBlock textBlock2 = new TextBlock()
{
Text = "日期:",
FontSize = 18,
FontWeight = FontWeights.Bold,
};
stackPanel.Children.Add(textBlock2);
var datePicker = new DatePicker()
{
FontSize = 18,
FontWeight = FontWeights.Bold,
SelectedDate = DateTime.Parse(date)
};
datePicker.SelectedDateChanged += (s, e) =>
{
date = ((DatePicker)s).SelectedDate.Value.ToString("yyyy-MM-dd");
LoadData();
};
stackPanel.Children.Add(datePicker);
// ✅ 让 StackPanel 跨两行
Grid.SetColumn(stackPanel, 2);
Grid.SetRow(stackPanel, 0);
Grid.SetRowSpan(stackPanel, 2); // ✅ 这里改成对 stackPanel 设置 RowSpan
this.MainGrid.Children.Add(stackPanel);
textBlock = new TextBlock()
{
Text = "班次",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 3);
Grid.SetRow(textBlock, 0);
Grid.SetRowSpan(textBlock, 2);
Grid.SetColumnSpan(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
int index = 1;
// 假设这是返回的集合
textBlock = new TextBlock()
{
Text = shiftName,
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 5);
Grid.SetRow(textBlock, 0);
Grid.SetRowSpan(textBlock, 2);
Grid.SetColumnSpan(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
textBlock = new TextBlock()
{
Text = "点检人",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 7);
Grid.SetRow(textBlock, 0);
Grid.SetRowSpan(textBlock, 2);
Grid.SetColumnSpan(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
// 在"点检人"左侧(列索引 7添加竖线
Line lineLeft = new Line()
{
Stroke = Brushes.Black, // 你可以改成 Black
StrokeThickness = 1, // 线条加粗
Y1 = 1,
Stretch = Stretch.Fill,
HorizontalAlignment = HorizontalAlignment.Left,
};
Grid.SetColumn(lineLeft, 7);
Grid.SetRow(lineLeft, 0);
Grid.SetRowSpan(lineLeft, 2);
this.MainGrid.Children.Add(lineLeft);
// 在"点检人"右侧(列索引 8添加竖线
Line lineRight = new Line()
{
Stroke = Brushes.Black, // 你可以改成 Black
StrokeThickness = 1, // 线条加粗
Y1 = 1,
Stretch = Stretch.Fill,
HorizontalAlignment = HorizontalAlignment.Right,
};
Grid.SetColumn(lineRight, 8);
Grid.SetRow(lineRight, 0);
Grid.SetRowSpan(lineRight, 2);
this.MainGrid.Children.Add(lineRight);
textBlock = new TextBlock()
{
Text = LoginUser.UserName,
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 9);
Grid.SetRow(textBlock, 0);
Grid.SetRowSpan(textBlock, 2);
Grid.SetColumnSpan(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
textBlock = new TextBlock()
{
Text = "检查标准",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, 2);
Grid.SetRow(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
for (int i = 3; i < 4; i++)
{
if (i % 2 == 1)
{
textBlock = new TextBlock()
{
Text = "检查结果",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(textBlock, i);
Grid.SetRow(textBlock, 2);
Grid.SetColumnSpan(textBlock, 2);
this.MainGrid.Children.Add(textBlock);
}
}
textBlock = new TextBlock()
{
Text = "存在问题",
FontSize = 18,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
// 设置到第3行索引2
Grid.SetRow(textBlock, 2);
// 从第6列索引5开始
Grid.SetColumn(textBlock, 5);
// **合并6到11列索引5到10共6列**
Grid.SetColumnSpan(textBlock, 6);
this.MainGrid.Children.Add(textBlock);
#endregion
}
private void ToggleButton_Click(object sender, RoutedEventArgs e)
{
if (((ToggleButton)sender).TemplatedParent is ComboBox comboBox)
{
comboBox.IsDropDownOpen = !comboBox.IsDropDownOpen;
var data = comboBox.Tag as ProductProcessData;
if (data != null)
{
var detailWindow = new Lanju_Product_Process_Check_Task_Detail(data);
detailWindow.ShowDialog();
}
}
}
//刷新
private void Refresh_Click(object sender, RoutedEventArgs e)
{
LoadData();
}
//关闭
private void Close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

@ -0,0 +1,192 @@
<Window x:Class="XGLFinishPro.Views.Lanju_Product_Process_Check_Task_Detail"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="检验项目" Height="600" Width="900"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 顶部:检验判定区域 -->
<Border Grid.Row="0" BorderBrush="LightGray" BorderThickness="0,0,0,1" Padding="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="最终判定结果" VerticalAlignment="Center"/>
<!--<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="10,0" >
<RadioButton x:Name="RadioQualified" Content="合格" GroupName="Result" VerticalAlignment="Center" Margin="0,0,10,0"/>
<RadioButton x:Name="RadioUnqualified" Content="不合格" GroupName="Result" VerticalAlignment="Center"/>
</StackPanel>-->
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="10,0">
<RadioButton x:Name="RadioQualified"
Content="合格"
GroupName="Result"
VerticalAlignment="Center"
Margin="0,0,10,0"
IsChecked="{Binding IsQualified, Mode=TwoWay}"/>
<RadioButton x:Name="RadioUnqualified"
Content="不合格"
GroupName="Result"
VerticalAlignment="Center"
IsChecked="{Binding IsUnqualified, Mode=TwoWay}"/>
</StackPanel>
<TextBlock Grid.Column="2" Text="缺陷分类" VerticalAlignment="Center" Margin="20,0,10,0"/>
<!-- 修改后的ComboBox绑定到DefectClasses -->
<ComboBox x:Name="CmbDefectCategory"
Grid.Column="3"
VerticalAlignment="Center"
ItemsSource="{Binding DefectClasses}"
SelectedItem="{Binding SelectedDefect, Mode=TwoWay}"
Width="200"
SelectionChanged="CmbDefectCategory_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding className}" Padding="5,2"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Column="4" Text="备注描述" VerticalAlignment="Center" Margin="20,0,10,0"/>
<TextBox Grid.Column="5"
x:Name="TxtRemark"
VerticalAlignment="Center"
Text="{Binding RemarkText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Border>
<!-- 中间:检验项目列表 -->
<Border Grid.Row="1" BorderBrush="LightGray" BorderThickness="0,1,0,1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="117*"/>
<ColumnDefinition Width="106*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 表头 -->
<Border Grid.Row="0" Background="LightGray" BorderBrush="Gray" BorderThickness="0,0,0,1" Grid.ColumnSpan="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="400"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="检测规则编码" Padding="5" FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="检验规则名称" Padding="5" FontWeight="Bold"/>
<TextBlock Grid.Column="2" Text="检测结果" Padding="5" FontWeight="Bold"/>
<TextBlock Grid.Column="3" Text="包材批次" Padding="5" FontWeight="Bold"/>
</Grid>
</Border>
<!-- 列表内容区域(使用 ItemsControl -->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Grid.ColumnSpan="2">
<ItemsControl x:Name="ItemsList">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="LightGray" BorderThickness="0,0,0,1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="400"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding projectNo}" Padding="5" VerticalAlignment="Center"/>
<TextBlock Grid.Column="1"
Text="{Binding ruleName}"
Padding="5"
VerticalAlignment="Center"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding ruleName}"/>
<!-- 检测结果下拉框固定Y/N选项 -->
<ComboBox Grid.Column="2"
SelectedValue="{Binding status}"
SelectedValuePath="Content"
Padding="5"
VerticalAlignment="Center">
<ComboBoxItem Content="Y"/>
<ComboBoxItem Content="N"/>
</ComboBox>
<!-- 包材批次改为可输入的TextBox -->
<TextBox Grid.Column="3"
Text="{Binding material_batch, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Padding="5"
VerticalAlignment="Center"
VerticalContentAlignment="Center"/>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Border>
<!-- 底部:分页和按钮 -->
<Border Grid.Row="2" Padding="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- 右侧按钮区域 -->
<StackPanel Grid.Column="1"
Orientation="Horizontal"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<Button Content="保存" x:Name="btnSave"
Width="80" Height="30"
Background="#2B7EE6" Foreground="White"
Click="BtnSubmit_Click"
Margin="0,0,10,0"/>
<Button Content="最终提交" x:Name="btnSubmit"
Width="80" Height="30"
Background="Red" Foreground="White"
Click="BtnSubmit_Click"
Margin="0,0,10,0"/>
<Button Content="取消" x:Name="btnCancel"
Width="80" Height="30"
Background="#2B7EE6" Foreground="White"
Click="BtnCancel_Click"/>
</StackPanel>
</Grid>
</Border>
</Grid>
</Window>

@ -0,0 +1,529 @@
using CommonFunc;
using CommonFunc.Tools;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using XGL.Data.DBService;
using XGL.Models;
using XGL.Models.Model.OrderPrepare;
namespace XGLFinishPro.Views
{
/// <summary>
/// Lanju_Product_Process_Check_Task_Detail.xaml 的交互逻辑
/// </summary>
public partial class Lanju_Product_Process_Check_Task_Detail : Window, INotifyPropertyChanged
{
// ProductProcessData.record_id = ProductProcessListData.belongTo
private ProductProcessData _taskData;
FormingMachineService dbService = new FormingMachineService();
private const string DEFECT_API_URL = "http://192.168.58.29:81/dev-api/open/openInterface/getClassInfoListByCheckType?checkType=checkTypeSCXJ";
private ObservableCollection<DefectClass> _defectClasses;
private DefectClass _selectedDefect;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public Lanju_Product_Process_Check_Task_Detail(ProductProcessData taskData)
{
InitializeComponent();
// 设置数据上下文为当前窗口实例
this.DataContext = this;
_taskData = taskData;
// 初始化数据
DefectClasses = new ObservableCollection<DefectClass>();
if (taskData.check_status == "1")
{
HideSaveButton();
}
LoadListData();
// 替换原来的LoadBackupDefectData()调用
LoadBackupDefectData(); // 旧方法
// 设置选中的缺陷分类基于数据库的remark_code
SetSelectedDefectFromDatabase();
// 使用新的API加载方法
_ = LoadDefectDataFromApiAsync(); // 异步加载API数据
}
public void BtnSubmit_Click(object sender, RoutedEventArgs e)
{
bool isSuccess = false;
bool isSuccessDetial = true;
string isFinal = "0";
if (sender is Button button)
{
if (button.Name == "btnSubmit")
{
isFinal = "1"; // 最终提交按钮
}
else if (button.Name == "btnSave")
{
isFinal = "0"; // 保存按钮
}
}
if (isFinal == "1")
{
var result = MessageBox.Show("是否将报表最终提交?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result != MessageBoxResult.Yes)
{
return;
}
}
//表头数据
string finalResult = "";
if (RadioQualified.IsChecked == true)
finalResult = "1";
else if (RadioUnqualified.IsChecked == true)
finalResult = "0";
string defectCategoryId = SelectedDefect?.id ?? "";
// 调试信息
Console.WriteLine($"提交时选中的缺陷ID: {defectCategoryId}");
Console.WriteLine($"提交时数据库remark_code: {_taskData?.remark_code}");
string remark = TxtRemark.Text;
//更新表头数据到数据库
int Taskresult = dbService.UpdateProductProcessCheckTask(_taskData, finalResult, defectCategoryId, remark, isFinal);
if (Taskresult > 0)
{
isSuccess = true;
}
//获取明细数据
string recordId = _taskData.record_id;
List<ProductProcessListData> itemListData = new List<ProductProcessListData>();
if (ItemsList.ItemsSource != null)
{
// 遍历所有项目
foreach (var item in ItemsList.ItemsSource)
{
// 方式A使用反射获取属性
var model = new ProductProcessListData
{
recordId = GetPropertyValue(item, "recordId"),
ruleName = GetPropertyValue(item, "ruleName"),
checkMode = GetPropertyValue(item, "checkMode"),
status = GetPropertyValue(item, "status"),
material_batch = GetPropertyValue(item, "material_batch")
};
itemListData.Add(model);
}
}
// 输出获取的数据
Console.WriteLine($"获取到 {itemListData.Count} 条检验项目数据");
if (itemListData.Count > 0)
{
//更新明细数据到数据库
int TaskresultDetial = dbService.UpdateProductProcessCheckTaskDetial(itemListData, recordId);
if (TaskresultDetial <= 0)
{
isSuccessDetial = false;
}
}
if (isSuccess && isSuccessDetial)
{
MessageBox.Show("保存成功!");
}
else
{
MessageBox.Show("保存失败!");
LogHelper.instance.log.Error("[Error] 保存失败!");
}
LoadListData();
this.Close();
}
// API响应数据模型
private class ApiDefectResponse
{
public int code { get; set; }
public string msg { get; set; }
public List<ApiDefectItem> data { get; set; }
}
private class ApiDefectItem
{
public string id { get; set; }
public string className { get; set; }
// 根据API实际返回字段添加其他属性
}
private async Task<ApiDefectResponse> LoadDefectDataAsync()
{
using (HttpClient client = new HttpClient())
{
try
{
// 设置超时
client.Timeout = TimeSpan.FromSeconds(30);
// 发送GET请求
HttpResponseMessage response = await client.GetAsync(DEFECT_API_URL);
response.EnsureSuccessStatusCode();
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine($"API响应: {responseContent.Substring(0, Math.Min(200, responseContent.Length))}...");
// 反序列化为ApiDefectResponse
return Utils.DeJson<ApiDefectResponse>(responseContent);
}
catch (Exception ex)
{
Console.WriteLine($"加载API数据失败: {ex.Message}");
return null; // 返回null表示失败
}
}
}
public async Task LoadDefectDataFromApiAsync()
{
try
{
var apiResponse = await LoadDefectDataAsync();
if (apiResponse != null && apiResponse.code == 200 && apiResponse.data != null && apiResponse.data.Count > 0)
{
// 切换到UI线程更新
await Dispatcher.Invoke(async () =>
{
// 备份当前选中的值
string currentSelectedId = SelectedDefect?.id;
// 清空集合并重新填充
DefectClasses.Clear();
DefectClasses.Add(new DefectClass { id = "", className = "请选择缺陷分类" });
foreach (var item in apiResponse.data)
{
DefectClasses.Add(new DefectClass
{
id = item.id ?? "",
className = item.className ?? ""
});
}
// 恢复选中的值
if (!string.IsNullOrEmpty(currentSelectedId))
{
var found = DefectClasses.FirstOrDefault(d => d.id == currentSelectedId);
if (found != null)
{
SelectedDefect = found;
}
else if (!string.IsNullOrEmpty(_taskData?.remark_code))
{
// 尝试使用数据库的值
found = DefectClasses.FirstOrDefault(d => d.id == _taskData.remark_code);
if (found != null)
{
SelectedDefect = found;
}
}
}
Console.WriteLine($"API数据已更新共 {apiResponse.data.Count} 条");
});
Console.WriteLine($"成功从API加载 {apiResponse.data.Count} 条缺陷数据");
}
else
{
Console.WriteLine($"API返回数据无效保持现有数据");
}
}
catch (Exception ex)
{
Console.WriteLine($"从API加载数据异常: {ex.Message}");
// 保持现有数据,不重新加载备用数据
}
}
/*<!-- -->
<TextBox Text="{Binding bz}"/>
<!--
DataContext WindowthisWindow bz
_taskData.bz _taskData Window
-->*/
public string RemarkText
{
get => _taskData?.bz ?? "";
set
{
if (_taskData != null && _taskData.bz != value)
{
_taskData.bz = value;
OnPropertyChanged(nameof(RemarkText));
Console.WriteLine($"备注已更新: {value}");
}
}
}
// 数据模型
public class DefectClass
{
public string id { get; set; }
public string className { get; set; }
}
// 缺陷分类数据源
public ObservableCollection<DefectClass> DefectClasses
{
get => _defectClasses;
set
{
_defectClasses = value;
OnPropertyChanged(nameof(DefectClasses));
}
}
public DefectClass SelectedDefect
{
get => _selectedDefect;
set
{
if (_selectedDefect != value)
{
_selectedDefect = value;
OnPropertyChanged(nameof(SelectedDefect));
// 更新数据库字段
if (_taskData != null)
{
_taskData.remark_code = value?.id ?? "";
Console.WriteLine($"更新数据库remark_code为: {_taskData.remark_code}");
}
}
}
}
//Radio方法 Action
// 检查是否为合格
public bool IsQualified
{
get
{
if (_taskData == null) return false;
return _taskData.check_result == "1";
}
set
{
if (value && _taskData != null)
{
_taskData.check_result = "1";
OnPropertyChanged(nameof(IsQualified));
OnPropertyChanged(nameof(IsUnqualified));
}
}
}
// 检查是否为不合格
public bool IsUnqualified
{
get
{
if (_taskData == null) return false;
return _taskData.check_result == "0" || string.IsNullOrEmpty(_taskData.check_result);
}
set
{
if (value && _taskData != null)
{
_taskData.check_result = "0";
OnPropertyChanged(nameof(IsUnqualified));
OnPropertyChanged(nameof(IsQualified));
}
}
}
//Radio方法 End
// 事件处理方法
public void CmbDefectCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (CmbDefectCategory.SelectedItem is DefectClass selectedDefect)
{
SelectedDefect = selectedDefect;
}
}
private void LoadListData()
{
//子项数据
string recordId = _taskData.record_id;
var baseDictDatas = dbService.GetProductProcessListCheckInfo(recordId).ToList();
if (baseDictDatas == null || baseDictDatas.Count == 0)
{
Console.WriteLine("[Error] 未获取到产品过程检【检验项目】信息。");
LogHelper.instance.log.Error("[Error] 未获取到产品过程检【检验项目】信息。");
}
ItemsList.ItemsSource = baseDictDatas;
Console.WriteLine($"加载了 {baseDictDatas.Count} 条检验项目数据");
}
// 设置选中的缺陷分类基于数据库的remark_code
private void SetSelectedDefectFromDatabase()
{
if (_taskData != null && !string.IsNullOrEmpty(_taskData.remark_code))
{
// 不使用Dispatcher直接查找
var found = DefectClasses.FirstOrDefault(d => d.id == _taskData.remark_code);
if (found != null)
{
_selectedDefect = found; // 直接设置私有字段
Console.WriteLine($"从数据库设置选中项: {found.className} (id: {found.id})");
}
else
{
Console.WriteLine($"未找到对应的缺陷分类remark_code: {_taskData.remark_code}");
// 如果没有找到,默认选中"请选择"
_selectedDefect = DefectClasses.FirstOrDefault();
}
// 触发属性变更通知
OnPropertyChanged(nameof(SelectedDefect));
}
else
{
Console.WriteLine("任务数据为空或remark_code为空");
}
}
public void BtnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private string GetPropertyValue(object obj, string propertyName)
{
if (obj == null) return string.Empty;
try
{
if (obj is System.Dynamic.ExpandoObject)
{
var dict = obj as IDictionary<string, object>;
if (dict.ContainsKey(propertyName))
return dict[propertyName]?.ToString() ?? string.Empty;
}
var property = obj.GetType().GetProperty(propertyName);
if (property != null)
{
var value = property.GetValue(obj);
if (propertyName == "status" && value is ComboBoxItem comboBoxItem)
{
return comboBoxItem.Content?.ToString() ?? string.Empty;
}
return value?.ToString() ?? string.Empty;
}
var field = obj.GetType().GetField(propertyName);
if (field != null)
{
var value = field.GetValue(obj);
if (propertyName == "status" && value is ComboBoxItem comboBoxItem)
{
return comboBoxItem.Content?.ToString() ?? string.Empty;
}
return value?.ToString() ?? string.Empty;
}
}
catch (Exception)
{
}
return string.Empty;
}
private void LoadBackupDefectData()
{
try
{
var backupData = new List<DefectClass>
{
new DefectClass { id = "21b078c25ad84e2fb47bee62f223c103", className = "瓶贴漏贴" },
new DefectClass { id = "3406e251e8384cd0896bd8d1106c914c", className = "瓶贴破损" },
new DefectClass { id = "840d024c579b422e92fc482f6f6f0f5d", className = "纸盒卡口扣不到位" },
new DefectClass { id = "c9e839ecf2d542d98a00e5aee04fedd9", className = "香花外观不良" },
new DefectClass { id = "d77d06d5d07c4432b55b075af5419182", className = "封口不良" },
new DefectClass { id = "f4902856cf1a46f0b21ca01014b33170", className = "夹具破裂" },
new DefectClass { id = "d43ea4c2db0443bca82fc11910a1b42b", className = "漏喷日期码" },
new DefectClass { id = "e5260474815c444f9106de3cee6bb6a1", className = "香花断片大于1/3" },
new DefectClass { id = "08ec2df244124abcaa169aeb37f25360", className = "日期码偏离,模糊不清" },
new DefectClass { id = "15526ee9c1f043b58287d90aee649be4", className = "少放香花" },
new DefectClass { id = "185f9c2864054a75be9ed40b7bd1ee17", className = "密封袋虚啤" },
new DefectClass { id = "4b7cfaf7f95c4936b97e3fbd0b10fd94", className = "香花搭片" },
new DefectClass { id = "2e3e798b5a424d9ebad6829781e133e9", className = "上下盖压不到位" },
new DefectClass { id = "3c913b866e114cc18e59a75155b8c50d", className = "包装盒翘口" },
new DefectClass { id = "ca13ce273ea04054a153395d8f787f2a", className = "漏放支架" },
new DefectClass { id = "3d5099beb88e480e8a137da569443d40", className = "香花断片小于1/3" },
new DefectClass { id = "261c1b03e6a14308ac4971e4b3c92dbd", className = "错码" },
new DefectClass { id = "1fd30c9c182a4f2ca80265270aa58059", className = "收缩不良" },
new DefectClass { id = "75d295dce3ca48be8433cadaadb10fdf", className = "多放支架" },
new DefectClass { id = "add1745fb96d4236a6e853520d905109", className = "多放香花" },
new DefectClass { id = "1f5eba0f8d9641f48b726014474fa7ae", className = "少放支架" },
new DefectClass { id = "12f9ff7af6e748f18be21dca72ecf3e1", className = "日期码不良" },
new DefectClass { id = "0035cc7cc64d41d5a4fcac0b76bb6616", className = "封口翘口" },
new DefectClass { id = "189d63dd1d8241c29555d42fcf53a688", className = "香花断裂" }
};
foreach (var item in backupData)
{
DefectClasses.Add(item);
}
}
catch (Exception ex)
{
MessageBox.Show($"加载备用数据失败: {ex.Message}", "错误",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void HideSaveButton()
{
if (!Dispatcher.CheckAccess())
{
Dispatcher.Invoke(() => HideSaveButton());
return;
}
if (btnSave != null)
{
btnSave.Visibility = Visibility.Collapsed;
}
if (btnSubmit != null)
{
btnSubmit.Visibility = Visibility.Collapsed;
}
}
}
}

@ -7,13 +7,15 @@
mc:Ignorable="d"
WindowStyle="SingleBorderWindow"
WindowStartupLocation="CenterScreen"
Height="450" Width="600">
Height="500" Width="600">
<Grid>
<StackPanel>
<Button Content="产品转换/完产清线点检表" Width="300" Height="50" Margin="20" Background="LightGreen" Click="Open_ReportForm" />
<Button Content="自检互检记录表" Width="300" Height="50" Margin="20" Background="LightGreen" Click="Open_SelfForm" />
<Button Content="产品首检表" Width="300" Height="50" Margin="20" Background="LightGreen" Click="Open_FistForm" />
<Button Content="班组安全生产每日点检报表" Width="300" Height="50" Margin="20" Background="LightGreen" Click="Open_SafeForm"></Button>
<Button Content="生产过程检报表" Width="300" Height="50" Margin="20" Background="LightGreen" Click="Open_ProductListForm"/>
</StackPanel>
</Grid>
</Window>

@ -65,5 +65,9 @@ namespace XGLFinishPro.Views
new Lanju_Daily_Check_Report().ShowDialog();
//}
}
private void Open_ProductListForm(object sender, RoutedEventArgs e)
{
new Lanju_Product_Process_Check_Report_List().ShowDialog();
}
}
}

@ -452,6 +452,12 @@
<Compile Include="Views\LanJu_First_Inspection_Reprot.xaml.cs">
<DependentUpon>LanJu_First_Inspection_Reprot.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Lanju_Product_Process_Check_Report_List.xaml.cs">
<DependentUpon>Lanju_Product_Process_Check_Report_List.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Lanju_Product_Process_Check_Task_Detail.xaml.cs">
<DependentUpon>Lanju_Product_Process_Check_Task_Detail.xaml</DependentUpon>
</Compile>
<Compile Include="Views\OrderWorkIdSelect.xaml.cs">
<DependentUpon>OrderWorkIdSelect.xaml</DependentUpon>
</Compile>
@ -762,6 +768,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Lanju_Product_Process_Check_Report_List.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Lanju_Product_Process_Check_Task_Detail.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\OrderWorkIdSelect.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

Loading…
Cancel
Save