using JNPF.Common.Core.Manager; using JNPF.Common.Extension; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Systems.Entitys.System; using Mapster; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using NPOI.OpenXmlFormats.Shared; using SqlSugar; using Tnb.ProductionMgr.Entitys.Dto.WorkOrder; using Tnb.ProductionMgr.Entitys.Entity; using Tnb.ProductionPlanMgr.Entitys.Dto.WorkOrder; using Tnb.ProductionPlanMgr.Interfaces; namespace Tnb.ProductionPlanMgr { /// /// 生产计划管理 /// [ApiDescriptionSettings(Tag = "ProductionMgr", Name = "WorkOrderCreate", Order = 700)] [Route("api/production/[controller]")] public class PrdMoService : IPrdMoService, IDynamicApiController, ITransient { private readonly ISqlSugarRepository _repository; private readonly IDataBaseManager _dataBaseManager; public PrdMoService(ISqlSugarRepository repository, IDataBaseManager dataBaseManager) { _repository = repository; _dataBaseManager = dataBaseManager; } /// /// 生产工单创建-生产工单下发 /// /// 生产工单下发输入参数 /// [HttpPut("workorder-issue")] public async Task WorkOrderIssue(WorkOrderIssueCrInput input) { if (input is null) { throw new ArgumentNullException(nameof(input)); } var db = await GetDbContext(); var row = await db.Updateable() .SetColumns(it => new PrdMoEntity { MoStatus = "25019232867093" }) .Where(it => input.WorkOrderIds.Contains(it.Id)) .ExecuteCommandAsync(); return (row > 0); } /// /// 生产工单-生产排产 /// /// /// [HttpPost("scheduling")] public async Task ProductionScheduling(ProductionSchedulingCrInput input) { var entity = input.Adapt(); entity.Id = input.Id ?? SnowflakeIdHelper.NextId(); var db = await GetDbContext(); var row = await db.Storageable(entity).ExecuteCommandAsync(); return (row > 0); } private async Task GetDbContext() { var link = await _repository.AsSugarClient().Queryable().FirstAsync(x => x.FullName == "tnb_mes"); var db = _dataBaseManager.ChangeDataBase(link); return db; } } }