119 lines
3.5 KiB
C#
119 lines
3.5 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.DataAnnotations.Schema;
|
||
using System.Text;
|
||
using WMS.Web.Core;
|
||
using WMS.Web.Domain.Values;
|
||
|
||
namespace WMS.Web.Domain.Entitys
|
||
{
|
||
/// <summary>
|
||
/// wms盘点单
|
||
/// </summary>
|
||
[Serializable]
|
||
[Table("t_wms_takestock")]
|
||
public class TakeStock : EntityBase
|
||
{
|
||
public TakeStock() { }
|
||
/// <summary>
|
||
/// 主键 订单编号
|
||
/// </summary>
|
||
[Column("Id")]
|
||
public override int Id { get; set; }
|
||
/// <summary>
|
||
/// 单据编号
|
||
/// </summary>
|
||
[Column("BillNo")]
|
||
public string BillNo { get; set; }
|
||
/// <summary>
|
||
/// 盘点日期
|
||
/// </summary>
|
||
[Column("Date")]
|
||
public DateTime Date { get; set; } = DateTime.Now;
|
||
/// <summary>
|
||
/// 盘点人员
|
||
/// </summary>
|
||
[Column("CreatorId")]
|
||
public int CreatorId { get; set; }
|
||
/// <summary>
|
||
/// 同步状态
|
||
/// </summary>
|
||
[Column("SuccessSync")]
|
||
public SyncStatus SuccessSync { get; set; } = SyncStatus.Success;
|
||
/// <summary>
|
||
/// 盘点结果类型:1为盘盈,2位盘亏
|
||
/// 盘点数量-系统库存 大于0为盘盈 小于0为盘亏
|
||
/// </summary>
|
||
[Column("ResultType")]
|
||
public TakeStockType ResultType { get; set; } = TakeStockType.Profit;
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
[Column("FailRemark")]
|
||
public string FailRemark { get; set; }
|
||
/// <summary>
|
||
/// 同步到金蝶后金蝶的单据Id
|
||
/// </summary>
|
||
[Column("ErpSyncBillNo")]
|
||
public string ErpSyncBillNo { get; set; }
|
||
/// <summary>
|
||
/// 明细
|
||
/// </summary>
|
||
public List<TakeStockDetails> Details { get; set; } = new List<TakeStockDetails>();
|
||
/// <summary>
|
||
/// 创建
|
||
/// </summary>
|
||
/// <param name="creatorId"></param>
|
||
public void Create(int creatorId, TakeStockType resultType)
|
||
{
|
||
this.ResultType = resultType;
|
||
this.CreatorId = creatorId;
|
||
this.Date = DateTime.Now;
|
||
}
|
||
/// <summary>
|
||
/// 同步金蝶结果
|
||
/// </summary>
|
||
/// <param name="isSuccess"></param>
|
||
/// <param name="remark"></param>
|
||
public void Sync(bool isSuccess, string remark, SyncStatus syncStatus,string erpBillNo)
|
||
{
|
||
this.SuccessSync = syncStatus;
|
||
this.FailRemark = remark;
|
||
this.ErpSyncBillNo = erpBillNo;
|
||
}
|
||
/// <summary>
|
||
/// 重传
|
||
/// </summary>
|
||
public void RepeatSync()
|
||
{
|
||
//只有完全失败的情况下才能重传
|
||
if (this.SuccessSync != SyncStatus.Fail) return;
|
||
this.SuccessSync = SyncStatus.SyncIng;
|
||
this.FailRemark = "";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 生成单据号
|
||
/// </summary>
|
||
public void GenerateNo()
|
||
{
|
||
//用户手动输入了 就不自动生成了
|
||
if (!string.IsNullOrEmpty(this.BillNo)) return;
|
||
|
||
if (this.Id.ToString().Length >= 8)
|
||
{
|
||
this.BillNo = "PD" + this.Id.ToString();
|
||
return;
|
||
}
|
||
|
||
string idStr = this.Id.ToString();
|
||
while (true)
|
||
{
|
||
idStr = "0" + idStr;
|
||
if (idStr.Length >= 8) break;
|
||
}
|
||
this.BillNo = "PD" + idStr;
|
||
}
|
||
}
|
||
}
|