Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
2023-11-23 09:36:26 +08:00
7 changed files with 242 additions and 9 deletions

View File

@@ -204,5 +204,9 @@ public class ModuleConsts
/// 模块标识-盘点签收配置
/// </summary>
public const string MODULE_WMSCHECKSIGNCONFIG_ID = "30059737083669";
/// <summary>
/// 模块标识-PDA盘点签收
/// </summary>
public const string MODLUE_WMSTASKSTOCK_ID = "27690726707477";
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
{
/// <summary>
/// Pda盘点签收输入参数
/// </summary>
public class TakeStockSignInput
{
public List<WmsCheckstockCode> details{ get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.WarehouseMgr.Entities.Dto.Queries
{
/// <summary>
/// 根据条码编号、载具Id获取条码信息输入参数
/// </summary>
public class CarryCodeInfoQuery
{
/// <summary>
/// 条码编号
/// </summary>
public string barcode { get; set; }
/// <summary>
/// 载具Id
/// </summary>
public string carryId { get; set; }
}
}

View File

@@ -12,5 +12,10 @@ public partial class WmsCheckstockD
/// </summary>
[SugarColumn(IsIgnore = true)]
public decimal codeqty { get; set; }
/// <summary>
/// 待盘点数量
/// </summary>
[SugarColumn(IsIgnore = true)]
public decimal? delayeqty { get; set; }
}

View File

@@ -370,13 +370,13 @@ namespace Tnb.WarehouseMgr
/// 根据产线获取Agv列表
/// </summary>
/// <param name="lineId">产线Id默认空(潍柴的只有一条产线所以不用传)</param>
/// <returns>
/// <remarks>
/// returns:
/// <br/>{
/// <br/> name:设备名称
/// <br/> code:设备代码
/// <br/>}
/// </returns>
/// </remarks>
[HttpGet("lineId"), AllowAnonymous]
public async Task<dynamic> GetAgvListByLineId(string lineId = "")
{
@@ -394,7 +394,7 @@ namespace Tnb.WarehouseMgr
/// 获取Agv实时信息
/// </summary>
/// <param name="q">查询输入参数</param>
/// <returns>
///<remarks>
/// <br/>{
/// <br/> deviceCode:设备序号
/// <br/> devicePostionRec:设备所在二维码的x,y坐标前边的值是x后边的是y
@@ -403,7 +403,7 @@ namespace Tnb.WarehouseMgr
/// <br/> speed:速度
/// <br/> shelfNumber当前搬运的货架编号,对应载具编号
/// <br/>}
/// </returns>
///</remarks>
[HttpGet, AllowAnonymous]
public async Task<List<AgvRealInfoOutput>> GetAgvRealInfo([FromQuery] AgvRealInfoQuery q)
{

View File

@@ -1,5 +1,6 @@
using System.Linq;
using System.Linq.Expressions;
using Aop.Api.Domain;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Extension;
@@ -12,12 +13,16 @@ using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.OpenXmlFormats.Dml.Spreadsheet;
using NPOI.SS.Formula.PTG;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Tnb.WarehouseMgr.Entities.Dto.Queries;
using Tnb.WarehouseMgr.Entities.Enums;
@@ -146,7 +151,7 @@ namespace Tnb.WarehouseMgr
var carryCodes = await _db.Queryable<BasLocation>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.location_id)
.InnerJoin<WmsCarryH>((a, b, c) => b.carry_id == c.id)
.Where(filterExpable.ToExpression())
.Select((a,b,c)=>new WmsCarryCode { carry_code = c.carry_code},true)
.Select((a, b, c) => new WmsCarryCode { carry_code = c.carry_code }, true)
.ToListAsync();
carryCodes ??= Enumerable.Empty<WmsCarryCode>().ToList();
@@ -166,7 +171,7 @@ namespace Tnb.WarehouseMgr
details.Add(checkstockD);
}
}
var r = await _db.Insertable(details).ExecuteCommandAsync();
var r = await _db.Insertable(details).ExecuteCommandAsync();
//生成预任务信息
if (details.Count > 0 && carryCodes.Count > 0)
{
@@ -313,7 +318,7 @@ namespace Tnb.WarehouseMgr
private Task<List<WmsDistaskH>> FetchDisTasks(Expression<Func<WmsDistaskH, BasLocation, bool>> joinExp, Expression<Func<WmsDistaskH, BasLocation, bool>> whereExp)
{
var details= _db.CopyNew().Queryable<WmsDistaskH>().InnerJoin<BasLocation>(joinExp).Where(whereExp).Select<WmsDistaskH>().ToListAsync();
var details = _db.CopyNew().Queryable<WmsDistaskH>().InnerJoin<BasLocation>(joinExp).Where(whereExp).Select<WmsDistaskH>().ToListAsync();
return details;
}
/// <summary>
@@ -324,7 +329,10 @@ namespace Tnb.WarehouseMgr
[HttpGet("{checkStockId}")]
public async Task<List<WmsCheckstockD>> GetCheckStockDList(string checkStockId)
{
var details = await _db.Queryable<WmsCheckstockD>().Where(it => it.checkstock_id == checkStockId).ToListAsync();
var details = await _db.Queryable<WmsCheckstockD>().Where(it => it.checkstock_id == checkStockId)
.Select<WmsCheckstockD>()
.Mapper(it => it.delayeqty = Math.Max(0, it.pr_qty.Value - it.qty.Value))
.ToListAsync();
return details;
}
@@ -384,7 +392,7 @@ namespace Tnb.WarehouseMgr
var carryCodes = await _db.Queryable<BasLocation>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.location_id)
.InnerJoin<WmsCarryH>((a, b, c) => b.carry_id == c.id)
.Where(filterExp)
.Select((a, b, c) =>new WmsCarryCode { carry_code=c.carry_code },true)
.Select<WmsCarryCode>()
.ToListAsync();
List<WmsCheckstockD> outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new WmsCheckstockD
@@ -402,5 +410,158 @@ namespace Tnb.WarehouseMgr
.ToList();
return outputs;
}
/// <summary>
/// 获取盘点任务信息
/// </summary>
/// <param name="carryCode">载具编号</param>
/// <returns></returns>
/// <remarks>
///
/// </remarks>
[HttpGet("{carryCode}")]
public async Task<dynamic> GetCheckTaskInfo(string carryCode)
{
var result = await _db.Queryable<WmsDistaskH>().InnerJoin<WmsCheckstockH>((a, b) => a.require_id == b.id)
.Where((a, b) => a.carry_code == carryCode)
.Select<WmsCheckstockH>()
.ToListAsync();
return result;
}
/// <summary>
/// 根据条码编号和载具id获取对应载具条码信息
/// </summary>
/// <param name="q"></param>
/// <returns></returns>
public async Task<dynamic> GetCarryCodeInfoByBarCode([FromQuery] CarryCodeInfoQuery q)
{
var items = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id)
.Where((a, b) => b.barcode == q.barcode && b.carry_id == q.carryId)
.Select((a, b) => new WmsCarryCode { carry_code = a.carry_code }, true)
.ToListAsync();
return items;
}
public async Task TakeStockSign(TakeStockSignInput input)
{
if (input == null) throw new ArgumentNullException("input");
if (input.details == null) throw new ArgumentNullException(nameof(input.details));
var checkStockCodes = input.details.Adapt<List<WmsCheckstockCode>>();
var disTask = await _db.Queryable<WmsDistaskH>().Where(it => it.carry_id == checkStockCodes[0].carry_id &&
it.status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID &&
it.is_sign == 0).FirstAsync();
if (disTask != null)
{
disTask.is_sign = 1;
_ = await _db.Updateable(disTask).UpdateColumns(it => it.is_sign).ExecuteCommandAsync();
}
var checkStock = await _db.Queryable<WmsCheckstockH>().SingleAsync(it => it.id == checkStockCodes[0].checkstock_id);
if (checkStock != null)
{
InStockStrategyQuery q = new() { warehouse_id = checkStock.warehouse_id };
var endLocs = await _warehouseService.InStockStrategy(q);
WmsPointH? sPoint = null, ePoint = null;
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == checkStockCodes[0].carry_id);
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
if (endLocs?.Count > 0)
{
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocs[0].id);
}
if (sPoint == null || ePoint == null) throw new AppFriendlyException("路径无效", 500);
List<WmsPointH> points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
{
if (points.Count <= 2)
{
throw new AppFriendlyException("该路径不存在", 500);
}
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
WmsPointH? sPoint = it.FirstOrDefault();
WmsPointH? ePoint = it.LastOrDefault();
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!,
start_floor = sPoint?.floor.ToString(),
end_floor = ePoint?.floor.ToString(),
startpoint_id = sPoint?.id!,
startpoint_code = sPoint?.point_code!,
endpoint_id = ePoint?.id!,
endpoint_code = ePoint?.point_code!,
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID,
task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
carry_id = carry?.id,
carry_code = carry?.carry_code,
area_id = sPoint?.area_id!,
area_code = it.Key,
create_id = _userManager.UserId,
create_time = DateTime.Now
};
return preTask;
}).ToList();
bool isOk = await _warehouseService.GenPreTask(preTasks, null!);
if (isOk)
{
GenPreTaskUpInput preTaskUpInput = new()
{
//RquireId = input.data["ReturnIdentity"].ToString()!,
CarryId = checkStockCodes[0].carry_id,
CarryStartLocationId = points.FirstOrDefault()!.location_id!,
CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
LocationIds = points.Select(x => x.location_id).ToList()!
};
WmsHandleH handleH = new()
{
org_id = _userManager.User.OrganizeId,
startlocation_id = carry.location_id,
endlocation_id = endLocs?[0].id ?? string.Empty,
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(),
biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID,
carry_id = checkStockCodes[0].carry_id,
carry_code = carry?.carry_code ?? string.Empty,
create_id = _userManager.UserId,
create_time = DateTime.Now
};
preTaskUpInput.PreTaskRecord = handleH;
//根据载具移入Id回更单据状态
_ = await _db.Updateable<WmsMoveInstock>().SetColumns(it => new WmsMoveInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
await _warehouseService.GenInStockTaskHandleAfter(preTaskUpInput,
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
it => new BasLocation { is_lock = 1 });
}
}
}
foreach (var csCode in checkStockCodes)
{
csCode.id = SnowflakeIdHelper.NextId();
var checkStockPartDs = await _db.Queryable<WmsCheckstockD>().Where(it => it.checkstock_id == csCode.checkstock_id).ToListAsync();
var checkStockDMap = checkStockPartDs.GroupBy(g => $"{g.carry_id}{g.material_id}{g.code_batch}").ToDictionary(x => x.Key, x => x.First().id);
csCode.checkstock_d_id = checkStockDMap.ContainsKey($"{csCode.carry_id}{csCode.material_id}{csCode.code_batch}") ? checkStockDMap[$"{csCode.carry_id}{csCode.material_id}{csCode.code_batch}"] : "";
}
//插入 盘点code表
await _db.Insertable(checkStockCodes).ExecuteCommandAsync();
var detailIds = checkStockCodes.Select(x => x.checkstock_d_id).ToList();
var checkStockDs = _db.Queryable<WmsCheckstockD>().Where(it => detailIds.Contains(it.id)).ToListAsync();
foreach (var csCode in checkStockCodes)
{
}
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.VisualDev;
using SqlSugar;
using Tnb.WarehouseMgr.Entities;
namespace Tnb.WarehouseMgr
{
/// <summary>
/// Pda盘点
/// </summary>
[OverideVisualDev(ModuleConsts.MODLUE_WMSTASKSTOCK_ID)]
public class WmsPDATakeStockService : BaseWareHouseService
{
private readonly ISqlSugarClient _db;
public WmsPDATakeStockService(ISqlSugarRepository<WmsCheckstockH> repo)
{
_db = repo.AsSugarClient();
}
}
}