Files
WMS-Api/src/WMS.Web.Domain/Entitys/InstockTask.cs
tongfei 7366fc8e27 实体
2024-01-08 14:42:47 +08:00

180 lines
5.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using WMS.Web.Core;
using WMS.Web.Domain.Values;
namespace WMS.Web.Domain.Entitys
{
/// <summary>
/// erp入库任务表
/// </summary>
[Serializable]
[Table("t_erp_instock_task")]
public class InStockTask : EntityBase
{
/// <summary>
/// ID
/// </summary>
public override int Id { get; set; }
/// <summary>
/// 单据编号
/// </summary>
public string BillNo { get; set; }
/// <summary>
/// 来源单号
/// </summary>
public string SourceBillNo { get; set; }
/// <summary>
/// 入库状态
/// </summary>
public InstockStatus Status { get; set; }
/// <summary>
/// 入库类型
/// </summary>
public InstockType Type { get; set; }
/// <summary>
/// 收货人
/// </summary>
public int? ReceiverId { get; set; }
/// <summary>
/// 收货时间
/// </summary>
public DateTime? ReceiveTime { get; set; }
/// <summary>
/// 上架人
/// </summary>
public int? ShelferId { get; set; }
/// <summary>
/// 入库时间(上架时间)
/// </summary>
public DateTime? ShelfTime { get; set; }
/// <summary>
/// 创建时间erp那边的创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 作废人
/// </summary>
public int? RepealerId { get; set; }
/// <summary>
/// 作废时间
/// </summary>
public DateTime? RepealTime { get; set; }
/// <summary>
/// 明细
/// </summary>
public List<InStockTaskDetails> Details { get; set; }
/// <summary>
/// 创建
/// </summary>
/// <param name="type"></param>
/// <param name="sourceBillNo"></param>
/// <param name="createTime"></param>
public void Create(InstockType type,string sourceBillNo, DateTime createTime)
{
if (type == InstockType.Purchase)
this.Status = InstockStatus.Wait;
else
this.Status = InstockStatus.WaitInStock;
this.Type = type;
this.SourceBillNo = sourceBillNo;
this.CreateTime = createTime;
}
/// <summary>
/// 作废
/// </summary>
public void Repeal(int repealerId)
{
this.Status = InstockStatus.Repeal;
this.RepealerId = repealerId;
this.RepealTime= DateTime.Now;
}
/// <summary>
/// 创建订单号
/// </summary>
/// <param name="newId"></param>
public void MakeBillNo(int newId)
{
//生成订单号
var length = newId.ToString().Length;
if (length >= 8)
{
this.BillNo = $"RKRW{newId.ToString()}";
}
else
{
var needLength = 8 - length;
var needStr = "";
for (int i = 0; i < needLength; i++)
{
needStr += "0";
}
this.BillNo = "RKRW" + needStr + newId.ToString();
}
}
/// <summary>
/// 收货
/// </summary>
/// <param name="creatorId"></param>
public void Receive(int creatorId)
{
this.Status = InstockStatus.WaitInStock;
this.ReceiverId = creatorId;
this.ReceiveTime = DateTime.Now;
}
/// <summary>
/// 上架
/// </summary>
/// <param name="creatorId"></param>
public void Shelf(int creatorId)
{
//明细中:所有的应入数量之和
var totalAccruedQty= this.Details.Sum(x => x.AccruedQty);
//明细中:所有的收货数量之和
var totalReceiveQty = this.Details.Sum(x => x.ReceiveQty);
if (totalAccruedQty == totalReceiveQty)
this.Status = InstockStatus.Already;
else
this.Status = InstockStatus.Part;
this.ShelferId = creatorId;
this.ShelfTime = DateTime.Now;
}
/// <summary>
/// 非采购上架
/// </summary>
/// <param name="creatorId"></param>
public void NoPurchaseShelf(int creatorId)
{
//明细中:所有的应入数量之和
var totalAccruedQty = this.Details.Sum(x => x.AccruedQty);
//明细中:所有的收货数量之和
var totalReceiveQty = this.Details.Sum(x => x.ReceiveQty);
if (totalAccruedQty == totalReceiveQty)
this.Status = InstockStatus.Already;
else
this.Status = InstockStatus.Part;
this.ReceiverId = creatorId;
this.ReceiveTime = DateTime.Now;
this.ShelferId = creatorId;
this.ShelfTime = DateTime.Now;
}
}
}