This commit is contained in:
qianjiawei
2023-07-13 17:45:14 +08:00
16 changed files with 288 additions and 180 deletions

View File

@@ -8,14 +8,14 @@
/// <summary>
/// 组织ID
/// </summary>
public string? org_id { get; set; }
public string org_id { get; set; }
/// <summary>
/// 载具Id
/// </summary>
public string? carry_code { get; set;}
public string carry_code { get; set;}
/// <summary>
/// 创建热Id
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
}
}

View File

@@ -14,22 +14,22 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 组织ID
/// </summary>
public string? org_id { get; set; }
public string org_id { get; set; }
/// <summary>
/// 库位编号
/// </summary>
public string? location_code { get; set; }
public string location_code { get; set; }
/// <summary>
/// 载具编号
/// </summary>
public string? carry_code { get; set; }
public string carry_code { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
/// <summary>
/// 入库仓库
/// </summary>
public string? warehouse_id { get; set; }
public string warehouse_id { get; set; }
}
}

View File

@@ -25,20 +25,20 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
/// <summary>
/// 入库仓库
/// </summary>
public string? warehouse_id { get; set; }
public string warehouse_id { get; set; }
/// <summary>
/// 载具规格编号
/// </summary>
public string? carrystd_id { get; set; }
public string carrystd_id { get; set; }
/// <summary>
/// 数量
/// </summary>
public int? qty { get; set; }
public int qty { get; set; }
}
}

View File

@@ -14,7 +14,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 所属组织ID
/// </summary>
public string? org_id { get; set; }
public string org_id { get; set; }
/// <summary>
/// 出库单创建日期
@@ -34,37 +34,37 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 库位ID
/// </summary>
public string? location_id { get; set; }
public string location_id { get; set; }
/// <summary>
/// 库位编号
/// </summary>
public string? location_code { get; set; }
public string location_code { get; set; }
/// <summary>
/// 载具ID
/// </summary>
public string? carry_id { get; set; }
public string carry_id { get; set; }
/// <summary>
/// 载具编号
/// </summary>
public string? carry_code { get; set; }
public string carry_code { get; set; }
/// <summary>
/// 产品ID
/// </summary>
public string? material_id { get; set; }
public string material_id { get; set; }
/// <summary>
/// 产品编号
/// </summary>
public string? material_code { get; set; }
public string material_code { get; set; }
/// <summary>
/// 齐套搭配方案ID
/// </summary>
public string? collocation_scheme_id { get; set; }
public string collocation_scheme_id { get; set; }
/// <summary>
/// 齐套搭配方案编号
@@ -74,7 +74,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 来源单据ID
/// </summary>
public string? source_id { get; set; }
public string source_id { get; set; }
/// <summary>
@@ -85,12 +85,12 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 创建用户ID
/// </summary>
public string? create_id { get; set; }
public string create_id { get; set; }
/// <summary>
/// MES齐套出库明细表输入
/// </summary>
public List<MESKittingOutStkDInput>? wmsKittingoutDs { get; set; }
public List<MESKittingOutStkDInput> wmsKittingoutDs { get; set; }
}
/// <summary>
@@ -108,33 +108,33 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 单位编号
/// </summary>
public string? unit_code { get; set; }
public string unit_code { get; set; }
/// <summary>
/// 产品ID
/// </summary>
public string? material_id { get; set; }
public string material_id { get; set; }
/// <summary>
/// 产品编号
/// </summary>
public string? material_code { get; set; }
public string material_code { get; set; }
/// <summary>
/// 批次
/// </summary>
public string? code_batch { get; set; }
public string code_batch { get; set; }
/// <summary>
/// 数量(件数)
/// </summary>
public decimal? pr_qty { get; set; }
public decimal pr_qty { get; set; }
/// <summary>
/// 箱数
/// </summary>
public int? box { get; set; }
public int box { get; set; }
}
}

View File

@@ -23,5 +23,6 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Outputs
/// </summary>
public object data { get; set; }
}
}

View File

