using Rhea.Common;
|
using Tiger.Model;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Threading.Tasks;
|
using System.Linq;
|
using Newtonsoft.Json;
|
using Rhea.Common.Authorization;
|
using Newtonsoft.Json.Linq;
|
using Tiger.Model.Minsun;
|
using System.Globalization;
|
using System.Data;
|
using Tiger.IBusiness;
|
|
namespace Tiger.Business.WMS
|
{
|
public partial class iWMS
|
{
|
/// <summary>
|
/// 通用批量入库
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public static ApiAction MultiInStorageAsync(MultiInvInStorageInput input)
|
{
|
var action = new ApiAction();
|
try
|
{
|
string flag = "";
|
//保存到数据库
|
var db = Business.Biz.Db;
|
var dbTran = db.UseTran(() =>
|
{
|
//插入或更新 InvBarcode
|
var x = db.Storageable(input.InvBarcodes)
|
.WhereColumns(t => new { t.BARCODE })
|
.ToStorage();
|
x.AsInsertable.ExecuteCommand();
|
x.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
|
flag = "InvBarcode更新成功";
|
#region 插入 InvStorageLotInfo
|
var y = db.Storageable(input.InvStorageLotInfos)
|
.WhereColumns(t => new { t.BARCODE })
|
.ToStorage();
|
y.AsInsertable.ExecuteCommand();
|
y.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
|
flag += "; InvStorageLotInfo更新成功";
|
#endregion
|
|
#region 插入 InvStorageInfo
|
var z = db.Storageable(input.InvStorageInfos)
|
.WhereColumns(t => new { t.WAREHOUSECODE, t.MATERIALCODE })
|
.ToStorage();
|
z.AsInsertable.ExecuteCommand();
|
z.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
|
#endregion
|
flag += "; InvStorageInfo更新成功";
|
#region 插入 InvScanMain 和 InvScanDetail
|
|
var m = db.Storageable(input.InvScanMains)
|
.ToStorage();
|
m.AsInsertable.IgnoreColumns(t => t.LastModificationTime).ExecuteCommand();
|
|
var o = db.Storageable(input.InvScanDetails)
|
.WhereColumns(t => new { t.SCANMAINID, t.SOURCEDETAILLINE, t.WAREHOUSECODE, t.MATERIALCODE })
|
.ToStorage();
|
o.AsInsertable.ExecuteCommand();
|
o.AsUpdateable.IgnoreColumns(t => t.Id).ExecuteCommand();
|
#endregion
|
flag += "; InvScanMain更新成功";
|
#region 插入 InvBarcodeLog
|
db.Insertable(input.InvBarcodeLogs).ExecuteCommand();
|
#endregion
|
flag += "; 入库成功";
|
});
|
if (!dbTran.IsSuccess)
|
{
|
action.IsSuccessed = false;
|
action.Message = $"{flag} Error:{dbTran.ErrorException.Message}";
|
action.Data = new MultiInvInStorageOutput
|
{
|
Message = $"{flag} Error:{dbTran.ErrorException.Message}",
|
InvBarcodes = input.InvBarcodes
|
};
|
//throw dbTran.ErrorException;
|
}
|
}
|
catch (System.Exception ex)
|
{
|
action.CatchExceptionWithLog(ex, $"入库异常");
|
}
|
action.Message = "OK";
|
action.Data = new MultiInvInStorageOutput
|
{
|
Message = "OK",
|
InvBarcodes = input.InvBarcodes
|
};
|
return action;
|
}
|
|
/// <summary>
|
/// 获得到货单完成信息
|
/// </summary>
|
/// <param name="billcode"></param>
|
/// <param name="materialCode"></param>
|
/// <returns></returns>
|
public static string GetERP_RECEIPTTips(string billcode, string materialCode)
|
{
|
var tips = "";
|
var otherInDetails = Biz.Db.Queryable<BIZ_ERP_RECEIPT_SN>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
|
&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
|
&& t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
|
//if (otherInDetails.Any())
|
{
|
tips += $"数量:{otherInDetails.Sum(q => q.SCANQTY):N0}";
|
}
|
var otherInScanList = Biz.Db.Queryable<BIZ_ERP_RECEIPT_SN>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
|
&& t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
|
&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()).ToList();
|
//if (otherInScanList.Any())
|
{
|
tips += $" ({otherInScanList.Count()} 盘)";
|
}
|
return tips;
|
}
|
/// <summary>
|
/// 获得到货单完成信息
|
/// </summary>
|
/// <param name="billcode"></param>
|
/// <param name="materialCode"></param>
|
/// <returns></returns>
|
public static string GetERP_ReturnTips(string billcode, string materialCode)
|
{
|
var tips = "";
|
var otherInDetails = Biz.Db.Queryable<BIZ_ERP_PROD_RETURN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
|
//&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
|
&& t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
|
//if (otherInDetails.Any())
|
{
|
tips += $"数量:{otherInDetails.Sum(q => q.QTY):N0}";
|
}
|
var otherInScanList = Biz.Db.Queryable<BIZ_ERP_PROD_RETURN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
|
&& t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
|
//&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
|
).ToList();
|
//if (otherInScanList.Any())
|
{
|
tips += $" ({otherInScanList.Count()} 盘)";
|
}
|
return tips;
|
}
|
|
/// <summary>
|
/// 获得其他入库单完成信息
|
/// </summary>
|
/// <param name="billcode"></param>
|
/// <param name="materialCode"></param>
|
/// <returns></returns>
|
public static string GetERP_OTH_INTips(string billcode, string materialCode)
|
{
|
var tips = "";
|
var otherInDetails = Biz.Db.Queryable<BIZ_ERP_OTH_IN_DTL>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
|
&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
|
&& t.LINESTATUS == BIZ_ERP_OTH_IN.STATUSs.WORKING.GetValue()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
|
//if (otherInDetails.Any())
|
{
|
tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.QTY):N0}";
|
}
|
var otherInScanList = Biz.Db.Queryable<BIZ_ERP_OTH_IN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
|
&& t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
|
&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()).ToList();
|
//if (otherInScanList.Any())
|
{
|
tips += $" ({otherInScanList.Count()} 盘)";
|
}
|
return tips;
|
}
|
/// <summary>
|
/// 获得其他入库单完成信息
|
/// </summary>
|
/// <param name="billcode"></param>
|
/// <param name="materialCode"></param>
|
/// <returns></returns>
|
public static string GetFinishedTips(string billcode, string materialCode)
|
{
|
var tips = "";
|
var otherInDetails = Biz.Db.Queryable<BIZ_ERP_PROD_IN_DTL>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
|
&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
|
&& t.LINESTATUS == BIZ_ERP_OTH_IN.STATUSs.WORKING.GetValue()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
|
//if (otherInDetails.Any())
|
{
|
tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.INVENTORYQTY):N0}";
|
}
|
var otherInScanList = Biz.Db.Queryable<BIZ_ERP_PROD_IN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
|
&& t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()
|
&& t.ITEM_CODE.ToUpper() == materialCode.ToUpper()).ToList();
|
//if (otherInScanList.Any())
|
{
|
tips += $" ({otherInScanList.Count()} 盘)";
|
}
|
return tips;
|
}
|
/// <summary>
|
/// 获得其他入库单完成信息
|
/// </summary>
|
/// <param name="billcode"></param>
|
/// <param name="materialCode"></param>
|
/// <returns></returns>
|
public static string GetBIZ_ERP_PROD_INips(string billcode)
|
{
|
var tips = "";
|
//var otherInDetails = Biz.Db.Queryable<BIZ_ERP_OTH_IN_DTL>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
|
// && t.ITEM_CODE.ToUpper() == materialCode.ToUpper()
|
// && t.LINESTATUS == BIZ_ERP_OTH_IN.STATUSs.WORKING.GetValue()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
|
////if (otherInDetails.Any())
|
//{
|
// tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.QTY):N0}";
|
//}
|
var otherInScanList = Biz.Db.Queryable<BIZ_ERP_PROD_IN_SN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
|
&& t.STATUS <= WMS_ITEM.STATUSs.WaitIn.GetValue()).ToList();
|
//if (otherInScanList.Any())
|
{
|
tips += $" 总数:({otherInScanList.Count()})";
|
}
|
return tips;
|
}
|
/// <summary>
|
/// 获得完成信息
|
/// </summary>
|
/// <param name="billcode"></param>
|
/// <param name="materialCode"></param>
|
/// <returns></returns>
|
public static string GetIncompleteTips(string billcode, string materialCode)
|
{
|
var tips = "";
|
var otherInDetails = Biz.Db.Queryable<WMS_OTHERINSTOCK_D>().Where(t => t.BILLCODE.ToUpper() == billcode.ToUpper()
|
&& t.MATERIALCODE.ToUpper() == materialCode.ToUpper()
|
&& t.LINESTATUS == OtherInstockSides.Status.WORKING.ToString()).OrderBy(t => new { t.BILLCODE, t.BILLLINE }).ToList();
|
if (otherInDetails.Any())
|
{
|
tips += $"数量:{otherInDetails.Sum(q => q.PRQTY - q.QTY):N0}";
|
}
|
var otherInScanList = Biz.Db.Queryable<WMS_OTHERINSTOCK_SCAN>().Where(t => t.BUSINESSCODE.ToUpper() == billcode.ToUpper()
|
&& t.MATERIALCODE.ToUpper() == materialCode.ToUpper()).OrderBy(t => new { t.BUSINESSCODE, t.BUSINESSLINE }).ToList();
|
if (otherInScanList.Any())
|
{
|
tips += $" ({otherInScanList.Count()} 盘)";
|
}
|
return tips;
|
}
|
|
/// <summary>
|
/// 客供料入库完成信息
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<CustSupplyInOutput> CustSupplyInIncompleteList(CustSupplyIncompleteInput input)
|
{
|
var otherInScanList = await Biz.Db.Queryable<WMS_OTHERINSTOCK_SCAN>()
|
.Where(t => t.BUSINESSCODE.ToUpper() == input.receiptNo.ToUpper()
|
&& t.MATERIALCODE.ToUpper() == input.materialCode.ToUpper())
|
.ToListAsync();
|
var incompleteList = otherInScanList.OrderBy(q => q.STATUS == "Billed" ? 1 : (q.STATUS == "Complete" ? 3 : 2))
|
.Select(q => new
|
{
|
Barcode = q.BARCODE,
|
Qty = (int)q.QTY,
|
Status = q.STATUS == "Billed" ? "待入库" : (q.STATUS == "Complete" ? "已入库" : $"其他({q.STATUS})")
|
});
|
return new CustSupplyInOutput() { result = JsonConvert.SerializeObject(incompleteList) };
|
}
|
}
|
}
|