调整获取随机数方式

This commit is contained in:
yang.lee
2023-11-14 15:21:18 +08:00
parent cd7d12a301
commit 3f6deb4204
4 changed files with 18 additions and 19 deletions

View File

@@ -290,7 +290,7 @@ namespace Tnb.WarehouseMgr
[HttpGet]
public async Task<dynamic> GetTaskDetailByCheckType([FromQuery] CheckDetailQuery input)
{
if(_carryMap.Count == 0)
if (_carryMap.Count == 0)
{
_carryMap = await _db.Queryable<WmsCarryH>().ToDictionaryAsync(x => x.id, x => x.carry_code);
}
@@ -299,28 +299,26 @@ namespace Tnb.WarehouseMgr
.And((a, b, c) => a.wh_id == input.warehouse_id)
.And((a, b, c) => a.is_type == ((int)EnumLocationType.).ToString())
.And((a, b, c) => c.is_lock == 0);
switch (input.CheckType)
filterExpable = input.CheckType switch
{
case EnumCheckType.:
filterExpable.AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id);
break;
case EnumCheckType.:
filterExpable.AndIF(input.regionIds?.Count> 0, (a, b, c) => input.regionIds.Contains(a.region_id));
break;
}
EnumCheckType. => filterExpable.AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id),
EnumCheckType. => filterExpable.AndIF(input.regionIds?.Count > 0, (a, b, c) => input.regionIds.Contains(a.region_id)),
_ => filterExpable,
};
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<WmsCarryCode>()
.ToListAsync();
List<CheckTaskDetailOutput> outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new CheckTaskDetailOutput
List<WmsCheckstockD> outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new WmsCheckstockD
{
material_code = x.Key.material_code,
code_batch = x.Key.code_batch,
location_code = x.Key.location_code,
carry_id = x.Key.carry_id,
carry_code = _carryMap[x.Key.carry_id]?.ToString() ?? string.Empty,
location_id = x.FirstOrDefault(y => y.location_code == x.Key.location_code)?.location_id ?? string.Empty,
location_code = x.Key.location_code,
pr_qty = x.Sum(d => d.codeqty),
closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID,
qty = 0,

View File

@@ -114,7 +114,7 @@ namespace Tnb.WarehouseMgr
List<string?> freeLocIds = fLocIds.Except(minTaskNumLocs.Select(x => x.endlocation_id)).ToList();
if (freeLocIds?.Count > 0)
{
int rIdx = new Random().Next(0, freeLocIds.Count);
int rIdx = Random.Shared.Next(0, freeLocIds.Count);
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == freeLocIds[rIdx]);
}
else
@@ -125,7 +125,7 @@ namespace Tnb.WarehouseMgr
}
else if (minTaskNumLocs?.Count < 1)
{
int rIdx = new Random().Next(0, fLocIds.Count);
int rIdx = Random.Shared.Next(0, fLocIds.Count);
loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == fLocIds[rIdx]);
}
input.data[nameof(WmsOutstockH.location_id)] = loc.id;

View File

@@ -28,7 +28,7 @@ namespace Tnb.WarehouseMgr
/// 采购收货、销售发货,通用业务类
/// </summary>
/// <typeparam name="TSubEntity"></typeparam>
public class WmsPurchaseAndSaleCommonService<TSubEntity> : BaseWareHouseService where TSubEntity : BaseEntity<string>, IPurchaseAndSaleEntity, IPurchaseAndSaleQueryEntity
public class WmsPurchaseAndSaleCommonService<TSubEntity> : BaseWareHouseService where TSubEntity : BaseEntity<string>, IPurchaseAndSaleEntity, IPurchaseAndSaleQueryEntity,new()
{
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
@@ -86,7 +86,7 @@ namespace Tnb.WarehouseMgr
x.modify_time = DateTime.Now;
});
await _db.Updateable(purchaseDs).ExecuteCommandAsync();
await _db.Updateable(purchaseDs).UpdateColumns(it => new { it.purchase_prqty, it.line_status }).ExecuteCommandAsync();
if (purchaseDs.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
{
@@ -125,7 +125,7 @@ namespace Tnb.WarehouseMgr
return await _db.Updateable<TEntity>().SetColumns(it => it.audit_status == (int)input.auditType).Where(it => input.ids.Contains(it.id)).ExecuteCommandHasChangeAsync();
}
protected Task SyncMesData(string maintableId,List<string> materialIds,EnumTriggerEvent triggerEvent)
protected Task SyncMesData(string maintableId, List<string> materialIds, EnumTriggerEvent triggerEvent)
{
CreateTaskEntity ctEntity = new();
ctEntity.maintableid = maintableId;

View File

@@ -80,6 +80,7 @@ namespace Tnb.WarehouseMgr
instockDs = purchaseDs.Adapt<List<WmsInstockD>>();
instockDs.ForEach(instockD =>
{
instockD.bill_id =instock.id;
instockD.create_id = _userManager.UserId;
instockD.create_time = DateTime.Now;
instockD.org_id = _userManager.User.OrganizeId;
@@ -87,7 +88,7 @@ namespace Tnb.WarehouseMgr
await _db.Insertable(instockDs).ExecuteCommandAsync();
}
//通知Mes接口
_ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.);
//_ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.入厂检按物料编号);
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)