Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
52
EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
Normal file
52
EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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.Interfaces;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养设备模板
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EqpMaintainTemEquipService : IEqpMaintainTemEquipService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpMaintainTemEquipH> _repository;
|
||||
|
||||
public EqpMaintainTemEquipService(ISqlSugarRepository<EqpMaintainTemEquipH> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task Stop(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpMaintainTemEquipH()
|
||||
{
|
||||
is_start = "0"
|
||||
}, x => x.id == id);
|
||||
List<string> ids = await _repository.AsSugarClient().Queryable<EqpMaintainRecordH>()
|
||||
.Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED)
|
||||
.Select(x => x.id).ToListAsync();
|
||||
await _repository.AsSugarClient().Deleteable<EqpMaintainRecordH>()
|
||||
.Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync();
|
||||
|
||||
await _repository.AsSugarClient().Deleteable<EqpMaintainRecordD>()
|
||||
.Where(x => ids.Contains(x.maintain_record_id)).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
}
|
||||
}
|
||||
}
|
||||
119
EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
Normal file
119
EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
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 EqpMaintainTemService : IEqpMaintainTemService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26123080740885";
|
||||
private readonly ISqlSugarRepository<EqpMaintainTemH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpMaintainTemService(ISqlSugarRepository<EqpMaintainTemH> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模板id发布到设备
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
[HttpPost]
|
||||
public async Task<string> Publish(SpotInsTemPublishInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
EqpMaintainTemH eqpMaintainTemH = await _repository.GetSingleAsync(x => x.id == input.id);
|
||||
List<EqpMaintainTemD> eqpMaintainTemDs = await db.Queryable<EqpMaintainTemD>().Where(x=>x.maintain_tem_id==input.id).ToListAsync();
|
||||
|
||||
if (input.equipIds != null && input.equipIds.Length > 0)
|
||||
{
|
||||
List<EqpMaintainTemEquipH> insertEqpMaintainTemEquipHs = new List<EqpMaintainTemEquipH>();
|
||||
List<EqpMaintainTemEquipD> insertEqpMaintainTemEquipDs = new List<EqpMaintainTemEquipD>();
|
||||
foreach (var equipId in input.equipIds)
|
||||
{
|
||||
string id = SnowflakeIdHelper.NextId();
|
||||
string code = $"{DateTime.Now.ToString("yyyyMMdd") + equipId}";
|
||||
EqpMaintainTemEquipH eqpMaintainTemEquipH = new EqpMaintainTemEquipH()
|
||||
{
|
||||
id = id,
|
||||
code = code,
|
||||
name = eqpMaintainTemH.name+equipId,
|
||||
plan_cycle = eqpMaintainTemH.plan_cycle,
|
||||
plan_cycle_unit = eqpMaintainTemH.plan_cycle_unit,
|
||||
plan_run_notice = eqpMaintainTemH.plan_run_notice,
|
||||
plan_delay = eqpMaintainTemH.plan_delay,
|
||||
start_time = eqpMaintainTemH.start_time,
|
||||
is_start = eqpMaintainTemH.is_start.ToString(),
|
||||
is_repeat = eqpMaintainTemH.is_repeat.ToString(),
|
||||
is_send = eqpMaintainTemH.is_send,
|
||||
maintain_tem_id = input.id,
|
||||
equip_id = equipId,
|
||||
remark = eqpMaintainTemH.remark,
|
||||
plan_run_notice_unit = eqpMaintainTemH.plan_run_notice_unit,
|
||||
plan_delay_unit = eqpMaintainTemH.plan_delay_unit,
|
||||
repeat_post_info_user_id = eqpMaintainTemH.repeat_post_info_user_id,
|
||||
send_post_info_user_id = eqpMaintainTemH.send_post_info_user_id,
|
||||
send_post_id = eqpMaintainTemH.send_post_id,
|
||||
org_id = eqpMaintainTemH.org_id,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
insertEqpMaintainTemEquipHs.Add(eqpMaintainTemEquipH);
|
||||
|
||||
if (eqpMaintainTemDs != null && eqpMaintainTemDs.Count > 0)
|
||||
{
|
||||
foreach (var eqpMaintainTem in eqpMaintainTemDs)
|
||||
{
|
||||
EqpMaintainTemEquipD eqpMaintainTemEquipD = new EqpMaintainTemEquipD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
maintain_item_id = eqpMaintainTem.maintain_item_id,
|
||||
maintain_tem_equip_id = id,
|
||||
};
|
||||
insertEqpMaintainTemEquipDs.Add(eqpMaintainTemEquipD);
|
||||
}
|
||||
}
|
||||
|
||||
EqpMaintainTemEquipH oldMaintainTemEquipH = await db.Queryable<EqpMaintainTemEquipH>().Where(x => x.maintain_tem_id == input.id && x.equip_id == equipId).FirstAsync();
|
||||
await db.Deleteable<EqpMaintainTemEquipH>().Where(x => x.maintain_tem_id == input.id && x.equip_id==equipId).ExecuteCommandAsync();
|
||||
if(oldMaintainTemEquipH!=null)
|
||||
await db.Deleteable<EqpMaintainTemEquipD>().Where(x => x.maintain_tem_equip_id==oldMaintainTemEquipH.id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (insertEqpMaintainTemEquipHs != null && insertEqpMaintainTemEquipHs.Count > 0)
|
||||
{
|
||||
await db.Insertable(insertEqpMaintainTemEquipHs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (insertEqpMaintainTemEquipDs != null && insertEqpMaintainTemEquipDs.Count > 0)
|
||||
{
|
||||
await db.Insertable(insertEqpMaintainTemEquipDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "发布成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Models.WorkFlow;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.WorkFlow.Interfaces.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
@@ -21,36 +24,50 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpRepairOutApply> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IFlowTaskService _flowTaskService;
|
||||
private const string flowId = "26299060075302";
|
||||
|
||||
public EqpRepairOutApplyService(ISqlSugarRepository<EqpRepairOutApply> repository,
|
||||
IFlowTaskService flowTaskService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_flowTaskService = flowTaskService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<EqpRepairOutApply> GetInfo(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable<EqpRepairApply>().SingleAsync(x => x.id == id);
|
||||
return await _repository.GetSingleAsync(x => x.repair_apply_id==eqpRepairApply.id);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> OutApply(RepairOutApplyInput input)
|
||||
{
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.id))
|
||||
{
|
||||
await _repository.InsertAsync(new EqpRepairOutApply
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
repair_apply_id = input.repair_apply_id,
|
||||
equip_id = input.equip_id,
|
||||
supplier_id = input.supplier_id,
|
||||
estimated_cost = input.estimated_cost,
|
||||
construction_period_requirement = input.construction_period_requirement,
|
||||
out_apply_reason = input.out_apply_reason,
|
||||
remark = input.remark,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
approve_status = RepairOutApplyStatus.TOBEAPPROVE,
|
||||
});
|
||||
// await _repository.InsertAsync(new EqpRepairOutApply
|
||||
// {
|
||||
// id = id,
|
||||
// repair_apply_id = input.repair_apply_id,
|
||||
// equip_id = input.equip_id,
|
||||
// supplier_id = input.supplier_id,
|
||||
// estimated_cost = input.estimated_cost,
|
||||
// construction_period_requirement = input.construction_period_requirement,
|
||||
// out_apply_reason = input.out_apply_reason,
|
||||
// remark = input.remark,
|
||||
// create_id = _userManager.UserId,
|
||||
// create_time = DateTime.Now,
|
||||
// approve_status = RepairOutApplyStatus.TOBEAPPROVE,
|
||||
// });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -73,10 +90,62 @@ namespace Tnb.EquipMgr
|
||||
.SetColumns(x=>x.status == RepairApplyStatus.OUTAPPLYAPPROVE)
|
||||
.Where(x=>x.id==input.repair_apply_id).ExecuteCommandAsync();
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
//todo 退回流程
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
_flowTaskService.Create(new FlowTaskSubmitModel()
|
||||
{
|
||||
flowId = flowId,
|
||||
parentId = "0",
|
||||
formData = new JObject()
|
||||
{
|
||||
{"id",id},
|
||||
{"repair_apply_id",input.repair_apply_id},
|
||||
{"equip_id",input.equip_id},
|
||||
{"create_id",_userManager.UserId},
|
||||
{"supplier_id",input.supplier_id},
|
||||
{"estimated_cost",input.estimated_cost},
|
||||
{"construction_period_requirement",input.construction_period_requirement},
|
||||
{"out_apply_reason",input.out_apply_reason},
|
||||
{"remark",input.remark},
|
||||
{"approve_status",RepairOutApplyStatus.TOBEAPPROVE},
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Register(RepairApplyOutRegisterInput input)
|
||||
{
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpRepairOutApply()
|
||||
{
|
||||
real_supplier_id = input.real_supplier_id,
|
||||
cost = input.cost,
|
||||
repair_time = input.repair_time,
|
||||
repair_take_time = input.repair_take_time,
|
||||
repair_remark = input.repair_remark,
|
||||
attachment = input.attachment,
|
||||
}, x => x.id == input.id);
|
||||
|
||||
await db.Updateable<EqpRepairApply>().SetColumns(x => x.status == RepairApplyStatus.COMPLETED)
|
||||
.Where(x => x.id == input.repair_apply_id).ExecuteCommandAsync();
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
return result.IsSuccess ? "登记成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
repeat_result = input.repeat_result,
|
||||
repeat_remark = input.repeat_remark,
|
||||
repeat_post_info_user_id = _userManager.UserId,
|
||||
repeat_user_id = _userManager.UserId,
|
||||
repeat_time = DateTime.Now,
|
||||
status = SpotInsRecordExecutionStatus.COMPLETED
|
||||
}, x => x.id == input.id);
|
||||
|
||||
@@ -11,7 +11,7 @@ using Tnb.EquipMgr.Entities;
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备管理
|
||||
/// 点巡检设备模板
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
@@ -24,26 +24,7 @@ namespace Tnb.EquipMgr
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
// public async Task<dynamic> GetTree()
|
||||
// {
|
||||
// List<EqpEquipment> eqpEquipments =
|
||||
// var data = _repository.AsSugarClient().Queryable<EqpEquipType>()
|
||||
// .Where(x => x.status == 1)
|
||||
// .Select((x) => new TreeModel
|
||||
// {
|
||||
// id = x.id,
|
||||
// parentId = "-1",
|
||||
// hasChildren = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Any(),
|
||||
// isLeaf = false,
|
||||
// num = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Count(),
|
||||
// children = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Select(y=>new TreeModel()
|
||||
// {
|
||||
//
|
||||
// }).ToList(model => ),
|
||||
// });
|
||||
// return new { list = 1 };
|
||||
// }
|
||||
|
||||
[HttpPost]
|
||||
public async Task Stop(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
|
||||
Reference in New Issue
Block a user