|
@ -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 _ls = _setls; |
|
|
|
|
|
var a = _ls.Where(p => string.IsNullOrEmpty(p.KENNCode)); |
|
|
|
|
|
var query = from arc in _ls |
|
|
|
|
|
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(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|