添加项目文件。

This commit is contained in:
2026-04-30 11:34:41 +08:00
parent a8539ccaac
commit 80635aa46e
181 changed files with 16378 additions and 0 deletions

View File

@@ -0,0 +1,211 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Models.Models;
using SamplePre.Models.Ext;
using SamplePre.ProcessBll.SampleSequence;
using SamplePreSystem.UI.ViewModel.SampleManager;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using static MaterialDesignThemes.Wpf.Theme;
namespace SamplePreSystem.UI.ViewModel.Child
{
public partial class ImportSampleViewModel: ObservableObject
{
SampleSequenceBll sampleSequenceBll = new SampleSequenceBll();
SampleExecViewModel sampleExecViewModel;
// 关闭窗口的委托
public Action<bool> CloseAction { get; set; }
public ImportSampleViewModel(SampleExecViewModel _sampleExecViewModel)
{
GetData();
sampleExecViewModel = _sampleExecViewModel;
}
private DateTime _startDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
public DateTime StartDate
{
get { return _startDate; }
set
{
SetProperty(ref _startDate, value);
}
}
private DateTime _endDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
public DateTime EndDate
{
get { return _endDate; }
set
{
SetProperty(ref _endDate, value);
}
}
private List<tube_input_ext> _sampleList = new List<tube_input_ext>();
public List<tube_input_ext> SampleList
{
get { return _sampleList; }
set {
SetProperty(ref _sampleList, value);
}
}
public void GetData()
{
//DateTime dt1 = DateTime.Parse(dt_start.DateTime.ToString("yyyy-MM-dd") + " 00:00:00");
//DateTime dt2 = DateTime.Parse(dt_end.DateTime.ToString("yyyy-MM-dd") + " 23:00:00");
var templist = sampleSequenceBll.GetTubeData(StartDate, EndDate); ///
List<tube_input_ext> samples = new List<tube_input_ext>();
foreach(var item in templist)
{
item.bach_no = $"批号:{item.bach_no}";
tube_input_ext model = new tube_input_ext();
model.qrcode = item.qrcode;
model.item_name = item.item_name;
model.tube_type = item.tube_type;
model.standrad_id = item.standrad_id;
model.standrad = item.standrad;
model.input_user = item.input_user;
model.input_date = item.input_date;
model.weight = item.weight;
model.tube_count = item.tube_count;
model.bach_no = $"批号:{item.bach_no}";
model.IsSelected = false;
samples.Add(model);
}
SampleList = samples;
}
public bool? IsAllItems1Selected
{
get
{
var selected = SampleList.Select(item => item.IsSelected).Distinct().ToList();
return selected.Count == 1 ? selected.Single() : false;
}
set
{
if (value.HasValue)
{
SelectAll(value.Value, SampleList);
OnPropertyChanged();
}
}
}
/// <summary>
/// 选择所有
/// </summary>
/// <param name="select"></param>
/// <param name="models"></param>
private static void SelectAll(bool select, IEnumerable<tube_input_ext> models)
{
foreach (var model in models)
{
model.IsSelected = select;
}
}
/// <summary>
/// 选择组内数据
/// </summary>
/// <param name="bachCode"></param>
/// <param name="isSelect"></param>
public void SelectGroupData(string bachCode, bool isSelect)
{
foreach (var item in SampleList.Where(p => p.bach_no == bachCode))
{
item.IsSelected = isSelect;
}
}
[RelayCommand]
public void FindClick()
{
GetData();
ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(SampleList);//获取数据视图
//分组
view.GroupDescriptions.Add(new PropertyGroupDescription("bach_no"));
}
[RelayCommand]
public void ImportClick()
{
List<tube_input> samples = new List<tube_input>();
foreach (var tube in SampleList)
{
if (tube.IsSelected)
{
samples.Add(tube);
}
}
this.sampleExecViewModel.TubeInputs = samples;
CloseAction?.Invoke(true);
}
/// <summary>
/// 选中导入项
/// </summary>
[RelayCommand]
public void CheckBoxClick(object groupName)
{
System.Windows.Controls.CheckBox checkBox = groupName as System.Windows.Controls.CheckBox;
if (checkBox != null)
{
bool select = (bool)checkBox.IsChecked;
string code = checkBox.Content.ToString();
SelectGroupData(code, select);
}
}
}
}

View File

