From 48208de17388eb6771f2991f3004bcd17a9372d9 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 17:32:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=A2=86=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WebApiConst.cs | 3 + .../Entity/PrdOutstockD.cs | 57 +++++++++ .../Entity/PrdOutstockH.cs | 72 +++++++++++ .../IPrdOutstockService.cs | 10 ++ .../Tnb.ProductionMgr/PrdOutstockService.cs | 115 ++++++++++++++++++ 5 files changed, 257 insertions(+) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs index c3312e59..bc6ff7f8 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs @@ -9,6 +9,9 @@ namespace Tnb.BasicData //载具签收接口 public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign"; + + //生产出库接口 + public const string MES_CREATE_OUTSTOCK = "/api/wms/wms-out-stock/mes-create-outstock"; #endregion diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs new file mode 100644 index 00000000..960834c6 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs @@ -0,0 +1,57 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// mes生产领料子表 +/// +[SugarTable("prd_outstock_d")] +public partial class PrdOutstockD : BaseEntity +{ + public PrdOutstockD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 物料id + /// + public string? material_id { get; set; } + + /// + /// 物料编号 + /// + public string? material_code { get; set; } + + /// + /// 单位id + /// + public string? unit_id { get; set; } + + /// + /// 出库需求数量 + /// + public string? pr_qty { get; set; } + + /// + /// 来源单据id + /// + public string? source_id { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 生产领料主表id + /// + public string? outstock_id { get; set; } + + /// + /// 物料名称 + /// + public string? material_name { get; set; } + +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs new file mode 100644 index 00000000..8e07b8db --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs @@ -0,0 +1,72 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// mes生产领料主表 +/// +[SugarTable("prd_outstock_h")] +public partial class PrdOutstockH : BaseEntity +{ + public PrdOutstockH() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 出库单创建日期 + /// + public string? bill_date { get; set; } + + /// + /// 单据类型 + /// + public string? bill_type { get; set; } + + /// + /// 发料仓库id + /// + public string? warehouse_id { get; set; } + + /// + /// 目标库位编号 + /// + public string? location_code { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 单据编号 + /// + public string? bill_code { get; set; } + + /// + /// 发料工位 + /// + public string? workstation { get; set; } + + /// + /// 所属产线 + /// + public string? workline { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs new file mode 100644 index 00000000..3d8bed0f --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs @@ -0,0 +1,10 @@ +namespace Tnb.ProductionMgr.Interfaces +{ + /// + /// 生产领料服务 + /// + public interface IPrdOutstockService + { + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs new file mode 100644 index 00000000..87cd0810 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -0,0 +1,115 @@ +using JNPF; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; +using JNPF.Extras.CollectiveOAuth.Utils; +using JNPF.FriendlyException; +using JNPF.Logging; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using SqlSugar; +using Tnb.BasicData; +using Tnb.BasicData.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Interfaces; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; + +namespace Tnb.ProductionMgr +{ + /// + /// 生产领料 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class PrdOutstockService : IOverideVisualDevService, IPrdOutstockService, IDynamicApiController, ITransient + { + private const string ModuleId = "27542506559765"; + private readonly ISqlSugarRepository _repository; + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private readonly IDictionaryDataService _dictionaryDataService; + private readonly IUserManager _userManager; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + + public PrdOutstockService(ISqlSugarRepository repository, IRunService runService, IUserManager userManager,IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + _dictionaryDataService = dictionaryDataService; + _repository = repository; + _userManager = userManager; + OverideFuncs.CreateAsync = Create; + } + + private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput) + { + try + { + var db = _repository.AsSugarClient(); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, visualDevModelDataCrInput); + + + MESCreateOutstockInput input = new MESCreateOutstockInput(); + input.outstock = new MESWmsOutstockHInput(); + input.outstockDs = new List(); + + string locationId = visualDevModelDataCrInput.data.ContainsKey("location_id") ? visualDevModelDataCrInput.data["location_id"].ToString() : ""; + 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.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; + input.outstock.location_code = location?.location_code ?? ""; + + // foreach (var item in (JArray)visualDevModelDataCrInput.data["tablefield107"]) + // { + // input.outstockDs.Add(new MESWmsOutstockDInput() + // { + // material_id = item.Value("material_id"), + // material_code = item.Value("material_code"), + // unit_id = item.Value("unit_id"), + // pr_qty = item.Value("pr_qty"), + // code_batch = item.Value("code_batch"), + // source_id = item.Value("source_id"), + // }); + // } + + input.outstockDs = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(visualDevModelDataCrInput.data["tablefield107"])); + 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_OUTSTOCK,JsonConvert.SerializeObject(input),header); + Log.Information(sendResult); + + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200) + { + throw Oops.Bah(authResponse.msg); + } + return await Task.FromResult(true); + } + catch (Exception e) + { + Console.WriteLine(e); + Log.Error(e.Message); + throw Oops.Bah(e.Message); + } + + } + } +} \ No newline at end of file