@ -64,6 +64,11 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
private readonly ISettleAccountBranchEfCoreRepository < WmsKanbanOutPutDetial , Guid > _ wmsRepository ;
private readonly ISettleAccountBranchEfCoreRepository < WmsKanbanOutPutDetial , Guid > _ wmsRepository ;
private readonly ISettleAccountBranchEfCoreRepository < WmsKanbanOutPut , Guid > _ wmsVersionRepository ;
private readonly ISettleAccountBranchEfCoreRepository < WmsKanbanOutPut , Guid > _ wmsVersionRepository ;
private readonly ISettleAccountBranchEfCoreRepository < WmsWithOutKanbanOutPutDetial , Guid > _ wmsRepository1 ;
private readonly ISettleAccountBranchEfCoreRepository < WmsWithOutKanbanOutPut , Guid > _ wmsVersionRepository1 ;
private readonly WMSEfCoreRepository < WmsKanbanOutPutDetial > _ wmsefRespository ;
private readonly WMSEfCoreRepository < WmsKanbanOutPutDetial > _ wmsefRespository ;
private readonly WMSEfCoreRepository < TB_BILL > _ wmstbRespository ;
private readonly WMSEfCoreRepository < TB_BILL > _ wmstbRespository ;
@ -184,13 +189,14 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
[Route("WmsWithOutKanbanOutPut")]
[Route("WmsWithOutKanbanOutPut")]
public async Task < string > WmsWithOutKanbanOutPut ( WmsJitRequestDto input )
public async Task < string > WmsWithOutKanbanOutPut ( WmsJitRequestDto input )
{
{
var _ billNum = "KA" + DateTime . Now . ToString ( "yyyyMMddhhmmss" ) ;
var _ billNum = "KA" + DateTime . Now . ToString ( "yyyyMMddhhmmss" ) ;
var _ joblist = _ job . Where ( p = > input . Guids . Contains ( p . Id ) & & p . FileName = = "已确认" ) . ToList ( ) ;
var _ joblist = _ job . Where ( p = > input . Guids . Contains ( p . Id ) & & p . FileName = = "已确认" ) . ToList ( ) ;
if ( _ joblist . Count ( ) > 0 )
if ( _ joblist . Count ( ) > 0 )
{
{
var fileList = _ joblist . Select ( p = > p . RealDownFileName ) . ToList ( ) ;
var fileList = _ joblist . Select ( p = > p . RealDownFileName ) . ToList ( ) ;
List < WmsKanbanOutPutDetial > _l st = new List < WmsKanbanOutPutDetial > ( ) ;
List < WmsWithOut KanbanOutPutDetial > _l st = new List < WmsWithOut KanbanOutPutDetial > ( ) ;
foreach ( var filename in fileList )
foreach ( var filename in fileList )
{
{
string fileSavePath = Environment . CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename ;
string fileSavePath = Environment . CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename ;
@ -198,49 +204,61 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
var _l ist = _ excelHelper . ExcelToList < SettleKBWithOutCode > ( ) ;
var _l ist = _ excelHelper . ExcelToList < SettleKBWithOutCode > ( ) ;
foreach ( var itm in _l ist )
foreach ( var itm in _l ist )
{
{
var _ entity = new WmsWithOutKanbanOutPutDetial (
var _ entity = new WmsKanbanOutPutDetial ( GuidGenerator . Create ( ) , string . Empty , string . Empty , itm . MaterialCode , itm . MaterialDesc
GuidGenerator . Create ( ) ,
, itm . SapMaterialGroup , string . Empty , string . Empty , 0 , string . Empty , string . Empty , itm . Version , itm . SapMaterialCode ,
string . Empty ,
_ billNum , Guid . Empty , string . Empty , itm . InvoiceQty
string . Empty ,
itm . MaterialCode ,
itm . MaterialDesc ,
itm . SapMaterialGroup ,
string . Empty ,
string . Empty ,
0 ,
string . Empty ,
string . Empty ,
input . Version ,
itm . SapMaterialCode ,
_ billNum ,
Guid . Empty ,
string . Empty ,
itm . InvoiceQty
) ;
) ;
_l st . Add ( _ entity ) ;
_l st . Add ( _ entity ) ;
}
}
}
}
var outPutDetail = await _ wmsRepository . Where ( p = > p . Version = = input . Version & & p . Kanban = = string . Empty ) . ToListAsync ( ) ;
var outPutDetail = await _ wmsRepository1 . Where ( p = > p . Version = = input . Version & & p . Kanban = = string . Empty ) . ToListAsync ( ) ;
//var error = from itm1 in outPutDetail
var error = from itm1 in outPutDetail
// join itm2 in _ls1 on
join itm2 in _l st on
// new { itm1.MaterialCode, itm1.Kanban }
new { itm1 . MaterialCode }
// equals
equals
// new { itm2.MaterialCode, itm2.Kanban }
new { itm2 . MaterialCode }
// select itm1;
select itm1 ;
//var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) });
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)
if ( errList . Count ( ) = = 0 )
//{
{
// var query = from itm1 in _ls1
var query = from itm1 in _l st
// join itm2 in outPutDetail on
join itm2 in outPutDetail on
// new { itm1.MaterialCode, itm1.Kanban }
new { itm1 . MaterialCode }
// equals
equals
// new { itm2.MaterialCode, itm2.Kanban } into temp1
new { itm2 . MaterialCode } into temp1
// from tm1 in temp1.DefaultIfEmpty()
from tm1 in temp1 . DefaultIfEmpty ( )
// where tm1 = = null
where tm1 = = null
// select itm1;
select itm1 ;
// var _wmslst = query.ToList();
var _ wmslst = query . ToList ( ) ;
// foreach (var itm in _lst)
foreach ( var itm in _l st )
// {
{
// itm.BillNum = _billNum;
itm . BillNum = _ billNum ;
// }
}
await _ wmsRepository . GetDbContext ( ) . BulkInsertAsync ( _l st , new BulkConfig ( ) { BulkCopyTimeout = 0 , BatchSize = 1 0 0 0 0 } ) ;
await _ wmsRepository1 . GetDbContext ( ) . BulkInsertAsync ( _l st , new BulkConfig ( ) { BulkCopyTimeout = 0 , BatchSize = 1 0 0 0 0 } ) ;
int _ count = _ wmsVersionRepository . Count ( p = > p . Version = = input . Version & & p . BillNum = = _ billNum ) ;
int _ count = _ wmsVersionRepository1 . Count ( p = > p . Version = = input . Version & & p . BillNum = = _ billNum ) ;
if ( _ count = = 0 )
if ( _ count = = 0 )
{
{
var _ version = new WmsKanbanOutPut ( GuidGenerator . Create ( ) , input . Version , _ billNum , CurrentUser . Email ) ;
var _ version = new WmsWithOut KanbanOutPut ( GuidGenerator . Create ( ) , input . Version , _ billNum , CurrentUser . Email ) ;
await _ wmsVersionRepository . InsertAsync ( _ version , true ) ;
await _ wmsVersionRepository1 . InsertAsync ( _ version , true ) ;
}
}
foreach ( var job in _ joblist )
foreach ( var job in _ joblist )
@ -249,26 +267,26 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
await _ job . UpdateAsync ( job ) ;
await _ job . UpdateAsync ( job ) ;
}
}
}
}
//else
else
//{
{
// StringBuilder _buffer = new StringBuilder();
StringBuilder _ buffer = new StringBuilder ( ) ;
// foreach (var itm in errList)
foreach ( var itm in errList )
// {
{
// _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number);
_ buffer . AppendFormat ( "出库单号:{0}重复记录数:{1}条" , itm . BillNum , itm . Number ) ;
// }
}
// var _errinfo = _buffer.ToString();
var _ errinfo = _ buffer . ToString ( ) ;
// foreach (var job in _joblist)
foreach ( var job in _ joblist )
// {
{
// job.FileName = _errinfo;
job . FileName = _ errinfo ;
// await _job.UpdateAsync(job);
await _ job . UpdateAsync ( job ) ;
// }
}
//}
}
//}
}
//else
else
//{
{
// _billNum = string.Empty;
_ billNum = string . Empty ;
//}
}
return ApplicationConsts . SuccessStr ; ;
return ApplicationConsts . SuccessStr ; ;
}
}