Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -18,6 +18,7 @@ using Tnb.Common.Utils;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -35,11 +36,11 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
public WmsCarryService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IUserManager userManager,
|
||||
IBillRullService billRullService,
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IUserManager userManager,
|
||||
IBillRullService billRullService,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService )
|
||||
IVisualDevService visualDevService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
@@ -49,6 +50,23 @@ namespace Tnb.WarehouseMgr
|
||||
OverideFuncs.CreateAsync = ExchangeCarry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据载具ID获取载具信息
|
||||
/// </summary>
|
||||
/// <param name="carryId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetCarryInfoById([FromRoute] string carryId)
|
||||
{
|
||||
var carryOutPut = await _db.Queryable<WmsCarryH>().Where(it => it.id == carryId).Select<CarryInfoOutput>().FirstAsync();
|
||||
if (carryOutPut == null) throw new AppFriendlyException("找不到载具", 500);
|
||||
carryOutPut.carryDetails = await _db.Queryable<WmsCarryD>().Where(it=>it.carry_id == carryId).ToListAsync();
|
||||
carryOutPut.carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||
carryOutPut.carryMats = await _db.Queryable<WmsCarryMat>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||
return carryOutPut;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更换载具
|
||||
/// </summary>
|
||||
@@ -63,7 +81,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
private async Task<dynamic> ExchangeCarry(VisualDevModelDataCrInput input)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var isOk = false;
|
||||
try
|
||||
@@ -146,7 +164,7 @@ namespace Tnb.WarehouseMgr
|
||||
carryObj.location_id = null;
|
||||
carryObj.location_code = null;
|
||||
carryObj.out_status = "0";
|
||||
carryObj.is_check = 0;
|
||||
carryObj.is_check = 1;
|
||||
carryObj.status = 1;
|
||||
carryObj.bale_num = null;
|
||||
carryObj.collocation_scheme_id = null;
|
||||
|
||||
@@ -95,11 +95,10 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
||||
}
|
||||
var partCarryMats = carryCodesPart.Adapt<List<WmsCarryMat>>();
|
||||
partCarryMats.ForEach(x =>
|
||||
for (int i = 0; i < partCarryMats.Count; i++)
|
||||
{
|
||||
x.need_qty = (int)os.pr_qty;
|
||||
x.real_qty = codeQty;
|
||||
});
|
||||
partCarryMats[i].need_qty = carryCodesPart[i].codeqty;
|
||||
}
|
||||
carryMats.AddRange(partCarryMats);
|
||||
}
|
||||
}
|
||||
@@ -110,12 +109,12 @@ namespace Tnb.WarehouseMgr
|
||||
.Select(x =>
|
||||
{
|
||||
WmsCarryMat? carryMat = x.FirstOrDefault()!;
|
||||
carryMat.real_qty = x.Sum(d => d.real_qty);
|
||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||
return carryMat;
|
||||
})
|
||||
.ToList();
|
||||
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.real_qty);
|
||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
||||
var allOutIds = new List<string>();
|
||||
var sortingOutIds = new List<string>();
|
||||
foreach (var pair in dic)
|
||||
|
||||
@@ -76,11 +76,11 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
||||
}
|
||||
var partCarryMats = carryCodesPart.Adapt<List<WmsCarryMat>>();
|
||||
partCarryMats.ForEach(x =>
|
||||
for (int i = 0; i < partCarryMats.Count; i++)
|
||||
{
|
||||
x.need_qty = (int)os.pr_qty;
|
||||
x.real_qty = codeQty;
|
||||
});
|
||||
partCarryMats[i].need_qty = carryCodesPart[i].codeqty;
|
||||
}
|
||||
|
||||
carryMats.AddRange(partCarryMats);
|
||||
}
|
||||
}
|
||||
@@ -91,89 +91,34 @@ namespace Tnb.WarehouseMgr
|
||||
.Select(x =>
|
||||
{
|
||||
WmsCarryMat? carryMat = x.FirstOrDefault()!;
|
||||
carryMat.real_qty = x.Sum(d => d.real_qty);
|
||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||
return carryMat;
|
||||
})
|
||||
.ToList();
|
||||
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.real_qty);
|
||||
var allOutIds = new List<string>();
|
||||
var sortingOutIds = new List<string>();
|
||||
foreach (var pair in dic)
|
||||
{
|
||||
var codes = carryCodes.FindAll(x => x.carry_id == pair.Key);
|
||||
if (codes?.Count > 0)
|
||||
{
|
||||
if (pair.Value == codes.Sum(d => d.codeqty))
|
||||
{
|
||||
allOutIds.Add(pair.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
sortingOutIds.Add(pair.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
||||
|
||||
carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList();
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
//天益项目不需要
|
||||
//await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||
if (carrys?.Count > 0)
|
||||
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToArrayAsync();
|
||||
if (carrys?.Length > 0)
|
||||
{
|
||||
List<WmsPretaskH> preTasks = new();
|
||||
List<string> locIds = new();
|
||||
foreach (var carry in carrys)
|
||||
string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
|
||||
if (carrys.Length > 6)
|
||||
{
|
||||
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||
WmsPointH ePoint = null!;
|
||||
|
||||
//ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||
var curPreTasks = 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 = WmsWareHouseConst.BIZTYPE_WMSOUTSTOCK_ID;
|
||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
||||
preTask.carry_id = carry.id;
|
||||
preTask.carry_code = carry.carry_code;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.area_code = it.Key;
|
||||
preTask.require_id = "";
|
||||
preTask.require_code = "";
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
//if (loc.is_sign == 0)
|
||||
//{
|
||||
// curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||
//}
|
||||
preTasks.AddRange(curPreTasks);
|
||||
|
||||
}
|
||||
}
|
||||
var leftCarrys = carrys[..6];
|
||||
var rightCarrys = carrys[6..];
|
||||
await _genPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
await _genPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _genPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
}
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, null);
|
||||
GenPreTaskUpInput genPreTaskAfterUpInput = new();
|
||||
@@ -186,5 +131,59 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
private async Task _genPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks)
|
||||
{
|
||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == eLocationId);
|
||||
foreach (var carry in carrys)
|
||||
{
|
||||
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 == eLocationId);
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||
var curPreTasks = 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 = WmsWareHouseConst.BIZTYPE_WMSOUTSTOCK_ID;
|
||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
||||
preTask.carry_id = carry.id;
|
||||
preTask.carry_code = carry.carry_code;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.area_code = it.Key;
|
||||
preTask.require_id = requireId;
|
||||
preTask.require_code = requireCode;
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
if (loc.is_sign == 0)
|
||||
{
|
||||
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||
}
|
||||
preTasks.AddRange(curPreTasks);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.Operations;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -19,10 +26,14 @@ namespace Tnb.WarehouseMgr
|
||||
public class WmsSignForDeliveryService : BaseWareHouseService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
|
||||
public WmsSignForDeliveryService(ISqlSugarRepository<WmsDistaskH> repository)
|
||||
private readonly IWmsCarryService _wareCarryService;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private static Dictionary<string, object> _dicBizType = new();
|
||||
public WmsSignForDeliveryService(ISqlSugarRepository<WmsDistaskH> repository, IWmsCarryService wareCarryService, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_wareCarryService = wareCarryService;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据载具ID获取,对应的执行任务记录
|
||||
@@ -35,10 +46,40 @@ namespace Tnb.WarehouseMgr
|
||||
var item = await _db.Queryable<WmsDistaskH>().FirstAsync(it => it.carry_id == carryId && it.status == WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID && it.is_sign == 0);
|
||||
return item;
|
||||
}
|
||||
/// <summary>
|
||||
/// 出库签收
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task SaveData()
|
||||
public async Task SignForDelivery(SignForDeliveryInput input)
|
||||
{
|
||||
|
||||
if (_dicBizType.Count < 1)
|
||||
{
|
||||
_dicBizType = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_BIZTYPE_ID);
|
||||
}
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carryId);
|
||||
if (carry != null)
|
||||
{
|
||||
var disTask = await _db.Queryable<WmsDistaskH>().SingleAsync(it => it.id == input.disTaskId);
|
||||
if (disTask != null)
|
||||
{
|
||||
if (_dicBizType.ContainsKey(disTask.biz_type))
|
||||
{
|
||||
switch (_dicBizType[disTask.biz_type])
|
||||
{
|
||||
case "空载具出库":
|
||||
case "寄存出库":
|
||||
case "齐套出库":
|
||||
case "一般出库":
|
||||
await _wareCarryService.UpdateNullCarry(carry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == carry.location_id);
|
||||
loc.is_use = "0";
|
||||
await _db.Updateable(loc).UpdateColumns(it => it.is_use).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user