1. 程式人生 > >abp(net core)+easyui+efcore實現倉儲管理系統——入庫管理之一(三十七)

abp(net core)+easyui+efcore實現倉儲管理系統——入庫管理之一(三十七)

abp(net core)+easyui+efcore實現倉儲管理系統目錄

abp(net core)+easyui+efcore實現倉儲管理系統——ABP總體介紹(一) abp(net core)+easyui+efcore實現倉儲管理系統——解決方案介紹(二) abp(net core)+easyui+efcore實現倉儲管理系統——領域層建立實體(三)  abp(net core)+easyui+efcore實現倉儲管理系統——定義倉儲並實現 (四) abp(net core)+easyui+efcore實現倉儲管理系統——建立應用服務(五) abp(net core)+easyui+efcore實現倉儲管理系統——展現層實現增刪改查之控制器(六) abp(net core)+easyui+efcore實現倉儲管理系統——展現層實現增刪改查之列表檢視(七) abp(net core)+easyui+efcore實現倉儲管理系統——展現層實現增刪改查之增刪改檢視(八) abp(net core)+easyui+efcore實現倉儲管理系統——展現層實現增刪改查之選單與測試(九) abp(net core)+easyui+efcore實現倉儲管理系統——多語言(十) abp(net core)+easyui+efcore實現倉儲管理系統——使用 WEBAPI實現CURD (十一) abp(net core)+easyui+efcore實現倉儲管理系統——選單-上 (十六)

abp(net core)+easyui+efcore實現倉儲管理系統——EasyUI前端頁面框架 (十八)

abp(net core)+easyui+efcore實現倉儲管理系統——EasyUI之貨物管理一 (十九) 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(net core)+easyui+efcore實現倉儲管理系統——ABP WebAPI與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三張表建立成功。