生产退料开发等
This commit is contained in:
@@ -6,8 +6,12 @@ using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -17,25 +21,22 @@ namespace Tnb.WarehouseMgr
|
||||
/// 载具解绑
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYUNBIND_ID)]
|
||||
public class WmsCarryUnbindService : BaseWareHouseService
|
||||
public class WmsCarryUnbindService : BaseWareHouseService, IWmsCarryUnbindService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
public WmsCarryUnbindService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IWareHouseService wareHouseService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_userManager = userManager;
|
||||
_wareHouseService = wareHouseService;
|
||||
OverideFuncs.CreateAsync = CarryUnbind;
|
||||
}
|
||||
private async Task<dynamic> CarryUnbind(VisualDevModelDataCrInput input)
|
||||
@@ -119,5 +120,116 @@ namespace Tnb.WarehouseMgr
|
||||
var isOk = await _db.Updateable<WmsCarryReplaceH>().SetColumns(it => new WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// 解绑定料箱到料架
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[NonAction]
|
||||
public async Task<Result> CarryUnbind(CarryBindInput input)
|
||||
{
|
||||
bool isOk = false;
|
||||
try
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
WmsCarryH? carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
|
||||
if (carry != null)
|
||||
{
|
||||
int row = await _db.Deleteable<WmsCarryD>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
|
||||
isOk = row > 0;
|
||||
|
||||
if (!isOk)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
|
||||
|
||||
// 插入子载具绑定记录
|
||||
VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary<string, object>() };
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id;
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code;
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id;
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code;
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0;
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id;
|
||||
if (!string.IsNullOrEmpty(input.create_id))
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id;
|
||||
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now;
|
||||
visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1;
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYUNBIND_ID, true);
|
||||
await _runService.Create(templateEntity, visualDevModelCrInput);
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (carry == null)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的主载具", 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"【CarryUnbind】 {ex.Message}");
|
||||
Logger.LogError($"【CarryUnbind】 {ex.StackTrace}");
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[NonAction]
|
||||
public async Task<dynamic> CarryCodeUnbind(CarryCodeUnbindInput input)
|
||||
{
|
||||
bool isOk = false;
|
||||
try
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
WmsCarryH? carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
|
||||
if (carry != null)
|
||||
{
|
||||
int row = await _db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
|
||||
isOk = row > 0;
|
||||
|
||||
if (!isOk)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (carry == null)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的主载具", 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user