|
|
@ -152,7 +152,21 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, Kitt |
|
|
|
var inputFileBytes = ms.GetAllBytes(); |
|
|
|
var importList= _excelService.Import<KittingImportInput>(inputFileBytes).ToList(); |
|
|
|
var checklist=importList.GroupBy(p => new { p.Code, p.PartCode }).Where(g => g.Count() > 1).Select(p => new { Code = p.Key.Code, PartCode = p.Key.PartCode });//导入重复报错
|
|
|
|
//检测是否导入重复
|
|
|
|
//检测是否导入重复
|
|
|
|
|
|
|
|
|
|
|
|
List<KittingErrorDto> errors = new List<KittingErrorDto>(); |
|
|
|
if (checklist.Any()) |
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var error in checklist) { |
|
|
|
|
|
|
|
errors.Add(new KittingErrorDto() { Code=error.Code,PartCode=error.PartCode, Content="记录有重复!" }); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -179,6 +193,7 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, Kitt |
|
|
|
var first = newDetail.FirstOrDefault(); |
|
|
|
var kitting = new KittingEditInput(); |
|
|
|
kitting.InjectFrom(first); |
|
|
|
// kitting.Code = $"Q{kitting.Code}";
|
|
|
|
foreach (var detail in newDetail) |
|
|
|
{ |
|
|
|
var inputdetail = new KittingDetailInput(); |
|
|
@ -210,8 +225,8 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, Kitt |
|
|
|
{ |
|
|
|
var existKittingList = importList.Where(p => existCodeList.Contains(p.Code)).ToList();//新Kitting
|
|
|
|
List<KittingEditInput> existKittingInputList = new List<KittingEditInput>(); |
|
|
|
List<KittingDetail> existKittingDetailList = new List<KittingDetail>(); |
|
|
|
List<KittingDetail> newKittingDetailList = new List<KittingDetail>(); |
|
|
|
//List<KittingDetail> existKittingDetailList = new List<KittingDetail>();
|
|
|
|
//List<KittingDetail> newKittingDetailList = new List<KittingDetail>();
|
|
|
|
foreach (var include in includeList) |
|
|
|
{ |
|
|
|
var newDetail = existKittingList.Where(p => p.Code == include.Code).ToList(); |
|
|
@ -334,12 +349,15 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, Kitt |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
var fileContent= _excelService.Export(errors); |
|
|
|
return new TestResult(fileContent.FileContents, ExportImportService.ContentType) { FileDownloadName="错误信息" }; |
|
|
|
} |
|
|
|
|
|
|
|
return new JsonResult(new { Code = 200, Message = "" }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileContent1 = _excelService.Export(importList); |
|
|
|
new TestResult(fileContent1.FileContents, ExportImportService.ContentType) { FileDownloadName = "导入文件" }; |
|
|
|
return new JsonResult(new { Code = 200, FileDownloadName="" }); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|