using JNPF.Common.Core.Manager; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.BasicData.Entities.Dto; using Tnb.BasicData.Entitys.Dto.BasProcess; using Tnb.BasicData.Interfaces; using Tnb.EquipMgr.Entities; using Tnb.WarehouseMgr.Entities; namespace Tnb.BasicData { /// /// 二维码 /// [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)] [Route("api/[area]/[controller]/[action]")] public class BasQrcodeService : IBasQrcodeService,IDynamicApiController, ITransient { private readonly ISqlSugarRepository _repository; private readonly DataBaseManager _dbManager; private readonly IDictionaryDataService _dictionaryDataService; public BasQrcodeService( ISqlSugarRepository repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService) { _repository = repository; _dbManager = dbManager; _dictionaryDataService = dictionaryDataService; } [HttpPost] public async Task GetQrcodeByCode(Dictionary dic) { string code = dic.ContainsKey("code") ? dic["code"] : ""; if (string.IsNullOrEmpty(code)) return null; var result = await _repository.AsSugarClient().Queryable() .LeftJoin((a, b) => a.source_id == b.Id) .LeftJoin((a, b, c) => a.source_id == c.id) .LeftJoin((a, b, c, d) => a.source_id == d.id) .LeftJoin((a,b,c,d,e)=>a.source_id==e.id) .LeftJoin((a,b,c,d,e,f)=>a.source_id==f.id) .Where((a, b, c, d) => a.code == code) .Select((a, b, c, d,e,f) => new { id = a.id, source_id = a.source_id, source_name = a.source_name, org_code = b.EnCode, org_name = b.FullName, equip_code = a.code, equip_name = c.name, tool_location_code = d.location_code, bas_location_name = e.location_name, bas_location_code = e.location_code, carry_name = f.carry_name, carry_code = f.carry_code, }).FirstAsync(); return result; } [HttpPost] public async Task GetWorkStationByCode(Dictionary dic) { string code = dic.ContainsKey("code") ? dic["code"] : ""; if (string.IsNullOrEmpty(code)) return null; var result = await _repository.AsSugarClient().Queryable() .LeftJoin((a, b) => a.source_id == b.Id) .LeftJoin((a,b,c)=>a.source_id==c.ObjectId && c.ObjectType=="Eqp") .LeftJoin((a,b,c,d)=>c.OrganizeId==d.Id) .Where((a, b, c) => a.code == code) .Select((a, b, c,d) => new { id = a.id, source_id = a.source_id, source_name = a.source_name, org_id = b.Id, org_code = b.EnCode, org_name = b.FullName, org_id2 = d.Id, org_code2 = d.EnCode, org_name2 = d.FullName, }).FirstAsync(); return result; } [HttpPost] public async Task GetWorkstationInfo() { var result = await _repository.AsSugarClient().Queryable() .LeftJoin((a, b) => a.Id == b.source_id && b.source_name == "BASE_ORGANIZE") .Where((a, b) => a.Category == DictConst.RegionCategoryStationCode && a.DeleteMark == null) .Select((a, b) => new { label = a.FullName, value = a.Id, qrcode = b.code }).ToListAsync(); return result; } } }