首次提交:添加src文件夹代码

This commit is contained in:
2026-02-27 14:02:43 +08:00
commit d330cfbca7
4184 changed files with 5546478 additions and 0 deletions

View File

@@ -0,0 +1,165 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using JSON = Newtonsoft.Json.JsonConvert;
namespace Cowain.Bake.Main.ViewModels
{
public class AddBatteryViewModel : BindableBase
{
private EBatteryStatus selectedEnum;
public EBatteryStatus SelectedEnum
{
get { return selectedEnum; }
set { SetProperty(ref selectedEnum, value); }
}
public List<object> Options { get; set; }
private object selectedOption;
public object SelectedOption
{
get { return selectedOption; }
set { SetProperty(ref selectedOption, value); }
}
public string batteryCode;
public string BatteryCode
{
get => batteryCode;
set => SetProperty(ref batteryCode, value);
}
int _palletID = 0;
int _palletVID = 0;
private IUnityContainer _unityContainer;
public AddBatteryViewModel(IUnityContainer unityContainer, int palletId, int VID)
{
_unityContainer = unityContainer;
_palletID = palletId;
_palletVID = VID;
SelectedEnum = EBatteryStatus.ToPallet;
SelectedPositionX = 1;
SelectedPositionY = 2;
Options = new List<object> { "否", "是" };
SelectedOption = "否";
}
public DelegateCommand<object> AddCommand => new DelegateCommand<object>((x) =>
{
if (string.IsNullOrEmpty(BatteryCode))
{
HandyControl.Controls.MessageBox.Warning("请输入电芯条码!");
return;
}
if (_unityContainer.Resolve<BatteryInfoService>().IsExistBattery(_palletVID, SelectedPositionX, SelectedPositionY))
{
HandyControl.Controls.MessageBox.Warning("夹具位置存在电芯,此位置不能再增加电芯!");
return;
}
if (0 == _palletVID)
{
HandyControl.Controls.MessageBox.Warning("此夹具的虚拟ID为0不能增加电芯!");
return;
}
TBatteryInfo batteryInfo = new TBatteryInfo()
{
PalletVirtualId = _palletVID,
BatteryCode = BatteryCode,
BatteryStatus = (sbyte)SelectedEnum,
PositionX = (sbyte)SelectedPositionX,
PositionY = (sbyte)SelectedPositionY,
ScanTime = DateTime.Now,
BindingTime = DateTime.Now,
DummyFlag = (SelectedOption?.ToString() == "是") ? true : false
};
if(0 == _unityContainer.Resolve<BatteryInfoService>().Insert(batteryInfo))
{
LogHelper.Instance.Debug($"手动增加电芯:【{BatteryCode}】失败!", true);
}
else
{
LogHelper.Instance.Info($"手动增加电芯:【{BatteryCode}】成功!", true);
_unityContainer.Resolve<LogService>().AddLog($"手动增加电芯成功,{ JSON.SerializeObject(batteryInfo)}", E_LogType.Operate.ToString());
_unityContainer.Resolve<PalletInfoService>().ModifyBatteryQty(_palletID); //数据减1
}
});
public List<KeyValuePair<EBatteryStatus, string>> EnumOptions
{
get
{
var enumType = typeof(EBatteryStatus);
var options = new List<KeyValuePair<EBatteryStatus, string>>();
foreach (var value in Enum.GetValues(enumType))
{
var field = enumType.GetField(value.ToString());
var attributes = field.GetCustomAttributes(typeof(DescriptionAttribute), false);
var description = ((DescriptionAttribute)attributes[0]).Description;
options.Add(new KeyValuePair<EBatteryStatus, string>((EBatteryStatus)value, description));
}
return options;
}
}
private int selectedPositionY;
public int SelectedPositionY
{
get { return selectedPositionY; }
set { SetProperty(ref selectedPositionY, value); }
}
private int selectedPositionX;
public int SelectedPositionX
{
get { return selectedPositionX; }
set { SetProperty(ref selectedPositionX, value); }
}
public List<int> PositionYRange
{
get
{
List<int> numbers = new List<int>();
for (int i = 1; i <= Global.PALLET_COLS; i++)
{
numbers.Add(i);
}
return numbers;
}
}
public List<int> PositionXRange
{
get
{
List<int> numbers = new List<int>();
for (int i = 1; i <= Global.PALLET_ROWS; i++)
{
numbers.Add(i);
}
return numbers;
}
}
}
}

View File

