天益报表导出功能
This commit is contained in:
@@ -34,7 +34,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost, AllowAnonymous]
|
||||||
public async Task<dynamic> CarryStock(CarryStockInput input)
|
public async Task<dynamic> CarryStock(CarryStockInput input)
|
||||||
{
|
{
|
||||||
var warehouse_id = "";
|
var warehouse_id = "";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using JNPF.Common.Security;
|
|||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
@@ -32,7 +33,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost, AllowAnonymous]
|
||||||
public async Task<dynamic> MaterialStock(VisualDevModelListQueryInput input)
|
public async Task<dynamic> MaterialStock(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var supplier_code = "";
|
var supplier_code = "";
|
||||||
@@ -164,7 +165,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost, AllowAnonymous]
|
||||||
public async Task<dynamic> OutinStockDetail(VisualDevModelListQueryInput input)
|
public async Task<dynamic> OutinStockDetail(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var code_batch = "";
|
var code_batch = "";
|
||||||
|
|||||||
@@ -35,4 +35,19 @@ public class VisualDevModelListQueryInput : PageInputBase
|
|||||||
/// 工序编码
|
/// 工序编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string process_code { get; set; }
|
public string process_code { get; set; }
|
||||||
|
|
||||||
|
#region 天益项目添加的定制代码
|
||||||
|
/// <summary>
|
||||||
|
/// 数据查询api(用于报表导出)
|
||||||
|
/// </summary>
|
||||||
|
public string customDataApi { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据查询字段列名对应关系(用于报表导出)
|
||||||
|
/// </summary>
|
||||||
|
public string fieldChnRelation { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using JNPF.Common.Configuration;
|
using System.Dynamic;
|
||||||
|
using JNPF.Common.Configuration;
|
||||||
using JNPF.Common.Const;
|
using JNPF.Common.Const;
|
||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Core.Manager.Files;
|
using JNPF.Common.Core.Manager.Files;
|
||||||
@@ -36,6 +37,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.Common.Utils;
|
||||||
|
|
||||||
namespace JNPF.VisualDev
|
namespace JNPF.VisualDev
|
||||||
{
|
{
|
||||||
@@ -450,6 +452,69 @@ namespace JNPF.VisualDev
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 天益项目添加的定制代码
|
||||||
|
/// <summary>
|
||||||
|
/// (天益项目添加的定制代码) 报表导出
|
||||||
|
/// </summary>
|
||||||
|
async Task<dynamic> 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<string, string> fieldChnRelation = new Dictionary<string, string>();
|
||||||
|
foreach (JProperty jProperty in fieldChnRelationObj.Properties())
|
||||||
|
fieldChnRelation.Add(jProperty.Name, jProperty.Value.ToString());
|
||||||
|
// 拼列名
|
||||||
|
List<FieldsModel> AllFieldsModel = new List<FieldsModel>();
|
||||||
|
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<Dictionary<string, object>>();
|
||||||
|
foreach (JObject row in respBodyList)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();
|
||||||
|
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
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导出.
|
/// 导出.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -459,6 +524,12 @@ namespace JNPF.VisualDev
|
|||||||
[HttpPost("{modelId}/Actions/Export")]
|
[HttpPost("{modelId}/Actions/Export")]
|
||||||
public async Task<dynamic> Export(string modelId, [FromBody] VisualDevModelListQueryInput input)
|
public async Task<dynamic> Export(string modelId, [FromBody] VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
|
#region 天益项目添加的定制代码
|
||||||
|
if (!string.IsNullOrEmpty(input.customDataApi))
|
||||||
|
return await ReportExcel(input);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
|
||||||
if (input.dataType == "1") input.pageSize = 99999999;
|
if (input.dataType == "1") input.pageSize = 99999999;
|
||||||
PageResult<Dictionary<string, object>>? pageList = await _runService.GetListResult(templateEntity, input);
|
PageResult<Dictionary<string, object>>? pageList = await _runService.GetListResult(templateEntity, input);
|
||||||
|
|||||||
Reference in New Issue
Block a user