@@ -32,27 +32,26 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
public async Task<dynamic> MESCarryQuery(MESCarryQueryInput input)
{
if (input.IsNull()) throw new ArgumentNullException("input");
var results = new List<CarryQueryOutput>();
var data = new List<CarryQueryOutput>();
try
{
var carrys = await _db.Queryable<WmsCarryH>()
.InnerJoin<WmsCollocationSchemeH>((a, b) => a.collocation_scheme_id == b.id)
.Where((a, b) => a.carry_code.Contains(input.carry_code) || b.bill_name.Contains(input.collocation_scheme_name))
.ToListAsync();
var carrys = await _db.Queryable<WmsCarryH>()
.InnerJoin<WmsCollocationSchemeH>((a, b) => a.collocation_scheme_id == b.id)
.Where((a, b) => a.carry_code.Contains(input.carry_code) || b.bill_name.Contains(input.collocation_scheme_name))
.ToListAsync();
data = carrys.Adapt<List<CarryQueryOutput>>();
results = carrys.Adapt<List<CarryQueryOutput>>();
}
catch (Exception ex)
catch (Exception)
{
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return ToApiResult(results);
return data;
}
/// <summary>
/// 载具查询返回接口
@@ -60,25 +59,26 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
//[NonUnify]
public async Task<dynamic> MESCarryQueryResult(MESCarryQueryResultInput input)
{
if (input.IsNull()) throw new ArgumentNullException("input");
var result = new CarryQueryOutput();
var data = new CarryQueryOutput();
try
{
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carry.id).ToListAsync();
result = carry.Adapt<CarryQueryOutput>();
result.wmsCarryCodes = carryCodes.Adapt<List<CarryCodeQueryOutput>>();
data = carry.Adapt<CarryQueryOutput>();
data.wmsCarryCodes = carryCodes.Adapt<List<CarryCodeQueryOutput>>();
}
catch (Exception ex)
{
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
//return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, result);
//return ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, data);
return data;
}
}
}

View File

@@ -88,14 +88,14 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
//[NonUnify]
public async Task<dynamic> MESCollocationSchemeQuery(MESCollocationSchemeQueryInput input)
{
if (input.IsNull()) throw new ArgumentNullException("input");
var results = new List<CollocationSchemeOutput>();
var data = new List<CollocationSchemeOutput>();
try
{
results = await _db.Queryable<WmsCollocationSchemeH>()
data = await _db.Queryable<WmsCollocationSchemeH>()
.Where(a => a.material_id == input.material_id)
.Select(a => new CollocationSchemeOutput
{
@@ -104,11 +104,10 @@ namespace Tnb.WarehouseMgr
.Mapper(it => it.CollocationSchemeDs = it.list?.Adapt<List<CollocationSchemeDOutput>>())
.ToListAsync();
}
catch (Exception ex)
catch (Exception)
{
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return await ToApiResult(results);
return data;
}
}
}

View File

@@ -87,10 +87,10 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
else
{
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
var sPoint = it.FirstOrDefault();
@@ -153,6 +153,10 @@ namespace Tnb.WarehouseMgr
}
}
else
{
throw new AppFriendlyException("起始库位不可用或无可用的目标库位", 500);
}
await _db.Ado.CommitTranAsync();
}
@@ -169,9 +173,9 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
public async Task<dynamic> MesEmptyCarryInStock(MESEmptyCarryInStockInput input)
{
var isSuccessful = false;
if (input.IsNull()) throw new ArgumentNullException("input");
try
{
@@ -203,15 +207,15 @@ namespace Tnb.WarehouseMgr
data = dic
};
await WmsEmptyIn(visualDevModelDataCrInput);
isSuccessful = true;
}
}
catch (Exception ex)
{
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
//return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return ToApiResult();
return isSuccessful;
}
public async override Task ModifyAsync(WareHouseUpInput input)

View File

@@ -89,25 +89,23 @@ namespace Tnb.WarehouseMgr
WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
{
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0);
}
int i = 0;
//根据每个载具的起始库位做路径运算
for (i = 0; i < setQty.qty; i++)
for (int i = 0; i < setQty.qty; i++)
{
if (carrys?.Count > 0)
{
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
}
var isOk = false;
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
else
{
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
var sPoint = it.FirstOrDefault();
@@ -142,7 +140,6 @@ namespace Tnb.WarehouseMgr
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
}
isOk = await _wareHouseService.GenPreTask(preTasks, null!);
}
if (isOk)
{
@@ -174,6 +171,10 @@ namespace Tnb.WarehouseMgr
it => new BasLocation { is_lock = 1 });
}
}
else
{
throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
}
}
@@ -220,30 +221,29 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
public async Task<dynamic> MESEmptyCarryOutStk(MESEmptyCarryOutStkInput input)
{
if (input.IsNull()) throw new ArgumentNullException("input");
try
{
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
var dic = new Dictionary<string, object>();
dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
var dic = new Dictionary<string, object>();
dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
{
data = dic,
};
await PDAWmsEmptyOut(visualDevModelDataCrInput);
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
{
data = dic,
};
await PDAWmsEmptyOut(visualDevModelDataCrInput);
}
catch (Exception ex)
{

View File

@@ -257,9 +257,9 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
public async Task<dynamic> MESCreateInstock(MESCreateInstockInput input)
{
var isSuccessFul = false;
try
{
await _db.Ado.BeginTranAsync();
@@ -445,6 +445,7 @@ namespace Tnb.WarehouseMgr
await _db.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCOdes.Select(x => x.bill_d_id).Contains(it.id)).ExecuteCommandAsync();
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
}
isSuccessFul = true;
}
}
}
@@ -453,11 +454,12 @@ namespace Tnb.WarehouseMgr
}
catch (Exception ex)
{
isSuccessFul = false;
JNPF.Logging.Log.Error(ex.Message);
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
//return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return await ToApiResult();
return isSuccessFul;
}
}
}

