|
|
@ -234,6 +234,186 @@ namespace Win.Sfs.SettleAccount.Entities.WMS |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
[Route("ExcelImportWithOutKanban")] |
|
|
|
[DisableRequestSizeLimit] |
|
|
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
|
|
public async Task<string> ExcelImportWithOutKanban([FromForm] IFormFileCollection files, string version) |
|
|
|
{ |
|
|
|
var _billNum = "KA" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var _list = _dapper.GetNoKanbanSettleDetail(version);
|
|
|
|
|
|
|
|
|
|
|
|
//var stockList = _wmsDapper.GetSalesStock();
|
|
|
|
//var query = from itm in _list
|
|
|
|
// join itm1 in stockList on itm.MaterialCode equals itm1.SapCode
|
|
|
|
//into temp1
|
|
|
|
// from tm1 in temp1.DefaultIfEmpty()
|
|
|
|
// select new WmsWithOutKanbanOutPutDetial(
|
|
|
|
// GuidGenerator.Create(),
|
|
|
|
// "无看板",
|
|
|
|
// itm.SapMaterialCode,
|
|
|
|
// itm.MaterialDesc,
|
|
|
|
// itm.Version,
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// itm.Qty,
|
|
|
|
// tm1.Qty,
|
|
|
|
// itm.Qty,
|
|
|
|
// string.Empty,
|
|
|
|
// _billNum,
|
|
|
|
// 0,
|
|
|
|
// 0,
|
|
|
|
// itm.InvoicePrice
|
|
|
|
// , itm.InvoiceAmt
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
//await _wmsRepository.GetDbContext().BulkInsertAsync(query.ToList(), new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
|
|
|
|
//int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum);
|
|
|
|
//if (_count == 0)
|
|
|
|
//{
|
|
|
|
// var _version = new WmsWithOutKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email);
|
|
|
|
// await _wmsVersionRepository.InsertAsync(_version, true);
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//return _billNum;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var _lsCopy = new List<WmsWithOutKanbanOutPutDetial>();
|
|
|
|
//foreach (var itm in query.ToList())
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
|
|
// WmsWithOutKanbanOutPutDetial _detail = new WmsWithOutKanbanOutPutDetial(
|
|
|
|
// GuidGenerator.Create(),
|
|
|
|
// "无看板",
|
|
|
|
// itm.SapMaterialCode,
|
|
|
|
// itm.MaterialDesc,
|
|
|
|
// itm.Version,
|
|
|
|
// string.Empty,
|
|
|
|
// string.Empty,
|
|
|
|
// itm.Qty,
|
|
|
|
// 0,
|
|
|
|
// itm.Qty,
|
|
|
|
// string.Empty,
|
|
|
|
// _billNum,
|
|
|
|
// 0,
|
|
|
|
// itm.
|
|
|
|
|
|
|
|
// );
|
|
|
|
// _lsCopy.Add(_detail);
|
|
|
|
//}
|
|
|
|
//_lst.AddRange(_lsCopy.ToArray());
|
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
|
var result = await _exportImporter.ExtendExcelImport<WmsWithOutKanbanOutPutDetial>(files, _excelImportService); |
|
|
|
List<WmsWithOutKanbanOutPutDetial> _lst = new List<WmsWithOutKanbanOutPutDetial>(); |
|
|
|
var _lsCopy = new List<WmsWithOutKanbanOutPutDetial>(); |
|
|
|
foreach (var itm in result) |
|
|
|
{ |
|
|
|
WmsWithOutKanbanOutPutDetial _detail = new WmsWithOutKanbanOutPutDetial( |
|
|
|
GuidGenerator.Create(), |
|
|
|
!string.IsNullOrEmpty(itm.Type) ? itm.Type : string.Empty, |
|
|
|
itm.SapMaterialCode, |
|
|
|
itm.MaterialDesc, |
|
|
|
itm.Version, |
|
|
|
itm.IsBack, |
|
|
|
itm.Remark, |
|
|
|
itm.Qty, |
|
|
|
itm.SockQty, |
|
|
|
itm.OutputQty, |
|
|
|
itm.Extend, |
|
|
|
itm.BillNum,0 |
|
|
|
,0, |
|
|
|
itm.Price, |
|
|
|
itm.Amt |
|
|
|
); |
|
|
|
_lsCopy.Add(_detail); |
|
|
|
} |
|
|
|
_lst.AddRange(_lsCopy.ToArray()); |
|
|
|
|
|
|
|
|
|
|
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == version && p.State!=4).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
var error = from itm1 in outPutDetail |
|
|
|
join itm2 in _lst on |
|
|
|
new { itm1.SapMaterialCode } |
|
|
|
equals |
|
|
|
new { itm2.SapMaterialCode } |
|
|
|
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.SapMaterialCode } |
|
|
|
equals |
|
|
|
new { itm2.SapMaterialCode } 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) |
|
|
|
{ |
|
|
|
var _version = new WmsWithOutKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); |
|
|
|
await _wmsVersionRepository.InsertAsync(_version, true); |
|
|
|
} |
|
|
|
return _billNum; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 选择任务,生成出库单,只包含已确认的单据
|
|
|
|
/// </summary>
|
|
|
@ -459,22 +639,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS |
|
|
|
} |
|
|
|
); |
|
|
|
return _fileName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 物料 物料组 物料描述 物料号 开始日期 结束日期 单位 出库数量 结算数量 寄售库存数量
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|