优化样品管理

This commit is contained in:
2026-05-08 15:08:20 +08:00
parent a28bfb9198
commit 06a5f9707d
9 changed files with 215 additions and 72 deletions

View File

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace SamplePre.Models.Ext namespace SamplePre.Models.Ext
{ {
public class tube_input_ext : tube_input,INotifyPropertyChanged public class tube_input_ext : sample_input,INotifyPropertyChanged
{ {
//public bool isChecked { get; set; } = false; //public bool isChecked { get; set; } = false;

View File

@@ -1,12 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SamplePre.Models.Models namespace SamplePre.Models.Models
{ {
public class sample_exec public class sample_exec :INotifyPropertyChanged
{ {
public string id { get; set; } public string id { get; set; }
public string standrad_id { get; set; } public string standrad_id { get; set; }
@@ -14,9 +15,22 @@ namespace SamplePre.Models.Models
public string cmd_content2 { get; set; } public string cmd_content2 { get; set; }
public string qrcodes { get; set; } public string qrcodes { get; set; }
public int sample_count { get; set; } public int sample_count { get; set; }
public string exec_state { get; set; } //public string exec_state { get; set; }
private string _exec_state;
public string exec_state
{
get { return _exec_state; }
set { _exec_state = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(exec_state)));
}
}
public DateTime exec_date { get; set; } public DateTime exec_date { get; set; }
public event PropertyChangedEventHandler? PropertyChanged;
} }
} }

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Models.Models namespace Models.Models
{ {
public class tube_input public class sample_input
{ {
public string qrcode { get; set; } public string qrcode { get; set; }
public string item_name { get; set; } public string item_name { get; set; }
@@ -20,5 +20,11 @@ namespace Models.Models
public int tube_count { get; set; } public int tube_count { get; set; }
public string bach_no { get; set; } public string bach_no { get; set; }
public string exec_state { get; set; }
public DateTime exec_date { get; set; }
public string exec_id { get; set; }
} }
} }

View File

@@ -106,7 +106,7 @@ namespace SamplePre.ProcessBll.SampleSequence
{ {
int val = DBFactory.Instance.Deleteable<tube_input>().Where(p => p.qrcode == code).ExecuteCommand(); int val = DBFactory.Instance.Deleteable<sample_input>().Where(p => p.qrcode == code).ExecuteCommand();
return val; return val;
} }
@@ -128,7 +128,23 @@ namespace SamplePre.ProcessBll.SampleSequence
//主记录 //主记录
int val = _db.Insertable<sample_exec>(cmdExec).ExecuteCommand(); int val = _db.Insertable<sample_exec>(cmdExec).ExecuteCommand();
//明细 //明细
int val2 = _db.Insertable<sample_exec_detail>(cmdExec.sampleExecDetails).ExecuteCommand(); //int val2 = _db.Insertable<sample_exec_detail>(cmdExec.sampleExecDetails).ExecuteCommand();
//更新样品状态
foreach (var item in cmdExec.sampleExecDetails)
{
_db.Updateable<sample_input>()
.SetColumns(p => new sample_input() { exec_state = cmdExec.exec_state ,
exec_date = cmdExec.exec_date ,
exec_id = cmdExec.id
})
.Where(p => p.qrcode == item.qrcode)
.ExecuteCommand();
}
_db.CommitTran(); _db.CommitTran();
} }
@@ -165,7 +181,7 @@ namespace SamplePre.ProcessBll.SampleSequence
} }
public int SaveDataAndQrcode(tube_input qRcode, sys_dict sys_Dict) public int SaveDataAndQrcode(sample_input qRcode, sys_dict sys_Dict)
{ {
var _db = DBFactory.Instance; var _db = DBFactory.Instance;
@@ -175,7 +191,7 @@ namespace SamplePre.ProcessBll.SampleSequence
_db.BeginTran(); _db.BeginTran();
//保存样品记录 //保存样品记录
_db.Insertable<tube_input>(qRcode).ExecuteCommand(); _db.Insertable<sample_input>(qRcode).ExecuteCommand();
//更新二维码 //更新二维码
int val = _db.Updateable<sys_dict>() int val = _db.Updateable<sys_dict>()
@@ -196,9 +212,9 @@ namespace SamplePre.ProcessBll.SampleSequence
return 1; return 1;
} }
public List<tube_input> GetTubeData(DateTime dt1, DateTime dt2) public List<sample_input> GetTubeData(DateTime dt1, DateTime dt2)
{ {
List<tube_input> data = DBFactory.Instance.Queryable<tube_input>().Where(p => p.input_date >= dt1 && p.input_date <= dt2).ToList(); List<sample_input> data = DBFactory.Instance.Queryable<sample_input>().Where(p => p.input_date >= dt1 && p.input_date <= dt2).ToList();
return data;; return data;;
@@ -484,33 +500,39 @@ namespace SamplePre.ProcessBll.SampleSequence
public List<sample_exec_detail_ext> GetSampleExecDetails() public List<sample_input> GetSampleExecDetails()
{ {
var result = DBFactory.Instance.Queryable<sample_exec_detail>() //var result = DBFactory.Instance.Queryable<sample_exec_detail>()
.LeftJoin<sample_exec>((a, b) => a.master_id == b.id) // .LeftJoin<sample_exec>((a, b) => a.master_id == b.id)
.LeftJoin<tube_input>((a, b, c) => a.qrcode == c.qrcode) // .LeftJoin<tube_input>((a, b, c) => a.qrcode == c.qrcode)
.Where((a, b, c) => b.exec_state == "执行中") // .Where((a, b, c) => b.exec_state == "执行中")
.Select((a, b, c) => new sample_exec_detail_ext { // .Select((a, b, c) => new sample_exec_detail_ext {
id = a.id, // id = a.id,
master_id = a.master_id, // master_id = a.master_id,
qrcode = a.qrcode, // qrcode = a.qrcode,
exec_state = b.exec_state, // exec_state = b.exec_state,
item_name= c.item_name, // item_name= c.item_name,
standrad_id = c.standrad_id, // standrad_id = c.standrad_id,
standrad = c.standrad, // standrad = c.standrad,
input_date = c.input_date, // input_date = c.input_date,
input_user = c.input_user // input_user = c.input_user
}) // })
// .ToList();
var result = DBFactory.Instance.Queryable<sample_input>()
.Where(b => b.exec_state == "执行中")
.ToList(); .ToList();
return result;// sampleSequenceDal.GetSampleExecDetails(); return result;// sampleSequenceDal.GetSampleExecDetails();
} }
public List<tube_input> QueryTubeInputByBachNo(string bachNo) public List<sample_input> QueryTubeInputByBachNo(string bachNo)
{ {
return DBFactory.Instance.Queryable<tube_input>().Where(p => p.bach_no == bachNo).ToList(); return DBFactory.Instance.Queryable<sample_input>().Where(p => p.bach_no == bachNo).ToList();
} }
public List<sys_standard_action_ext> GetStrandActionByStrandId(string standrad_id) public List<sys_standard_action_ext> GetStrandActionByStrandId(string standrad_id)

View File

@@ -175,7 +175,7 @@ namespace SamplePreSystem.UI.ViewModel.Child
[RelayCommand] [RelayCommand]
public void ImportClick() public void ImportClick()
{ {
List<tube_input> samples = new List<tube_input>(); List<sample_input> samples = new List<sample_input>();
foreach (var tube in SampleList) foreach (var tube in SampleList)
{ {

View File

@@ -170,10 +170,10 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
private List<sample_exec_detail_ext> _sampleExecList = new List<sample_exec_detail_ext>(); private List<sample_input> _sampleExecList = new List<sample_input>();
public List<sample_exec_detail_ext> SampleExecList public List<sample_input> SampleExecList
{ {
get { return _sampleExecList; } get { return _sampleExecList; }
set { set {
@@ -204,7 +204,7 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
private void GetSampleData() private void GetSampleData()
{ {
List<sample_exec_detail_ext> samples = sampleSequenceBll.GetSampleExecDetails(); List<sample_input> samples = sampleSequenceBll.GetSampleExecDetails();
SampleExecList = samples; SampleExecList = samples;
//设置当前SOP——ID //设置当前SOP——ID

View File

@@ -51,9 +51,9 @@ namespace SamplePreSystem.UI.ViewModel.QueryManager
} }
} }
private List<tube_input> _sampleList = new List<tube_input>(); private List<sample_input> _sampleList = new List<sample_input>();
public List<tube_input> SampleList public List<sample_input> SampleList
{ {
get { return _sampleList; } get { return _sampleList; }
set { set {

View File

@@ -12,6 +12,7 @@ using SamplePre.UIWpf.ParamManager.chirld;
using SamplePre.UIWpf.SampleManager.chirld; using SamplePre.UIWpf.SampleManager.chirld;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@@ -39,11 +40,11 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
} }
private tube_input _tubeInput = new tube_input(); private sample_input _tubeInput = new sample_input();
/// <summary> /// <summary>
/// 样品录入实体 /// 样品录入实体
/// </summary> /// </summary>
public tube_input TubeInput public sample_input TubeInput
{ {
get { return _tubeInput; } get { return _tubeInput; }
set { set {
@@ -168,9 +169,9 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
return qrcode; return qrcode;
} }
private List<tube_input> _tubeInputs = new List<tube_input>(); private List<sample_input> _tubeInputs = new List<sample_input>();
public List<tube_input> TubeInputs public List<sample_input> TubeInputs
{ {
get { return _tubeInputs; } get { return _tubeInputs; }
set { set {
@@ -214,14 +215,14 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
/// </summary> /// </summary>
public bool SaveSample() public bool SaveSample()
{ {
List<tube_input> tempList = new List<tube_input>(); List<sample_input> tempList = new List<sample_input>();
////二维码序号 ////二维码序号
int sqno = int.Parse(TubeInput.qrcode.Substring(8));// int.Parse(txtSampleSeqno2.Text); int sqno = int.Parse(TubeInput.qrcode.Substring(8));// int.Parse(txtSampleSeqno2.Text);
string strDate = TubeInput.qrcode.Substring(0, 8); string strDate = TubeInput.qrcode.Substring(0, 8);
for (int i = 0; i < TubeInput.tube_count; i++) for (int i = 0; i < TubeInput.tube_count; i++)
{ {
tube_input qRcode = new tube_input(); sample_input qRcode = new sample_input();
qRcode.qrcode = strDate + sqno.ToString(); //TubeInput.qrcode; qRcode.qrcode = strDate + sqno.ToString(); //TubeInput.qrcode;
qRcode.item_name = TubeInput.item_name; qRcode.item_name = TubeInput.item_name;
//qRcode.seqno = txtSampleSeqno.Text + txtSampleSeqno2.Text; //qRcode.seqno = txtSampleSeqno.Text + txtSampleSeqno2.Text;
@@ -281,12 +282,12 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
} }
private tube_input _selectSample; private sample_input _selectSample;
/// <summary> /// <summary>
/// 选中的样品 /// 选中的样品
/// </summary> /// </summary>
public tube_input SelectSample public sample_input SelectSample
{ {
get { return _selectSample; } get { return _selectSample; }
set { set {
@@ -301,7 +302,7 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
public void DeleSelectSample() public void DeleSelectSample()
{ {
tube_input[] tube_Inputs = new tube_input[TubeInputs.Count]; sample_input[] tube_Inputs = new sample_input[TubeInputs.Count];
TubeInputs.CopyTo(tube_Inputs); TubeInputs.CopyTo(tube_Inputs);
@@ -323,9 +324,9 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
} }
private List<sample_exec_ext> _cmdList = new List<sample_exec_ext>(); private ObservableCollection<sample_exec_ext> _cmdList = new ObservableCollection<sample_exec_ext>();
public List<sample_exec_ext> CmdList public ObservableCollection<sample_exec_ext> CmdList
{ {
get { return _cmdList; } get { return _cmdList; }
set { set {
@@ -341,9 +342,9 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
/// </summary> /// </summary>
public void CreateCmdList() public void CreateCmdList()
{ {
List<sample_exec_ext> temp_CmdList = new List<sample_exec_ext>(); //List<sample_exec_ext> temp_CmdList = new List<sample_exec_ext>();
//this.tubes = gridSamples.DataSource as List<tube_input>; CmdList.Clear();
var groups = TubeInputs.GroupBy(p => new { p.standrad_id, p.standrad }); var groups = TubeInputs.GroupBy(p => new { p.standrad_id, p.standrad });
@@ -365,10 +366,10 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
sampleCmdExec.sampleExecDetails = details; sampleCmdExec.sampleExecDetails = details;
sampleCmdExec.exec_state = "未执行"; sampleCmdExec.exec_state = "未执行";
temp_CmdList.Add(sampleCmdExec); CmdList.Add(sampleCmdExec);
} }
CmdList = temp_CmdList; //CmdList = temp_CmdList;
//BadingSopData(cmds); //BadingSopData(cmds);
} }
@@ -482,8 +483,7 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
{ {
if (!CmdExec()) return; if (!CmdExec()) return;
//保存下发记录 //保存下发记录
SelectItemCmd.exec_state = "执行中"; SelectItemCmd.exec_state = "执行中";
SelectItemCmd.cmd_content = sopStr; SelectItemCmd.cmd_content = sopStr;
SelectItemCmd.exec_date = DateTime.Now; SelectItemCmd.exec_date = DateTime.Now;
@@ -528,11 +528,11 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager
sopStr = string.Join("-", sop.ToArray()); sopStr = string.Join("-", sop.ToArray());
//写入PLC ////写入PLC
bool val = communicationBll.WritePlcData(100, 0, sop.ToArray()); //bool val = communicationBll.WritePlcData(100, 0, sop.ToArray());
//bool val = monitorBll.WritePlcData(1, 0, sop.ToArray()); //bool val = monitorBll.WritePlcData(1, 0, sop.ToArray());
return val; return true;
} }

View File

@@ -38,10 +38,13 @@
<RowDefinition Height="30" /> <RowDefinition Height="30" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel
Grid.Row="0" <Grid Grid.Row="0">
Height="30" <Grid.ColumnDefinitions>
VerticalAlignment="Center"> <ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock <TextBlock
Margin="10,0" Margin="10,0"
Padding="6" Padding="6"
@@ -49,7 +52,74 @@
VerticalAlignment="Center" VerticalAlignment="Center"
FontWeight="Bold" FontWeight="Bold"
Text="样品列表" /> Text="样品列表" />
</StackPanel> <StackPanel
Grid.Column="1"
Height="30"
VerticalAlignment="Center"
Orientation="Horizontal">
<Button
Width="80"
Height="25"
Margin="5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="启动"
Style="{StaticResource IconTextButtonStyle}"
Tag="Play"
ToolTip="启动" />
<Button
Width="80"
Height="25"
Margin="5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="暂停"
Style="{StaticResource IconTextButtonStyle}"
Tag="Pause"
ToolTip="暂停" />
<Button
Width="80"
Height="25"
Margin="5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="继续"
Style="{StaticResource IconTextButtonStyle}"
Tag="PlayPause"
ToolTip="继续" />
<Button
Width="80"
Height="25"
Margin="5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="停止"
Style="{StaticResource IconTextButtonStyle}"
Tag="Stop"
ToolTip="停止" />
<Button
Width="80"
Height="25"
Margin="5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="复位"
FontSize="13"
Style="{StaticResource IconTextButtonStyle}"
Tag="Refresh"
ToolTip="复位" />
</StackPanel>
</Grid>
<DataGrid <DataGrid
x:Name="dg_sample" x:Name="dg_sample"
Grid.Row="1" Grid.Row="1"
@@ -286,14 +356,12 @@
<!-- 功能单元 --> <!-- 功能单元 -->
<Grid Grid.Column="2"> <Grid Grid.Column="2">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="31*" /> <RowDefinition Height="3*" />
<RowDefinition Height="44*" /> <RowDefinition Height="*" />
<RowDefinition Height="15*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 功能岛信息 --> <!-- 功能岛信息 -->
<Border <Border
Grid.RowSpan="2"
Margin="0,5,5,5" Margin="0,5,5,5"
Background="White" Background="White"
BorderThickness="1" BorderThickness="1"
@@ -347,6 +415,8 @@
</Style> </Style>
</Border.Style> </Border.Style>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
@@ -357,10 +427,13 @@
<ColumnDefinition /> <ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- 功能岛名称 -->
<TextBlock <TextBlock
Margin="5" Margin="5"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Text="{Binding unitName}" /> Text="{Binding unitName}" />
<!-- 详情链接 -->
<TextBlock <TextBlock
Grid.Column="1" Grid.Column="1"
Margin="5" Margin="5"
@@ -372,11 +445,8 @@
[详情] [详情]
</Hyperlink> </Hyperlink>
</TextBlock> </TextBlock>
<!--<Image Grid.Row="1" Grid.Column="0"
Source="{Binding imgPath}" Height="48" Width="48" Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>-->
<!-- 图标 -->
<Border <Border
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
@@ -395,15 +465,13 @@
Kind="{Binding packIconKind}" /> Kind="{Binding packIconKind}" />
</Border> </Border>
<UniformGrid <UniformGrid
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Columns="1" Columns="1"
Rows="2"> Rows="3">
<StackPanel <StackPanel
Margin="0,2" Margin="0,2"
@@ -425,8 +493,41 @@
CornerRadius="3" /> CornerRadius="3" />
<TextBlock VerticalAlignment="Center" Text="{Binding StateName}" /> <TextBlock VerticalAlignment="Center" Text="{Binding StateName}" />
</StackPanel> </StackPanel>
<!-- 功能按钮 -->
<!--
<StackPanel
Grid.Row="1"
HorizontalAlignment="Center"
Orientation="Horizontal">
<Button
Width="45" Margin="2,0"
Height="24" Background="White" Foreground="OrangeRed"
ToolTip="暂停">
<materialDesign:PackIcon Kind="Pause" />
</Button>
<Button
Width="45" Background="White" Foreground="DarkBlue"
Height="24"
ToolTip="继续">
<materialDesign:PackIcon Kind="PlayPause" />
</Button>
<Button
Width="45" Background="White" Foreground="Green"
Height="24"
ToolTip="复位">
<materialDesign:PackIcon Kind="Refresh" />
</Button>
</StackPanel>-->
</UniformGrid> </UniformGrid>
</Grid> </Grid>
</Border> </Border>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
@@ -438,7 +539,7 @@
<!-- 故障信息 --> <!-- 故障信息 -->
<Border <Border
Grid.Row="2" Grid.Row="1"
Margin="0,0,5,5" Margin="0,0,5,5"
Background="White" Background="White"
BorderThickness="1" BorderThickness="1"