diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InOutStockApplyforUpInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InOutStockApplyforUpInput.cs
new file mode 100644
index 00000000..609401fa
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InOutStockApplyforUpInput.cs
@@ -0,0 +1,217 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tnb.WarehouseMgr.Entities.Enums;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ ///
+ /// 出入库申请修改输入参数
+ ///
+ public class InOutStockApplyforUpInput
+ {
+ // bill_line,location_id,delivery_date,carry_id,carry_code
+ ///
+ /// 出入库申请类型 1、入库 2、出库
+ ///
+ public EnumInOutStockType inoutStockType { get; set; }
+ ///
+ /// 所属组织ID
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 入库单ID
+ ///
+ public string bill_id { get; set; } = string.Empty;
+
+ ///
+ /// 执行状态
+ ///
+ public string line_status { get; set; } = string.Empty;
+
+ ///
+ /// 物品ID
+ ///
+ public string material_id { get; set; } = string.Empty;
+
+ ///
+ /// 物品代码
+ ///
+ public string material_code { get; set; } = string.Empty;
+
+ ///
+ /// 单位ID
+ ///
+ public string unit_id { get; set; } = string.Empty;
+
+ ///
+ /// 单位代码
+ ///
+ public string? unit_code { get; set; }
+
+ ///
+ /// 入库需求数量
+ ///
+ public int pr_qty { get; set; }
+
+ ///
+ /// 实际入库数量
+ ///
+ public int qty { get; set; }
+
+ ///
+ /// 原因
+ ///
+ public string? reason { get; set; }
+
+ ///
+ /// 入库仓库ID
+ ///
+ public string? warehouse_id { get; set; }
+
+ ///
+ /// 不含税单价
+ ///
+ public decimal? price { get; set; }
+
+ ///
+ /// 含税单价
+ ///
+ public decimal? tax_price { get; set; }
+
+ ///
+ /// 不含税金额
+ ///
+ public decimal? amount { get; set; }
+
+ ///
+ /// 含税金额
+ ///
+ public decimal? all_amount { get; set; }
+
+ ///
+ /// 来源单据ID
+ ///
+ public string? source_id { get; set; }
+
+ ///
+ /// 来源单据代码
+ ///
+ public string? source_code { get; set; }
+
+ ///
+ /// 源单单据类型
+ ///
+ public int? source_type { get; set; }
+
+ ///
+ /// 来源单据行号
+ ///
+ public int? source_line { get; set; }
+
+ ///
+ /// 来源单据明细ID
+ ///
+ public string? source_detail_id { get; set; }
+
+ ///
+ /// 生产工单号
+ ///
+ public string? mo_code { get; set; }
+
+ ///
+ /// 生产工单行号
+ ///
+ public int? mo_line { get; set; }
+
+ ///
+ /// 生产工单BOM明细Id
+ ///
+ public string? mo_bom_detail_id { get; set; }
+
+ ///
+ /// 已打印数量
+ ///
+ public int print_qty { get; set; }
+
+ ///
+ /// 扫描数量
+ ///
+ public int scan_qty { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 扩展字段
+ ///
+ public string? extras { get; set; }
+
+ ///
+ /// 时间戳
+ ///
+ public DateTime? time_stamp { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 批次
+ ///
+ public string? code_batch { get; set; }
+
+ ///
+ /// 打印模板ID
+ ///
+ public string? print_id { get; set; }
+
+ ///
+ /// 行号
+ ///
+ public int bill_line { get; set; }
+
+ ///
+ /// 库位ID
+ ///
+ public string location_id { get; set; } = string.Empty;
+ ///
+ /// 要求出库日期(销售出库为交期)
+ ///
+ public DateTime delivery_date { get; set; } = DateTime.Now;
+
+ ///
+ /// 载具ID
+ ///
+ public string? carry_id { get; set; }
+
+ ///
+ /// 载具编号
+ ///
+ public string? carry_code { get; set; }
+
+ public List InstockCodes { get; set; }
+ public List OutstockCodes { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InOutStockDetailQuery.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InOutStockDetailQuery.cs
new file mode 100644
index 00000000..2a931b06
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InOutStockDetailQuery.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tnb.WarehouseMgr.Entities.Enums;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ public class InOutStockDetailQuery
+ {
+ ///
+ /// 出入库申请类型 1、入库 2、出库
+ ///
+ public EnumInOutStockType inoutStockType { get; set; }
+ ///
+ /// 出入库单明细Id
+ ///
+ public string bill_d_id { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InStockDetailOutput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InStockDetailOutput.cs
new file mode 100644
index 00000000..bc562eb5
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/InStockDetailOutput.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ ///
+ /// 入库单据物料明细信息
+ ///
+ public class InStockDetailOutput
+ {
+ ///
+ /// 入库单明细Id
+ ///
+ public string bill_id { get; set; }
+ ///
+ /// 单位id
+ ///
+ public string unit_id { get; set; }
+ ///
+ /// 批次
+ ///
+ public string code_batch { get; set; }
+ ///
+ /// 入库仓库Id
+ ///
+ public string warehouse_id { get; set; }
+ ///
+ /// 执行状态
+ ///
+ public string line_status { get; set; }
+ ///
+ /// 原因
+ ///
+ public string reason { get; set; }
+ ///
+ /// 需求数量
+ ///
+ public int pr_qty { get; set; }
+ ///
+ /// 实际入库数量
+ ///
+ public int qty { get; set; }
+ ///
+ /// 不含税单价
+ ///
+ public decimal? price { get; set; }
+ ///
+ /// 含税单价
+ ///
+ public decimal? tax_price { get; set; }
+ ///
+ /// 已打印数量
+ ///
+ public int print_qty { get; set; }
+ ///
+ /// 扫描数量
+ ///
+ public int scan_qty { get; set; }
+ ///
+ /// 条码明细
+ ///
+ public List CodeDetails { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumInOutStockType.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumInOutStockType.cs
new file mode 100644
index 00000000..ad03a4f7
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumInOutStockType.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Enums
+{
+ ///
+ /// 出入库申请类型
+ ///
+ public enum EnumInOutStockType
+ {
+ ///
+ /// 入库
+ ///
+ In=1,
+ ///
+ /// 出库
+ ///
+ Out=2,
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index 9683dd70..f3e9e677 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -1,15 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Aspose.Cells.Drawing;
+using JNPF.Common.Contracts;
+using JNPF.Common.Enums;
using JNPF.Common.Extension;
+using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Config;
+using JNPF.FriendlyException;
+using Mapster;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.CodeAnalysis;
using NPOI.OpenXmlFormats.Wordprocessing;
using Polly.Timeout;
using Spire.Pdf.Widget;
@@ -18,6 +25,8 @@ using Tnb.BasicData.Entities;
using Tnb.BasicData.Entities.Enums;
using Tnb.Common.Utils;
using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
@@ -69,102 +78,101 @@ namespace Tnb.WarehouseMgr
return items;
}
///
- /// 获取载具信息(入库业务) 当前载具启用;未锁定;如果有库位信息,库位不能为存储库位,出库库位,分拣库位;
+ /// 库房业务,入库、出库申请新增修改功能
///
- ///
- /// returns:
- ///
{
- ///
carry_id:载具Id
- ///
carry_code:载具编号
- ///
carry_name:载具名称
- ///
location_id:库位id
- ///
location_code:库位编码
- ///
location_name:库位名称
- ///
}
- ///
- [HttpGet]
- public async Task GetCarryInfo()
+ ///
+ ///
+ [HttpPost]
+ public async Task ApplyFor(InOutStockApplyforUpInput input)
{
- var locationTypes = new[] { (int)EnumLocationType.存储库位, (int)EnumLocationType.出库库位, (int)EnumLocationType.分拣库位 };
- var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id)
- .Where((a, b) => a.status == 0 && a.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(b.is_type)))
- .Select((a, b) => new
- {
- carry_id = a.id,
- carry_code = a.carry_code,
- carry_name = a.carry_name,
- location_id = b.id,
- location_code = b.location_code,
- location_name = b.location_name,
- })
- .ToListAsync();
- return items;
+ // bill_line,location_id,delivery_date,carry_id,carry_code
+ if (input == null) throw new ArgumentNullException("input");
+ var isOk = false;
+ switch (input.inoutStockType)
+ {
+ case EnumInOutStockType.In:
+ var wmsInstockD = input.Adapt();
+ var wmsInstockCodes = input.InstockCodes.Adapt>();
+ wmsInstockCodes.ForEach(x =>
+ {
+ if (x.id.IsNullOrWhiteSpace())
+ {
+ x.id = SnowflakeIdHelper.NextId();
+ }
+ });
+ isOk = await _update(wmsInstockD, wmsInstockCodes);
+ break;
+ case EnumInOutStockType.Out:
+ var wmsOutstockD = input.Adapt();
+ var wmsOutstockCodes = input.InstockCodes.Adapt>();
+ wmsOutstockCodes.ForEach(x =>
+ {
+ if (x.id.IsNullOrWhiteSpace())
+ {
+ x.id = SnowflakeIdHelper.NextId();
+ }
+ });
+ isOk = await _update(wmsOutstockD, wmsOutstockCodes);
+ break;
+ }
+ if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
}
///
- /// 获取库位信息(入库业务) 库位不能为存储库位,出库库位,分拣库位;未锁定
- ///
- ///
- /// returns
- ///
{
- ///
location_id:库位Id
- ///
location_code:库位编号
- ///
location_name:库位名称
- ///
layers:楼层
- ///
}
- ///
- [HttpGet]
- public async Task GetLocationInfo()
- {
- var locationTypes = new[] { (int)EnumLocationType.存储库位, (int)EnumLocationType.出库库位, (int)EnumLocationType.分拣库位 };
- var items = await _db.Queryable().Where(it => it.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(it.is_type)))
- .Select(it => new
- {
- location_id = it.id,
- location_code = it.location_code,
- location_name = it.location_name,
- layers = it.layers,
- })
- .ToListAsync();
- return items;
- }
- ///
- /// 出库查询目标库位信息,覆盖过滤条件
+ /// 根据明细Id获取出入库明细信息
///
+ ///
///
[HttpGet]
- public async Task GetOutStoreDestLocation()
+ public async Task GetInOutStockCodesById([FromQuery] InOutStockDetailQuery input)
{
- var locationTypes = new[] { (int)EnumLocationType.存储库位, (int)EnumLocationType.入库库位 };
- var items = await _db.Queryable().Where(it => it.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(it.is_type)))
- .Select(it => new
- {
- location_id = it.id,
- location_code = it.location_code,
- })
- .ToListAsync();
- return items;
+ dynamic result = null;
+ switch (input.inoutStockType)
+ {
+ case EnumInOutStockType.In:
+ result = await _db.Queryable()
+ .Where(a => a.id == input.bill_d_id)
+ .Select(a => new InStockDetailOutput
+ {
+ bill_id = a.id,
+ unit_id = a.unit_id,
+ code_batch = a.code_batch,
+ warehouse_id = a.warehouse_id,
+ line_status = a.line_status,
+ reason = a.reason,
+ pr_qty = a.pr_qty,
+ qty = a.qty,
+ price = a.price,
+ tax_price = a.tax_price,
+ print_qty = a.print_qty,
+ scan_qty = a.scan_qty,
+ CodeDetails = SqlFunc.Subqueryable().Where(it => it.bill_d_id == a.id).ToList(),
+ }).ToListAsync();
+
+ break;
+ case EnumInOutStockType.Out:
+ result = await _db.Queryable().Where(it => it.bill_d_id == input.bill_d_id).ToListAsync();
+ break;
+ }
+ return result;
}
- ///
- /// 出库申请-查询载具信息
- ///
- ///
- [HttpGet]
- public async Task GetOutStoreLocation()
+
+ private async Task _update(T1 entity, List entities) where T1 : BaseEntity, new() where T2 : BaseEntity, new()
{
- var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id)
- .Where((a, b) => a.status == 0 && a.is_lock == 0 && Convert.ToInt32(b.is_type) == (int)EnumLocationType.存储库位)
- .Select((a, b) => new
- {
- carry_id = a.id,
- carry_code = a.carry_code,
- carry_name = a.carry_name,
- location_id = b.id,
- location_code = b.location_code,
- location_name = b.location_name,
- })
- .ToListAsync();
- return items;
+ var isOk = false;
+ try
+ {
+ await _db.Ado.BeginTranAsync();
+ isOk = await _db.Updateable(entity).ExecuteCommandHasChangeAsync();
+ isOk = await _db.Updateable(entities).ExecuteCommandHasChangeAsync();
+ await _db.Ado.CommitTranAsync();
+ }
+ catch (Exception)
+ {
+ await _db.Ado.RollbackTranAsync();
+ }
+ return isOk;
}
+
///
/// 路径算法
///