| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- using System.Collections.Generic;
- using System.Linq;
- using ivf_tl_Entity.Entity.balance;
- using CommunityToolkit.Mvvm.ComponentModel;
- using ivf_tl_Entity.Entity.Result;
- using ivf_tl_Service.HttpProvider;
- using ivf_tl_Entity.Entity;
- using ivf_tl_Manage.Converts;
- using System.Diagnostics;
- using System;
- using ivf_tl_Entity.Enums;
- using System.Collections.ObjectModel;
- namespace ivf_tl_Manage.ViewModels
- {
- public partial class DetailViewModel : BaseViewModel
- {
- public DetailProvider detailProvider = null;
- public BaseViewModel ParentViewModel = null;
- [ObservableProperty]
- private House currentHouse = null;
- [ObservableProperty]
- private Dish currentDish;
- [ObservableProperty]
- private Embryo currentEmbryo = null;
- [ObservableProperty]
- private double videoAllTime = 1;
- [ObservableProperty]
- private double videoCurrentTime = 0;
- [ObservableProperty]
- private int currentFocal = 0;
- [ObservableProperty]
- private Dictionary<double, string> fpsItemList = new Dictionary<double, string>();
- [ObservableProperty]
- private KeyValuePair<double, string> selectedFps = new KeyValuePair<double, string>(1, "1.0x");
- [ObservableProperty]
- private bool isDishRecord = false;
- [ObservableProperty]
- private bool isHistory = false;
- [ObservableProperty]
- private bool isCurrentDish = true;
- [ObservableProperty]
- private bool isUpdata = false;
- [ObservableProperty]
- private ObservableCollection<MeasurementEntity> measurementList = new ObservableCollection<MeasurementEntity>();
- public List<DishPicAndVideo> DishPicAndVideoList { get; set; } = new List<DishPicAndVideo>();
- public DishPicAndVideo CurrentWellDishPicAndVideo { get; set; } = null;
- public LayerPicAndVideo CurrentWellLayerPicAndVideo { get; set; } = null;
- public DetailPic CurrentPic { get; set; } = null;
- public List<ButtonEntity> QuickButtons { get; set; } = new List<ButtonEntity>();
- private bool _IsInit = false;
- public int MaxTotalLayer = -1;
- public DetailViewModel(BaseViewModel baseViewModel, TLInfo tLInfo, Dish dish, House house, bool dishrecord)
- {
- AppData.Instance.CurrentTlInfo = tLInfo;
- MeasurementList.Clear();
- MeasurementList.Add(new MeasurementEntity { Num = 1 });
- MeasurementList.Add(new MeasurementEntity { Num = 2 });
- MeasurementList.Add(new MeasurementEntity { Num = 3 });
- FpsItemList.Clear();
- FpsItemList.Add(2, "2.0x");
- FpsItemList.Add(1.5, "1.5x");
- FpsItemList.Add(1.25, "1.25x");
- FpsItemList.Add(1, "1.0x");
- FpsItemList.Add(0.5, "0.5x");
- FpsItemList.Add(0.25, "0.25x");
- if (detailProvider == null) detailProvider = AppData.Instance.GetDetailProvider();
- base.ViewModelName = nameof(DetailViewModel);
- this.ParentViewModel = baseViewModel;
- IsDishRecord = dishrecord;
- this.CurrentHouse = house;
- this.CurrentDish = dish;
- if (CurrentDish.embryoList == null) CurrentDish.embryoList = new List<Embryo>();
- IsUpdata = true;
- base.NavName = $"{KeyToStringConvert.GetLanguageStringByKey("0163")}{CurrentHouse.houseSn}";
- NavList.Clear();
- if (IsDishRecord == true)
- {
- NavList.Add(baseViewModel);
- NavList.Add(this);
- return;
- }
- NavList.Add(AppData.Instance.MainWindowViewModel.devManageViewModel);
- NavList.Add(AppData.Instance.MainWindowViewModel.patientManageViewModel);
- NavList.Add(this);
- }
- public void Init()
- {
- Stopwatch stopwatch = Stopwatch.StartNew();
- TimeLog($"{CurrentHouse.houseSn}号舱室详情界面数据初始化开始,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}", LogEnum.TakeTime);
- var time1 = stopwatch.Elapsed;
- VideoAllTime = 1;
- VideoCurrentTime = 0;
- CurrentFocal = 0;
- if (_IsInit) return;
- _IsInit = true;
- SelectedFps = new KeyValuePair<double, string>(1, "1.0x");
- CurrentEmbryo = null;
- DishPicAndVideoList.Clear();
- CurrentWellDishPicAndVideo = null;
- CurrentWellLayerPicAndVideo = null;
- CurrentPic = null;
- QuickButtons.Clear();
- if (CurrentDish.embryoList != null && CurrentDish.embryoList.Any())
- DishPicAndVideoList = detailProvider.GetRecordDetailApi(CurrentDish.tlSn, CurrentDish.houseSn, CurrentDish.id, CurrentDish.embryoList.Select(x => x.wellSn).ToList());
- var time2 = stopwatch.Elapsed;
- TimeLog($"获取图片视频:{DateTime.Now},耗时:{(time2 - time1).TotalMilliseconds}毫秒", LogEnum.TakeTime);
- QuickButtons = detailProvider.GetQuickButtonsApi();
- time1 = stopwatch.Elapsed;
- DebugLog($"{CurrentHouse.houseSn}号舱室详情界面数据初始化完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},[读取快捷按钮耗时:{(time1 - time2).TotalMilliseconds}毫秒]总耗时:{stopwatch.Elapsed.TotalMilliseconds}毫秒", LogEnum.TakeTime);
- stopwatch.Stop();
- }
- public void Back()
- {
- if (ParentViewModel != null)
- AppData.Instance.MainWindowViewModel.CurrentViewModle = ParentViewModel;
- else
- AppData.Instance.MainWindowViewModel.CurrentViewModle = AppData.Instance.MainWindowViewModel.devManageViewModel;
- }
- public void MarkEmbryo()
- {
- //MarkUseViewModel markUseViewModel = null;
- //if (!IsDishRecord) markUseViewModel = new MarkUseViewModel(this, $"{KeyToStringConvert.GetLanguageStringByKey("0163")}{CurrentHouse.houseSn}");
- //else markUseViewModel = new MarkUseViewModel(this, ParentViewModel, $"{KeyToStringConvert.GetLanguageStringByKey("0163")}{CurrentHouse.houseSn}");
- //markUseViewModel.Init();
- //AppData.Instance.MainWindowViewModel.CurrentViewModle = markUseViewModel;
- MarkUseViewModel markUseViewModel = new MarkUseViewModel(this, IsDishRecord, IsCurrentDish);
- markUseViewModel.Init();
- AppData.Instance.MainWindowViewModel.CurrentViewModle = markUseViewModel;
- }
- public bool MarkEmbryo(int embryoState)
- {
- return detailProvider.MarkEmbryoDestinationApi(CurrentEmbryo.id, embryoState);
- }
- public bool EndDish()
- {
- if (detailProvider.EndCultureRecordApi(CurrentDish.id))
- {
- AppData.Instance.MainWindowViewModel.patientManageViewModel.EndDish(CurrentDish.houseSn);
- return true;
- }
- return false;
- }
- public void GetPicDetail()
- {
- }
- }
- }
|