Merge branch 'template' into develop

This commit is contained in:
曹鹏飞 2025-07-01 15:18:53 +08:00
commit 1c2867b0ef
4 changed files with 22 additions and 7 deletions

View File

@ -11,7 +11,6 @@ import com.nflg.wms.starter.BaseController;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -132,11 +131,11 @@ public class SupplierController extends BaseController {
} }
/** /**
* 导出选中的供应商 * 导出选中的供应商为空时导出模版
* @param ids 选中的id集合 * @param ids 选中的id集合
*/ */
@PostMapping("export") @PostMapping("export")
public void exportSelect(HttpServletResponse response,@Valid @RequestBody @NotEmpty List<Long> ids) throws Exception { public void exportSelect(HttpServletResponse response,@RequestBody List<Long> ids) throws Exception {
userControllerService.exportSupplier(response,ids); userControllerService.exportSupplier(response,ids);
} }
} }

View File

@ -28,7 +28,6 @@ import com.nflg.wms.starter.service.FileUploadService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -447,8 +446,12 @@ public class UserControllerService {
if (Objects.isNull(userSupplier)) { if (Objects.isNull(userSupplier)) {
userSupplier = new UserSupplier(); userSupplier = new UserSupplier();
user = new User(); user = new User();
user.setCreateBy(UserUtil.getUserName());
user.setCreateTime(LocalDateTime.now());
} else { } else {
user = uService.getById(userSupplier.getUserId()); user = uService.getById(userSupplier.getUserId());
user.setUpdateBy(UserUtil.getUserName());
user.setUpdateTime(LocalDateTime.now());
} }
} }
if (StrUtil.isBlank(dto.getSupplierName())) { if (StrUtil.isBlank(dto.getSupplierName())) {
@ -491,8 +494,8 @@ public class UserControllerService {
return false; return false;
} }
public void exportSupplier(HttpServletResponse response, @Valid @NotEmpty List<Long> ids) throws IOException { public void exportSupplier(HttpServletResponse response, List<Long> ids) throws IOException {
List<VUserSupplier> users = vUserSupplierService.listByIds(ids); List<VUserSupplier> users = CollectionUtil.isNotEmpty(ids)?vUserSupplierService.listByIds(ids):new ArrayList<>();
List<DictionaryItem> suppliersCategory = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_SUPPLIERS_CATEGORY); List<DictionaryItem> suppliersCategory = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_SUPPLIERS_CATEGORY);
List<SupplierExcelExportDTO> datas = users.stream().map(vu -> { List<SupplierExcelExportDTO> datas = users.stream().map(vu -> {
SupplierExcelExportDTO dto = new SupplierExcelExportDTO(); SupplierExcelExportDTO dto = new SupplierExcelExportDTO();
@ -509,6 +512,17 @@ public class UserControllerService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("供应商导出.xlsx", StandardCharsets.UTF_8)); 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() new Workbook()
.addSheet(new ListSheet<>(datas)) .addSheet(new ListSheet<>(datas))
.writeTo(response.getOutputStream()); .writeTo(response.getOutputStream());

View File

@ -1,9 +1,11 @@
package com.nflg.wms.common.pojo.dto; package com.nflg.wms.common.pojo.dto;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import org.ttzero.excel.annotation.ExcelColumn; import org.ttzero.excel.annotation.ExcelColumn;
@Data @Data
@Accessors(chain = true)
public class SupplierExcelExportDTO { public class SupplierExcelExportDTO {
/** /**

View File

@ -11,7 +11,7 @@ import java.time.LocalDateTime;
/** /**
* <p> * <p>
* *
* </p> * </p>
* *
* @author 代码生成器生成 * @author 代码生成器生成