执行代码清理,修复warning

This commit is contained in:
2023-11-06 19:59:12 +08:00
parent c6b8dfc861
commit 1dbb17f103
118 changed files with 5046 additions and 4111 deletions

View File

@@ -50,7 +50,7 @@ namespace Tnb.EquipMgr
private async Task<object> GetList(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
ISqlSugarClient db = _repository.AsSugarClient();
Dictionary<string, object>? queryJson = (input == null || string.IsNullOrEmpty(input.queryJson)) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
string equioInfo = queryJson.ContainsKey("query_info") ? (queryJson["query_info"].ToString() ?? "") : "";
string status = queryJson.ContainsKey("status") ? (queryJson["status"].ToString() ?? "") : "";
@@ -67,7 +67,7 @@ namespace Tnb.EquipMgr
input.sidx = "a." + input.sidx;
}
var list = await db.Queryable<EqpMaintainRecordH, EqpEquipment, UserEntity, UserEntity>((a, b, c, d) => new object[]
SqlSugarPagedList<EqpMaintainRecordListOutput> list = await db.Queryable<EqpMaintainRecordH, EqpEquipment, UserEntity, UserEntity>((a, b, c, d) => new object[]
{
JoinType.Left, a.equip_id == b.id,
JoinType.Left, a.execute_user_id == c.Id,
@@ -105,7 +105,7 @@ namespace Tnb.EquipMgr
a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
})
.ToPagedListAsync((input?.currentPage ?? 1), (input?.pageSize ?? 50));
.ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
return PageResult<EqpMaintainRecordListOutput>.SqlSugarPageResult(list);
}
@@ -120,16 +120,8 @@ namespace Tnb.EquipMgr
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
EqpMaintainRecordH eqpSpotInsRecordH = _repository.GetSingle(x => x.id == input.id);
string status = "";
if (eqpSpotInsRecordH.is_repeat == "1")
{
status = SpotInsRecordExecutionStatus.TOBECHECK;
}
else
{
status = SpotInsRecordExecutionStatus.COMPLETED;
}
await _repository.UpdateAsync(x => new EqpMaintainRecordH()
string status = eqpSpotInsRecordH.is_repeat == "1" ? SpotInsRecordExecutionStatus.TOBECHECK : SpotInsRecordExecutionStatus.COMPLETED;
_ = await _repository.UpdateAsync(x => new EqpMaintainRecordH()
{
result = input.result,
attachment = input.attachment,
@@ -141,9 +133,9 @@ namespace Tnb.EquipMgr
if (input != null && input.details != null)
{
foreach (var item in input.details)
foreach (Dictionary<string, string> item in input.details)
{
await _repository.AsSugarClient().Updateable<EqpMaintainRecordD>()
_ = await _repository.AsSugarClient().Updateable<EqpMaintainRecordD>()
.SetColumns(x => x.result == item["result"])
.SetColumnsIF(item.ContainsKey("maintain_descrip"), x => x.maintain_descrip == item["maintain_descrip"])
.Where(x => x.id == item["id"])
@@ -154,8 +146,7 @@ namespace Tnb.EquipMgr
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "执行成功" : result.ErrorMessage;
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "执行成功" : result.ErrorMessage);
}
/// <summary>
@@ -184,7 +175,7 @@ namespace Tnb.EquipMgr
{
x.maintain_type = typeDic.ContainsKey(x.maintain_type) ? typeDic[x.maintain_type] + "" : x.maintain_type;
});
MaintainRecordRepeatOutput output = new MaintainRecordRepeatOutput()
MaintainRecordRepeatOutput output = new()
{
model = eqpSpotInsRecordH,
details = eqpSpotInsRecordDs,
@@ -199,7 +190,7 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task<string> RepeatMaintain(MaintainRecordRepeatInput input)
{
var db = _repository.AsSugarClient();
ISqlSugarClient db = _repository.AsSugarClient();
EqpMaintainRecordH eqpMaintainRecordH = await _repository.GetSingleAsync(x => x.id == input.id);
if (eqpMaintainRecordH.status == "1")
{
@@ -210,9 +201,9 @@ namespace Tnb.EquipMgr
if (input != null && input.details != null)
{
foreach (var item in input.details)
foreach (Dictionary<string, string> item in input.details)
{
await db.Updateable<EqpMaintainRecordD>()
_ = await db.Updateable<EqpMaintainRecordD>()
.SetColumnsIF(item.ContainsKey("repeat_descrip"), x => x.repeat_descrip == item["repeat_descrip"])
.SetColumns(x => x.repeat_result == item["repeat_result"])
.Where(x => x.id == item["id"]).ExecuteCommandAsync();
@@ -221,7 +212,7 @@ namespace Tnb.EquipMgr
if (input != null)
{
await _repository.UpdateAsync(x => new EqpMaintainRecordH()
_ = await _repository.UpdateAsync(x => new EqpMaintainRecordH()
{
repeat_result = input.repeat_result,
repeat_remark = input.repeat_remark,
@@ -232,20 +223,19 @@ namespace Tnb.EquipMgr
}
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "复核成功" : result.ErrorMessage;
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "复核成功" : result.ErrorMessage;
}
[HttpPost]
public async Task<dynamic> GetMaintainRecordList(EquipQueryInput input)
{
var db = _repository.AsSugarClient();
Dictionary<string, string>? queryJson = new Dictionary<string, string>();
ISqlSugarClient db = _repository.AsSugarClient();
Dictionary<string, string>? queryJson = new();
if (!string.IsNullOrEmpty(input.queryJson))
{
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
}
var result = await db.Queryable<EqpMaintainRecordH>()
SqlSugarPagedList<EquipMaintainRecordQueryOutput> result = await db.Queryable<EqpMaintainRecordH>()
.LeftJoin<EqpEquipment>((a, b) => a.equip_id == b.id)
.LeftJoin<UserEntity>((a, b, c) => a.execute_user_id == c.Id)
.LeftJoin<UserEntity>((a, b, c, d) => a.repeat_user_id == d.Id)
@@ -277,24 +267,28 @@ namespace Tnb.EquipMgr
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> GetEqpMaintainRecordInfoById(Dictionary<string, string> dic)
public async Task<dynamic?> GetEqpMaintainRecordInfoById(Dictionary<string, string> dic)
{
string id = dic.ContainsKey("id") ? dic["id"] : "";
if (string.IsNullOrEmpty(id)) return null;
var db = _repository.AsSugarClient();
if (string.IsNullOrEmpty(id))
{
return null;
}
ISqlSugarClient db = _repository.AsSugarClient();
return await db.Queryable<EqpMaintainRecordH>()
.LeftJoin<EqpEquipment>((a, b) => a.equip_id == b.id)
.Where((a, b) => a.id == id)
.Select((a, b) => new
{
id = a.id,
equip_id = a.equip_id,
a.id,
a.equip_id,
equip_code = b.code,
equip_name = b.name,
create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
result_remark = a.result_remark,
result = a.result,
status = a.status,
a.result_remark,
a.result,
a.status,
}).FirstAsync();
}