|
@@ -19,13 +19,15 @@ using System.Threading.Tasks;
|
|
|
using Newtonsoft.Json;
|
|
|
using QuestPDF.Fluent;
|
|
|
using System.Windows;
|
|
|
+using Prism.Regions;
|
|
|
|
|
|
namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
{
|
|
|
|
|
|
|
|
|
- public class ResultQueryViewModel : BindableBase
|
|
|
+ public class ResultQueryViewModel : BindableBase,INavigationAware
|
|
|
{
|
|
|
+ private readonly IRegionManager _regionManager;
|
|
|
private readonly IBasicDeviceService _iBasicDeviceService;
|
|
|
private readonly IBasicDeviceKindService _iBasicDeviceKindService;
|
|
|
private readonly IBasicProjectService _iBasicProjectService;
|
|
@@ -36,9 +38,11 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IDialogService _dialog;
|
|
|
private readonly ILogger _logger;
|
|
|
+ private List<DeviceDtlWithResultModel> allDeviceAndSchResultList = new List<DeviceDtlWithResultModel>();//所有设备,并带有测试方案
|
|
|
private List<DeviceDtlWithResultModel> allDeviceList = new List<DeviceDtlWithResultModel>();//所有方案
|
|
|
private List<DeviceDtlWithResultModel> conditionDevices = new List<DeviceDtlWithResultModel>();//符合条件的方案
|
|
|
- public ResultQueryViewModel(IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBizTestRecordDtlService iBizTestRecordDtlService, IBizTestRecordService iBizTestRecordService, IBasicPlcTestSchemeDtlService iBasicPlcTestSchemeDtlService, IMapper mapper, IDialogService dialog, ILogger logger)
|
|
|
+ private string selectProjectName;
|
|
|
+ public ResultQueryViewModel(IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBizTestRecordDtlService iBizTestRecordDtlService, IBizTestRecordService iBizTestRecordService, IBasicPlcTestSchemeDtlService iBasicPlcTestSchemeDtlService, IRegionManager regionManager,IMapper mapper, IDialogService dialog, ILogger logger)
|
|
|
{
|
|
|
_iBasicDeviceService = iBasicDeviceService;
|
|
|
_iBasicDeviceKindService = iBasicDeviceKindService;
|
|
@@ -47,6 +51,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
_iBizTestRecordService= iBizTestRecordService;
|
|
|
_iBizTestRecordDtlService= iBizTestRecordDtlService;
|
|
|
_iBasicPlcTestSchemeDtlService = iBasicPlcTestSchemeDtlService;
|
|
|
+ _regionManager = regionManager;
|
|
|
_mapper = mapper;
|
|
|
_dialog = dialog;
|
|
|
_logger = logger;
|
|
@@ -58,6 +63,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
OnLoadCommand = new DelegateCommand(OnLoad);
|
|
|
PdfReportCommand = new DelegateCommand<object>(CreatePdf);
|
|
|
UnqualifiedCommand = new DelegateCommand<object>(RetryTest);
|
|
|
+ DgSelectChangeCommand = new DelegateCommand<object>(DgSelect);
|
|
|
+ GoBackCommand = new DelegateCommand<object>(GoBack);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -130,7 +137,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
/// <param name="obj"></param>
|
|
|
private void CheckDetail(object obj)
|
|
|
{
|
|
|
- //测试方案明细主键ID
|
|
|
+ //设备ID
|
|
|
long id = Convert.ToInt64(obj);
|
|
|
DialogParameters parm = new DialogParameters();
|
|
|
parm.Add("Key", id);
|
|
@@ -214,12 +221,36 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 单元格查看
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="obj"></param>
|
|
|
+ private void DgSelect(object obj)
|
|
|
+ {
|
|
|
+ DeviceDtlWithResultModel dtlSch = (DeviceDtlWithResultModel)obj;
|
|
|
+ if (dtlSch != null)
|
|
|
+ {
|
|
|
+ SchItemResultList = new ObservableCollection<DeviceDtlWithResultModel>(allDeviceAndSchResultList.FindAll(x => ((x.ProjectName == dtlSch.ProjectName) && (x.DeviceName == dtlSch.DeviceName))));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 返回界面
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="obj"></param>
|
|
|
+ /// <exception cref="NotImplementedException"></exception>
|
|
|
+ private void GoBack(object obj)
|
|
|
+ {
|
|
|
+ _regionManager.Regions["ContentRegion"].RequestNavigate("ProjectTestResultView");
|
|
|
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 获取所有项目
|
|
|
/// </summary>
|
|
|
private void GetProjectConfig()
|
|
|
{
|
|
|
+ allDeviceAndSchResultList.Clear();
|
|
|
allDeviceList.Clear();
|
|
|
conditionDevices.Clear();
|
|
|
|
|
@@ -271,6 +302,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
countResult++;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
//测试结果
|
|
|
if(countResult== schDtls.Count)
|
|
@@ -285,6 +317,24 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
}
|
|
|
//加入时间集合
|
|
|
startDateTimes.Add(sch.start_test_time.Value);
|
|
|
+ //把
|
|
|
+ allDeviceAndSchResultList.Add(new DeviceDtlWithResultModel()
|
|
|
+ {
|
|
|
+
|
|
|
+ DeviceId = deviceMsg.device_id,
|
|
|
+ DeviceNo = deviceMsg.device_no,
|
|
|
+ DeviceName = deviceMsg.device_name,
|
|
|
+ DeviceKindName = deviceKind,
|
|
|
+ ProjectName = projectName,
|
|
|
+ // StartTestTime = startDateTimes.Min(),//取最小时间
|
|
|
+ TestResult = testResult,
|
|
|
+ SchemeName = sch.scheme_name,
|
|
|
+ SchemeId = schId,
|
|
|
+ CreateTime = sch.start_test_time.Value,
|
|
|
+ CreateBy=sch.create_by,
|
|
|
+ Remark=sch.remark,
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
//计算这个设备是否所有的方案都通过
|
|
|
if ((deviceCountResult!=0)&&(deviceCountResult == recordMsgs.Count))
|
|
@@ -295,29 +345,34 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
{
|
|
|
deviceTestResult = "不通过";
|
|
|
}
|
|
|
- //这里不添加方案名称
|
|
|
- allDeviceList.Add(new DeviceDtlWithResultModel()
|
|
|
+ //只添加选择的项目
|
|
|
+ if (projectName == selectProjectName)
|
|
|
{
|
|
|
+ //这里不添加方案名称
|
|
|
+ allDeviceList.Add(new DeviceDtlWithResultModel()
|
|
|
+ {
|
|
|
|
|
|
- DeviceId = deviceMsg.device_id,
|
|
|
- DeviceNo = deviceMsg.device_no,
|
|
|
- DeviceName = deviceMsg.device_name,
|
|
|
- DeviceKindName = deviceKind,
|
|
|
- ProjectName = projectName,
|
|
|
- StartTestTime = startDateTimes.Min(),//取最小时间
|
|
|
- TestResult = deviceTestResult
|
|
|
- }); ;
|
|
|
- conditionDevices.Add(new DeviceDtlWithResultModel()
|
|
|
- {
|
|
|
-
|
|
|
- DeviceId = deviceMsg.device_id,
|
|
|
- DeviceNo = deviceMsg.device_no,
|
|
|
- DeviceName = deviceMsg.device_name,
|
|
|
- DeviceKindName = deviceKind,
|
|
|
- ProjectName = projectName,
|
|
|
- StartTestTime = startDateTimes.Min(),//取最小时间
|
|
|
- TestResult = deviceTestResult
|
|
|
- });
|
|
|
+ DeviceId = deviceMsg.device_id,
|
|
|
+ DeviceNo = deviceMsg.device_no,
|
|
|
+ DeviceName = deviceMsg.device_name,
|
|
|
+ DeviceKindName = deviceKind,
|
|
|
+ ProjectName = projectName,
|
|
|
+ StartTestTime = startDateTimes.Min(),//取最小时间
|
|
|
+ TestResult = deviceTestResult
|
|
|
+ });
|
|
|
+ conditionDevices.Add(new DeviceDtlWithResultModel()
|
|
|
+ {
|
|
|
+
|
|
|
+ DeviceId = deviceMsg.device_id,
|
|
|
+ DeviceNo = deviceMsg.device_no,
|
|
|
+ DeviceName = deviceMsg.device_name,
|
|
|
+ DeviceKindName = deviceKind,
|
|
|
+ ProjectName = projectName,
|
|
|
+ StartTestTime = startDateTimes.Min(),//取最小时间
|
|
|
+ TestResult = deviceTestResult
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -577,6 +632,30 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
|
|
|
return invoiceModel;
|
|
|
}
|
|
|
+
|
|
|
+ public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
+ {
|
|
|
+ //编辑
|
|
|
+ var getMsg = navigationContext.Parameters.GetValues<string>("Key");
|
|
|
+ ///值不为空,表示修改,为空表示新增
|
|
|
+ if (getMsg != null)
|
|
|
+ {
|
|
|
+ foreach (var item in getMsg)
|
|
|
+ {
|
|
|
+ selectProjectName = item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
#endregion
|
|
|
#region 命令绑定
|
|
|
|
|
@@ -592,6 +671,9 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
public DelegateCommand<object> UnqualifiedCommand { set; get; }
|
|
|
|
|
|
public DelegateCommand<object> PdfReportCommand { set; get; }
|
|
|
+
|
|
|
+ public DelegateCommand<object> DgSelectChangeCommand { set; get; }
|
|
|
+ public DelegateCommand<object> GoBackCommand { set; get; }
|
|
|
#endregion
|
|
|
|
|
|
#region 数据绑定
|
|
@@ -602,6 +684,13 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
set { deviceResultItemList = value; RaisePropertyChanged(); }
|
|
|
}
|
|
|
|
|
|
+ private ObservableCollection<DeviceDtlWithResultModel> schItemResultList = new ObservableCollection<DeviceDtlWithResultModel>();
|
|
|
+ public ObservableCollection<DeviceDtlWithResultModel> SchItemResultList
|
|
|
+ {
|
|
|
+ get { return schItemResultList; }
|
|
|
+ set { schItemResultList = value; RaisePropertyChanged(); }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 设备编号
|
|
|
/// </summary>
|