点巡检复核
This commit is contained in:
@@ -25,20 +25,24 @@ namespace Tnb.EquipMgr
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpSpotInsTemService(ISqlSugarRepository<EqpSpotInsTemH> repository,
|
||||
IUserManager userManager,
|
||||
IVisualDevService visualDevService)
|
||||
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 () =>
|
||||
{
|
||||
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();
|
||||
List<EqpSpotInsTemD> eqpSpotInsTemDs = await db.Queryable<EqpSpotInsTemD>().Where(x=>x.spot_ins_tem_id==input.id).ToListAsync();
|
||||
|
||||
if (input.equipIds != null && input.equipIds.Length > 0)
|
||||
{
|
||||
@@ -47,7 +51,7 @@ namespace Tnb.EquipMgr
|
||||
foreach (var equipId in input.equipIds)
|
||||
{
|
||||
string id = SnowflakeIdHelper.NextId();
|
||||
string code = $"{DateTime.Now.ToString("yyyy-MM-dd") + equipId}";
|
||||
string code = $"{DateTime.Now.ToString("yyyyMMdd") + equipId}";
|
||||
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH()
|
||||
{
|
||||
id = id,
|
||||
@@ -82,12 +86,17 @@ namespace Tnb.EquipMgr
|
||||
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
spot_ins_item_id = eqpSpotInsTem.id,
|
||||
spot_ins_item_id = eqpSpotInsTem.spot_ins_item_id,
|
||||
spot_ins_tem_equip_id = id,
|
||||
};
|
||||
insertEqpSpotInsTemEquipDs.Add(eqpSpotInsTemEquipD);
|
||||
}
|
||||
}
|
||||
|
||||
EqpSpotInsTemEquipH oldSpotInsTemEquipH = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.spot_ins_tem_id == input.id && x.equip_id == equipId).FirstAsync();
|
||||
await db.Deleteable<EqpSpotInsTemEquipH>().Where(x => x.spot_ins_tem_id == input.id && x.equip_id==equipId).ExecuteCommandAsync();
|
||||
if(oldSpotInsTemEquipH!=null)
|
||||
await db.Deleteable<EqpSpotInsTemEquipD>().Where(x => x.spot_ins_tem_equip_id==oldSpotInsTemEquipH.id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (insertEqpSpotInsTemEquipHs != null && insertEqpSpotInsTemEquipHs.Count > 0)
|
||||
|
||||
Reference in New Issue
Block a user