150 lines
6.0 KiB
C#
150 lines
6.0 KiB
C#
|
using DevExpress.Spreadsheet;
|
|||
|
using DevExpress.Utils.Menu;
|
|||
|
using DevExpress.XtraSpreadsheet.Menu;
|
|||
|
using DeviceRepair.Models;
|
|||
|
using DeviceRepair.Models.Enum;
|
|||
|
using DeviceRepairAndOptimization.Common.NpoiExtend;
|
|||
|
|
|||
|
namespace DeviceRepairAndOptimization.Biz.PreserveTemplate
|
|||
|
{
|
|||
|
public class Template_AM_01 : BaseTemplate
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 设备型号
|
|||
|
/// </summary>
|
|||
|
internal readonly string EquipmentModelAddress = "[C,1]";
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 设备编号
|
|||
|
/// </summary>
|
|||
|
internal readonly string EquipmentNumberAddress = "[E,1]";
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 年月
|
|||
|
/// </summary>
|
|||
|
internal readonly string YearAndMonthAddress = "[H,1]";
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 班次/频次
|
|||
|
/// </summary>
|
|||
|
internal readonly string BanciColumnAddress = "G";
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 日期
|
|||
|
/// </summary>
|
|||
|
internal readonly string DayColumnAddress = "H";
|
|||
|
|
|||
|
/// 正文
|
|||
|
/// </summary>
|
|||
|
internal override SpreadsheetPopupMenu popupContent
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_popupContent == null)
|
|||
|
{
|
|||
|
_popupContent = new SpreadsheetPopupMenu()
|
|||
|
{
|
|||
|
Caption = "正文",
|
|||
|
Items =
|
|||
|
{
|
|||
|
new DXMenuItem("正常",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "√"); }),
|
|||
|
new DXMenuItem("有问题",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "△", EnumMaintenanceOperationType.Write, true); }),
|
|||
|
new DXMenuItem("不适用或无生产",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "N/A"); }),
|
|||
|
new DXMenuItem("清空",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "", EnumMaintenanceOperationType.Clear); }),
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
return _popupContent;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public Template_AM_01() : base()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 初始化对象
|
|||
|
/// </summary>
|
|||
|
/// <param name="ws">Worksheet 控件对象</param>
|
|||
|
/// <param name="CurrentType">当前计划类型</param>
|
|||
|
/// <param name="EditColValue">当前编辑列</param>
|
|||
|
public Template_AM_01(Worksheet ws) : base(ws)
|
|||
|
{
|
|||
|
#region 设备型号
|
|||
|
DeviceSpecification.Add(SheetExtend.AddressToIndex(EquipmentModelAddress));
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 设备型号
|
|||
|
EquipmentID.Add(SheetExtend.AddressToIndex(EquipmentNumberAddress));
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 年检表 年/月
|
|||
|
YearAndMonth.Add(SheetExtend.AddressToIndex(YearAndMonthAddress));
|
|||
|
#endregion
|
|||
|
|
|||
|
int MonthStartColIndex = SheetExtend.ColumnIndexFromLetter(DayColumnAddress);
|
|||
|
int MonthEndColIndex = MonthStartColIndex + 30;
|
|||
|
int BanciColIndex = SheetExtend.ColumnIndexFromLetter(BanciColumnAddress);
|
|||
|
|
|||
|
for (int rowIndex = 2; rowIndex < LastUsedRowIndex; rowIndex++)
|
|||
|
{
|
|||
|
#region 空行判断
|
|||
|
Cell FirstCell = worksheet.Cells[rowIndex, 0];
|
|||
|
if (FirstCell.Value.IsEmpty && !FirstCell.IsMerged)
|
|||
|
break;
|
|||
|
#endregion
|
|||
|
|
|||
|
for (int colIndex = MonthStartColIndex; colIndex <= MonthEndColIndex; colIndex++)
|
|||
|
{
|
|||
|
Cell cell = worksheet.Cells[rowIndex, colIndex];
|
|||
|
Cell BanciCell = worksheet[rowIndex, BanciColIndex];
|
|||
|
|
|||
|
EnumMaintenanceBanciType Banci;
|
|||
|
switch ((BanciCell?.Value?.TextValue ?? "").Trim())
|
|||
|
{
|
|||
|
case "早":
|
|||
|
Banci = EnumMaintenanceBanciType.Morning;
|
|||
|
break;
|
|||
|
case "中":
|
|||
|
Banci = EnumMaintenanceBanciType.Noon;
|
|||
|
break;
|
|||
|
case "夜":
|
|||
|
Banci = EnumMaintenanceBanciType.Night;
|
|||
|
break;
|
|||
|
case "周":
|
|||
|
Banci = EnumMaintenanceBanciType.Week;
|
|||
|
break;
|
|||
|
default:
|
|||
|
Banci = EnumMaintenanceBanciType.None;
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
Cell FirstDataCell = worksheet[FirstCell.RowIndex, FirstCell.ColumnIndex];
|
|||
|
if (FirstCell.IsMerged)
|
|||
|
{
|
|||
|
//获取主单元格位置
|
|||
|
int PreRowIndex = (FirstCell.GetMergedRanges()[0]).TopRowIndex;
|
|||
|
int PreColumnIndex = (FirstCell.GetMergedRanges()[0]).LeftColumnIndex;
|
|||
|
FirstDataCell = worksheet[PreRowIndex, PreColumnIndex];
|
|||
|
}
|
|||
|
|
|||
|
if ((FirstDataCell?.Value?.TextValue ?? "").Trim() == "其他异常处理")
|
|||
|
{
|
|||
|
// 异常备注:
|
|||
|
ExceptionDescription.Add(new SheetDataItem { RowIndex = rowIndex, ColumnIndex = 1, MaintenanceType = EnumMaintenanceType.Daily, MaintenanceTypeValue = worksheet.Cells[1, colIndex].Value.NumericValue + "", BanciType = Banci });
|
|||
|
|
|||
|
// 保养人签字
|
|||
|
Operation.Add(new SheetDataItem { RowIndex = rowIndex, ColumnIndex = colIndex, MaintenanceType = EnumMaintenanceType.Daily, MaintenanceTypeValue = worksheet.Cells[1, colIndex].Value.NumericValue + "", BanciType = Banci });
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// 正文
|
|||
|
Content.Add(new SheetDataItem { RowIndex = rowIndex, ColumnIndex = colIndex, MaintenanceType = EnumMaintenanceType.Daily, MaintenanceTypeValue = worksheet.Cells[1, colIndex].Value.NumericValue + "", BanciType = Banci });
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|