diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 10b21f06..183953d8 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -235,7 +235,7 @@ namespace Tnb.ProductionMgr throw new Exception("该物料不是生产bom投入物料,不能签收"); var detail = await db.Queryable() - .Where(x => x.carry_id == carry.id && x.is_all_feeding == 0).FirstAsync(); + .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 { @@ -283,8 +283,8 @@ namespace Tnb.ProductionMgr } - // await db.Insertable(prdFeedingH).ExecuteCommandAsync(); - // await db.Insertable(list).ExecuteCommandAsync(); + await db.Insertable(prdFeedingH).ExecuteCommandAsync(); + await db.Insertable(list).ExecuteCommandAsync(); }); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 64429b5e..2e5d2d2f 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -27,6 +27,10 @@ using Tnb.EquipMgr.Entities; using Tnb.ProductionMgr.Entities.Dto.PrdManage; using JNPF.Common.Filter; using JNPF.Common.Security; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Interfaces.Permission; +using SQLitePCL; +using SqlSugar.Extensions; namespace Tnb.ProductionMgr { @@ -40,15 +44,18 @@ namespace Tnb.ProductionMgr { private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; + private readonly IOrganizeService _organizeService; private const string ModuleId = "25572529329173"; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); public PrdInstockService( ISqlSugarRepository repository, + IOrganizeService organizeService, IUserManager userManager ) { _repository = repository; + _organizeService = organizeService; _userManager = userManager; OverideFuncs.GetListAsync = GetList; } @@ -100,8 +107,18 @@ namespace Tnb.ProductionMgr PrdInstockH prdInstockH = null; List prdInstockDs = new List() { }; DbResult result2 = new DbResult(); + + if (string.IsNullOrEmpty(input.station_id)) + { + throw Oops.Bah("请先选择工位"); + } + DbResult result = await db.Ado.UseTranAsync(async () => { + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorklineCode); + OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorkshopCode); + + prdInstockH = new PrdInstockH() { bill_type = input.bill_type, @@ -111,8 +128,8 @@ namespace Tnb.ProductionMgr carry_code = input.carry_code, is_check = input.is_check, station_id = input.station_id, - workline_id = input.workline_id, - workshop_id = input.workshop_id, + workline_id = workline?.Id ?? "", + workshop_id = workshop?.Id ?? "", org_id = _userManager.GetUserInfo().Result.organizeId, warehouse_id = location?.wh_id, status = 0, @@ -127,8 +144,10 @@ namespace Tnb.ProductionMgr material_id = item.ContainsKey("material_id") ? item["material_id"] : "", material_code = item.ContainsKey("material_code") ? item["material_code"] : "", unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "", - code_batch = item.ContainsKey("batch") ? item["batch"] : "", - barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "", + // code_batch = item.ContainsKey("batch") ? item["batch"] : "", + // barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "", + barcode = item.ContainsKey("barcode") ? item["barcode"] : "", + code_batch = item.ContainsKey("barcode") ? item["barcode"]+"0001" : "", quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), }); } @@ -166,7 +185,7 @@ namespace Tnb.ProductionMgr material_id = item.ContainsKey("material_id") ? item["material_id"] : "", material_code = item.ContainsKey("material_code") ? item["material_code"] : "", unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "", - code_batch = item.ContainsKey("batch") ? item["batch"] : "", + code_batch = item.ContainsKey("barcode") ? item["barcode"]+"0001" : "", pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), }); @@ -175,8 +194,10 @@ namespace Tnb.ProductionMgr material_id = item.ContainsKey("material_id") ? item["material_id"] : "", material_code = item.ContainsKey("material_code") ? item["material_code"] : "", unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "", - code_batch = item.ContainsKey("batch") ? item["batch"] : "", - barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "", + // code_batch = item.ContainsKey("batch") ? item["batch"] : "", + // barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "", + barcode = item.ContainsKey("barcode") ? item["barcode"] : "", + code_batch = item.ContainsKey("barcode") ? item["barcode"]+"0001" : "", codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), }); } @@ -188,7 +209,7 @@ namespace Tnb.ProductionMgr var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header); Log.Information(sendResult); AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); - if (authResponse.code != 200) + if (authResponse.code != 200 || !authResponse.data.ObjToBool()) { throw Oops.Bah(authResponse.msg); } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdKittingOutService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdKittingOutService.cs index 5674bd65..e94f3915 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdKittingOutService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdKittingOutService.cs @@ -7,6 +7,8 @@ using JNPF.Extras.CollectiveOAuth.Models; using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; using JNPF.Logging; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Interfaces.Permission; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; using JNPF.VisualDev.Entitys; @@ -37,15 +39,21 @@ namespace Tnb.ProductionMgr private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; private readonly IUserManager _userManager; + private readonly IOrganizeService _organizeService; private readonly IBillRullService _billRullService; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); - public PrdKittingOutService(ISqlSugarRepository repository, IRunService runService, IBillRullService billRullService,IUserManager userManager,IVisualDevService visualDevService) + public PrdKittingOutService(ISqlSugarRepository repository, IRunService runService, + IBillRullService billRullService, + IUserManager userManager, + IOrganizeService organizeService, + IVisualDevService visualDevService) { _runService = runService; _visualDevService = visualDevService; _repository = repository; _userManager = userManager; + _organizeService = organizeService; _billRullService = billRullService; // OverideFuncs.CreateAsync = Create; } @@ -161,7 +169,9 @@ namespace Tnb.ProductionMgr try { var db = _repository.AsSugarClient(); - + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(kittingOutInput.workstation_id, DictConst.RegionCategoryWorklineCode); + kittingOutInput.workline_id = workline?.Id ?? ""; + List input = new List(); input.Add(new MESKittingOutStkInput() { diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index b956c738..ed200e3d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -8,6 +8,8 @@ using JNPF.Extras.CollectiveOAuth.Models; using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; using JNPF.Logging; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Interfaces.Permission; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; @@ -38,17 +40,20 @@ namespace Tnb.ProductionMgr { private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; + private readonly IOrganizeService _organizeService; private readonly IBillRullService _billRullService; public PrdMaterialReceiptService( ISqlSugarRepository repository, IBillRullService billRullService, + IOrganizeService organizeService, IUserManager userManager ) { _repository = repository; _userManager = userManager; + _organizeService = organizeService; _billRullService = billRullService; } @@ -148,6 +153,9 @@ namespace Tnb.ProductionMgr .ToListAsync(); string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE); + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorklineCode); + OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorkshopCode); + prdMaterialReceiptH = new PrdMaterialReceiptH() { code = code, @@ -155,9 +163,9 @@ namespace Tnb.ProductionMgr mo_task_id = input.mo_task_id, process_id = input.process_id, equip_id = input.equip_id, - workshop_id = input.workshop_id, + workshop_id = workshop?.Id ?? "", carry_id = input.carry_id, - workline_id = input.workline_id, + workline_id = workline?.Id ?? "", carry_code = input.carry_code, remark = input.remark, mbom_process_id = input.mbom_process_id, @@ -186,9 +194,9 @@ namespace Tnb.ProductionMgr member_carry_id = item["member_carry_id"]?.ToString(), member_carry_code = item["member_carry_code"]?.ToString(), feeding_num = 0, - supplier_id = item["supplier_id"]?.ToString(), - instock_time = (DateTime)item["instock_time"], - check_conclusion = item["check_conclusion"]?.ToString() + supplier_id = item.ContainsKey("supplier_id") ? item["supplier_id"]?.ToString() : "", + instock_time = item.ContainsKey("instock_time") ? (DateTime)item["instock_time"] : DateTime.Now, + check_conclusion = item.ContainsKey("check_conclusion") ? item["check_conclusion"]?.ToString() : "", }); } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 4f4b9344..9c7ca149 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -888,8 +888,8 @@ namespace Tnb.ProductionMgr .Where((a, b) => a.barcode == barcode).SumAsync((a, b) => b.num); output.list[0].material_name = basMaterial.name; output.list[0].material_standard = basMaterial.material_standard; - output.list[0].supplier_name = basSupplier.supplier_name; - output.list[0].unit_name = unit.FullName; + output.list[0].supplier_name = basSupplier?.supplier_name ?? ""; + output.list[0].unit_name = unit?.FullName ?? ""; return output.list[0]; } @@ -913,11 +913,11 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c) => b.feeding_id == c.id) .Where(a => a.barcode == barcode) .Select((a, b, c) => c.mo_task_id).ToListAsync(); - - return await _db.Queryable() + + var result = await _db.Queryable() .LeftJoin((a, b) => a.mo_id == b.id) - .LeftJoin((a,b,c)=>a.material_id==c.id) - .Where((a,b,c)=>ids.Contains(a.id)) + .LeftJoin((a, b, c) => a.material_id == c.id) + .Where((a, b, c) => ids.Contains(a.id)) .Select((a, b, c) => new PrdMoReverseFromFeedingOutput { mo_task_id = a.id, @@ -927,22 +927,28 @@ namespace Tnb.ProductionMgr material_name = c.name, material_standard = c.material_standard, children = SqlFunc.Subqueryable() - .LeftJoin((x,y)=>x.feeding_id==y.id) - .LeftJoin((x,y,z)=>y.create_id==z.Id) - .LeftJoin((x,y,z,org)=>y.station_id==org.Id) - .LeftJoin((x,y,z,org,process)=>y.process_id==process.id) - .LeftJoin((x,y,z,org,process,mp)=>x.material_receipt_detail_id==mp.id) - .Where((x,y,z)=>y.mo_task_id==a.id).ToList((x,y,z,org,process,mp)=>new PrdMoReverseFromFeedingDetailOutput - { - feeding_detail_id = x.id, - feeding_time = y.create_time==null ? "" : y.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), - num = x.num, - check_conclusion = mp.check_conclusion, - feeding_name = z.RealName, - station_name = org.FullName, - process_name = process.process_name - }), + .LeftJoin((x, y) => x.feeding_id == y.id) + .LeftJoin((x, y, z) => y.create_id == z.Id) + .LeftJoin((x, y, z, org) => y.station_id == org.Id) + .LeftJoin((x, y, z, org, process) => y.process_id == process.id) + .LeftJoin((x, y, z, org, process, mp) => + x.material_receipt_detail_id == mp.id) + .Where((x, y, z) => y.mo_task_id == a.id).ToList((x, y, z, org, process, mp) => + new PrdMoReverseFromFeedingDetailOutput + { + feeding_detail_id = x.id, + feeding_time = y.create_time == null + ? "" + : y.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), + num = x.num, + check_conclusion = mp.check_conclusion, + feeding_name = z.RealName, + station_name = org.FullName, + process_name = process.process_name + }), }).ToListAsync(); + return result; + // return PageResult.SqlSugarPageResult(result); } /// diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs index 91be4166..fef2d924 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -65,7 +65,8 @@ namespace Tnb.ProductionMgr BasLocation location = await db.Queryable().SingleAsync(x => x.id == locationId); input.outstock.bill_type = visualDevModelDataCrInput.data.ContainsKey("bill_type") ? visualDevModelDataCrInput.data["bill_type"].ToString() : ""; - input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now; + // input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now; + input.outstock.bill_date = DateTime.Now; input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId; input.outstock.warehouse_id = visualDevModelDataCrInput.data.ContainsKey("warehouse_id") ? visualDevModelDataCrInput.data["warehouse_id"].ToString() : ""; input.outstock.create_id = _userManager.UserId;