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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM