Wms路径算法代码提交,根据dijkstra
This commit is contained in:
82
WarehouseMgr/Tnb.WarehouseMgr/WmsCollocationSchemeSevice.cs
Normal file
82
WarehouseMgr/Tnb.WarehouseMgr/WmsCollocationSchemeSevice.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 齐套配套方案服务
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class WmsCollocationSchemeSevice : BaseService, IWmsCollocationSchemeSevice
|
||||
{
|
||||
private const string ModuleId = "26167204892965";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly ISqlSugarRepository<WmsCollocationSchemeH> _repository;
|
||||
|
||||
|
||||
|
||||
public WmsCollocationSchemeSevice(
|
||||
ISqlSugarRepository<WmsCollocationSchemeH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
}
|
||||
|
||||
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
|
||||
{
|
||||
string materialCode = "";
|
||||
int seq = 0;
|
||||
|
||||
if (input.data.ContainsKey(nameof(WmsCollocationSchemeH.material_code)))
|
||||
{
|
||||
materialCode = input.data[nameof(WmsCollocationSchemeH.material_code)]?.ToString();
|
||||
}
|
||||
if (input.data.ContainsKey(nameof(WmsCollocationSchemeH.seq)) && input.data[nameof(WmsCollocationSchemeH.seq)] != null)
|
||||
{
|
||||
seq = input.data[nameof(WmsCollocationSchemeH.seq)].ParseToInt();
|
||||
}
|
||||
if (!materialCode.IsNullOrEmpty() && seq > 0)
|
||||
{
|
||||
var item = await _repository.GetFirstAsync(it => it.material_code == materialCode && it.seq == seq);
|
||||
if (item != null)
|
||||
{
|
||||
throw new AppFriendlyException($"物料+顺序【{materialCode}{seq}】,在数据库中已存在", 500);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user