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

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

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

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的主从功能app

2、入库单的流程框架

      1.通常状况下会有一个前置的OMS系统——即订单管理系统。主要功能之一是由供应商填写送货单。工具

   若是公司有货代、仓储、运输等业务,或者是给某些大型客户(例如宜家、联想等)作第三方的物流服务,那么在作物流系统时入库单流程时,须要考虑入库单的前置流程——订单管理系统。post

   订单管理系统(OMS)是物流信息管理系统的一部分,经过对客户下达的订单进行管理及跟踪,动态掌握订单的进展和完成状况,提高物流过程当中的做业效率,从而节省运做时间和做业成本,提升物流企业的市场竞争力。顾名思义,订单管理系统是物流企业用户、供应商用户、客户对于订单的管控、跟踪的系统,衔接着WMS、运输管理系统、订舱系统等,是物流信息管理系统的基础模块。学习

   简单地说订单管理系统做为整个物流信息管理系统的基础核心,管理着全部的交易进出。一个好的订单管理系统须要有很好地扩展性和流畅性,在一个物流信息管理系统从0-1的过程,订单管理系统做为其基础模块须要提早考虑到各系统的扩展,订单管理系统若是在前期就能考虑到后面的扩展,相信对于物流企业的壮大会很是有帮助。测试

   流畅性指的是整个交易链路须要很流畅,早期公司作订单系统时,想的很复杂,想作的很全面,最后作的很是庞大,可是却没有考虑到整个物流流程的通畅性,致使连基础的订单流程都没有办法正常走下去,因此,在从0到1地作一套订单管理系统时,须要有一些前瞻性,但落地时,须要先实现一个能够把整个流程走下去的简单的订单管理系统,而后不断的去试错->改进。ui

     2.当运输公司把货物送到仓库时,仓库会有检验员进行抽检,并制做入库单,分配库位,而后打印标签,粘贴条码标签,分配托盘,核验条码标签,货物上架,并在系统中对入库单进行审核经过。整个流程以下图。

 

    固然咱们接下来要实现的入库单功能,没有这么复杂。 咱们没有实现订单管理系统,这个有时间后面补上。

 

3、建立入库单实体

  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三张表建立成功。

 

相关文章
相关标签/搜索