diff --git a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs new file mode 100644 index 00000000..c3312e59 --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs @@ -0,0 +1,16 @@ +namespace Tnb.BasicData +{ + public static class WebApiConst + { + #region wms + + //mes生产入库接口 + public const string MES_CREATE_INSTOCK = "/api/wms/wms-in-stock/mes-create-instock"; + + //载具签收接口 + public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign"; + + #endregion + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs new file mode 100644 index 00000000..485e4233 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs @@ -0,0 +1,34 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class PrdInstockInput + { + + /// + /// 单据类型 + /// + public string bill_type { get; set; } = string.Empty; + + + /// + /// 载具编号 + /// + public string carry_code { get; set; } = string.Empty; + + /// + /// 起始库位编号 + /// + public string location_code { get; set; } = string.Empty; + + + /// + /// 检验(0-未检 1-已检) + /// + public int is_check { get; set; } + + /// + /// 子表明细 + /// + public List> details { get; set; } + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs index 7bff1e66..04c6db66 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs @@ -37,7 +37,7 @@ public partial class PrdInstockD : BaseEntity /// /// 数量 /// - public string quantity { get; set; } = string.Empty; + public int quantity { get; set; } /// /// 批次 @@ -49,4 +49,9 @@ public partial class PrdInstockD : BaseEntity /// public string barcode { get; set; } = string.Empty; + /// + /// 生产提报id + /// + public string report_id { get; set; } = string.Empty; + } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs index 9616f5d2..390c5651 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs @@ -38,16 +38,12 @@ public partial class PrdInstockH : BaseEntity /// 起始库位编号 /// public string location_code { get; set; } = string.Empty; - - /// - /// 来源单据ID - /// - public string source_id { get; set; } = string.Empty; + /// /// 检验(0-未检 1-已检) /// - public string is_check { get; set; } = string.Empty; + public int is_check { get; set; } /// /// 创建用户 diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs index 4d48963a..5e6b5e87 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs @@ -1,3 +1,5 @@ +using Tnb.ProductionMgr.Entities.Dto; + namespace Tnb.ProductionMgr.Interfaces { /// @@ -6,6 +8,13 @@ namespace Tnb.ProductionMgr.Interfaces public interface IPrdInstockService { + /// + /// 生产入库报错 + /// + /// + /// + public Task SaveData(PrdInstockInput input); + /// /// 入库申请同步 /// diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 9e5a8039..2a0d6aec 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -1,13 +1,16 @@ +using JNPF; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; using Microsoft.ClearScript.Util.Web; +using Newtonsoft.Json; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.ProductionMgr.Entities; @@ -16,6 +19,7 @@ using Tnb.ProductionMgr.Interfaces; using Tnb.ProductionMgr.Entities.Consts; using Tnb.WarehouseMgr; using Tnb.WarehouseMgr.Entities; +using Tnb.BasicData; namespace Tnb.ProductionMgr { @@ -29,20 +33,20 @@ namespace Tnb.ProductionMgr private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; private readonly IBillRullService _billRullService; - private readonly WmsSignForDeliveryService _wmsSignForDeliveryService; + // private readonly WmsSignForDeliveryService _wmsSignForDeliveryService; public PrdFeedingService( ISqlSugarRepository repository, IBillRullService billRullService, - WmsSignForDeliveryService wmsSignForDeliveryService, + // WmsSignForDeliveryService wmsSignForDeliveryService, IUserManager userManager ) { _repository = repository; _userManager = userManager; - _wmsSignForDeliveryService = _wmsSignForDeliveryService; + // _wmsSignForDeliveryService = _wmsSignForDeliveryService; _billRullService = billRullService; } @@ -143,12 +147,12 @@ namespace Tnb.ProductionMgr if (result.IsSuccess) { //签收后调用载具签收接口 - await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() - { - org_id = _userManager.GetUserInfo().Result.organizeId, - create_id = _userManager.UserId, - carry_code = input.carry_code ?? "", - }); + // await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + // { + // org_id = _userManager.GetUserInfo().Result.organizeId, + // create_id = _userManager.UserId, + // carry_code = input.carry_code ?? "", + // }); } if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); @@ -257,12 +261,26 @@ namespace Tnb.ProductionMgr if (result.IsSuccess) { //签收后调用载具签收接口 - await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + // await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + // { + // org_id = _userManager.GetUserInfo().Result.organizeId, + // create_id = _userManager.UserId, + // carry_code = input.carry_code ?? "", + // }); + + var mesCarrySignInput = new MESCarrySignInput() { org_id = _userManager.GetUserInfo().Result.organizeId, create_id = _userManager.UserId, carry_code = input.carry_code ?? "", - }); + }; + + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new Dictionary() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header); } if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 5e8a2a63..4f2ededd 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -1,12 +1,24 @@ +using JNPF; using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Utils; +using JNPF.FriendlyException; +using JNPF.RemoteRequest; using JNPF.Systems.Interfaces.System; +using Mapster; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using SqlSugar; +using Tnb.BasicData.Entities; using Tnb.ProductionMgr.Entities; using Tnb.ProductionMgr.Entities.Dto; using Tnb.ProductionMgr.Interfaces; +using Tnb.WarehouseMgr; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; +using Tnb.BasicData; namespace Tnb.ProductionMgr { @@ -19,18 +31,112 @@ namespace Tnb.ProductionMgr { private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; - private readonly IBillRullService _billRullService; public PrdInstockService( ISqlSugarRepository repository, - IBillRullService billRullService, IUserManager userManager ) { _repository = repository; _userManager = userManager; - _billRullService = billRullService; + } + + [HttpPost] + public async Task SaveData(PrdInstockInput input) + { + var db = _repository.AsSugarClient(); + var location = await db.Queryable().FirstAsync(x => x.location_code == input.location_code); + PrdInstockH prdInstockH = null; + DbResult result = await db.Ado.UseTranAsync(async () => + { + prdInstockH = new PrdInstockH() + { + bill_type = input.bill_type, + bill_date = DateTime.Now, + create_id = _userManager.UserId, + location_code = input.location_code, + carry_code = input.carry_code, + is_check = input.is_check, + org_id = _userManager.GetUserInfo().Result.organizeId, + warehouse_id = location?.wh_id, + status = 0, + }; + + List prdInstockDs = new List() { }; + foreach (var item in input.details) + { + prdInstockDs.Add(new PrdInstockD() + { + instock_id = prdInstockH.id, + report_id = item.ContainsKey("report_id") ? item["report_id"] : "", + 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" : "", + quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), + }); + } + + await _repository.InsertAsync(prdInstockH); + + if (prdInstockDs.Count > 0) + { + await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + } + + }); + + if (result.IsSuccess) + { + MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput(); + mesCreateInstockInput.instock = new MESWmsInstockHInput() + { + org_id = _userManager.GetUserInfo().Result.organizeId, + bill_date = DateTime.Now, + bill_type = input.bill_type, + warehouse_id = location?.wh_id, + source_id = prdInstockH.id, + create_id = _userManager.UserId, + carry_code = input.carry_code, + location_code = input.location_code, + is_check = input.is_check, + }; + mesCreateInstockInput.instockds = new List(); + mesCreateInstockInput.instockcodes = new List(); + foreach (var item in input.details) + { + mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput() + { + 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"] : "", + pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), + }); + + mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput() + { + 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" : "", + codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), + }); + } + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new Dictionary() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header); + Console.WriteLine(sendResult); + } + + if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); + return result.IsSuccess ? "保存成功" : result.ErrorMessage; } /// diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj index 832c4f03..6316cd83 100644 --- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj +++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj @@ -15,7 +15,6 @@ -