组织管理代码调整

This commit is contained in:
DEVICE8\12494
2023-04-21 09:06:49 +08:00
parent 95cc47ebac
commit ab92c80838
21 changed files with 558 additions and 36 deletions

View File

@@ -1,13 +1,17 @@
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.Entitys.Entity;
using Tnb.ProductionPlanMgr.Interfaces;
namespace Tnb.ProductionPlanMgr
@@ -15,13 +19,13 @@ namespace Tnb.ProductionPlanMgr
/// <summary>
/// 生产计划管理
/// </summary>
[ApiDescriptionSettings(Tag = "ProductPlanMgr", Name = "WorkOrderCreate", Order = 700)]
[ApiDescriptionSettings(Tag = "ProductionMgr", Name = "WorkOrderCreate", Order = 700)]
[Route("api/production/[controller]")]
public class WorkOrderCreateService :IWorkOrderCreateService,IDynamicApiController, ITransient
public class PrdMoService : IPrdMoService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<PrdMoEntity> _repository;
private readonly IDataBaseManager _dataBaseManager;
public WorkOrderCreateService(ISqlSugarRepository<PrdMoEntity> repository, IDataBaseManager dataBaseManager)
public PrdMoService(ISqlSugarRepository<PrdMoEntity> repository, IDataBaseManager dataBaseManager)
{
_repository = repository;
_dataBaseManager = dataBaseManager;
@@ -38,13 +42,36 @@ namespace Tnb.ProductionPlanMgr
{
throw new ArgumentNullException(nameof(input));
}
var link = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == "tnb_mes");
var db = _dataBaseManager.ChangeDataBase(link);
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;
}
}
}

View File

@@ -11,8 +11,8 @@
<ItemGroup>
<ProjectReference Include="..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" />
<ProjectReference Include="..\common\Tnb.Common\Tnb.Common.csproj" />
<ProjectReference Include="..\Tnb.ProductionPlanMgr.Entitys\Tnb.ProductionPlanMgr.Entitys.csproj" />
<ProjectReference Include="..\Tnb.ProductionPlanMgr.Interfaces\Tnb.ProductionPlanMgr.Interfaces.csproj" />
<ProjectReference Include="..\Tnb.ProductionPlanMgr.Entitys\Tnb.ProductionMgr.Entitys.csproj" />
<ProjectReference Include="..\Tnb.ProductionPlanMgr.Interfaces\Tnb.ProductionMgr.Interfaces.csproj" />
</ItemGroup>
</Project>

View File

@@ -4,20 +4,80 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Cells;
using DingTalk.Api.Request;
using JNPF.Common.Core.Manager;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Systems.Entitys.System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.UserModel;
using SqlSugar;
using Tnb.ProductionMgr.Entitys.Entity;
namespace Tnb.ProductionPlanMgr
{
[ApiDescriptionSettings(Tag = "ProductPlanMgr", Name = "WorkOrderScheduling", Order = 700)]
/// <summary>
/// 生产排产
/// </summary>
[ApiDescriptionSettings(Tag = "ProductMgr", Name = "WorkOrderScheduling", Order = 700)]
[Route("api/production/[controller]")]
public class WorkOrderSchedulingService: IDynamicApiController, ITransient
public class WorkOrderSchedulingService : IDynamicApiController, ITransient
{
public WorkOrderSchedulingService()
private readonly IDataBaseManager _dataBaseManager;
private readonly ISqlSugarRepository<DbLinkEntity> _repository;
public WorkOrderSchedulingService(IDataBaseManager dataBaseManager, ISqlSugarRepository<DbLinkEntity> repository)
{
_dataBaseManager = dataBaseManager;
_repository = repository;
}
/// <summary>
/// 测试数据导入
/// </summary>
/// <returns></returns>
[HttpPost("data")]
[AllowAnonymous]
public async Task ImportMoldsData()
{
List<(string pId, string eqpId)> multi = new()
{
("25546268026149","25530823999765"),
("25546256076325","25530834099477"),
};
List<MoldsEntity> list = new();
var index = 1;
foreach (var item in multi)
{
MoldsEntity entity = new();
entity.Id = SnowflakeIdHelper.NextId();
entity.MoldCode = $"m00{index}";
entity.MoldName = "磨具" + index;
entity.ItemId = item.pId;
entity.EqpId = item.eqpId;
list.Add(entity);
index++;
}
var link = await _repository.GetFirstAsync(x => x.FullName == "tnb_eqp");
var db = _dataBaseManager.ChangeDataBase(link);
var row = await db.Insertable(list).ExecuteCommandAsync();
if (row > 0)
{
foreach (var item in list)
{
var dic = new Dictionary<string, object>
{
{"id",item.EqpId },
{ "mold_id", item.Id}
};
var row2 = await db.Updateable(dic).AS("eqp_equipment")
.WhereColumns("id").
ExecuteCommandAsync();
}
}
await Task.CompletedTask;
}
}
}

View File

@@ -9,17 +9,13 @@ using JNPF.DependencyInjection;
using JNPF.Systems.Entitys.System;
using SqlSugar;
namespace Tnb.ProductionPlanMgr.internals
namespace Tnb.ProductionPlanMgr
{
public class BaseService : ITransient
{
private readonly Dictionary<string, ISqlSugarClient> _dbContextDic = new(StringComparer.OrdinalIgnoreCase);
static BaseService()
{
var repo = App.GetService<ISqlSugarRepository<DbLinkEntity>>();
//var = await repo.GetListAsync();
var dbMgr = App.GetService<IDataBaseManager>();
}