1
This commit is contained in:
@@ -138,4 +138,6 @@ public partial class ToolMolds : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string item_json { get; set; }
|
||||
|
||||
public string qrcode { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
@@ -26,14 +33,91 @@ namespace Tnb.EquipMgr
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMoldsService : IToolMoldsService, IDynamicApiController, ITransient
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class ToolMoldsService : IOverideVisualDevService, IToolMoldsService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "26103059189781";
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ISqlSugarRepository<ToolMolds> _repository;
|
||||
public ToolMoldsService(IUserManager userManager, ISqlSugarRepository<ToolMolds> repository)
|
||||
private readonly IRunService _runService;
|
||||
public ToolMoldsService(IUserManager userManager, ISqlSugarRepository<ToolMolds> repository, IVisualDevService visualDevService, IRunService runService)
|
||||
{
|
||||
_visualDevService = visualDevService;
|
||||
_userManager = userManager;
|
||||
_repository = repository;
|
||||
_runService = runService;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
OverideFuncs.UpdateAsync = Update;
|
||||
}
|
||||
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 ToolId = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? "";
|
||||
|
||||
if (!string.IsNullOrEmpty(qrcode))
|
||||
{
|
||||
BasQrcode basQrcode = new BasQrcode()
|
||||
{
|
||||
code = visualDevModelDataCrInput.data["qrcode"].ToString(),
|
||||
source_id = ToolId,
|
||||
source_name = "TOOL_MOLDS",
|
||||
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 = "TOOL_MOLDS",
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user