27 changed files with 14800 additions and 31 deletions
@ -0,0 +1,84 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Dtos |
|||
{ |
|||
public class ImportNoteCreateDto |
|||
{ |
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
public virtual string Vin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物流配货顺序号
|
|||
/// </summary>
|
|||
public virtual int HostSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号 #
|
|||
/// </summary>
|
|||
public virtual string SerialNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型代码
|
|||
/// </summary>
|
|||
public virtual string VehicleModelCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型名称
|
|||
/// </summary>
|
|||
public virtual string VehicleModelName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上级产品系列(规格说明)
|
|||
/// </summary>
|
|||
public virtual string SpecDesc { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型
|
|||
/// </summary>
|
|||
public virtual string VehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 公告车型
|
|||
/// </summary>
|
|||
public virtual string AfficheVehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 特殊车标识
|
|||
/// </summary>
|
|||
public virtual string SpecialCarLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? PaintOfflineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? OnlineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备注
|
|||
/// </summary>
|
|||
public virtual string Remark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
public virtual DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人
|
|||
/// </summary>
|
|||
public virtual string CreatePerson { get; set; } |
|||
|
|||
public virtual DateTime? ImportTime { get; set; } |
|||
|
|||
public virtual string ImportPerson { get; set; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,127 @@ |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Magicodes.ExporterAndImporter.Excel; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Dtos |
|||
{ |
|||
/// <summary>
|
|||
/// 导入记录表
|
|||
/// </summary>
|
|||
[ExcelExporter(Name = "导入记录表V2", AutoFitAllColumn = true, MaxRowNumberOnASheet = 50000)] //一个Sheet最大允许的行数,设置了之后将输出多个Sheet
|
|||
[Serializable] |
|||
public class ImportNoteDto |
|||
{ |
|||
[ExporterHeader(IsIgnore = true)] |
|||
[ImporterHeader(IsIgnore = true)] |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "底盘号")] |
|||
[ImporterHeader(Name = "底盘号")] |
|||
public virtual string Vin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物流配货顺序号
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "物流配货顺序号")] |
|||
[ImporterHeader(Name = "物流配货顺序号")] |
|||
public virtual int HostSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号 #
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "#")] |
|||
[ImporterHeader(Name = "#")] |
|||
public virtual string SerialNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型代码
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "车型代码")] |
|||
[ImporterHeader(Name = "车型代码")] |
|||
public virtual string VehicleModelCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型名称
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "车型名称")] |
|||
[ImporterHeader(Name = "车型名称")] |
|||
public virtual string VehicleModelName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上级产品系列(规格说明)
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "上级产品系列")] |
|||
[ImporterHeader(Name = "上级产品系列")] |
|||
public virtual string SpecDesc { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "车型")] |
|||
[ImporterHeader(Name = "车型")] |
|||
public virtual string VehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 公告车型
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "公告车型")] |
|||
[ImporterHeader(Name = "公告车型")] |
|||
public virtual string AfficheVehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 特殊车标识
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "特殊车标识")] |
|||
[ImporterHeader(Name = "特殊车标识")] |
|||
public virtual string SpecialCarLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "涂装下线EA1", Format = "yyyy-MM-dd HH:mm:ss")] |
|||
[ImporterHeader(Name = "涂装下线EA1", Format = "yyyy-MM-dd HH:mm:ss")] |
|||
public virtual DateTime? PaintOfflineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "总装上线EA2", Format = "yyyy-MM-dd HH:mm:ss")] |
|||
[ImporterHeader(Name = "总装上线EA2", Format = "yyyy-MM-dd HH:mm:ss")] |
|||
public virtual DateTime? OnlineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备注
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "备注")] |
|||
[ImporterHeader(Name = "备注")] |
|||
public virtual string Remark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "创建时间", Format = "yyyy-MM-dd HH:mm:ss")] |
|||
[ImporterHeader(Name = "创建时间", Format = "yyyy-MM-dd HH:mm:ss")] |
|||
public virtual DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人
|
|||
/// </summary>
|
|||
[ExporterHeader(DisplayName = "创建人")] |
|||
[ImporterHeader(Name = "创建人")] |
|||
public virtual string CreatePerson { get; set; } |
|||
|
|||
[ExporterHeader(IsIgnore = true)] |
|||
[ImporterHeader(IsIgnore = true)] |
|||
public virtual DateTime? ImportTime { get; set; } |
|||
|
|||
[ExporterHeader(IsIgnore = true)] |
|||
[ImporterHeader(IsIgnore = true)] |
|||
public virtual string ImportPerson { get; set; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,84 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Dtos |
|||
{ |
|||
public class ImportNoteHisCreateDto |
|||
{ |
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
public virtual string Vin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物流配货顺序号
|
|||
/// </summary>
|
|||
public virtual int HostSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号 #
|
|||
/// </summary>
|
|||
public virtual string SerialNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型代码
|
|||
/// </summary>
|
|||
public virtual string VehicleModelCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型名称
|
|||
/// </summary>
|
|||
public virtual string VehicleModelName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上级产品系列(规格说明)
|
|||
/// </summary>
|
|||
public virtual string SpecDesc { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型
|
|||
/// </summary>
|
|||
public virtual string VehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 公告车型
|
|||
/// </summary>
|
|||
public virtual string AfficheVehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 特殊车标识
|
|||
/// </summary>
|
|||
public virtual string SpecialCarLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? PaintOfflineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? OnlineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备注
|
|||
/// </summary>
|
|||
public virtual string Remark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
public virtual DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人
|
|||
/// </summary>
|
|||
public virtual string CreatePerson { get; set; } |
|||
|
|||
public virtual DateTime? ImportTime { get; set; } |
|||
|
|||
public virtual string ImportPerson { get; set; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,86 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Dtos |
|||
{ |
|||
public class ImportNoteHisDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
public virtual string Vin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物流配货顺序号
|
|||
/// </summary>
|
|||
public virtual int HostSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号 #
|
|||
/// </summary>
|
|||
public virtual string SerialNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型代码
|
|||
/// </summary>
|
|||
public virtual string VehicleModelCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型名称
|
|||
/// </summary>
|
|||
public virtual string VehicleModelName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上级产品系列(规格说明)
|
|||
/// </summary>
|
|||
public virtual string SpecDesc { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型
|
|||
/// </summary>
|
|||
public virtual string VehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 公告车型
|
|||
/// </summary>
|
|||
public virtual string AfficheVehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 特殊车标识
|
|||
/// </summary>
|
|||
public virtual string SpecialCarLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? PaintOfflineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? OnlineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备注
|
|||
/// </summary>
|
|||
public virtual string Remark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
public virtual DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人
|
|||
/// </summary>
|
|||
public virtual string CreatePerson { get; set; } |
|||
|
|||
public virtual DateTime? ImportTime { get; set; } |
|||
|
|||
public virtual string ImportPerson { get; set; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,81 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using WY.NewJit.Common; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Dtos |
|||
{ |
|||
public class ImportNoteInputDto : PagedAndSortedBase |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
public virtual string Vin { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 车型代码
|
|||
/// </summary>
|
|||
public virtual string VehicleModelCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间起
|
|||
/// </summary>
|
|||
public virtual DateTime? PaintOfflineTimeBegin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间止
|
|||
/// </summary>
|
|||
public virtual DateTime? PaintOfflineTimeEnd { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间起
|
|||
/// </summary>
|
|||
public virtual DateTime? OnlineTimeBegin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间止
|
|||
/// </summary>
|
|||
public virtual DateTime? OnlineTimeEnd { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号起
|
|||
/// </summary>
|
|||
public virtual string SerialNumBegin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号止
|
|||
/// </summary>
|
|||
public virtual string SerialNumEnd { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 流水号起
|
|||
/// </summary>
|
|||
public virtual int? HostSNBegin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 流水号止
|
|||
/// </summary>
|
|||
public virtual int? HostSNEnd { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 生产线:A/B
|
|||
/// </summary>
|
|||
public virtual string ProductLine { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间起
|
|||
/// </summary>
|
|||
public virtual DateTime? CreateTimeBegin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间止
|
|||
/// </summary>
|
|||
public virtual DateTime? CreateTimeEnd { get; set; } |
|||
|
|||
public virtual DateTime? ImportTimeBegin { get; set; } |
|||
public virtual DateTime? ImportTimeEnd { get; set; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,70 @@ |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using WY.NewJit.EdiReceive.Dtos; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Interfaces |
|||
{ |
|||
public interface IImportNoteAppService : IApplicationService |
|||
{ |
|||
#region 接口方法
|
|||
|
|||
/// 根据筛选条件获取分页实体列表
|
|||
/// </summary>
|
|||
/// <param name="input">输入查询条件</param>
|
|||
/// <param name="page">输入分页条件</param>
|
|||
/// <returns>返回符合条件的排序分页列表</returns>
|
|||
Task<PagedResultDto<ImportNoteDto>> GetListAsync(ImportNoteInputDto input); |
|||
|
|||
/// <summary>
|
|||
/// 按主键获取唯一实体
|
|||
/// </summary>
|
|||
/// <param name="id">主键</param>
|
|||
/// <returns>实体信息</returns>
|
|||
Task<ObjectResultDto<ImportNoteDto>> GetAsync(Guid id); |
|||
|
|||
/// <summary>
|
|||
/// 添加实体
|
|||
/// </summary>
|
|||
/// <param name="input">添加内容</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
Task<ObjectResultDto<Guid>> CreateAsync(ImportNoteCreateDto input); |
|||
|
|||
/// <summary>
|
|||
/// 修改实体
|
|||
/// </summary>
|
|||
/// <param name="id">更新主键</param>
|
|||
/// <param name="input">修改内容</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
Task<ObjectResultDto> UpdateAsync(Guid id, ImportNoteCreateDto input); |
|||
|
|||
/// <summary>
|
|||
/// 删除实体
|
|||
/// </summary>
|
|||
/// <param name="id">删除主键</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
Task<ObjectResultDto> DeleteAsync(string id); |
|||
|
|||
/// <summary>
|
|||
/// 导出信息
|
|||
/// </summary>
|
|||
/// <param name="input">导出查询条件</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
Task<ObjectResultDto<string>> ExportAsync(ImportNoteInputDto input); |
|||
|
|||
/// <summary>
|
|||
/// 导入信息
|
|||
/// </summary>
|
|||
/// <param name="files">导入文件流</param>
|
|||
/// <param name="forceExecute">是否强制执行</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files, bool forceExecute = false); |
|||
#endregion
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,563 @@ |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Magicodes.ExporterAndImporter.Core.Models; |
|||
using Magicodes.ExporterAndImporter.Excel; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Logging; |
|||
using Shouldly; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Uow; |
|||
using WY.NewJit.Common; |
|||
using WY.NewJit.EdiReceive.Dtos; |
|||
using WY.NewJit.EdiReceive.Entitys; |
|||
using WY.NewJit.EdiReceive.Interfaces; |
|||
using WY.NewJit.EdiReceive.Services; |
|||
using WY.NewJit.EntityFrameworkCore; |
|||
using WY.NewJit.MsgBaseData; |
|||
using WY.NewJit.MsgCheck; |
|||
|
|||
namespace WY.NewJit.EdiReceive |
|||
{ |
|||
/// <summary>
|
|||
/// 零件管理应用服务实现
|
|||
/// </summary>
|
|||
[Microsoft.AspNetCore.Mvc.Route("api/newjit/import-note")] |
|||
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.报文接收)] |
|||
public class ImportNoteAppService : ApplicationService, IImportNoteAppService |
|||
{ |
|||
#region 成员
|
|||
/// <summary>
|
|||
/// 零件仓储
|
|||
/// </summary>
|
|||
private readonly IRepository<ImportNote, Guid> _importNoteRepository; |
|||
|
|||
/// <summary>
|
|||
/// 日志
|
|||
/// </summary>
|
|||
private ILogger<ImportNoteAppService> _logger; |
|||
|
|||
/// <summary>
|
|||
/// Dapper仓储
|
|||
/// </summary>
|
|||
private readonly NewJitDapperRepository _newJitDapperRepository; |
|||
|
|||
/// <summary>
|
|||
/// BLOB存储
|
|||
/// </summary>
|
|||
private readonly IBlobContainer<OurFileContainer> _blobContainer; |
|||
|
|||
/// <summary>
|
|||
/// 字典领域服务
|
|||
/// </summary>
|
|||
private readonly DicDomainService _dicDomainService; |
|||
|
|||
private readonly EdiParseDomainSrvV2 _ediParseDomainService; |
|||
|
|||
/// <summary>
|
|||
/// 配置
|
|||
/// </summary>
|
|||
private readonly Microsoft.Extensions.Configuration.IConfiguration _configuration; |
|||
|
|||
/// <summary>
|
|||
/// 错误信息前缀
|
|||
/// </summary>
|
|||
private string _errorMessagePrefix |
|||
{ |
|||
get |
|||
{ |
|||
return System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."; |
|||
} |
|||
} |
|||
|
|||
private readonly IUnitOfWorkManager _unitOfWorkManager; |
|||
|
|||
|
|||
|
|||
#endregion
|
|||
|
|||
/// <summary>
|
|||
/// 构造函数
|
|||
/// </summary>
|
|||
public ImportNoteAppService( |
|||
IRepository<ImportNote, Guid> importNoteRepository, |
|||
ILogger<ImportNoteAppService> logger, |
|||
NewJitDapperRepository newJitDapperRepository, |
|||
IBlobContainer<OurFileContainer> blobContainer, |
|||
DicDomainService dicDomainService, |
|||
EdiParseDomainSrvV2 ediParseDomainService, |
|||
Microsoft.Extensions.Configuration.IConfiguration configuration, |
|||
IUnitOfWorkManager unitOfWorkManager) |
|||
{ |
|||
_importNoteRepository = importNoteRepository; |
|||
_logger = logger; |
|||
_newJitDapperRepository = newJitDapperRepository; |
|||
_blobContainer = blobContainer; |
|||
_dicDomainService = dicDomainService; |
|||
_ediParseDomainService = ediParseDomainService; |
|||
_configuration = configuration; |
|||
_unitOfWorkManager = unitOfWorkManager; |
|||
} |
|||
|
|||
#region 私有方法
|
|||
private static string GetWhere(ImportNoteInputDto input) |
|||
{ |
|||
string where = ""; |
|||
//if (input.Factory.HasValue())
|
|||
//{
|
|||
// where += string.Format(" and Factory = '{0}'", input.Factory);
|
|||
//}
|
|||
if (input.Vin.HasValue()) |
|||
{ |
|||
where += string.Format(" and Vin = '{0}'", input.Vin); |
|||
} |
|||
if (input.VehicleModelCode.HasValue()) |
|||
{ |
|||
where += string.Format(" and VehicleModelCode = '{0}'", input.VehicleModelCode); |
|||
} |
|||
if (input.PaintOfflineTimeBegin.HasValue()) |
|||
{ |
|||
where += string.Format(" and PaintOfflineTime >= '{0}'", input.PaintOfflineTimeBegin?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.PaintOfflineTimeEnd.HasValue()) |
|||
{ |
|||
where += string.Format(" and PaintOfflineTime <= '{0}'", input.PaintOfflineTimeEnd?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.OnlineTimeBegin.HasValue()) |
|||
{ |
|||
where += string.Format(" and OnlineTime >= '{0}'", input.OnlineTimeBegin?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.OnlineTimeEnd.HasValue()) |
|||
{ |
|||
where += string.Format(" and OnlineTime <= '{0}'", input.OnlineTimeEnd?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.OnlineTimeBegin.HasValue()) |
|||
{ |
|||
where += string.Format(" and OnlineTime >= '{0}'", input.OnlineTimeBegin?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.OnlineTimeEnd.HasValue()) |
|||
{ |
|||
where += string.Format(" and OnlineTime <= '{0}'", input.OnlineTimeEnd?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.SerialNumBegin.HasValue()) |
|||
{ |
|||
where += string.Format(" and SerialNum >= '{0}'", input.SerialNumBegin); |
|||
} |
|||
if (input.SerialNumEnd.HasValue()) |
|||
{ |
|||
where += string.Format(" and SerialNum <= '{0}'", input.SerialNumEnd); |
|||
} |
|||
if (input.HostSNBegin.HasValue()) |
|||
{ |
|||
where += string.Format(" and HostSN >= '{0}'", input.HostSNBegin); |
|||
} |
|||
if (input.HostSNEnd.HasValue()) |
|||
{ |
|||
where += string.Format(" and HostSN <= '{0}'", input.HostSNEnd); |
|||
} |
|||
//if (input.ProductLine.HasValue())
|
|||
//{
|
|||
// where += string.Format(" and ProductLine = '{0}'", input.ProductLine);
|
|||
//}
|
|||
if (input.CreateTimeBegin.HasValue()) |
|||
{ |
|||
where += string.Format(" and CreateTime >= '{0}'", input.CreateTimeBegin?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.CreateTimeEnd.HasValue()) |
|||
{ |
|||
where += string.Format(" and CreateTime <= '{0}'", input.CreateTimeEnd?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.ImportTimeBegin.HasValue()) |
|||
{ |
|||
where += string.Format(" and ImportTime >= '{0}'", input.ImportTimeBegin?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
if (input.ImportTimeEnd.HasValue()) |
|||
{ |
|||
where += string.Format(" and ImportTime <= '{0}'", input.ImportTimeEnd?.ToString("yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
return where; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 取单表记录总数
|
|||
/// </summary>
|
|||
/// <param name="tableName"></param>
|
|||
/// <param name="where"></param>
|
|||
/// <returns></returns>
|
|||
private async Task<int> GetEntityCountAsync(string tableName, string where) |
|||
{ |
|||
string sql = $"select count(*) from {tableName} where 1=1 {where}"; |
|||
var ret = await _newJitDapperRepository.GetSingleBySqlAsync<int>(sql); |
|||
return ret; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 取单表当前页数据
|
|||
/// </summary>
|
|||
/// <typeparam name="T"></typeparam>
|
|||
/// <param name="tableName"></param>
|
|||
/// <param name="where"></param>
|
|||
/// <param name="orderFieldName"></param>
|
|||
/// <param name="pageSize"></param>
|
|||
/// <param name="pageIndex"></param>
|
|||
/// <returns></returns>
|
|||
private async Task<List<T>> GetEntityListAsync<T>(string tableName, string where, string orderFieldName, int pageSize, int pageIndex) |
|||
{ |
|||
int takeNum = pageSize; |
|||
int skipNum = (pageIndex - 1) * pageSize; |
|||
string sql = $"select * from {tableName} where 1=1 {where} order by {orderFieldName} offset {skipNum} rows fetch next {takeNum} rows only"; |
|||
var ret = await _newJitDapperRepository.GetListBySqlAsync<T>(sql); |
|||
return ret; |
|||
} |
|||
|
|||
private async Task<List<T>> GetEntityListFromToAsync<T>(string tableName, string where, string orderFieldName, int skipNum, int takeNum) |
|||
{ |
|||
string sql = $"select * from {tableName} where 1=1 {where} order by {orderFieldName} offset {skipNum} rows fetch next {takeNum} rows only"; |
|||
var ret = await _newJitDapperRepository.GetListBySqlAsync<T>(sql); |
|||
return ret; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 根据筛选条件获取实体列表
|
|||
/// </summary>
|
|||
private async Task<PagedResultDto<ImportNoteDto>> QueryByConditionAsync(ImportNoteInputDto input, PagedAndSortedBase page) |
|||
{ |
|||
PagedResultDto<ImportNoteDto> ret = new PagedResultDto<ImportNoteDto>(); |
|||
string where = GetWhere(input); |
|||
|
|||
ret.TotalCount = await GetEntityCountAsync("FisImportNote", where); |
|||
|
|||
//计算分页
|
|||
int skipNum = page.SkipCount; |
|||
int takeNum = page.MaxResultCount; |
|||
|
|||
var lst = await GetEntityListFromToAsync<ImportNoteDto>("FisImportNote", where, "HostSN", skipNum, takeNum); |
|||
ret.Items = lst; |
|||
return ret; |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
|
|||
#region 公有方法
|
|||
/// <summary>
|
|||
/// 根据筛选条件获取分页实体列表
|
|||
/// </summary>
|
|||
/// <param name="input">输入查询条件</param>
|
|||
/// <returns>返回符合条件的排序分页列表</returns>
|
|||
[HttpGet] |
|||
[UnitOfWork(false)] |
|||
[Route("list")] |
|||
public async Task<PagedResultDto<ImportNoteDto>> GetListAsync(ImportNoteInputDto input) |
|||
{ |
|||
_logger.LogDebug(_errorMessagePrefix + "GetListAsync 进入"); |
|||
PagedResultDto<ImportNoteDto> ret = new PagedResultDto<ImportNoteDto>(); |
|||
try |
|||
{ |
|||
ret = await QueryByConditionAsync(input, (PagedAndSortedBase)input); |
|||
return ret; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
var msg = _errorMessagePrefix + "GetListAsync 执行出错:" + ex.Message; |
|||
_logger.LogError(msg); |
|||
return ret; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 按主键获取唯一实体
|
|||
/// </summary>
|
|||
/// <param name="id">主键</param>
|
|||
/// <returns>实体信息</returns>
|
|||
[HttpGet] |
|||
[Route("{id}")] |
|||
public async Task<ObjectResultDto<ImportNoteDto>> GetAsync(Guid id) |
|||
{ |
|||
_logger.LogDebug(_errorMessagePrefix + "GetAsync 进入"); |
|||
ObjectResultDto<ImportNoteDto> ret = new ObjectResultDto<ImportNoteDto>(); |
|||
try |
|||
{ |
|||
ImportNote sourceObj = await _importNoteRepository.GetAsync(id); |
|||
ImportNoteDto targetObj = ObjectMapper.Map<ImportNote, ImportNoteDto>(sourceObj); |
|||
ret.Item = targetObj; |
|||
return ret; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
ret.Status = false; |
|||
ret.Message = _errorMessagePrefix + "GetAsync 执行出错:" + ex.Message; |
|||
_logger.LogError(ret.Message); |
|||
return ret; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 添加实体
|
|||
/// </summary>
|
|||
/// <param name="input">添加内容</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
[HttpPost] |
|||
[UnitOfWork] |
|||
[Route("")]//create
|
|||
public async Task<ObjectResultDto<Guid>> CreateAsync(ImportNoteCreateDto input) |
|||
{ |
|||
_logger.LogDebug(_errorMessagePrefix + "CreateAsync 进入"); |
|||
ObjectResultDto<Guid> ret = new ObjectResultDto<Guid>(); |
|||
try |
|||
{ |
|||
ImportNote obj = ObjectMapper.Map<ImportNoteCreateDto, ImportNote>(input); |
|||
ImportNote obj2 = await _importNoteRepository.InsertAsync(obj); |
|||
ret.Item = obj2.Id; //返回添加对象的主键
|
|||
return ret; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
ret.Status = false; |
|||
ret.Message = _errorMessagePrefix + "CreateAsync 执行出错:" + ex.Message; |
|||
_logger.LogError(ret.Message); |
|||
return ret; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 修改实体
|
|||
/// </summary>
|
|||
/// <param name="id">更新主键</param>
|
|||
/// <param name="input">修改内容</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
[HttpPut] |
|||
[UnitOfWork] |
|||
[Route("{id}")]//update/
|
|||
public async Task<ObjectResultDto> UpdateAsync(Guid id, ImportNoteCreateDto input) |
|||
{ |
|||
_logger.LogDebug(_errorMessagePrefix + "UpdateAsync 进入"); |
|||
ObjectResultDto ret = new ObjectResultDto(); |
|||
try |
|||
{ |
|||
ImportNote targetObj = await _importNoteRepository.GetAsync(id); |
|||
ObjectMapper.Map<ImportNoteCreateDto, ImportNote>(input, targetObj); |
|||
await _importNoteRepository.UpdateAsync(targetObj); |
|||
return ret; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
ret.Status = false; |
|||
ret.Message = _errorMessagePrefix + "UpdateAsync 执行出错:" + ex.Message; |
|||
_logger.LogError(ret.Message); |
|||
return ret; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除实体
|
|||
/// </summary>
|
|||
/// <param name="id">删除主键</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
[UnitOfWork] |
|||
[HttpDelete] |
|||
[Route("{id}")]//delete/
|
|||
public async Task<ObjectResultDto> DeleteAsync(string id) |
|||
{ |
|||
_logger.LogDebug(_errorMessagePrefix + "DeleteAsync 进入"); |
|||
ObjectResultDto ret = new ObjectResultDto(); |
|||
try |
|||
{ |
|||
Guid guid = Guid.Parse(id); |
|||
await _importNoteRepository.DeleteAsync(guid); |
|||
|
|||
return ret; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
ret.Status = false; |
|||
ret.Message = _errorMessagePrefix + "DeleteAsync 执行出错:" + ex.Message; |
|||
_logger.LogError(ret.Message); |
|||
return ret; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导出信息
|
|||
/// </summary>
|
|||
/// <param name="input">导出查询条件</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
[UnitOfWork(false)] |
|||
[HttpPost] |
|||
[Route("export")] |
|||
public async Task<ObjectResultDto<string>> ExportAsync(ImportNoteInputDto input) |
|||
{ |
|||
_logger.LogDebug(_errorMessagePrefix + "ExportAsync 进入"); |
|||
ObjectResultDto<string> ret = new ObjectResultDto<string>(); |
|||
try |
|||
{ |
|||
PagedResultDto<ImportNoteDto> pageLst = await QueryByConditionAsync(input, (PagedAndSortedBase)input); |
|||
var items = pageLst.Items.AsEnumerable().ToList(); |
|||
//将实体列表转换成excel文件流
|
|||
IExporter exporter = new ExcelExporter(); |
|||
byte[] byteArr = await exporter.ExportAsByteArray<ImportNoteDto>(items); |
|||
byteArr.ShouldNotBeNull(); |
|||
//将excel文件流保存到服务器端文件系统
|
|||
string fileName = string.Format("导入记录_{0}.xlsx", Guid.NewGuid().ToString()); |
|||
await _blobContainer.SaveAsync(fileName, byteArr); |
|||
|
|||
ret.Item = fileName; |
|||
return ret; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
ret.Status = false; |
|||
ret.Message = _errorMessagePrefix + "ExportAsync 执行出错:" + ex.Message; |
|||
_logger.LogError(ret.Message); |
|||
return ret; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导入
|
|||
/// </summary>
|
|||
/// <param name="files">导入文件</param>
|
|||
/// <param name="forceExecute">校验出错时,是否强制执行</param>
|
|||
/// <returns>执行成功返回真</returns>
|
|||
//[UnitOfWork(IsDisabled =true)]
|
|||
//[UnitOfWork(isTransactional: false)] //[UnitOfWork(false)]
|
|||
[UnitOfWork] |
|||
[HttpPost] |
|||
[Route("import")] |
|||
[DisableRequestSizeLimit] |
|||
public virtual async Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files, bool forceExecute = false) |
|||
{ |
|||
|
|||
_logger.LogDebug(_errorMessagePrefix + "ImportAsync 进入"); |
|||
ObjectResultDto ret = new ObjectResultDto(); |
|||
try |
|||
{ |
|||
ImportResult<ImportNoteDto> impResult; |
|||
using (var memoryStream = new MemoryStream()) |
|||
{ |
|||
//保存到内存流
|
|||
IFormFile file = files[0]; |
|||
await file.CopyToAsync(memoryStream); |
|||
memoryStream.Seek(0, SeekOrigin.Begin); |
|||
IImporter importer = new ExcelImporter(); |
|||
impResult = await importer.Import<ImportNoteDto>(memoryStream); |
|||
} |
|||
|
|||
if (impResult.HasError) |
|||
{ |
|||
string rowErrStr = ""; |
|||
foreach (var rowErr in impResult.RowErrors) |
|||
{ |
|||
string fieldErr = string.Concat(rowErr.FieldErrors.Select(itm => $"字段:{itm.Key},错误信息:{itm.Value}")); |
|||
rowErrStr += $"行号:{rowErr.RowIndex},{fieldErr}\r\n"; |
|||
} |
|||
string templateErrStr = ""; |
|||
foreach (var templateErr in impResult.TemplateErrors) |
|||
{ |
|||
string errorLevel = templateErr.ErrorLevel == ErrorLevels.Error ? "错误" : "警告"; |
|||
templateErrStr += $"错误等级:{errorLevel},列名:{templateErr.ColumnName},需要列:{templateErr.RequireColumnName},错误消息:{templateErr.Message}\r\n"; |
|||
} |
|||
ret.Message = rowErrStr + templateErrStr; |
|||
ret.Status = false; |
|||
return ret; |
|||
} |
|||
|
|||
//using (var uow = _unitOfWorkManager.Begin())
|
|||
//{
|
|||
var srcLst = impResult.Data.AsEnumerable().ToList(); |
|||
|
|||
#region 校验重复报文(本次导入内部重复)
|
|||
string msg = ""; |
|||
var groupLst = srcLst.GroupBy(itm => new { itm.Vin, itm.HostSN }).Select(itm => new |
|||
{ |
|||
Vin = itm.Key.Vin, |
|||
HostSN = itm.Key.HostSN, |
|||
Count = itm.Count() |
|||
}); |
|||
var tempLst = groupLst.Where(itm => itm.Count > 1).ToList(); |
|||
foreach (var temp in tempLst) |
|||
{ |
|||
msg += $"底盘{temp.Vin}、顺序号{temp.HostSN}记录重复\r\n"; |
|||
} |
|||
if (msg.Length > 0) |
|||
{ |
|||
ret.Message = msg; |
|||
ret.Status = false; |
|||
return ret; |
|||
} |
|||
#endregion
|
|||
|
|||
var tarLst = ObjectMapper.Map<List<ImportNoteDto>, List<ImportNote>>(srcLst); |
|||
foreach (var tar in tarLst) |
|||
{ |
|||
tar.CreateTime = ServerHelper.CurrentDateTime; |
|||
if (tar.OnlineTime == null) |
|||
{ |
|||
tar.OnlineTime = tar.PaintOfflineTime; //导入文件时 总装上线时间 为空,使用 涂装下线时间 代替 总装上线时间
|
|||
} |
|||
} |
|||
//报文解析
|
|||
ObjectResultDto ret2 = await _ediParseDomainService.ParseEdi(tarLst, forceExecute); |
|||
if (ret2.Status == false) |
|||
{ |
|||
return ret2; |
|||
} |
|||
if (ret2.Status == true && ret2.Message.HasValue()) |
|||
{ |
|||
return ret2; |
|||
} |
|||
//await uow.CompleteAsync();
|
|||
ret.Status = true; |
|||
|
|||
return ret; |
|||
//}
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
ret.Status = false; |
|||
ret.Message = _errorMessagePrefix + "ImportAsync 执行出错:" + ex.Message; |
|||
_logger.LogError(ret.Message); |
|||
throw new BusinessException("1001", ret.Message); |
|||
//return ret;
|
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 打印时间提醒
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[UnitOfWork] |
|||
[HttpPost] |
|||
[Route("print-timeout-remind")] |
|||
public virtual async Task<TimeOutRemindResultDto> PrintTimeoutRemind() |
|||
{ |
|||
//return new TimeOutRemindResultDto();
|
|||
TimeOutRemindResultDto retObj = new TimeOutRemindResultDto(); |
|||
retObj.ConfigMinutes = _configuration[$"ConfigDic:ProductLineTimeoutRemind_New:{"Record"}"].TryToInt() ?? 40; |
|||
var qry = await _importNoteRepository.MaxAsync(itm => itm.CreateTime); |
|||
retObj.LastReceiveTime = qry != null ? Convert.ToDateTime(qry) : ServerHelper.CurrentDateTime; |
|||
retObj.TimeoutMinutes = MinuteDiff(retObj.LastReceiveTime, ServerHelper.CurrentDateTime); |
|||
return retObj; |
|||
} |
|||
|
|||
private int MinuteDiff(DateTime beginTime, DateTime endTime) |
|||
{ |
|||
TimeSpan beginSpan = new TimeSpan(beginTime.Ticks); |
|||
TimeSpan endSpan = new TimeSpan(endTime.Ticks); |
|||
TimeSpan diffSpan = endSpan.Subtract(beginSpan).Duration(); |
|||
return (int)(diffSpan.TotalMinutes); |
|||
} |
|||
#endregion
|
|||
} |
|||
} |
@ -0,0 +1,87 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Entitys |
|||
{ |
|||
public class ImportNote : Entity<Guid> |
|||
{ |
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
public virtual string Vin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物流配货顺序号
|
|||
/// </summary>
|
|||
public virtual int HostSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号 #
|
|||
/// </summary>
|
|||
public virtual string SerialNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型代码
|
|||
/// </summary>
|
|||
public virtual string VehicleModelCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型名称
|
|||
/// </summary>
|
|||
public virtual string VehicleModelName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上级产品系列(规格说明)
|
|||
/// </summary>
|
|||
public virtual string SpecDesc { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型
|
|||
/// </summary>
|
|||
public virtual string VehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 公告车型
|
|||
/// </summary>
|
|||
public virtual string AfficheVehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 特殊车标识
|
|||
/// </summary>
|
|||
public virtual string SpecialCarLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? PaintOfflineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? OnlineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备注
|
|||
/// </summary>
|
|||
public virtual string Remark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
public virtual DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人
|
|||
/// </summary>
|
|||
public virtual string CreatePerson { get; set; } |
|||
|
|||
public virtual DateTime? ImportTime { get; set; } |
|||
|
|||
public virtual string ImportPerson { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,87 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Entitys |
|||
{ |
|||
public class ImportNoteHis : Entity<Guid> |
|||
{ |
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
public virtual string Vin { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物流配货顺序号
|
|||
/// </summary>
|
|||
public virtual int HostSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 序列号 #
|
|||
/// </summary>
|
|||
public virtual string SerialNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型代码
|
|||
/// </summary>
|
|||
public virtual string VehicleModelCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型名称
|
|||
/// </summary>
|
|||
public virtual string VehicleModelName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上级产品系列(规格说明)
|
|||
/// </summary>
|
|||
public virtual string SpecDesc { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 车型
|
|||
/// </summary>
|
|||
public virtual string VehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 公告车型
|
|||
/// </summary>
|
|||
public virtual string AfficheVehicleModel { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 特殊车标识
|
|||
/// </summary>
|
|||
public virtual string SpecialCarLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 涂装下线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? PaintOfflineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总装上线时间
|
|||
/// </summary>
|
|||
public virtual DateTime? OnlineTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备注
|
|||
/// </summary>
|
|||
public virtual string Remark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
public virtual DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人
|
|||
/// </summary>
|
|||
public virtual string CreatePerson { get; set; } |
|||
|
|||
public virtual DateTime? ImportTime { get; set; } |
|||
|
|||
public virtual string ImportPerson { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,557 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Domain.Services; |
|||
using WY.NewJit.EdiReceive.Entitys; |
|||
using WY.NewJit.IRepositories; |
|||
using WY.NewJit.MsgBaseData; |
|||
using WY.NewJit.MsgCheck; |
|||
using WY.NewJit.Common; |
|||
using WY.NewJit.MsgBaseData.Entitys; |
|||
|
|||
namespace WY.NewJit.EdiReceive.Services |
|||
{ |
|||
/// <summary>
|
|||
/// 红旗报文接收
|
|||
/// </summary>
|
|||
public class EdiParseDomainSrvV2 : DomainService |
|||
{ |
|||
#region 成员
|
|||
/// <summary>
|
|||
/// 日志
|
|||
/// </summary>
|
|||
private readonly ILogger<EdiParseDomainSrvV2> _logger; |
|||
|
|||
/// <summary>
|
|||
/// Dapper仓储
|
|||
/// </summary>
|
|||
private readonly INewJitDapperRepository _newJitDapperRepository; |
|||
|
|||
/// <summary>
|
|||
/// 字典领域服务
|
|||
/// </summary>
|
|||
private readonly DicDomainService _dicDomainService; |
|||
|
|||
/// <summary>
|
|||
/// 导入记录仓储
|
|||
/// </summary>
|
|||
private readonly IRepository<ImportNote, Guid> _importNoteRepository; |
|||
|
|||
/// <summary>
|
|||
/// M100单据
|
|||
/// </summary>
|
|||
private readonly IRepository<BillM100, Guid> _billM100Repository; |
|||
|
|||
/// <summary>
|
|||
/// 整车总成配置仓库
|
|||
/// </summary>
|
|||
private readonly IRepository<AssemblyCfgVehicle, Guid> _assemblyCfgVehicleRepository; |
|||
|
|||
/// <summary>
|
|||
/// 导入最大流水号 领域服务
|
|||
/// </summary>
|
|||
private readonly LastImportHostSNDomainService _lastImportHostSNDomainService; |
|||
|
|||
/// <summary>
|
|||
/// 缓存管理 领域服务
|
|||
/// </summary>
|
|||
private readonly HQ_CacheManagerDomainService _hqCacheManagerDomainService; |
|||
|
|||
/// <summary>
|
|||
/// 插入M100、未打印表 领域服务
|
|||
/// </summary>
|
|||
private readonly HQ_M100DomainService _hqM100DomainServie; |
|||
|
|||
/// <summary>
|
|||
/// 重复报文仓库
|
|||
/// </summary>
|
|||
private readonly IRepository<RepeatM100, Guid> _repeatM100Repository; |
|||
|
|||
/// <summary>
|
|||
/// 未知总成仓库
|
|||
/// </summary>
|
|||
private readonly IRepository<UnknownAssembly, Guid> _unknownAssemblyRepository; |
|||
|
|||
/// <summary>
|
|||
/// 根据车型代码中的前两位(HS),过滤属于派格的订单;只针对派格的订单进行报文解析
|
|||
/// </summary>
|
|||
private string[] _vehicleModelPrefix = new string[2] { "D077", "E007" }; |
|||
|
|||
/// <summary>
|
|||
/// 错误信息前缀
|
|||
/// </summary>
|
|||
private string _errorMessagePrefix |
|||
{ |
|||
get |
|||
{ |
|||
return System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."; |
|||
} |
|||
} |
|||
|
|||
private const string _productLineCode = "12"; |
|||
|
|||
|
|||
#endregion
|
|||
public EdiParseDomainSrvV2(ILogger<EdiParseDomainSrvV2> logger, INewJitDapperRepository newJitDapperRepository, DicDomainService dicDomainService, IRepository<ImportNote, Guid> importNoteRepository, IRepository<BillM100, Guid> billM100Repository, LastImportHostSNDomainService lastImportHostSNDomainService, IRepository<AssemblyCfgGroup, Guid> assemblyCfgGroupRepository = null, IRepository<AssemblyCfgErp, Guid> assemblyCfgErpRepository = null, IRepository<AssemblyCfgVehicle, Guid> assemblyCfgVehicleRepository = null, HQ_CacheManagerDomainService hqCacheManagerDomainService = null, HQ_M100DomainService hqM100DomainServie = null, IRepository<RepeatM100, Guid> repeatM100Repository = null, IRepository<UnknownAssembly, Guid> unknownAssemblyRepository = null) |
|||
{ |
|||
_logger = logger; |
|||
_newJitDapperRepository = newJitDapperRepository; |
|||
_dicDomainService = dicDomainService; |
|||
_importNoteRepository = importNoteRepository; |
|||
_billM100Repository = billM100Repository; |
|||
_lastImportHostSNDomainService = lastImportHostSNDomainService; |
|||
|
|||
_assemblyCfgVehicleRepository = assemblyCfgVehicleRepository; |
|||
_hqCacheManagerDomainService = hqCacheManagerDomainService; |
|||
_hqM100DomainServie = hqM100DomainServie; |
|||
_repeatM100Repository = repeatM100Repository; |
|||
_unknownAssemblyRepository = unknownAssemblyRepository; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 解析报文
|
|||
/// 一、导入记录表
|
|||
/// 1. 从客户网站导出EXCEL格式的订单列表
|
|||
/// 2. 校验 本次导入的最小HostSN必须<= 上次导入的最大HostSN + 1 (上次是10, 本次可以是 9 10 11,不能是12)
|
|||
/// 3. 根据VIN和HostSN,扣除重复导入的记录
|
|||
/// 4. 断号提醒:导入Excel时,如果系统中的流水号不能顺序连接,需要给出提醒,是否继续导入,如果选择继续导入,仍可以导入到系统中
|
|||
/// 5. 最后导入到本系统中 input
|
|||
///
|
|||
/// 二、插入M100
|
|||
/// 1. 根据车型名称 前4位等于D077或E007,过滤属于派格的订单;只针对派格的订单进行报文解析
|
|||
/// 2. 根据VIN判断是否重复报文,将重复报文放到“重复报文表”
|
|||
/// 3. 通过车型名称中的颜色(条件一)和上级产线系列(条件二)两个字段能够定位到该底盘对应哪个总成组(4个总成一组)。如果匹配将订单和总成组进行绑定;如果不匹配将订单放入未知总成
|
|||
/// 4. 插入M100 (更新派格车型、 生产线)
|
|||
/// 5. 插入WaitPrint
|
|||
/// </summary>
|
|||
/// <param name="input">导入Excel内容</param>
|
|||
/// <param name="forceExecute">校验不通过时,是否强制执行通过</param>
|
|||
public virtual async Task<ObjectResultDto> ParseEdi(List<ImportNote> input, bool forceExecute = false) |
|||
{ |
|||
ObjectResultDto ret = new ObjectResultDto(); |
|||
bool autoSave = false; |
|||
|
|||
//扣除重复导入的订单(和数据库对比)
|
|||
List<ImportNote> notRepeatOrder = await GetNotRepeatOrder(input); |
|||
if (notRepeatOrder.Count == 0) |
|||
{ |
|||
ret.Status = false; |
|||
ret.Message = $"本次导入Excel文件中{input.Count}条记录,重复订单数量{input.Count- notRepeatOrder.Count},都是重复的订单、无法导入!"; |
|||
return ret; |
|||
} |
|||
#region 断号提醒
|
|||
//校验两次导入之间是否断号
|
|||
int priorMaxHostSN = await _lastImportHostSNDomainService.GetLastImportMaxHostSN(_productLineCode); |
|||
string betweenBreakNumMsg = await CheckBetweenBreakNum(input, priorMaxHostSN); |
|||
//校验本次导入数据是否断号
|
|||
string breakNumMsg = CheckBreakNum(ref notRepeatOrder); |
|||
|
|||
if (betweenBreakNumMsg.HasValue() || breakNumMsg.HasValue()) |
|||
{ |
|||
if (forceExecute == false) |
|||
{ |
|||
//断号提醒
|
|||
ret.Status = true; |
|||
ret.Message = betweenBreakNumMsg + breakNumMsg; |
|||
return ret; |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
//初始化缓存
|
|||
_hqCacheManagerDomainService.InitLoadCache(); |
|||
|
|||
//批量插入 导入记录
|
|||
await _importNoteRepository.InsertManyAsync(notRepeatOrder, autoSave); |
|||
|
|||
//过滤掉其它厂家的订单,只取派格订单
|
|||
//车型名称 前4位等于D077或E007
|
|||
var paigeOrderLst = notRepeatOrder.Where(itm => _vehicleModelPrefix.Contains(itm.VehicleModelName?.Substring(0, 4))).OrderBy(itm => itm.HostSN).ToList(); |
|||
int idx = 0; |
|||
foreach (ImportNote orderItem in paigeOrderLst) |
|||
{ |
|||
Guid importNoteId = orderItem.Id; |
|||
int hostSN = orderItem.HostSN; |
|||
string vin = orderItem.Vin; |
|||
string specExplain = orderItem.SpecDesc; |
|||
string colorExplain = GetColor(orderItem.VehicleModelName); |
|||
|
|||
idx++; |
|||
if (idx % 10 == 0) |
|||
{ |
|||
_logger.LogDebug(_errorMessagePrefix + $"循环中:{idx}/{paigeOrderLst.Count}"); |
|||
} |
|||
//构建M100实体
|
|||
BillM100 m100Obj = BuildM100Entity(orderItem); |
|||
//更新车型、产线
|
|||
UpdateProductLine(m100Obj); |
|||
|
|||
//重复报文
|
|||
bool isRepeat = await _billM100Repository.AnyAsync(itm => itm.HostSN == hostSN && itm.VIN == vin); |
|||
if (isRepeat == true) |
|||
{ |
|||
#region 重复报文
|
|||
var succObj = await InsertM100RepeatBill(importNoteId, m100Obj, autoSave); |
|||
_logger.LogDebug(_errorMessagePrefix + $"流水号{hostSN}是重复报文"); |
|||
ret.Status = (succObj != null); |
|||
return ret; |
|||
#endregion
|
|||
} |
|||
|
|||
//绑定总成分组
|
|||
Group_Assembly groupAssemblyObj = HQ_CacheManagerDomainService._groupAssemblyList.FirstOrDefault(itm => itm.SpecExplain == specExplain && itm.ColorExplain == colorExplain); |
|||
if (groupAssemblyObj != null) |
|||
{ |
|||
#region 插入整车总成
|
|||
Guid vehicleAssemblyId = GuidGenerator.Create(); |
|||
AssemblyCfgVehicle vehicleAssemblyCfgObj = new AssemblyCfgVehicle(vehicleAssemblyId, null, m100Obj.VehicleModelCode, null, true); |
|||
foreach (OnlyAssemblyInfo assemblyItem in groupAssemblyObj.AssemblyDetails) //插入子表
|
|||
{ |
|||
vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), assemblyItem.Id); |
|||
} |
|||
var vehicleAssemblyResu = await _assemblyCfgVehicleRepository.InsertAsync(vehicleAssemblyCfgObj, autoSave); |
|||
if (vehicleAssemblyResu == null) |
|||
{ |
|||
throw new Exception("插入整车总成返回结果为空InsertAsync!"); |
|||
} |
|||
#endregion
|
|||
|
|||
//插入M100、未打印表
|
|||
m100Obj.SetAssemblyID(vehicleAssemblyResu.Id); |
|||
m100Obj.SetBillStatus(BillStatusEnum.Match); |
|||
m100Obj.SpecExplain = specExplain; |
|||
m100Obj.ColorExplain = colorExplain; |
|||
var insM100Ret = await _hqM100DomainServie.InsertM100(m100Obj, autoSave); |
|||
if (insM100Ret == null) |
|||
{ |
|||
throw new Exception("插入M100返回结果为空InsertAsync!"); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
//未知总成
|
|||
_logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成开始:{hostSN}"); |
|||
//更新单据表
|
|||
m100Obj.SetAssemblyID(null); |
|||
m100Obj.SetBillStatus(BillStatusEnum.NotMatch); |
|||
m100Obj.SpecExplain = specExplain; |
|||
m100Obj.ColorExplain = colorExplain; |
|||
var succObj1 = await _hqM100DomainServie.InsertM100(m100Obj, autoSave); |
|||
|
|||
//不匹配时,插入未知总成
|
|||
var succObj2 = await InsertUnknownAssembly(m100Obj, autoSave); |
|||
_logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成完成:{hostSN}"); |
|||
ret.Status = (succObj1 != null && succObj2 != null); |
|||
} |
|||
|
|||
} //foreach
|
|||
|
|||
//更新本次导入的最大HostSN
|
|||
int curMaxHostSN = input.Max(itm => itm.HostSN); |
|||
await _lastImportHostSNDomainService.SetCurrentImportMaxHostSN(_productLineCode, curMaxHostSN, true); //取最大号必须缓存autoSave = true
|
|||
|
|||
if (notRepeatOrder.Count < input.Count) |
|||
{ |
|||
int repeatCount = input.Count - notRepeatOrder.Count; |
|||
|
|||
ret.Message = $"本次导入Excel文件中{input.Count}条记录,上次导入最大流水号是{priorMaxHostSN},本次导入重复记录{repeatCount}"; |
|||
ret.Status = false; |
|||
return ret; |
|||
} |
|||
|
|||
ret.Status = true; |
|||
return ret; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 从车型名称中取颜色:截取车型名称最后一个逗号右侧的部分
|
|||
/// </summary>
|
|||
/// <param name="vehicleName"></param>
|
|||
/// <returns></returns>
|
|||
private string GetColor(string vehicleName) |
|||
{ |
|||
if (vehicleName.IsNullOrEmpty() || vehicleName.Trim() == "") |
|||
{ |
|||
return ""; |
|||
} |
|||
int lastIdx = vehicleName.Replace(",", ",").LastIndexOf(","); |
|||
// 如果找不到逗号,则返回原字符串
|
|||
if (lastIdx == -1) |
|||
{ |
|||
return ""; |
|||
} |
|||
|
|||
// 返回最后一个逗号后面的部分
|
|||
return vehicleName.Substring(lastIdx + 1).Trim(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 未知总成-重新解析
|
|||
/// </summary>
|
|||
/// <param name="m100Obj"></param>
|
|||
/// <param name="specExplain"></param>
|
|||
/// <param name="colorExplain"></param>
|
|||
/// <returns></returns>
|
|||
//public virtual async Task<ObjectResultDto<bool>> ReParsing(BillM100 m100Obj, string specExplain, string colorExplain)
|
|||
//{
|
|||
// ObjectResultDto<bool> ret = new ObjectResultDto<bool>();
|
|||
// Group_Assembly groupAssemblyObj = HQ_CacheManagerDomainService._groupAssemblyList.FirstOrDefault(itm => itm.SpecExplain == specExplain && itm.ColorExplain == colorExplain);
|
|||
// if (groupAssemblyObj != null)
|
|||
// {
|
|||
// #region 插入整车总成
|
|||
// Guid vehicleAssemblyId = GuidGenerator.Create();
|
|||
// AssemblyCfgVehicle vehicleAssemblyCfgObj = new AssemblyCfgVehicle(vehicleAssemblyId, null, m100Obj.VehicleModelCode, null, true);
|
|||
// foreach (OnlyAssemblyInfo assemblyItem in groupAssemblyObj.AssemblyDetails) //插入子表
|
|||
// {
|
|||
// vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), assemblyItem.Id);
|
|||
// }
|
|||
// var vehicleAssemblyResu = await _assemblyCfgVehicleRepository.InsertAsync(vehicleAssemblyCfgObj, true);
|
|||
// if (vehicleAssemblyResu == null)
|
|||
// {
|
|||
// throw new Exception($"{_errorMessagePrefix}插入整车总成失败:{m100Obj.HostSN2}");
|
|||
// }
|
|||
// #endregion
|
|||
|
|||
// //更新M100
|
|||
// m100Obj.SetAssemblyID(vehicleAssemblyResu.Id);
|
|||
// m100Obj.SetBillStatus(BillStatusEnum.Match);
|
|||
// var m100Ret = await _billM100Repository.UpdateAsync(m100Obj);
|
|||
// if (m100Ret == null)
|
|||
// {
|
|||
// throw new Exception($"{_errorMessagePrefix}更新M100失败:{m100Obj.HostSN2}");
|
|||
// }
|
|||
|
|||
// //bool hasBeforeNotPrint = await _hqM100DomainServie.BeforeNotPrint((int)(m100Obj.HostSN2));
|
|||
// //bool isReplenishPrint = hasBeforeNotPrint ? false : true; //未打印表包含重新解析之前的记录,设置成正常打印,否则设置成补打
|
|||
// bool isReplenishPrint = await _hqM100DomainServie.JugdeIsReplenishPrint(m100Obj.ProductLine, (int)(m100Obj.HostSN2));
|
|||
|
|||
// //判断未打印表是否有数据,有则更新,没有则插入
|
|||
// ObjectResultDto wpRet = await _hqM100DomainServie.InsertOrUpdateWaitPrintByM100(m100Ret, false, isReplenishPrint);
|
|||
// if (wpRet.Status == false)
|
|||
// {
|
|||
// throw new Exception(wpRet.Message);
|
|||
// }
|
|||
// //var updM100Ret = await _hqM100DomainServie.UpdateM100(m100Obj);
|
|||
// ret.Status = true;
|
|||
// ret.Item = true;
|
|||
// return ret;
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// ret.Status = true;
|
|||
// ret.Item = false;
|
|||
// ret.Message = $"重新解析失败:流水号{m100Obj.HostSN2},规格说明:{specExplain},颜色说明:{colorExplain}";
|
|||
// return ret;
|
|||
// }
|
|||
//}
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 上次导入和本次导入之间的流水号是否连续
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
private async Task<string> CheckBetweenBreakNum(List<ImportNote> input, int priorMaxHostSN) |
|||
{ |
|||
string ret = ""; |
|||
//取本次导入的最小HostSN
|
|||
int curMinHostSN = input.Min(itm => itm.HostSN); |
|||
//上次导入的最大HostSN
|
|||
//int priorMaxHostSN = await _lastImportHostSNDomainService.GetLastImportMaxHostSN();
|
|||
if (priorMaxHostSN > 0) //第一次导入时(priorMaxHostSN = 0),不需要校验两次导入之间的断号
|
|||
{ |
|||
if (curMinHostSN <= priorMaxHostSN + 1) |
|||
{ |
|||
} |
|||
else |
|||
{ |
|||
//两次导入断号提醒
|
|||
ret = $"两次导入断号提醒:本次导入的最小流水号是:{curMinHostSN},上次导入的最大流水号是:{priorMaxHostSN},两者不连续\r\n"; |
|||
} |
|||
} |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
private BillM100 BuildM100Entity(ImportNote orderItem) |
|||
{ |
|||
BillM100 m100Obj = new BillM100(GuidGenerator.Create()); |
|||
m100Obj.MessageFileReceiveID = orderItem.Id; |
|||
m100Obj.SerialNum = orderItem.SerialNum.TryToInt(); //ServerHelper.VinToSN(orderItem.Vin);
|
|||
m100Obj.SerialNumStr = ServerHelper.ToSerialNumStr(orderItem.OnlineTime, orderItem.HostSN); |
|||
m100Obj.HostSN = orderItem.HostSN; |
|||
m100Obj.HostSN2 = orderItem.HostSN; //流水号
|
|||
m100Obj.KNR = null; // orderItem.VehicleBodyCode;
|
|||
m100Obj.VIN = orderItem.Vin; |
|||
m100Obj.AssemblyID = null; |
|||
m100Obj.OnlineTime = orderItem.OnlineTime; |
|||
m100Obj.VehicleModelCode = orderItem.VehicleModelName.Substring(0, 4); //orderItem.VehicleModelCode.Substring(0, 2);
|
|||
m100Obj.ProductLine = null; |
|||
m100Obj.Version = ""; |
|||
m100Obj.ReceiveTime = ServerHelper.CurrentDateTime; |
|||
m100Obj.BillStatus = BillStatusEnum.NotMatch; |
|||
m100Obj.Description = ""; |
|||
//m100Obj.OperationType = operationType;
|
|||
//m100Obj.Operator = @operator;
|
|||
//m100Obj.OperationTime = operationTime;
|
|||
m100Obj.CanNotPrint = false; |
|||
m100Obj.NeedReplenishPrint = 0; |
|||
m100Obj.IsPartSwitch = false; |
|||
return m100Obj; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 校验本次导入数据断号
|
|||
/// </summary>
|
|||
/// <param name="notRepeatOrder"></param>
|
|||
/// <returns></returns>
|
|||
private static string CheckBreakNum(ref List<ImportNote> notRepeatOrder) |
|||
{ |
|||
StringBuilder sb = new StringBuilder(); |
|||
notRepeatOrder = notRepeatOrder.OrderBy(itm => itm.HostSN).ToList(); |
|||
for (int curIdx = 1; curIdx < notRepeatOrder.Count; curIdx++) |
|||
{ |
|||
int curVal = notRepeatOrder[curIdx].HostSN; |
|||
int priorIdx = curIdx - 1; |
|||
int priorVal = notRepeatOrder[priorIdx].HostSN; |
|||
if (curVal - priorVal > 1) |
|||
{ |
|||
sb.AppendLine($"流水号{priorVal}和{curVal}之间存在断号"); |
|||
} |
|||
else if (curVal - priorVal == 0) |
|||
{ |
|||
sb.AppendLine($"流水号{priorVal}和{curVal}之间存在重复"); |
|||
} |
|||
} |
|||
return sb.ToString(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据流水号、VIN 扣除重复导入的订单
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
private async Task<List<ImportNote>> GetNotRepeatOrder(List<ImportNote> input) |
|||
{ |
|||
List<ImportNote> notRepeatLst = new List<ImportNote>(); |
|||
List<ImportNote> importHistoryLst = await _importNoteRepository.GetPagedListAsync(0, 10000, "HostSN desc"); |
|||
|
|||
foreach (ImportNote item in input) |
|||
{ |
|||
bool hasData = importHistoryLst.Any(itm => itm.HostSN == item.HostSN && itm.Vin == item.Vin); |
|||
if (hasData) |
|||
{ |
|||
} |
|||
else |
|||
{ |
|||
notRepeatLst.Add(item); |
|||
} |
|||
} |
|||
return notRepeatLst; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 更新车型、生产线
|
|||
/// </summary>
|
|||
/// <param name="billResObj"></param>
|
|||
private void UpdateProductLine(BillM100 bill) |
|||
{ |
|||
string ediVehicleModel = bill.VehicleModelCode; //报文车型
|
|||
//车型转换:3H 转 CC
|
|||
var obj1 = HQ_CacheManagerDomainService._msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel); |
|||
if (obj1 != null) |
|||
{ |
|||
string paigeVehicleModel = obj1.DicItemName; // CC
|
|||
if (paigeVehicleModel.Contains('-')) //去掉B8L-PHEV中的-PHEV
|
|||
{ |
|||
paigeVehicleModel = paigeVehicleModel.Split('-')[0]; |
|||
} |
|||
bill.SetVehicleModelCode(paigeVehicleModel); |
|||
//根据车型取对应生产线
|
|||
var obj2 = HQ_CacheManagerDomainService._m100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel); |
|||
if (obj2 != null) |
|||
{ |
|||
string productLine = obj2.DicItemName; |
|||
bill.SetProductLine(productLine); |
|||
} |
|||
else |
|||
{ |
|||
string errorMsg = $"零件生产工厂车型{paigeVehicleModel}没有对应的生产线!"; |
|||
_logger.LogError(errorMsg); |
|||
} |
|||
} |
|||
else //报文车型 没有对应的 派格车型
|
|||
{ |
|||
string errorMsg = $"报文车型{ediVehicleModel}没有对应的零件生产工厂车型!"; |
|||
_logger.LogError(errorMsg); |
|||
} |
|||
} |
|||
|
|||
private async Task<RepeatM100> InsertM100RepeatBill(Guid impordRecId, BillM100 m100Bill, bool autoSave = false) |
|||
{ |
|||
RepeatM100 ret = null; |
|||
int newSN = ServerHelper.VinToSN(m100Bill.VIN); |
|||
RepeatM100 repeatBill = new RepeatM100( |
|||
GuidGenerator.Create(), |
|||
impordRecId, |
|||
newSN, |
|||
m100Bill.HostSN, |
|||
m100Bill.KNR, |
|||
m100Bill.VIN, |
|||
null, |
|||
m100Bill.OnlineTime, |
|||
ServerHelper.CurrentDateTime, |
|||
m100Bill.VehicleModelCode, |
|||
m100Bill.ProductLine, |
|||
((DateTime)m100Bill.OnlineTime).ToString("yyyyMM"), |
|||
BillStatusEnum.None |
|||
); |
|||
|
|||
//零件子表赋值【红旗版没有子零件表数据】
|
|||
//foreach (BillM100Part m100Part in m100Bill.BillM100Parts)
|
|||
//{
|
|||
// repeatBill.AddChildObj(GuidGenerator.Create(), m100Part.PartCode, m100Part.PartNum, m100Part.Description);
|
|||
//}
|
|||
//插入重复单据
|
|||
ret = await _repeatM100Repository.InsertAsync(repeatBill, autoSave); |
|||
return ret; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 不匹配时,插入未知总成,写提醒日志
|
|||
/// </summary>
|
|||
/// <param name="bill"></param>
|
|||
private async Task<UnknownAssembly> InsertUnknownAssembly(BillM100 bill, bool autoSave = false) |
|||
{ |
|||
UnknownAssembly ret = null; |
|||
try |
|||
{ |
|||
//插入未知总成
|
|||
UnknownAssembly unknownAssemblyObj = new UnknownAssembly(GuidGenerator.Create(), bill.Id, "M100"); |
|||
//预批量赋值
|
|||
unknownAssemblyObj.Description = bill.Description; //描述字段保存预批量信息
|
|||
|
|||
//foreach (BillM100Part billPart in bill.BillM100Parts)
|
|||
//{
|
|||
// unknownAssemblyObj.AddChildObj(GuidGenerator.Create(), billPart.PartCode, billPart.PartNum, billPart.Description);
|
|||
//}
|
|||
//var partNumSum = unknownAssemblyObj.UnknownAssemblyParts.Sum(itm => (int)itm.PartNum);
|
|||
//unknownAssemblyObj.SetPartNum(partNumSum);
|
|||
ret = await _unknownAssemblyRepository.InsertAsync(unknownAssemblyObj, autoSave); |
|||
return ret; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw new Exception($"InsertUnknownAssembly方法报错:" + ex.Message); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,74 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace WY.NewJit.Migrations |
|||
{ |
|||
public partial class _2025021702 : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "FisImportNoteHis", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Vin = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
HostSN = table.Column<int>(type: "int", nullable: false), |
|||
SerialNum = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
VehicleModelCode = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
VehicleModelName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
SpecDesc = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
VehicleModel = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true), |
|||
AfficheVehicleModel = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
SpecialCarLogo = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
PaintOfflineTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
OnlineTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true), |
|||
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
CreatePerson = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
ImportTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
ImportPerson = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_FisImportNoteHis", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "FisImportRecordV2", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Vin = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
HostSN = table.Column<int>(type: "int", nullable: false), |
|||
SerialNum = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
VehicleModelCode = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
VehicleModelName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
SpecDesc = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true), |
|||
VehicleModel = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true), |
|||
AfficheVehicleModel = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
SpecialCarLogo = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
PaintOfflineTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
OnlineTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true), |
|||
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
CreatePerson = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
ImportTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
ImportPerson = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_FisImportRecordV2", x => x.Id); |
|||
}); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "FisImportNoteHis"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "FisImportRecordV2"); |
|||
} |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,17 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace WY.NewJit.Migrations |
|||
{ |
|||
public partial class _2025021703 : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
File diff suppressed because it is too large
Loading…
Reference in new issue