@ -42,8 +42,8 @@ namespace TaskJob.Services
public string ImportFile ( Guid id , List < string > fileName , List < string > realfileName , List < CustomCondition > customConditions )
public string ImportFile ( Guid id , List < string > fileName , List < string > realfileName , List < CustomCondition > customConditions )
{
{
IExporter _ excel = new ExcelExporter ( ) ;
IExporter _ excel = new ExcelExporter ( ) ;
string fileSavePath = Environment . CurrentDirectory + @"\wwwroot\files\host\my-file-container\" ;
string fileSavePath = Environment . CurrentDirectory + @"\wwwroot\files\host\my-file-container\" ;
var version = customConditions . Where ( p = > p . Name = = "Version" ) . FirstOrDefault ( ) . Value ;
var version = customConditions . Where ( p = > p . Name = = "Version" ) . FirstOrDefault ( ) . Value ;
@ -53,6 +53,7 @@ namespace TaskJob.Services
var factory = customConditions . Where ( p = > p . Name = = "Factory" ) . FirstOrDefault ( ) . Value ;
var factory = customConditions . Where ( p = > p . Name = = "Factory" ) . FirstOrDefault ( ) . Value ;
//_versionRepository.Delete(version);
//_versionRepository.Delete(version);
//_repository.Delete(version);
//_repository.Delete(version);
List < Win . Sfs . SettleAccount . Entities . SettleAccounts . SettleAccount > _ setls = new List < Win . Sfs . SettleAccount . Entities . SettleAccounts . SettleAccount > ( ) ;
var _ id = Guid . NewGuid ( ) ;
var _ id = Guid . NewGuid ( ) ;
foreach ( var itm in fileName )
foreach ( var itm in fileName )
@ -62,9 +63,9 @@ namespace TaskJob.Services
var filePath = fileSavePath + itm ; //获取到导入的excel
var filePath = fileSavePath + itm ; //获取到导入的excel
var exten = Path . GetExtension ( fileSavePath ) ;
var exten = Path . GetExtension ( fileSavePath ) ;
List < Win . Sfs . SettleAccount . Entities . SettleAccounts . SettleAccount > _ setls = new List < Win . Sfs . SettleAccount . Entities . SettleAccounts . SettleAccount > ( ) ;
List < string > _ errorList = new List < string > ( ) ;
List < string > _ errorList = new List < string > ( ) ;
var checkList = new List < ErrorExportDto > ( ) ;
var checkList = new List < ErrorExportDto > ( ) ;
//var _chList = await _relrepository.GetAllAsync(GuidGenerator.Create(), true);
//var _chList = await _relrepository.GetAllAsync(GuidGenerator.Create(), true);
//var _chls = _chList.Select(p => p.SettleMaterialCode).Distinct();
//var _chls = _chList.Select(p => p.SettleMaterialCode).Distinct();
@ -130,29 +131,22 @@ namespace TaskJob.Services
else
else
{
{
// _setls= _inputService.Input<Win.Sfs.SettleAccount.Entities.SettleAccounts.SettleAccount>(filePath);
// _setls= _inputService.Input<Win.Sfs.SettleAccount.Entities.SettleAccounts.SettleAccount>(filePath);
var errorlist = new List < ErrorExportDto > ( ) ;
var errorlist = new List < ErrorExportDto > ( ) ;
var dtoList = _ inputService . Input < SettleAccountImportDto > ( filePath , null , errorlist ) ;
var dtoList = _ inputService . Input < SettleAccountImportDto > ( filePath , null , errorlist ) ;
foreach ( var dto in dtoList )
foreach ( var dto in dtoList )
{
{
if ( dto . KENNCode . Length = = 6 )
if ( dto . KENNCode . Length = = 6 )
{
{
dto . KENNCode = "0" + dto . KENNCode ;
dto . KENNCode = "0" + dto . KENNCode ;
}
}
var _ settleaccount = new Win . Sfs . SettleAccount . Entities . SettleAccounts . SettleAccount ( Guid . NewGuid ( ) , Guid . NewGuid ( ) , dto . SettleYear , dto . KENNCode ,
var _ settleaccount = new Win . Sfs . SettleAccount . Entities . SettleAccounts . SettleAccount ( Guid . NewGuid ( ) , Guid . NewGuid ( ) , dto . SettleYear , dto . KENNCode ,
dto . ChassisNumber , dto . Model , dto . CP5A , dto . CP7 ,
dto . ChassisNumber , dto . Model , dto . CP5A , dto . CP7 ,
dto . MaterialCode , dto . Qty , dto . SettlementID , dto . SettlementSupplier ,
dto . MaterialCode , dto . Qty , dto . SettlementID , dto . SettlementSupplier ,
DateTime . Now . Month . ToString ( ) , dto . SettleYear , _ id , version , DateTime . Now , Guid . NewGuid ( ) ) ;
DateTime . Now . Month . ToString ( ) , dto . SettleYear , _ id , version , DateTime . Now , Guid . NewGuid ( ) ) ;
_ setls . Add ( _ settleaccount ) ;
_ setls . Add ( _ settleaccount ) ;
}
}
}
}
var _l s = _ setls ;
var a = _l s . Where ( p = > string . IsNullOrEmpty ( p . KENNCode ) ) ;
var query = from arc in _l s
group arc by new { arc . ChassisNumber , arc . MaterialCode } into g
where g . Count ( ) > 1
select g ;
_ repository . Insert ( _ setls ) ;
_ versionRepository . Insert ( _ id , version , customerCode , customerCode ) ;
@ -160,7 +154,7 @@ namespace TaskJob.Services
#region
#region
//var errorFileName = "错误文件.xlsx";
//var errorFileName = "错误文件.xlsx";
//checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ERP物料号{0}底盘号 {1}有重复", "11111111111", "22222222222"), string.Empty));
//checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ERP物料号{0}底盘号 {1}有重复", "11111111111", "22222222222"), string.Empty));
//_service.ExportError<ErrorExportDto>(id,errorFileName, checkList);
//_service.ExportError<ErrorExportDto>(id,errorFileName, checkList);
#endregion
#endregion
}
}
@ -169,6 +163,14 @@ namespace TaskJob.Services
throw e ;
throw e ;
}
}
}
}
_ setls = _ setls . GroupBy ( p = > new { p . ChassisNumber , p . MaterialCode , p . KENNCode } ) . Select ( p = > p . FirstOrDefault ( ) ) . ToList ( ) ;
_ repository . Insert ( _ setls ) ;
_ versionRepository . Insert ( _ id , version , customerCode , customerCode ) ;
return id . ToString ( ) ;
return id . ToString ( ) ;
}
}
}
}