78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
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 SqlSugar;
|
|
using Tnb.ProductionMgr.Entities;
|
|
|
|
namespace Tnb.ProductionMgr
|
|
{
|
|
/// <summary>
|
|
/// 生产排产
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = "ProductMgr", Name = "WorkOrderScheduling", Order = 700)]
|
|
[Route("api/production/[controller]")]
|
|
public class WorkOrderSchedulingService : IDynamicApiController, ITransient
|
|
{
|
|
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();
|
|
int index = 1;
|
|
foreach ((string pId, string eqpId) in multi)
|
|
{
|
|
MoldsEntity entity = new()
|
|
{
|
|
id = SnowflakeIdHelper.NextId(),
|
|
MoldCode = $"m00{index}",
|
|
MoldName = "磨具" + index,
|
|
ItemId = pId,
|
|
EqpId = eqpId
|
|
};
|
|
list.Add(entity);
|
|
index++;
|
|
}
|
|
DbLinkEntity link = await _repository.GetFirstAsync(x => x.FullName == "tnb_eqp");
|
|
SqlSugarScope db = _dataBaseManager.ChangeDataBase(link);
|
|
int row = await db.Insertable(list).ExecuteCommandAsync();
|
|
if (row > 0)
|
|
{
|
|
foreach (MoldsEntity item in list)
|
|
{
|
|
Dictionary<string, object> dic = new()
|
|
{
|
|
{"id",item.EqpId },
|
|
{ "mold_id", item.id}
|
|
};
|
|
int row2 = await db.Updateable(dic).AS("eqp_equipment")
|
|
.WhereColumns("id").
|
|
ExecuteCommandAsync();
|
|
}
|
|
}
|
|
|
|
await Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|