| | |
| | | { |
| | | var details = new List<WmsConfigDeviceWarning>(); |
| | | int index = dataStartLine;//模版列名开始行 |
| | | decimal offset = 0.0M; |
| | | decimal intValue = 0.0M; |
| | | string my_DeviceAreaCode = ""; |
| | | foreach (System.Data.DataRow row in dataTable.Rows) |
| | | { |
| | | index++; |
| | |
| | | _WarningContent = row["报警内容"]?.ToString() ; |
| | | #endregion |
| | | |
| | | if (!string.IsNullOrEmpty(my_DeviceAreaCode) && _DeviceAreaCode != my_DeviceAreaCode) |
| | | { |
| | | throw Oops.Oh($"第{index}行一次只能导入一个设备区域!"); |
| | | } |
| | | my_DeviceAreaCode = _DeviceAreaCode; |
| | | |
| | | #region 验证 |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | if(!string.IsNullOrEmpty(_WarningCode)) |
| | | { |
| | | addItem.WarningCode = (string)(_WarningCode.Trim()); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_WarningContent)) |
| | | { |
| | | addItem.WarningContent = (string)(_WarningContent.Trim()); |
| | | } |
| | | #endregion |
| | | |
| | | addItem.WarningCode = SysHelper.GetDBForDeviceWarning(_DeviceAreaCode) + "|" + intValue.ToString("0.0"); |
| | | |
| | | if (offset == 0.7M) |
| | | { |
| | | offset = 0.0M; |
| | | intValue += 0.3M; |
| | | } |
| | | else |
| | | { |
| | | offset += 0.1M; |
| | | intValue += 0.1M; |
| | | } |
| | | |
| | | |
| | | details.Add(addItem); |
| | |
| | | |
| | | //根据单独校验验证表格中中是否已存在相同数据 |
| | | var existExcelItemForSingle_WarningCode = inputs.GroupBy(g => new { g.WarningCode}).Where(g => g.Count() > 1).ToList(); |
| | | if(existExcelItemForSingle_WarningCode != null && existExcelItemForSingle_WarningCode.Count > 0){ |
| | | if (existExcelItemForSingle_WarningCode != null && existExcelItemForSingle_WarningCode.Count > 0) |
| | | { |
| | | var item= existExcelItemForSingle_WarningCode.First().ToList().First(); |
| | | throw Oops.Oh($"验证失败,导入的表格中,报警代码[" + item.WarningCode + "]已重复存在"); |
| | | } |