abp(net core)+easyui+efcore实现仓储管理系统——入库管理之一(三十七)

abp(net core)+easyui+efcore实现仓储管理系统目录

abp(net core)+easyui+efcore实现仓储管理系统——EasyUI前端页面框架 (十八)

abp(net core)+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之八(三十四)

 

.前言

   通过前面的文章( abp(net core)+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之一(二十七) abp(net core)+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之十(三十六) )的学习,我们已经有实现了使用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三张表创建成功。

 

posted @ 2020-02-21 17:22  DotNet菜园  阅读(2356)  评论(2编辑  收藏  举报