using JNPF.Common.Core.Manager; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.BasicData.Interfaces; namespace Tnb.BasicData { /// /// 物料档案 /// [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)] [Route("api/[area]/[controller]/[action]")] public class BasMaterialService : IBasMaterialService,IDynamicApiController, ITransient { private readonly ISqlSugarRepository _repository; private readonly DataBaseManager _dbManager; private readonly IDictionaryDataService _dictionaryDataService; public BasMaterialService( ISqlSugarRepository repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService) { _repository = repository; _dbManager = dbManager; _dictionaryDataService = dictionaryDataService; } // [HttpPost] // public async Task> GetEbomVersionAndRouteName(Dictionary parameters) // { // string materialId = parameters["materialId"]; // var db = _repository.AsSugarClient(); // var dic = await _dictionaryDataService.GetDicByKey(DicTypeKey.MeasurementUnit); // // var momDbLink = await _repository.AsSugarClient().Queryable().FirstAsync(x => x.FullName == DbName.TNBMON); // // if (momDbLink != null) // // { // // db = _dbManager.ChangeDataBase(momDbLink); // // } // // var ebom = await db.Queryable() // .LeftJoin((a,b)=>a.route_id==b.id) // .Where((a,b) => a.material_id == materialId) // .Select((a,b)=>new // { // a.id, // a.version, // b.name, // }).SingleAsync(); // return new Dictionary() // { // ["version"] = ebom?.version, // ["routeName"] = ebom?.name, // ["routeId"] = ebom?.id // }; // } // [HttpPost] // public async Task> GetMaterialUnits(Dictionary parameters) // { // string materialId = parameters["materialId"]; // var db = _repository.AsSugarClient(); // // var type = await db.Queryable().Where(x => x.EnCode == DictConst.MeasurementUnit) // .SingleAsync(); // string typeId = type?.Id; // var queryable1 = db.Queryable() // .LeftJoin((a,b)=>a.unit_id==b.EnCode && b.DictionaryTypeId==typeId) // .Where((a,b) => a.Id == materialId) // .Select((a,b)=> new ElementSelectDto // { // value = b.EnCode, // label = b.FullName, // }); // var queryable2 = db.Queryable() // .LeftJoin((a,b)=>a.pickunit_id==b.EnCode && b.DictionaryTypeId==typeId) // .Where((a,b) => a.Id == materialId) // .Select((a,b)=> new ElementSelectDto // { // value = b.EnCode, // label = b.FullName, // }); // List data = await db.Union(queryable1, queryable2).ToListAsync(); // return data; // } } }