diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs index 0dc9458e..ad4010f8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs @@ -34,7 +34,7 @@ namespace Tnb.WarehouseMgr _userManager = userManager; } - [HttpPost] + [HttpPost, AllowAnonymous] public async Task CarryStock(CarryStockInput input) { var warehouse_id = ""; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs index 5cda53c2..7016f16f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs @@ -5,6 +5,7 @@ using JNPF.Common.Security; using JNPF.VisualDev; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; using Mapster; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using SqlSugar; @@ -32,7 +33,7 @@ namespace Tnb.WarehouseMgr } - [HttpPost] + [HttpPost, AllowAnonymous] public async Task MaterialStock(VisualDevModelListQueryInput input) { var supplier_code = ""; @@ -164,7 +165,7 @@ namespace Tnb.WarehouseMgr } - [HttpPost] + [HttpPost, AllowAnonymous] public async Task OutinStockDetail(VisualDevModelListQueryInput input) { var code_batch = ""; diff --git a/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs b/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs index 5463d159..f7c6630e 100644 --- a/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs +++ b/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs @@ -35,4 +35,19 @@ public class VisualDevModelListQueryInput : PageInputBase /// 工序编码 /// public string process_code { get; set; } + + #region 天益项目添加的定制代码 + /// + /// 数据查询api(用于报表导出) + /// + public string customDataApi { get; set; } + + /// + /// 数据查询字段列名对应关系(用于报表导出) + /// + public string fieldChnRelation { get; set; } + #endregion + + + } \ No newline at end of file diff --git a/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs b/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs index c80c4268..180ec555 100644 --- a/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs +++ b/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs @@ -1,4 +1,5 @@ -using JNPF.Common.Configuration; +using System.Dynamic; +using JNPF.Common.Configuration; using JNPF.Common.Const; using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager.Files; @@ -36,6 +37,7 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SqlSugar; +using Tnb.Common.Utils; namespace JNPF.VisualDev { @@ -450,6 +452,69 @@ namespace JNPF.VisualDev } } + + #region 天益项目添加的定制代码 + /// + /// (天益项目添加的定制代码) 报表导出 + /// + async Task ReportExcel(VisualDevModelListQueryInput input) + { + // 全部页面导出 限制条数 + if (input.dataType == "1") input.pageSize = 9999; + dynamic reqBody = new ExpandoObject(); + CancellationTokenSource Ctu = new(); + reqBody.currentPage = input.currentPage; + reqBody.pageSize = input.pageSize; + reqBody.sort = input.sort; + reqBody.sidx = input.sidx; + reqBody.queryJson = input.queryJson; + reqBody.menuId = ""; + reqBody.superQueryJson = ""; + string respBody = HttpClientHelper.PostStreamAsync($"http://localhost:9231{input.customDataApi}", reqBody, Ctu.Token).Result; + JObject respBodyObj = JObject.Parse(respBody.ToString()); + JObject respBodyData = JObject.Parse(respBodyObj["data"].ToString()); + JArray respBodyList = JArray.Parse(respBodyData["list"].ToString()); + if (respBodyList.Count == 0) + return null; + JObject fieldChnRelationObj = JObject.Parse(input.fieldChnRelation); + // 字段列名对应关系 + Dictionary fieldChnRelation = new Dictionary(); + foreach (JProperty jProperty in fieldChnRelationObj.Properties()) + fieldChnRelation.Add(jProperty.Name, jProperty.Value.ToString()); + // 拼列名 + List AllFieldsModel = new List(); + JObject firstRow = respBodyList[0] as JObject; + foreach (JProperty jProperty in firstRow.Properties()) + { + if (!fieldChnRelation.ContainsKey(jProperty.Name)) + continue; + FieldsModel fieldsModel = new FieldsModel(); + ConfigModel configModel = new ConfigModel(); + configModel.label = fieldChnRelation[jProperty.Name]; + fieldsModel.__config__ = configModel; + fieldsModel.__vModel__ = jProperty.Name; + AllFieldsModel.Add(fieldsModel); + } + // 拼值 + var resultList = new List>(); + foreach (JObject row in respBodyList) + { + Dictionary keyValuePairs = new Dictionary(); + foreach (JProperty jProperty in firstRow.Properties()) + { + keyValuePairs.Add(jProperty.Name, jProperty.Value); + } + resultList.Add(keyValuePairs); + } + + var excelName = string.Format("表单信息{0}", DateTime.Now.ToString("yyyyMMddHHmmssf")); + _cacheManager.Set(excelName + ".xls", string.Empty); + + + return await ExcelCreateModel(AllFieldsModel, resultList, input.selectKey, excelName); + } + #endregion + /// /// 导出. /// @@ -459,6 +524,12 @@ namespace JNPF.VisualDev [HttpPost("{modelId}/Actions/Export")] public async Task Export(string modelId, [FromBody] VisualDevModelListQueryInput input) { + #region 天益项目添加的定制代码 + if (!string.IsNullOrEmpty(input.customDataApi)) + return await ReportExcel(input); + #endregion + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); if (input.dataType == "1") input.pageSize = 99999999; PageResult>? pageList = await _runService.GetListResult(templateEntity, input);