|
@@ -67,13 +67,21 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
|
|
|
private void Query(object obj)
|
|
|
{
|
|
|
- var conditions = (from a in allProjectResultPicList
|
|
|
- where (string.IsNullOrEmpty(ProjectNo) ? true : (a.txtProjectNo.Text == ProjectNo))
|
|
|
- && (string.IsNullOrEmpty(ProjectName) ? true : (a.txtName.Text == ProjectName))
|
|
|
- && (string.IsNullOrEmpty(ProjectLeader) ? true : (a.txtProjectLeader.Text == ProjectLeader))
|
|
|
- && (EndTime == string.Empty ? true : (Convert.ToDateTime(a.txtCreateTime.Text) < Convert.ToDateTime(EndTime)) && (Convert.ToDateTime(StartTime) < Convert.ToDateTime(a.txtCreateTime.Text)))
|
|
|
- select a).ToList();
|
|
|
- ProjectResultPicList = new ObservableCollection<DeviceResultCardView>(conditions);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var conditions = (from a in allProjectResultPicList
|
|
|
+ where (string.IsNullOrEmpty(ProjectNo) ? true : (a.txtProjectNo.Text == ProjectNo))
|
|
|
+ && (string.IsNullOrEmpty(ProjectName) ? true : (a.txtName.Text == ProjectName))
|
|
|
+ && (string.IsNullOrEmpty(ProjectLeader) ? true : (a.txtProjectLeader.Text == ProjectLeader))
|
|
|
+ && (EndTime == string.Empty ? true : (Convert.ToDateTime(a.txtCreateTime.Text) < Convert.ToDateTime(EndTime)) && (Convert.ToDateTime(StartTime) < Convert.ToDateTime(a.txtCreateTime.Text)))
|
|
|
+ select a).ToList();
|
|
|
+ ProjectResultPicList = new ObservableCollection<DeviceResultCardView>(conditions);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _logger.LogError(ex.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void OnLoad()
|
|
@@ -97,139 +105,144 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
//所有测试方案
|
|
|
var schlist = _basicPlcTestSchemeService.QueryList();
|
|
|
var schDtoList = _mapper.Map<List<bas_plc_test_scheme>, List<BasicPlcTestSchemeDto>>(schlist);
|
|
|
- //测试记录中的所有设备
|
|
|
- var deviceIds = _iBizTestRecordService.QueryList().Select(X => X.device_id).Distinct();
|
|
|
- foreach (var deviceId in deviceIds)
|
|
|
+ try
|
|
|
{
|
|
|
- List<DateTime> startDateTimes = new List<DateTime>();
|
|
|
- var deviceMsg = _iBasicDeviceService.Find(((int)deviceId));
|
|
|
- if (deviceMsg != null)
|
|
|
+ //测试记录中的所有设备
|
|
|
+ var deviceIds = _iBizTestRecordService.QueryList().Select(X => X.device_id).Distinct();
|
|
|
+ foreach (var deviceId in deviceIds)
|
|
|
{
|
|
|
- string deviceKind = _iBasicDeviceKindService.Find((int)deviceMsg.device_kind_id)?.devicekind_name;
|
|
|
- string projectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name;
|
|
|
- //记录设备下的方案通过个数
|
|
|
- int deviceCountResult = 0;
|
|
|
- string deviceTestResult = string.Empty;
|
|
|
- //查找哦记录有的方案
|
|
|
-
|
|
|
- var recordMsgs = _iBizTestRecordService.FindRecordByDeviceId(deviceId);
|
|
|
- foreach (var sch in recordMsgs)
|
|
|
+ List<DateTime> startDateTimes = new List<DateTime>();
|
|
|
+ var deviceMsg = _iBasicDeviceService.Find(((int)deviceId));
|
|
|
+ if (deviceMsg != null)
|
|
|
{
|
|
|
+ string deviceKind = _iBasicDeviceKindService.Find((int)deviceMsg.device_kind_id)?.devicekind_name;
|
|
|
+ string projectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name;
|
|
|
+ //记录设备下的方案通过个数
|
|
|
+ int deviceCountResult = 0;
|
|
|
+ string deviceTestResult = string.Empty;
|
|
|
+ //查找哦记录有的方案
|
|
|
|
|
|
- long schId = (long)_basicPlcTestSchemeService.FindByNameAndType(sch.scheme_name, deviceKind)?.scheme_id;
|
|
|
- //计算测试结果
|
|
|
- string testResult = string.Empty;
|
|
|
- int countResult = 0;
|
|
|
- var records = _iBizTestRecordDtlService.FindRecordDetailByRecordID(sch.record_id);
|
|
|
- //
|
|
|
- var schDtls = _iBasicPlcTestSchemeDtlService.FindAllBySchId(schId);
|
|
|
- //循环所有测试项,有一个不合格,则整个测试方案不合格
|
|
|
- foreach (var dtl in schDtls)
|
|
|
+ var recordMsgs = _iBizTestRecordService.FindRecordByDeviceId(deviceId);
|
|
|
+ foreach (var sch in recordMsgs)
|
|
|
{
|
|
|
- //选取开始时间最大的一个数据,查看测试结果
|
|
|
- long schDtId = dtl.scheme_dtl_id;
|
|
|
- var findRecords = records.FindAll(x => x.scheme_dtl_id == schDtId).OrderByDescending(x => x.start_test_time).ToArray();
|
|
|
- if (findRecords.Length > 0)
|
|
|
+
|
|
|
+ long schId = (long)_basicPlcTestSchemeService.FindByNameAndType(sch.scheme_name, deviceKind)?.scheme_id;
|
|
|
+ //计算测试结果
|
|
|
+ string testResult = string.Empty;
|
|
|
+ int countResult = 0;
|
|
|
+ var records = _iBizTestRecordDtlService.FindRecordDetailByRecordID(sch.record_id);
|
|
|
+ //
|
|
|
+ var schDtls = _iBasicPlcTestSchemeDtlService.FindAllBySchId(schId);
|
|
|
+ //循环所有测试项,有一个不合格,则整个测试方案不合格
|
|
|
+ foreach (var dtl in schDtls)
|
|
|
{
|
|
|
- int result = (int)findRecords[0]?.test_result.Value;
|
|
|
- if (result == 0)
|
|
|
+ //选取开始时间最大的一个数据,查看测试结果
|
|
|
+ long schDtId = dtl.scheme_dtl_id;
|
|
|
+ var findRecords = records.FindAll(x => x.scheme_dtl_id == schDtId).OrderByDescending(x => x.start_test_time).ToArray();
|
|
|
+ if (findRecords.Length > 0)
|
|
|
{
|
|
|
- testResult = "不通过";
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- countResult++;
|
|
|
+ int result = (int)findRecords[0]?.test_result.Value;
|
|
|
+ if (result == 0)
|
|
|
+ {
|
|
|
+ testResult = "不通过";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ countResult++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //测试结果
|
|
|
+ if (countResult == schDtls.Count)
|
|
|
+ {
|
|
|
+ testResult = "通过";
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算这个设备是否通过
|
|
|
+ if (testResult == "通过")
|
|
|
+ {
|
|
|
+ deviceCountResult++;
|
|
|
+ }
|
|
|
+ //加入时间集合
|
|
|
+ startDateTimes.Add(sch.start_test_time.Value);
|
|
|
}
|
|
|
- //测试结果
|
|
|
- if (countResult == schDtls.Count)
|
|
|
+ //计算这个设备是否所有的方案都通过
|
|
|
+ if ((deviceCountResult != 0) && (deviceCountResult == recordMsgs.Count))
|
|
|
{
|
|
|
- testResult = "通过";
|
|
|
+ deviceTestResult = "通过";
|
|
|
}
|
|
|
-
|
|
|
- //计算这个设备是否通过
|
|
|
- if (testResult == "通过")
|
|
|
+ else
|
|
|
{
|
|
|
- deviceCountResult++;
|
|
|
+ deviceTestResult = "不通过";
|
|
|
}
|
|
|
- //加入时间集合
|
|
|
- startDateTimes.Add(sch.start_test_time.Value);
|
|
|
- }
|
|
|
- //计算这个设备是否所有的方案都通过
|
|
|
- if ((deviceCountResult != 0) && (deviceCountResult == recordMsgs.Count))
|
|
|
- {
|
|
|
- deviceTestResult = "通过";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- deviceTestResult = "不通过";
|
|
|
+ //这里不添加方案名称
|
|
|
+ allDeviceList.Add(new DeviceDtlWithResultModel()
|
|
|
+ {
|
|
|
+ ProjectId = deviceMsg.project_id,
|
|
|
+ DeviceId = deviceMsg.device_id,
|
|
|
+ DeviceNo = deviceMsg.device_no,
|
|
|
+ DeviceName = deviceMsg.device_name,
|
|
|
+ DeviceKindName = deviceKind,
|
|
|
+ ProjectName = projectName,
|
|
|
+ StartTestTime = startDateTimes.Min(),//取最小时间
|
|
|
+ TestResult = deviceTestResult
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
- //这里不添加方案名称
|
|
|
- allDeviceList.Add(new DeviceDtlWithResultModel()
|
|
|
- {
|
|
|
- ProjectId= deviceMsg.project_id,
|
|
|
- DeviceId = deviceMsg.device_id,
|
|
|
- DeviceNo = deviceMsg.device_no,
|
|
|
- DeviceName = deviceMsg.device_name,
|
|
|
- DeviceKindName = deviceKind,
|
|
|
- ProjectName = projectName,
|
|
|
- StartTestTime = startDateTimes.Min(),//取最小时间
|
|
|
- TestResult = deviceTestResult
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- //所有新项目
|
|
|
- List<string> projectNames = allDeviceList.Select(x => x.ProjectName).Distinct().ToList();
|
|
|
- foreach (var project in projectNames)
|
|
|
- {
|
|
|
- int projectId =(int) allDeviceList?.FirstOrDefault(x => x.ProjectName == project)?.ProjectId;
|
|
|
- //总设备
|
|
|
- int totalDevice=(int)_iBasicDeviceService.QueryList()?.FindAll(x=>x.project_id== projectId).Count();
|
|
|
- //已测试设备数
|
|
|
- int deviceTestCount =(int)allDeviceList?.FindAll(x => x.ProjectName == project)?.Select(x => x.DeviceId)?.Distinct().Count();
|
|
|
+ //所有新项目
|
|
|
+ List<string> projectNames = allDeviceList.Select(x => x.ProjectName).Distinct().ToList();
|
|
|
+ foreach (var project in projectNames)
|
|
|
+ {
|
|
|
+ int projectId = (int)allDeviceList?.FirstOrDefault(x => x.ProjectName == project)?.ProjectId;
|
|
|
+ //总设备
|
|
|
+ int totalDevice = (int)_iBasicDeviceService.QueryList()?.FindAll(x => x.project_id == projectId).Count();
|
|
|
+ //已测试设备数
|
|
|
+ int deviceTestCount = (int)allDeviceList?.FindAll(x => x.ProjectName == project)?.Select(x => x.DeviceId)?.Distinct().Count();
|
|
|
|
|
|
- int passCount=(int)allDeviceList?.FindAll(x => (x.ProjectName == project)&&(x.TestResult=="通过")).Count;
|
|
|
- int noPassCount = (int)allDeviceList?.FindAll(x => (x.ProjectName == project) && (x.TestResult == "不通过")).Count;
|
|
|
- //添加卡片
|
|
|
- DeviceResultCardView deviceCard = new DeviceResultCardView();
|
|
|
- //创建时间
|
|
|
- deviceCard.txtCreateTime.Text = _iBasicProjectService.FindByProjectName(project)?.create_time.ToString();
|
|
|
- deviceCard.txtName.Text = project;
|
|
|
- deviceCard.txtProjectNo.Text = _iBasicProjectService.FindByProjectName(project)?.project_no;
|
|
|
- deviceCard.txtProjectLeader.Text = _iBasicProjectService.FindByProjectName(project)?.project_leader;
|
|
|
- //总设备数量
|
|
|
- deviceCard.txtDeviceCount.Text = totalDevice.ToString()+" 台";
|
|
|
- deviceCard.txtTestCount.Text = deviceTestCount.ToString()+" 台";
|
|
|
- deviceCard.txtPassCount.Text = passCount.ToString()+" 台";
|
|
|
- deviceCard.txtNoPassCount.Text = noPassCount.ToString() + " 台";
|
|
|
- //赋值
|
|
|
- allProjectResultPicList.Add(deviceCard);
|
|
|
- }
|
|
|
- foreach (var item in allProjectResultPicList)
|
|
|
- {
|
|
|
- ProjectResultPicList.Add(item);
|
|
|
- }
|
|
|
- //计算行数
|
|
|
- if (projectNames.Count % eachColumNum == 0)
|
|
|
- {
|
|
|
- RowsCount = projectNames.Count / eachColumNum;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- RowsCount = projectNames.Count / eachColumNum + 1;
|
|
|
+ int passCount = (int)allDeviceList?.FindAll(x => (x.ProjectName == project) && (x.TestResult == "通过")).Count;
|
|
|
+ int noPassCount = (int)allDeviceList?.FindAll(x => (x.ProjectName == project) && (x.TestResult == "不通过")).Count;
|
|
|
+ //添加卡片
|
|
|
+ DeviceResultCardView deviceCard = new DeviceResultCardView();
|
|
|
+ //创建时间
|
|
|
+ deviceCard.txtCreateTime.Text = _iBasicProjectService.FindByProjectName(project)?.create_time.ToString();
|
|
|
+ deviceCard.txtName.Text = project;
|
|
|
+ deviceCard.txtProjectNo.Text = _iBasicProjectService.FindByProjectName(project)?.project_no;
|
|
|
+ deviceCard.txtProjectLeader.Text = _iBasicProjectService.FindByProjectName(project)?.project_leader;
|
|
|
+ //总设备数量
|
|
|
+ deviceCard.txtDeviceCount.Text = totalDevice.ToString() + " 台";
|
|
|
+ deviceCard.txtTestCount.Text = deviceTestCount.ToString() + " 台";
|
|
|
+ deviceCard.txtPassCount.Text = passCount.ToString() + " 台";
|
|
|
+ deviceCard.txtNoPassCount.Text = noPassCount.ToString() + " 台";
|
|
|
+ //赋值
|
|
|
+ allProjectResultPicList.Add(deviceCard);
|
|
|
+ }
|
|
|
+ foreach (var item in allProjectResultPicList)
|
|
|
+ {
|
|
|
+ ProjectResultPicList.Add(item);
|
|
|
+ }
|
|
|
+ //计算行数
|
|
|
+ if (projectNames.Count % eachColumNum == 0)
|
|
|
+ {
|
|
|
+ RowsCount = projectNames.Count / eachColumNum;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ RowsCount = projectNames.Count / eachColumNum + 1;
|
|
|
+ }
|
|
|
+ if (RowsCount < 2)
|
|
|
+ {
|
|
|
+ RowsCount = 2;
|
|
|
+ }
|
|
|
}
|
|
|
- if (RowsCount < 2)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- RowsCount = 2;
|
|
|
+ _logger.LogError(ex.ToString());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
#endregion
|
|
|
|