108 lines
4.0 KiB
C#
108 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using COSXML.Model.Tag;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.Systems.Interfaces.System;
|
|
using JNPF.VisualDev;
|
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
|
using JNPF.VisualDev.Entitys;
|
|
using JNPF.VisualDev.Interfaces;
|
|
using NPOI.Util;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.EquipMgr.Entities;
|
|
using Tnb.ProductionMgr.Entities;
|
|
using Tnb.ProductionMgr.Interfaces;
|
|
using Aspose.Cells.Drawing;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using DbModels;
|
|
|
|
namespace Tnb.ProductionMgr
|
|
{
|
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
[OverideVisualDev(ModuleId)]
|
|
public class PrdTaskManageService : IPrdTaskManageService, IOverideVisualDevService, IDynamicApiController, ITransient
|
|
{
|
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
|
private const string ModuleId = "25617945906709";
|
|
private readonly ISqlSugarRepository<PrdTask> _repository;
|
|
private readonly IUserManager _userManager;
|
|
private readonly IDictionaryDataService _dictionaryDataService;
|
|
private readonly IRunService _runService;
|
|
private readonly IVisualDevService _visualDevService;
|
|
public PrdTaskManageService(
|
|
ISqlSugarRepository<PrdTask> repository,
|
|
IUserManager userManager,
|
|
IDictionaryDataService dictionaryDataService,
|
|
IRunService runService,
|
|
IVisualDevService visualDevService
|
|
)
|
|
{
|
|
_repository = repository;
|
|
_userManager = userManager;
|
|
_dictionaryDataService = dictionaryDataService;
|
|
_runService = runService;
|
|
_visualDevService = visualDevService;
|
|
OverideFuncs.GetListAsync = GetList;
|
|
}
|
|
|
|
|
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
|
{
|
|
var db = _repository.AsSugarClient();
|
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
|
var data = await _runService.GetListResult(templateEntity, input);
|
|
if (data?.list?.Count > 0)
|
|
{
|
|
foreach (var row in data.list)
|
|
{
|
|
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
|
var pkName = "material_id";
|
|
if (dic.ContainsKey(pkName))
|
|
{
|
|
var materialId = dic[pkName]?.ToString();
|
|
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
|
if (material != null)
|
|
{
|
|
row[pkName] = $"{material.code}/{material.name}";
|
|
}
|
|
}
|
|
//模具
|
|
if (dic.ContainsKey("mold_id"))
|
|
{
|
|
var moldId = dic["mold_id"]?.ToString();
|
|
var mold = await db.Queryable<ToolMolds>().FirstAsync(it => it.id == moldId);
|
|
if (mold != null)
|
|
{
|
|
row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
|
|
}
|
|
}
|
|
//设备
|
|
if (dic.ContainsKey("eqp_id"))
|
|
{
|
|
var eqpId = dic["eqp_id"]?.ToString();
|
|
var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
|
if (eqp != null)
|
|
{
|
|
row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
return data!;
|
|
}
|
|
|
|
//public async Task<dynamic> GetPrdMoTaskList()
|
|
//{
|
|
// var db= _repository.AsSugarClient();
|
|
//}
|
|
}
|
|
}
|