diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs index 71ade71f..4fd65c0f 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs @@ -43,6 +43,17 @@ public partial class PrdMaterialReceiptD : BaseEntity /// 载具id /// public string carry_id { get; set; } = string.Empty; + + /// + /// 子载具id + /// + public string? member_carry_id { get; set; } + + /// + /// 子载具编号 + /// + public string? member_carry_code { get; set; } + /// /// 是否全部投料 diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index bdb2348f..b42dcfaf 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -57,26 +57,78 @@ namespace Tnb.ProductionMgr public async Task GetInfoByQrCode(string qrCode) { var db = _repository.AsSugarClient(); - var result = await db.Queryable() - .Where((a) => a.carry_code == qrCode) - .Select(a => new - { - carry_id = a.id, - carry_name = a.carry_name, - children = SqlFunc.Subqueryable() - .LeftJoin((b,c)=>b.material_id==c.id) - .Where((b,c)=>a.id==b.carry_id).ToList((b,c)=>new CarryCodeDetailOutput() - { - unit_id = c.unit_id, - barcode = b.barcode, - code_batch = b.code_batch, - codeqty = b.codeqty, - material_id = b.material_id, - material_code = c.code, - material_name = c.name - }) - }).FirstAsync(); - return result; + // var result = await db.Queryable() + // .Where((a) => a.carry_code == qrCode) + // .Select(a => new + // { + // carry_id = a.id, + // carry_name = a.carry_name, + // children = SqlFunc.Subqueryable() + // .LeftJoin((b,c)=>b.material_id==c.id) + // .Where((b,c)=>a.id==b.carry_id).ToList((b,c)=>new CarryCodeDetailOutput() + // { + // unit_id = c.unit_id, + // barcode = b.barcode, + // code_batch = b.code_batch, + // codeqty = b.codeqty, + // material_id = b.material_id, + // material_code = c.code, + // material_name = c.name + // }) + // }).FirstAsync(); + + if (await db.Queryable() + .AnyAsync(x => x.member_carry_code == qrCode && x.is_all_feeding == 0)) + { + var result = await db.Queryable() + .LeftJoin((a, b) => a.carry_id == b.id) + .Where((a) => a.member_carry_code == qrCode && a.is_all_feeding == 0) + .Select((a, b) => new FeedingDetailOutput + { + carry_id = b.id, + carry_name = b.carry_name, + children = SqlFunc.Subqueryable() + .LeftJoin((c, d) => c.material_id == d.id) + .Where((c, d) => a.member_carry_code == c.member_carry_code && c.is_all_feeding == 0) + .ToList((c, d) => new CarryCodeDetailOutput() + { + unit_id = d.unit_id, + // barcode = c.barcode, + // code_batch = c.code_batch, + code_batch = c.batch, + codeqty = c.num, + material_id = c.material_id, + material_code = d.code, + material_name = d.name + }) + }).FirstAsync(); + return result; + } + else + { + var result = await db.Queryable() + .LeftJoin((a, b) => a.carry_id == b.id) + .Where((a) => a.carry_code == qrCode) + .Select((a, b) => new FeedingDetailOutput + { + carry_id = a.carry_id, + carry_name = b.carry_name, + children = SqlFunc.Subqueryable() + .LeftJoin((c, d) => c.material_id == d.id) + .Where((c, d) => a.id == c.material_receipt_id && c.is_all_feeding==0).ToList((c, d) => new CarryCodeDetailOutput() + { + unit_id = d.unit_id, + // barcode = c.barcode, + // code_batch = c.code_batch, + code_batch = c.batch, + codeqty = c.num, + material_id = c.material_id, + material_code = d.code, + material_name = d.name + }) + }).FirstAsync(); + return result; + } } [HttpPost] @@ -90,7 +142,8 @@ namespace Tnb.ProductionMgr { var moTask = await db.Queryable().FirstAsync(x => x.id == input.mo_task_id); var inputMaterials = await db.Queryable() - .Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == input.mbom_process_id) + .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) .ToListAsync(); @@ -113,7 +166,6 @@ namespace Tnb.ProductionMgr org_id = _userManager.GetUserInfo().Result.organizeId }; - List list = new List(); if (input.details != null && input.details.Count > 0) { foreach (var item in input.details) @@ -130,6 +182,8 @@ namespace Tnb.ProductionMgr unit_id = item["unit_id"], carry_id = input.carry_id, is_all_feeding = 0, + member_carry_id = item["member_carry_id"], + member_carry_code = item["member_carry_code"], feeding_num = 0, }); } @@ -185,9 +239,9 @@ namespace Tnb.ProductionMgr } } - - if(!result2.IsSuccess) throw Oops.Oh(result2.ErrorMessage); - return result2.IsSuccess ? "签收成功" : result2.ErrorMessage; + if(!result.IsSuccess) throw Oops.Bah(result.ErrorMessage); + if(!result2.IsSuccess) throw Oops.Bah(result2.ErrorMessage); + return "签收成功"; } } } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/FeedingDetailOutput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/FeedingDetailOutput.cs new file mode 100644 index 00000000..e57f58f2 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/FeedingDetailOutput.cs @@ -0,0 +1,12 @@ +namespace Tnb.WarehouseMgr.Entities.Dto +{ + /// + /// 扫码投料 + /// + public class FeedingDetailOutput + { + public string carry_id { get; set; } + public string carry_name { get; set; } + public List children { get; set; } + } +} \ No newline at end of file