工序工位存入bas_process_station
This commit is contained in:
90
BasicData/Tnb.BasicData/BasProcessService.cs
Normal file
90
BasicData/Tnb.BasicData/BasProcessService.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
/// <summary>
|
||||
/// 工序定义
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModelId)]
|
||||
public class BasProcessService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
public const string ModelId = "25483283228965";
|
||||
private readonly ISqlSugarRepository<BasProcess> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
public BasProcessService(
|
||||
ISqlSugarRepository<BasProcess> repository,
|
||||
IUserManager userManager,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
DataBaseManager dbManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_dbManager = dbManager;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存工序工位关联表
|
||||
/// </summary>
|
||||
/// <param name="processStationInput">process_id 工序id</param>
|
||||
/// <param name="processStationInput">stationIds 工位id集合</param>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModelId, true);
|
||||
await _runService.Create(templateEntity, visualDevModelDataCrInput);
|
||||
|
||||
string processId = visualDevModelDataCrInput.data["ReturnIdentity"].ToString();
|
||||
|
||||
List<BasProcessStation> list = new List<BasProcessStation>();
|
||||
foreach (var item in (JArray)visualDevModelDataCrInput.data["station"])
|
||||
{
|
||||
|
||||
string processStationId = SnowflakeIdHelper.NextId();
|
||||
list.Add(new BasProcessStation()
|
||||
{
|
||||
id = processStationId,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
process_id = processId,
|
||||
station_id = item.Last().ToString(),
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
});
|
||||
}
|
||||
|
||||
await _repository.AsSugarClient().Insertable<BasProcessStation>(list).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user