Browse Source

代码合并

dev_DY_CC
lvzb 10 months ago
parent
commit
2b7d494aab
  1. BIN
      .vs/WZC2/v17/.wsuo
  2. 54
      be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs
  3. 12
      be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs
  4. 8
      be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/SparePartIssueJobsController.cs
  5. 22
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs
  6. 6
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs
  7. 32
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs
  8. 38
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs
  9. 123
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs

BIN
.vs/WZC2/v17/.wsuo

Binary file not shown.

54
be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs

@ -1,5 +1,3 @@
//---------------------- //----------------------
// <auto-generated> // <auto-generated>
// Generated using the NSwag toolchain v14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) // Generated using the NSwag toolchain v14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
@ -72,7 +70,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
/// </summary> /// </summary>
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<int> GetMacStaticAsync() public virtual System.Threading.Tasks.Task<ResultJson> GetMacStaticAsync()
{ {
return GetMacStaticAsync(System.Threading.CancellationToken.None); return GetMacStaticAsync(System.Threading.CancellationToken.None);
} }
@ -83,7 +81,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
/// </summary> /// </summary>
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<int> GetMacStaticAsync(System.Threading.CancellationToken cancellationToken) public virtual async System.Threading.Tasks.Task<ResultJson> GetMacStaticAsync(System.Threading.CancellationToken cancellationToken)
{ {
var client_ = _httpClient; var client_ = _httpClient;
var disposeClient_ = false; var disposeClient_ = false;
@ -125,7 +123,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
var status_ = (int)response_.StatusCode; var status_ = (int)response_.StatusCode;
if (status_ == 200) if (status_ == 200)
{ {
var objectResponse_ = await ReadObjectResponseAsync<int>(response_, headers_, cancellationToken).ConfigureAwait(false); var objectResponse_ = await ReadObjectResponseAsync<ResultJson>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null) if (objectResponse_.Object == null)
{ {
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
@ -214,7 +212,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<ResponCargoItem>> GetCargoStaticAsync(string areaID) public virtual System.Threading.Tasks.Task<ResponCargos> GetCargoStaticAsync(string areaID)
{ {
return GetCargoStaticAsync(areaID, System.Threading.CancellationToken.None); return GetCargoStaticAsync(areaID, System.Threading.CancellationToken.None);
} }
@ -222,7 +220,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<ResponCargoItem>> GetCargoStaticAsync(string areaID, System.Threading.CancellationToken cancellationToken) public virtual async System.Threading.Tasks.Task<ResponCargos> GetCargoStaticAsync(string areaID, System.Threading.CancellationToken cancellationToken)
{ {
var client_ = _httpClient; var client_ = _httpClient;
var disposeClient_ = false; var disposeClient_ = false;
@ -269,7 +267,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
var status_ = (int)response_.StatusCode; var status_ = (int)response_.StatusCode;
if (status_ == 200) if (status_ == 200)
{ {
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<ResponCargoItem>>(response_, headers_, cancellationToken).ConfigureAwait(false); var objectResponse_ = await ReadObjectResponseAsync<ResponCargos>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null) if (objectResponse_.Object == null)
{ {
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
@ -536,6 +534,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
} }
public partial class ResponCargoItem1 public partial class ResponCargoItem1
{ {
/// <summary> /// <summary>
@ -572,6 +571,45 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ResponCargos
{
[Newtonsoft.Json.JsonProperty("code", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int Code { get; set; }
[Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int Value { get; set; }
[Newtonsoft.Json.JsonProperty("msg", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Msg { get; set; }
[Newtonsoft.Json.JsonProperty("datalist", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<ResponCargoItem> Datalist { get; set; }
}
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ResultJson
{
[Newtonsoft.Json.JsonProperty("code", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int Code { get; set; }
[Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int Value { get; set; }
[Newtonsoft.Json.JsonProperty("result", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Result { get; set; }
[Newtonsoft.Json.JsonProperty("msg", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Msg { get; set; }
[Newtonsoft.Json.JsonProperty("valuestr", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Valuestr { get; set; }
}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ApiException : System.Exception public partial class ApiException : System.Exception
{ {

12
be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs

@ -76,7 +76,7 @@ public class InjectionMoldingRequestReader : IReader
Stopwatch sw = Stopwatch.StartNew(); Stopwatch sw = Stopwatch.StartNew();
Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录 Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录
var flag = await client.GetMacStaticAsync().ConfigureAwait(false); var flag = await client.GetMacStaticAsync().ConfigureAwait(false);
if (flag != 1) if (flag.Code != 200)
{ {
// 记录错误日志并返回空列表 // 记录错误日志并返回空列表
_logger.LogInformation($"读取到摄像头信息为不可用{DateTime.Now},请检查摄像头"); _logger.LogInformation($"读取到摄像头信息为不可用{DateTime.Now},请检查摄像头");
@ -94,7 +94,15 @@ public class InjectionMoldingRequestReader : IReader
{ {
foreach (var itm in ids)//遍历区域查找所有货物 foreach (var itm in ids)//遍历区域查找所有货物
{ {
var idsList = await client.GetCargoStaticAsync(itm).ConfigureAwait(false);
var obj= await client.GetCargoStaticAsync(itm).ConfigureAwait(false);
var idsList = obj.Datalist;
if (idsList == null)
{
_logger.LogInformation($"没有设置指定区域无数据");
return new List<IncomingFromExternal>();
}

8
be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/SparePartIssueJobsController.cs

@ -52,10 +52,10 @@ public class SparePartIssueJobsController : AbpController
{ {
status.Add((int)EnumJobStatus.Open); status.Add((int)EnumJobStatus.Open);
} }
else if (jobStatus == "Wait") //else if (jobStatus == "Wait")
{ //{
status.Add((int)EnumJobStatus.Wait); // status.Add((int)EnumJobStatus.Wait);
} //}
else else
{ {
status.Add((int)EnumJobStatus.Done); status.Add((int)EnumJobStatus.Done);

22
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs

@ -15,7 +15,7 @@ public class ResponseJson
// 错误码: // 错误码:
public int Code { set; get; } = 0; public int Code { set; get; } = 0;
// 返回值 其具体含义由调用接口确定 // 返回值 其具体含义由调用接口确定
public string Value { set; get; } = ""; public int Value { set; get; } =0;
// 错误消息 // 错误消息
public string Msg { set; get; } = ""; public string Msg { set; get; } = "";
} }
@ -35,3 +35,23 @@ public class ResponCargoItem
[Display(Name = "货位状态")] [Display(Name = "货位状态")]
public int Flag { set; get; } = 0; public int Flag { set; get; } = 0;
} }
public class ResponCargos : ResponseJson
{
//货位状态列表
public List<ResponCargoItem> Datalist { set; get; }
}
public class ResultJson
{
// 错误码:
public int Code { set; get; } = 0;
// 返回值 其具体含义由调用接口确定
public int Value { set; get; } = 0;
// 错误消息
public string Result { set; get; } = "";
public string Msg { set; get; } = "";
public string Valuestr { set; get; }
}

6
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs

@ -126,9 +126,9 @@ public class ProductionLineItemAppService :
public virtual async Task<ProductionLineItemDTO> GetByProductLineCodeAndItemCodeAsync(string productLineCode, public virtual async Task<ProductionLineItemDTO> GetByProductLineCodeAndItemCodeAsync(string productLineCode,
string itemCode) string itemCode)
{ {
var entityList = await _repository var entity = await _repository
.FindAsync(p => p.ProdLineCode == productLineCode && p.ItemCode == itemCode).ConfigureAwait(false); .FirstOrDefaultAsync(p => p.ProdLineCode == productLineCode && p.ItemCode == itemCode).ConfigureAwait(false);
return ObjectMapper.Map<ProductionLineItem, ProductionLineItemDTO>(entityList); return ObjectMapper.Map<ProductionLineItem, ProductionLineItemDTO>(entity);
} }
[HttpPost("get-by-productlinecode-and-itemcode-and-erplocationcode-async")] [HttpPost("get-by-productlinecode-and-itemcode-and-erplocationcode-async")]
public virtual async Task<List<string>> GetByProductLineCodeAndItemCodeAndErpLocationCodeAsync(List<EnumLocationType> locationType, string erpLocationCodes,string itemCode) public virtual async Task<List<string>> GetByProductLineCodeAndItemCodeAndErpLocationCodeAsync(List<EnumLocationType> locationType, string erpLocationCodes,string itemCode)

32
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs

@ -40,9 +40,12 @@ public class TestService:ApplicationService
/// 生命周期操作 /// 生命周期操作
/// </summary> /// </summary>
[HttpPost("GetMacStatic")] [HttpPost("GetMacStatic")]
public async Task<int> GetMacStatic() public async Task<ResultJson> GetMacStatic()
{ {
return 1;
return new ResultJson() { Code = 200, Msg = "SUCESS", Value = 1 , Valuestr = "", Result = ""};
} }
@ -51,7 +54,7 @@ public class TestService:ApplicationService
/// <summary> /// <summary>
/// 异步开始生命周期操作不能堵塞 /// 异步开始生命周期操作不能堵塞
/// </summary> /// </summary>
public async Task<List<ResponCargoItem>> GetCargoStatic(string AreaID) public async Task<ResponCargos> GetCargoStatic(string AreaID)
{ {
List<ResponCargoItem> result = new List<ResponCargoItem>(); List<ResponCargoItem> result = new List<ResponCargoItem>();
@ -63,7 +66,14 @@ public class TestService:ApplicationService
result = result.Where(p => p.AreaID == AreaID).ToList(); result = result.Where(p => p.AreaID == AreaID).ToList();
return result;
var t = new ResponCargos();
t.Code = 200;
t.Msg = "Success";
t.Datalist = result;
return t;
} }
//[HttpPost("SyncIssueJobStereo")] //[HttpPost("SyncIssueJobStereo")]
@ -82,8 +92,18 @@ public class TestService:ApplicationService
//} //}
[HttpPost("GetCargoStatic1")]
/// <summary>
/// 异步开始生命周期操作不能堵塞
/// </summary>
public async Task<ResponCargos> GetCargoStatic1(ResponCargos p_cas)
{
return p_cas;
}
@ -93,7 +113,9 @@ public class TestService:ApplicationService
}
}
/// <summary> /// <summary>
/// 发给立体库主表 /// 发给立体库主表
/// </summary> /// </summary>

38
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -36,5 +37,42 @@ public sealed class CommonHelper
return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
} }
} }
}
/// <summary>
/// Expression动态拼接+泛型缓存
/// </summary>
/// <typeparam name="TIn"></typeparam>
/// <typeparam name="TOut"></typeparam>
public class ExpressionGenericMapper<TIn, TOut>//Mapper`2
{
private static Func<TIn, TOut> _FUNC = null;
static ExpressionGenericMapper()
{
ParameterExpression parameterExpression = Expression.Parameter(typeof(TIn), "p");
List<MemberBinding> memberBindingList = new List<MemberBinding>();
foreach (var item in typeof(TOut).GetProperties())
{
MemberExpression property = Expression.Property(parameterExpression, typeof(TIn).GetProperty(item.Name));
MemberBinding memberBinding = Expression.Bind(item, property);
memberBindingList.Add(memberBinding);
}
foreach (var item in typeof(TOut).GetFields())
{
MemberExpression property = Expression.Field(parameterExpression, typeof(TIn).GetField(item.Name));
MemberBinding memberBinding = Expression.Bind(item, property);
memberBindingList.Add(memberBinding);
}
MemberInitExpression memberInitExpression = Expression.MemberInit(Expression.New(typeof(TOut)), memberBindingList.ToArray());
Expression<Func<TIn, TOut>> lambda = Expression.Lambda<Func<TIn, TOut>>(memberInitExpression, new ParameterExpression[]
{
parameterExpression
});
_FUNC = lambda.Compile();//拼装是一次性的
}
public static TOut Trans(TIn t)
{
return _FUNC(t);
}
} }

123
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs

@ -25,9 +25,9 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager
public async Task<bool> BatchInsertAsync(List<SplitPackingRec> input) public async Task<bool> BatchInsertAsync(List<SplitPackingRec> input)
{ {
#region 校验
foreach (SplitPackingRec item in input) foreach (SplitPackingRec item in input)
{ {
#region 校验
if (item.OprType == OprTypeEnum.SplitBox || item.OprType == OprTypeEnum.MergeBox) //拆箱或合箱 if (item.OprType == OprTypeEnum.SplitBox || item.OprType == OprTypeEnum.MergeBox) //拆箱或合箱
{ {
if (item.FromPackingCode == item.ToPackingCode) if (item.FromPackingCode == item.ToPackingCode)
@ -42,18 +42,26 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager
throw new UserFriendlyException("操作类型不是拆箱或合箱状态,源箱码和目标箱码必须相同!"); throw new UserFriendlyException("操作类型不是拆箱或合箱状态,源箱码和目标箱码必须相同!");
} }
} }
#endregion
} }
#endregion
//缓存数据
var query = await _repository.GetQueryableAsync().ConfigureAwait(false); var query = await _repository.GetQueryableAsync().ConfigureAwait(false);
var fromPackCodeLst = input.Select(itm => itm.FromPackingCode).ToList();
var toPackCodeLst = input.Select(itm => itm.ToPackingCode).ToList();
var historyLst = await query.Where(itm => fromPackCodeLst.Contains(itm.ToPackingCode) && (itm.OprType == OprTypeEnum.SplitBox || itm.OprType == OprTypeEnum.MergeBox)).ToListAsync().ConfigureAwait(false); //取顶级箱码时用到
var hisLst2 = await query.Where(itm => fromPackCodeLst.Contains(itm.FromPackingCode)).ToListAsync().ConfigureAwait(false);
Dictionary<string, SplitPackingRec> hisLst3 = await query.Where(itm => toPackCodeLst.Contains(itm.FromPackingCode) && itm.OprType == OprTypeEnum.Other).ToDictionaryAsync(itm => itm.FromPackingCode, it2 => it2).ConfigureAwait(false);
//遍历、批量插入
List<SplitPackingRec> operLst = new List<SplitPackingRec>();
foreach (SplitPackingRec item in input) foreach (SplitPackingRec item in input)
{ {
if (item.OprType == OprTypeEnum.SplitBox || item.OprType == OprTypeEnum.MergeBox) if (item.OprType == OprTypeEnum.SplitBox || item.OprType == OprTypeEnum.MergeBox)
{ {
//设置顶级箱码 //设置顶级箱码
item.FromTopPackingCode = CalcuTopPackingCode(query, item.FromPackingCode); item.FromTopPackingCode = CalcuTopPackingCode(input, historyLst, item);
item.ToTopPackingCode = CalcuTopPackingCode(query, item.FromPackingCode); //ToPackingCode item.ToTopPackingCode = CalcuTopPackingCode(input, historyLst, item);
if (item.FromTopPackingCode.IsNullOrEmpty()) if (item.FromTopPackingCode.IsNullOrEmpty())
{ {
item.FromTopPackingCode = item.FromPackingCode; item.FromTopPackingCode = item.FromPackingCode;
@ -63,14 +71,12 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager
item.ToTopPackingCode = item.FromTopPackingCode; item.ToTopPackingCode = item.FromTopPackingCode;
} }
//设置六个单据号 //设置六个单据号
SetBillNumber(query, item); SetBillNumber(hisLst2, item);
//拆箱时,如果目标箱不存在,插入目标箱(两个箱码相同) //拆箱时,如果目标箱不存在,插入目标箱(两个箱码相同)
string toPackCode = item.ToPackingCode; if (hisLst3.ContainsKey(item.ToPackingCode) == false)
var toHis = await query.Where(itm => itm.FromPackingCode == toPackCode && itm.ToPackingCode == toPackCode).OrderBy(itm => itm.CreationTime).FirstOrDefaultAsync().ConfigureAwait(false);
if (toHis == null)
{ {
//SplitPackingRec newObj = CommonHelper.CloneObj(item);
SplitPackingRec newObj = CommonHelper.CloneObj(item); SplitPackingRec newObj = ExpressionGenericMapper<SplitPackingRec, SplitPackingRec>.Trans(item);
newObj.SetId(GuidGenerator.Create()); newObj.SetId(GuidGenerator.Create());
newObj.OprType = OprTypeEnum.Other; newObj.OprType = OprTypeEnum.Other;
newObj.FromPackingCode = newObj.ToPackingCode; //克隆赋值 newObj.FromPackingCode = newObj.ToPackingCode; //克隆赋值
@ -79,11 +85,20 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager
newObj.FromUom = newObj.ToUom; newObj.FromUom = newObj.ToUom;
newObj.FromQty = newObj.ToQty; newObj.FromQty = newObj.ToQty;
newObj.FromLot = newObj.ToLot; newObj.FromLot = newObj.ToLot;
var res = await _repository.InsertAsync(newObj, false).ConfigureAwait(false); //var res = await _repository.InsertAsync(newObj, false).ConfigureAwait(false);
operLst.Add(newObj);
} }
SplitPackingRec newEntity = CommonHelper.CloneObj(item); //var toHis = await query.Where(itm => itm.FromPackingCode == toPackCode && itm.ToPackingCode == toPackCode).OrderBy(itm => itm.CreationTime).FirstOrDefaultAsync().ConfigureAwait(false);
//if (toHis == null)
//{
//}
//SplitPackingRec newEntity = CommonHelper.CloneObj(item);
SplitPackingRec newEntity = ExpressionGenericMapper<SplitPackingRec, SplitPackingRec>.Trans(item);
newEntity.SetId(GuidGenerator.Create()); newEntity.SetId(GuidGenerator.Create());
var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false); // var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false);
operLst.Add(newEntity);
} }
else else
{ {
@ -95,11 +110,14 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager
{ {
item.ToTopPackingCode = item.FromPackingCode;// ToPackingCode; item.ToTopPackingCode = item.FromPackingCode;// ToPackingCode;
} }
SplitPackingRec newEntity = CommonHelper.CloneObj(item); //SplitPackingRec newEntity = CommonHelper.CloneObj(item);
SplitPackingRec newEntity = ExpressionGenericMapper<SplitPackingRec, SplitPackingRec>.Trans(item);
newEntity.SetId(GuidGenerator.Create()); newEntity.SetId(GuidGenerator.Create());
var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false); //var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false);
operLst.Add(newEntity);
} }
} //foreach } //foreach
await _repository.InsertManyAsync(operLst).ConfigureAwait(false);
return true; return true;
} }
@ -203,48 +221,71 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager
} }
/// <summary> /// <summary>
/// 取顶级箱码 /// 取顶级箱码
/// </summary> /// </summary>
/// <param name="historyQuery">箱码历史</param> /// <param name="memoryInput">本次操作要插入的拆箱记录列表,位于内存中</param>
/// <param name="packingCode">箱码,from to时都传入from</param> /// <param name="historyLst">数据库中的历史数据:拆箱或合箱、to箱码=内存中的from箱码</param>
/// <param name="curRecord">内存中当前记录</param>
/// <returns></returns> /// <returns></returns>
private static string CalcuTopPackingCode(IQueryable<SplitPackingRec> historyQuery, string packingCode) private static string CalcuTopPackingCode(List<SplitPackingRec> memoryInput, List<SplitPackingRec> historyLst, SplitPackingRec curRecord)
{ {
var qry = historyQuery.Where(itm => itm.OprType == OprTypeEnum.SplitBox || itm.OprType == OprTypeEnum.MergeBox); //根据当前记录在内存列表中递归取得最上级拆箱记录:1-2 2-3 3-4 根据3-4能取到1-2
string ret = null; SplitPackingRec priorMemoryRecord = curRecord;
SplitPackingRec? firstObj = null;
string toCode = packingCode;
while (1 == 1) while (1 == 1)
{ {
firstObj = qry.FirstOrDefault(itm => itm.ToPackingCode == toCode); var obj = memoryInput.FirstOrDefault(itm => itm.ToPackingCode == priorMemoryRecord.FromPackingCode);
if (firstObj == null) if (obj != null)
{ {
ret = toCode; priorMemoryRecord = obj;
break;
} }
else else
{ {
toCode = firstObj.FromPackingCode; break;
} }
} }
return ret; /*
//var historyRec = historyQuery.Where(itm => itm.FromPackingCode == packingCode).OrderBy(itm => itm.CreationTime).FirstOrDefault(); from箱码在数据库中取上级拆箱记录
//if (historyRec != null)
//{ 1-1
// return historyRec.FromTopPackingCode; 2-2
//} 1-2 to箱码=1=from箱码
//else 3-3
2-3 to箱码=21-2
4-4
3-4 to箱码=32-3
5-5
3-5 to箱码=32-3
*/
var hisObj = historyLst.FirstOrDefault(itm => itm.ToPackingCode == priorMemoryRecord.FromPackingCode);
if (hisObj != null)
{
return hisObj.FromTopPackingCode;
}
else
{
return priorMemoryRecord.FromPackingCode;
}
//var qry = historyLst.Where(itm => itm.OprType == OprTypeEnum.SplitBox || itm.OprType == OprTypeEnum.MergeBox);
//string ret = null;
//SplitPackingRec? firstObj = null;
//string toCode = priorRecord.FromPackingCode;
//while (1 == 1)
//{ //{
// historyRec = historyQuery.Where(itm => itm.ToPackingCode == packingCode).OrderBy(itm => itm.CreationTime).FirstOrDefault(); // firstObj = qry.FirstOrDefault(itm => itm.ToPackingCode == toCode);
// if (historyRec != null) // if (firstObj == null)
// {
// ret = toCode;
// break;
// }
// else
// { // {
// return historyRec.ToTopPackingCode; // toCode = firstObj.FromPackingCode;
// } // }
//} //}
//return null; //return ret;
} }
private static void SetBillNumber(IQueryable<SplitPackingRec> historyQuery, SplitPackingRec obj) private static void SetBillNumber(List<SplitPackingRec> historyQuery, SplitPackingRec obj)
{ {
var historyRec = historyQuery.Where(itm => itm.FromPackingCode == obj.FromPackingCode).OrderBy(itm => itm.CreationTime).FirstOrDefault(); var historyRec = historyQuery.Where(itm => itm.FromPackingCode == obj.FromPackingCode).OrderBy(itm => itm.CreationTime).FirstOrDefault();
if (historyRec != null) if (historyRec != null)

Loading…
Cancel
Save