执行代码清理,修复warning
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetInfoByQrCode(string qrCode)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
// var result = await db.Queryable<WmsCarryH>()
|
||||
// .Where((a) => a.carry_code == qrCode)
|
||||
// .Select(a => new
|
||||
@@ -77,7 +77,7 @@ namespace Tnb.ProductionMgr
|
||||
if (await db.Queryable<PrdMaterialReceiptD>()
|
||||
.AnyAsync(x => x.member_carry_code == qrCode && x.is_all_feeding == 0))
|
||||
{
|
||||
var result = await db.Queryable<PrdMaterialReceiptD>()
|
||||
FeedingDetailOutput result = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.LeftJoin<WmsCarryH>((a, b) => a.carry_id == b.id)
|
||||
.Where((a) => a.member_carry_code == qrCode && a.is_all_feeding == 0)
|
||||
.Select((a, b) => new FeedingDetailOutput
|
||||
@@ -103,7 +103,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await db.Queryable<PrdMaterialReceiptH>()
|
||||
FeedingDetailOutput result = await db.Queryable<PrdMaterialReceiptH>()
|
||||
.LeftJoin<WmsCarryH>((a, b) => a.carry_id == b.id)
|
||||
.Where((a) => a.carry_code == qrCode)
|
||||
.Select((a, b) => new FeedingDetailOutput
|
||||
@@ -131,14 +131,14 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(MaterialReceiptInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
PrdMaterialReceiptH prdMaterialReceiptH = null;
|
||||
List<PrdMaterialReceiptD> list = new List<PrdMaterialReceiptD>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result2 = new();
|
||||
PrdMaterialReceiptH? prdMaterialReceiptH = null;
|
||||
List<PrdMaterialReceiptD> list = new();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
PrdMoTask moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mbom_process_id), x => x.mbom_process_id == input.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
@@ -168,10 +168,12 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, object> item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
|
||||
list.Add(new PrdMaterialReceiptD
|
||||
{
|
||||
@@ -214,7 +216,7 @@ namespace Tnb.ProductionMgr
|
||||
// carry_code = input.carry_code ?? "",
|
||||
// });
|
||||
|
||||
var mesCarrySignInput = new MESCarrySignInput()
|
||||
MESCarrySignInput mesCarrySignInput = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
create_id = _userManager.UserId,
|
||||
@@ -222,30 +224,24 @@ 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_CARRY_SIGN, JsonConvert.SerializeObject(mesCarrySignInput), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN, JsonConvert.SerializeObject(mesCarrySignInput), header);
|
||||
Log.Information(sendResult);
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
if (authResponse.code != 200)
|
||||
{
|
||||
throw Oops.Bah(authResponse.msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
result2 = await db.Ado.UseTranAsync(async () =>
|
||||
result2 = authResponse.code != 200
|
||||
? throw Oops.Bah(authResponse.msg)
|
||||
: await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||
if (!result2.IsSuccess) throw Oops.Bah(result2.ErrorMessage);
|
||||
return "签收成功";
|
||||
return !result.IsSuccess
|
||||
? throw Oops.Bah(result.ErrorMessage)
|
||||
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user