人工空托盘入库
This commit is contained in:
117
WarehouseMgr/Tnb.WarehouseMgr/WmsEmptycarryInstockLogService.cs
Normal file
117
WarehouseMgr/Tnb.WarehouseMgr/WmsEmptycarryInstockLogService.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
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 Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.QcMgr.Entities.Enums;
|
||||
using Tnb.QcMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using Tnb.QcMgr.Interfaces;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.FriendlyException;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Npgsql;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using JNPF.VisualDev;
|
||||
using System.Runtime.InteropServices;
|
||||
using Tnb.BasicData.Entities;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSEMPTYCARRYINSTOCK_ID)]
|
||||
public class WmsEmptycarryInstockLogService : BaseWareHouseService,IWmsEmptycarryInstockLogService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
public WmsEmptycarryInstockLogService(ISqlSugarRepository<WmsEmptycarryInstockLog> repository)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 人工空托盘入库
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
///
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> Instock(WmsEmptycarryInstockServiceInstockInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.location_code))
|
||||
{
|
||||
throw new Exception("请扫描入库库位");
|
||||
}
|
||||
if (string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
throw new Exception("请扫描载具");
|
||||
}
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).FirstAsync();
|
||||
BasLocation basLocation = await _db.Queryable<BasLocation>().Where(r => r.location_code == input.location_code).FirstAsync();
|
||||
|
||||
if (wmsCarryH.is_lock == 1)
|
||||
{
|
||||
throw new Exception($"载具{wmsCarryH.carry_code}已锁定");
|
||||
}
|
||||
if (wmsCarryH.carry_status == "1")
|
||||
{
|
||||
throw new Exception($"载具{wmsCarryH.carry_code}已占用");
|
||||
}
|
||||
|
||||
if (basLocation.is_lock == 1)
|
||||
{
|
||||
throw new Exception($"库位{basLocation.location_code}已锁定");
|
||||
}
|
||||
if (basLocation.is_use == "1")
|
||||
{
|
||||
throw new Exception($"库位{basLocation.location_code}已占用");
|
||||
}
|
||||
|
||||
wmsCarryH.location_id = basLocation.id;
|
||||
wmsCarryH.location_code = basLocation.location_code;
|
||||
|
||||
basLocation.is_use = "1";
|
||||
|
||||
await _db.Updateable(wmsCarryH).UpdateColumns(r => new { r.location_id , r.location_code}).ExecuteCommandAsync();
|
||||
await _db.Updateable(basLocation).UpdateColumns(r => new { r.is_use }).ExecuteCommandAsync();
|
||||
|
||||
WmsEmptycarryInstockLog wmsEmptycarryInstockLog = new WmsEmptycarryInstockLog();
|
||||
wmsEmptycarryInstockLog.carry_id = wmsCarryH.id;
|
||||
wmsEmptycarryInstockLog.carry_code = wmsCarryH.carry_code;
|
||||
wmsEmptycarryInstockLog.location_id = basLocation.id;
|
||||
wmsEmptycarryInstockLog.location_code = basLocation.location_code;
|
||||
wmsEmptycarryInstockLog.org_id = input.org_id;
|
||||
wmsEmptycarryInstockLog.create_id =input.create_id ;
|
||||
wmsEmptycarryInstockLog.create_time = DateTime.Now;
|
||||
|
||||
await _db.Insertable(wmsEmptycarryInstockLog).ExecuteCommandAsync();
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogInformation("【WmsEmptycarryInstockService-Instock】" + ex.Message);
|
||||
Logger.LogInformation("【WmsEmptycarryInstockService-Instock】" + ex.StackTrace);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user