83 lines
2.8 KiB
C#
83 lines
2.8 KiB
C#
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 : BaseWareHouseService, 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);
|
|
}
|
|
}
|
|
}
|