添加出入库记录逻辑,采购收货调拨打印、绑定条码更接口变更等
This commit is contained in:
@@ -453,7 +453,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
|
||||
if (WmsCarryCode != null)
|
||||
{
|
||||
LoggerBGWCarrySupplement.LogInformation($"【ScanInStock】 八工位 {key} 查找到托盘{carry.carry_code}在WmsCarryCode中存在");
|
||||
LoggerBGWCarrySupplement.LogInformation($"【ScanInStock】 八工位 {key} 查找到托盘{carry.carry_code}在WmsCarryCode中存在");
|
||||
|
||||
VisualDevModelDataCrInput input = new VisualDevModelDataCrInput();
|
||||
input.data = new Dictionary<string, object>();
|
||||
|
||||
@@ -121,6 +121,10 @@ public class ModuleConsts
|
||||
/// </summary>
|
||||
public const string MODULE_WMSCARRYREPLACE_ID = "26188532491557";//26188532491557
|
||||
/// <summary>
|
||||
/// 模块标识-出入库流水记录 todo
|
||||
/// </summary>
|
||||
public const string MODULE_WMSOUTINSTOCKDETAIL_ID = "MODULE_WMSOUTINSTOCKDETAIL_ID";
|
||||
/// <summary>
|
||||
/// 模块标识-人工空载具入库 todo
|
||||
/// </summary>
|
||||
public const string MODULE_WMSEMPTYCARRYINSTOCK_ID = "MODULE_WMSEMPTYCARRYINSTOCK_ID";//
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
|
||||
{
|
||||
public class AddOutinStockDetailInput
|
||||
{
|
||||
public WmsDistaskH disTask { get; set; }
|
||||
public string? warehouse_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,9 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
|
||||
public class BarCodeInput
|
||||
{
|
||||
public string? BillId { get; set; }
|
||||
/// <summary>
|
||||
/// 条码的张数
|
||||
/// </summary>
|
||||
public int barcode_qty { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
|
||||
public string? material_code { get; set; }
|
||||
public string? barcode { get; set; }
|
||||
public string? code_batch { get; set; }
|
||||
public string? codeqty { get; set; }
|
||||
public decimal codeqty { get; set; }
|
||||
public int is_out { get; set; }
|
||||
public string? unit_id { get; set; }
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 出入库流水明细条码表
|
||||
/// </summary>
|
||||
[SugarTable("wms_outin_stock_code")]
|
||||
public partial class WmsOutinStockCode : BaseEntity<string>
|
||||
{
|
||||
public WmsOutinStockCode()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 所属组织ID
|
||||
/// </summary>
|
||||
public string org_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 出入库流水明细ID
|
||||
/// </summary>
|
||||
public string bill_d_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物品ID
|
||||
/// </summary>
|
||||
public string material_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string material_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 条码编号
|
||||
/// </summary>
|
||||
public string barcode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 批次
|
||||
/// </summary>
|
||||
public string? code_batch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码数量
|
||||
/// </summary>
|
||||
public decimal codeqty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位ID
|
||||
/// </summary>
|
||||
public string unit_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 单位代码
|
||||
/// </summary>
|
||||
public string? unit_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展字段
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public DateTime? time_stamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public string? material_specification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱号
|
||||
/// </summary>
|
||||
public string? container_no { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 期初数量
|
||||
/// </summary>
|
||||
public decimal? start_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 期末数量
|
||||
/// </summary>
|
||||
public decimal? end_qty { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 出入库流水明细表
|
||||
/// </summary>
|
||||
[SugarTable("wms_outin_stock_detail")]
|
||||
public partial class WmsOutinStockDetail : BaseEntity<string>
|
||||
{
|
||||
public WmsOutinStockDetail()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 所属组织ID
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行状态
|
||||
/// </summary>
|
||||
public string line_status { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 入库仓库ID
|
||||
/// </summary>
|
||||
public string? warehouse_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单据ID
|
||||
/// </summary>
|
||||
public string? source_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单据代码
|
||||
/// </summary>
|
||||
public string? source_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 源单单据类型
|
||||
/// </summary>
|
||||
public int? source_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单据行号
|
||||
/// </summary>
|
||||
public int? source_line { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单据明细ID
|
||||
/// </summary>
|
||||
public string? source_detail_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展字段
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public DateTime? time_stamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 打印模板ID
|
||||
/// </summary>
|
||||
public string? print_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 载具id
|
||||
/// </summary>
|
||||
public string? carry_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 载具编码
|
||||
/// </summary>
|
||||
public string? carry_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务执行编码
|
||||
/// </summary>
|
||||
public string? distask_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预任务编码
|
||||
/// </summary>
|
||||
public string? pretask_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务开始时间
|
||||
/// </summary>
|
||||
public DateTime? act_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务结束时间
|
||||
/// </summary>
|
||||
public DateTime? act_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起点库位id
|
||||
/// </summary>
|
||||
public string? startlocation_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 终点库位id
|
||||
/// </summary>
|
||||
public string? endlocation_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起点库位编码
|
||||
/// </summary>
|
||||
public string? startlocation_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 终点库位编码
|
||||
/// </summary>
|
||||
public string? endlocation_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出入库类型
|
||||
/// </summary>
|
||||
public string? type { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Interfaces
|
||||
{
|
||||
public interface IWmsOutinStockDetailService
|
||||
{
|
||||
/// <summary>
|
||||
/// 插入出入库明细记录
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="dbConn"></param>
|
||||
/// <returns></returns>
|
||||
public Task AddOutinStockDetail(AddOutinStockDetailInput input, ISqlSugarClient dbConn = null);
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,8 @@ namespace Tnb.WarehouseMgr
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F4DMJCInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F4DMJCOutstock = new(1);
|
||||
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_AddOutinStockDetail = new(1);
|
||||
|
||||
protected static Dictionary<string, int> _s_eleUseStatusDic;
|
||||
|
||||
protected IEventPublisher? EventPublisher { set; get; }
|
||||
|
||||
@@ -362,6 +362,18 @@ namespace Tnb.WarehouseMgr
|
||||
wmsPurchaseOrderD.fk_wms_purchase_order_id = wmsPurchaseOrderH.id;
|
||||
wmsPurchaseOrderD.matcode = detail.material_code;
|
||||
wmsPurchaseOrderD.unit = detail.unit_code;
|
||||
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
|
||||
if (erpExtendField != null)
|
||||
{
|
||||
wmsPurchaseOrderD.unit = erpExtendField.EnCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【PurchaseOrder】表体明细中单位{detail.unit_code}在wms系统中未找到!");
|
||||
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
|
||||
}
|
||||
|
||||
|
||||
wmsPurchaseOrderD.purchase_quantity = detail.purchase_quantity;
|
||||
wmsPurchaseOrderD.stock_location = detail.stock_location;
|
||||
wmsPurchaseOrderD.code_batch = detail.code_batch;
|
||||
@@ -468,7 +480,18 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
wmsOutsourceOrderD.fk_wms_outsource_order_id = wmsOutsourceOrderH.id;
|
||||
wmsOutsourceOrderD.matcode = detail.material_code;
|
||||
wmsOutsourceOrderD.unit = detail.unit_code;
|
||||
|
||||
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
|
||||
if (erpExtendField != null)
|
||||
{
|
||||
wmsOutsourceOrderD.unit = erpExtendField.EnCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【OutsourceOrder】表体明细中单位{detail.unit_code}在wms系统中未找到!");
|
||||
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
|
||||
}
|
||||
|
||||
wmsOutsourceOrderD.outsource_quantity = detail.outsource_quantity;
|
||||
wmsOutsourceOrderD.stock_location = detail.stock_location;
|
||||
wmsOutsourceOrderD.code_batch = detail.code_batch;
|
||||
@@ -869,7 +892,18 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
msRawmatTransferinstockD.bill_id = wmsRawmatTransferinstockH.id;
|
||||
msRawmatTransferinstockD.matcode = detail.material_code;
|
||||
msRawmatTransferinstockD.unit = detail.unit_code;
|
||||
|
||||
|
||||
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
|
||||
if (erpExtendField != null)
|
||||
{
|
||||
msRawmatTransferinstockD.unit = erpExtendField.EnCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】表体明细中单位{detail.unit_code}在wms系统中未找到!");
|
||||
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
|
||||
}
|
||||
msRawmatTransferinstockD.qty = detail.qty;
|
||||
msRawmatTransferinstockD.stock_location = detail.stock_location;
|
||||
msRawmatTransferinstockD.code_batch = detail.code_batch;
|
||||
|
||||
@@ -73,6 +73,10 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IElevatorControlService _elevatorControlService;
|
||||
private readonly IWmsCarryBindService _wmsCarryBindService;
|
||||
private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
|
||||
private readonly IWmsOutinStockDetailService _wmsOutinStockDetailService;
|
||||
|
||||
|
||||
|
||||
private static readonly Dictionary<string, int> _elevatorAgvCtlStatusMap = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
|
||||
private static Dictionary<string, object> locMap = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -86,6 +90,7 @@ namespace Tnb.WarehouseMgr
|
||||
public static SemaphoreSlim s_taskGenPreTask = new(1);
|
||||
public static SemaphoreSlim s_GenTaskExecute = new(1);
|
||||
|
||||
|
||||
public Func<string, int, Task> AddUnExecuteTask { get; set; }
|
||||
|
||||
|
||||
@@ -126,7 +131,8 @@ namespace Tnb.WarehouseMgr
|
||||
IWmsCarryBindService wmsCarryBindService,
|
||||
IWmsCarryUnbindService wmsCarryUnbindService,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService
|
||||
IVisualDevService visualDevService,
|
||||
IWmsOutinStockDetailService wmsOutinStockDetailService
|
||||
//IConfiguration configuration
|
||||
) : base(repository.AsSugarClient())
|
||||
{
|
||||
@@ -141,6 +147,7 @@ namespace Tnb.WarehouseMgr
|
||||
_wmsCarryUnbindService = wmsCarryUnbindService;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_wmsOutinStockDetailService = wmsOutinStockDetailService;
|
||||
//_configuration = configuration;
|
||||
|
||||
}
|
||||
@@ -2537,15 +2544,21 @@ namespace Tnb.WarehouseMgr
|
||||
_ = await _db.Updateable(carryIts).UpdateColumns(it => new { it.is_lock, it.location_id, it.location_code, it.instock_time }).ExecuteCommandAsync();
|
||||
Logger.Information($"【TaskComplate】 更新载具 {JsonConvert.SerializeObject(carryIts)}");
|
||||
//更新条码的库位和仓库信息
|
||||
_ = await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).Where(it => multiList.Select(x => x.carry_id).Contains(it.carry_id)).ExecuteCommandAsync();
|
||||
//更新库位信息,使用状态为 使用,锁定状态为未锁定
|
||||
_ = await _db.Updateable(locIts).UpdateColumns(it => new { it.is_use, it.is_lock }).ExecuteCommandAsync();
|
||||
Logger.Information($"【TaskComplate】 更新库位 {JsonConvert.SerializeObject(locIts)}");
|
||||
/* var loginType= _userManager?.LoginType ?? "web";
|
||||
Log.Information($"_userManager.LoginType={loginType}");
|
||||
*/ //更新业务主表的单据状态
|
||||
|
||||
foreach (WmsDistaskH? dt in disTasks)
|
||||
{
|
||||
AddOutinStockDetailInput addOutinStockDetailInput = new AddOutinStockDetailInput();
|
||||
addOutinStockDetailInput.disTask = dt;
|
||||
addOutinStockDetailInput.warehouse_id = carryCodeIts[0].warehouse_id;
|
||||
await _wmsOutinStockDetailService.AddOutinStockDetail(addOutinStockDetailInput, _db);
|
||||
|
||||
#region todo 移到service中
|
||||
// 销售出库
|
||||
if (dt.biz_type == WmsWareHouseConst.BIZTYPE_WMSSALERELEASE_ID)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Dynamic;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -194,6 +195,7 @@ namespace Tnb.WarehouseMgr
|
||||
WmsCarryCode.id = SnowflakeIdHelper.NextId();
|
||||
WmsCarryCode.carry_id = carry.id;
|
||||
WmsCarryCode.is_out = 0;
|
||||
WmsCarryCode.codeqty = detail.codeqty;
|
||||
WmsCarryCode.create_id = input.create_id;
|
||||
WmsCarryCode.create_time = DateTime.Now;
|
||||
WmsCarryCodes.Add(WmsCarryCode);
|
||||
@@ -284,7 +286,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[NonAction]
|
||||
public async Task<Result> CarryBind(CarryBindInput input, ISqlSugarClient dbConn = null)
|
||||
public async Task<Entities.Dto.Outputs.Result> CarryBind(CarryBindInput input, ISqlSugarClient dbConn = null)
|
||||
{
|
||||
bool isOk = false;
|
||||
|
||||
|
||||
@@ -535,7 +535,7 @@ namespace Tnb.WarehouseMgr
|
||||
CarryMaterialDetail carryMaterialDetail = new CarryMaterialDetail();
|
||||
carryMaterialDetail.material_id = wmsMaterialTransferD.material_id;
|
||||
carryMaterialDetail.material_code = wmsMaterialTransferD.material_code;
|
||||
carryMaterialDetail.codeqty = wmsCarryH.qty.ToString();
|
||||
carryMaterialDetail.codeqty = wmsCarryH.qty;
|
||||
carryMaterialDetail.code_batch = wmsMaterialTransferD.code_batch;
|
||||
carryMaterialDetail.barcode = wmsCarryHs[index].carry_code;
|
||||
carryMaterialDetail.unit_id = wmsMaterialTransferD.unit_id;
|
||||
@@ -1491,7 +1491,7 @@ namespace Tnb.WarehouseMgr
|
||||
CarryMaterialDetail carryMaterialDetail = new CarryMaterialDetail();
|
||||
carryMaterialDetail.material_id = wmsMaterialTransferD.material_id;
|
||||
carryMaterialDetail.material_code = wmsMaterialTransferD.material_code;
|
||||
carryMaterialDetail.codeqty = input.qty.ToString();
|
||||
carryMaterialDetail.codeqty = input.qty;
|
||||
carryMaterialDetail.code_batch = wmsMaterialTransferD.code_batch;
|
||||
carryMaterialDetail.barcode = wmsCarryH.carry_code;
|
||||
carryMaterialDetail.unit_id = wmsMaterialTransferD.unit_id;
|
||||
|
||||
212
WarehouseMgr/Tnb.WarehouseMgr/WmsOutinStockDetailService.cs
Normal file
212
WarehouseMgr/Tnb.WarehouseMgr/WmsOutinStockDetailService.cs
Normal file
@@ -0,0 +1,212 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using JNPF.Common.Contracts;
|
||||
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.Logging;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Npgsql;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSOUTINSTOCKDETAIL_ID)]
|
||||
public class WmsOutinStockDetailService : BaseWareHouseService, IWmsOutinStockDetailService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
public WmsOutinStockDetailService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IUserManager userManager,
|
||||
IBillRullService billRullService,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据任务单获取出入库类型
|
||||
/// </summary>
|
||||
string GetOutinStockTypeByTask(string task_type, string biz_type)
|
||||
{
|
||||
//if (biz_type == WmsWareHouseConst.BIZTYPE_WMSINSTOCK_ID)
|
||||
// return "";
|
||||
|
||||
string type = "";
|
||||
|
||||
switch (task_type)
|
||||
{
|
||||
case WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID:
|
||||
{
|
||||
type = "入库";
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID:
|
||||
{
|
||||
type = "转移";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据任务单获取操作员
|
||||
/// </summary>
|
||||
string GetUserIdByTask()
|
||||
{
|
||||
string create_id = WmsWareHouseConst.AdministratorUserId;
|
||||
return create_id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入出入库明细记录
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="dbConn"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[NonAction]
|
||||
public async Task AddOutinStockDetail(AddOutinStockDetailInput input, ISqlSugarClient dbConn = null)
|
||||
{
|
||||
var db = _db;
|
||||
if (dbConn != null)
|
||||
db = dbConn;
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.disTask.carry_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await _s_taskExecuteSemaphore_AddOutinStockDetail.WaitAsync();
|
||||
|
||||
string type = GetOutinStockTypeByTask(input.disTask.task_type, input.disTask.biz_type);
|
||||
if (string.IsNullOrEmpty(type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<WmsCarryCode> wmsCarryCodes = await db.Queryable<WmsCarryCode>().Where(r => r.carry_id == input.disTask.carry_id).ToListAsync();
|
||||
|
||||
//await db.Ado.BeginTranAsync();
|
||||
|
||||
WmsOutinStockDetail wmsOutinStockDetail = new WmsOutinStockDetail();
|
||||
wmsOutinStockDetail.warehouse_id = input.warehouse_id;
|
||||
wmsOutinStockDetail.carry_id = input.disTask.carry_id;
|
||||
wmsOutinStockDetail.carry_code = input.disTask.carry_code;
|
||||
wmsOutinStockDetail.create_id = GetUserIdByTask();
|
||||
wmsOutinStockDetail.startlocation_id = input.disTask.startlocation_id;
|
||||
wmsOutinStockDetail.startlocation_code = input.disTask.startlocation_code;
|
||||
wmsOutinStockDetail.endlocation_id = input.disTask.endlocation_id;
|
||||
wmsOutinStockDetail.endlocation_code = input.disTask.endlocation_code;
|
||||
wmsOutinStockDetail.act_start_date = input.disTask.act_start_date;
|
||||
wmsOutinStockDetail.act_end_date = input.disTask.act_end_date;
|
||||
wmsOutinStockDetail.pretask_code = input.disTask.pretask_code;
|
||||
wmsOutinStockDetail.distask_code = input.disTask.bill_code;
|
||||
wmsOutinStockDetail.type = type;
|
||||
|
||||
List<BasMaterial> mats = await db.Queryable<BasMaterial>().Where(r => wmsCarryCodes.Select(x => x.material_id).Distinct().Contains(r.id)).ToListAsync();
|
||||
|
||||
List<WmsOutinStockCode> wmsOutinStockCodes = new List<WmsOutinStockCode>();
|
||||
|
||||
|
||||
foreach (var itGroup in wmsCarryCodes.GroupBy(g => new { g.warehouse_id, g.location_id, g.material_id, g.code_batch }))
|
||||
{
|
||||
dynamic key = itGroup.Key;
|
||||
|
||||
List<WmsCarryCode> curCarryCodes = itGroup.ToList().FindAll(x => x.warehouse_id == itGroup.Key.warehouse_id && x.location_id == itGroup.Key.location_id
|
||||
&& x.material_id == itGroup.Key.material_id && x.code_batch == itGroup.Key.code_batch);
|
||||
|
||||
decimal start_qty = db.Queryable<WmsCarryCode>().Where(r => r.warehouse_id == itGroup.Key.warehouse_id
|
||||
&& r.code_batch == itGroup.Key.code_batch).Sum(r => r.codeqty);
|
||||
|
||||
curCarryCodes.ForEach(x =>
|
||||
{
|
||||
WmsOutinStockCode wmsOutinStockCode = new WmsOutinStockCode();
|
||||
BasMaterial mat = mats.Where(r => r.id == x.material_id).First();
|
||||
wmsOutinStockCode.bill_d_id = wmsOutinStockDetail.id;
|
||||
wmsOutinStockCode.barcode = x.barcode;
|
||||
wmsOutinStockCode.material_id = mat.id;
|
||||
wmsOutinStockCode.material_code = mat.code;
|
||||
wmsOutinStockCode.material_specification = mat.material_specification;
|
||||
wmsOutinStockCode.code_batch = x.code_batch;
|
||||
wmsOutinStockCode.codeqty = x.codeqty;
|
||||
wmsOutinStockCode.start_qty = start_qty;
|
||||
if (type == "入库")
|
||||
wmsOutinStockCode.end_qty = start_qty + x.codeqty;
|
||||
else if (type == "出库")
|
||||
wmsOutinStockCode.end_qty = start_qty - x.codeqty;
|
||||
wmsOutinStockCode.container_no = mat.container_no;
|
||||
wmsOutinStockCode.unit_id = mat.unit_id;
|
||||
|
||||
wmsOutinStockCodes.Add(wmsOutinStockCode);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
int rows = await db.Insertable(wmsOutinStockDetail).ExecuteCommandAsync();
|
||||
if (rows == 0)
|
||||
{
|
||||
throw new Exception($"插入入库明细失败!");
|
||||
}
|
||||
rows = await db.Insertable(wmsOutinStockCodes).ExecuteCommandAsync();
|
||||
if (rows == 0)
|
||||
{
|
||||
throw new Exception($"插入入库明细条码失败!");
|
||||
}
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (PostgresException ex)
|
||||
{
|
||||
////await db.Ado.RollbackTranAsync();
|
||||
Logger.LogError(ex.Message);
|
||||
Logger.LogError(ex.StackTrace);
|
||||
throw new AppFriendlyException($"插入入库明细失败 {ex.Message}", 500);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//await db.Ado.RollbackTranAsync();
|
||||
Logger.LogError(ex.Message);
|
||||
Logger.LogError(ex.StackTrace);
|
||||
throw new AppFriendlyException($"插入入库明细失败 {ex.Message}", 500);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_s_taskExecuteSemaphore_AddOutinStockDetail.Release();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,6 @@ namespace Tnb.WarehouseMgr
|
||||
var blFlag = true;
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
WmsInstockH? instock = null;
|
||||
var purchaseDs = await PurchaseAndSaleUpdate(input);
|
||||
@@ -330,8 +328,16 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (minPacking.HasValue && minPacking.Value > 0)
|
||||
{
|
||||
int mod = (int)(WmsPurchaseD.purchase_arriveqty % minPacking.Value);
|
||||
codeNum = (int)(mod > 0 ? (WmsPurchaseD.purchase_arriveqty / minPacking.Value) + 1 : WmsPurchaseD.purchase_arriveqty / minPacking.Value);
|
||||
codeNum = input.barcode_qty;
|
||||
|
||||
decimal qty = (int)(codeNum * minPacking);
|
||||
|
||||
decimal mod = 0;
|
||||
decimal extra = qty - WmsPurchaseD.purchase_arriveqty;
|
||||
if (extra > 0 && extra < minPacking)
|
||||
{
|
||||
mod = minPacking.Value - extra;
|
||||
}
|
||||
|
||||
for (int j = 0; j < codeNum; j++)
|
||||
{
|
||||
@@ -367,11 +373,11 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
barcodes.AddRange(wmsTempCodes.Select(p => p.barcode).ToList());
|
||||
if (barcodes?.Count > 0)
|
||||
{
|
||||
var ip= _db.Queryable<BasFactoryConfig>().Where(p=>p.key== "printerip").FirstAsync().Result.value;
|
||||
base.BarCodePrint(barcodes, 1, ip);
|
||||
}
|
||||
//if (barcodes?.Count > 0)
|
||||
//{
|
||||
// var ip= _db.Queryable<BasFactoryConfig>().Where(p=>p.key== "printerip").FirstAsync().Result.value;
|
||||
// base.BarCodePrint(barcodes, 1, ip);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -101,8 +101,16 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (minPacking.HasValue && minPacking.Value > 0)
|
||||
{
|
||||
int mod = (int)(WmsRawmatTransferinstockD.actual_qty % minPacking.Value);
|
||||
codeNum = (int)(mod > 0 ? (WmsRawmatTransferinstockD.actual_qty / minPacking.Value) + 1 : WmsRawmatTransferinstockD.actual_qty / minPacking.Value);
|
||||
codeNum = input.barcode_qty;
|
||||
|
||||
decimal qty = (int)(codeNum * minPacking);
|
||||
|
||||
decimal mod = 0;
|
||||
decimal extra = (qty - WmsRawmatTransferinstockD.actual_qty).Value;
|
||||
if (extra > 0 && extra < minPacking)
|
||||
{
|
||||
mod = minPacking.Value - extra;
|
||||
}
|
||||
|
||||
for (int j = 0; j < codeNum; j++)
|
||||
{
|
||||
@@ -137,11 +145,11 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
barcodes.AddRange(wmsTempCodes.Select(p => p.barcode).ToList());
|
||||
if (barcodes?.Count > 0)
|
||||
{
|
||||
var ip = _db.Queryable<BasFactoryConfig>().Where(p => p.key == "printerip").FirstAsync().Result.value;
|
||||
base.BarCodePrint(barcodes, 1, ip);
|
||||
}
|
||||
//if (barcodes?.Count > 0)
|
||||
//{
|
||||
// var ip = _db.Queryable<BasFactoryConfig>().Where(p => p.key == "printerip").FirstAsync().Result.value;
|
||||
// base.BarCodePrint(barcodes, 1, ip);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
@@ -161,5 +162,56 @@ namespace Tnb.WarehouseMgr
|
||||
};
|
||||
return PageResult<WmsStockReportH>.SqlSugarPageResult(pagedList);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> OutinStockDetail(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var code_batch = "";
|
||||
var material_specification = "";
|
||||
if (!input.queryJson.IsNullOrWhiteSpace())
|
||||
{
|
||||
code_batch = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.code_batch));
|
||||
material_specification = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.material_specification));
|
||||
}
|
||||
|
||||
IEnumerable<dynamic> result = null;
|
||||
|
||||
result = await _db.Queryable<WmsOutinStockDetail>()
|
||||
.InnerJoin<WmsOutinStockCode>((a, b) => a.id == b.bill_d_id)
|
||||
.InnerJoin<BasWarehouse>((a, b, c) => a.warehouse_id == c.id)
|
||||
.Select((a,b,c) => new
|
||||
{
|
||||
act_start_date = a.act_start_date,
|
||||
act_end_date = a.act_end_date,
|
||||
whname = c.whname,
|
||||
material_id = b.material_id,
|
||||
material_code = b.material_code,
|
||||
material_name = b.material_name,
|
||||
material_specification = b.material_specification,
|
||||
container_no = b.container_no,
|
||||
code_batch = b.code_batch,
|
||||
location_id = a.endlocation_id,
|
||||
location_code = a.endlocation_code,
|
||||
unit_id = b.unit_id,
|
||||
unit_code = b.unit_code,
|
||||
start_qty = b.start_qty,
|
||||
end_qty = b.end_qty,
|
||||
type = a.type
|
||||
}).ToListAsync();
|
||||
|
||||
List<dynamic> pages = result.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList();
|
||||
SqlSugarPagedList<dynamic> pagedList = new()
|
||||
{
|
||||
list = pages,
|
||||
pagination = new()
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = result.Count()
|
||||
}
|
||||
};
|
||||
return PageResult<dynamic>.SqlSugarPageResult(pagedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user