Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -7,7 +7,7 @@ using JNPF.Common.Enums;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Dto.Outputs
|
||||
{
|
||||
public class DataResult
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 响应状态码
|
||||
@@ -44,6 +44,27 @@ public partial class WmsDistaskH : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? end_floor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起始点位ID
|
||||
/// </summary>
|
||||
public string startpoint_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 起始点位编号
|
||||
/// </summary>
|
||||
public string startpoint_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 终止点位ID
|
||||
/// </summary>
|
||||
public string endpoint_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 终止点位编号
|
||||
/// </summary>
|
||||
public string endpoint_code { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
/// </summary>
|
||||
|
||||
@@ -44,6 +44,26 @@ public partial class WmsPretaskH : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? end_floor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起始点位ID
|
||||
/// </summary>
|
||||
public string startpoint_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 起始点位编号
|
||||
/// </summary>
|
||||
public string startpoint_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 终止点位ID
|
||||
/// </summary>
|
||||
public string endpoint_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 终止点位编号
|
||||
/// </summary>
|
||||
public string endpoint_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
/// </summary>
|
||||
|
||||
@@ -90,9 +90,9 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
protected Task<DataResult> ToApiResult()
|
||||
protected Task<Result> ToApiResult()
|
||||
{
|
||||
DataResult result = new();
|
||||
Result result = new();
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
@@ -101,9 +101,9 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
protected Task<DataResult> ToApiResult(HttpStatusCode statusCode, object data)
|
||||
protected Task<Result> ToApiResult(HttpStatusCode statusCode, object data)
|
||||
{
|
||||
DataResult result = new()
|
||||
Result result = new()
|
||||
{
|
||||
code = statusCode,
|
||||
data = data
|
||||
@@ -118,9 +118,9 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
protected Task<DataResult> ToApiResult(object data)
|
||||
protected Task<Result> ToApiResult(object data)
|
||||
{
|
||||
DataResult result = new()
|
||||
Result result = new()
|
||||
{
|
||||
data = data
|
||||
};
|
||||
@@ -131,9 +131,9 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
protected Task<DataResult> ToApiResult(HttpStatusCode statusCode, string msg)
|
||||
protected Task<Result> ToApiResult(HttpStatusCode statusCode, string msg)
|
||||
{
|
||||
DataResult result = new()
|
||||
Result result = new()
|
||||
{
|
||||
code = statusCode,
|
||||
msg = msg
|
||||
@@ -145,9 +145,9 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
protected Task<DataResult> ToApiResult(HttpStatusCode statusCode, string msg, object data)
|
||||
protected Task<Result> ToApiResult(HttpStatusCode statusCode, string msg, object data)
|
||||
{
|
||||
DataResult result = new()
|
||||
Result result = new()
|
||||
{
|
||||
code = statusCode,
|
||||
msg = msg,
|
||||
|
||||
28
WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs
Normal file
28
WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Senparc.NeuChar.ApiHandlers;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// Wms设备接口提供程序服务类
|
||||
/// </summary>
|
||||
|
||||
public class DeviceProviderService : BaseWareHouseService
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建任务链
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> CreateTaskChain()
|
||||
{
|
||||
return await Task.FromResult<Result>(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -698,7 +698,7 @@ namespace Tnb.WarehouseMgr
|
||||
List<WmsPointH> results = new() { startObj };
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
points.Where(it => result.Contains(it.id));
|
||||
//points.Where(it => result.Contains(it.id));
|
||||
foreach (var i in result)
|
||||
{
|
||||
WmsPointH? point = points?.Find(x => x.id == i);
|
||||
|
||||
@@ -109,6 +109,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID;
|
||||
|
||||
@@ -106,6 +106,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSMOOUTSTK_ID;
|
||||
|
||||
@@ -110,6 +110,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Tnb.WarehouseMgr
|
||||
//判断目标库位是否自动签收
|
||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||
//出库取起点,获取所有符合输入的载具规格的载具
|
||||
var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString()};
|
||||
var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString() };
|
||||
var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
||||
|
||||
// 判断最终目标库位是否可以放置当前载具
|
||||
@@ -128,6 +128,10 @@ namespace Tnb.WarehouseMgr
|
||||
endlocation_code = ePoint?.location_code!,
|
||||
start_floor = sPoint?.floor.ToString(),
|
||||
end_floor = ePoint?.floor.ToString(),
|
||||
startpoint_id = sPoint?.id!,
|
||||
startpoint_code = sPoint?.point_code!,
|
||||
endpoint_id = ePoint?.id!,
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
@@ -152,7 +156,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
}
|
||||
if(isOk)
|
||||
if (isOk)
|
||||
{
|
||||
GenPreTaskUpInput preTaskUpInput = new()
|
||||
{
|
||||
|
||||
@@ -108,6 +108,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSKITTINGINSTK_ID;
|
||||
|
||||
@@ -106,6 +106,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSOUTBALE_ID;
|
||||
|
||||
@@ -219,6 +219,10 @@ namespace Tnb.WarehouseMgr
|
||||
endlocation_code = ePoint?.location_code!,
|
||||
start_floor = sPoint?.floor.ToString(),
|
||||
end_floor = ePoint?.floor.ToString(),
|
||||
startpoint_id = sPoint?.id!,
|
||||
startpoint_code = sPoint?.point_code!,
|
||||
endpoint_id = ePoint?.id!,
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSOUTSTOCK_ID,
|
||||
|
||||
@@ -107,6 +107,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID;
|
||||
|
||||
@@ -102,6 +102,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSMOOUTSTK_ID;
|
||||
|
||||
@@ -137,6 +137,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService!.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID;
|
||||
|
||||
@@ -106,6 +106,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
|
||||
|
||||
@@ -116,6 +116,10 @@ namespace Tnb.WarehouseMgr
|
||||
endlocation_code = ePoint?.location_code!,
|
||||
start_floor = sPoint?.floor.ToString(),
|
||||
end_floor = ePoint?.floor.ToString(),
|
||||
startpoint_id = sPoint?.id!,
|
||||
startpoint_code = sPoint?.point_code!,
|
||||
endpoint_id = ePoint?.id!,
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
|
||||
@@ -120,6 +120,10 @@ namespace Tnb.WarehouseMgr
|
||||
endlocation_code = ePoint?.location_code ?? "",
|
||||
start_floor = sPoint?.floor.ToString(),
|
||||
end_floor = ePoint?.floor.ToString(),
|
||||
startpoint_id = sPoint?.id!,
|
||||
startpoint_code = sPoint?.point_code!,
|
||||
endpoint_id = ePoint?.id!,
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = input.data[nameof(WmsPretaskH.biz_type)]?.ToString() ?? "",
|
||||
|
||||
@@ -107,6 +107,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSINBALE_ID;
|
||||
|
||||
@@ -99,6 +99,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSOUTBALE_ID;
|
||||
|
||||
@@ -99,6 +99,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSTRANSFER_ID;
|
||||
|
||||
@@ -77,19 +77,18 @@ namespace Tnb.WarehouseMgr
|
||||
List<WmsCarryCode> carryCodes = new();
|
||||
List<string> carryIds = new();
|
||||
|
||||
|
||||
|
||||
foreach (var os in setSortingDList)
|
||||
{
|
||||
var OutStockStrategyInput = new OutStockStrategyQuery {
|
||||
carry_id = carryMat.carry_id,
|
||||
material_id = os.material_id,
|
||||
warehouse_id = os.warehouse_id,
|
||||
code_batch = os.code_batch,
|
||||
var OutStockStrategyInput = new OutStockStrategyQuery
|
||||
{
|
||||
carry_id = carryMat.carry_id,
|
||||
material_id = os.material_id,
|
||||
warehouse_id = os.warehouse_id,
|
||||
code_batch = os.code_batch,
|
||||
};
|
||||
var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
||||
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
||||
.Where((a, b) => outStkCarrys.Select(x=>x.id).Contains(b.carry_id))
|
||||
.Where((a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id))
|
||||
.Select<WmsCarryCode>()
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
@@ -99,6 +99,10 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSTRANSFER_ID;
|
||||
|
||||
@@ -191,6 +191,10 @@ namespace Tnb.WarehouseMgr
|
||||
endlocation_code = ePoint?.location_code!,
|
||||
start_floor = sPoint?.floor.ToString(),
|
||||
end_floor = ePoint?.floor.ToString(),
|
||||
startpoint_id = sPoint?.id!,
|
||||
startpoint_code = sPoint?.point_code!,
|
||||
endpoint_id = ePoint?.id!,
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = ko.biz_type,
|
||||
|
||||
244
common/Tnb.Common/Utils/HttpClientHelper.cs
Normal file
244
common/Tnb.Common/Utils/HttpClientHelper.cs
Normal file
@@ -0,0 +1,244 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Logging;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Tnb.Common.Utils
|
||||
{
|
||||
public class ApiException : Exception
|
||||
{
|
||||
public int StatusCode { get; set; }
|
||||
|
||||
public string Content { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Http请求帮助类
|
||||
/// added by ly on 20230801
|
||||
/// </summary>
|
||||
public class HttpClientHelper
|
||||
{
|
||||
private static readonly HttpClient HttpClient = new HttpClient();
|
||||
private static Dictionary<string, HttpClient> HttpClientDict = new Dictionary<string, HttpClient>(StringComparer.OrdinalIgnoreCase);
|
||||
public static string Url { get; private set; }
|
||||
|
||||
public static async Task<string> HttpPostAsync(string url, string clientKey, string postData = null, Dictionary<string, string> headers = null, string contentType = "application/json", int timeOut = 30)
|
||||
{
|
||||
using var client = HttpClientDict[clientKey];
|
||||
if (headers != null)
|
||||
{
|
||||
foreach (var header in headers)
|
||||
client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
||||
}
|
||||
using HttpContent httpContent = new StringContent(postData, Encoding.UTF8);
|
||||
if (contentType != null)
|
||||
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
|
||||
|
||||
var response = await client.PostAsync(url, httpContent);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发起POST异步请求
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="postData"></param>
|
||||
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
|
||||
/// <param name="headers">填充消息头</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> HttpPostAsync(string url, string postData = null, Dictionary<string, string> headers = null, string contentType = "application/json", int timeOut = 30)
|
||||
{
|
||||
postData ??= "";
|
||||
HttpResponseMessage response = null;
|
||||
HttpClient client = null;
|
||||
try
|
||||
{
|
||||
|
||||
if (client == null)
|
||||
client = new HttpClient();
|
||||
|
||||
//HttpClient.Timeout = new TimeSpan(0, 0, timeOut);
|
||||
if (headers != null)
|
||||
{
|
||||
foreach (var header in headers)
|
||||
client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
||||
}
|
||||
//var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
//request.Headers.Accept.Clear();
|
||||
//request.Headers.
|
||||
|
||||
|
||||
using HttpContent httpContent = new StringContent(postData, Encoding.UTF8);
|
||||
if (contentType != null)
|
||||
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
|
||||
|
||||
response = await client.PostAsync(url, httpContent);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
client = new HttpClient();
|
||||
}
|
||||
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
public static async Task<string> PostFormDataAsync(string url, Dictionary<string, string> pars)
|
||||
{
|
||||
var respJson = "";
|
||||
try
|
||||
{
|
||||
var content = new FormUrlEncodedContent(pars);
|
||||
var respBody = await HttpClient.PostAsync(url, content);
|
||||
respJson = await respBody.Content.ReadAsStringAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("调用PostFormDataAsync时出错", ex);
|
||||
}
|
||||
return respJson;
|
||||
}
|
||||
|
||||
|
||||
public static async Task<string> GetAsync(string url, Dictionary<string, string> headers = null, Dictionary<string, string> pars = null)
|
||||
{
|
||||
var reqUri = url;
|
||||
if (pars?.Count > 0)
|
||||
{
|
||||
reqUri = QueryHelpers.AddQueryString(url, pars);
|
||||
}
|
||||
if (headers?.Count > 0)
|
||||
{
|
||||
foreach (var (k, v) in headers)
|
||||
{
|
||||
HttpClient.DefaultRequestHeaders.Add(k, v);
|
||||
}
|
||||
}
|
||||
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
var respBody = await HttpClient.GetAsync(reqUri);
|
||||
var result = await respBody.Content.ReadAsStringAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static async Task PostStreamAsync(object content, CancellationToken cancellationToken)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Post, Url))
|
||||
using (var httpContent = CreateHttpContent(content))
|
||||
{
|
||||
request.Content = httpContent;
|
||||
|
||||
using (var response = await client
|
||||
.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken)
|
||||
.ConfigureAwait(false))
|
||||
{
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static HttpContent CreateHttpContent(object content)
|
||||
{
|
||||
HttpContent httpContent = null;
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
SerializeJsonIntoStream(content, ms);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
httpContent = new StreamContent(ms);
|
||||
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
}
|
||||
|
||||
return httpContent;
|
||||
}
|
||||
|
||||
|
||||
public static void SerializeJsonIntoStream(object value, Stream stream)
|
||||
{
|
||||
using (var sw = new StreamWriter(stream, new UTF8Encoding(false), 1024, true))
|
||||
using (var jtw = new JsonTextWriter(sw) { Formatting = Formatting.None })
|
||||
{
|
||||
var js = new JsonSerializer();
|
||||
js.Serialize(jtw, value);
|
||||
jtw.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static T DeserializeJsonFromStream<T>(Stream stream)
|
||||
{
|
||||
if (stream == null || stream.CanRead == false)
|
||||
return default(T);
|
||||
|
||||
using (var sr = new StreamReader(stream))
|
||||
using (var jtr = new JsonTextReader(sr))
|
||||
{
|
||||
var js = new JsonSerializer();
|
||||
var searchResult = js.Deserialize<T>(jtr);
|
||||
return searchResult;
|
||||
}
|
||||
}
|
||||
private static async Task<string> StreamToStringAsync(Stream stream)
|
||||
{
|
||||
string content = null;
|
||||
|
||||
if (stream != null)
|
||||
using (var sr = new StreamReader(stream))
|
||||
content = await sr.ReadToEndAsync();
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
private static async Task<List<T>> DeserializeFromStreamCallAsync<T>(CancellationToken cancellationToken)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, Url))
|
||||
using (var response = await client.SendAsync(request, cancellationToken))
|
||||
{
|
||||
var stream = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
return DeserializeJsonFromStream<List<T>>(stream);
|
||||
|
||||
var content = await StreamToStringAsync(stream);
|
||||
throw new ApiException
|
||||
{
|
||||
StatusCode = (int)response.StatusCode,
|
||||
Content = content
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<List<T>> DeserializeOptimizedFromStreamCallAsync<T>(CancellationToken cancellationToken)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, Url))
|
||||
using (var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken))
|
||||
{
|
||||
var stream = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
return DeserializeJsonFromStream<List<T>>(stream);
|
||||
|
||||
var content = await StreamToStringAsync(stream);
|
||||
throw new ApiException
|
||||
{
|
||||
StatusCode = (int)response.StatusCode,
|
||||
Content = content
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user