770 lines
29 KiB
C#
770 lines
29 KiB
C#
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.在烤箱水含量OK,2.在烤箱水含量NG, 3.在下料位水含量OK,4.在下料位水含量NG,5.在下料位待测水含量
|
||
只有测试OK才解锁
|
||
1.ProcUpdateTask,烤箱夹具(水含量测试OK)->下料,3.在下料位而且是测试ok,
|
||
NG或待测不解锁:2,4,5,
|
||
*/
|
||
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(); //刷新界面
|
||
});
|
||
}
|
||
}
|