77 lines
2.8 KiB
C#
77 lines
2.8 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 生产计划管理
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = "ProductionMgr", Name = "WorkOrderCreate", Order = 700)]
|
|
[Route("api/production/[controller]")]
|
|
public class PrdMoService : IPrdMoService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<PrdMoEntity> _repository;
|
|
private readonly IDataBaseManager _dataBaseManager;
|
|
public PrdMoService(ISqlSugarRepository<PrdMoEntity> repository, IDataBaseManager dataBaseManager)
|
|
{
|
|
_repository = repository;
|
|
_dataBaseManager = dataBaseManager;
|
|
}
|
|
/// <summary>
|
|
/// 生产工单创建-生产工单下发
|
|
/// </summary>
|
|
/// <param name="input">生产工单下发输入参数</param>
|
|
/// <returns></returns>
|
|
[HttpPut("workorder-issue")]
|
|
public async Task<dynamic> WorkOrderIssue(WorkOrderIssueCrInput input)
|
|
{
|
|
if (input is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(input));
|
|
}
|
|
var db = await GetDbContext();
|
|
var row = await db.Updateable<PrdMoEntity>()
|
|
.SetColumns(it => new PrdMoEntity { MoStatus = "25019232867093" })
|
|
.Where(it => input.WorkOrderIds.Contains(it.Id))
|
|
.ExecuteCommandAsync();
|
|
return (row > 0);
|
|
}
|
|
/// <summary>
|
|
/// 生产工单-生产排产
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("scheduling")]
|
|
public async Task<dynamic> ProductionScheduling(ProductionSchedulingCrInput input)
|
|
{
|
|
var entity = input.Adapt<PrdTask>();
|
|
entity.Id = input.Id ?? SnowflakeIdHelper.NextId();
|
|
var db = await GetDbContext();
|
|
var row = await db.Storageable(entity).ExecuteCommandAsync();
|
|
return (row > 0);
|
|
}
|
|
|
|
private async Task<ISqlSugarClient> GetDbContext()
|
|
{
|
|
var link = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == "tnb_mes");
|
|
var db = _dataBaseManager.ChangeDataBase(link);
|
|
return db;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |