41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using Cowain.Preheat.Common.Converter;
|
|
using Cowain.Preheat.Model.Entity;
|
|
using CsvHelper;
|
|
using CsvHelper.Configuration;
|
|
using CsvHelper.TypeConversion;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Cowain.Preheat.Common.CsvMap
|
|
{
|
|
public class MesDataMapConverter : DefaultTypeConverter
|
|
{
|
|
private static readonly SendFlagConvertor _converter = new SendFlagConvertor();
|
|
|
|
public override string ConvertToString(object value, IWriterRow row, MemberMapData memberMapData)
|
|
{
|
|
// 使用IValueConverter转换逻辑
|
|
return _converter.Convert(value, typeof(string), null, CultureInfo.InvariantCulture) as string;
|
|
}
|
|
}
|
|
public sealed class MesDataMap : ClassMap<MesDataEntity>
|
|
{
|
|
public MesDataMap()
|
|
{
|
|
Map(m => m.CreateTime).Name("创建时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); ;
|
|
Map(m => m.SendTime).Name("发送时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); ;
|
|
Map(m => m.RecvTime).Name("接收时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); ;
|
|
Map(m => m.Content).Name("发送信息");
|
|
Map(m => m.RecvContent).Name("接收信息");
|
|
Map(m => m.BatteryCode).Name("电芯条码");
|
|
Map(m => m.SendFlag)
|
|
.Name("发送状态")
|
|
.TypeConverter<MesDataMapConverter>();
|
|
}
|
|
}
|
|
}
|