@@ -0,0 +1,120 @@
using Models.Const;
using Models.Models;
using SamplePre.Models;
using SamplePre.ProcessBll.BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace SamplePreSystem.UI.ViewModel.Child
{
public class NewActionViewModel: INotifyPropertyChanged
{
ActionMangerBll actionMangerBll = new ActionMangerBll();
public NewActionViewModel()
{
BindingUnit();
}
public void BindingUnit()
{
ActionUnits = SystemConst.dictDatas.Where(p => p.class_id == 2).ToList();
}
private List<sys_dict> actionUnits;
public event PropertyChangedEventHandler PropertyChanged;
public List<sys_dict> ActionUnits
{
get { return actionUnits; }
set { actionUnits = value;
OnPropertyChanged();
}
}
/// <summary>
/// 选择的动作单元
/// </summary>
private sys_dict _selectSysDict;
public sys_dict SelectSysDict
{
get { return _selectSysDict; }
set { _selectSysDict = value;
OnPropertyChanged();
}
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private sys_action sysAction = new sys_action();
public sys_action SysAction
{
get { return sysAction; }
set { sysAction = value;
OnPropertyChanged();
}
}
public int SaveNewData()
{
if (string.IsNullOrEmpty(SysAction.action_name))
{
MessageBox.Show("内容不能为空");
return -1;
}
//判断plc编码是否重复
if (actionMangerBll.IsExtisPlCcode(SysAction.plc_type))
{
MessageBox.Show("存在相同plc编码不能保存");
return -1;
}
sys_action process = new sys_action();
process.id = Guid.NewGuid().ToString();
process.action_name = SysAction.action_name;
process.plc_type = SysAction.plc_type;
process.remark = SysAction.remark;
//var selectItem = cmbActionUnit.SelectedItem as ComboBoxListItem;
process.action_unit = SelectSysDict.id;
//process.action_adress = actionAdress.Text;
int val = actionMangerBll.SaveSysAction(process);
return val;
}
}
}

View File

@@ -0,0 +1,218 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Models.Models;
using SamplePre.Models.Ext;
using SamplePre.ProcessBll.BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace SamplePreSystem.UI.ViewModel.Child
{
public partial class SelectParmListViewModel : ObservableObject
{
ActionMangerBll actionMangerBll = new ActionMangerBll();
SOPManagerBll sopBll = new SOPManagerBll();
sys_standard_action_ext sysStandardAction = null;
sys_action_ext sysAction = null;
// 关闭窗口的委托
public Action<bool> CloseAction { get; set; }
public SelectParmListViewModel(sys_standard_action_ext _sysStandardAction)
{
sysStandardAction = _sysStandardAction;
GetData();
FilterData(FilterType);
}
public SelectParmListViewModel(sys_action_ext _sysAction)
{
sysAction = _sysAction;
GetData();
FilterData(FilterType);
}
/// <summary>
/// 参数类型
/// </summary>
[ObservableProperty]
public List<string> dataTypes = new List<string> { "通用", "耗材", "液体" };
/// <summary>
/// 所有参数列表
/// </summary>
private List<sys_parm> allSysParams = new List<sys_parm>();
/// <summary>
/// 过滤参数列表
/// </summary>
[ObservableProperty]
public List<sys_parm> parms = new List<sys_parm>();
/// <summary>
/// 选中的参数列表
/// </summary>
[ObservableProperty]
public sys_parm selectParm = new sys_parm();
public void GetData()
{
if (Parms.Count <= 0)
{
//parms = standardDal.QuerySysParm();
allSysParams = actionMangerBll.QuerySysParm();
}
}
private string filterType = "通用";
/// <summary>
/// 类型过滤属性
/// </summary>
public string FilterType
{
get { return filterType; }
set {
SetProperty(ref filterType, value);
FilterData(value);
}
}
public void FilterData(string dataType)
{
if (string.IsNullOrEmpty(dataType))
{
Parms = allSysParams;
return;
}
Parms = allSysParams.Where(p => p.param_type == dataType).ToList();
}
public int SaveData(List<sys_parm> selectParam)
{
int val = -1;
if (sysStandardAction != null)
{
val = SavaDataSop(selectParam);
}
else if(sysAction != null)
{
val = SavaDataActionParam(selectParam);
}
return val;
}
private int SavaDataActionParam(List<sys_parm> selectParam)
{
//保存
List<sys_action_parm_map> actionParams = new List<sys_action_parm_map>();
foreach (var item in selectParam)
{
sys_action_parm_map map = new sys_action_parm_map();
map.process_id = sysAction.id;
map.parm_id = item.id;
//standardDal.Save_process_parm_map(map);
actionParams.Add(map);
}
int val = actionMangerBll.SaveActionParm(actionParams);
return val;
}
private int SavaDataSop(List<sys_parm> selectParam)
{
//保存
List<sys_standard_action_parm> actionParms = new List<sys_standard_action_parm>();
foreach (var item in selectParam)
{
//保存标准动作参数表
sys_standard_action_parm parmmodel = new sys_standard_action_parm()
{
id = Guid.NewGuid().ToString(),
standard_id = sysStandardAction.standard_id,
action_id = sysStandardAction.process_id,
action_seqno = sysStandardAction.process_no,
parm_id = item.id,
data_value = item.data_value,
parm_seqno = 0
};
actionParms.Add(parmmodel);
}
int val = sopBll.SaveStandardActionParam(actionParms);
return val;
}
/// <summary>
/// 确定命令
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[RelayCommand]
public void BtnOKClick()
{
if (SelectParm != null)
{
List<sys_parm> selectParams = new List<sys_parm>();
selectParams.Add(SelectParm);
if (selectParams.Count > 0)
{
if (SaveData(selectParams) > 0)
{
CloseAction?.Invoke(true);
}
}
}
}
/// <summary>
/// 取消命令
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[RelayCommand]
public void BtnCancelClick()
{
CloseAction?.Invoke(false);
}
}
}