特种设备检验

This commit is contained in:
2023-06-01 15:25:41 +08:00
parent c920a99e8a
commit b8d77e72d9
4 changed files with 260 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
namespace Tnb.EquipMgr.Entities;
/// <summary>
/// 特种设备检验登记记录表
/// </summary>
[SugarTable("eqp_sp_equip_check_record")]
public partial class EqpSpEquipCheckRecord : BaseEntity<string>
{
public EqpSpEquipCheckRecord()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 设备id
/// </summary>
public string? equip_id { get; set; }
/// <summary>
/// 证书编号
/// </summary>
public string? license_code { get; set; }
/// <summary>
/// 经办人id
/// </summary>
public string? oper_user_id { get; set; }
/// <summary>
/// 送检时间
/// </summary>
public DateTime? send_time { get; set; }
/// <summary>
/// 领证时间
/// </summary>
public DateTime? get_time { get; set; }
/// <summary>
/// 检验结果
/// </summary>
public int? check_result { get; set; }
/// <summary>
/// 提前预警时间
/// </summary>
public int? warm_time { get; set; }
/// <summary>
/// 提前预警时间单位
/// </summary>
public int? warn_unit { get; set; }
/// <summary>
/// 有效开始时间
/// </summary>
public DateTime? start_time { get; set; }
/// <summary>
/// 有效结束时间
/// </summary>
public DateTime? end_time { get; set; }
/// <summary>
/// 下次检验时间
/// </summary>
public DateTime? next_check_time { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? remark { get; set; }
/// <summary>
/// 状态 0 待检验 1 已检验
/// </summary>
public string status { get; set; }
/// <summary>
/// 证书名称
/// </summary>
public string? license_name { get; set; }
/// <summary>
/// 证书附件
/// </summary>
public string? attachment { get; set; }
/// <summary>
/// 流程任务Id
/// </summary>
public string? f_flowtaskid { get; set; }
/// <summary>
/// 流程引擎Id
/// </summary>
public string? f_flowid { get; set; }
/// <summary>
/// 所属组织
/// </summary>
public string? org_id { get; set; }
}

View File

@@ -0,0 +1,9 @@
using Tnb.EquipMgr.Entities;
namespace Tnb.EquipMgr.Interfaces
{
public interface IEqpSpEquipCheckRecordService
{
public Task Register(EqpSpEquipCheckRecord entity);
}
}

View File

@@ -0,0 +1,56 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using Microsoft.AspNetCore.Mvc;
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 EqpSpEquipCheckRecordService : IEqpSpEquipCheckRecordService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<EqpSpEquipCheckRecord> _repository;
private readonly IUserManager _userManager;
public EqpSpEquipCheckRecordService(ISqlSugarRepository<EqpSpEquipCheckRecord> repository,
IUserManager userManager)
{
_repository = repository;
_userManager = userManager;
}
[HttpPost]
public async Task Register(EqpSpEquipCheckRecord entity)
{
if (await _repository.IsAnyAsync(x => x.equip_id == entity.equip_id))
{
throw Oops.Bah("该设备已存在检验计划");
}
if (entity.warn_unit == 1)//月
{
entity.next_check_time = entity.end_time.Value.AddMonths(-entity.warm_time.Value);
}else if (entity.warn_unit == 2)//天
{
entity.next_check_time = entity.end_time.Value.AddDays(-entity.warm_time.Value);
}
entity.id = SnowflakeIdHelper.NextId();
entity.create_time = DateTime.Now;
entity.create_id = _userManager.UserId;
entity.org_id = _userManager.GetUserInfo().Result.organizeId;
await _repository.InsertAsync(entity);
}
}
}