abp(net core)+easyui+efcore实现仓储治理系统——入库治理之一(三十七)
什么?接口中方法可以不是抽象的「JDK8接口新语法的深度思考」
一.媒介
经由历程前面的文章( 至)的进修,我们已有完成了运用ABP供应的WebAPI体式格局+EasyUI来完成增编削查的功用。之前我们把一些基本的信息已完成了,如货色信息,供应商信息。有了前面的基本信息,我们能够完成入库治理功用。从本章入手下手我们来进修一个入库单功用,这个将会触及DataGrid的主从功用。
二、入库单的流程
1.平常状况下会有一个前置的OMS体系——即定单治理体系。主要功用之一是由供应商填写送货单。
假如公司有货代、仓储、运输等营业,或者是给某些大型客户(比方宜家、遐想等)做第三方的物流效劳,那末在做物流体系时入库单流程时,须要斟酌入库单的前置流程——定单治理体系。
定单治理体系(OMS)是物流信息治理体系的一部分,经由历程对客户下达的定单举行治理及跟踪,动态控制定单的希望和完成状况,提拔物流历程当中的功课效力,从而节约运作时候和功课本钱,进步物流企业的市场竞争力。望文生义,定单治理体系是物流企业用户、供应商用户、客户关于定单的管控、跟踪的体系,衔接着WMS、运输治理体系、订舱体系等,是物流信息治理体系的基本模块。
简朴地说定单治理体系作为全部物流信息治理体系的基本中心,治理着一切的生意业务收支。一个好的定单治理体系须要有很好地扩大性和流通性,在一个物流信息治理体系从0-1的历程,定单治理体系作为其基本模块须要提早斟酌到各体系的扩大,定单治理体系假如在前期就可以斟酌到背面的扩大,置信关于物流企业的壮大会异常有协助。
流通性指的是全部生意业务链路须要很流通,初期公司做定单体系时,想的很庞杂,想做的很周全,末了做的异常巨大,然则却没有斟酌到全部物流流程的通行性,致使连基本的定单流程都没有方法一般走下去,所以,在从0到1地做一套定单治理体系时,须要有一些前瞻性,但落地时,须要先完成一个能够把全部流程走下去的简朴的定单治理体系,然后不停的去试错->革新。
2.当运输公司把货色送到堆栈时,堆栈会有检验员举行抽检,并制造入库单,分派库位,然后打印标签,粘贴条码标签,分派托盘,核验条码标签,货色上架,并在体系中对入库单举行考核经由历程。全部流程以下图。
固然我们接下来要完成的入库单功用,没有这么庞杂。 我们没有完成定单治理体系,这个有时候背面补上。
三、建立入库单实体
1. 做为一个入库单,在数据库中平常存在三张表,表头InStockOrder,表体InStockDetail、库位表InStockDetailLoc。
2.在Visual Studio 2017的“解决方案资源治理器”中,右键单击“ABP.TPLMS.Core”项目的“Entitys”文件夹,在弹出菜单中挑选“增加” >
> “类”。 将类命名为 InStockOrder,然后挑选“增加”。
3.建立InStockOrder类继续自Entity<int>,经由历程完成审计模块中的IHasCreationTime来完成保留建立时候。代码以下:
using Abp.Domain.Entities; using Abp.Domain.Entities.Auditing; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; namespace ABP.TPLMS.Entitys { public class InStockOrder : Entity<int>, IHasCreationTime { public const int MaxLength = 255; public InStockOrder() { No = string.Empty; CustomerCode = string.Empty; CustomerName = string.Empty; WarehouseNo = string.Empty; WarehouseType = string.Empty; DeliveryNo = string.Empty; Receiver = string.Empty; ReceiveTime = string.Empty; CreationTime = DateTime.Now; Oper = string.Empty; Checker = string.Empty; CheckTime = string.Empty; Gwt = 0; Nwt = 0; PackageNum = 0; OwnerCode = string.Empty; OwnerName = string.Empty; Remark = string.Empty; Status = 0; PreDeliveryTime = string.Empty; } [StringLength(50)] [Required] public string No { get; set; } /// <summary> /// 客户称号 /// </summary> [StringLength(MaxLength)] [Required] public string CustomerName { get; set; } public string WarehouseType { get; set; } /// <summary> /// 客户代码 /// </summary> [StringLength(50)] [Required] public string CustomerCode { get; set; } /// <summary> /// 送货单号 /// </summary> public string DeliveryNo { get; set; } /// <summary> /// 堆栈号 /// </summary> public string WarehouseNo { get; set; } /// <summary> /// 货主 /// </summary> [StringLength(MaxLength)] [Required] public string OwnerName { get; set; } public decimal Gwt { get; set; } public decimal Nwt { get; set; } public int PackageNum { get; set; } /// <summary> /// 吸收时候 /// </summary> [StringLength(20)] public string ReceiveTime { get; set; } /// <summary> /// 吸收人 /// </summary> [StringLength(50)] public string Receiver { get; set; } [StringLength(50)] public string Oper { get; set; } public int Status { get; set; } [StringLength(50)] public string OwnerCode { get; set; } /// <summary> /// 估计送货时候 /// </summary> [StringLength(20)] public string PreDeliveryTime { get; set; } /// <summary> /// 考核人 /// </summary> [StringLength(50)] public string Checker { get; set; } [StringLength(20)] public string CheckTime { get; set; } [StringLength(1000)] public string Remark { get; set; } public DateTime CreationTime { get; set; } [StringLength(20)] public string LastUpdateTime { get; set; } [StringLength(50)] public string LastOper { get; set; } [NotMapped] public List<InStockOrderDetail> InStockOrderDetail { get; set; } } }
4.重得第2,3步,我们在“ABP.TPLMS.Core”项目的“Entitys”文件夹,顺次建立InStockOrderDetail与InStockOrderDetailLoc两个类。代码以下:
using Abp.Domain.Entities; using Abp.Domain.Entities.Auditing; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; namespace ABP.TPLMS.Entitys { public class InStockOrderDetail : Entity<int>, IHasCreationTime { public const int MaxLength = 255; public InStockOrderDetail() { this.Qty = 0; this.CargoCode = string.Empty; this.CargoName = string.Empty; this.Brand = string.Empty; this.Country = string.Empty; this.CreationTime = DateTime.Now; this.Curr = string.Empty; this.GrossWt = 0; this.Height = 0; this.HSCode = string.Empty; this.Length = 0; this.SecdLawfQty = 0; this.LawfQty = 0; this.NetWt = 0; this.Package = string.Empty; this.Price = 0; this.Spcf = string.Empty; this.Unit = string.Empty; this.InStockNo = string.Empty; this.LawfUnit = string.Empty; this.Vol = 0; this.Width = 0; this.LawfUnit = string.Empty; this.SecdLawfUnit = string.Empty; this.SeqNo = 0; this.Batch = string.Empty; this.DeliveryOrderDetailId = 0; } public int SupplierId { get; set; } [MaxLength(50)] public string CargoCode { get; set; } [MaxLength(10)] public string HSCode { get; set; } [MaxLength(MaxLength)] public string CargoName { get; set; } [MaxLength(MaxLength)] public string Spcf { get; set; } [MaxLength(20)] public string Unit { get; set; } [MaxLength(20)] public string Country { get; set; } [MaxLength(50)] public string Brand { get; set; } [MaxLength(20)] public string Curr { get; set; } [MaxLength(20)] public string Package { get; set; } public decimal Length { get; set; } public decimal Width { get; set; } public decimal Height { get; set; } public decimal Vol { get; set; } public decimal Price { get; set; } public decimal TotalAmt { get; set; } public decimal GrossWt { get; set; } public decimal NetWt { get; set; } public DateTime CreationTime { get; set; } [MaxLength(20)] public string InStockNo { get; set; } public int SeqNo { get; set; } public decimal Qty { get; set; } public decimal LawfQty { get; set; } public decimal SecdLawfQty { get; set; } [MaxLength(20)] public string LawfUnit { get; set; } [MaxLength(20)] public string SecdLawfUnit { get; set; } [MaxLength(20)] public string Batch { get; set; } public int DeliveryOrderDetailId { get; set; } [NotMapped] public List<InStockOrderDetailLoc> InStockOrderDetailLoc { get; set; } } }
using Abp.Domain.Entities; using Abp.Domain.Entities.Auditing; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Text; namespace ABP.TPLMS.Entitys { public class InStockOrderDetailLoc : Entity<int>, IHasCreationTime { public InStockOrderDetailLoc() { this.Qty = 0; this.SeqNo = 0; this.Loc = string.Empty; this.CreationTime = DateTime.Now; this.InStockOrderDetailId = 0; } public int InStockOrderDetailId { get; set; } public int SeqNo { get; set; } [StringLength(50)] public string Loc { get; set; } public decimal Qty { get; set; } public DateTime CreationTime { get; set; } } }
5.定义入库单的实体以后,我们去“ABP.TPLMS.EntityFrameworkCore”项目中的“TPLMSDbContext”类中定义实体对应的DbSet,以运用Code First 数据迁徙。增加以下代码
using Microsoft.EntityFrameworkCore; using Abp.Zero.EntityFrameworkCore; using ABP.TPLMS.Authorization.Roles; using ABP.TPLMS.Authorization.Users; using ABP.TPLMS.MultiTenancy; using ABP.TPLMS.Entitys; namespace ABP.TPLMS.EntityFrameworkCore { public class TPLMSDbContext : AbpZeroDbContext<Tenant, Role, User, TPLMSDbContext> { /* Define a DbSet for each entity of the application */ public TPLMSDbContext(DbContextOptions<TPLMSDbContext> options) : base(options) { } public DbSet<Module> Modules { get; set; } public DbSet<Supplier> Suppliers { get; set; } public DbSet<Cargo> Cargos { get; set; } public DbSet<Org> Orgs { get; set; } public virtual DbSet<InStockOrder> InStockOrder { get; set; } public virtual DbSet<InStockOrderDetail> InStockOrderDetail { get; set; } public virtual DbSet<InStockOrderDetailLoc> InStockOrderDetailLoc { get; set; } } }
6.从菜单中挑选“东西->NuGet包治理器器—>程序包治理器控制台”菜单。
7. 在PMC中,默许项目挑选EntityframeworkCore对应的项目后。输入以下敕令:Add-Migration AddEntityInStock,建立迁徙。以下图。
8. 在上面的敕令实行终了以后,建立胜利后,会在Migrations文件夹下建立时候_AddEntityInStock花样的类文件,这些代码是基于DbContext指定的模子。以下图。
9.在程序包治理器控制台,输入Update-Database,回车实行迁徙。实行胜利后,以下图。
10. 在SQL Server Management Studio中检察数据库,InStockOrder、InStockOrderDetail、InStockOrderDetailLoc三张表建立胜利。
## springboot 下策略模式的简单使用