View File

@@ -96,9 +96,19 @@ namespace Tnb.WarehouseMgr
List<WmsCarryCode> carryCodes = new();
foreach (var os in outStockDList)
{
var whereExpr = Expressionable.Create<WmsCarryH, WmsCarryCode, BasLocation>()
.And((a, b, c) => b.material_id == os.material_id)
.And((a, b, c) => a.is_lock == 0)
.And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
.And((a, b, c) => a.status == (int)EnumCarryStatus.)
.And((a, b, c) => c.is_type == ((int)EnumLocationType.).ToString())
.And((a, b, c) => a.out_status == "0")
.And((a, b, c) => c.wh_id == input.data[nameof(WmsOutstockH.warehouse_id)].ToString())
.AndIF(!string.IsNullOrEmpty(os.code_batch), (a, b, c) => b.code_batch == os.code_batch)
.ToExpression();
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
.Where((a, b, c) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus. && c.is_type == ((int)EnumLocationType.).ToString())
.WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch)
.Where(whereExpr)
.Select<WmsCarryCode>()
.ToListAsync();
if (carryCodesPart?.Count > 0)
@@ -201,9 +211,9 @@ namespace Tnb.WarehouseMgr
WmsPretaskH preTask = new()
{
org_id = _userManager.User.OrganizeId,
startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!,
startlocation_id = sPoint?.location_id ?? string.Empty,
startlocation_code = sPoint?.location_code ?? string.Empty,
endlocation_id = ePoint?.location_id ?? string.Empty,
endlocation_code = ePoint?.location_code!,
start_floor = sPoint?.floor.ToString(),
end_floor = ePoint?.floor.ToString(),
@@ -213,13 +223,13 @@ namespace Tnb.WarehouseMgr
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
carry_id = carry.id,
carry_code = carry.carry_code,
area_id = sPoint?.area_id!,
area_id = sPoint?.area_id ?? string.Empty,
area_code = it.Key,
require_id = input.data["ReturnIdentity"].ToString()
require_id = input.data["ReturnIdentity"].ToString(),
require_code = input.data[nameof(preTask.bill_code)]?.ToString()!,
create_id = _userManager.UserId,
create_time = DateTime.Now
};
preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
if (loc.is_sign == 0)
@@ -245,10 +255,17 @@ namespace Tnb.WarehouseMgr
pretaskCodes.AddRange(curPreTaskCodes);
}
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
GenPreTaskUpInput genPreTaskAfterUpInput = new();
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
if (isOk)
{
outStockDList.ForEach(x => x.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID);
await _db.Updateable(outStockDList).UpdateColumns(it => it.line_status).ExecuteCommandAsync();
await _db.Updateable<WmsOutstockH>().SetColumns(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).Where(it => it.id == input.data["ReturnIdentity"].ToString()).ExecuteCommandAsync();
GenPreTaskUpInput genPreTaskAfterUpInput = new();
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
}
}
else throw new AppFriendlyException("库存不足", 500);
}
@@ -288,7 +305,7 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
//[NonUnify]
public async Task<dynamic> MESCreateOutstock(MESCreateOutstockInput input)
{
try
@@ -306,7 +323,7 @@ namespace Tnb.WarehouseMgr
//报错, 提示数据不全。
throw new AppFriendlyException("数据不全!", 500);
}
// 生成库申请数据,添加其他数据 主表
// 生成库申请数据,添加其他数据 主表
outstock.id = SnowflakeIdHelper.NextId();
outstock.location_id = location.id;
outstock.biz_type = WmsWareHouseConst.BIZTYPE_WMSOUTSTOCK_ID;
@@ -439,10 +456,10 @@ namespace Tnb.WarehouseMgr
WmsPretaskH preTask = new()
{
org_id = _userManager.User.OrganizeId,
startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!,
endlocation_code = ePoint?.location_code!,
startlocation_id = sPoint?.location_id ?? string.Empty,
startlocation_code = sPoint?.location_code ?? string.Empty,
endlocation_id = ePoint?.location_id ?? string.Empty,
endlocation_code = ePoint?.location_code ?? string.Empty,
start_floor = sPoint?.floor.ToString(),
end_floor = ePoint?.floor.ToString(),
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
@@ -451,13 +468,14 @@ namespace Tnb.WarehouseMgr
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
carry_id = carry.id,
carry_code = carry.carry_code,
area_id = sPoint?.area_id!,
area_id = sPoint?.area_id ?? string.Empty,
area_code = it.Key,
require_id = outstock.id.ToString()
require_id = outstock.id.ToString(),
require_code = outstock.bill_code?.ToString(),
create_id = _userManager.UserId,
create_time = DateTime.Now
};
preTask.require_code = outstock.bill_code?.ToString()!;
preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
if (location.is_sign == 0)
@@ -483,10 +501,17 @@ namespace Tnb.WarehouseMgr
pretaskCodes.AddRange(curPreTaskCodes);
}
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
GenPreTaskUpInput genPreTaskAfterUpInput = new();
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
if (isOk)
{
outstockDs.ForEach(x => x.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID);
await _db.Updateable(outstockDs).UpdateColumns(it => it.line_status).ExecuteCommandAsync();
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it=>it.id == outstock.id).ExecuteCommandAsync();
GenPreTaskUpInput genPreTaskAfterUpInput = new();
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
}
}
else throw new AppFriendlyException("库存不足", 500);
}

