Browse Source

临时提交

集成Redis
郑勃旭 2 years ago
parent
commit
919691fa4f
  1. 5
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/AppBase/FasterBaseDto/FasterAuditedEntityBaseDto.cs
  2. 2
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/AppBase/FasterBaseDto/FasterCreateUpdateBaseDto.cs
  3. 4
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrder/Dtos/CreateUpdateStoreWorkOrderDto.cs
  4. 43
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrder/Dtos/StoreWorkOrderDto.cs
  5. 4
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrderDetail/Dtos/CreateUpdateStoreWorkOrderDetailDto.cs
  6. 34
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrderDetail/Dtos/StoreWorkOrderDetailDto.cs
  7. 54
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application/AppBase/ZbxBase.cs
  8. 18
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application/Z_Business/StoreSaleOrder/StoreSaleOrderAppService.cs
  9. 45
      WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.EntityFrameworkCore/EntityFrameworkCore/WmsDbContext.cs

5
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/AppBase/FasterBaseDto/FasterAuditedEntityBaseDto.cs

@ -3,7 +3,8 @@ using Volo.Abp.Application.Dtos;
namespace WinIn.FasterZ.Wms.AppBase.FasterBaseDto; namespace WinIn.FasterZ.Wms.AppBase.FasterBaseDto;
public class FasterAuditedEntityBaseDto : AuditedEntityDto<Guid> [Serializable]
public class FasterAuditedEntityBaseDto<TPrimaryKey> : AuditedEntityDto<TPrimaryKey>
{ {
public string ConcurrencyStamp { get; set; } public string ConcurrencyStamp { get; set; } = string.Empty;
} }

2
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/AppBase/FasterBaseDto/FasterCreateUpdateBaseDto.cs

@ -6,5 +6,5 @@ public class FasterCreateUpdateBaseDto
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public string ConcurrencyStamp { get; set; } public string ConcurrencyStamp { get; set; } = string.Empty;
} }

4
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrder/Dtos/CreateUpdateStoreWorkOrderDto.cs

