diff --git a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/SupplierController.java b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/SupplierController.java index bcb34a07..a13509fd 100644 --- a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/SupplierController.java +++ b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/SupplierController.java @@ -11,7 +11,6 @@ import com.nflg.wms.starter.BaseController; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; @@ -132,11 +131,11 @@ public class SupplierController extends BaseController { } /** - * 导出选中的供应商 + * 导出选中的供应商,为空时导出模版 * @param ids 选中的id集合 */ @PostMapping("export") - public void exportSelect(HttpServletResponse response,@Valid @RequestBody @NotEmpty List ids) throws Exception { + public void exportSelect(HttpServletResponse response,@RequestBody List ids) throws Exception { userControllerService.exportSupplier(response,ids); } } diff --git a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/UserControllerService.java b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/UserControllerService.java index 8bedfe0d..26e99c0c 100644 --- a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/UserControllerService.java +++ b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/UserControllerService.java @@ -28,7 +28,6 @@ import com.nflg.wms.starter.service.FileUploadService; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; @@ -447,8 +446,12 @@ public class UserControllerService { if (Objects.isNull(userSupplier)) { userSupplier = new UserSupplier(); user = new User(); + user.setCreateBy(UserUtil.getUserName()); + user.setCreateTime(LocalDateTime.now()); } else { user = uService.getById(userSupplier.getUserId()); + user.setUpdateBy(UserUtil.getUserName()); + user.setUpdateTime(LocalDateTime.now()); } } if (StrUtil.isBlank(dto.getSupplierName())) { @@ -491,8 +494,8 @@ public class UserControllerService { return false; } - public void exportSupplier(HttpServletResponse response, @Valid @NotEmpty List ids) throws IOException { - List users = vUserSupplierService.listByIds(ids); + public void exportSupplier(HttpServletResponse response, List ids) throws IOException { + List users = CollectionUtil.isNotEmpty(ids)?vUserSupplierService.listByIds(ids):new ArrayList<>(); List suppliersCategory = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_SUPPLIERS_CATEGORY); List datas = users.stream().map(vu -> { SupplierExcelExportDTO dto = new SupplierExcelExportDTO(); @@ -509,6 +512,17 @@ public class UserControllerService { }).collect(Collectors.toList()); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("供应商导出.xlsx", StandardCharsets.UTF_8)); + if (CollectionUtil.isEmpty(datas)){ + datas.add(new SupplierExcelExportDTO() + .setSupplierCode("(必填)供应商编号") + .setSupplierName("(必填)供应商名称") + .setTypeName("(必填)供应商类别") + .setUserName("负责人姓名") + .setUserCode("登录账号,不填则不开通账号") + .setPhone("负责人电话") + .setAbbreviation("供应商简称") + .setRemark("备注信息,此行为提示信息,导入时请删除")); + } new Workbook() .addSheet(new ListSheet<>(datas)) .writeTo(response.getOutputStream()); diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/SupplierExcelExportDTO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/SupplierExcelExportDTO.java index a149c92a..7dd7d039 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/SupplierExcelExportDTO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/SupplierExcelExportDTO.java @@ -1,9 +1,11 @@ package com.nflg.wms.common.pojo.dto; import lombok.Data; +import lombok.experimental.Accessors; import org.ttzero.excel.annotation.ExcelColumn; @Data +@Accessors(chain = true) public class SupplierExcelExportDTO { /** diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/VUserInterior.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/VUserInterior.java index 67ba5516..6a58313b 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/VUserInterior.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/VUserInterior.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; /** *

- * + * *

* * @author 代码生成器生成