View File

@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.Common.Utils;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Consts;
@@ -93,15 +94,16 @@ namespace Tnb.WarehouseMgr
}
else if (os.pr_qty <= carryCodesPart[i].codeqty)
{
carryCodesPart[i].codeqty = os.pr_qty;
curCarryCodes.Add(carryCodesPart[i]);
WmsCarryCode curCarryCode = DeepCopyHelper<WmsCarryCode>.DeepCopy(carryCodesPart[i]);
curCarryCode.codeqty = os.pr_qty;
curCarryCodes.Add(curCarryCode);
break;
}
}
var partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
for (int i = 0; i < partCarryMats.Count; i++)
{
partCarryMats[i].need_qty = carryCodesPart[i].codeqty;
partCarryMats[i].need_qty = curCarryCodes[i].codeqty;
}
carryMats.AddRange(partCarryMats);

View File

@@ -82,9 +82,6 @@ namespace Tnb.WarehouseMgr
loc.is_use = ((int)EnumCarryStatus.).ToString();
await _db.Updateable(loc).UpdateColumns(it => it.is_use).ExecuteCommandAsync();
}
carry.location_id = null;
carry.location_code = null;
await _db.Updateable(carry).UpdateColumns(it => new { it.location_id, it.location_code }).ExecuteCommandAsync();
WmsDistaskH? disTask = null;
if (!input.disTaskId.IsNullOrEmpty())
{
@@ -129,20 +126,22 @@ namespace Tnb.WarehouseMgr
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost, NonUnify]
[HttpPost]
public async Task<dynamic> MESCarrySign(MESCarrySignInput input)
{
var isSuccessFul = false;
if (input.IsNull()) throw new ArgumentNullException("input");
var signInput = input.Adapt<SignForDeliveryInput>();
try
{
await SignForDelivery(signInput);
isSuccessFul = true;
}
catch (Exception)
{
return ToApiResult(HttpStatusCode.InternalServerError, "签收失败");
isSuccessFul= false;
}
return ToApiResult();
return isSuccessFul;
}
}
}

View File

