wms库房业务代码提交
This commit is contained in:
102
WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs
Normal file
102
WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
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.BasicData.Entities;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送申请服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class WmsDeliveryService : IOverideVisualDevService, IWmsDeliveryService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26126388337189";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IBasLocationService _basLocationService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public WmsDeliveryService(
|
||||
ISqlSugarRepository<WmsDelivery> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IBasLocationService basLocationService
|
||||
)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_basLocationService = basLocationService;
|
||||
//OverideFuncs.CreateAsync = Create;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据载具编号获取起始库位点
|
||||
/// </summary>
|
||||
/// <param name="carryId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetUnStoreLocationListByCarryId([FromRoute] string carryId)
|
||||
{
|
||||
var items = await _db.Queryable<WmsCarryH>().LeftJoin<BasLocation>((a, b) => a.location_id == b.id)
|
||||
.Where(a => a.id == carryId)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
carry_code = a.carry_code,
|
||||
location_code = b.location_code,
|
||||
})
|
||||
.ToListAsync();
|
||||
return items;
|
||||
}
|
||||
|
||||
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
//startlocation_id
|
||||
//endlocation_id
|
||||
string startLocationId = "", endLocationId = "";
|
||||
if (input.data.ContainsKey(nameof(WmsDelivery.startlocation_id)))
|
||||
{
|
||||
startLocationId = input.data[nameof(WmsDelivery.startlocation_id)]?.ToString()!;
|
||||
}
|
||||
if (input.data.ContainsKey(nameof(WmsDelivery.endlocation_id)))
|
||||
{
|
||||
endLocationId = input.data[nameof(WmsDelivery.endlocation_id)]?.ToString()!;
|
||||
}
|
||||
var locIds = new[] { startLocationId, endLocationId };
|
||||
var locs = await _basLocationService.GetLocationInfobyIds(locIds);
|
||||
if (locs?.Count > 0)
|
||||
{
|
||||
var isStoreLoc = locs.Where(x => !x.IsNullOrEmpty()).Select(x => x.is_type.ParseToInt()).Any(x => x == (int)EnumLocationType.存储库位);
|
||||
if (isStoreLoc) throw new AppFriendlyException("起始库位不能为存储库位", 500);
|
||||
}
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return await Task.FromResult(false);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user