From 71ff32b9090dac50357ee3e8e06ab5bc40b7373c Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 6 Dec 2023 14:32:33 +0800 Subject: [PATCH 1/8] bug --- ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs index d2d2ce09..a3f88ef8 100644 --- a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs @@ -288,6 +288,7 @@ namespace Tnb.ProductionMgr .SetColumns(x => x.repair_id == _userManager.UserId) .SetColumns(x=>x.status==DictConst.AndonStatusYXY) .SetColumns(x => x.response_time == DateTime.Now) + .Where(x => x.id == id) .ExecuteCommandAsync(); Dictionary postData = new() { From ad65e9fd0deffd3bf7dc55621563ead2383491ed Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 6 Dec 2023 16:28:53 +0800 Subject: [PATCH 2/8] bug --- ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs index a3f88ef8..bbc2ca99 100644 --- a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs @@ -395,7 +395,7 @@ namespace Tnb.ProductionMgr } else { - if (andonRecords.status != DictConst.AndonStatusYWC) + if (andonRecords.status != DictConst.AndonStatusDQR) { throw Oops.Bah($"状态错误"); } From 3a7a0dd5720e64cf1dda26ee6d62c9035f10a3fe Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Fri, 8 Dec 2023 17:05:10 +0800 Subject: [PATCH 3/8] =?UTF-8?q?ERP=E5=AF=B9=E6=8E=A5WMS=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/ErpInputs/AllotInput.cs | 36 +++ .../Dto/ErpInputs/PurchaseArriveInput.cs | 74 ++++++ .../Dto/ErpInputs/PurchaseReturnInput.cs | 73 ++++++ .../Dto/ErpInputs/SaleOutInput.cs | 77 +++++++ .../Entity/WmsAllot.cs | 115 ++++++++++ .../Tnb.WarehouseMgr/ErpToWmsService.cs | 212 ++++++++++++++++++ 6 files changed, 587 insertions(+) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/AllotInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseArriveInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseReturnInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleOutInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsAllot.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/AllotInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/AllotInput.cs new file mode 100644 index 00000000..cfa0d206 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/AllotInput.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs +{ + public class AllotInput + { + /// + /// 起始库位ID + /// + public string startlocation { get; set; } = string.Empty; + + /// + /// 目标库位ID + /// + public string endlocation { get; set; } = string.Empty; + + /// + /// 单据状态 + /// + public string status { get; set; } = string.Empty; + + /// + /// 业务类型: + /// + public string biz_type { get; set; } = string.Empty; + + /// + /// 所属仓库 + /// + public string warehouse { get; set; } = string.Empty; + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseArriveInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseArriveInput.cs new file mode 100644 index 00000000..fac481e7 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseArriveInput.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs +{ + public class PurchaseArriveInput + { + /// + /// 入库仓库 + /// + public string? warehouse { get; set; } + + /// + /// 供应商代码 + /// + public string? supplier_code { get; set; } + + /// + /// 来源单据ID + /// + public string? source_id { get; set; } + + /// + /// 来源单据代码 + /// + public string? source_code { get; set; } + + /// + /// 供货日期 + /// + public DateTime delivery_date { get; set; } = DateTime.Now; + + /// + /// 运输方式 + /// + public string? shipping_method { get; set; } + public List details { get; set; } + } + public class PurchaseArriveDetail + { + /// + /// 物品代码 + /// + public string material_code { get; set; } = string.Empty; + + /// + /// 采购数量 + /// + public decimal purchase_qty { get; set; } + + /// + /// 已到货数量 + /// + public decimal purchase_prqty { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 本次到货数量 + /// + public decimal purchase_arriveqty { get; set; } + + /// + /// 箱号 + /// + public string? container_no { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseReturnInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseReturnInput.cs new file mode 100644 index 00000000..5fc4f80f --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/PurchaseReturnInput.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs +{ + public class PurchaseReturnInput + { /// + /// 入库仓库 + /// + public string? warehouse { get; set; } + + /// + /// 供应商代码 + /// + public string? supplier_code { get; set; } + + /// + /// 来源单据ID + /// + public string? source_id { get; set; } + + /// + /// 来源单据代码 + /// + public string? source_code { get; set; } + + /// + /// 供货日期 + /// + public DateTime delivery_date { get; set; } = DateTime.Now; + + /// + /// 运输方式 + /// + public string? shipping_method { get; set; } + public List details { get; set; } + } + public class PurchaseReturnDetail + { + /// + /// 物品代码 + /// + public string material_code { get; set; } = string.Empty; + + /// + /// 采购数量 + /// + public decimal purchase_qty { get; set; } + + /// + /// 已到货数量 + /// + public decimal purchase_prqty { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 本次到货数量 + /// + public decimal purchase_arriveqty { get; set; } + + /// + /// 箱号 + /// + public string? container_no { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleOutInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleOutInput.cs new file mode 100644 index 00000000..9aa224aa --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleOutInput.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Org.BouncyCastle.Crypto; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs +{ + public class SaleOutInput + { + /// + /// 仓库 + /// + public string? warehouse { get; set; } + + /// + /// 客户代码 + /// + public string? customer_code { get; set; } + + /// + /// 来源单据ID + /// + public string? source_id { get; set; } + + /// + /// 来源单据代码 + /// + public string? source_code { get; set; } + + /// + /// 供货日期 + /// + public DateTime ship_date { get; set; } = DateTime.Now; + + /// + /// 运输方式 + /// + public string? shipping_method { get; set; } + + public List details { get; set; } + } + public class SaleOutDetail + { + /// + /// 物品代码 + /// + public string material_code { get; set; } = string.Empty; + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 箱号 + /// + public string? container_no { get; set; } + + /// + /// 本次发货数量 + /// + public decimal purchase_arriveqty { get; set; } + + /// + ///已 发货数量 + /// + public decimal purchase_prqty { get; set; } + + /// + /// 发货数量 + /// + public decimal purchase_qty { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsAllot.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsAllot.cs new file mode 100644 index 00000000..47e04c0a --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsAllot.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities +{ + + /// + /// 库内转移 + /// + [SugarTable("wms_allot")] + public partial class WmsAllot : BaseEntity + { + public WmsAllot() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 租户ID + /// + public string? tenant_id { get; set; } + + /// + /// 所属组织ID + /// + public string? org_id { get; set; } + + /// + /// 起始库位ID + /// + public string startlocation_id { get; set; } = string.Empty; + + /// + /// 目标库位ID + /// + public string endlocation_id { get; set; } = string.Empty; + + /// + /// 单号 + /// + public string bill_code { get; set; } = string.Empty; + + /// + /// 单据状态 + /// + public string status { get; set; } = string.Empty; + + /// + /// 业务类型: + /// + public string biz_type { get; set; } = string.Empty; + + /// + /// 载具ID + /// + public string carry_id { get; set; } = string.Empty; + + /// + /// 载具编号 + /// + public string carry_code { get; set; } = string.Empty; + + /// + /// 所属仓库 + /// + public string warehouse_id { get; set; } = string.Empty; + + /// + /// 创建用户 + /// + public string create_id { get; set; } = string.Empty; + + /// + /// 创建时间 + /// + public DateTime create_time { get; set; } = DateTime.Now; + + /// + /// 最后修改人员ID + /// + public string? modify_id { get; set; } + + /// + /// 最后修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 扩展字段 + /// + public string? extras { get; set; } + + /// + /// 时间戳(用于并发控制) + /// + public DateTime? timestamp { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + + } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs new file mode 100644 index 00000000..b0e0f8c8 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs @@ -0,0 +1,212 @@ +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Interfaces.System; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Dto.ErpInputs; + +namespace Tnb.WarehouseMgr +{ + /// + /// erp接口模块 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 800)] + public class ErpToWmsService : IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IBillRullService _billRuleService; + public ErpToWmsService(ISqlSugarRepository repository, IBillRullService billRuleService) + { + _repository = repository; + _billRuleService = billRuleService; + } + /// + /// 采购到货单 + /// + public async Task PurchaseArrive(PurchaseArriveInput input) + { + //主表 create_time 采购收货单号 bill_code 单据类型 bill_type 单据状态 status 业务类型 biz_type 入库仓库ID warehouse_id 供应商ID supplier_id 供应商名称supplier_name 生成类型 generate_type + //子表 主表id bill_id 执行状态line_status 单位id unit_id 物料id material_id + var db = _repository.AsSugarClient(); + WmsPurchaseH wmsPurchaseH = new WmsPurchaseH(); + string Code = await _billRuleService.GetBillNumber("WmsPurchase"); + wmsPurchaseH.bill_code = Code; + wmsPurchaseH.bill_type = "25103333373205";//收料通知单(到货单) + wmsPurchaseH.biz_type = "26191496816421";//一般入库 + wmsPurchaseH.status = "25065138925589";//新增 + wmsPurchaseH.generate_type = "1";//0人工 1自动 + wmsPurchaseH.create_time = DateTime.Now; + wmsPurchaseH.source_id = input.source_id; + wmsPurchaseH.source_code = input.source_code; + wmsPurchaseH.delivery_date = input.delivery_date; + wmsPurchaseH.shipping_method = input.shipping_method; + var warehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync(); + if (warehouse != null) + wmsPurchaseH.warehouse_id = warehouse.id; + wmsPurchaseH.supplier_code = input.supplier_code; + var supplier = await db.Queryable().Where(p => p.supplier_code == input.supplier_code).FirstAsync(); + if (supplier != null) + { + wmsPurchaseH.supplier_id = supplier.id; + wmsPurchaseH.supplier_name = supplier.supplier_name; + } + List WmsPurchaseDs = new List(); + foreach (var detail in input.details) + { + WmsPurchaseD wmsPurchased = new WmsPurchaseD(); + wmsPurchased.bill_id = wmsPurchaseH.id; + wmsPurchased.line_status = "25065138925589";//新增 + wmsPurchased.purchase_qty = detail.purchase_qty; + wmsPurchased.purchase_prqty = detail.purchase_prqty; + wmsPurchased.code_batch = detail.code_batch; + wmsPurchased.purchase_arriveqty = detail.purchase_arriveqty; + wmsPurchased.container_no = detail.container_no; + wmsPurchased.material_code = detail.material_code; + var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); + if (material != null) + { + wmsPurchased.material_id = material.id; + // wmsPurchased.material_name = material.name; + wmsPurchased.unit_id = material.unit_id; + } + WmsPurchaseDs.Add(wmsPurchased); + } + await db.Insertable(wmsPurchaseH).ExecuteCommandAsync(); + await db.Insertable(WmsPurchaseDs).ExecuteCommandAsync(); + + } + /// + /// 采购退货单 + /// + public async Task PurchaseReturn(PurchaseReturnInput input) + { + //主表 create_time 采购收货单号 bill_code 单据类型 bill_type 单据状态 status 业务类型 biz_type 入库仓库ID warehouse_id 供应商ID supplier_id 供应商名称supplier_name 生成类型 generate_type + //子表 主表id bill_id 执行状态line_status 单位id unit_id 物料id material_id + var db = _repository.AsSugarClient(); + WmsPurchaseH wmsPurchaseH = new WmsPurchaseH(); + string Code = await _billRuleService.GetBillNumber("WmsPurchase"); + wmsPurchaseH.bill_code = Code; + wmsPurchaseH.bill_type = "25103345478421";//采购退料单 + wmsPurchaseH.biz_type = "26191522660645";//一般出库 + wmsPurchaseH.status = "25065138925589";//新增 + wmsPurchaseH.generate_type = "1";//0人工 1自动 + wmsPurchaseH.create_time = DateTime.Now; + wmsPurchaseH.source_id = input.source_id; + wmsPurchaseH.source_code = input.source_code; + wmsPurchaseH.delivery_date = input.delivery_date; + wmsPurchaseH.shipping_method = input.shipping_method; + var warehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync(); + if (warehouse != null) + wmsPurchaseH.warehouse_id = warehouse.id; + wmsPurchaseH.supplier_code = input.supplier_code; + var supplier = await db.Queryable().Where(p => p.supplier_code == input.supplier_code).FirstAsync(); + if (supplier != null) + { + wmsPurchaseH.supplier_id = supplier.id; + + wmsPurchaseH.supplier_name = supplier.supplier_name; + } + List WmsPurchaseDs = new List(); + foreach (var detail in input.details) + { + WmsPurchaseD wmsPurchased = new WmsPurchaseD(); + wmsPurchased.bill_id = wmsPurchaseH.id; + wmsPurchased.line_status = "25065138925589";//新增 + wmsPurchased.purchase_qty = detail.purchase_qty; + wmsPurchased.purchase_prqty = detail.purchase_prqty; + wmsPurchased.code_batch = detail.code_batch; + wmsPurchased.purchase_arriveqty = detail.purchase_arriveqty; + wmsPurchased.container_no = detail.container_no; + wmsPurchased.material_code = detail.material_code; + var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); + if (material != null) + { + wmsPurchased.material_id = material.id; + // wmsPurchased.material_name = material.name; + wmsPurchased.unit_id = material.unit_id; + } + WmsPurchaseDs.Add(wmsPurchased); + } + await db.Insertable(wmsPurchaseH).ExecuteCommandAsync(); + await db.Insertable(WmsPurchaseDs).ExecuteCommandAsync(); + + } + /// + /// 仓库调拨 + /// + public async Task Allot(AllotInput input) + { + var db = _repository.AsSugarClient(); + WmsAllot wmsAllot = new WmsAllot(); + string Code = await _billRuleService.GetBillNumber("WmsTransfer"); + wmsAllot.bill_code = Code; + wmsAllot.biz_type = "25044010525205";//仓库调拨 + wmsAllot.status = "25065138925589";//新增 + var warehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync(); + if (warehouse != null) + wmsAllot.warehouse_id = warehouse.id; + var startloc = await db.Queryable().Where(p => p.location_code == input.startlocation).FirstAsync(); + if (startloc != null) + wmsAllot.startlocation_id = startloc.id; + var endloc = await db.Queryable().Where(p => p.location_code == input.endlocation).FirstAsync(); + if (endloc != null) + wmsAllot.endlocation_id = endloc.id; + wmsAllot.create_time = DateTime.Now; + await db.Insertable(wmsAllot).ExecuteCommandAsync(); + } + /// + /// 销售出库单 + /// + public async Task SaleOut(SaleOutInput input) + { + var db = _repository.AsSugarClient(); + WmsSaleH WmsSaleH = new WmsSaleH(); + string Code = await _billRuleService.GetBillNumber("WmsSale"); + WmsSaleH.bill_code = Code; + WmsSaleH.bill_type = "25103439022357";//销售出库单 + WmsSaleH.biz_type = "26191522660645";//一般出库 + WmsSaleH.status = "25065138925589";//新增 + WmsSaleH.generate_type = "1";//0人工 1自动 + WmsSaleH.create_time = DateTime.Now; + WmsSaleH.source_id = input.source_id; + WmsSaleH.source_code = input.source_code; + WmsSaleH.ship_date = input.ship_date; + WmsSaleH.shipping_method = input.shipping_method; + var warehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync(); + if (warehouse != null) + WmsSaleH.warehouse_id = warehouse.id; + WmsSaleH.customer_code = input.customer_code; + var customer = await db.Queryable().Where(p => p.customer_code == input.customer_code).FirstAsync(); + if (customer != null) + { + WmsSaleH.customer_id = customer.id; + WmsSaleH.customer_name = customer.customer_name; + } + List WmsSaleDs = new List(); + foreach (var detail in input.details) + { + WmsSaleD WmsSaleD = new WmsSaleD(); + WmsSaleD.bill_id = WmsSaleH.id; + WmsSaleD.line_status = "25065138925589";//新增 + WmsSaleD.purchase_qty = detail.purchase_qty; + WmsSaleD.purchase_prqty = detail.purchase_prqty; + WmsSaleD.code_batch = detail.code_batch; + WmsSaleD.purchase_arriveqty = detail.purchase_arriveqty; + WmsSaleD.container_no = detail.container_no; + WmsSaleD.material_code = detail.material_code; + var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); + if (material != null) + { + WmsSaleD.material_id = material.id; + // WmsSaleD.material_name = material.name; + WmsSaleD.unit_id = material.unit_id; + } + WmsSaleDs.Add(WmsSaleD); + } + await db.Insertable(WmsSaleH).ExecuteCommandAsync(); + await db.Insertable(WmsSaleDs).ExecuteCommandAsync(); + } + } +} From f2f38134940835fb2f7b762fa6c2bc6430b7763c Mon Sep 17 00:00:00 2001 From: "tao.zhang" <865692298@qq.com> Date: Mon, 11 Dec 2023 09:21:16 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index d6348e64..40bbc9cb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -66,6 +66,7 @@ namespace Tnb.WarehouseMgr var blFlag = true; try { + await _db.Ado.BeginTranAsync(); WmsInstockH? instock = null; var purchaseDs = await PurchaseAndSaleUpdate(input); From e03fda5ae1f01829ab28996a9ea15552ebb24f5e Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Mon, 11 Dec 2023 09:28:12 +0800 Subject: [PATCH 5/8] =?UTF-8?q?erp=E7=89=A9=E6=96=99=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/BasMaterial/ErpBasMaterialInput.cs | 370 ++++++++++++++++++ .../Entity/BasMaterial.cs | 5 + .../BasMaterialIntoFactorySpecifications.cs | 2 +- BasicData/Tnb.BasicData/BasMaterialService.cs | 183 +++++++++ 4 files changed, 559 insertions(+), 1 deletion(-) create mode 100644 BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/ErpBasMaterialInput.cs diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/ErpBasMaterialInput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/ErpBasMaterialInput.cs new file mode 100644 index 00000000..0ccd30c4 --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Dto/BasMaterial/ErpBasMaterialInput.cs @@ -0,0 +1,370 @@ +namespace Tnb.BasicData.Entities.Dto +{ + public class ErpBasMaterialInput + { + public ErpBasMaterial bas_material { get; set; } + public List bas_material_units { get; set; } = new List(); + + // public List bas_material_into_factory_specificationses { get; set; } = new List(); + // + // public List bas_substitution_materials { get; set; } = new List(); + // + // public List bas_material_send_warehouses { get; set; } = new List(); + // + // public List bas_material_inbound_whs { get; set; } = new List(); + } + + public class ErpBasMaterial + { + /// + /// 物料代码 + /// + public string code { get; set; } = string.Empty; + + /// + /// 物料名称 + /// + public string name { get; set; } = string.Empty; + + /// + /// 物料分类ID + /// + public string category_id { get; set; } = string.Empty; + + /// + /// 单位ID + /// + public string unit_id { get; set; } = string.Empty; + + // /// + // /// 单价 + // /// + // public decimal? cost { get; set; } + // + // /// + // /// 毛重 + // /// + // public decimal? grossweight { get; set; } + // + // /// + // /// 净重 + // /// + // public decimal? netweight { get; set; } + // + // /// + // /// 长 + // /// + // public decimal? length { get; set; } + // + // /// + // /// 宽 + // /// + // public decimal? width { get; set; } + // + // /// + // /// 高 + // /// + // public decimal? high { get; set; } + // + // /// + // /// 体积 + // /// + // public decimal? volumn { get; set; } + // + // /// + // /// 是否免检 + // /// + // public int? isexemption { get; set; } + + /// + /// 安全库存 + /// + public decimal? safeqty { get; set; } + + /// + /// 保质期 + /// + public int? qualityperiod { get; set; } + + // /// + // /// 是否过期允许出库 + // /// + // public string? expireout { get; set; } + + /// + /// 最小包装 + /// + public decimal? minpacking { get; set; } + + /// + /// 是否先进先出管控 + /// + public string? fifo { get; set; } + + // /// + // /// 先进先出间隔天数,批次间隔天数 + // /// + // public int? fifo_interval_days { get; set; } + + /// + /// 物料规格型号 + /// + public string? material_standard { get; set; } + + // /// + // /// 海关编码 + // /// + // public string? fhscode { get; set; } + + // /// + // /// 附属性 + // /// + // public string? attribute { get; set; } + + // /// + // /// 管控类型: 批管控:Lot 单管控:KeyParts 非管控:NoControl + // /// + // public string? controltype { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + // /// + // /// 创建用户 + // /// + // public string? create_id { get; set; } + + /// + /// 创建用户 + /// + public string? create_count { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + // /// + // /// 修改用户 + // /// + // public string? modify_id { get; set; } + + /// + /// 修改用户 + /// + public string? modify_count { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + // /// + // /// 扩展字段 + // /// + // public string? extras { get; set; } + + /// + /// 状态 + /// + public string? state { get; set; } + + /// + /// 物料属性 + /// + public string? material_property { get; set; } + + /// + /// 标签 + /// + public string? label { get; set; } + + /// + /// 描述 + /// + public string? descrip { get; set; } + + /// + /// 批次管理 + /// + public int? is_batch_enabled { get; set; } + + /// + /// 标签管理 + /// + public int? is_label_enabled { get; set; } + + // /// + // /// 附件 + // /// + // public string? attachment { get; set; } + + /// + /// 先进先出 0否 1是 + /// + public int? first_in_out { get; set; } + + /// + /// 存储有效期(天) + /// + public int? storage_valid_day { get; set; } + + /// + /// 预警提前期(天) + /// + public int? early_warn_day { get; set; } + + /// + /// 安全库存 + /// + public int? safe_stock { get; set; } + + /// + /// 安全库存包含状态 + /// + public string? safe_stock_stauts { get; set; } + + /// + /// 发料仓库id + /// + public string? send_warehouse_id { get; set; } + + /// + /// 入厂单位id + /// + public string? into_factory_unit_id { get; set; } + + /// + /// 投料单位 + /// + public string? material_in_unit_id { get; set; } + + /// + /// 产出单位 + /// + public string? material_out_unit_id { get; set; } + + /// + /// 请料方式 1按计划排程请料 2自行管控 + /// + public string? material_request_method { get; set; } + + /// + /// 是否包含入库数 + /// + public int? is_contain_into_num { get; set; } + + /// + /// 是否创建子工单 + /// + public string? is_create_sub_work_order { get; set; } + + /// + /// 保质期 + /// + public int? quality_guarantee_period { get; set; } + + /// + /// DI编码 + /// + public string? di { get; set; } + + } + + public class ErpBasMaterialUnit + { + /// + /// 主单位数量 + /// + public string? number_of_primary_unit { get; set; } + + /// + /// 辅助单位数量 + /// + public string? number_of_auxiliary_unit { get; set; } + + /// + /// 辅助单位 + /// + public string auxiliary_unit_id { get; set; } = string.Empty; + + } + + public class ErpBasMaterialIntoFactorySpecifications + { + /// + /// 单位id + /// + public string unit_id { get; set; } = string.Empty; + + /// + /// 数量 + /// + public decimal num { get; set; } + } + + public class ErpBasSubstitutionMaterial + { + + /// + /// 替代料编号 + /// + public string sub_material_code { get; set; } = string.Empty; + + /// + /// 替代比例,如1(一个物料可以用一个替代料代替) + /// + public decimal proportion { get; set; } + + } + + public class ErpBasMaterialSendWarehouse + { + + /// + /// 仓库编号 + /// + public string? wh_code { get; set; } + + /// + /// 最大库存 + /// + public int? max_stock { get; set; } + + /// + /// 最小库存 + /// + public int? min_stock { get; set; } + + /// + /// 安全库存 + /// + public int? safe_stock { get; set; } + } + + public class ErpBasMaterialInboundWh + { + + /// + /// 仓库编号 + /// + public string? wh_code { get; set; } + + /// + /// 最大库存 + /// + public int? max_stock { get; set; } + + /// + /// 最小库存 + /// + public int? min_stock { get; set; } + + /// + /// 安全库存 + /// + public int? safe_stock { get; set; } + } +} \ No newline at end of file diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs index 77335163..ceb22bc4 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs @@ -263,5 +263,10 @@ public partial class BasMaterial : BaseEntity /// DI编码 /// public string? di { get; set; } + + /// + /// 删除标志 + /// + public int? deleted { get; set; } } diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterialIntoFactorySpecifications.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterialIntoFactorySpecifications.cs index 952e4a49..cf53bac8 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterialIntoFactorySpecifications.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterialIntoFactorySpecifications.cs @@ -5,7 +5,7 @@ using SqlSugar; namespace Tnb.BasicData.Entities; /// -/// 物料入场规格 +/// 物料入厂规格 /// [SugarTable("bas_material_into_factory_specifications")] public partial class BasMaterialIntoFactorySpecifications : BaseEntity diff --git a/BasicData/Tnb.BasicData/BasMaterialService.cs b/BasicData/Tnb.BasicData/BasMaterialService.cs index 6cb32234..386096b8 100644 --- a/BasicData/Tnb.BasicData/BasMaterialService.cs +++ b/BasicData/Tnb.BasicData/BasMaterialService.cs @@ -6,10 +6,13 @@ using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; +using Mapster; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; +using SQLitePCL; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.BasicData.Entities.Dto; @@ -275,5 +278,185 @@ namespace Tnb.BasicData return ids; } + + + /// + /// 物料新增修改接口 + /// + /// + /// + [HttpPost] + public async Task CreateCreateOrUpdateMaterial(ErpBasMaterialInput input) + { + var db = _repository.AsSugarClient(); + if (input == null) + { + throw Oops.Bah("参数为空"); + } + if (input.bas_material == null) + { + throw Oops.Bah("物料信息为空"); + } + if (!string.IsNullOrEmpty(input.bas_material.code)) + { + throw Oops.Bah("物料编号为空"); + } + if (!string.IsNullOrEmpty(input.bas_material.name)) + { + throw Oops.Bah("物料名称为空"); + } + DbResult result = await db.Ado.UseTranAsync(async () => + { + BasMaterial basMaterial = input.bas_material.Adapt(); + if (!await db.Queryable().AnyAsync(x => x.code == input.bas_material.code)) + { + basMaterial.id = SnowflakeIdHelper.NextId(); + } + + if (!string.IsNullOrEmpty(input.bas_material.create_count)) + { + UserEntity userEntity = await db.Queryable().FirstAsync(x=>x.Account==input.bas_material.create_count); + if (userEntity == null) + { + throw Oops.Bah($"未找到用户{input.bas_material.create_count}"); + } + basMaterial.create_id = userEntity?.Id; + } + + if (!string.IsNullOrEmpty(input.bas_material.modify_count)) + { + UserEntity userEntity = await db.Queryable().FirstAsync(x=>x.Account==input.bas_material.modify_count); + if (userEntity == null) + { + throw Oops.Bah($"未找到用户{input.bas_material.modify_count}"); + } + basMaterial.modify_id = userEntity?.Id; + } + + List basMaterialUnits = new List(); + // List basMaterialIntoFactorySpecificationsList = new List(); + // List basSubstitutionMaterials = new List(); + // List basMaterialSendWarehouses = new List(); + // List basMaterialInboundWhs = new List(); + + if (input.bas_material_units != null && input.bas_material_units.Count > 0) + { + foreach(var item in input.bas_material_units) + { + BasMaterialUnit basMaterialUnit = item.Adapt(); + basMaterialUnit.id = SnowflakeIdHelper.NextId(); + basMaterialUnit.material_id = basMaterial.id; + basMaterialUnits.Add(basMaterialUnit); + } + } + + // if (input.bas_material_into_factory_specificationses != null && input.bas_material_into_factory_specificationses.Count > 0) + // { + // foreach(var item in input.bas_material_into_factory_specificationses) + // { + // BasMaterialIntoFactorySpecifications basMaterialIntoFactorySpecifications = item.Adapt(); + // basMaterialIntoFactorySpecifications.id = SnowflakeIdHelper.NextId(); + // basMaterialIntoFactorySpecifications.material_id = basMaterial.id; + // basMaterialIntoFactorySpecificationsList.Add(basMaterialIntoFactorySpecifications); + // } + // } + // + // if (input.bas_substitution_materials != null && input.bas_substitution_materials.Count > 0) + // { + // foreach(var item in input.bas_substitution_materials) + // { + // BasSubstitutionMaterial basSubstitutionMaterial = item.Adapt(); + // basSubstitutionMaterial.id = SnowflakeIdHelper.NextId(); + // basSubstitutionMaterial.material_id = basMaterial.id; + // BasMaterial subBasMaterial = await db.Queryable().FirstAsync(x=>x.code==item.sub_material_code); + // if (subBasMaterial == null) + // { + // throw Oops.Bah($"未找到替代物料{item.sub_material_code}"); + // } + // basSubstitutionMaterial.sub_material_id = subBasMaterial?.id ?? item.sub_material_code; + // basSubstitutionMaterials.Add(basSubstitutionMaterial); + // } + // } + // + // if (input.bas_material_send_warehouses != null && input.bas_material_send_warehouses.Count > 0) + // { + // foreach(var item in input.bas_material_send_warehouses) + // { + // BasMaterialSendWarehouse basMaterialSendWarehouse = item.Adapt(); + // basMaterialSendWarehouse.id = SnowflakeIdHelper.NextId(); + // basMaterialSendWarehouse.material_id = basMaterial.id; + // BasWarehouse basWarehouse = await db.Queryable().FirstAsync(x=>x.whcode==item.wh_code); + // if (basWarehouse == null) + // { + // throw Oops.Bah($"发料仓库未找到仓库{item.wh_code}"); + // } + // basMaterialSendWarehouse.wh_id = basWarehouse?.id ?? item.wh_code; + // basMaterialSendWarehouses.Add(basMaterialSendWarehouse); + // } + // } + // + // if (input.bas_material_inbound_whs != null && input.bas_material_inbound_whs.Count > 0) + // { + // foreach(var item in input.bas_material_inbound_whs) + // { + // BasMaterialInboundWh basMaterialInboundWh = item.Adapt(); + // basMaterialInboundWh.id = SnowflakeIdHelper.NextId(); + // basMaterialInboundWh.material_id = basMaterial.id; + // BasWarehouse basWarehouse = await db.Queryable().FirstAsync(x=>x.whcode==item.wh_code); + // if (basWarehouse == null) + // { + // throw Oops.Bah($"入库仓库未找到仓库{item.wh_code}"); + // } + // basMaterialInboundWh.wh_id = basWarehouse?.id ?? item.wh_code; + // basMaterialInboundWhs.Add(basMaterialInboundWh); + // } + // } + + if (!await db.Queryable().AnyAsync(x => x.code == input.bas_material.code)) + { + await db.Insertable(basMaterial).ExecuteCommandAsync(); + } + else + { + await db.Updateable(basMaterial).ExecuteCommandAsync(); + } + + // var x= await db.Storageable(basMaterial).ToStorageAsync(); + // await x.AsInsertable.ExecuteCommandAsync();//不存在插入 + // await x.AsUpdateable.ExecuteCommandAsync();//存在更新 + + if (basMaterialUnits.Count > 0) + { + await db.Deleteable().Where(x=>x.material_id==basMaterial.id).ExecuteCommandAsync(); + await db.Insertable(basMaterialUnits).ExecuteCommandAsync(); + } + + // if (basMaterialIntoFactorySpecificationsList.Count > 0) + // { + // await db.Deleteable().Where(x=>x.material_id==basMaterial.id).ExecuteCommandAsync(); + // await db.Insertable(basMaterialIntoFactorySpecificationsList).ExecuteCommandAsync(); + // } + // + // if (basSubstitutionMaterials.Count > 0) + // { + // await db.Deleteable().Where(x=>x.material_id==basMaterial.id).ExecuteCommandAsync(); + // await db.Insertable(basSubstitutionMaterials).ExecuteCommandAsync(); + // } + // + // if (basMaterialSendWarehouses.Count > 0) + // { + // await db.Deleteable().Where(x=>x.material_id==basMaterial.id).ExecuteCommandAsync(); + // await db.Insertable(basMaterialSendWarehouses).ExecuteCommandAsync(); + // } + // + // if (basMaterialInboundWhs.Count > 0) + // { + // await db.Deleteable().Where(x=>x.material_id==basMaterial.id).ExecuteCommandAsync(); + // await db.Insertable(basMaterialInboundWhs).ExecuteCommandAsync(); + // } + + }); + return !result.IsSuccess ? throw Oops.Oh(result.ErrorMessage) : "保存成功"; + } } } \ No newline at end of file From 5012f1b08dd23c3a6c083cd57e3304a68ebb66a5 Mon Sep 17 00:00:00 2001 From: "tao.zhang" <865692298@qq.com> Date: Mon, 11 Dec 2023 09:34:16 +0800 Subject: [PATCH 6/8] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 40bbc9cb..0e8e426b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -66,7 +66,7 @@ namespace Tnb.WarehouseMgr var blFlag = true; try { - + string a; await _db.Ado.BeginTranAsync(); WmsInstockH? instock = null; var purchaseDs = await PurchaseAndSaleUpdate(input); From 7a9820e7b768dddc61d4d5fd99462e67cf38cde7 Mon Sep 17 00:00:00 2001 From: "tao.zhang" <865692298@qq.com> Date: Mon, 11 Dec 2023 09:35:41 +0800 Subject: [PATCH 7/8] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 0e8e426b..d6348e64 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -66,7 +66,6 @@ namespace Tnb.WarehouseMgr var blFlag = true; try { - string a; await _db.Ado.BeginTranAsync(); WmsInstockH? instock = null; var purchaseDs = await PurchaseAndSaleUpdate(input); From 67206206e4fd2f4366e44c42bbfa930adfea97e8 Mon Sep 17 00:00:00 2001 From: "tao.zhang" <865692298@qq.com> Date: Mon, 11 Dec 2023 09:36:29 +0800 Subject: [PATCH 8/8] ceishi --- WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index d6348e64..6c61e35f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -66,6 +66,8 @@ namespace Tnb.WarehouseMgr var blFlag = true; try { + + await _db.Ado.BeginTranAsync(); WmsInstockH? instock = null; var purchaseDs = await PurchaseAndSaleUpdate(input);