@ -1,5 +1,5 @@
using System; using System;
using WinIn.FasterZ.Wms.AppBase.CreateUpdateBaseDto; using WinIn.FasterZ.Wms.AppBase.FasterBaseDto;
namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos; namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos;
@ -10,7 +10,7 @@ using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos; using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos;
[Serializable] [Serializable]
public class CreateUpdateStoreWorkOrderDto: CreateUpdateBaseDto public class CreateUpdateStoreWorkOrderDto: FasterCreateUpdateBaseDto
{ {
public DateTime ActiveDate { get; set; } public DateTime ActiveDate { get; set; }

43
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrder/Dtos/StoreWorkOrderDto.cs

@ -1,51 +1,46 @@
using System; using System;
using Volo.Abp.Application.Dtos; using System.Collections.Generic;
using WinIn.FasterZ.Wms.AppBase.FasterBaseDto; using WinIn.FasterZ.Wms.AppBase.FasterBaseDto;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos; using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos;
namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos; namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos;
using System.Collections.Generic;
using WinIn.FasterZ.Wms.Permissions;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail;
[Serializable] [Serializable]
public class StoreWorkOrderDto : FasterAuditedEntityBaseDto<Guid> public class StoreWorkOrderDto : FasterAuditedEntityBaseDto<Guid>
{ {
public DateTime ActiveDate { get; set; } public DateTime ActiveDate { get; set; }
public DateTime EffectiveDate { get; set; } public DateTime EffectiveDate { get; set; }
public string ItemCode { get; set; } public string ItemCode { get; set; }
public string? ItemDesc1 { get; set; } public string? ItemDesc1 { get; set; }
public string? ItemDesc2 { get; set; } public string? ItemDesc2 { get; set; }
public string? ItemName { get; set; } public string? ItemName { get; set; }
public string? LocationCode { get; set; } public string? LocationCode { get; set; }
public string Number { get; set; } public string Number { get; set; }
public string? Op { get; set; } public string? Op { get; set; }
public decimal Qty { get; set; } public decimal Qty { get; set; }
public string? Remark { get; set; } public string? Remark { get; set; }
public List<StoreWorkOrderDetailDto> Details {get;set;} =new (); public List<StoreWorkOrderDetailDto> Details { get; set; } = new();
public string Type { get; set; } public string Type { get; set; }
public string Uom { get; set; } public string Uom { get; set; }
public string? Worker { get; set; } public string? Worker { get; set; }
public string? WorkOrderId { get; set; } public string? WorkOrderId { get; set; }
public string? WorkStation { get; set; } public string? WorkStation { get; set; }
public string WoStatus { get; set; } public string WoStatus { get; set; }
} }

4
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrderDetail/Dtos/CreateUpdateStoreWorkOrderDetailDto.cs

@ -1,13 +1,13 @@
using System; using System;
using WinIn.FasterZ.Wms.AppBase.FasterBaseDto;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos; using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos;
namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos; namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos;
using WinIn.FasterZ.Wms.AppBase.CreateUpdateBaseDto;
using WinIn.FasterZ.Wms.Permissions; using WinIn.FasterZ.Wms.Permissions;
[Serializable] [Serializable]
public class CreateUpdateStoreWorkOrderDetailDto: CreateUpdateBaseDto public class CreateUpdateStoreWorkOrderDetailDto: FasterCreateUpdateBaseDto
{ {
public DateTime EffectiveDate { get; set; } public DateTime EffectiveDate { get; set; }

34
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application.Contracts/Z_Business/StoreWorkOrderDetail/Dtos/StoreWorkOrderDetailDto.cs

@ -1,38 +1,32 @@
using System; using System;
using Volo.Abp.Application.Dtos; using WinIn.FasterZ.Wms.AppBase.FasterBaseDto;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos;
namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos; namespace WinIn.FasterZ.Wms.Z_Business.StoreWorkOrderDetail.Dtos;
using WinIn.FasterZ.Wms.Permissions;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder;
[Serializable] [Serializable]
public class StoreWorkOrderDetailDto : AuditedEntityDto<Guid> public class StoreWorkOrderDetailDto : FasterAuditedEntityBaseDto<Guid>
{ {
public DateTime EffectiveDate { get; set; } public DateTime EffectiveDate { get; set; }
public string ItemCode { get; set; }
public string? ItemDesc1 { get; set; } public string ItemCode { get; set; }
public string? ItemDesc2 { get; set; } public string? ItemDesc1 { get; set; }
public string? ItemName { get; set; } public string? ItemDesc2 { get; set; }
public string? ItemName { get; set; }
public Guid MasterId { get; set; } public Guid MasterId { get; set; }
public string Number { get; set; } public string Number { get; set; }
public string? Op { get; set; } public string? Op { get; set; }
public string? RawLocationCode { get; set; } public string? RawLocationCode { get; set; }
public decimal RawQty { get; set; } public decimal RawQty { get; set; }
public string? RawUom { get; set; } public string? RawUom { get; set; }
public string? Remark { get; set; } public string? Remark { get; set; }
} }

54
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application/AppBase/ZbxBase.cs

@ -11,6 +11,7 @@ using AutoMapper;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
@ -56,7 +57,6 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
private IDistributedCache<TEntity> Cache => private IDistributedCache<TEntity> Cache =>
LazyServiceProvider.LazyGetRequiredService<IDistributedCache<TEntity>>(); LazyServiceProvider.LazyGetRequiredService<IDistributedCache<TEntity>>();
private IMapper _mapper; private IMapper _mapper;
#endregion #endregion
@ -205,17 +205,18 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPut("api/[controller]/base/update-by-id")] [HttpPut("api/[controller]/base/update-by-id")]
public new async Task<TEntityDto> UpdateAsync(TKey id, TEntityDto input) public new async Task<TEntityDto> UpdateAsync(TKey id, TUpdateInput input)
{ {
//return base.UpdateAsync(id, input); //return base.UpdateAsync(id, input);
await CheckUpdatePolicyAsync().ConfigureAwait(false); await CheckUpdatePolicyAsync().ConfigureAwait(true);
var entity = await GetEntityByIdAsync(id).ConfigureAwait(false); var entity = await GetEntityByIdAsync(id).ConfigureAwait(true);
var entity2 = input!.ToObject<TEntity>();
Type t1 = null; Type t1 = null;
Type t2 = null; Type t2 = null;
Type t3 = typeof(TUpdateInput);
#region 给所有字表的 Id和MasterId赋值 否则默认的会是000000-000-....的id 插入时会报错 #region 给所有字表的 Id和MasterId赋值 否则默认的会是000000-000-....的id 插入时会报错
@ -224,10 +225,10 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
foreach (var propertyInfo in dtolist) foreach (var propertyInfo in dtolist)
{ {
if (propertyInfo.Name == "Details" if (propertyInfo.Name == "Details"
&& propertyInfo.PropertyType.IsGenericType && propertyInfo.PropertyType.IsGenericType
&& propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(List<>)) && propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(List<>))
{ {
var listProperty = typeof(TEntityDto).GetProperty("Details"); var listProperty = typeof(TUpdateInput).GetProperty("Details");
if (listProperty != null) if (listProperty != null)
{ {
t1 = listProperty.PropertyType.GetGenericArguments()[0]; t1 = listProperty.PropertyType.GetGenericArguments()[0];
@ -247,7 +248,7 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
if (listProperty != null) if (listProperty != null)
{ {
var listItemType = listProperty.PropertyType.GetGenericArguments()[0]; var listItemType = listProperty.PropertyType.GetGenericArguments()[0];
t2= listProperty.PropertyType.GetGenericArguments()[0]; t2 = listProperty.PropertyType.GetGenericArguments()[0];
// 获取元素类型的 ID 属性 // 获取元素类型的 ID 属性
//var detailIdProperty = listItemType.GetProperty("Id"); //var detailIdProperty = listItemType.GetProperty("Id");
@ -271,20 +272,20 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
// } // }
//} //}
if (masterIdProperty != null) //if (masterIdProperty != null)
{ //{
// 获取 List 属性的值 // // 获取 List 属性的值
var list = (IList)listProperty.GetValue(entity); // var list = (IList)listProperty.GetValue(entity);
// 遍历 List 集合中的每个元素,给 ID 属性赋值 // // 遍历 List 集合中的每个元素,给 ID 属性赋值
if (list != null) // if (list != null)
{ // {
foreach (var item in list) // foreach (var item in list)
{ // {
masterIdProperty.SetValue(item, id); // masterIdProperty.SetValue(item, id);
} // }
} // }
} //}
} }
} }
} }
@ -293,16 +294,19 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
{ {
// 动态创建映射关系 // 动态创建映射关系
cfg.CreateMap(typeof(TEntityDto), typeof(TEntity)); cfg.CreateMap(typeof(TEntityDto), typeof(TEntity));
cfg.CreateMap(t1,t2); cfg.CreateMap(t1, t2);
cfg.CreateMap(typeof(TUpdateInput), typeof(TEntity));
}); });
_mapper = new Mapper(config); _mapper = new Mapper(config);
var tt = _mapper.Map(input, entity); var tt = _mapper.Map(input, entity);
#endregion #endregion
await Repository.UpdateAsync(entity, true); //await Repository.UpdateAsync(entity, true);
//await Repository.UpdateAsync(tt, true);
await Cache.SetAsync(entity.Id.ToString(), entity, GetCacheTime()); //await Cache.SetAsync(entity.Id.ToString(), entity, GetCacheTime());
await Repository.UpdateAsync(entity, true);
return await MapToGetOutputDtoAsync(entity); return await MapToGetOutputDtoAsync(entity);
} }

18
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.Application/Z_Business/StoreSaleOrder/StoreSaleOrderAppService.cs

@ -1,10 +1,13 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WinIn.FasterZ.Wms.Permissions; using WinIn.FasterZ.Wms.Permissions;
using WinIn.FasterZ.Wms.Z_Business.StoreSaleOrder.Dtos; using WinIn.FasterZ.Wms.Z_Business.StoreSaleOrder.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using WinIn.FasterZ.Wms.AppBase; using WinIn.FasterZ.Wms.AppBase;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder;
using WinIn.FasterZ.Wms.Z_Business.StoreWorkOrder.Dtos;
namespace WinIn.FasterZ.Wms.Z_Business.StoreSaleOrder; namespace WinIn.FasterZ.Wms.Z_Business.StoreSaleOrder;
@ -20,9 +23,20 @@ public class StoreSaleOrderAppService : ZbxBase<StoreSaleOrder, StoreSaleOrderDt
private readonly IStoreSaleOrderRepository _repository; private readonly IStoreSaleOrderRepository _repository;
public StoreSaleOrderAppService(IStoreSaleOrderRepository repository) : base(repository) private readonly IStoreWorkOrderAppService _workOrderAppService;
public StoreSaleOrderAppService(IStoreSaleOrderRepository repository, IStoreWorkOrderAppService workOrderAppService) : base(repository)
{ {
_repository = repository; _repository = repository;
_workOrderAppService = workOrderAppService;
} }
[HttpPost("xcvxcv")]
public async Task test(CreateUpdateStoreWorkOrderDto dto)
{
dto.Qty = 1;
await _workOrderAppService.UpdateAsync(dto.Id, dto);
dto.Qty = 4;
await _workOrderAppService.UpdateAsync(dto.Id, dto);
}
} }

45
WinIn.FasterZ.Wms.Be/WinIn.FasterZ.Wms/WinIn.FasterZ.Wms/src/WinIn.FasterZ.Wms.EntityFrameworkCore/EntityFrameworkCore/WmsDbContext.cs

@ -3214,36 +3214,39 @@ namespace WinIn.FasterZ.Wms.EntityFrameworkCore
public override int SaveChanges() public override int SaveChanges()
{ {
this.ChangeTracker.DetectChanges(); //this.ChangeTracker.DetectChanges();
var modity = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).Select(x => x.Entity).ToList(); //var modity = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).Select(x => x.Entity).ToList();
foreach (var item in modity) //foreach (var item in modity)
{ //{
item?.GetType().GetProperty("ConcurrencyStamp")?.SetValue(item, Guid.NewGuid().ToString()); // item?.GetType().GetProperty("ConcurrencyStamp")?.SetValue(item, Guid.NewGuid().ToString());
} //}
return base.SaveChanges(); //return base.SaveChanges();
return 1;
} }
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken()) public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken())
{ {
this.ChangeTracker.DetectChanges(); //this.ChangeTracker.DetectChanges();
var modity = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).Select(x => x.Entity).ToList(); //var modity = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).Select(x => x.Entity).ToList();
foreach (var item in modity) //foreach (var item in modity)
{ //{
item?.GetType().GetProperty("ConcurrencyStamp")?.SetValue(item, Guid.NewGuid().ToString()); // item?.GetType().GetProperty("ConcurrencyStamp")?.SetValue(item, Guid.NewGuid().ToString());
} //}
return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken); //return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
return Task.FromResult(1);
} }
public override Task<int> SaveChangesOnDbContextAsync(bool acceptAllChangesOnSuccess, public override Task<int> SaveChangesOnDbContextAsync(bool acceptAllChangesOnSuccess,
CancellationToken cancellationToken = new CancellationToken()) CancellationToken cancellationToken = new CancellationToken())
{ {
this.ChangeTracker.DetectChanges(); //this.ChangeTracker.DetectChanges();
var modity = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).Select(x => x.Entity).ToList(); //var modity = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).Select(x => x.Entity).ToList();
foreach (var item in modity) //foreach (var item in modity)
{ //{
item?.GetType().GetProperty("ConcurrencyStamp")?.SetValue(item, Guid.NewGuid().ToString()); // item?.GetType().GetProperty("ConcurrencyStamp")?.SetValue(item, Guid.NewGuid().ToString());
} //}
return base.SaveChangesOnDbContextAsync(acceptAllChangesOnSuccess, cancellationToken); //return base.SaveChangesOnDbContextAsync(acceptAllChangesOnSuccess, cancellationToken);
return Task.FromResult(1);
} }
} }
} }

Loading…
Cancel
Save