|
|
@ -27,6 +27,8 @@ import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.io.IOException; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.ZoneOffset; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
@ -192,13 +194,19 @@ public class ItembasicController { |
|
|
|
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") |
|
|
|
}) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:itembasic:import')") |
|
|
|
public void importExcel(HttpServletResponse response, |
|
|
|
public CommonResult<Map<String, Object>> importExcel(HttpServletResponse response, |
|
|
|
@RequestParam("file") MultipartFile file, |
|
|
|
@RequestParam(value = "mode") Integer mode, |
|
|
|
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { |
|
|
|
List<ItembasicImportExcelVo> list = ExcelUtils.read(file, ItembasicImportExcelVo.class); |
|
|
|
List<ItembasicImportExcelVo> errorList = itembasicService.importUserList(list, mode, updatePart); |
|
|
|
ExcelUtils.write(response, "物品基本信息导入错误数据.xls", "错误列表", ItembasicImportExcelVo.class, errorList); |
|
|
|
Map<String, Object> returnMap = new HashMap<>(); |
|
|
|
returnMap.put("errorCount", errorList.size()); |
|
|
|
if(!errorList.isEmpty()) { |
|
|
|
String url = ExcelUtils.writeLocalFile("用户导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xls", "错误列表", errorList); |
|
|
|
returnMap.put("errorFile", url); |
|
|
|
} |
|
|
|
return success(returnMap); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|