From c1e82f45ed1f1cd8dcb6748a2727bf03aa3a188c Mon Sep 17 00:00:00 2001 From: zhangke Date: Thu, 25 Sep 2025 11:21:29 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E5=AF=BC=E5=87=BA=E5=92=8C=E5=AF=BC=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=202=E3=80=81=E4=BF=AE=E6=94=B9=E6=97=A0=E7=A0=81?= =?UTF-8?q?=E6=94=B6=E8=B4=A7=E6=9F=A5=E8=AF=A2=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=8D=95=E6=8D=AE=E7=BC=96=E5=8F=B7=E6=90=9C=E7=B4=A2=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/NormalPGIController.java | 17 +++- .../admin/controller/SupplierController.java | 16 ++++ .../admin/service/UserControllerService.java | 84 ++++++++++++++----- .../pojo/dto/SupplierExcelExportDTO.java | 4 +- .../pojo/qo/BarcodeLessReceivingSearchQO.java | 5 ++ .../repository/mapper/UserSupplierMapper.java | 3 + .../service/IUserSupplierService.java | 3 + .../service/impl/UserSupplierServiceImpl.java | 3 + 8 files changed, 108 insertions(+), 27 deletions(-) diff --git a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/NormalPGIController.java b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/NormalPGIController.java index 7ab871db..6b87bca5 100644 --- a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/NormalPGIController.java +++ b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/NormalPGIController.java @@ -657,10 +657,19 @@ public class NormalPGIController extends BaseController { @ApiMark(moduleName = "送货单管理", apiName = "一键收货查询") public ApiResult> getDeliveryByNoScan(@Valid @RequestBody BarcodeLessReceivingSearchQO request) { List list = new ArrayList<>(); - List orders = wmsSrmOrderService.lambdaQuery() - .in(WmsSrmOrder::getId, request.getId()) - .eq(WmsSrmOrder::getIsCompleted, false) - .list(); + List orders = null; + if (Objects.isNull(request.getId()) && request.getId() > 0) { + orders = wmsSrmOrderService.lambdaQuery() + .eq(WmsSrmOrder::getId, request.getId()) + .eq(WmsSrmOrder::getIsCompleted, false) + .list(); + } else { + orders = wmsSrmOrderService.lambdaQuery() + .eq(WmsSrmOrder::getNoteNum, request.getOrderNo()) + .eq(WmsSrmOrder::getIsCompleted, false) + .list(); + } + VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(orders)).throwMessage("不存在未完成收货的物料!"); // 查找订单信息 List items = wmsSrmOrderItemService.lambdaQuery() 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 bf28daea..12c6ad6b 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 @@ -1,5 +1,7 @@ package com.nflg.wms.admin.controller; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.nflg.wms.admin.service.UserControllerService; import com.nflg.wms.common.pojo.ApiResult; import com.nflg.wms.common.pojo.PageData; @@ -7,12 +9,14 @@ import com.nflg.wms.common.pojo.qo.*; import com.nflg.wms.common.pojo.vo.RoleSimpleVO; import com.nflg.wms.common.pojo.vo.UserSupplierItemVO; import com.nflg.wms.common.pojo.vo.UserSupplierVO; +import com.nflg.wms.common.util.VUtil; import com.nflg.wms.repository.entity.DictionaryItem; import com.nflg.wms.starter.BaseController; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; +import org.postgresql.core.Utils; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -155,4 +159,16 @@ public class SupplierController extends BaseController { public void exportSelect(HttpServletResponse response, @RequestBody(required = false) List ids) throws Exception { userControllerService.exportSupplier(response, ids); } + + /** + * 导出供应商 + * @param request 搜索参数 + */ + @PostMapping("exportall") + public void exportALL(HttpServletResponse response, @Valid @RequestBody UserSupplierSearchQO request) throws Exception { + request.setPageSize(Integer.MAX_VALUE); + IPage data = userControllerService.searchSupplier(request); + VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(data.getRecords())).throwMessage("数据不存在"); + userControllerService.exportSupplierByFilter(response, data.getRecords()); + } } 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 74ec6913..d0b216d6 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 @@ -466,7 +466,7 @@ public class UserControllerService { VUtil.trueThrowBusinessError(Objects.isNull(userSupplier) || StrUtil.isBlank(userSupplier.getSupplierCode())) .throwMessage("供应商不存在"); if (userSupplier.getIsOpenAccount()) { - enableUser(userSupplier.getUserId(),request.getEnable()?1:2); + enableUser(userSupplier.getUserId(), request.getEnable() ? 1 : 2); } userSupplierService.lambdaUpdate().set(UserSupplier::getState, request.getEnable() ? 1 : 2) .set(UserSupplier::getUpdateBy, UserUtil.getUserName()) @@ -523,7 +523,7 @@ public class UserControllerService { new Workbook() .addSheet(new ListSheet<>(data)) .writeTo(osOut); - try(ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) { + try (ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) { return ApiResult.error(STATE.DataNoCheckPass, "导入文件失败", fileUploadService.upload("temp/" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "/" + IdUtil.fastUUID() + ".xlsx", isIn, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")); } } catch (Exception e) { @@ -542,19 +542,16 @@ public class UserControllerService { List suppliersCategory = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_SUPPLIERS_CATEGORY); List userSuppliers = new ArrayList<>(); for (SupplierExcelDTO dto : data) { - UserSupplier userSupplier = new UserSupplier(); + Long typeId = 0L; + UserSupplier userSupplier = null;// new UserSupplier(); StringBuilder sb = new StringBuilder(); if (Objects.isNull(dto.getSupplierCode())) { sb.append("供应商编号不能为空;"); } else if (data.stream().filter(item -> StrUtil.equals(item.getSupplierCode(), dto.getSupplierCode())).count() > 1) { sb.append("供应商编号重复;"); - } else { - userSupplier = userSupplierService.lambdaQuery().eq(UserSupplier::getSupplierCode, dto.getSupplierCode()).one(); } if (StrUtil.isBlank(dto.getSupplierName())) { sb.append("供应商名称不能为空;"); - } else { - userSupplier.setSupplierName(dto.getSupplierName()); } if (StrUtil.isBlank(dto.getTypeName())) { sb.append("供应商类别不能为空;"); @@ -563,24 +560,38 @@ public class UserControllerService { if (Objects.isNull(type)) { sb.append("供应商类别无效;"); } else { - userSupplier.setTypeId(type.getId()); + typeId = type.getId(); } } - userSupplier.setUserId(0L); + if (sb.length() > 0) { + dto.setResult(sb.toString()); + continue; + } +// if (data.stream().noneMatch(it -> StrUtil.isBlank(it.getResult()))) { +// return false; +// } + userSupplier = userSupplierService.lambdaQuery().eq(UserSupplier::getSupplierCode, dto.getSupplierCode()).one(); + if (Objects.isNull(userSupplier)) { + userSupplier = new UserSupplier(); + userSupplier.setUserId(0L); + userSupplier.setDefaultLanguage(""); + userSupplier.setAvatar(""); + userSupplier.setState(1); + userSupplier.setIsOpenAccount(false); + userSupplier.setCreateBy(UserUtil.getUserName()); + userSupplier.setCreateTime(LocalDateTime.now()); + userSupplier.setUpdateBy(UserUtil.getUserName()); + userSupplier.setUpdateTime(LocalDateTime.now()); + } + userSupplier.setSupplierName(dto.getSupplierName()); + userSupplier.setTypeId(typeId); + userSupplier.setSupplierCode(dto.getSupplierCode()); + userSupplier.setPciName(dto.getUserName()); + userSupplier.setPciPhone(dto.getPhone()); userSupplier.setAbbreviation(dto.getAbbreviation()); userSupplier.setAbbreviation1(StringUtil.toPinYin(dto.getAbbreviation())); userSupplier.setAbbreviation2(StringUtil.getPinYinFirstLetter(dto.getAbbreviation())); - userSupplier.setPciName(dto.getUserName()); - userSupplier.setPciPhone(dto.getPhone()); - userSupplier.setDefaultLanguage(""); - userSupplier.setAvatar(""); - userSupplier.setState(1); - userSupplier.setIsOpenAccount(false); userSupplier.setRemark(dto.getRemark()); - userSupplier.setCreateBy(UserUtil.getUserName()); - userSupplier.setCreateTime(LocalDateTime.now()); - userSupplier.setUpdateBy(UserUtil.getUserName()); - userSupplier.setUpdateTime(LocalDateTime.now()); dto.setResult(sb.toString()); userSuppliers.add(userSupplier); } @@ -604,7 +615,7 @@ public class UserControllerService { DictionaryItem type = suppliersCategory.stream().filter(it -> Objects.equals(it.getId(), vu.getTypeId())).findFirst().get(); dto.setTypeName(type.getName()); dto.setRemark(vu.getRemark()); - dto.setUserCode(vu.getUserCode()); + // dto.setUserCode(vu.getUserCode()); return dto; }).collect(Collectors.toList()); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); @@ -615,7 +626,7 @@ public class UserControllerService { .setSupplierName("供应商名称") .setTypeName("供应商类别") .setUserName("负责人姓名") - .setUserCode("登录账号,不填则不开通账号") + // .setUserCode("登录账号,不填则不开通账号") .setPhone("负责人电话") .setAbbreviation("供应商简称") .setRemark("备注信息,此行为提示信息,导入时请删除")); @@ -717,4 +728,35 @@ public class UserControllerService { } return vo; } + + public void exportSupplierByFilter(HttpServletResponse response, List records) throws IOException { + List datas = records.stream().map(vu -> { + SupplierExcelExportDTO dto = new SupplierExcelExportDTO(); + dto.setSupplierCode(vu.getSupplierCode()); + dto.setSupplierName(vu.getSupplierName()); + dto.setAbbreviation(vu.getAbbreviation()); + dto.setUserName(vu.getPciName()); + dto.setPhone(vu.getPciPhone()); + //DictionaryItem type = suppliersCategory.stream().filter(it -> Objects.equals(it.getId(), vu.getTypeId())).findFirst().get(); + dto.setTypeName(vu.getTypeName()); + dto.setRemark(vu.getRemark()); + // dto.setUserCode(vu.getSupplierCode()); + return dto; + }).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("负责人姓名") + .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 7dd7d039..b880ad47 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 @@ -47,8 +47,8 @@ public class SupplierExcelExportDTO { /** * 登录账号 */ - @ExcelColumn("登录账号") - private String userCode; +// @ExcelColumn("登录账号") +// private String userCode; /** * 备注 diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/BarcodeLessReceivingSearchQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/BarcodeLessReceivingSearchQO.java index af10b644..0bb9647b 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/BarcodeLessReceivingSearchQO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/BarcodeLessReceivingSearchQO.java @@ -10,4 +10,9 @@ public class BarcodeLessReceivingSearchQO { * 送货单Id */ private Long id; + + /** + * 订单号 ,和送货单号二选一 + */ + private String orderNo; } diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/UserSupplierMapper.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/UserSupplierMapper.java index 7b3026c6..7274e6e4 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/UserSupplierMapper.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/mapper/UserSupplierMapper.java @@ -7,6 +7,8 @@ import com.nflg.wms.common.pojo.qo.UserSupplierSearchQO; import com.nflg.wms.common.pojo.vo.UserSupplierVO; import com.nflg.wms.repository.entity.UserSupplier; +import java.util.List; + /** *

* Mapper 接口 @@ -18,4 +20,5 @@ import com.nflg.wms.repository.entity.UserSupplier; public interface UserSupplierMapper extends BaseMapper { IPage search(UserSupplierSearchQO request, Page objectPage); + } diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IUserSupplierService.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IUserSupplierService.java index b26f8cc4..7fba9a12 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IUserSupplierService.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/IUserSupplierService.java @@ -8,6 +8,8 @@ import com.nflg.wms.repository.entity.UserSupplier; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; +import java.util.List; + /** *

* 服务类 @@ -27,4 +29,5 @@ public interface IUserSupplierService extends IService { UserSupplier getByUserId(Long id); UserSupplier getByCode(@NotBlank String supplierNo); + } diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/UserSupplierServiceImpl.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/UserSupplierServiceImpl.java index c9804b19..3aa7892a 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/UserSupplierServiceImpl.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/UserSupplierServiceImpl.java @@ -14,6 +14,8 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + /** *

* 服务实现类 @@ -65,4 +67,5 @@ public class UserSupplierServiceImpl extends ServiceImpl