调整出库申请,终止点位代码逻辑

This commit is contained in:
alex
2023-09-05 17:40:35 +08:00
parent 9fb0e0eba8
commit a6fdf64681
5 changed files with 71 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Aop.Api.Domain;
@@ -10,12 +11,14 @@ using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using SqlSugar.DbConvert;
using Tnb.BasicData.Entities;
@@ -101,10 +104,15 @@ namespace Tnb.WarehouseMgr
code_batch = os.code_batch,
};
var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
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) => outStkCarrys.Select(x => x.id).Contains(b.carry_id))
.Select<WmsCarryCode>()
.ToListAsync();
Expression<Func<WmsCarryH, WmsCarryCode, bool>> whereExp = input.data.ContainsKey(nameof(WmsOutstockH.carry_id))
? (a, b) => a.id == input.data[nameof(WmsOutstockH.carry_id)].ToString()
: (a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id);
List<WmsCarryCode>? 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(whereExp)
.Select<WmsCarryCode>()
.ToListAsync(); ;
if (carryCodesPart?.Count > 0)
{
var codeQty = carryCodesPart.Sum(x => x.codeqty);
@@ -199,6 +207,37 @@ namespace Tnb.WarehouseMgr
{
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
}
else if (input.data.ContainsKey(nameof(WmsOutstockH.station_id)))
{
//多个投料库位
/*
* 潍柴
* 1、那个库位状态是空的出那个
* 1.1、没有空位直接抛异常
*
* 天益
* 2、不管库位是否为空 获取到所有库位 A B
* 2.1 根据这些库位去查任务执行 目的库位是这些库位的未完成任务数。 A 10 B 9
* 2.2 哪个最少给哪个
*/
var org = await _db.Queryable<OrganizeEntity>().FirstAsync(it => it.Id == input.data[nameof(WmsOutstockH.station_id)].ToString());
if (!org?.FeedingLocationId.IsNullOrWhiteSpace() ?? false)
{
var fLocIds = JArray.Parse(org.FeedingLocationId).Values<string>();
var minTaskNumLoc = await _db.Queryable<WmsPretaskH>().Where(it => it.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && fLocIds.Contains(it.endlocation_id))
.GroupBy(it => it.endlocation_id)
.Select(it => new
{
it.endlocation_id,
count = SqlFunc.AggregateCount(it.endlocation_id)
})
.MergeTable()
.OrderBy(it => it.count)
.FirstAsync();
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == minTaskNumLoc.endlocation_id);
}
}
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);