@@ -0,0 +1,155 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model.Entity;
using Prism.Mvvm;
using System;
using System.Collections.ObjectModel;
using System.Windows.Media;
using Unity;
namespace Cowain.Bake.Main.ViewModels
{
public class BasicInfoViewModel : BindableBase
{
public static ObservableCollection<string> EventListNoticfication = new ObservableCollection<string>();
private string _userName;
public string UserName
{
get { return _userName; }
set { SetProperty<string>(ref _userName, value); }
}
private string _currentJobNum;
public string CurrentJobNum
{
get { return _currentJobNum; }
set { SetProperty<string>(ref _currentJobNum, value); }
}
private string _dispMode;
public string DispMode
{
get { return _dispMode; }
set { SetProperty<string>(ref _dispMode, value); }
}
private string _currentOperation;
public string CurrentOperation
{
get { return _currentOperation; }
set { SetProperty<string>(ref _currentOperation, value); }
}
private string _userId;
public string UserId
{
get { return _userId; }
set { SetProperty<string>(ref _userId, value); }
}
private string _startStatusName;
public string StartStatusName
{
get { return _startStatusName; }
set { SetProperty<string>(ref _startStatusName, value); }
}
private string _failPointData;
public string FailPointData
{
get { return _failPointData; }
set { SetProperty<string>(ref _failPointData, value); }
}
private string _deviceStatusName;
public string DeviceStatusName
{
get { return _deviceStatusName; }
set { SetProperty<string>(ref _deviceStatusName, value); }
}
//EventList
private ObservableCollection<string> _eventList = new ObservableCollection<string>();
public ObservableCollection<string> EventList
{
get => _eventList;
set => SetProperty(ref _eventList, value);
}
private bool _mesStatus;
public bool MesStatus
{
get { return _mesStatus; }
set { SetProperty(ref _mesStatus, value); RaisePropertyChanged(nameof(StatusColor)); }
}
public SolidColorBrush StatusColor
{
get
{
if (!MesStatus)
{
return new SolidColorBrush(Colors.Red);
}
else
{
return new SolidColorBrush(Colors.Green);
}
}
}
private readonly IUnityContainer _unityContainer;
public BasicInfoViewModel(IUnityContainer unityContainer)
{
_unityContainer = unityContainer;
ShowInfo();
}
public void ShowInfo()
{
UserEntity userInfo = _unityContainer.Resolve<MemoryDataProvider>().CurrentUser;
userInfo.JobNum = _unityContainer.Resolve<ProductionInformationService>().GetCurrentProductInfo().JobNum;
userInfo.ProcessParamName = _unityContainer.Resolve<ProcessParamService>().Get(_unityContainer.Resolve<ProductionInformationService>().GetCurrentProductInfo().ProcessParamId).ProcessParamName;
FailPointData = "0";
UserName = userInfo.UserName;
UserId = userInfo.UserId;
CurrentJobNum = userInfo.JobNum;
CurrentOperation = userInfo.ProcessParamName;
DeviceStatusName = EDeviceStatus.None.GetDescription();
DispMode = SettingProvider.Instance.DispMode.GetDescription();
}
public void SetTempData(string value)
{
System.Threading.SynchronizationContext.SetSynchronizationContext(new
System.Windows.Threading.DispatcherSynchronizationContext(System.Windows.Application.Current.Dispatcher));
System.Threading.SynchronizationContext.Current.Post(p1 =>
{
FailPointData = value;
}, null);
}
public void SetEvent(string msg)
{
// 在第一个位置插入新元素
System.Threading.SynchronizationContext.SetSynchronizationContext(new
System.Windows.Threading.DispatcherSynchronizationContext(System.Windows.Application.Current.Dispatcher));
System.Threading.SynchronizationContext.Current.Post(p1 =>
{
/*
RemoveAt:放在外面,会崩
该类型的 CollectionView 不支持从调度程序线程以外的线程对其 SourceCollection 进行的更改。, 在 System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
在 System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
在 System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
*/
if (EventList.Count > Bake.Common.Global.MAX_QUEUE_SIGNAL)
{
EventList.RemoveAt(EventList.Count - 1);
}
EventList.Insert(0, $"{ DateTime.Now.ToString("HH:mm:ss")}: {msg}");
}, null);
}
}
}

View File

