点巡检执行 模板发布
This commit is contained in:
111
EquipMgr/Tnb.EquipMgr/EqpSpotInsTemService.cs
Normal file
111
EquipMgr/Tnb.EquipMgr/EqpSpotInsTemService.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 点巡检模板管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EqpSpotInsTemService : IEqpSpotInsTemService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26123080740885";
|
||||
private readonly ISqlSugarRepository<EqpSpotInsTemH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpSpotInsTemService(ISqlSugarRepository<EqpSpotInsTemH> repository,
|
||||
IUserManager userManager,
|
||||
IVisualDevService visualDevService)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public async Task<string> Publish(SpotInsTemPublishInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
EqpSpotInsTemH eqpSpotInsTemH = await _repository.GetSingleAsync(x => x.id == input.id);
|
||||
List<EqpSpotInsTemD> eqpSpotInsTemDs = await db.Queryable<EqpSpotInsTemD>().Where(x=>x.spot_ins_item_id==input.id).ToListAsync();
|
||||
|
||||
if (input.equipIds != null && input.equipIds.Length > 0)
|
||||
{
|
||||
List<EqpSpotInsTemEquipH> insertEqpSpotInsTemEquipHs = new List<EqpSpotInsTemEquipH>();
|
||||
List<EqpSpotInsTemEquipD> insertEqpSpotInsTemEquipDs = new List<EqpSpotInsTemEquipD>();
|
||||
foreach (var equipId in input.equipIds)
|
||||
{
|
||||
string id = SnowflakeIdHelper.NextId();
|
||||
string code = $"{DateTime.Now.ToString("yyyy-MM-dd") + equipId}";
|
||||
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH()
|
||||
{
|
||||
id = id,
|
||||
code = code,
|
||||
name = eqpSpotInsTemH.name+equipId,
|
||||
plan_cycle = eqpSpotInsTemH.plan_cycle,
|
||||
plan_cycle_unit = eqpSpotInsTemH.plan_cycle_unit,
|
||||
plan_run_notice = eqpSpotInsTemH.plan_run_notice,
|
||||
plan_delay = eqpSpotInsTemH.plan_delay,
|
||||
start_time = eqpSpotInsTemH.start_time,
|
||||
is_start = eqpSpotInsTemH.is_start.ToString(),
|
||||
is_repeat = eqpSpotInsTemH.is_repeat.ToString(),
|
||||
is_send = eqpSpotInsTemH.is_send,
|
||||
spot_ins_tem_id = input.id,
|
||||
equip_id = equipId,
|
||||
remark = eqpSpotInsTemH.remark,
|
||||
plan_run_notice_unit = eqpSpotInsTemH.plan_run_notice_unit,
|
||||
plan_delay_unit = eqpSpotInsTemH.plan_delay_unit,
|
||||
repeat_post_info_user_id = eqpSpotInsTemH.repeat_post_info_user_id,
|
||||
send_post_info_user_id = eqpSpotInsTemH.send_post_info_user_id,
|
||||
send_post_id = eqpSpotInsTemH.send_post_id,
|
||||
org_id = eqpSpotInsTemH.org_id,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
insertEqpSpotInsTemEquipHs.Add(eqpSpotInsTemEquipH);
|
||||
|
||||
if (eqpSpotInsTemDs != null && eqpSpotInsTemDs.Count > 0)
|
||||
{
|
||||
foreach (var eqpSpotInsTem in eqpSpotInsTemDs)
|
||||
{
|
||||
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
spot_ins_item_id = eqpSpotInsTem.id,
|
||||
spot_ins_tem_equip_id = id,
|
||||
};
|
||||
insertEqpSpotInsTemEquipDs.Add(eqpSpotInsTemEquipD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insertEqpSpotInsTemEquipHs != null && insertEqpSpotInsTemEquipHs.Count > 0)
|
||||
{
|
||||
await db.Insertable(insertEqpSpotInsTemEquipHs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (insertEqpSpotInsTemEquipDs != null && insertEqpSpotInsTemEquipDs.Count > 0)
|
||||
{
|
||||
await db.Insertable(insertEqpSpotInsTemEquipDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "发布成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
82
EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
Normal file
82
EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
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 Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 点巡检执行管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class EquSpotInsRecordService : IOverideVisualDevService, IEquSpotInsRecordService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "26123080740885";
|
||||
private readonly ISqlSugarRepository<EqpSpotInsRecordH> _repository;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EquSpotInsRecordService(ISqlSugarRepository<EqpSpotInsRecordH> repository,
|
||||
IRunService runService,
|
||||
IUserManager userManager,
|
||||
IVisualDevService visualDevService)
|
||||
{
|
||||
_repository = repository;
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
_userManager = userManager;
|
||||
OverideFuncs.UpdateAsync = ExecuteSpotIns;
|
||||
}
|
||||
|
||||
public async Task<dynamic> ExecuteSpotIns(string id,[FromBody]VisualDevModelDataUpInput input)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
//string attachment = JsonConvert.SerializeObject(input.data["attachment"]);
|
||||
// _repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
||||
// {
|
||||
// result = (int)input.data["result"],
|
||||
// attachment = attachment,
|
||||
// result_remark = input.data["result_remark"].ToString(),
|
||||
// }, x => x.id == input.data["id"]);
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Update(id,templateEntity, input);
|
||||
|
||||
EqpSpotInsRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.data["id"].ToString());
|
||||
string status = "";
|
||||
if (eqpSpotInsRecordH.is_repeat == "1")
|
||||
{
|
||||
status = SpotInsRecordExecutionStatus.TOBECHECK;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SpotInsRecordExecutionStatus.COMPLETED;
|
||||
}
|
||||
_repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
||||
{
|
||||
status = status,
|
||||
spot_record_date_time = DateTime.Now,
|
||||
spot_record_user_id = _userManager.UserId
|
||||
}, x => x.id == input.data["id"]);
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "执行成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user