diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs index 997f84f2..62ec0678 100644 --- a/BasicData/Tnb.BasicData/BasMbomService.cs +++ b/BasicData/Tnb.BasicData/BasMbomService.cs @@ -83,35 +83,6 @@ namespace Tnb.BasicData return PageResult.SqlSugarPageResult(list); } - /// - /// 根据bomid获取对应的子bom列表 - /// - /// - /// - [HttpGet] - public async Task GetSubMoListByBomId([FromRoute] string bomId) - { - if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty"); - var result = await _db.Queryable().LeftJoin((a, b) => a.route_id == b.route_id) - .LeftJoin((a, b, c) => b.process_id == c.id) - .LeftJoin((a, b, c, d) => c.id == d.process_id) - .LeftJoin((a, b, c, d, e) => d.material_id == e.id) - .LeftJoin((a, b, c, d, e, f) => e.category_id == f.id) - .Where((a, b, c, d, e, f) => a.id == bomId) - .Select((a, b, c, d, e, f) => new SubBomListOutput - { - material_id = e.id, - material_code = e.code, - material_name = e.name, - material_category_code = f.category_code, - num = d.num - }) - .Mapper(it => it.output_qty = it.num.ParseToInt()) - .Distinct() - .ToListAsync(); - return result; - } - /// /// 获取编辑信息 /// @@ -159,6 +130,38 @@ namespace Tnb.BasicData } + /// + /// 根据bomid获取对应的子bom列表 + /// + /// + /// + [HttpGet] + public async Task GetSubMoListByBomId([FromRoute] string bomId) + { + if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty"); + var result = await _db.Queryable().LeftJoin((a, b) => a.route_id == b.route_id) + .LeftJoin((a, b, c) => b.process_id == c.id) + .LeftJoin((a, b, c, d) => c.id == d.process_id) + .LeftJoin((a, b, c, d, e) => d.material_id == e.id) + .LeftJoin((a, b, c, d, e, f) => e.category_id == f.id) + .Where((a, b, c, d, e, f) => a.id == bomId) + .Select((a, b, c, d, e, f) => new SubBomListOutput + { + material_id = e.id, + material_code = e.code, + material_name = e.name, + material_category_code = f.category_code, + num = d.num + }) + .Mapper(it => it.output_qty = it.num.ParseToInt()) + .Distinct() + .ToListAsync(); + return result; + } + + + + /// /// 根据物料id获取生产bom /// @@ -204,6 +207,7 @@ namespace Tnb.BasicData [HttpPost] public async Task SaveData(MbomSaveDataInput mbomSaveDataInput) { + ErrorCode errorCode = ErrorCode.COM1008; DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => { //新增 @@ -312,14 +316,14 @@ namespace Tnb.BasicData else//修改 { if (await _repository.IsAnyAsync(x => - x.material_id == mbomSaveDataInput.material_id && x.version == mbomSaveDataInput.version && x.id!=mbomSaveDataInput.id)) + x.material_id == mbomSaveDataInput.material_id && x.version == mbomSaveDataInput.version && x.id != mbomSaveDataInput.id)) { - //errorCode = ErrorCode.COM1004; + errorCode = ErrorCode.COM1004; throw Oops.Oh(ErrorCode.COM1004); } - - string orgId = _userManager.GetUserInfo().Result.organizeId; - await _repository.UpdateAsync(x=>new BasMbom() + + string orgId = _userManager.GetUserInfo().Result.organizeId; + await _repository.UpdateAsync(x => new BasMbom() { // org_id = orgId, material_id = mbomSaveDataInput.material_id, @@ -439,9 +443,10 @@ namespace Tnb.BasicData throw Oops.Oh(errorCode); } } - + } return result.IsSuccess ? "保存成功" : result.ErrorMessage; } } + } \ No newline at end of file