|
|
@ -98,52 +98,47 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
/// <param name="file"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
[HttpPost("import-dongyang")] |
|
|
|
public async Task<IActionResult> ImportDYAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) |
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
|
|
|
|
using var ms = new MemoryStream(); |
|
|
|
await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); |
|
|
|
var inputFileBytes = ms.GetAllBytes(); |
|
|
|
var importList = _excelService.Import<UnplannedIssueRequestImportDto>(inputFileBytes).ToList(); |
|
|
|
await CreateByDYOAsync(importList, EnumUnplannedIssueType.IMPORT).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
List<UnplannedIssueRequestImportDto> errorsList = new List<UnplannedIssueRequestImportDto>(); |
|
|
|
|
|
|
|
foreach (var itm in importList) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(itm.CaseCode) |
|
|
|
|| string.IsNullOrEmpty(itm.ItemCode) |
|
|
|
|| itm.Qty == 0 |
|
|
|
|| string.IsNullOrEmpty(itm.ProjCapacityCode) |
|
|
|
|| string.IsNullOrEmpty(itm.FromLocationErpCode) |
|
|
|
//[HttpPost("import-dongyang")]
|
|
|
|
//public async Task<IActionResult> ImportDYAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file)
|
|
|
|
//{
|
|
|
|
// try
|
|
|
|
// {
|
|
|
|
// using var ms = new MemoryStream();
|
|
|
|
// await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false);
|
|
|
|
// var inputFileBytes = ms.GetAllBytes();
|
|
|
|
// var importList = _excelService.Import<UnplannedIssueRequestImportDto>(inputFileBytes).ToList();
|
|
|
|
// await CreateByDYOAsync(importList).ConfigureAwait(false);
|
|
|
|
// List<UnplannedIssueRequestImportDto> errorsList = new List<UnplannedIssueRequestImportDto>();
|
|
|
|
// foreach (var itm in importList)
|
|
|
|
// {
|
|
|
|
// if (string.IsNullOrEmpty(itm.CaseCode)
|
|
|
|
// || string.IsNullOrEmpty(itm.ItemCode)
|
|
|
|
// || itm.Qty == 0
|
|
|
|
// || string.IsNullOrEmpty(itm.ProjCapacityCode)
|
|
|
|
// || string.IsNullOrEmpty(itm.FromLocationErpCode)
|
|
|
|
|
|
|
|
) |
|
|
|
{ |
|
|
|
itm.Explain = "此项错误"; |
|
|
|
errorsList.Add(itm); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (errorsList.Count > 0) |
|
|
|
{ |
|
|
|
var fileContent = _excelService.Export(errorsList); |
|
|
|
return new TestResult(fileContent.FileContents, ExportImportService.ContentType) { FileDownloadName =fileContent.FileDownloadName }; |
|
|
|
} |
|
|
|
|
|
|
|
var fileContent1 = _excelService.Export(importList); |
|
|
|
// )
|
|
|
|
// {
|
|
|
|
// itm.Explain = "此项错误";
|
|
|
|
// errorsList.Add(itm);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (errorsList.Count > 0)
|
|
|
|
// {
|
|
|
|
// var fileContent = _excelService.Export(errorsList);
|
|
|
|
// return new TestResult(fileContent.FileContents, ExportImportService.ContentType) { FileDownloadName =fileContent.FileDownloadName };
|
|
|
|
// }
|
|
|
|
|
|
|
|
// var fileContent1 = _excelService.Export(importList);
|
|
|
|
|
|
|
|
return new JsonResult(new { Code = 200, FileDownloadName = fileContent1.FileDownloadName }); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException(e.Message); |
|
|
|
} |
|
|
|
} |
|
|
|
// return new JsonResult(new { Code = 200, FileDownloadName = fileContent1.FileDownloadName });
|
|
|
|
// }
|
|
|
|
// catch (Exception e)
|
|
|
|
// {
|
|
|
|
// throw new UserFriendlyException(e.Message);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -191,7 +186,7 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
UnplannedIssueRequestDTO request = new UnplannedIssueRequestDTO(); |
|
|
|
try |
|
|
|
{ |
|
|
|
return await CreateByDYOAsync(p_list, EnumUnplannedIssueType.OA, true).ConfigureAwait(false); |
|
|
|
return await CreateByDYOAsync(p_list, true).ConfigureAwait(false); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
@ -205,7 +200,7 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected async Task<UnplannedIssueRequestDTO> CreateByDYOAsync(List<UnplannedIssueRequestImportDto> p_list, EnumUnplannedIssueType type, bool isAutoSubmit=false) |
|
|
|
protected async Task<UnplannedIssueRequestDTO> CreateByDYOAsync(List<UnplannedIssueRequestImportDto> p_list, bool isAutoSubmit=false) |
|
|
|
{ |
|
|
|
UnplannedIssueRequest request = new UnplannedIssueRequest(); |
|
|
|
if (p_list.Count == 0) |
|
|
@ -214,7 +209,7 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
} |
|
|
|
|
|
|
|
var first = p_list.FirstOrDefault(); |
|
|
|
request.UnplannedIssueType = type; |
|
|
|
|
|
|
|
request.SetId(GuidGenerator.Create()); |
|
|
|
request.AutoCompleteJob = false; |
|
|
|
request.AutoSubmit = isAutoSubmit; |
|
|
|