From d4d62c3e09bd875a5aa32e27807316e72a504ba6 Mon Sep 17 00:00:00 2001
From: qianjiawei <1184704771@qq.com>
Date: Mon, 11 Dec 2023 17:30:42 +0800
Subject: [PATCH 1/2] =?UTF-8?q?erp=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/ErpInputs/SaleReturnInput.cs | 130 ++++++++++++++++++
.../Tnb.WarehouseMgr/ErpToWmsService.cs | 70 ++++++++++
2 files changed, 200 insertions(+)
create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleReturnInput.cs
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleReturnInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleReturnInput.cs
new file mode 100644
index 00000000..b258aff6
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleReturnInput.cs
@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
+{
+ public class SaleReturnInput
+ {
+ ///
+ /// 入库仓库ID
+ ///
+ public string? warehouse { get; set; }
+
+ ///
+ /// 供应商代码
+ ///
+ public string? supplier_code { get; set; }
+
+ ///
+ /// 打印状态
+ ///
+ public string print_status { get; set; } = string.Empty;
+
+ ///
+ /// 库位
+ ///
+ public string? location { 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 purchase_code { get; set; }
+
+ public List details { get; set; }
+ }
+ public class SaleReturnDetail
+ {
+ ///
+ /// 物品代码
+ ///
+ public string material_code { get; set; } = string.Empty;
+
+ ///
+ /// 入库需求数量
+ ///
+ public decimal? pr_qty { get; set; }
+
+ ///
+ /// 实际入库数量
+ ///
+ public decimal qty { get; set; }
+
+ ///
+ /// 原因
+ ///
+ public string? reason { get; set; }
+
+ ///
+ /// 入库仓库ID
+ ///
+ public string? warehouse { get; set; }
+
+ ///
+ /// 不含税单价
+ ///
+ public decimal? price { get; set; }
+
+ ///
+ /// 含税单价
+ ///
+ public decimal? tax_price { get; set; }
+
+ ///
+ /// 不含税金额
+ ///
+ public decimal? amount { get; set; }
+
+ ///
+ /// 含税金额
+ ///
+ public decimal? all_amount { get; set; }
+
+ ///
+ /// 已打印数量
+ ///
+ public decimal print_qty { get; set; }
+
+ ///
+ /// 扫描数量
+ ///
+ public decimal scan_qty { get; set; }
+
+ ///
+ /// 批次
+ ///
+ public string? code_batch { get; set; }
+
+ ///
+ /// 箱号
+ ///
+ public string? container_no { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
index b0e0f8c8..d0bfb5f8 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
@@ -208,5 +208,75 @@ namespace Tnb.WarehouseMgr
await db.Insertable(WmsSaleH).ExecuteCommandAsync();
await db.Insertable(WmsSaleDs).ExecuteCommandAsync();
}
+ ///
+ /// 销售退货单
+ ///
+ public async Task SaleReturn(SaleReturnInput input)
+ {
+ var db = _repository.AsSugarClient();
+ WmsInstockH WmsInstockH = new WmsInstockH();
+ string Code = await _billRuleService.GetBillNumber("WmsInStock");
+ WmsInstockH.bill_code = Code;
+ WmsInstockH.bill_date = DateTime.Now;
+ WmsInstockH.bill_type = "25103434001429";//销售退货单
+ WmsInstockH.biz_type = "26191496816421";//一般入库
+ WmsInstockH.status = "25065138925589";//新增
+ WmsInstockH.generate_type = "1";//0人工 1自动
+ WmsInstockH.create_time = DateTime.Now;
+ WmsInstockH.source_id = input.source_id;
+ WmsInstockH.source_code = input.source_code;
+ WmsInstockH.source_line = input.source_line;
+ WmsInstockH.source_detail_id = input.source_detail_id;
+ WmsInstockH.is_check = 1;
+ WmsInstockH.purchase_code = input.purchase_code;
+ WmsInstockH.sync_status = "26191359047461";//无需同步
+ WmsInstockH.print_status = "26191366982437";//未打印
+ WmsInstockH.create_id = "";
+ WmsInstockH.create_time = DateTime.Now;
+ var location = await db.Queryable().Where(p => p.location_code == input.location).FirstAsync();
+ if (location != null)
+ WmsInstockH.location_id = location.id;
+ var warehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync();
+ if (warehouse != null)
+ WmsInstockH.warehouse_id = warehouse.id;
+ WmsInstockH.supplier_code = input.supplier_code;
+ var supplier = await db.Queryable().Where(p => p.supplier_code == input.supplier_code).FirstAsync();
+ if (supplier != null)
+ {
+ WmsInstockH.supplier_id = supplier.id;
+ WmsInstockH.supplier_name = supplier.supplier_name;
+ }
+ List WmsInstockDs = new List();
+ foreach (var detail in input.details)
+ {
+ WmsInstockD WmsInstockD = new WmsInstockD();
+ WmsInstockD.bill_id = WmsInstockH.id;
+ WmsInstockD.line_status = "25065138925589";//新增
+ WmsInstockD.pr_qty = detail.pr_qty;
+ WmsInstockD.qty = detail.qty;
+ WmsInstockD.reason = detail.reason;
+ WmsInstockD.price = detail.price;
+ WmsInstockD.tax_price = detail.tax_price;
+ WmsInstockD.amount = detail.amount;
+ WmsInstockD.all_amount = detail.all_amount;
+ WmsInstockD.print_qty = 0;
+ WmsInstockD.scan_qty = 0;
+ WmsInstockD.code_batch = detail.code_batch;
+ WmsInstockD.container_no = detail.container_no;
+ var detailwarehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync();
+ if (detailwarehouse != null)
+ WmsInstockD.warehouse_id = detailwarehouse.id;
+ var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync();
+ if (material != null)
+ {
+ WmsInstockD.material_id = material.id;
+ WmsInstockD.unit_id = material.unit_id;
+
+ }
+ WmsInstockDs.Add(WmsInstockD);
+ }
+ await db.Insertable(WmsInstockH).ExecuteCommandAsync();
+ await db.Insertable(WmsInstockDs).ExecuteCommandAsync();
+ }
}
}
From 581242f54745e3da3df1fbbda3513adf875ddc61 Mon Sep 17 00:00:00 2001
From: qianjiawei <1184704771@qq.com>
Date: Tue, 12 Dec 2023 13:56:55 +0800
Subject: [PATCH 2/2] =?UTF-8?q?wms=E6=8E=A5=E5=85=A5redis?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/Inputs/CheckPutInput.cs | 14 ++++++++
.../LocationDefinitionService.cs | 7 ++--
.../Tnb.WarehouseMgr/WareHouseService.cs | 35 ++++++++++++++++---
3 files changed, 49 insertions(+), 7 deletions(-)
create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CheckPutInput.cs
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CheckPutInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CheckPutInput.cs
new file mode 100644
index 00000000..7bc98a7e
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/CheckPutInput.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
+{
+ public class CheckPutInput
+ {
+ public string point_code { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs
index f5eb3179..361949a2 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs
@@ -44,11 +44,11 @@ namespace Tnb.WarehouseMgr
//遍历字典,找出需要查询数据库拿的相关字段
foreach (Dictionary d in dics)
- {
+ { /*
if (d.Select(x => x.Value.ToString()).ToList().Find(v => v != "" && v != string.Empty && v != null) == null)
{
continue;
- }
+ }*/
string LCode = d["location_code"]?.ToString() ?? string.Empty;
if (LCode == string.Empty)
{
@@ -134,13 +134,14 @@ namespace Tnb.WarehouseMgr
{
row = await _db.Fastest().BulkCopyAsync(locs);
}
+ /*
else if (locs.Count > 400)
{
_db.Utilities.PageEach(locs, 100, async pageList =>
{
row = await _db.Insertable(pageList).ExecuteCommandAsync();
});
- }
+ }*/
else
{
row = await _db.Insertable(locs).ExecuteCommandAsync();
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index 8afa268e..dbbe073b 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -12,12 +12,15 @@ using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.System;
using Mapster;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using NPOI.OpenXmlFormats.Dml;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.Common.Extension;
+using Tnb.Common.Redis;
using Tnb.Common.Utils;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Configs;
@@ -45,8 +48,8 @@ namespace Tnb.WarehouseMgr
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build();
private static Dictionary locMap = new Dictionary(StringComparer.OrdinalIgnoreCase);
public Func AddUnExecuteTask { get; set; }
-
- public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService,
+ private readonly RedisData _redisData;
+ public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, RedisData redisData,
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService)
//: base(repository.AsSugarClient())
{
@@ -57,9 +60,8 @@ namespace Tnb.WarehouseMgr
_cacheManager = cacheManager;
_elevatorControlService = elevatorControlService;
_ = InitializationTask;
+ _redisData = redisData;
}
-
-
///
/// 根据载具Id带出库位、仓库信息
///
@@ -223,6 +225,31 @@ namespace Tnb.WarehouseMgr
.ToListAsync();
return input.Size > 0 ? items.Take(input.Size).ToList() : items;
}
+ ///
+ /// 判断CTU是否可以放货
+ ///
+ ///
+ [HttpPost]
+ public async Task CheckPut(CheckPutInput input)
+ {
+ Dictionary dic = new Dictionary();
+ dic.Add("5号输送线点位", new string[] { "TY4C-ZHUSU1", "weighDone_5" });
+ dic.Add("6号输送线点位", new string[] { "TY4C-ZHUSU1", "weighDone_6" });
+ if (!dic.ContainsKey(input.point_code))
+ throw new AppFriendlyException("点位" + input.point_code + "不存在", 500);
+ var strs = dic.Where(p => p.Key == input.point_code).First().Value;
+ bool flag = await _redisData.HashExist(strs[0], strs[1]);
+ if (!flag)
+ {
+ throw new AppFriendlyException("点位" + input.point_code + "不存在", 500);
+ }
+ string data = await _redisData.GetHash(strs[0], strs[1]);
+ JObject? res = JsonConvert.DeserializeObject(data);
+ bool result = res != null && res["Value"] != null ? res.Value("Value") : false;
+ if (!result)
+ throw new AppFriendlyException("点位" + input.point_code + "不可放", 500);
+ }
+
///
/// 生成任务执行
///