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 { /// /// 载具移出 /// [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 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 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().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.carry_id)].ToString()); var subCarry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.membercarry_id)].ToString()); var deleteQty = await _db.Deleteable().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().SetColumns(it => new WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); }*/ } }