From 1a0df13ec4b5ee014eaaeba4f4c19dd7b3b7b8ac Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Fri, 16 Jun 2023 11:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E7=AD=BE=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IBasMbomService.cs | 9 +- BasicData/Tnb.BasicData/BasMbomService.cs | 14 ++ .../Dto/PrdManage/MaterialReceiptInput.cs | 59 ++++++++ .../Entity/PrdMaterialReceiptD.cs | 42 ++++++ .../Entity/PrdMaterialReceiptH.cs | 92 +++++++++++++ .../IPrdMaterialReceiptService.cs | 19 +++ .../PrdMaterialReceiptService.cs | 129 ++++++++++++++++++ .../Tnb.ProductionMgr.csproj | 1 + 8 files changed, 364 insertions(+), 1 deletion(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMaterialReceiptService.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs index 4f85705e..1c048c98 100644 --- a/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs +++ b/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs @@ -5,10 +5,17 @@ namespace Tnb.BasicData.Interfaces public interface IBasMbomService { /// - /// 根据物料id获取对应的子任务列表 + /// 鏍规嵁鐗╂枡id鑾峰彇瀵瑰簲鐨勫瓙浠诲姟鍒楄〃 /// /// bomid /// Task GetSubMoListByBomId([FromRoute] string bomId); + + /// + /// 鏍规嵁鐢熶骇bom宸ュ簭id鑾峰彇鎶曞叆鐗╂枡 + /// + /// id + /// + Task GetInputMaterialByMbomProcessId(Dictionary dic); } } \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs index f92b105c..e16924c5 100644 --- a/BasicData/Tnb.BasicData/BasMbomService.cs +++ b/BasicData/Tnb.BasicData/BasMbomService.cs @@ -181,6 +181,20 @@ namespace Tnb.BasicData return result; } + [HttpPost] + public async Task GetInputMaterialByMbomProcessId(Dictionary dic) + { + string id = dic["id"]; + var result = await _repository.AsSugarClient().Queryable() + .Where(x => x.mbom_process_id == id) + .Select(x => new + { + material_id = x.material_id, + }).ToListAsync(); + return result; + + } + /// /// 鏍规嵁鐗╂枡id鑾峰彇鐢熶骇bom /// diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs new file mode 100644 index 00000000..5d0e22ad --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs @@ -0,0 +1,59 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class MaterialReceiptInput + { + public string id { get; set; } + + /// + /// 宸ヤ綅id + /// + public string station_id { get; set; } = string.Empty; + + /// + /// 浠诲姟鍗昳d + /// + public string? mo_task_id { get; set; } + + /// + /// 宸ュ簭id + /// + public string? process_id { get; set; } + + /// + /// 璁惧id + /// + public string? equip_id { get; set; } + + /// + /// 杞﹂棿id + /// + public string? workshop_id { get; set; } + + /// + /// 杞藉叿id + /// + public string? carry_id { get; set; } + + /// + /// 浜х嚎id + /// + public string? workline_id { get; set; } + + /// + /// 浜岀淮鐮佷俊鎭 + /// + public string? carry_code { get; set; } + + /// + /// 澶囨敞 + /// + public string? remark { get; set; } + + /// + /// 鐢熶骇bom宸ュ簭id + /// + public string? mbom_process_id { get; set; } + + public List> details { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs new file mode 100644 index 00000000..76f17cd4 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs @@ -0,0 +1,42 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// 鐗╂枡绛炬敹瀛愯〃 +/// +[SugarTable("prd_material_receipt_d")] +public partial class PrdMaterialReceiptD : BaseEntity +{ + public PrdMaterialReceiptD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 鐗╂枡绛炬敹id + /// + public string material_receipt_id { get; set; } = string.Empty; + + /// + /// 鐗╂枡id + /// + public string material_id { get; set; } = string.Empty; + + /// + /// 鏁伴噺 + /// + public int num { get; set; } + + /// + /// 鎵规 + /// + public string? batch { get; set; } + + /// + /// 鍗曚綅id + /// + public string? unit_id { get; set; } + +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs new file mode 100644 index 00000000..57ae28fe --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs @@ -0,0 +1,92 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// 鐗╂枡绛炬敹涓昏〃 +/// +[SugarTable("prd_material_receipt_h")] +public partial class PrdMaterialReceiptH : BaseEntity +{ + public PrdMaterialReceiptH() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 宸ヤ綅id + /// + public string station_id { get; set; } = string.Empty; + + /// + /// 浠诲姟鍗昳d + /// + public string? mo_task_id { get; set; } + + /// + /// 宸ュ簭id + /// + public string? process_id { get; set; } + + /// + /// 璁惧id + /// + public string? equip_id { get; set; } + + /// + /// 杞﹂棿id + /// + public string? workshop_id { get; set; } + + /// + /// 杞藉叿id + /// + public string? carry_id { get; set; } + + /// + /// 浜х嚎id + /// + public string? workline_id { get; set; } + + /// + /// 鍒涘缓鐢ㄦ埛 + /// + public string? create_id { get; set; } + + /// + /// 鍒涘缓鏃堕棿 + /// + public DateTime? create_time { get; set; } + + /// + /// 浜岀淮鐮佷俊鎭 + /// + public string? carry_code { get; set; } + + /// + /// 澶囨敞 + /// + public string? remark { get; set; } + + /// + /// 娴佺▼寮曟搸Id + /// + public string? f_flowid { get; set; } + + /// + /// 娴佺▼浠诲姟Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 鎵灞炵粍缁 + /// + public string? org_id { get; set; } + + /// + /// 鐢熶骇bom宸ュ簭id + /// + public string? mbom_process_id { get; set; } + +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMaterialReceiptService.cs new file mode 100644 index 00000000..3810560c --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMaterialReceiptService.cs @@ -0,0 +1,19 @@ +using Tnb.ProductionMgr.Entities.Dto; + +namespace Tnb.ProductionMgr.Interfaces +{ + /// + /// 鐗╂枡绛炬敹鏈嶅姟鎺ュ彛 + /// + public interface IPrdMaterialReceiptService + { + /// + /// 鏍规嵁閾佺墖浜岀淮鐮佽幏鍙栦俊鎭 + /// + /// + /// + public Task GetInfoByQrCode(string qrCode); + + public Task SaveData(MaterialReceiptInput input); + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs new file mode 100644 index 00000000..f437c660 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -0,0 +1,129 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using Microsoft.AspNetCore.Mvc; +using Microsoft.ClearScript.Util.Web; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; +using Tnb.ProductionMgr.Interfaces; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Dto; + +namespace Tnb.ProductionMgr +{ + /// + /// 涓氬姟瀹炵幇:鐗╂枡绛炬敹 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class PrdMaterialReceiptService : IPrdMaterialReceiptService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + + public PrdMaterialReceiptService( + ISqlSugarRepository repository, + IUserManager userManager + ) + { + _repository = repository; + _userManager = userManager; + } + + + [HttpPost] + 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; + } + + [HttpPost] + public async Task SaveData(MaterialReceiptInput input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + 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) + .Select(x=>x.material_id) + .ToListAsync(); + + PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH() + { + station_id = input.station_id, + mo_task_id = input.mo_task_id, + process_id = input.process_id, + equip_id = input.equip_id, + workshop_id = input.workshop_id, + carry_id = input.carry_id, + workline_id = input.workline_id, + carry_code = input.carry_code, + remark = input.remark, + mbom_process_id = input.mbom_process_id, + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId + }; + + List list = new List(); + if (input.details != null && input.details.Count > 0) + { + foreach (var item in input.details) + { + if(!inputMaterials.Contains(item["material_id"])) + throw new Exception("璇ョ墿鏂欎笉鏄敓浜om鎶曞叆鐗╂枡锛屼笉鑳界鏀"); + + list.Add(new PrdMaterialReceiptD + { + material_receipt_id = prdMaterialReceiptH.id, + material_id = item["material_id"], + num = Convert.ToInt32(item["num"]), + batch = item["batch"], + unit_id = item["unit_id"], + }); + } + } + else + { + throw new Exception("娌℃湁绛炬敹鐗╂枡"); + } + + + await db.Insertable(prdMaterialReceiptH).ExecuteCommandAsync(); + await db.Insertable(list).ExecuteCommandAsync(); + + }); + + if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); + return result.IsSuccess ? "绛炬敹鎴愬姛" : result.ErrorMessage; + } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj index dc0d6697..0ea7ec46 100644 --- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj +++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj @@ -12,6 +12,7 @@ +