Files
tnb.server/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs
FanLian dd3ca9abd2 1
2023-06-16 13:48:54 +08:00

93 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
{
/// <summary>
/// 载具移出
/// </summary>
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACE_ID)]
public class WmsCarryUnbindService : BaseWareHouseService
{
private readonly ISqlSugarClient _db;
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private readonly IWareHouseService _wareHouseService;
private readonly IBillRullService _billRullService;
private readonly IUserManager _userManager;
public WmsCarryUnbindService(
ISqlSugarRepository<WmsCarryH> repository,
IRunService runService,
IVisualDevService visualDevService,
IWareHouseService wareHouseService,
IUserManager userManager,
IBillRullService billRullService)
{
_db = repository.AsSugarClient();
_runService = runService;
_visualDevService = visualDevService;
_wareHouseService = wareHouseService;
_userManager = userManager;
_billRullService = billRullService;
OverideFuncs.CreateAsync = CarryUnbind;
}
private async Task<dynamic> CarryUnbind(VisualDevModelDataCrInput input)
{
try
{
await _db.Ado.BeginTranAsync();
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true);
await _runService.Create(templateEntity, input);
if (input == null) throw new ArgumentNullException(nameof(input));
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.carry_id)].ToString());
var subCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.membercarry_id)].ToString());
var deleteQty = await _db.Deleteable<WmsCarryD>().Where(it => it.carry_id == carry.id ).ExecuteCommandAsync();
if (deleteQty <= 0) throw Oops.Oh(ErrorCode.COM1002);
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await _db.Ado.RollbackTranAsync();
throw;
}
return Task.FromResult(true);
}
/* public override async Task ModifyAsync(WareHouseUpInput input)
{
if (input == null) throw new ArgumentNullException(nameof(input));
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);
}*/
}
}