112 lines
4.3 KiB
C#
112 lines
4.3 KiB
C#
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.Interfaces;
|
|
using Tnb.EquipMgr.Entities;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
|
|
namespace Tnb.BasicData
|
|
{
|
|
/// <summary>
|
|
/// 二维码
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
public class BasQrcodeService : IBasQrcodeService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
|
private readonly DataBaseManager _dbManager;
|
|
private readonly IDictionaryDataService _dictionaryDataService;
|
|
|
|
public BasQrcodeService(
|
|
ISqlSugarRepository<BasMaterial> repository, DataBaseManager dbManager, IDictionaryDataService dictionaryDataService)
|
|
{
|
|
_repository = repository;
|
|
_dbManager = dbManager;
|
|
_dictionaryDataService = dictionaryDataService;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<dynamic?> GetQrcodeByCode(Dictionary<string, string> dic)
|
|
{
|
|
string code = dic.ContainsKey("code") ? dic["code"] : "";
|
|
if (string.IsNullOrEmpty(code))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var result = await _repository.AsSugarClient().Queryable<BasQrcode>()
|
|
.LeftJoin<OrganizeEntity>((a, b) => a.source_id == b.Id)
|
|
.LeftJoin<EqpEquipment>((a, b, c) => a.source_id == c.id)
|
|
.LeftJoin<ToolLocation>((a, b, c, d) => a.source_id == d.id)
|
|
.LeftJoin<BasLocation>((a, b, c, d, e) => a.source_id == e.id)
|
|
.LeftJoin<WmsCarryH>((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
|
|
{
|
|
a.id,
|
|
a.source_id,
|
|
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,
|
|
f.carry_name,
|
|
f.carry_code,
|
|
}).FirstAsync();
|
|
return result;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<dynamic?> GetWorkStationByCode(Dictionary<string, string> dic)
|
|
{
|
|
string code = dic.ContainsKey("code") ? dic["code"] : "";
|
|
if (string.IsNullOrEmpty(code))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var result = await _repository.AsSugarClient().Queryable<BasQrcode>()
|
|
.LeftJoin<OrganizeEntity>((a, b) => a.source_id == b.Id)
|
|
.LeftJoin<OrganizeRelationEntity>((a, b, c) => a.source_id == c.ObjectId && c.ObjectType == "Eqp")
|
|
.LeftJoin<OrganizeEntity>((a, b, c, d) => c.OrganizeId == d.Id)
|
|
.Where((a, b, c) => a.code == code)
|
|
.Select((a, b, c, d) => new
|
|
{
|
|
a.id,
|
|
a.source_id,
|
|
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<dynamic> GetWorkstationInfo()
|
|
{
|
|
var result = await _repository.AsSugarClient().Queryable<OrganizeEntity>()
|
|
.LeftJoin<BasQrcode>((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;
|
|
}
|
|
}
|
|
} |