执行代码清理,修复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

@@ -57,9 +57,9 @@ namespace Tnb.ProductionMgr
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
{
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
string moCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
var list = await _repository.AsSugarClient().Queryable<PrdMoTask>()
List<PrdMoTaskTreeOutput> list = await _repository.AsSugarClient().Queryable<PrdMoTask>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
.LeftJoin<EqpEquipment>((a, b, c, d) => a.eqp_id == d.id)
@@ -79,7 +79,7 @@ namespace Tnb.ProductionMgr
estimated_end_date = a.estimated_end_date.ToString(),
create_time = a.create_time.ToString()
}).ToListAsync();
var treeList = list.ToTree();
List<PrdMoTaskTreeOutput> treeList = list.ToTree();
treeList = treeList.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList();
SqlSugarPagedList<PrdMoTaskTreeOutput> pagedList = new()
{
@@ -97,11 +97,11 @@ namespace Tnb.ProductionMgr
[HttpPost]
public async Task<dynamic> SaveData(PrdInstockInput input)
{
var db = _repository.AsSugarClient();
var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
PrdInstockH prdInstockH = null;
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
DbResult<bool> result2 = new DbResult<bool>();
ISqlSugarClient db = _repository.AsSugarClient();
BasLocation location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };
DbResult<bool> result2 = new();
if (string.IsNullOrEmpty(input.station_id))
{
@@ -130,7 +130,7 @@ namespace Tnb.ProductionMgr
status = 0,
};
foreach (var item in input.details)
foreach (Dictionary<string, string> item in input.details)
{
prdInstockDs.Add(new PrdInstockD()
{
@@ -158,22 +158,24 @@ namespace Tnb.ProductionMgr
if (result.IsSuccess)
{
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
mesCreateInstockInput.instock = new MESWmsInstockHInput()
MESCreateInstockInput mesCreateInstockInput = new()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = input.bill_type,
warehouse_id = location?.wh_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = input.carry_code,
location_code = input.location_code,
is_check = input.is_check,
instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = input.bill_type,
warehouse_id = location?.wh_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = input.carry_code,
location_code = input.location_code,
is_check = input.is_check,
},
instockds = new List<MESWmsInstockDInput>(),
instockcodes = new List<MESWmsInstockCodeInput>()
};
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
foreach (var item in input.details)
foreach (Dictionary<string, string> item in input.details)
{
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
{
@@ -197,34 +199,27 @@ namespace Tnb.ProductionMgr
});
}
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
Dictionary<string, object> header = new Dictionary<string, object>()
Dictionary<string, object> header = new()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
Log.Information(sendResult);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
{
throw Oops.Bah(authResponse.msg);
}
else
{
result2 = await db.Ado.UseTranAsync(async () =>
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
? throw Oops.Bah(authResponse.msg)
: await db.Ado.UseTranAsync(async () =>
{
await _repository.InsertAsync(prdInstockH);
_ = await _repository.InsertAsync(prdInstockH);
if (prdInstockDs.Count > 0)
{
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
}
});
}
}
if (!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result2.IsSuccess ? "保存成功" : result2.ErrorMessage;
return !result2.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result2.IsSuccess ? "保存成功" : result2.ErrorMessage);
}
/// <summary>
@@ -235,20 +230,20 @@ namespace Tnb.ProductionMgr
public async Task<dynamic> SyncInstock(Dictionary<string, string> dic)
{
string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : "";
var db = _repository.AsSugarClient();
ISqlSugarClient db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
if (!string.IsNullOrEmpty(sourceId))
{
await _repository.UpdateAsync(x => new PrdInstockH()
_ = await _repository.UpdateAsync(x => new PrdInstockH()
{
status = 1
}, x => x.id == sourceId);
var details = await db.Queryable<PrdInstockD>().Where(x => x.instock_id == sourceId).ToListAsync();
List<PrdInstockD> details = await db.Queryable<PrdInstockD>().Where(x => x.instock_id == sourceId).ToListAsync();
foreach (var item in details)
foreach (PrdInstockD item in details)
{
await db.Updateable<PrdReport>().SetColumns(x => x.status == 1)
_ = await db.Updateable<PrdReport>().SetColumns(x => x.status == 1)
.Where(x => x.id == item.report_id).ExecuteCommandAsync();
}
}
@@ -268,21 +263,40 @@ namespace Tnb.ProductionMgr
{
string equip_code = inut.equip_code;
string as_location_code = inut.as_location_code;
if (!string.IsNullOrEmpty(equip_code)) throw Oops.Bah("请传机台号");
var db = _repository.AsSugarClient();
if (!string.IsNullOrEmpty(equip_code))
{
throw Oops.Bah("请传机台号");
}
ISqlSugarClient db = _repository.AsSugarClient();
EqpEquipment equipment = await db.Queryable<EqpEquipment>().Where(x => x.code == equip_code).FirstAsync();
if (equipment == null) throw Oops.Bah("未找到机台");
if (string.IsNullOrEmpty(equipment.as_location_id)) throw Oops.Bah("未找到入库库位");
if (equipment == null)
{
throw Oops.Bah("未找到机台");
}
if (string.IsNullOrEmpty(equipment.as_location_id))
{
throw Oops.Bah("未找到入库库位");
}
BasLocation basLocation = await db.Queryable<BasLocation>().SingleAsync(x => x.id == equipment.as_location_id);
if (basLocation == null) throw Oops.Bah("未找到入库库位");
if (basLocation == null)
{
throw Oops.Bah("未找到入库库位");
}
PrdReport prdReport = await db.Queryable<PrdReport>()
.Where(x => x.equip_id == equipment.id && x.status == 0).OrderByDescending(x => x.create_time)
.FirstAsync();
if (prdReport == null) throw Oops.Bah("未找到提报记录");
if (prdReport == null)
{
throw Oops.Bah("未找到提报记录");
}
PrdInstockH prdInstockH = null;
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
DbResult<bool> result2 = new DbResult<bool>();
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };
DbResult<bool> result2 = new();
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdReport.material_id);
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
@@ -320,21 +334,23 @@ namespace Tnb.ProductionMgr
if (result.IsSuccess)
{
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
mesCreateInstockInput.instock = new MESWmsInstockHInput()
MESCreateInstockInput mesCreateInstockInput = new()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = basLocation?.wh_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = prdReport.material_box_code,
location_code = basLocation.location_code,
is_check = 1,
instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = basLocation?.wh_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = prdReport.material_box_code,
location_code = basLocation.location_code,
is_check = 1,
},
instockds = new List<MESWmsInstockDInput>(),
instockcodes = new List<MESWmsInstockCodeInput>()
};
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
{
material_id = prdReport.material_id,
@@ -354,46 +370,39 @@ namespace Tnb.ProductionMgr
codeqty = (int)prdReport.reported_qty,
});
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
Dictionary<string, object> header = new Dictionary<string, object>()
Dictionary<string, object> header = new()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
Log.Information(sendResult);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
{
throw Oops.Bah(authResponse.msg);
}
else
{
result2 = await db.Ado.UseTranAsync(async () =>
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
? throw Oops.Bah(authResponse.msg)
: await db.Ado.UseTranAsync(async () =>
{
await _repository.InsertAsync(prdInstockH);
_ = await _repository.InsertAsync(prdInstockH);
if (prdInstockDs.Count > 0)
{
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
}
});
}
}
if (!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result2.IsSuccess ? "申请成功" : result2.ErrorMessage;
return !result2.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result2.IsSuccess ? "申请成功" : result2.ErrorMessage);
}
[HttpPost]
public async Task<string> InstockTubeOne(PrdReport prdReport)
{
var db = _repository.AsSugarClient();
ISqlSugarClient db = _repository.AsSugarClient();
string location_code = "JMXHC-01";
string warehouse_id = "26103348825381";
PrdInstockH prdInstockH = null;
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
DbResult<bool> result2 = new DbResult<bool>();
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };
DbResult<bool> result2 = new();
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdReport.material_id);
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
@@ -431,21 +440,23 @@ namespace Tnb.ProductionMgr
if (result.IsSuccess)
{
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
mesCreateInstockInput.instock = new MESWmsInstockHInput()
MESCreateInstockInput mesCreateInstockInput = new()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = warehouse_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = prdReport.material_box_code,
location_code = location_code,
is_check = 1,
instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = warehouse_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = prdReport.material_box_code,
location_code = location_code,
is_check = 1,
},
instockds = new List<MESWmsInstockDInput>(),
instockcodes = new List<MESWmsInstockCodeInput>()
};
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
{
material_id = prdReport.material_id,
@@ -465,30 +476,24 @@ namespace Tnb.ProductionMgr
codeqty = (int)prdReport.reported_qty,
});
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
Dictionary<string, object> header = new Dictionary<string, object>()
Dictionary<string, object> header = new()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
Log.Information(sendResult);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
{
throw Oops.Bah(authResponse.msg);
}
else
{
result2 = await db.Ado.UseTranAsync(async () =>
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
? throw Oops.Bah(authResponse.msg)
: await db.Ado.UseTranAsync(async () =>
{
await _repository.InsertAsync(prdInstockH);
_ = await _repository.InsertAsync(prdInstockH);
if (prdInstockDs.Count > 0)
{
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
}
});
}
}
return result2.IsSuccess ? "true" : "false";