diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java index 82b4661..a969aab 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java @@ -140,14 +140,20 @@ public class CreditUserController extends BaseController { @PreAuthorize("hasAuthority('credit:creditUser:save')") @Operation(summary = "批量导入赊账客户") @PostMapping("/import") - public ApiResult> importBatch(MultipartFile file) { + public ApiResult> importBatch(@RequestParam("file") MultipartFile file) { ImportParams importParams = new ImportParams(); + importParams.setTitleRows(1); + importParams.setHeadRows(1); List errorMessages = new ArrayList<>(); int successCount = 0; try { List list = ExcelImportUtil.importExcel(file.getInputStream(), CreditUserImportParam.class, importParams); + if (list == null || list.isEmpty()) { + return fail("未读取到数据,请确认模板表头与示例格式一致", null); + } + User loginUser = getLoginUser(); Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; @@ -155,7 +161,6 @@ public class CreditUserController extends BaseController { CreditUserImportParam param = list.get(i); try { CreditUser item = convertImportParamToEntity(param); - System.out.println("item = " + item); // 设置默认值 if (item.getUserId() == null && currentUserId != null) { diff --git a/src/main/java/com/gxwebsoft/credit/param/CreditUserImportParam.java b/src/main/java/com/gxwebsoft/credit/param/CreditUserImportParam.java new file mode 100644 index 0000000..706bf44 --- /dev/null +++ b/src/main/java/com/gxwebsoft/credit/param/CreditUserImportParam.java @@ -0,0 +1,80 @@ +package com.gxwebsoft.credit.param; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + +/** + * 赊账客户导入参数 + * + * @author 科技小王子 + * @since 2025-12-15 + */ +@Data +public class CreditUserImportParam implements Serializable { + private static final long serialVersionUID = 1L; + + @Excel(name = "客户名称") + private String name; + + @Excel(name = "唯一标识") + private String code; + + @Excel(name = "类型", replace = {"普通用户_0", "招投标_1"}) + private Integer type; + + @Excel(name = "企业角色") + private String role; + + @Excel(name = "上级ID") + private Integer parentId; + + @Excel(name = "信息类型") + private String infoType; + + @Excel(name = "所在国家") + private String country; + + @Excel(name = "所在省份") + private String province; + + @Excel(name = "所在城市") + private String city; + + @Excel(name = "所在辖区") + private String region; + + @Excel(name = "街道地址") + private String address; + + @Excel(name = "招采单位名称") + private String procurementName; + + @Excel(name = "中标单位名称") + private String winningName; + + @Excel(name = "中标金额") + private String winningPrice; + + @Excel(name = "备注") + private String comments; + + @Excel(name = "是否推荐", replace = {"否_0", "是_1"}) + private Integer recommend; + + @Excel(name = "到期时间", format = "yyyy-MM-dd HH:mm:ss") + private String expirationTime; + + @Excel(name = "排序") + private Integer sortNumber; + + @Excel(name = "状态", replace = {"正常_0", "冻结_1"}) + private Integer status; + + @Excel(name = "用户ID") + private Integer userId; + + @Excel(name = "租户ID") + private Integer tenantId; +}