Files
WMS-Api/src/WMS.Web.Domain/Entitys/BoxMark.cs
tongfei 896450fd23 优化
2024-03-18 11:03:51 +08:00

138 lines
3.8 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.Text;
using WMS.Web.Core;
namespace WMS.Web.Domain.Entitys
{
/// <summary>
/// 箱唛表
/// </summary>
[Serializable]
[Table("t_wms_box_mark")]
public class BoxMark : EntityBase
{
/// <summary>
/// ID
/// </summary>
public override int Id { get; set; }
/// <summary>
/// 订单编号
/// </summary>
public string OrderBillNo { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string MaterialNumber { get; set; }
/// <summary>
/// 产品数量
/// </summary>
public decimal ProductQty { get; set; }
/// <summary>
/// 装箱数量
/// </summary>
public decimal CratingQty { get; set; }
/// <summary>
/// 装箱净重
/// </summary>
public decimal CratingNetWeightQty { get; set; }
/// <summary>
/// 装箱毛重
/// </summary>
public decimal CratingGrossWeightQty { get; set; }
/// <summary>
/// 尾箱数量
/// </summary>
public decimal TailboxQty { get; set; }
/// <summary>
/// 尾箱净重
/// </summary>
public decimal TailboxNetWeightQty { get; set; }
/// <summary>
/// 尾箱毛重
/// </summary>
public decimal TailboxGrossWeightQty { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 操作人
/// </summary>
public int CreatorId { get; set; }
/// <summary>
/// 创建时间(生成时间)
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 编号集合
/// </summary>
public List<BoxMarkBillNo> BillNos { get; set; } = new List<BoxMarkBillNo>();
/// <summary>
/// 创建
/// </summary>
/// <param name="creatorId"></param>
public void Create(int creatorId)
{
this.CreatorId = creatorId;
this.CreateTime = DateTime.Now;
}
/// <summary>
/// 生成编号
/// </summary>
/// <param name="firstBillNo"></param>
/// <param name="lastBillNo"></param>
public void GenerateBillNo(int firstBillNo, int lastBillNo)
{
if (this.BillNos == null)
this.BillNos = new List<BoxMarkBillNo>();
//计算要装的箱数量
var boxCount_tag = this.ProductQty / this.CratingQty;
var boxCount = Convert.ToInt32(boxCount_tag);
//判断是否存在小数点true表明有尾箱数,false没有尾箱数
var hasPart = Math.Floor(boxCount_tag) != boxCount_tag;
//有小数点向上取整
if (hasPart)
boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag));
for (int i = 1; i <= boxCount; i++)
{
//添加编号生成
var bill = new BoxMarkBillNo();
bill.Sort = i;
if (hasPart && i == boxCount && boxCount>1)
bill.IsTail = true;
bill.GenerateBillNo(firstBillNo, lastBillNo);
this.BillNos.Add(bill);
//改变前后的billNo值,新的值再一次被使用
firstBillNo = bill.FirstBillNo;
lastBillNo = bill.LastBillNo;
}
//判断有小数点,那么它就有尾箱,把当前第一条的编号是否是尾箱字段改为true
//if (this.BillNos.Count != 0 && hasPart)
// this.BillNos[0].IsTail = true;
}
}
}