执行代码清理,修复warning
This commit is contained in:
@@ -50,17 +50,17 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(MaterialReceiptInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
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 && x.mbom_process_id == input.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
.ToListAsync();
|
||||
|
||||
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
|
||||
PrdFeedingH prdFeedingH = new PrdFeedingH()
|
||||
PrdFeedingH prdFeedingH = new()
|
||||
{
|
||||
code = code,
|
||||
station_id = input.station_id,
|
||||
@@ -78,15 +78,17 @@ namespace Tnb.ProductionMgr
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
|
||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
List<PrdFeedingD> list = new();
|
||||
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投入物料,不能签收");
|
||||
}
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.carry_id == input.carry_id && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
@@ -108,20 +110,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}
|
||||
else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
_ = detail.feeding_num + num == detail.num
|
||||
? await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync()
|
||||
: await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -135,29 +135,31 @@ namespace Tnb.ProductionMgr
|
||||
throw new Exception("没有签收物料");
|
||||
}
|
||||
|
||||
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
|
||||
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
|
||||
var station = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == input.station_id);
|
||||
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == input.process_id);
|
||||
var taskLog = new PrdTaskLog();
|
||||
taskLog.id = SnowflakeIdHelper.NextId();
|
||||
taskLog.mo_code = mo?.mo_code!;
|
||||
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.equip_id))?.code!;
|
||||
taskLog.mold_code = "";
|
||||
taskLog.item_code = material?.code!;
|
||||
taskLog.item_standard = material?.material_standard!;
|
||||
taskLog.status = "生产投料";
|
||||
taskLog.operator_name = _userManager.RealName;
|
||||
taskLog.create_id = _userManager.UserId;
|
||||
taskLog.create_time = DateTime.Now;
|
||||
taskLog.mo_task_id = moTask.id;
|
||||
taskLog.mo_task_code = moTask.mo_task_code;
|
||||
taskLog.station_code = station?.EnCode;
|
||||
taskLog.process_code = process.code;
|
||||
PrdMo mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
|
||||
BasMaterial? material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
|
||||
OrganizeEntity station = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == input.station_id);
|
||||
BasMaterial process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == input.process_id);
|
||||
PrdTaskLog taskLog = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
mo_code = mo?.mo_code!,
|
||||
eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.equip_id))?.code!,
|
||||
mold_code = "",
|
||||
item_code = material?.code!,
|
||||
item_standard = material?.material_standard!,
|
||||
status = "生产投料",
|
||||
operator_name = _userManager.RealName,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
mo_task_id = moTask.id,
|
||||
mo_task_code = moTask.mo_task_code,
|
||||
station_code = station?.EnCode,
|
||||
process_code = process.code
|
||||
};
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
@@ -172,30 +174,29 @@ namespace Tnb.ProductionMgr
|
||||
// });
|
||||
}
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
return result.IsSuccess ? "投料成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Oh(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "投料成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveDataNew(MaterialReceiptNewInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
PrdFeedingH prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdFeedingH? prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new();
|
||||
DbResult<bool> result2 = new();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
var parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
PrdMoTask moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
PrdMoTask parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
string worklineId = moTask.workline_id;
|
||||
if (parentMoTask != null && !string.IsNullOrEmpty(parentMoTask.workline_id))
|
||||
{
|
||||
worklineId = parentMoTask.workline_id;
|
||||
}
|
||||
var carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
var workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
var workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
OrganizeEntity workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
OrganizeEntity workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == moTask.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
.ToListAsync();
|
||||
@@ -222,12 +223,14 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
@@ -249,20 +252,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}
|
||||
else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
_ = detail.feeding_num + num == detail.num
|
||||
? await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync()
|
||||
: await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -277,8 +278,8 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
@@ -322,8 +323,7 @@ namespace Tnb.ProductionMgr
|
||||
// }
|
||||
}
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "签收成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -337,28 +337,32 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> Feeding(MaterialReceiptNewInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
|
||||
{
|
||||
{"station_id",input.station_id}
|
||||
});
|
||||
|
||||
if (moTask == null) throw Oops.Bah("找不到任务单");
|
||||
PrdFeedingH prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
if (moTask == null)
|
||||
{
|
||||
throw Oops.Bah("找不到任务单");
|
||||
}
|
||||
|
||||
PrdFeedingH? prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new();
|
||||
DbResult<bool> result2 = new();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
PrdMoTask parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
string worklineId = moTask.workline_id;
|
||||
if (parentMoTask != null && !string.IsNullOrEmpty(parentMoTask.workline_id))
|
||||
{
|
||||
worklineId = parentMoTask.workline_id;
|
||||
}
|
||||
var carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
var workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
var workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
OrganizeEntity workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
OrganizeEntity workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == moTask.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
.ToListAsync();
|
||||
@@ -385,12 +389,14 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
@@ -412,20 +418,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}
|
||||
else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
_ = detail.feeding_num + num == detail.num
|
||||
? await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync()
|
||||
: await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -440,21 +444,20 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "签收成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetFeedingRecordTree()
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Queryable<PrdMoTask>()
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
List<FeedingRecordTreeOutput> result = await db.Queryable<PrdMoTask>()
|
||||
.Where(a => a.schedule_type == 2 && a.parent_id != null)
|
||||
.Select(a => new FeedingRecordTreeOutput()
|
||||
{
|
||||
@@ -479,7 +482,7 @@ namespace Tnb.ProductionMgr
|
||||
})
|
||||
}).Mapper(x =>
|
||||
{
|
||||
foreach (var item in x.children)
|
||||
foreach (FeedingRecordChildren item in x.children)
|
||||
{
|
||||
item.children = db.Queryable<PrdFeedingD>()
|
||||
.LeftJoin<BasMaterial>((c, d) => c.material_id == d.id)
|
||||
|
||||
Reference in New Issue
Block a user