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

 

相關文章
相關標籤/搜索