83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
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 SqlSugar;
|
|
using Tnb.ProductionMgr.Entitys.Entity;
|
|
|
|
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();
|
|
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;
|
|
}
|
|
}
|
|
}
|