|
@@ -121,6 +121,7 @@ namespace Hotline.Api.Controllers
|
|
|
.FirstAsync(x => x.Id == id);
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
#region 质检项管理
|
|
|
/// <summary>
|
|
|
/// 新增项目
|
|
@@ -138,17 +139,17 @@ namespace Hotline.Api.Controllers
|
|
|
await _qualiteyItem.AddAsync(model, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 删除项目
|
|
|
- /// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [Permission(EPermission.DeleteQualityItem)]
|
|
|
- [HttpDelete("item")]
|
|
|
- public async Task Delete([FromBody] QualityItemDeleteDto dto)
|
|
|
- {
|
|
|
- await _qualiteyItem.RemoveAsync(x => x.Id == dto.Id);
|
|
|
- }
|
|
|
+ ///// <summary>
|
|
|
+ ///// 删除项目
|
|
|
+ ///// </summary>
|
|
|
+ ///// <param name="dto"></param>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //[Permission(EPermission.DeleteQualityItem)]
|
|
|
+ //[HttpDelete("item")]
|
|
|
+ //public async Task Delete([FromBody] QualityItemDeleteDto dto)
|
|
|
+ //{
|
|
|
+ // await _qualiteyItem.RemoveAsync(x => x.Id == dto.Id);
|
|
|
+ //}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除项目
|
|
@@ -160,7 +161,13 @@ namespace Hotline.Api.Controllers
|
|
|
public async Task Delete([FromBody] QualityItemBatchDeleteDto dto)
|
|
|
{
|
|
|
List<QualityItem> items = await _qualiteyItem.Queryable().In(x => x.Id, dto.Ids).ToListAsync();
|
|
|
- await _qualiteyItem.RemoveRangeAsync(items, HttpContext.RequestAborted);
|
|
|
+ foreach (var item in items)
|
|
|
+ {
|
|
|
+ var detail = await _qualiteyDetail.Queryable().Where(x => x.Name == item.Name && !x.IsDeleted).AnyAsync();
|
|
|
+ //质检中已存在 启用状态不可以删
|
|
|
+ if (item.IsEnable == 0 || detail) items.Remove(item);
|
|
|
+}
|
|
|
+ if (items.Any()) await _qualiteyItem.RemoveRangeAsync(items,true, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -175,6 +182,10 @@ namespace Hotline.Api.Controllers
|
|
|
var item = await _qualiteyItem.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
if (item is null)
|
|
|
throw UserFriendlyException.SameMessage("无效质检项目");
|
|
|
+ if (item.IsEnable != dto.IsEnable || item.Name != dto.Name) {
|
|
|
+ var detail = await _qualiteyDetail.Queryable().Where(x => x.Name == item.Name && !x.IsDeleted).AnyAsync();
|
|
|
+ if(detail) throw UserFriendlyException.SameMessage("质检项目在中心质检中已使用,不能修改状态和名称!");
|
|
|
+ }
|
|
|
_mapper.Map(dto, item);
|
|
|
item.LastModificationName = _sessionContext.UserName;
|
|
|
await _qualiteyItem.UpdateAsync(item, HttpContext.RequestAborted);
|
|
@@ -211,6 +222,7 @@ namespace Hotline.Api.Controllers
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
#region 质检模版管理
|
|
|
/// <summary>
|
|
|
/// 新增模版
|
|
@@ -345,6 +357,7 @@ namespace Hotline.Api.Controllers
|
|
|
await _qualityTemplate.UpdateAsync(template, HttpContext.RequestAborted);
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
#region 质检词库管理
|
|
|
|
|
|
/// <summary>
|