108 lines
4.0 KiB
C#
108 lines
4.0 KiB
C#
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Dtos.VisualDev;
|
|
using JNPF.Common.Enums;
|
|
using JNPF.Common.Filter;
|
|
using JNPF.Common.Models;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.FriendlyException;
|
|
using JNPF.Logging;
|
|
using JNPF.Systems.Common;
|
|
using JNPF.Systems.Entitys.Permission;
|
|
using JNPF.Systems.Interfaces.Common;
|
|
using JNPF.VisualDev;
|
|
using JNPF.VisualDev.Entitys;
|
|
using JNPF.VisualDev.Interfaces;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
using Tnb.EquipMgr.Entities;
|
|
using Tnb.EquipMgr.Entities.Dto;
|
|
using Tnb.EquipMgr.Interfaces;
|
|
|
|
namespace Tnb.EquipMgr
|
|
{
|
|
/// <summary>
|
|
/// 设备保养计划执行管理
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
public class EqpEquipFileService : IEqpEquipFileService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<EqpEquipFile> _repository;
|
|
private readonly IUserManager _userManager;
|
|
private readonly FileService _fileService;
|
|
|
|
public EqpEquipFileService(ISqlSugarRepository<EqpEquipFile> repository,
|
|
FileService fileService,
|
|
IUserManager userManager)
|
|
{
|
|
_repository = repository;
|
|
_userManager = userManager;
|
|
_fileService = fileService;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<string> Upload([FromForm]string equip_id,[FromForm] ChunkModel input)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
var attachment = await _fileService.Uploader("annexpic", input);
|
|
|
|
EqpEquipFile eqpEquipFile = new EqpEquipFile()
|
|
{
|
|
file_name = input.file.FileName,
|
|
equip_id = equip_id,
|
|
create_id = _userManager.UserId,
|
|
create_time = DateTime.Now,
|
|
attachment = JsonConvert.SerializeObject(attachment),
|
|
org_id = _userManager.GetUserInfo().Result.organizeId,
|
|
};
|
|
|
|
await _repository.InsertAsync(eqpEquipFile);
|
|
msg = "上传成功";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "上传失败";
|
|
Log.Error(e.Message);
|
|
throw Oops.Oh(ErrorCode.D8001);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<dynamic> GetEquipFileList(EquipQueryInput input)
|
|
{
|
|
var db = _repository.AsSugarClient();
|
|
Dictionary<string, string> queryJson = new Dictionary<string, string>();
|
|
if (!string.IsNullOrEmpty(input.queryJson))
|
|
{
|
|
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
|
|
}
|
|
var result = await db.Queryable<EqpEquipFile>()
|
|
.LeftJoin<UserEntity >((a, b) => a.create_id == b.Id)
|
|
.LeftJoin<UserEntity >((a, b,c) => a.modify_id == c.Id)
|
|
.LeftJoin<EqpEquipment >((a, b,c,d) => a.equip_id == d.id)
|
|
.Where((a,b,c,d)=>a.equip_id==input.equip_id)
|
|
.WhereIF(queryJson.ContainsKey("file_name"),(a,b,c,d)=>a.file_name.Contains(queryJson["file_name"]))
|
|
.Select((a, b, c,d) => new EquipFileQueryOutput
|
|
{
|
|
id = a.id,
|
|
attachment = a.attachment,
|
|
create_id = b.RealName,
|
|
create_id_id = a.create_id,
|
|
create_time = a.create_time.Value.ToString("yyyy-MM-dd"),
|
|
equip_id=d.name,
|
|
equip_id_id= a.equip_id,
|
|
file_name=a.file_name,
|
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
|
|
|
return PageResult<EquipFileQueryOutput>.SqlSugarPageResult(result);
|
|
}
|
|
}
|
|
} |