打印修改

usertest
cjy 4 months ago
parent 58405de358
commit 83b4a34a70

@ -116,6 +116,45 @@ public class RequestHelper
}
}
/// <summary>
/// http post请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="parameter">入参</param>
/// <param name="token"></param>
/// <param name="headers">头信息</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
/// , string token ="", Dictionary<string, string> headers = null
public static async Task<string> PostJosnAsyncNoHeaders(string url, string parameter)
{
using (var client = new HttpClient())
{
//var data = new StringContent("param1=value1&param2=value2", Encoding.UTF8, "application/x-www-form-urlencoded");
var data = new StringContent(parameter, Encoding.UTF8, "application/json");
//_logger.LogWarning($"data:{data.ToJsonString()}parameter{parameter}");
// 添加header参数
//client.DefaultRequestHeaders.Add("Authorization", "Bearer your_token_here");
//foreach (var header in headers)
//{
// client.DefaultRequestHeaders.Add(header.Key, header.Value);
//}
//_logger.LogWarning($"header:{client.DefaultRequestHeaders.ToJsonString()}");
try
{
var response = await client.PostAsync(url, data);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
return responseBody;
}
catch (HttpRequestException e)
{
throw new Exception(e.Message);
}
}
}
/// <summary>
/// http异步请求
/// </summary>
/// <param name="url">url</param>

@ -72,6 +72,6 @@ namespace DS.WMS.Core.Sys.Interface
/// 打印模板列表
/// </summary>
/// <returns></returns>
public Task<DataResult<List<SysPrintTemplateRes>>> GetOpenPrintTemplateList(string id);
public Task<DataResult<List<SysPrintTemplateRes>>> GetOpenPrintTemplateList(PageRequest req);
}
}

@ -156,12 +156,14 @@ namespace DS.WMS.Core.Sys.Method
return await Task.FromResult(DataResult<List<SysPrintModuleRes>>.Success(data));
}
public async Task<DataResult<List<SysPrintTemplateRes>>> GetOpenPrintTemplateList(string id)
public async Task<DataResult<List<SysPrintTemplateRes>>> GetOpenPrintTemplateList(PageRequest req)
{
var data = await db.Queryable<SysPrintTemplate>().Where(x => x.Disable == false && x.ModuleId == long.Parse(id))
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(req.QueryCondition);
var data = await db.Queryable<SysPrintTemplate>().Where(x => x.Disable == false)
.Select<SysPrintTemplateRes>()
.ToListAsync();
return await Task.FromResult(DataResult<List<SysPrintTemplateRes>>.Success(data));
.Where(whereList).ToQueryPageAsync(req.PageCondition); ;
return data;
}
}
}

@ -146,11 +146,11 @@ namespace DS.WMS.MainApi.Controllers
/// 获取打印模板列表
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
[Route("GetOpenPrintTemplateList")]
public async Task<DataResult<List<SysPrintTemplateRes>>> GetOpenPrintTemplateList([FromQuery]string id)
public async Task<DataResult<List<SysPrintTemplateRes>>> GetOpenPrintTemplateList([FromBody]PageRequest req)
{
return await _invokeService.GetOpenPrintTemplateList(id);
return await _invokeService.GetOpenPrintTemplateList(req);
}
/// <summary>
/// 获取Json本地打印信息
@ -166,7 +166,7 @@ namespace DS.WMS.MainApi.Controllers
if (url.IsNull())
return await Task.FromResult(DataResult<string>.Failed("未配置本地打印地址"));
var res = await RequestHelper.PostAsyncNoHeaders(url, req.ToJson());
var res = await RequestHelper.PostJosnAsyncNoHeaders(url, req.ToJson());
var result = JsonConvert.DeserializeObject<DataResult<string>>(res);
if (result.Succeeded)
{

Loading…
Cancel
Save