@@ -132,71 +132,85 @@ namespace Tnb.WarehouseMgr
public async Task KittingOutByIsToBeShipped()
{
var kittingOuts = await _db.Queryable<WmsKittingoutH>()
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID)
.OrderBy(a => a.seq)
.ToListAsync();
if (kittingOuts?.Count > 0)
try
{
var grpList = kittingOuts.GroupBy(g => g.location_id).ToList();
foreach (var koGrp in grpList)
var kittingOuts = await _db.Queryable<WmsKittingoutH>()
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID)
.OrderBy(a => a.seq)
.ToListAsync();
if (kittingOuts?.Count > 0)
{
var locs = await _db.Queryable<BasLocation>().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.).ToString() && it.is_lock == 0).ToListAsync();
if (locs?.Count > 0)
var grpList = kittingOuts.GroupBy(g => g.location_id).ToList();
foreach (var koGrp in grpList)
{
var arr = koGrp.ToArray();
var ko = arr[^arr.Length];
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == ko.carry_id);
if (carry != null)
var locs = await _db.Queryable<BasLocation>().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.).ToString() && it.is_lock == 0).ToListAsync();
if (locs?.Count > 0)
{
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == ko.location_id);
if (sPoint != null && ePoint != null)
var arr = koGrp.ToArray();
var ko = arr[^arr.Length];
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == ko.carry_id);
if (carry != null)
{
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points?.Count > 0)
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == ko.location_id);
if (sPoint != null && ePoint != null)
{
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
if (points?.Count > 0)
{
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = ko.biz_type;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
preTask.carry_id = ko!.carry_id!;
preTask.carry_code = ko!.carry_code!;
preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key;
preTask.require_id = ko.id;
preTask.require_code = ko.bill_code;
preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
await _warehouseService.GenPreTask(preTasks, null!);
var subCarrys = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == ko.carry_id).ToListAsync();
var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList();
GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List<string> { carry.location_id!, ko.location_id! } };
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_lock = 1 });
WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = ko.biz_type;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
preTask.carry_id = ko!.carry_id!;
preTask.carry_code = ko!.carry_code!;
preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key;
preTask.require_id = ko.id;
preTask.require_code = ko.bill_code;
preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
await _warehouseService.GenPreTask(preTasks, null!);
var subCarrys = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == ko.carry_id).ToListAsync();
var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList();
GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List<string> { carry.location_id!, ko.location_id! } };
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_lock = 1 });
}
}
}
else
{
throw new AppFriendlyException("无可用的载具", 500);
}
}
else
{
throw new AppFriendlyException("无可用的库位", 500);
}
}
}
}
catch (Exception)
{
throw;
}
}
public override async Task ModifyAsync(WareHouseUpInput input)
@@ -288,9 +302,9 @@ namespace Tnb.WarehouseMgr
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[NonUnify]
public async Task<dynamic> MESKittingOutStk(List<MESKittingOutStkInput> input)
{
var isSuccessFul = false;
if (input.IsNull()) throw new ArgumentNullException("input");
try
{
@@ -320,15 +334,18 @@ namespace Tnb.WarehouseMgr
}
await _db.Insertable(kittingOuts).ExecuteCommandAsync();
await _db.Insertable(kittingOutDs).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
await KittingOutByAdd();
isSuccessFul = true;
}
catch (Exception ex)
{
isSuccessFul = false;
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
await KittingOutByAdd();
return ToApiResult();
return isSuccessFul;
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.Common.Utils
{
public class PropertyNotNullChecker<T>
{
private static readonly Dictionary<Type, Func<T, bool>> Cache = new Dictionary<Type, Func<T, bool>>();
public static bool CheckAllPropertiesNotNull(T obj)
{
//Type type = typeof(T);
//// 检查缓存中是否存在类型的检查方法
//if (Cache.TryGetValue(type, out var checkFunc))
//{
// return checkFunc(obj);
//}
//var properties = type.GetProperties();
//// 创建表达式树的参数
//var objParam = Expression.Parameter(type, "obj");
//var propertyNotNullExpressions = new List<Expression>();
//foreach (var property in properties)
//{
// // 创建访问属性的表达式
// var propertyAccess = Expression.Property(objParam, property);
// // 创建检查属性非空的表达式
// var notNullExpression = Expression.NotEqual(propertyAccess, Expression.Constant(null));
// propertyNotNullExpressions.Add(notNullExpression);
//}
//// 创建所有属性非空的表达式
//var allPropertiesNotNullExpression = Expression.AndAlso(propertyNotNullExpressions);
//// 创建Lambda表达式
//var lambda = Expression.Lambda<Func<T, bool>>(allPropertiesNotNullExpression, objParam);
//// 编译表达式并执行
//var func = lambda.Compile();
//// 将类型和检查方法添加到缓存中
//Cache[type] = func;
//return func(obj);
return false;
}
}
}

View File

@@ -69,7 +69,7 @@ public class WechatOpenService : IDynamicApiController, ITransient
[HttpPost("token")]
[AllowAnonymous]
[IgnoreLog]
[NonUnify]
//[NonUnify]
public async Task<dynamic> Create([FromQuery] string signature, [FromQuery] string timestamp, [FromQuery] string nonce, [FromQuery] string openid)
{
var input = await GetWechatMPEvent();