载具签收,生产入库

This commit is contained in:
2023-07-17 11:29:01 +08:00
parent 22cbcd83cd
commit 25c81366b6
8 changed files with 205 additions and 22 deletions

View File

@@ -0,0 +1,16 @@
namespace Tnb.BasicData
{
public static class WebApiConst
{
#region wms
//mes生产入库接口
public const string MES_CREATE_INSTOCK = "/api/wms/wms-in-stock/mes-create-instock";
//载具签收接口
public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign";
#endregion
}
}

View File

@@ -0,0 +1,34 @@
namespace Tnb.ProductionMgr.Entities.Dto
{
public class PrdInstockInput
{
/// <summary>
/// 单据类型
/// </summary>
public string bill_type { get; set; } = string.Empty;
/// <summary>
/// 载具编号
/// </summary>
public string carry_code { get; set; } = string.Empty;
/// <summary>
/// 起始库位编号
/// </summary>
public string location_code { get; set; } = string.Empty;
/// <summary>
/// 检验(0-未检 1-已检)
/// </summary>
public int is_check { get; set; }
/// <summary>
/// 子表明细
/// </summary>
public List<Dictionary<string,string>> details { get; set; }
}
}

View File

@@ -37,7 +37,7 @@ public partial class PrdInstockD : BaseEntity<string>
/// <summary>
/// 数量
/// </summary>
public string quantity { get; set; } = string.Empty;
public int quantity { get; set; }
/// <summary>
/// 批次
@@ -49,4 +49,9 @@ public partial class PrdInstockD : BaseEntity<string>
/// </summary>
public string barcode { get; set; } = string.Empty;
/// <summary>
/// 生产提报id
/// </summary>
public string report_id { get; set; } = string.Empty;
}

View File

@@ -38,16 +38,12 @@ public partial class PrdInstockH : BaseEntity<string>
/// 起始库位编号
/// </summary>
public string location_code { get; set; } = string.Empty;
/// <summary>
/// 来源单据ID
/// </summary>
public string source_id { get; set; } = string.Empty;
/// <summary>
/// 检验(0-未检 1-已检)
/// </summary>
public string is_check { get; set; } = string.Empty;
public int is_check { get; set; }
/// <summary>
/// 创建用户

View File

@@ -1,3 +1,5 @@
using Tnb.ProductionMgr.Entities.Dto;
namespace Tnb.ProductionMgr.Interfaces
{
/// <summary>
@@ -6,6 +8,13 @@ namespace Tnb.ProductionMgr.Interfaces
public interface IPrdInstockService
{
/// <summary>
/// 生产入库报错
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public Task<dynamic> SaveData(PrdInstockInput input);
/// <summary>
/// 入库申请同步
/// </summary>

View File

@@ -1,13 +1,16 @@
using JNPF;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.ProductionMgr.Entities;
@@ -16,6 +19,7 @@ using Tnb.ProductionMgr.Interfaces;
using Tnb.ProductionMgr.Entities.Consts;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities;
using Tnb.BasicData;
namespace Tnb.ProductionMgr
{
@@ -29,20 +33,20 @@ namespace Tnb.ProductionMgr
private readonly ISqlSugarRepository<PrdFeedingH> _repository;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
// private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
public PrdFeedingService(
ISqlSugarRepository<PrdFeedingH> repository,
IBillRullService billRullService,
WmsSignForDeliveryService wmsSignForDeliveryService,
// WmsSignForDeliveryService wmsSignForDeliveryService,
IUserManager userManager
)
{
_repository = repository;
_userManager = userManager;
_wmsSignForDeliveryService = _wmsSignForDeliveryService;
// _wmsSignForDeliveryService = _wmsSignForDeliveryService;
_billRullService = billRullService;
}
@@ -143,12 +147,12 @@ namespace Tnb.ProductionMgr
if (result.IsSuccess)
{
//签收后调用载具签收接口
await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
create_id = _userManager.UserId,
carry_code = input.carry_code ?? "",
});
// await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
// {
// org_id = _userManager.GetUserInfo().Result.organizeId,
// create_id = _userManager.UserId,
// carry_code = input.carry_code ?? "",
// });
}
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
@@ -257,12 +261,26 @@ namespace Tnb.ProductionMgr
if (result.IsSuccess)
{
//签收后调用载具签收接口
await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
// await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
// {
// org_id = _userManager.GetUserInfo().Result.organizeId,
// create_id = _userManager.UserId,
// carry_code = input.carry_code ?? "",
// });
var mesCarrySignInput = new MESCarrySignInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
create_id = _userManager.UserId,
carry_code = input.carry_code ?? "",
});
};
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
Dictionary<string, object> header = new Dictionary<string, object>()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
}
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);

View File

@@ -1,12 +1,24 @@
using JNPF;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
using JNPF.RemoteRequest;
using JNPF.Systems.Interfaces.System;
using Mapster;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
using Tnb.ProductionMgr.Interfaces;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.BasicData;
namespace Tnb.ProductionMgr
{
@@ -19,18 +31,112 @@ namespace Tnb.ProductionMgr
{
private readonly ISqlSugarRepository<PrdInstockH> _repository;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
public PrdInstockService(
ISqlSugarRepository<PrdInstockH> repository,
IBillRullService billRullService,
IUserManager userManager
)
{
_repository = repository;
_userManager = userManager;
_billRullService = billRullService;
}
[HttpPost]
public async Task<dynamic> SaveData(PrdInstockInput input)
{
var db = _repository.AsSugarClient();
var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
PrdInstockH prdInstockH = null;
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
prdInstockH = new PrdInstockH()
{
bill_type = input.bill_type,
bill_date = DateTime.Now,
create_id = _userManager.UserId,
location_code = input.location_code,
carry_code = input.carry_code,
is_check = input.is_check,
org_id = _userManager.GetUserInfo().Result.organizeId,
warehouse_id = location?.wh_id,
status = 0,
};
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
foreach (var item in input.details)
{
prdInstockDs.Add(new PrdInstockD()
{
instock_id = prdInstockH.id,
report_id = item.ContainsKey("report_id") ? item["report_id"] : "",
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
});
}
await _repository.InsertAsync(prdInstockH);
if (prdInstockDs.Count > 0)
{
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
}
});
if (result.IsSuccess)
{
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
mesCreateInstockInput.instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = input.bill_type,
warehouse_id = location?.wh_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = input.carry_code,
location_code = input.location_code,
is_check = input.is_check,
};
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
foreach (var item in input.details)
{
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
{
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
});
mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput()
{
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
});
}
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
Dictionary<string, object> header = new Dictionary<string, object>()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
Console.WriteLine(sendResult);
}
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
}
/// <summary>

View File

@@ -15,7 +15,6 @@
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr\Tnb.WarehouseMgr.csproj" />
<ProjectReference Include="..\Tnb.ProductionMgr.Interfaces\Tnb.ProductionMgr.Interfaces.csproj" />
</ItemGroup>