|
|
@ -216,6 +216,12 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 选择任务,生成出库单,只包含已确认的单据
|
|
|
|
/// </summary>
|
|
|
@ -227,17 +233,28 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
public async Task<string> WmsSharePartOutPut(WmsJitRequestDto input) |
|
|
|
{ |
|
|
|
var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
|
|
|
var _billNoNum = "BNoBill" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
|
|
|
var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); |
|
|
|
if (_joblist.Count() > 0) |
|
|
|
{ |
|
|
|
var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); |
|
|
|
List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>(); |
|
|
|
List<WmsSharePartOutPutDetial> _lstBill = new List<WmsSharePartOutPutDetial>(); |
|
|
|
foreach (var filename in fileList) |
|
|
|
{ |
|
|
|
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; |
|
|
|
ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); |
|
|
|
var _list = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>(); |
|
|
|
if (_list.Count() > 0) |
|
|
|
var _listSummary = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>(); |
|
|
|
|
|
|
|
var _list = _listSummary.Where(p => p.OrderBillNum == "").ToList();//过滤 采购订单号为空的集合
|
|
|
|
var _listBill = _listSummary.Where(p => p.OrderBillNum != "").ToList();//过滤 采购订单号不为空的集合
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var _list = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>();
|
|
|
|
//没有 采购订单号
|
|
|
|
if (_list != null && _list.Count > 0) |
|
|
|
{ |
|
|
|
var _lsAry = _list.Select(p => new |
|
|
|
WmsSharePartOutPutDetial( |
|
|
@ -255,7 +272,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
string.Empty, |
|
|
|
string.Empty, |
|
|
|
p.MaterialCode, |
|
|
|
_billNum, |
|
|
|
_billNoNum, |
|
|
|
GuidGenerator.Create(), |
|
|
|
string.Empty, |
|
|
|
p.Qty, |
|
|
@ -266,15 +283,49 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
)); |
|
|
|
_lst.AddRange(_list.ToArray()); |
|
|
|
} |
|
|
|
|
|
|
|
if (_listBill != null && _listBill.Count() > 0) |
|
|
|
{ |
|
|
|
var _lsAry = _listBill.Select(p => new |
|
|
|
WmsSharePartOutPutDetial( |
|
|
|
GuidGenerator.Create(), |
|
|
|
p.WmsBillNum, |
|
|
|
p.OrderBillNum, |
|
|
|
p.MaterialCode, |
|
|
|
p.MaterialDesc, |
|
|
|
p.MaterialGroup, |
|
|
|
string.Empty, |
|
|
|
string.Empty, |
|
|
|
0, |
|
|
|
!string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, |
|
|
|
|
|
|
|
string.Empty, |
|
|
|
string.Empty, |
|
|
|
p.MaterialCode, |
|
|
|
_billNum, |
|
|
|
GuidGenerator.Create(), |
|
|
|
string.Empty, |
|
|
|
p.Qty, |
|
|
|
p.StockQty, |
|
|
|
p.Qty, |
|
|
|
p.Price, |
|
|
|
p.Amt |
|
|
|
)); |
|
|
|
_lstBill.AddRange(_listBill.ToArray()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync(); |
|
|
|
|
|
|
|
if (_lst != null) |
|
|
|
{ |
|
|
|
//没有采购订单号
|
|
|
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version && p.OrderBillNum == "").ToListAsync(); |
|
|
|
|
|
|
|
var error = from itm1 in outPutDetail |
|
|
|
join itm2 in _lst on |
|
|
|
new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum } |
|
|
|
new { itm1.MaterialCode } |
|
|
|
equals |
|
|
|
new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum } |
|
|
|
new { itm2.MaterialCode } |
|
|
|
select itm1; |
|
|
|
|
|
|
|
var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); |
|
|
@ -282,14 +333,14 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
{ |
|
|
|
var query = from itm1 in _lst |
|
|
|
join itm2 in outPutDetail on |
|
|
|
new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum } |
|
|
|
new { itm1.MaterialCode } |
|
|
|
equals |
|
|
|
new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } into temp1 |
|
|
|
new { itm2.MaterialCode } into temp1 |
|
|
|
from tm1 in temp1.DefaultIfEmpty() |
|
|
|
where tm1 == null |
|
|
|
select itm1; |
|
|
|
var _wmslst = query.ToList(); |
|
|
|
_wmslst= _wmslst.Select(p => new |
|
|
|
_wmslst = _wmslst.Select(p => new |
|
|
|
WmsSharePartOutPutDetial( |
|
|
|
GuidGenerator.Create(), |
|
|
|
string.Empty, |
|
|
@ -304,7 +355,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
string.Empty, |
|
|
|
input.Version, |
|
|
|
p.MaterialCode, |
|
|
|
_billNum, |
|
|
|
_billNoNum, |
|
|
|
GuidGenerator.Create(), |
|
|
|
string.Empty, |
|
|
|
p.Qty, |
|
|
@ -314,15 +365,105 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
p.Amt |
|
|
|
)).ToList(); |
|
|
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
|
|
|
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNoNum); |
|
|
|
if (_wmslst.Count() > 0 && _count == 0) |
|
|
|
{ |
|
|
|
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNoNum, CurrentUser.Email); |
|
|
|
await _wmsVersionRepository.InsertAsync(_version, true); |
|
|
|
} |
|
|
|
foreach (var job in _joblist) |
|
|
|
{ |
|
|
|
job.FileName = _billNoNum; |
|
|
|
await _job.UpdateAsync(job); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
StringBuilder _buffer = new StringBuilder(); |
|
|
|
foreach (var itm in errList) |
|
|
|
{ |
|
|
|
_buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); |
|
|
|
} |
|
|
|
var _errinfo = _buffer.ToString(); |
|
|
|
|
|
|
|
foreach (var job in _joblist) |
|
|
|
{ |
|
|
|
job.FileName = _errinfo; |
|
|
|
await _job.UpdateAsync(job); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_lstBill != null) |
|
|
|
{ |
|
|
|
//有采购订单号
|
|
|
|
var outPutDetailBill = await _wmsRepository.Where(p => p.Version == input.Version && p.OrderBillNum != "").ToListAsync(); |
|
|
|
|
|
|
|
var error = from itm1 in outPutDetailBill |
|
|
|
join itm2 in _lstBill on |
|
|
|
new { itm1.MaterialCode, itm1.OrderBillNum } |
|
|
|
equals |
|
|
|
new { itm2.MaterialCode, itm2.OrderBillNum } |
|
|
|
select itm1; |
|
|
|
|
|
|
|
var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); |
|
|
|
if (errList.Count() == 0) |
|
|
|
{ |
|
|
|
var queryBill = from itm1 in _lstBill |
|
|
|
join itm2 in outPutDetailBill on |
|
|
|
new { itm1.MaterialCode, itm1.OrderBillNum } |
|
|
|
equals |
|
|
|
new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 |
|
|
|
from tm1 in temp1.DefaultIfEmpty() |
|
|
|
where tm1 == null |
|
|
|
select itm1; |
|
|
|
var _wmslstBill = queryBill.ToList(); |
|
|
|
_wmslstBill = _wmslstBill.Select(p => new |
|
|
|
WmsSharePartOutPutDetial( |
|
|
|
GuidGenerator.Create(), |
|
|
|
p.WmsBillNum, |
|
|
|
p.OrderBillNum, |
|
|
|
p.MaterialCode, |
|
|
|
p.MaterialDesc, |
|
|
|
p.MaterialGroup, |
|
|
|
string.Empty, |
|
|
|
string.Empty, |
|
|
|
0, |
|
|
|
!string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, |
|
|
|
string.Empty, |
|
|
|
input.Version, |
|
|
|
p.MaterialCode, |
|
|
|
_billNum, |
|
|
|
GuidGenerator.Create(), |
|
|
|
string.Empty, |
|
|
|
p.Qty, |
|
|
|
p.StockQty, |
|
|
|
p.Qty, |
|
|
|
p.Price, |
|
|
|
p.Amt |
|
|
|
)).ToList(); |
|
|
|
|
|
|
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslstBill, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
|
|
|
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); |
|
|
|
if (_wmslst.Count()>0 && _count == 0) |
|
|
|
if (_wmslstBill.Count() > 0 && _count == 0) |
|
|
|
{ |
|
|
|
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); |
|
|
|
await _wmsVersionRepository.InsertAsync(_version, true); |
|
|
|
} |
|
|
|
foreach (var job in _joblist) |
|
|
|
{ |
|
|
|
if (_lst != null) |
|
|
|
{ |
|
|
|
job.FileName = _billNum + "/" + _billNoNum; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
job.FileName = _billNum; |
|
|
|
} |
|
|
|
|
|
|
|
await _job.UpdateAsync(job); |
|
|
|
} |
|
|
|
} |
|
|
@ -342,12 +483,19 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_billNum = string.Empty; |
|
|
|
_billNoNum = string.Empty; |
|
|
|
} |
|
|
|
return ApplicationConsts.SuccessStr; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 出库界面功能,核准出库功能
|
|
|
|
/// </summary>
|
|
|
@ -359,6 +507,9 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
[UnitOfWork(false)] |
|
|
|
public async Task<bool> WmsSharePartOutPutPass(WmsJitRequestDto input) |
|
|
|
{ |
|
|
|
if (input.BillNum.Contains("NoBill")) |
|
|
|
{ |
|
|
|
//没有采购订单号的出库方式
|
|
|
|
if (input.Guids != null) |
|
|
|
{ |
|
|
|
List<WmsSharePartOutPutDetial> _ls = new List<WmsSharePartOutPutDetial>(); |
|
|
@ -379,14 +530,223 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
" @date = N'{1}'\n" + |
|
|
|
"SELECT 'Return Value' = @return_value"; |
|
|
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
|
|
|
string.Format(sql, input.BillNum,input.AccountDate.ToShortDateString())); |
|
|
|
string.Format(sql, input.BillNum, input.AccountDate.ToShortDateString())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//有采购订单号的出库方式
|
|
|
|
if (input.Guids != null) |
|
|
|
{ |
|
|
|
List<WmsSharePartOutPutDetial> _ls = new List<WmsSharePartOutPutDetial>(); |
|
|
|
if (input.Guids.Count() > 0) |
|
|
|
{ |
|
|
|
_ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); |
|
|
|
} |
|
|
|
if (_ls.Count() > 0) |
|
|
|
{ |
|
|
|
var sql = "DECLARE @return_value int\n" + |
|
|
|
"EXEC @return_value = [dbo].[p_wms_output]\n" + |
|
|
|
" @billnum = N'{0}',\n" + |
|
|
|
" @type = 10,\n" + |
|
|
|
" @date = N'{1}'\n" + |
|
|
|
"SELECT 'Return Value' = @return_value"; |
|
|
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
|
|
|
string.Format(sql, input.BillNum, input.AccountDate.ToShortDateString())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 选择任务,生成出库单,只包含已确认的单据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
/// <param name="version"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
//[HttpPost]
|
|
|
|
//[Route("WmsSharePartOutPut")]
|
|
|
|
//public async Task<string> WmsSharePartOutPut(WmsJitRequestDto input)
|
|
|
|
//{
|
|
|
|
// var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss");
|
|
|
|
// var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList();
|
|
|
|
// if (_joblist.Count() > 0)
|
|
|
|
// {
|
|
|
|
// var fileList = _joblist.Select(p => p.RealDownFileName).ToList();
|
|
|
|
// List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>();
|
|
|
|
// foreach (var filename in fileList)
|
|
|
|
// {
|
|
|
|
// string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename;
|
|
|
|
// ExcelHelper _excelHelper = new ExcelHelper(fileSavePath);
|
|
|
|
// var _list = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>();
|
|
|
|
// if (_list.Count() > 0)
|
|
|
|
// {
|
|
|
|
// var _lsAry = _list.Select(p => new
|
|
|
|
// WmsSharePartOutPutDetial(
|
|
|
|
// GuidGenerator.Create(),
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// p.MaterialCode,
|
|
|
|
// p.MaterialDesc,
|
|
|
|
// p.MaterialGroup,
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// 0,
|
|
|
|
// !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty,
|
|
|
|
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// p.MaterialCode,
|
|
|
|
// _billNum,
|
|
|
|
// GuidGenerator.Create(),
|
|
|
|
// string.Empty,
|
|
|
|
// p.Qty,
|
|
|
|
// p.StockQty,
|
|
|
|
// p.Qty,
|
|
|
|
// p.Price,
|
|
|
|
// p.Amt
|
|
|
|
// ));
|
|
|
|
// _lst.AddRange(_list.ToArray());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync();
|
|
|
|
|
|
|
|
// var error = from itm1 in outPutDetail
|
|
|
|
// join itm2 in _lst on
|
|
|
|
// new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum }
|
|
|
|
// equals
|
|
|
|
// new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum }
|
|
|
|
// select itm1;
|
|
|
|
|
|
|
|
// var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) });
|
|
|
|
// if (errList.Count() == 0)
|
|
|
|
// {
|
|
|
|
// var query = from itm1 in _lst
|
|
|
|
// join itm2 in outPutDetail on
|
|
|
|
// new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum }
|
|
|
|
// equals
|
|
|
|
// new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } into temp1
|
|
|
|
// from tm1 in temp1.DefaultIfEmpty()
|
|
|
|
// where tm1 == null
|
|
|
|
// select itm1;
|
|
|
|
// var _wmslst = query.ToList();
|
|
|
|
// _wmslst = _wmslst.Select(p => new
|
|
|
|
// WmsSharePartOutPutDetial(
|
|
|
|
// GuidGenerator.Create(),
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// p.MaterialCode,
|
|
|
|
// p.MaterialDesc,
|
|
|
|
// p.MaterialGroup,
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// 0,
|
|
|
|
// !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// input.Version,
|
|
|
|
// p.MaterialCode,
|
|
|
|
// _billNum,
|
|
|
|
// GuidGenerator.Create(),
|
|
|
|
// string.Empty,
|
|
|
|
// p.Qty,
|
|
|
|
// p.StockQty,
|
|
|
|
// p.Qty,
|
|
|
|
// p.Price,
|
|
|
|
// p.Amt
|
|
|
|
// )).ToList();
|
|
|
|
// await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
|
|
|
|
// int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum);
|
|
|
|
// if (_wmslst.Count() > 0 && _count == 0)
|
|
|
|
// {
|
|
|
|
// var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email);
|
|
|
|
// await _wmsVersionRepository.InsertAsync(_version, true);
|
|
|
|
// }
|
|
|
|
// foreach (var job in _joblist)
|
|
|
|
// {
|
|
|
|
// job.FileName = _billNum;
|
|
|
|
// await _job.UpdateAsync(job);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// StringBuilder _buffer = new StringBuilder();
|
|
|
|
// foreach (var itm in errList)
|
|
|
|
// {
|
|
|
|
// _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number);
|
|
|
|
// }
|
|
|
|
// var _errinfo = _buffer.ToString();
|
|
|
|
|
|
|
|
// foreach (var job in _joblist)
|
|
|
|
// {
|
|
|
|
// job.FileName = _errinfo;
|
|
|
|
// await _job.UpdateAsync(job);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// _billNum = string.Empty;
|
|
|
|
// }
|
|
|
|
// return ApplicationConsts.SuccessStr;
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
///// 出库界面功能,核准出库功能
|
|
|
|
///// </summary>
|
|
|
|
///// <param name="version"></param>
|
|
|
|
///// <param name="p_list"></param>
|
|
|
|
///// <returns></returns>
|
|
|
|
//[HttpPost]
|
|
|
|
//[Route("WmsSharePartOutPut-Pass")]
|
|
|
|
//[UnitOfWork(false)]
|
|
|
|
//public async Task<bool> WmsSharePartOutPutPass(WmsJitRequestDto input)
|
|
|
|
//{
|
|
|
|
// if (input.Guids != null)
|
|
|
|
// {
|
|
|
|
// List<WmsSharePartOutPutDetial> _ls = new List<WmsSharePartOutPutDetial>();
|
|
|
|
// if (input.Guids.Count() > 0)
|
|
|
|
// {
|
|
|
|
// _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync();
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// _ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync();
|
|
|
|
// }
|
|
|
|
// if (_ls.Count() > 0)
|
|
|
|
// {
|
|
|
|
// var sql = "DECLARE @return_value int\n" +
|
|
|
|
// "EXEC @return_value = [dbo].[p_wms_output]\n" +
|
|
|
|
// " @billnum = N'{0}',\n" +
|
|
|
|
// " @type = 2,\n" +
|
|
|
|
// " @date = N'{1}'\n" +
|
|
|
|
// "SELECT 'Return Value' = @return_value";
|
|
|
|
// await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync(
|
|
|
|
// string.Format(sql, input.BillNum,input.AccountDate.ToShortDateString()));
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return true;
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
[Route("WmsSharePartOutPutModify")] |
|
|
|
[DisableRequestSizeLimit] |
|
|
@ -414,7 +774,10 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
[Route("WmsSharePartOutPut-Cancel")] |
|
|
|
public async Task<bool> WmsSharePartOutPutCancel(WmsJitRequestDto input) |
|
|
|
{ |
|
|
|
if(input.Guids != null && input.Guids.Count() > 0) |
|
|
|
if (input.BillNum.Contains("NoBill")) |
|
|
|
{ |
|
|
|
//没有有采购单据号的单子
|
|
|
|
if (input.Guids != null && input.Guids.Count() > 0) |
|
|
|
{ |
|
|
|
List<string> _ls = new List<string>(); |
|
|
|
foreach (var itm in input.Guids) |
|
|
@ -439,6 +802,37 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//有采购单据号的单子
|
|
|
|
if (input.Guids != null && input.Guids.Count() > 0) |
|
|
|
{ |
|
|
|
List<string> _ls = new List<string>(); |
|
|
|
foreach (var itm in input.Guids) |
|
|
|
{ |
|
|
|
_ls.Add(string.Format("{0}", itm)); |
|
|
|
} |
|
|
|
|
|
|
|
string str = string.Join(",", _ls.ToArray()); |
|
|
|
|
|
|
|
var sql = "DECLARE @return_value int\n" + |
|
|
|
"EXEC @return_value = [dbo].[p_wms_output_cancel]\n" + |
|
|
|
" @Guids ='{0}', \n" + |
|
|
|
" @billnum = N'{1}',\n" + |
|
|
|
" @type = 10,\n" + |
|
|
|
" @accountdate = N'{2}'\n" + |
|
|
|
"SELECT 'Return Value' = @return_value"; |
|
|
|
|
|
|
|
sql = string.Format(sql, str, input.BillNum, input.AccountDate.ToShortDateString()); |
|
|
|
|
|
|
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
|
|
|
sql |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -453,6 +847,9 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
[UnitOfWork(false)] |
|
|
|
public async Task<bool> WmsOutPutDelete(WmsJitRequestDto input) |
|
|
|
{ |
|
|
|
if (input.BillNum.Contains("NoBill")) |
|
|
|
{ |
|
|
|
//没有采购单据号的单子
|
|
|
|
var count = _wmsRepository.Count(p => p.BillNum == input.BillNum && p.State != 0); |
|
|
|
|
|
|
|
if (count > 0) |
|
|
@ -467,6 +864,25 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
|
|
|
string.Format(sql, input.BillNum) |
|
|
|
); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//有采购单据号的单子
|
|
|
|
var count = _wmsRepository.Count(p => p.BillNum == input.BillNum && p.State != 0); |
|
|
|
|
|
|
|
if (count > 0) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
var sql = "DECLARE @return_value int\n" + |
|
|
|
"EXEC @return_value = [dbo].[p_wms_output_cancel_all]\n" + |
|
|
|
" @billnum = N'{0}',\n" + |
|
|
|
" @type = 10\n" + |
|
|
|
"SELECT 'Return Value' = @return_value"; |
|
|
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
|
|
|
string.Format(sql, input.BillNum) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -480,18 +896,29 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
|
|
public async Task<string> ExcelImport([FromForm] IFormFileCollection files, string version) |
|
|
|
{ |
|
|
|
var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
|
|
|
|
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
|
var result = await _exportImporter.ExtendExcelImport<WmsSharePartOutPutDetial>(files, _excelImportService); |
|
|
|
|
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new BusinessException("导入的模板中没有数据,不能为空,请检查!"); |
|
|
|
} |
|
|
|
|
|
|
|
var result_withbill = result.Where(p => p.OrderBillNum != "").ToList(); |
|
|
|
var result_nobill = result.Where(p => p.OrderBillNum == "").ToList(); |
|
|
|
|
|
|
|
//没有采购单号
|
|
|
|
if (result_nobill != null) |
|
|
|
{ |
|
|
|
var _billNoNum = "BNoBill" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
|
|
|
List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>(); |
|
|
|
|
|
|
|
var _lsCopy = new List<WmsSharePartOutPutDetial>(); |
|
|
|
foreach (var itm in result) |
|
|
|
foreach (var itm in result_nobill) |
|
|
|
{ |
|
|
|
WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial( |
|
|
|
GuidGenerator.Create(), |
|
|
|
//itm.WmsBillNum,
|
|
|
|
//itm.OrderBillNum,
|
|
|
|
string.Empty, |
|
|
|
string.Empty, |
|
|
|
itm.MaterialCode, |
|
|
@ -500,7 +927,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
string.Empty, |
|
|
|
string.Empty, |
|
|
|
0, |
|
|
|
!string.IsNullOrEmpty(itm.Extend1) ?itm.Extend1 : string.Empty, |
|
|
|
!string.IsNullOrEmpty(itm.Extend1) ? itm.Extend1 : string.Empty, |
|
|
|
string.Empty, |
|
|
|
version, |
|
|
|
itm.ParentMaterialCode, |
|
|
@ -510,8 +937,8 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
, itm.Qty |
|
|
|
, 0 |
|
|
|
, itm.Qty |
|
|
|
,itm.Price |
|
|
|
,itm.Amt |
|
|
|
, itm.Price |
|
|
|
, itm.Amt |
|
|
|
); |
|
|
|
_lsCopy.Add(_detail); |
|
|
|
} |
|
|
@ -520,14 +947,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
//var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList();
|
|
|
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
//var error = from itm1 in outPutDetail
|
|
|
|
// join itm2 in _ls1 on
|
|
|
|
// new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum }
|
|
|
|
// equals
|
|
|
|
// new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum }
|
|
|
|
// select itm1;
|
|
|
|
|
|
|
|
var error = from itm1 in outPutDetail |
|
|
|
join itm2 in _lst on |
|
|
|
new { itm1.MaterialCode } |
|
|
@ -548,14 +967,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
return await ExportErrorReportAsync(checkList); |
|
|
|
} |
|
|
|
|
|
|
|
//var query = from itm1 in _ls1
|
|
|
|
// join itm2 in outPutDetail on
|
|
|
|
// new { itm1.MaterialCode, itm1.OrderBillNum }
|
|
|
|
// equals
|
|
|
|
// new { itm2.MaterialCode, itm2.OrderBillNum } into temp1
|
|
|
|
// from tm1 in temp1.DefaultIfEmpty()
|
|
|
|
// where tm1 == null
|
|
|
|
// select itm1;
|
|
|
|
var query = from itm1 in _lst |
|
|
|
join itm2 in outPutDetail on |
|
|
|
new { itm1.MaterialCode } |
|
|
@ -566,19 +977,218 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
|
|
select itm1; |
|
|
|
var _wmslst = query.ToList(); |
|
|
|
foreach (var itm in _wmslst) |
|
|
|
{ |
|
|
|
itm.BillNum = _billNoNum; |
|
|
|
} |
|
|
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
|
|
|
int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNoNum); |
|
|
|
if (_count == 0 && _wmslst.Count() > 0) |
|
|
|
{ |
|
|
|
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNoNum, CurrentUser.Email); |
|
|
|
await _wmsVersionRepository.InsertAsync(_version, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//有采购单号
|
|
|
|
if (result_withbill != null) |
|
|
|
{ |
|
|
|
var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
|
|
|
List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>(); |
|
|
|
|
|
|
|
var _lsCopy = new List<WmsSharePartOutPutDetial>(); |
|
|
|
foreach (var itm in result_withbill) |
|
|
|
{ |
|
|
|
WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial( |
|
|
|
GuidGenerator.Create(), |
|
|
|
itm.WmsBillNum, |
|
|
|
itm.OrderBillNum, |
|
|
|
itm.MaterialCode, |
|
|
|
itm.MaterialDesc, |
|
|
|
itm.MaterialGroup, |
|
|
|
string.Empty, |
|
|
|
string.Empty, |
|
|
|
0, |
|
|
|
!string.IsNullOrEmpty(itm.Extend1) ? itm.Extend1 : string.Empty, |
|
|
|
string.Empty, |
|
|
|
version, |
|
|
|
itm.ParentMaterialCode, |
|
|
|
itm.BillNum, |
|
|
|
GuidGenerator.Create() |
|
|
|
, string.Empty |
|
|
|
, itm.Qty |
|
|
|
, 0 |
|
|
|
, itm.Qty |
|
|
|
, itm.Price |
|
|
|
, itm.Amt |
|
|
|
); |
|
|
|
_lsCopy.Add(_detail); |
|
|
|
} |
|
|
|
_lst.AddRange(_lsCopy.ToArray()); |
|
|
|
|
|
|
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
var error = from itm1 in outPutDetail |
|
|
|
join itm2 in _lst on |
|
|
|
new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum } |
|
|
|
equals |
|
|
|
new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } |
|
|
|
select itm1; |
|
|
|
|
|
|
|
|
|
|
|
var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); |
|
|
|
|
|
|
|
var checkList = new List<ErrorExportDto>(); |
|
|
|
foreach (var itm in errList) |
|
|
|
{ |
|
|
|
checkList.Add(new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) }); |
|
|
|
} |
|
|
|
if (checkList.Count > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
return await ExportErrorReportAsync(checkList); |
|
|
|
} |
|
|
|
|
|
|
|
var query = from itm1 in _lst |
|
|
|
join itm2 in outPutDetail on |
|
|
|
new { itm1.MaterialCode, itm1.OrderBillNum } |
|
|
|
equals |
|
|
|
new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 |
|
|
|
from tm1 in temp1.DefaultIfEmpty() |
|
|
|
where tm1 == null |
|
|
|
select itm1; |
|
|
|
var _wmslst = query.ToList(); |
|
|
|
foreach (var itm in _wmslst) |
|
|
|
{ |
|
|
|
itm.BillNum = _billNum; |
|
|
|
} |
|
|
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
|
|
|
int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); |
|
|
|
if (_count == 0 && _wmslst.Count()>0) |
|
|
|
if (_count == 0 && _wmslst.Count() > 0) |
|
|
|
{ |
|
|
|
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); |
|
|
|
await _wmsVersionRepository.InsertAsync(_version, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return ApplicationConsts.SuccessStr; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//[HttpPost]
|
|
|
|
//[Route("ExcelImport")]
|
|
|
|
//[DisableRequestSizeLimit]
|
|
|
|
////[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
|
|
//public async Task<string> ExcelImport([FromForm] IFormFileCollection files, string version)
|
|
|
|
//{
|
|
|
|
// var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss");
|
|
|
|
// ExportImporter _exportImporter = new ExportImporter();
|
|
|
|
// var result = await _exportImporter.ExtendExcelImport<WmsSharePartOutPutDetial>(files, _excelImportService);
|
|
|
|
|
|
|
|
// //if (result == null)
|
|
|
|
// //{
|
|
|
|
// // throw new BusinessException("导入的模板中没有数据,不能为空,请检查!");
|
|
|
|
// //}
|
|
|
|
|
|
|
|
// //var result_withbill = result.Select(p => p.BillNum != string.Empty).ToList();
|
|
|
|
// //var result_nobill = result.Select(p => p.BillNum == string.Empty).ToList();
|
|
|
|
|
|
|
|
// List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>();
|
|
|
|
|
|
|
|
// var _lsCopy = new List<WmsSharePartOutPutDetial>();
|
|
|
|
// foreach (var itm in result)
|
|
|
|
// {
|
|
|
|
// WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial(
|
|
|
|
// GuidGenerator.Create(),
|
|
|
|
// //itm.WmsBillNum,
|
|
|
|
// //itm.OrderBillNum,
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// itm.MaterialCode,
|
|
|
|
// itm.MaterialDesc,
|
|
|
|
// itm.MaterialGroup,
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// 0,
|
|
|
|
// !string.IsNullOrEmpty(itm.Extend1) ? itm.Extend1 : string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// version,
|
|
|
|
// itm.ParentMaterialCode,
|
|
|
|
// itm.BillNum,
|
|
|
|
// GuidGenerator.Create()
|
|
|
|
// , string.Empty
|
|
|
|
// , itm.Qty
|
|
|
|
// , 0
|
|
|
|
// , itm.Qty
|
|
|
|
// , itm.Price
|
|
|
|
// , itm.Amt
|
|
|
|
// );
|
|
|
|
// _lsCopy.Add(_detail);
|
|
|
|
// }
|
|
|
|
// _lst.AddRange(_lsCopy.ToArray());
|
|
|
|
|
|
|
|
// //var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList();
|
|
|
|
// var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
// //var error = from itm1 in outPutDetail
|
|
|
|
// // join itm2 in _ls1 on
|
|
|
|
// // new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum }
|
|
|
|
// // equals
|
|
|
|
// // new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum }
|
|
|
|
// // select itm1;
|
|
|
|
|
|
|
|
// var error = from itm1 in outPutDetail
|
|
|
|
// join itm2 in _lst on
|
|
|
|
// new { itm1.MaterialCode }
|
|
|
|
// equals
|
|
|
|
// new { itm2.MaterialCode }
|
|
|
|
// select itm1;
|
|
|
|
|
|
|
|
// var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) });
|
|
|
|
|
|
|
|
// var checkList = new List<ErrorExportDto>();
|
|
|
|
// foreach (var itm in errList)
|
|
|
|
// {
|
|
|
|
// checkList.Add(new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) });
|
|
|
|
// }
|
|
|
|
// if (checkList.Count > 0)
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return await ExportErrorReportAsync(checkList);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //var query = from itm1 in _ls1
|
|
|
|
// // join itm2 in outPutDetail on
|
|
|
|
// // new { itm1.MaterialCode, itm1.OrderBillNum }
|
|
|
|
// // equals
|
|
|
|
// // new { itm2.MaterialCode, itm2.OrderBillNum } into temp1
|
|
|
|
// // from tm1 in temp1.DefaultIfEmpty()
|
|
|
|
// // where tm1 == null
|
|
|
|
// // select itm1;
|
|
|
|
// var query = from itm1 in _lst
|
|
|
|
// join itm2 in outPutDetail on
|
|
|
|
// new { itm1.MaterialCode }
|
|
|
|
// equals
|
|
|
|
// new { itm2.MaterialCode } into temp1
|
|
|
|
// from tm1 in temp1.DefaultIfEmpty()
|
|
|
|
// where tm1 == null
|
|
|
|
// select itm1;
|
|
|
|
// var _wmslst = query.ToList();
|
|
|
|
// foreach (var itm in _wmslst)
|
|
|
|
// {
|
|
|
|
// itm.BillNum = _billNum;
|
|
|
|
// }
|
|
|
|
// await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
|
|
|
|
// int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum);
|
|
|
|
// if (_count == 0 && _wmslst.Count() > 0)
|
|
|
|
// {
|
|
|
|
// var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email);
|
|
|
|
// await _wmsVersionRepository.InsertAsync(_version, true);
|
|
|
|
// }
|
|
|
|
// return ApplicationConsts.SuccessStr;
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |