| | |
| | | }; |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importInOrder", ""); |
| | | } |
| | | if (importMaterials.GroupBy(x => x.Code).Any(g => g.Count() > 1)) |
| | | //if (importMaterials.GroupBy(x => x.Code).Any(g => g.Count() > 1)) |
| | | //{ |
| | | // responseMessage = new ApiResponse<string>() |
| | | // { |
| | | // Code = 500, |
| | | // Success = false, |
| | | // Message = "本次请求中物料号不能重复", |
| | | // Data = null, |
| | | // }; |
| | | // return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | //} |
| | | // 按物料号分组,并找出有重复的组 |
| | | var duplicateGroups = importMaterials |
| | | .GroupBy(x => x.Code) |
| | | .Where(g => g.Count() > 1) |
| | | .ToList(); |
| | | |
| | | if (duplicateGroups.Any()) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | // 收集所有重复的物料号 |
| | | var duplicateCodes = duplicateGroups |
| | | .Select(g => g.Key) // 每个组的Key就是物料号(Code) |
| | | .OrderBy(code => code) // 可选:排序,让输出更整齐 |
| | | .ToList(); |
| | | |
| | | // 构造友好的提示信息 |
| | | var message = $"本次入库请求中物料号不能重复,重复物料号有:{string.Join("、", duplicateCodes)}"; |
| | | |
| | | responseMessage = new ApiResponse<string> |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "本次请求中物料号不能重复", |
| | | Message = message, |
| | | Data = null, |
| | | }; |
| | | |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | } |
| | | #endregion |
| | |
| | | }; |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | } |
| | | if (inputmaterials.GroupBy(x => x.Code).Any(g => g.Count() > 1)) |
| | | // 按物料号分组,并找出有重复的组 |
| | | var duplicateGroups = inputmaterials |
| | | .GroupBy(x => x.Code) |
| | | .Where(g => g.Count() > 1) |
| | | .ToList(); |
| | | |
| | | if (duplicateGroups.Any()) |
| | | { |
| | | responseMessage = new ApiResponse<string>() |
| | | // 收集所有重复的物料号 |
| | | var duplicateCodes = duplicateGroups |
| | | .Select(g => g.Key) // 每个组的Key就是物料号(Code) |
| | | .OrderBy(code => code) // 可选:排序,让输出更整齐 |
| | | .ToList(); |
| | | |
| | | // 构造友好的提示信息 |
| | | var message = $"本次出库请求中物料号不能重复,重复物料号有:{string.Join("、", duplicateCodes)}"; |
| | | |
| | | responseMessage = new ApiResponse<string> |
| | | { |
| | | Code = 500, |
| | | Success = false, |
| | | Message = "本次请求中物料号不能重复", |
| | | Message = message, |
| | | Data = null, |
| | | }; |
| | | |
| | | return ApiResponseHelper.ReturnApiResponse(responseMessage, "importOutOrder", ""); |
| | | } |
| | | #endregion |