系统二维码
This commit is contained in:
47
BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs
Normal file
47
BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.BasicData.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 系统二维码表
|
||||
/// </summary>
|
||||
[SugarTable("bas_qrcode")]
|
||||
public partial class BasQrcode : BaseEntity<string>
|
||||
{
|
||||
public BasQrcode()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 关联表id
|
||||
/// </summary>
|
||||
public string? source_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联表名
|
||||
/// </summary>
|
||||
public string? source_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extras.CollectiveOAuth.Models;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Senparc.NeuChar.ApiHandlers;
|
||||
@@ -16,6 +22,7 @@ using Tnb.BasicData;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
using Tnb.BasicData.Entities;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
@@ -29,12 +36,24 @@ namespace Tnb.EquipMgr
|
||||
public class EquipmentService : IOverideVisualDevService, IEquipmentService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "25064865727509";
|
||||
private const string ModuleId = "26012367560469";
|
||||
private readonly ISqlSugarRepository<EqpEquipment> _repository;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EquipmentService(ISqlSugarRepository<EqpEquipment> repository)
|
||||
public EquipmentService(ISqlSugarRepository<EqpEquipment> repository,
|
||||
IVisualDevService visualDevService,
|
||||
IUserManager userManager,
|
||||
IRunService runService
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
_userManager = userManager;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
OverideFuncs.UpdateAsync = Update;
|
||||
}
|
||||
/// <summary>
|
||||
/// 在线开发-获取设备列表
|
||||
@@ -67,6 +86,75 @@ namespace Tnb.EquipMgr
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return pagedList;
|
||||
}
|
||||
|
||||
private async Task<dynamic> Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
|
||||
{
|
||||
string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : "";
|
||||
if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable<BasQrcode>().AnyAsync(x => x.code == qrcode))
|
||||
{
|
||||
throw Oops.Bah("二维码总表中已存在该二维码");
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Create(templateEntity, visualDevModelDataCrInput);
|
||||
|
||||
string equipId = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? "";
|
||||
|
||||
if (!string.IsNullOrEmpty(qrcode))
|
||||
{
|
||||
BasQrcode basQrcode = new BasQrcode()
|
||||
{
|
||||
code = visualDevModelDataCrInput.data["qrcode"].ToString(),
|
||||
source_id = equipId,
|
||||
source_name = "EQP_EQUIPMENT",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable<BasQrcode>(basQrcode).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private async Task<dynamic> Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput)
|
||||
{
|
||||
string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : "";
|
||||
if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable<BasQrcode>().AnyAsync(x => x.code == visualDevModelDataUpInput.data["qrcode"] && x.source_id!=id))
|
||||
{
|
||||
throw Oops.Bah("二维码总表中已存在该二维码");
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Update(id,templateEntity, visualDevModelDataUpInput);
|
||||
|
||||
if (!string.IsNullOrEmpty(qrcode))
|
||||
{
|
||||
if (await _repository.AsSugarClient().Queryable<BasQrcode>().AnyAsync(x => x.source_id == id))
|
||||
{
|
||||
await _repository.AsSugarClient().Updateable<BasQrcode>()
|
||||
.SetColumns(x => x.code == visualDevModelDataUpInput.data["qrcode"].ToString()).Where(x => x.source_id == id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
BasQrcode basQrcode = new BasQrcode()
|
||||
{
|
||||
code = visualDevModelDataUpInput.data["qrcode"].ToString(),
|
||||
source_id = id,
|
||||
source_name = "EQP_EQUIPMENT",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable<BasQrcode>(basQrcode).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<EqpEquipment> GetEntityById(Dictionary<string,string> dic)
|
||||
|
||||
@@ -4,10 +4,17 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
@@ -18,16 +25,99 @@ namespace Tnb.EquipMgr
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMoldLocationService : IToolMoldLocationService, IDynamicApiController, ITransient
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class ToolMoldLocationService : IToolMoldLocationService,IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "27207685649173";
|
||||
private readonly ISqlSugarClient _db;
|
||||
public ToolMoldLocationService(ISqlSugarRepository<ToolLocation> repository)
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IUserManager _userManager;
|
||||
public ToolMoldLocationService(ISqlSugarRepository<ToolLocation> repository,
|
||||
IVisualDevService visualDevService,
|
||||
IUserManager userManager,
|
||||
IRunService runService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
_userManager = userManager;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
OverideFuncs.UpdateAsync = Update;
|
||||
}
|
||||
public async Task<Dictionary<string, object>> GetLocationDictionary()
|
||||
{
|
||||
return await _db.Queryable<ToolLocation>().ToDictionaryAsync(x => x.id, x => x.location_code);
|
||||
}
|
||||
|
||||
private async Task<dynamic> Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
|
||||
{
|
||||
string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : "";
|
||||
if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable<BasQrcode>().AnyAsync(x => x.code == qrcode))
|
||||
{
|
||||
throw Oops.Bah("二维码总表中已存在该二维码");
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Create(templateEntity, visualDevModelDataCrInput);
|
||||
|
||||
string id = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? "";
|
||||
|
||||
if (!string.IsNullOrEmpty(qrcode))
|
||||
{
|
||||
BasQrcode basQrcode = new BasQrcode()
|
||||
{
|
||||
code = visualDevModelDataCrInput.data["qrcode"].ToString(),
|
||||
source_id = id,
|
||||
source_name = "TOOL_LOCATION",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
};
|
||||
await _db.Insertable<BasQrcode>(basQrcode).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private async Task<dynamic> Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput)
|
||||
{
|
||||
string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : "";
|
||||
if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable<BasQrcode>().AnyAsync(x => x.code == visualDevModelDataUpInput.data["qrcode"] && x.source_id!=id))
|
||||
{
|
||||
throw Oops.Bah("二维码总表中已存在该二维码");
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Update(id,templateEntity, visualDevModelDataUpInput);
|
||||
|
||||
if (!string.IsNullOrEmpty(qrcode))
|
||||
{
|
||||
if (await _db.Queryable<BasQrcode>().AnyAsync(x => x.source_id == id))
|
||||
{
|
||||
await _db.Updateable<BasQrcode>()
|
||||
.SetColumns(x => x.code == visualDevModelDataUpInput.data["qrcode"].ToString()).Where(x => x.source_id == id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
BasQrcode basQrcode = new BasQrcode()
|
||||
{
|
||||
code = visualDevModelDataUpInput.data["qrcode"].ToString(),
|
||||
source_id = id,
|
||||
source_name = "TOOL_LOCATION",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
};
|
||||
await _db.Insertable<BasQrcode>(basQrcode).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,6 +313,32 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
|
||||
|
||||
if (adminlist.Any()) await _repository.AsSugarClient().Insertable(adminlist).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
#endregion
|
||||
|
||||
if (input.category != DictConst.RegionCategoryCompanyCode)
|
||||
{
|
||||
var jsonObj = input.propertyJson;
|
||||
var qrcode = jsonObj.GetValue("qrcode");
|
||||
if (qrcode is not null && !string.IsNullOrEmpty(qrcode.ToString()))
|
||||
{
|
||||
if (await _repository.AsSugarClient().Queryable<BasQrcode>().AnyAsync(x => x.code == qrcode.ToString()))
|
||||
{
|
||||
throw Oops.Bah("二维码总表中已存在该二维码");
|
||||
}
|
||||
else
|
||||
{
|
||||
BasQrcode basQrcode = new BasQrcode()
|
||||
{
|
||||
code = qrcode.ToString(),
|
||||
source_id = entity.Id,
|
||||
source_name = "BASE_ORGANIZE",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable<BasQrcode>(basQrcode).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 第三方同步
|
||||
|
||||
@@ -450,6 +476,43 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
|
||||
|
||||
int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.D2018);
|
||||
|
||||
//modified by zkd on 20230718 处理二维码
|
||||
if (input.category != DictConst.RegionCategoryCompanyCode)
|
||||
{
|
||||
var jsonObj = input.propertyJson;
|
||||
var qrcode = jsonObj.GetValue("qrcode");
|
||||
if (qrcode is not null && !string.IsNullOrEmpty(qrcode.ToString()))
|
||||
{
|
||||
if (await _repository.AsSugarClient().Queryable<BasQrcode>().AnyAsync(x => x.code == qrcode.ToString() && x.source_id!=id))
|
||||
{
|
||||
throw Oops.Bah("二维码总表中已存在该二维码");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (await _repository.AsSugarClient().Queryable<BasQrcode>().AnyAsync(x => x.source_id == id))
|
||||
{
|
||||
await _repository.AsSugarClient().Updateable<BasQrcode>()
|
||||
.SetColumns(x => x.code == qrcode.ToString()).Where(x => x.source_id == id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
BasQrcode basQrcode = new BasQrcode()
|
||||
{
|
||||
code = qrcode.ToString(),
|
||||
source_id = id,
|
||||
source_name = "BASE_ORGANIZE",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable<BasQrcode>(basQrcode).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//modified by ly on 20230426 处理工位信息,将工位插入到设备表
|
||||
if (input.category == DictConst.RegionCategoryStationCode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user