66 lines
2.2 KiB
C#
66 lines
2.2 KiB
C#
|
|
using Cowain.Bake.BLL;
|
|||
|
|
using Cowain.Bake.Model.Entity;
|
|||
|
|
using Cowain.Bake.Common;
|
|||
|
|
using Cowain.Bake.Model;
|
|||
|
|
using Prism.Regions;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Collections.ObjectModel;
|
|||
|
|
using Unity;
|
|||
|
|
using Prism.Commands;
|
|||
|
|
using HandyControl.Controls;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
using Cowain.Bake.Model.Models;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace Cowain.Bake.UI.DataQuery.ViewModels
|
|||
|
|
{
|
|||
|
|
public class DummyInfoViewModel:ViewModelBase
|
|||
|
|
{
|
|||
|
|
public DummyInfoViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
|||
|
|
{
|
|||
|
|
this.PageTitle = "电池追踪";
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private ObservableCollection<BatteryInfoEntity> cellList;
|
|||
|
|
public ObservableCollection<BatteryInfoEntity> CellList
|
|||
|
|
{
|
|||
|
|
get => cellList ?? (cellList = new ObservableCollection<BatteryInfoEntity>());
|
|||
|
|
set { SetProperty(ref cellList, value); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DelegateCommand<object> DummyQueryCommand => new DelegateCommand<object>((x) =>
|
|||
|
|
{
|
|||
|
|
CellList.Clear();
|
|||
|
|
if (string.IsNullOrWhiteSpace(Code))
|
|||
|
|
{
|
|||
|
|
HandyControl.Controls.MessageBox.Error($@"没有数据!请输入正确的条码", "操作提示");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BatteryInfoEntity batteryInfo = _unityContainer.Resolve<BatteryInfoService>().QueryBatteryWaterValue(Code);
|
|||
|
|
if(null == batteryInfo)
|
|||
|
|
{
|
|||
|
|
HandyControl.Controls.MessageBox.Error($@"没有数据到所属托盘或没有此电芯!", "警告");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(batteryInfo.WaterValue))
|
|||
|
|
{
|
|||
|
|
List<WaterModel> waterModelList = JsonConvert.DeserializeObject<List<WaterModel>>(batteryInfo.WaterValue);
|
|||
|
|
WaterModel waterModel = waterModelList.OrderByDescending(w=>w.Id).FirstOrDefault();
|
|||
|
|
batteryInfo.SeptumValue = waterModel.SeptumWaterValue;
|
|||
|
|
batteryInfo.AnodeValue = waterModel.AnodeWaterValue;
|
|||
|
|
batteryInfo.CathodeValue = waterModel.CathodeWaterValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CellList.Add(batteryInfo);
|
|||
|
|
Growl.Success("查询完成!");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|