小修改
This commit is contained in:
parent
838127c200
commit
39ba91f3ba
@ -20,7 +20,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -189,8 +188,8 @@ public class RepairWaresController {
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
||||
})
|
||||
public CommonResult<RepairWaresExcelRespVO> importData(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception{
|
||||
public CommonResult<ImportExcelRespVO> importData(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception{
|
||||
List<RepairWaresExcelVO> list = ExcelUtils.read(file, RepairWaresExcelVO.class);
|
||||
return success(waresService.importData(list, updateSupport));
|
||||
}
|
||||
|
@ -85,5 +85,5 @@ public interface RepairWaresService extends IService<RepairWares> {
|
||||
* @author 小李
|
||||
* @date 16:20 2024/11/29
|
||||
**/
|
||||
RepairWaresExcelRespVO importData(List<RepairWaresExcelVO> list, Boolean updateSupport);
|
||||
ImportExcelRespVO importData(List<RepairWaresExcelVO> list, Boolean updateSupport);
|
||||
}
|
@ -151,7 +151,7 @@ public class RepairWaresServiceImpl extends ServiceImpl<RepairWaresMapper, Repai
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public RepairWaresExcelRespVO importData(List<RepairWaresExcelVO> list, Boolean updateSupport) {
|
||||
public ImportExcelRespVO importData(List<RepairWaresExcelVO> list, Boolean updateSupport) {
|
||||
// 参数校验
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception0(500, "导入配件数据不能为空!");
|
||||
@ -166,7 +166,7 @@ public class RepairWaresServiceImpl extends ServiceImpl<RepairWaresMapper, Repai
|
||||
Map<String, String> typesMap = types.stream().collect(Collectors.toMap(BaseType::getName, BaseType::getId));
|
||||
|
||||
// 遍历,逐个创建 or 更新
|
||||
RepairWaresExcelRespVO result = RepairWaresExcelRespVO.builder().createNames(new ArrayList<>())
|
||||
ImportExcelRespVO result = ImportExcelRespVO.builder().createNames(new ArrayList<>())
|
||||
.updateNames(new ArrayList<>()).failureNames(new LinkedHashMap<>()).build();
|
||||
list.forEach(item -> {
|
||||
// 验证是否存在,用selectList防止本来就有多个导致的报错
|
||||
|
@ -7,14 +7,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导入配件数据后的响应
|
||||
* 导入数据的时候用的通用的响应
|
||||
*
|
||||
* @author 小李
|
||||
* @date 16:22 2024/11/29
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
public class RepairWaresExcelRespVO {
|
||||
public class ImportExcelRespVO {
|
||||
|
||||
/** 导入成功的配件名称集合 */
|
||||
private List<String> createNames;
|
Loading…
Reference in New Issue
Block a user