增加MES-WMS接口
This commit is contained in:
@@ -78,6 +78,20 @@ namespace Tnb.WarehouseMgr
|
||||
result.data = data;
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Api响应结果
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
protected Task<DataResult> ToApiResult( object data)
|
||||
{
|
||||
DataResult result = new();
|
||||
result.data = data;
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
/// <summary>
|
||||
/// Api响应结果
|
||||
/// </summary>
|
||||
|
||||
78
WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs
Normal file
78
WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
public class WmsCarryQueryService : BaseWareHouseService, IWmsCarryQueryService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
public WmsCarryQueryService(ISqlSugarRepository<WmsCarryH> repository)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 载具查询接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> MESCarryQuery(MESCarryQueryInput input)
|
||||
{
|
||||
var results = new List<CarryQueryOutput>();
|
||||
try
|
||||
{
|
||||
var carrys = await _db.Queryable<WmsCarryH>()
|
||||
.InnerJoin<WmsCollocationSchemeH>((a, b) => a.collocation_scheme_id == b.id)
|
||||
.Where((a, b) => a.carry_code.Contains(input.carry_code) || b.bill_name.Contains(input.collocation_scheme_name))
|
||||
.ToListAsync();
|
||||
|
||||
results = carrys.Adapt<List<CarryQueryOutput>>();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
return ToApiResult(results);
|
||||
}
|
||||
/// <summary>
|
||||
/// 载具查询返回接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> MESCarryQueryResult(MESCarryQueryResultInput input)
|
||||
{
|
||||
var result = new CarryQueryOutput();
|
||||
try
|
||||
{
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
|
||||
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carry.id).ToListAsync();
|
||||
result = carry.Adapt<CarryQueryOutput>();
|
||||
result.wmsCarryCodes = carryCodes.Adapt<List<CarryCodeQueryOutput>>();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
return ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Extension;
|
||||
@@ -12,9 +13,12 @@ using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
@@ -78,5 +82,32 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
/// <summary>
|
||||
/// MES齐套搭配方案查询接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> MESCollocationSchemeQuery(MESCollocationSchemeQueryInput input)
|
||||
{
|
||||
var results = new List<CollocationSchemeOutput>();
|
||||
try
|
||||
{
|
||||
results = await _db.Queryable<WmsCollocationSchemeH>()
|
||||
.LeftJoin<WmsCollocationSchemeD>((a, b) => b.bill_id == a.id)
|
||||
.Where(a => a.material_id == input.material_id)
|
||||
.Select((a, b) => new CollocationSchemeOutput
|
||||
{
|
||||
list = SqlFunc.Subqueryable<WmsCollocationSchemeD>().Where(b => b.bill_id == a.id).ToList(),
|
||||
}, true)
|
||||
.Mapper(it=> it.CollocationSchemeDs = it.list.Adapt<List<CollocationSchemeDOutput>>())
|
||||
.ToListAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
return await ToApiResult(results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -22,6 +23,7 @@ using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
@@ -33,7 +35,7 @@ namespace Tnb.WarehouseMgr
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
|
||||
public class WmsEmptyInstockService : BaseWareHouseService
|
||||
public class WmsEmptyInstockService : BaseWareHouseService, IWmsEmptyInstockService
|
||||
{
|
||||
private const string BizTypeId = "26121986416677";
|
||||
private readonly ISqlSugarClient _db;
|
||||
@@ -116,7 +118,7 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks,null!);
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
if (isOk)
|
||||
{
|
||||
var preTaskUpInput = new GenPreTaskUpInput();
|
||||
@@ -161,7 +163,55 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
/// <summary>
|
||||
/// MES空载具入库
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> MesEmptyCarryInStock(MESEmptyCarryInStockInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
|
||||
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
|
||||
var emptyInstock = await _db.Queryable<WmsEmptyInstock>().FirstAsync(it => it.carry_code == input.carry_code && it.status == WmsWareHouseConst.BILLSTATUS_ADD_ID);
|
||||
if (emptyInstock != null)
|
||||
{
|
||||
return ToApiResult(HttpStatusCode.InternalServerError, $"空载具{emptyInstock.carry_code},预任务已生成");
|
||||
}
|
||||
if (carry != null && location != null)
|
||||
{
|
||||
var cols = new List<string>();
|
||||
var dic = new Dictionary<string, object>();
|
||||
dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId();
|
||||
dic[nameof(WmsEmptyInstock.org_id)] = input.org_id;
|
||||
dic[nameof(WmsEmptyInstock.location_id)] = location.id;
|
||||
dic[nameof(WmsEmptyInstock.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE);
|
||||
dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
||||
dic[nameof(WmsEmptyInstock.carry_id)] = carry.id;
|
||||
dic[nameof(WmsEmptyInstock.carry_code)] = input.carry_code;
|
||||
dic[nameof(WmsEmptyInstock.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
|
||||
dic[nameof(WmsEmptyInstock.create_id)] = input.create_id;
|
||||
dic[nameof(WmsEmptyInstock.create_time)] = DateTime.Now;
|
||||
dic[nameof(WmsEmptyInstock.warehouse_id)] = input.warehouse_id;
|
||||
|
||||
VisualDevModelDataCrInput visualDevModelDataCrInput = new ()
|
||||
{
|
||||
data = dic
|
||||
};
|
||||
await WmsEmptyIn(visualDevModelDataCrInput);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
return ToApiResult();
|
||||
|
||||
}
|
||||
public async override Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -21,6 +22,7 @@ using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -33,7 +35,7 @@ namespace Tnb.WarehouseMgr
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
|
||||
public class WmsEmptyOutstockService : BaseWareHouseService
|
||||
public class WmsEmptyOutstockService : BaseWareHouseService, IWmsEmptyOutstockService
|
||||
{
|
||||
private const string BizTypeId = "26122265173285";
|
||||
private readonly ISqlSugarClient _db;
|
||||
@@ -59,6 +61,8 @@ namespace Tnb.WarehouseMgr
|
||||
OverideFuncs.CreateAsync = PDAWmsEmptyOut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task<dynamic> PDAWmsEmptyOut(VisualDevModelDataCrInput input)
|
||||
{
|
||||
|
||||
@@ -209,5 +213,42 @@ namespace Tnb.WarehouseMgr
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES空载具出库接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> MESEmptyCarryOutStk(MESEmptyCarryOutStkInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
|
||||
var dic = new Dictionary<string, object>();
|
||||
dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
|
||||
dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
|
||||
dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
|
||||
dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
|
||||
dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
|
||||
dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
||||
dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
|
||||
dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
|
||||
dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
|
||||
dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
|
||||
|
||||
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
|
||||
{
|
||||
data = dic,
|
||||
};
|
||||
await PDAWmsEmptyOut(visualDevModelDataCrInput);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
return ToApiResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.Operations;
|
||||
using SqlSugar;
|
||||
@@ -25,7 +26,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// <summary>
|
||||
/// 出库签收
|
||||
/// </summary>
|
||||
public class WmsSignForDeliveryService : BaseWareHouseService
|
||||
public class WmsSignForDeliveryService : BaseWareHouseService, IWmsSignForDeliveryService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IWmsCarryService _wareCarryService;
|
||||
@@ -112,6 +113,17 @@ namespace Tnb.WarehouseMgr
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// MES调用载具签收接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task MESCarrySign(MESCarrySignInput input)
|
||||
{
|
||||
var signInput = input.Adapt<SignForDeliveryInput>();
|
||||
await SignForDelivery(signInput);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,12 +5,14 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
@@ -18,6 +20,8 @@ using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -278,6 +282,53 @@ namespace Tnb.WarehouseMgr
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// MES齐套出库接口
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> MESKittingOutStk(List<MESKittingOutStkInput> input)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
List<WmsKittingoutD> kittingOutDs = new();
|
||||
var kittingOuts = input.Adapt<List<WmsKittingoutH>>();
|
||||
|
||||
for (int i = 0; i < kittingOuts.Count; i++)
|
||||
{
|
||||
var x= kittingOuts[i];
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_KITTINGOUTSTK_ENCODE).GetAwaiter().GetResult();
|
||||
x.bill_date = DateTime.Now;
|
||||
x.bill_type = WmsWareHouseConst.BIZTYPE_WMSKITTINGOUTSTK_ID;
|
||||
x.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
||||
x.biz_type = WmsWareHouseConst.BIZTYPE_WMSKITTINGOUTSTK_ID;
|
||||
var d = input[i]?.wmsKittingoutDs?.Adapt<List<WmsKittingoutD>>();
|
||||
d?.ForEach(it =>
|
||||
{
|
||||
it.id = SnowflakeIdHelper.NextId();
|
||||
it.bill_id = x.id;
|
||||
it.qty = 0;
|
||||
it.real_box = 0;
|
||||
it.warehouse_id = x.warehouse_id;
|
||||
});
|
||||
kittingOutDs.AddRange(d!);
|
||||
}
|
||||
await _db.Insertable(kittingOuts).ExecuteCommandAsync();
|
||||
await _db.Insertable(kittingOutDs).ExecuteCommandAsync();
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
await KittingOutByAdd();
|
||||
return ToApiResult();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user