增加PDA载具绑定和解绑
This commit is contained in:
132
WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs
Normal file
132
WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
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_WMSCARRYBINDPDA_ID)]
|
||||
public class WmsPDACarryBindService : BaseWareHouseService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
public WmsPDACarryBindService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IUserManager userManager,
|
||||
IBillRullService billRullService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
OverideFuncs.CreateAsync = PDACarryBind;
|
||||
}
|
||||
|
||||
private async Task<dynamic> PDACarryBind(VisualDevModelDataCrInput input)
|
||||
{
|
||||
var isOk = false;
|
||||
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 carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : "";
|
||||
var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : "";
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
var subCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == subCarryId);
|
||||
WmsCarrybindH wmsCarrybindH = carry.Adapt<WmsCarrybindH>();
|
||||
if (carry != null && subCarry != null)
|
||||
{
|
||||
wmsCarrybindH.id = SnowflakeIdHelper.NextId();
|
||||
wmsCarrybindH.org_id = carry.org_id;
|
||||
wmsCarrybindH.carry_id = carry.id;
|
||||
wmsCarrybindH.membercarry_id = subCarry.id;
|
||||
wmsCarrybindH.membercarry_code = subCarry.carry_code;
|
||||
wmsCarrybindH.loc = input.data[nameof(WmsCarrybindH.loc)].ParseToInt(1);
|
||||
wmsCarrybindH.create_id = _userManager.UserId;
|
||||
wmsCarrybindH.create_time = DateTime.Now;
|
||||
var row = await _db.Insertable(wmsCarrybindH).ExecuteCommandAsync();
|
||||
carry.carry_status = "1";
|
||||
row = await _db.Updateable(carry).ExecuteCommandAsync();
|
||||
subCarry.carry_status = "1";
|
||||
row = await _db.Updateable(subCarry).ExecuteCommandAsync();
|
||||
var items = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == subCarryId).ToListAsync();
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
WmsCarrybindCode wmsCarrybindCode = new();
|
||||
wmsCarrybindCode.id = SnowflakeIdHelper.NextId();
|
||||
wmsCarrybindCode.org_id = subCarry.id;
|
||||
wmsCarrybindCode.carrybind_id = wmsCarrybindH.id;
|
||||
wmsCarrybindCode.material_id = items[i].material_id;
|
||||
wmsCarrybindCode.material_code = items[i].material_code;
|
||||
wmsCarrybindCode.barcode = items[i].barcode;
|
||||
wmsCarrybindCode.code_batch = items[i].code_batch;
|
||||
wmsCarrybindCode.codeqty = items[i].codeqty;
|
||||
wmsCarrybindCode.membercarry_id = subCarry.id;
|
||||
wmsCarrybindCode.membercarry_code = subCarry.carry_code;
|
||||
wmsCarrybindCode.unit_id = items[i].unit_id;
|
||||
wmsCarrybindCode.unit_code = items[i].unit_code;
|
||||
wmsCarrybindCode.create_id = _userManager.UserId;
|
||||
wmsCarrybindCode.create_time = DateTime.Now;
|
||||
row = await _db.Insertable(wmsCarrybindCode).ExecuteCommandAsync();
|
||||
}
|
||||
isOk = (row > 0);
|
||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (carry == null || subCarry == null)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的主载具", 500);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
108
WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs
Normal file
108
WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs
Normal file
@@ -0,0 +1,108 @@
|
||||
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_WMSCARRYUNBINDPDA_ID)]
|
||||
public class WmsPDACarryUnbindService : BaseWareHouseService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
public WmsPDACarryUnbindService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IWareHouseService wareHouseService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_userManager = userManager;
|
||||
_wareHouseService = wareHouseService;
|
||||
OverideFuncs.CreateAsync = PDACarryUnbind;
|
||||
}
|
||||
private async Task<dynamic> PDACarryUnbind(VisualDevModelDataCrInput input)
|
||||
{
|
||||
var isOk = false;
|
||||
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 carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : "";
|
||||
var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : "";
|
||||
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == carryId);
|
||||
var subCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == subCarryId);
|
||||
//WmsCarryunbindH wmsCarryUnbindH = carry.Adapt<WmsCarryunbindH>();
|
||||
if (carry != null && subCarry != null)
|
||||
{
|
||||
var row = await _db.Deleteable<WmsCarryD>().Where(it => it.carry_id == subCarry.id).ExecuteCommandAsync();
|
||||
carry.carry_status = "0";
|
||||
row = await _db.Updateable(carry).ExecuteCommandAsync();
|
||||
subCarry.carry_status = "0";
|
||||
row = await _db.Updateable(subCarry).ExecuteCommandAsync();
|
||||
isOk = (row > 0);
|
||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (carry == null)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的主载具", 500);
|
||||
}
|
||||
if (subCarry == null)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的子载具", 500);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user