@@ -0,0 +1,769 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Communication.Interface;
using Cowain.Bake.Main.Views;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using Cowain.Bake.Model.Models;
using HandyControl.Controls;
using HslCommunication;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Windows;
using Unity;
namespace Cowain.Bake.Main.ViewModels
{
public class CavityDtlViewModel: BindableBase//, Prism.Services.Dialogs.IDialogAware
{
private string stationName;
private string palletCode;
private string stationEnable;
private string batteryCount;
private int _virtualId;
private string selectedValue;
private string selectedJobNum;
private string isWaterValue;
private List<string> arrJobNum;
private List<string> palletStatus;
private List<string> lastPalletList;
private string lastValue;
private int _bakingCount;
private bool _isEnabled ;
private bool _isEnabledAdd;
private bool _lastEnabled;
List<CavityInfoModel> _cavityInfo;
CavityHeaderModel _cavityHeaderInfo = null;
private IUnityContainer _unityContainer;
public string Title => "工站明细";
// 弹窗打开时触发:读取传递的参数
//public void OnDialogOpened(IDialogParameters parameters)
//{
// if (parameters.TryGetValue<string>("StatinName", out var text))
// {
// StationName = text; // 赋值后界面自动更新
// GetInfo();
// }
//}
//// 允许关闭弹窗返回true即可
//public bool CanCloseDialog() => true;
//// 弹窗关闭后清理资源(可选)
//public void OnDialogClosed() { }
//// Prism 8中用于触发弹窗关闭的事件
//public event Action<IDialogResult> RequestClose;
//// 关闭弹窗的逻辑
//public DelegateCommand CloseCommand =>
// new DelegateCommand(() =>
// RequestClose?.Invoke(new DialogResult(ButtonResult.OK)));
//private readonly IDialogService _dialogService;
public CavityDtlViewModel(IUnityContainer unityContainer)
{
_unityContainer = unityContainer;
//_dialogService = dialogService;
_cavityInfo = _unityContainer.Resolve<CavityInfoService>().GetAllStation();
}
private ObservableCollection<string> palletList;
public ObservableCollection<string> PalletList
{
get => palletList;
set => SetProperty(ref palletList, value);
}
public string SelectedValue
{
get => selectedValue;
set => SetProperty(ref selectedValue, value);
}
public string SelectedJobNum
{
get => selectedJobNum;
set => SetProperty(ref selectedJobNum, value);
}
public string IsWaterValue
{
get => isWaterValue;
set => SetProperty(ref isWaterValue, value);
}
public List<string> PalletStatus
{
get => palletStatus;
set => SetProperty(ref palletStatus, value);
}
public List<string> ArrJobNum
{
get => arrJobNum;
set => SetProperty(ref arrJobNum, value);
}
public string StationName
{
get => stationName;
set => SetProperty(ref stationName, value);
}
public string BatteryCount
{
get => batteryCount;
set => SetProperty(ref batteryCount, value);
}
public string WaterValueModel;
public string StationEnable
{
get => stationEnable;
set => SetProperty(ref stationEnable, value);
}
public string remark;
public string Remark
{
get => remark;
set => SetProperty(ref remark, value);
}
public string PalletCode
{
get { return palletCode; }
set
{
SetProperty(ref palletCode, value);
// 在属性更改时调用需要执行的方法
//SetPalletList();
}
}
public int BakingCount
{
get => _bakingCount;
set => SetProperty(ref _bakingCount, value);
}
public bool IsEnabled
{
get { return _isEnabled; }
set { SetProperty(ref _isEnabled, value); }
}
public bool IsEnabledAdd
{
get { return _isEnabledAdd; }
set { SetProperty(ref _isEnabledAdd, value); }
}
public bool LastEnabled
{
get { return _lastEnabled; }
set { SetProperty(ref _lastEnabled, value); }
}
public List<string> LastPalletList
{
get => lastPalletList;
set => SetProperty(ref lastPalletList, value);
}
public string LastValue
{
get { return lastValue; }
set
{
SetProperty(ref lastValue, value);
if (lastValue != "")
{
UpdateLastPallet();
}
}
}
public int VirtualId
{
get => _virtualId;
set => SetProperty(ref _virtualId, value);
}
public event PropertyChangedEventHandler NotifyPropertyChanged;
public void OnPropertyChanged(string propName)
{
if (NotifyPropertyChanged != null)
{
NotifyPropertyChanged.Invoke(this, new PropertyChangedEventArgs(propName));
}
}
private BatteryInfoEntity batteryInfoSelectedItem;
public BatteryInfoEntity BatteryInfoSelectedItem
{
get { return batteryInfoSelectedItem; }
set
{
if (value != null)
{
batteryInfoSelectedItem = value;
OnPropertyChanged("BatteryInfoSelectedItem");
}
}
}
public void GetInfo()
{
SetPalletCodeCombox();
SetPalletStatusCombox();
SetPalletLastCombox();
SetJobNumCombox();
GetHeaderInfo();
FillGridView();
}
private void SetPalletCodeCombox()
{
PalletList = new ObservableCollection<string>();
_unityContainer.Resolve<PalletInfoService>().GetAll().ForEach(item => PalletList.Add(item.PalletCode));
}
private void SetPalletLastCombox()
{
LastPalletList = new List<string>();
foreach (EPalletLast ePalletStatus in System.Enum.GetValues(typeof(EPalletLast)))
{
LastPalletList.Add(ePalletStatus.GetDescription());
}
}
private void SetPalletStatusCombox()
{
PalletStatus = new List<string>();
foreach (EPalletStatus ePalletStatus in System.Enum.GetValues(typeof(EPalletStatus)))
{
PalletStatus.Add(ePalletStatus.GetDescription());
}
}
private void SetJobNumCombox()
{
var jobNums = _unityContainer.Resolve<ProductionInformationService>().GeAll();
ArrJobNum = jobNums.Select(x => x.JobNum).ToList();
}
bool IsPassWordPass()
{
// 创建输入对话框
//string pwd = Microsoft.VisualBasic.Interaction.InputBox("请您输入密码!", "修改");
//if (pwd != SettingProvider.Instance.PWD)
//{
// LogHelper.Instance.Warn("您输入的密码错误!",true);
// return false;
//}
return true;
}
public DelegateCommand<object> UpdatePalletStatus => new DelegateCommand<object>((x) =>
{
if (1 == _cavityHeaderInfo.PalletId)
{
LogHelper.Instance.Warn("新夹具,不能修改夹具状态!",true);
return;
}
if (0 == _cavityHeaderInfo.PalletId)
{
LogHelper.Instance.Error("此机台未绑定托盘!", true);
return;
}
if (!IsPassWordPass())
{
return;
}
CavityInfoModel stationDetail = _cavityInfo.Where(y => y.CavityName == StationName).FirstOrDefault();
var list = EnumHelper.GetEnumList<EPalletStatus>().Where(item => item.EnumDesc == SelectedValue);
int palletStatus = list.FirstOrDefault().EnumIntValue;
if (palletStatus == (int)EPalletStatus.BlankOver) //将清空夹具里的电芯,是确认是否要改成下料完成
{
if (_unityContainer.Resolve<BatteryInfoService>().IsIntoStation(VirtualId))
{
if (MessageBoxResult.OK == HandyControl.Controls.MessageBox.Ask("夹具中有电芯,如果改成【下料完成】,将设置电芯为出站,\n请确认是否要改状态", "操作提示"))
{
_unityContainer.Resolve<BatteryInfoService>().SetBatteryOutBound(VirtualId);
}
}
_unityContainer.Resolve<PalletInfoService>().SetUnBinding(_cavityHeaderInfo.PalletId);
}
else if (palletStatus == (int)EPalletStatus.WaitTest)
{
if (IsUnLoading(stationDetail))
{
LogHelper.Instance.Error("禁止将在下料机台的托盘状态更改为‘待测水含量!’", true);
return;
}
}
else if (palletStatus == (int)EPalletStatus.Advisable)
{
_unityContainer.Resolve<PalletInfoService>().UpdateNowJobNum(VirtualId);
var memory = _unityContainer.Resolve<MemoryDataProvider>();
SelectedJobNum = memory.CurrentUser.JobNum;
}
else if (palletStatus == (int)EPalletStatus.Bake) //烘烤中,设置夹具烘烤位置
{
TStation station = _unityContainer.Resolve<StationService>().GetStationByCavityId(_cavityHeaderInfo.Id);
if (station.Type == (int)EStationType.Stove)
{
if (0 == _unityContainer.Resolve<PalletInfoService>().UpdateBakingPos(_cavityHeaderInfo.PalletCode,
_cavityHeaderInfo.Id))
{
LogHelper.Instance.Error($"修改烘烤位置失败!");
}
}
}
_unityContainer.Resolve<CavityInfoService>().UpdatePalletStatus(_cavityHeaderInfo.PalletId, StationName, palletStatus);
HandyControl.Controls.Growl.Success("更新成功!");
_unityContainer.Resolve<LogService>().AddLog("人为修改状态:" + stationName
+ ";" + ((EPalletStatus)palletStatus).GetDescription(), E_LogType.Operate.ToString());
BotnnVisible(palletStatus);
GetHeaderInfo();
FillGridView();
});
public DelegateCommand<object> UpdatePalletCode => new DelegateCommand<object>((x) =>
{
if (string.IsNullOrEmpty(palletCode))
{
LogHelper.Instance.Error("请选托盘编码!", true);
return;
}
if (_cavityHeaderInfo.Lock)
{
LogHelper.Instance.Error("该位置已有调度任务锁定,无法绑定托盘!", true);
return;
}
_unityContainer.Resolve<CavityInfoService>().UpdateStationPalletCode(stationName, PalletCode);
GetHeaderInfo();
FillGridView();
var list = EnumHelper.GetEnumList<EPalletStatus>().Where(item => item.EnumDesc == SelectedValue);
int palletStatus = list.FirstOrDefault().EnumIntValue;
if (palletStatus == (int)EPalletStatus.BakeOver || palletStatus == (int)EPalletStatus.Bake)
{
CavityInfoModel machine = _cavityInfo.Where(y => y.Id ==_cavityHeaderInfo.Id).FirstOrDefault();
if (machine.Type == (int)EStationType.Stove)
{
_unityContainer.Resolve<PalletInfoService>().UpdateBakingPos(PalletCode, _cavityHeaderInfo.Id);
}
}
HandyControl.Controls.MessageBox.Success("已更新!");
_unityContainer.Resolve<LogService>().AddLog("人为绑定托盘:" + stationName
+";"+palletCode, E_LogType.Operate.ToString());
});
public DelegateCommand<object> BindJobNum => new DelegateCommand<object>((x) =>
{
if (!IsPassWordPass())
{
return;
}
if (0 == _unityContainer.Resolve<PalletInfoService>().SetJobNum(stationName, selectedJobNum))
{
LogHelper.Instance.Error("此机台未绑定托盘!", true);
return;
}
HandyControl.Controls.MessageBox.Success("已更新!");
_unityContainer.Resolve<LogService>().AddLog($"人为绑定工单,工站:{stationName},工单:{selectedJobNum}"
, E_LogType.Operate.ToString());
});
public DelegateCommand<object> UnBindJobNum => new DelegateCommand<object>((x) =>
{
if (0 == _unityContainer.Resolve<PalletInfoService>().SetJobNum(stationName, ""))
{
LogHelper.Instance.Error("此机台未绑定托盘!", true);
return;
}
HandyControl.Controls.MessageBox.Success("已更新!");
GetHeaderInfo();
_unityContainer.Resolve<LogService>().AddLog($"人为解绑工单,工站:{stationName},工单:{selectedJobNum}"
, E_LogType.Operate.ToString());
});
public DelegateCommand<object> AddBatteryCommand => new DelegateCommand<object>((x) =>
{
if (!IsPassWordPass())
{
return;
}
var viewModel = new AddBatteryViewModel(_unityContainer, _cavityHeaderInfo.PalletId, VirtualId);
AddBatteryView dlg = new AddBatteryView { DataContext = viewModel };
dlg.ShowDialog();
GetHeaderInfo(); //刷新数量
FillGridView();
});
public DelegateCommand<object> AddRemark => new DelegateCommand<object>((x) =>
{
if (50 <= remark.Length)
{
HandyControl.Controls.MessageBox.Error($@"输入的备注长度不能大于50个字符!", "操作提示");
return;
}
if (0 == _unityContainer.Resolve<CavityInfoService>().UpdateRemark(stationName, remark))
{
LogHelper.Instance.Error("修改备注失败!" ,true);
}
else
{
LogHelper.Instance.Info("修改备注成功!", true);
}
});
public DelegateCommand<object> UpdatePalletNoneCode => new DelegateCommand<object>((x) =>
{
if (!IsPassWordPass())
{
return;
}
if (0 == _cavityHeaderInfo.PalletId)
{
LogHelper.Instance.Error("此机台未绑定托盘!", true);
return;
}
_unityContainer.Resolve<CavityInfoService>().UpdateStationNonePallet(stationName);
GetHeaderInfo();
HandyControl.Controls.MessageBox.Success("已更新为无托盘!");
_unityContainer.Resolve<LogService>().AddLog("人为解绑," + stationName
, E_LogType.Operate.ToString());
});
public DelegateCommand<object> UpdateVirtualId => new DelegateCommand<object>((x) =>
{
if (!IsPassWordPass())
{
return;
}
if (1 == _cavityHeaderInfo.PalletId)
{
LogHelper.Instance.Warn("新夹具不能修改夹具信息ID", true);
return;
}
if (string.IsNullOrEmpty(palletCode))
{
LogHelper.Instance.Error("请选托盘编码!", true);
return;
}
var BatteryList = _unityContainer.Resolve<BatteryInfoService>().GetBatteryInfos(VirtualId);
if (BatteryList.Count < 1)
{
//LogHelper.Instance.Error("所输入的虚拟夹具号没有电芯信息!", true);
//return; //add by lsm 后面要开放,暂时为了测温度数据
}
if (_unityContainer.Resolve<PalletInfoService>().UpdateVirtualId(VirtualId, PalletCode) < 1)
{
HandyControl.Controls.MessageBox.Error("同一个虚拟码或更新失败!");
_unityContainer.Resolve<LogService>().AddLog($"更新失败,人为绑定托盘虚拟码,{stationName},托盘虚拟码:{VirtualId}"
, E_LogType.Operate.ToString());
return;
}
GetHeaderInfo();
FillGridView();
HandyControl.Controls.MessageBox.Success("已更新!");
_unityContainer.Resolve<LogService>().AddLog($"人为绑定托盘虚拟码,{stationName},托盘虚拟码:{VirtualId}"
, E_LogType.Operate.ToString());
});
private void GetHeaderInfo()
{
_cavityHeaderInfo = _unityContainer.Resolve<CavityInfoService>().GetHeadInfo(StationName);
BatteryCount = _cavityHeaderInfo.BatteryQty.ToString();
SelectedJobNum = _cavityHeaderInfo.JobNum;
stationEnable = _cavityHeaderInfo.Enable;
IsWaterValue = _cavityHeaderInfo.IsWater;
PalletCode = _cavityHeaderInfo.PalletCode;
WaterValueModel = _cavityHeaderInfo.WaterValue;
BakingCount = _cavityHeaderInfo.BakingCount;
Remark = _cavityHeaderInfo.Remark;
VirtualId = _cavityHeaderInfo.VirtualId;
SelectedValue = "";
if (null != _cavityHeaderInfo.PalletStatus)
{
int enumValue = _cavityHeaderInfo.PalletStatus ?? 1;
SelectedValue = EnumHelper.GetEnumList<EPalletStatus>()
.Where(item => item.EnumIntValue == enumValue).FirstOrDefault().EnumDesc;
BotnnVisible(enumValue);
}
if (null != _cavityHeaderInfo.LastFlag)
{
int enumValue = (_cavityHeaderInfo.LastFlag ?? false) ? 1 : 0;
LastValue = EnumHelper.GetEnumList<EPalletLast>()
.Where(item => item.EnumIntValue == enumValue).FirstOrDefault().EnumDesc;
}
CommonCoreHelper.Instance.MainViewAutoEvent.Set();
IsEnabledAdd = ((0 == VirtualId) || (Global.PALLET_TOTAL_BATTERYS == int.Parse(BatteryCount))) ? false : true;
}
private ObservableCollection<BatteryInfoEntity> batteryDtl2 = new ObservableCollection<BatteryInfoEntity>();
public ObservableCollection<BatteryInfoEntity> BatteryDtl2
{
get => batteryDtl2;
set => SetProperty(ref batteryDtl2, value);
}
private void FillGridView()
{
List<TBatteryInfo> table = _unityContainer.Resolve<BatteryInfoService>().GetBatteryInfos(VirtualId).
OrderBy(x=>x.PositionY).OrderBy(x=>x.PositionX).ToList();
//_unityContainer.Resolve<BatteryInfoService>().GetCavityBattery(StationName);
BatteryDtl2.Clear();
if (table.Count == 0)
{
return;
}
foreach (var item in table)
{
if ((int)EBatteryStatus.Over != item.BatteryStatus)
{
BatteryInfoEntity batteryInfoEntity = new BatteryInfoEntity();
batteryInfoEntity.Id = item.Id;
batteryInfoEntity.BatteryCode = item.BatteryCode;
batteryInfoEntity.BatteryStatus = item.BatteryStatus;
batteryInfoEntity.PositionX = item.PositionX;
batteryInfoEntity.PositionY = item.PositionY;
batteryInfoEntity.DummyFlag = item.DummyFlag ;
batteryInfoEntity.BindingTime =item.BindingTime;
BatteryDtl2.Add(batteryInfoEntity);
}
}
}
private void BotnnVisible(int enumValue)
{
CavityInfoModel stationDetail = _cavityInfo.Where(y => y.CavityName == StationName).FirstOrDefault();
//不是待测水含量不能使用判断按钮
IsEnabled = (int)EPalletStatus.WaitTest == enumValue ? true: false;
if (!_unityContainer.Resolve<BLL.BatteryInfoService>().IsPalletDummy(VirtualId))//不带水的不能使用判断按钮
{
IsEnabled = false;
}
//在上料或下料工站的不能修改为最后一盘
if (stationDetail.Type == (int)EStationType.Loading
|| stationDetail.Type == (int)EStationType.UnLoading)
{
LastEnabled = false; //显示“最后一盘” Enabled
}
else
{
LastEnabled = true;
}
}
public DelegateCommand<object> MoistureInput => new DelegateCommand<object>((x) =>
{
MoistureValueView moisture = new MoistureValueView( _unityContainer, this);
moisture.ShowDialog();
//var p = new DialogParameters
//{
// { "this", this }
// //{ "waterValue", WaterValueModel }
//};
//_dialogService.ShowDialog(nameof(MoistureValueView), p, r => { /*回调*/ });
GetHeaderInfo();
BotnnVisible(_cavityHeaderInfo.PalletStatus??10);
});
/*
解锁重点 add by lsm 调度锁放有效,锁对取盘无效
5.种状态1.在烤箱水含量OK2.在烤箱水含量NG 3.在下料位水含量OK4.在下料位水含量NG5.在下料位待测水含量
只有测试OK才解锁
1.ProcUpdateTask,烤箱夹具(水含量测试OK)->下料,3.在下料位而且是测试ok,
NG或待测不解锁245
*/
public void MoistureRuturn(int palletstaus,string moistureValue )
{
if (!UpdatePalletState(palletstaus, moistureValue))
{
return;
}
CavityInfoModel stationDetail = _cavityInfo.Where(y => y.CavityName == StationName).FirstOrDefault();
if (IsUnLoading(stationDetail))
{
var conf = _unityContainer.Resolve<DeviceConfigService>().GetConfig(stationDetail.StationId);
IPLCDevice plc = _unityContainer.Resolve<IPLCDevice>(conf.Name);
if (SelectedValue == EPalletStatus.TestOK.GetDescription())
{
OperateResult operateResult = plc.Write<bool>($"ns=4;s=PC_IN_Par_Request{stationDetail.Column}", true);
if (!operateResult.IsSuccess)
{
LogHelper.Instance.Debug($"设置请求参数下发失败:{operateResult.Message}");
HandyControl.Controls.Growl.Success("设置请求参数下发失败!");
}
else
{
//解除锁定
_unityContainer.Resolve<CavityInfoService>().GetPalletBakingPosAndUpdateLock(PalletCode); //夹具在下料,解除炉子的锁
}
}
}
}
/// <summary>
/// 改变托盘状态以及保存水分值
/// </summary>
private bool UpdatePalletState(int palletstaus, string moistureValue) //未将对象引用设置到对象的实例
{
var proceParamModel = _unityContainer.Resolve<ProductionInformationService>().GetProductionInformation(SelectedJobNum);
try
{
if (null == proceParamModel)
{
LogHelper.Instance.Error($"查询工单信息失败!,工单号:【{SelectedJobNum}】", true);
return false;
}
if (proceParamModel.DummyRule == (int)DummyPlaceRule.DEFAULT_EVERY_STOVE_LAYER_PLACED_ONE)//判断是不是一个炉层放一个水含量规则
{
int updateResult = _unityContainer.Resolve<PalletInfoService>().UpdateDummyLayerValue(_cavityHeaderInfo.BakingPosition, palletstaus, moistureValue, _cavityHeaderInfo.PalletId);
if (updateResult <= 0)
{
LogHelper.Instance.Warn($"修改夹具状态失败!烘烤位置:{_cavityHeaderInfo.BakingPosition},夹具ID:{_cavityHeaderInfo.PalletId}");
}
}
else
{
if (0 >= _unityContainer.Resolve<PalletInfoService>().UpdateWaterValue(_cavityHeaderInfo.PalletId, palletstaus, moistureValue))
{
LogHelper.Instance.Warn($"修改夹具:{_cavityHeaderInfo.Id},状态:{palletstaus}失败!");
}
}
HandyControl.Controls.Growl.Success("更新成功!");
}
catch(Exception ex)
{
LogHelper.Instance.Error($"修改托盘水含量信息失败,{ex.Message}", true);
return false;
}
return true;
}
private void UpdateLastPallet()
{
var service = _unityContainer.Resolve<PalletInfoService>();
TPalletInfo palletInfo = service.GetPalletInfo(palletCode);
int i = palletInfo.LastFlag ? 1 : 0;
string palletLast = EnumHelper.GetEnumList<EPalletLast>()
.Where(item => item.EnumIntValue == i).FirstOrDefault().EnumDesc;
//判断当前和数据库内的值是否相等,不相等就执行更改
if (LastValue != palletLast && LastValue != "")
{
service.UpdateLast(palletCode, LastValue);
HandyControl.Controls.MessageBox.Success("修改成功!");
}
}
private bool IsUnLoading(CavityInfoModel cavityInfo)
{
if (cavityInfo.Type == (int)EStationType.UnLoading)
{
return true;
}
return false;
}
public DelegateCommand<object> DeleteCommand => new DelegateCommand<object>((x) =>
{
if (!IsPassWordPass())
{
return;
}
var result = HandyControl.Controls.MessageBox.Ask($@"确定删除?", "操作提示");
if (result == System.Windows.MessageBoxResult.Cancel)
{
return;
}
var t = x as BatteryInfoEntity;
if (t != null)
{
if (_unityContainer.Resolve<BatteryInfoService>().Delete<TBatteryInfo>(t.Id) > 0)
{
batteryDtl2.Remove(t);
Growl.Success("删除成功!");
_unityContainer.Resolve<PalletInfoService>().ModifyBatteryQty(_cavityHeaderInfo.PalletId, -1); //数据减1
GetHeaderInfo(); //刷新界面
}
else
{
Growl.Fatal("删除失败!");
}
}
else
{
Growl.Fatal("删除失败!");
}
});
public DelegateCommand<object> ChangeDummyCommand => new DelegateCommand<object>((x) =>
{
if (null == BatteryInfoSelectedItem)
{
Growl.Warning("选择失败!");
return;
}
if (_unityContainer.Resolve<BLL.BatteryInfoService>().IsPalletDummy(VirtualId))
{
Growl.Warning("夹具有水含量电芯,不能再设置水含量电芯");
FillGridView();
return;
}
if (MessageBoxResult.Cancel == HandyControl.Controls.MessageBox.Ask("是否确定要设置此电芯为【水含量电芯】?", "提示"))
{
FillGridView();
return;
}
if (_unityContainer.Resolve<BLL.BatteryInfoService>().SetDummy(BatteryInfoSelectedItem.Id) > 0)
{
Growl.Info("设置为水含量电芯成功!");
}
else
{
Growl.Fatal("设置为水含量电芯失败!");
}
FillGridView(); //刷新界面
});
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
using Prism.Mvvm;
using Prism.Regions;
using Unity;
namespace Cowain.Bake.Main.ViewModels
{
public class MainHeaderViewModel : BindableBase
{
IUnityContainer _unityContainer;
public MainHeaderViewModel(IUnityContainer unityContainer, IRegionManager regionManager)
{
_unityContainer = unityContainer;
//userInfo = _unityContainer.Resolve<GlobalEntity>();
////可以看到这种声明方式提供了一个ObservesProperty方法不需要显示调用命令状态改变事件ObservesProperty属性观察
////属性观察,如果有变化就触发CanExecute
//ExecuteAutoCommand = new DelegateCommand(AutoExecute, AutoCanExecute).ObservesProperty(() => IsAutoEnabled);
//ExecuteManualCommand = new DelegateCommand(ManualExecute, ManualCanExecute).ObservesProperty(() => IsManualEnabled);
}
}
}

View File

@@ -0,0 +1,262 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Main.Models;
using Cowain.Bake.Main.Views;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Models;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using Unity;
namespace Cowain.Bake.Main.ViewModels
{
public class MainWindowViewModel : BindableBase
{
private string promptContent = "";
public string PromptContent
{
get { return promptContent; }
set { SetProperty<string>(ref promptContent, value); }
}
private string recentMsg; //最新的消息
readonly IUnityContainer _unityContainer;
private SubscriptionToken _subscriptionToken;
private readonly IEventAggregator _eventAggregator;
//缩放因子,用于调整在不同分辨率屏幕的位置
public MainWindowViewModel(IUnityContainer unityContainer, IEventAggregator eventAggregator)
{
_unityContainer = unityContainer;
//Global.STOVE_LAYERS = _unityContainer.Resolve<MemoryDataProvider>().AllStation.Find(x => x.Type ==(int)EStationType.Stove).Layers;
MainTitle = SettingProvider.Instance.ProductionLineName + Global.VS;
SetlogDict();
LogHelper.Instance.Warn($"-------------{Global.VS}------------------");
LogHelper.Instance.Debug($"-------------{Global.VS}------------------");
LogHelper.Instance.Error($"-------------{Global.VS}------------------");
LogHelper.Instance.Fatal($"-------------{Global.VS}------------------");
LogHelper.Instance.Info($"-------------{Global.VS}------------------");
InitializeLogLevels();
_eventAggregator = eventAggregator;
_subscriptionToken = _eventAggregator.GetEvent<AlarmAddEvent>() //Unsubscribe: 取消订阅(如在组件销毁时)
.Subscribe(OnAddAlarm, ThreadOption.UIThread); //事件触发时执行的方法,ThreadOption.UIThread,(默认):在发布事件的线程执行
_subscriptionToken = _eventAggregator.GetEvent<AlarmCancelEvent>()
.Subscribe(OnCancelAlarm, ThreadOption.UIThread);
_subscriptionToken = _eventAggregator.GetEvent<AlarmStaionCancelEvent>()
.Subscribe(OnCancelAlarm, ThreadOption.UIThread);
}
private void OnAddAlarm(TAlarm alarm)
{
var model = Alarms.Where(item => item.StationId == alarm.StationId && item.Desc == alarm.Desc).FirstOrDefault();
if (null == model)
{
Alarms.Add(alarm);
}
//ShowPromptContent();
}
private void OnCancelAlarm(TAlarm alarm)
{
var model = Alarms.Where(item => item.StationId == alarm.StationId && item.Desc == alarm.Desc).FirstOrDefault();
if (null != model)
{
Alarms.Remove(model);
}
//ShowPromptContent();
}
private void OnCancelAlarm(int stationId)
{
var models = Alarms.Where(item => item.StationId == stationId).ToList();
foreach (var model in models)
{
Alarms.Remove(model);
}
//ShowPromptContent();
}
public void ShowPromptContent()
{
int index = 0;
PromptContent = "";
foreach (var item in Alarms.Reverse())
{
if (++index > 2)
{
return; //数据太多了,就会卡,所以只让显示二条数据
}
PromptContent += item.Desc + " "; //太多了,界面卡
}
}
public void AddPromptContent(string msg)
{
//string addContent = promptContent;
//if (string.IsNullOrEmpty(addContent))
//{
// addContent = msg;
//}
//else
//{
// var parts = addContent.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
// if (!parts.Contains(msg))
// {
// addContent += "|" + msg;
// }
//}
//if (promptContent == addContent)
//{
// return;
//}
;
PromptContent = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} : {msg}";
}
public void DeletePromptContent(string msg ="")
{
string deleteContent = promptContent;
if (string.IsNullOrEmpty(deleteContent))
{
return;
}
//if (!deleteContent.Contains(msg))
//{
// return;
//}
//var parts = deleteContent.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
// .Select(p => p.Trim())
// .Where(p => p != msg)
// .ToList();
//deleteContent = string.Join("|", parts);
PromptContent = "";
}
private void InitializeLogLevels()
{
var logTypes = EnumHelper.GetEnumList<E_LogType>();
for (int i = 0; i < (logTypes.Count - 3); i++)
{
LogLevelModel1.Add(new MultiComboBox.MultiCbxBaseData
{
Id = i,
IsCheck = true,
ViewName = logTypes[i].EnumString.ToString()
});
}
LogHelper.Instance.OnShowInvoke = LogShow;
}
private Dictionary<E_LogType, (string FontColor, MessageBoxImage Image)> logDict;
private void SetlogDict()
{
logDict = new Dictionary<E_LogType, (string, MessageBoxImage)>
{
{ E_LogType.Debug, ("#5352ed", MessageBoxImage.Exclamation) },
{ E_LogType.Info, ("#1abc9c", MessageBoxImage.Information) },
{ E_LogType.Warn, ("#eccc68", MessageBoxImage.Warning) },
{ E_LogType.Error, ("red", MessageBoxImage.Error) },
{ E_LogType.Fatal, ("red", MessageBoxImage.Error) }
};
}
private void LogShow(string log, bool ispopup, E_LogType logType)
{
if (recentMsg == log && !ispopup)
{
return;
}
recentMsg = log;
DateTime date = DateTime.Now;
if (logDict.TryGetValue(logType, out var logInfo))
{
InfoLogModel = new LogModel
{
LogLevel = logType.ToString(),
LogText = log,
LogTime = date,
FontColor = logInfo.FontColor
};
if (ispopup)
{
Application.Current.Dispatcher.Invoke(() =>
{
HandyControl.Controls.MessageBox.Show(log, logType.GetDescription(), MessageBoxButton.OK, logInfo.Image);
});
}
}
}
public DelegateCommand<object> AlarmQueryCommand => new DelegateCommand<object>((x) =>
{
HistoryAlarmsData.Clear();
var service = _unityContainer.Resolve<AlarmService>();
service.GetAlarmReport(AlarmStartTime, AlarmEndTime).ForEach(item => HistoryAlarmsData.Add(item));
});
#region
private string mainTitle;
public string MainTitle
{
get => mainTitle;
set => SetProperty(ref mainTitle, value);
}
private LogModel logModel1;
public LogModel InfoLogModel
{
get => logModel1;
set => SetProperty(ref logModel1, value);
}
private ObservableCollection<MultiComboBox.MultiCbxBaseData> logLevelModel1 = new ObservableCollection<MultiComboBox.MultiCbxBaseData>();
public ObservableCollection<MultiComboBox.MultiCbxBaseData> LogLevelModel1
{
get => logLevelModel1;
set => SetProperty(ref logLevelModel1, value);
}
private string alarmStartTime = DateTime.Now.ToString("yyyy-MM-dd");
public string AlarmStartTime
{
get => alarmStartTime;
set => SetProperty(ref alarmStartTime, value);
}
private string alarmEndTime = DateTime.Now.ToString("yyyy-MM-dd");
public string AlarmEndTime
{
get => alarmEndTime;
set => SetProperty(ref alarmEndTime, value);
}
private ObservableCollection<TAlarm> alarms = new ObservableCollection<TAlarm>();
public ObservableCollection<TAlarm> Alarms
{
get => alarms;
set => SetProperty(ref alarms, value);
}
private ObservableCollection<TAlarm> historyAlarms = new ObservableCollection<TAlarm>();
public ObservableCollection<TAlarm> HistoryAlarmsData
{
get => historyAlarms;
set => SetProperty(ref historyAlarms, value);
}
#endregion
}
}

View File

@@ -0,0 +1,123 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Main.Station;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Entity;
using Cowain.Bake.Model.Models;
using Newtonsoft.Json;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Data;
using Unity;
namespace Cowain.Bake.Main.ViewModels
{
public class ManualTaskViewModel: BindableBase
{
private IUnityContainer _unityContainer;
private string selectFromValue;
public string SelectFromValue
{
get => selectFromValue;
set => SetProperty(ref selectFromValue, value);
}
private string selectToValue;
public string SelectToValue
{
get => selectToValue;
set => SetProperty(ref selectToValue, value);
}
//不写set;get还设置不了这里的值
public List<string> StationDtl { set; get; } = new List<string>();
public void GetStationDtl()
{
List<string> table = _unityContainer.Resolve<CavityInfoService>().GetCanUseStationName();
foreach (var item in table)
{
StationDtl.Add(item);
}
}
public ManualTaskViewModel(IUnityContainer unityContainer)
{
_unityContainer = unityContainer;
}
public DelegateCommand GenerateTaskCommand => new DelegateCommand(() =>
{
GenerateTask();
});
private void GenerateTask()
{
if (SettingProvider.Instance.DispMode == EDispatchMode.Auto)
{
HandyControl.Controls.Growl.Warning("自动调度,不能手动生成任务!");
return;
}
if (string.IsNullOrEmpty(selectFromValue)
|| string.IsNullOrEmpty(SelectToValue))
{
HandyControl.Controls.Growl.Error("取放为空,不能手动生成任务!");
return;
}
if (_unityContainer.Resolve<TaskRecordService>().UnexecuteTask() != null)
{
HandyControl.Controls.Growl.Warning("还有调度任务没有执行完成,不能手动生成任务!");
return;
}
TCavityInfo fromTable = _unityContainer.Resolve<CavityInfoService>().GetStationID(selectFromValue);
TCavityInfo toTable = _unityContainer.Resolve<CavityInfoService>().GetStationID(SelectToValue);
Cowain.Bake.Model.TTaskRecord taskRecord = new Model.TTaskRecord();
if (0 == fromTable.PalletId)
{
LogHelper.Instance.Error("添加失败,取位置无托盘记忆!", true);
return;
}
if (!fromTable.IsLoad)
{
LogHelper.Instance.Error("添加失败,取位置感应不到夹具到位!", true);
return;
}
if (0 != toTable.PalletId || toTable.IsLoad)
{
LogHelper.Instance.Error("添加失败,放位置有托盘信息!", true);
return;
}
TPalletInfo palletInfo = _unityContainer.Resolve<PalletInfoService>().GetPalletInfo(fromTable.PalletId);
if (palletInfo.PalletStatus == (int)EPalletStatus.Bake)
{
LogHelper.Instance.Error("添加失败,无法将在烘烤中的托盘添加到任务!", true);
return;
}
taskRecord.PalletId = fromTable.PalletId;
taskRecord.TaskTypeId = 0;
taskRecord.Source = fromTable.Id;
taskRecord.Target = toTable.Id;
taskRecord.Status = (int)ETaskStatus.UnExecute;
taskRecord.BuildTime = DateTime.Now;
taskRecord.StepId = (int)ETaskStep.Unexecuted;
if (0 == _unityContainer.Resolve<TaskRecordService>().Insert(taskRecord))
{
LogHelper.Instance.Error("插入任务到数据库失败!", true);
return;
}
_unityContainer.Resolve<TaskStation>()._newTaskEvent.Set();
LogHelper.Instance.Info($"插入任务成功!{JsonConvert.SerializeObject(taskRecord)}");
HandyControl.Controls.MessageBox.Success("已添加成功!");
}
}
}

View File

@@ -0,0 +1,156 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common.Core;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Cowain.Bake.Model.Models;
using Newtonsoft.Json;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Unity;
namespace Cowain.Bake.Main.ViewModels
{
internal class MoistureValueViewMode: BindableBase//, Prism.Services.Dialogs.IDialogAware
{
private readonly IUnityContainer _unityContainer;
private float? septumwaterJudge;
private float? cathodewaterJudge;
private float? anodewaterJudge ;
//public string WaterValueModel;
List<WaterModel> waterModels = null;
public CavityDtlViewModel thatParent = null;
//public string Title => "输入水含量值";
//// 弹窗打开时触发:读取传递的参数
//public void OnDialogOpened(IDialogParameters parameters)
//{
// thatParent = parameters.GetValue<CavityDtlViewModel>("this");
// WaterValueModel = thatParent.WaterValueModel ?? "";
//}
//// 允许关闭弹窗返回true即可
//public bool CanCloseDialog() => true;
//// 弹窗关闭后清理资源(可选)
//public void OnDialogClosed() { }
//// Prism 8中用于触发弹窗关闭的事件
//public event Action<IDialogResult> RequestClose;
//public DelegateCommand CloseCommand =>
// new DelegateCommand(() =>
// RequestClose?.Invoke(new DialogResult(ButtonResult.OK)));
public MoistureValueViewMode(IUnityContainer unityContainer)
{
_unityContainer = unityContainer;
}
public float? SeptumWaterJudge //隔离膜水分
{
get => septumwaterJudge;
set => SetProperty(ref septumwaterJudge, value);
}
public float? AnodeWaterJudge //正极水分
{
get => anodewaterJudge;
set => SetProperty(ref anodewaterJudge, value);
}
public float? CathodeWaterJudge //负极水分
{
get => cathodewaterJudge;
set => SetProperty(ref cathodewaterJudge, value);
}
public DelegateCommand<object> Judge => new DelegateCommand<object>((x) =>
{
int septumwaterTargetValue = int.Parse(_unityContainer.Resolve<SysSetupService>().GetValueByParaID(ESysSetup.SeptumwaterTargetJudge.ToString()));
int cathodewaterTargetValue = int.Parse(_unityContainer.Resolve<SysSetupService>().GetValueByParaID(ESysSetup.CathodewaterTargetJudge.ToString()));
int anodewaterTargetValue = int.Parse(_unityContainer.Resolve<SysSetupService>().GetValueByParaID(ESysSetup.AnodewaterTargetJudge.ToString()));
//MessageBoxResult result = HandyControl.Controls.MessageBox.Ask($@"是否确定为手动输入的水含量值?", "操作提示");
//if (result == System.Windows.MessageBoxResult.Cancel)
//{
// return;
//}
LogHelper.Instance.Warn($"开始测水含量0!");
if (!septumwaterJudge.HasValue
|| !anodewaterJudge.HasValue
|| !cathodewaterJudge.HasValue
)
{
HandyControl.Controls.MessageBox.Warning("数值为空, 请人工输入!");
return;
}
var WaterModel = new WaterModel();
WaterModel.AnodeWaterValue = anodewaterJudge.ToString();
WaterModel.CathodeWaterValue = cathodewaterJudge.ToString();
WaterModel.SeptumWaterValue = septumwaterJudge.ToString();
int palletStatus = (int)EPalletStatus.TestOK;
if (septumwaterJudge >= septumwaterTargetValue
|| cathodewaterJudge >= cathodewaterTargetValue
|| anodewaterJudge >= anodewaterTargetValue)
{
palletStatus = (int)EPalletStatus.TestNG;
MessageBoxResult judgeResult = HandyControl.Controls.MessageBox.Ask($@"本次判定水含量值为NG,请确认!", "判定提示");
if (judgeResult == System.Windows.MessageBoxResult.Cancel)
{
return;
}
}
//WaterValueModel,在这个界面点【判定】,会刷新这个值。也就是这个判断结果会累加,但在【工站明细】中不会
waterModels = JsonConvert.DeserializeObject<List<WaterModel>>(thatParent.WaterValueModel??""); //WaterValueModel:数据库中的水含量数据
WaterModel.BatteryCode = GetBatteryCode(waterModels);
if (null == waterModels)
{
waterModels = new List<WaterModel>();
}
else
{
WaterModel.Id = waterModels.Max(w => w.Id) + 1;
}
waterModels.Add(WaterModel);
thatParent.MoistureRuturn(palletStatus, JsonConvert.SerializeObject(waterModels));
HandyControl.Controls.MessageBox.Info("设置测试水含量成功");
});
string GetBatteryCode(List<WaterModel> waterList)
{
var dummys = _unityContainer.Resolve<BatteryInfoService>().GetWaterBatteryCode(thatParent.VirtualId);
if (0 == dummys.Count)
{
return "";
}
if (waterList == null
|| 0 == waterList.Count)
{
return dummys[0].BatteryCode;
}
List<string> dummyCodes = dummys.Select(x => x.BatteryCode).ToList();
List<string> waterCodes = waterList.Select(x => x.BatteryCode).ToList();
// 查找 list1 中不在 list2 中的字符串 var notInList2 = list1.Except(list2);
var batteryCode = dummyCodes.Except(waterCodes);
if (0 ==batteryCode.Count())
{
return waterList.OrderByDescending(x => x.Id).FirstOrDefault().BatteryCode;//最后一次的假电芯码
}
return batteryCode.First();
}
}
}

View File

@@ -0,0 +1,28 @@
using Cowain.Bake.Common;
using Prism.Regions;
using Unity;
namespace Cowain.Bake.Main.ViewModels
{
public class PalletIdInputWindowViewModel : ViewModelBase
{
private string _title;
public string Title
{
get => _title;
set => SetProperty(ref _title, value);
}
private string _msgContent;
public string MsgContent
{
get => _msgContent;
set => SetProperty(ref _msgContent, value);
}
public PalletIdInputWindowViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
{
}
}
}