Compare commits

..

2 Commits

Author SHA1 Message Date
曹鹏飞 7aa04aa2ee chore(config): 新增和调整各微服务配置文件
- 新增 nflg-qms-admin、nflg-wms-admin、nflg-wms-auth、nflg-wms-gateway、nflg-wms-scheduled、nflg-wms-shipment、nflg-wms-srm-receive 应用配置
- 配置服务端端口及Tomcat最大表单提交大小
- 各服务配置Nacos注册中心及配置管理,支持配置文件自动刷新
- 设置Spring Boot应用名、激活开发环境配置
- 配置文件上传大小限制及多部分请求大小限制
- 全局开启管理端点,配置健康检查和日志级别
- sa-token 配置JWT及SSO参数于认证服务中
- 调整wms-admin生产环境nacos日志级别为info,降低trace日志输出
2026-04-17 14:38:11 +08:00
曹鹏飞 0d2ccc6e62 修正对象lambda更新中的条件传参,确保删除逻辑正确执行 2026-04-17 09:56:48 +08:00
9 changed files with 73 additions and 65 deletions

View File

@ -13,6 +13,8 @@ spring:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud: cloud:
nacos: nacos:
username: wms
password: wms
config: config:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms
@ -21,6 +23,8 @@ spring:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms
group: ${spring.profiles.active} group: ${spring.profiles.active}
username: wms
password: wms
servlet: servlet:
multipart: multipart:
max-file-size: 200MB max-file-size: 200MB

View File

@ -7,7 +7,7 @@ logging:
nflg: debug nflg: debug
alibaba: alibaba:
cloud: cloud:
nacos: trace nacos: info
org: org:
springframework: info springframework: info
# sa-token配置 # sa-token配置

View File

@ -13,8 +13,8 @@ spring:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud: cloud:
nacos: nacos:
username: wms username: ${nacos.username:}
password: wms password: ${nacos.password:}
config: config:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms

View File

@ -9,12 +9,14 @@ spring:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud: cloud:
nacos: nacos:
username: wms username: ${nacos.username:}
password: wms password: ${nacos.password:}
config: config:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms
group: ${spring.profiles.active} group: ${spring.profiles.active}
file-extension: properties
refresh-enabled: true
discovery: discovery:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms

View File

@ -9,12 +9,14 @@ spring:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud: cloud:
nacos: nacos:
username: wms username: ${nacos.username:}
password: wms password: ${nacos.password:}
config: config:
server-addr: ${nacos.server-addr:112.74.186.154:8848} server-addr: ${nacos.server-addr:112.74.186.154:8848}
namespace: wms namespace: wms
group: ${spring.profiles.active} group: ${spring.profiles.active}
file-extension: properties
refresh-enabled: true
discovery: discovery:
server-addr: ${nacos.server-addr:112.74.186.154:8848} server-addr: ${nacos.server-addr:112.74.186.154:8848}
namespace: wms namespace: wms

View File

@ -9,12 +9,14 @@ spring:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud: cloud:
nacos: nacos:
username: wms username: ${nacos.username:}
password: wms password: ${nacos.password:}
config: config:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms
group: ${spring.profiles.active} group: ${spring.profiles.active}
file-extension: properties
refresh-enabled: true
discovery: discovery:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms

View File

@ -9,10 +9,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.wms.common.pojo.ApiResult; import com.nflg.wms.common.pojo.ApiResult;
import com.nflg.wms.common.pojo.PageData; import com.nflg.wms.common.pojo.PageData;
import com.nflg.wms.common.pojo.dto.MaterialCodePrintDTO;
import com.nflg.wms.common.pojo.dto.MaterialPdfDTO; import com.nflg.wms.common.pojo.dto.MaterialPdfDTO;
import com.nflg.wms.common.pojo.qo.*; import com.nflg.wms.common.pojo.qo.*;
import com.nflg.wms.common.pojo.vo.*; import com.nflg.wms.common.pojo.vo.MaterialPdfVO;
import com.nflg.wms.common.pojo.vo.ShipmentMaterialCodeItemVO;
import com.nflg.wms.common.pojo.vo.ShipmentMaterialCodeQRVO;
import com.nflg.wms.common.util.EecExcelUtil; import com.nflg.wms.common.util.EecExcelUtil;
import com.nflg.wms.common.util.NumberUtil; import com.nflg.wms.common.util.NumberUtil;
import com.nflg.wms.common.util.UserUtil; import com.nflg.wms.common.util.UserUtil;
@ -49,8 +50,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -136,7 +137,7 @@ public class MaterialCodeController extends BaseController {
if (CollectionUtil.isNotEmpty(idsForDelete)) { if (CollectionUtil.isNotEmpty(idsForDelete)) {
materialCodeService.removeByIds(idsForDelete); materialCodeService.removeByIds(idsForDelete);
materialCodeForwardService.lambdaUpdate() materialCodeForwardService.lambdaUpdate()
.in(WmsShipmentMaterialCodeForward::getMaterialCodeId) .in(WmsShipmentMaterialCodeForward::getMaterialCodeId, idsForDelete)
.remove(); .remove();
idsForDelete = materialCodeItemService.lambdaQuery() idsForDelete = materialCodeItemService.lambdaQuery()
.in(WmsShipmentMaterialCodeItem::getMaterialCodeId, idsForDelete) .in(WmsShipmentMaterialCodeItem::getMaterialCodeId, idsForDelete)
@ -399,7 +400,6 @@ public class MaterialCodeController extends BaseController {
/** /**
* 清单明细-导入 * 清单明细-导入
*
* @param materialCodeId 清单ID * @param materialCodeId 清单ID
* @param cover 导入模式true:覆盖false:新增 * @param cover 导入模式true:覆盖false:新增
* @param file 文件 * @param file 文件
@ -558,7 +558,6 @@ public class MaterialCodeController extends BaseController {
/** /**
* 清单明细-根据二维码唯一号获取物料信息PDA使用 * 清单明细-根据二维码唯一号获取物料信息PDA使用
*
* @param code 二维码唯一号 * @param code 二维码唯一号
*/ */
@GetMapping("getInfoByQRCode") @GetMapping("getInfoByQRCode")
@ -588,7 +587,6 @@ public class MaterialCodeController extends BaseController {
/** /**
* 根据清单导出标签图片ZIP用于直连打印机打印 * 根据清单导出标签图片ZIP用于直连打印机打印
*
* @param ids 清单id列表 * @param ids 清单id列表
*/ */
@PostMapping("exportItemImageZip1") @PostMapping("exportItemImageZip1")
@ -600,7 +598,6 @@ public class MaterialCodeController extends BaseController {
/** /**
* 根据清单项导出标签图片ZIP用于直连打印机打印 * 根据清单项导出标签图片ZIP用于直连打印机打印
*
* @param ids 清单明细id列表 * @param ids 清单明细id列表
*/ */
@PostMapping("exportItemImageZip") @PostMapping("exportItemImageZip")
@ -643,7 +640,6 @@ public class MaterialCodeController extends BaseController {
/** /**
* 代发物料-导入 * 代发物料-导入
*
* @param id 清单ID * @param id 清单ID
*/ */
@PostMapping("importForward") @PostMapping("importForward")
@ -762,32 +758,32 @@ public class MaterialCodeController extends BaseController {
@PostMapping("exportPdf") @PostMapping("exportPdf")
public ApiResult<String> exportPdf(HttpServletResponse response, @Valid @RequestBody MaterialPdfExportQO qo) throws Exception { public ApiResult<String> exportPdf(HttpServletResponse response, @Valid @RequestBody MaterialPdfExportQO qo) throws Exception {
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(qo.getIds())).throwMessage("没有需要导出的数据"); VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(qo.getIds())).throwMessage("没有需要导出的数据");
// 每页数量校验 // 每页数量校验
Integer perPage = qo.getPerPage() != null ? qo.getPerPage() : 6; Integer perPage = qo.getPerPage() != null ? qo.getPerPage() : 6;
List<Integer> validPerPage = List.of(2, 4, 6, 8, 9); List<Integer> validPerPage = List.of(2, 4, 6, 8, 9);
VUtil.trueThrowBusinessError(!validPerPage.contains(perPage)).throwMessage("每页数量只能为2/4/6/8/9"); VUtil.trueThrowBusinessError(!validPerPage.contains(perPage)).throwMessage("每页数量只能为2/4/6/8/9");
// list 中提取物料ID明细ID // list 中提取物料ID明细ID
List<Long> materialIds = qo.getIds().stream() List<Long> materialIds = qo.getIds().stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
.toList(); .toList();
VUtil.trueThrowBusinessError(materialIds.isEmpty()).throwMessage("物料ID不能为空"); VUtil.trueThrowBusinessError(materialIds.isEmpty()).throwMessage("物料ID不能为空");
// 根据前端传入的物料ID查询对应的物料编号再查询物料主数据 // 根据前端传入的物料ID查询对应的物料编号再查询物料主数据
List<WmsShipmentMaterialCodeItem> materialCodeItems = materialCodeItemService.lambdaQuery() List<WmsShipmentMaterialCodeItem> materialCodeItems = materialCodeItemService.lambdaQuery()
.in(WmsShipmentMaterialCodeItem::getId, materialIds) .in(WmsShipmentMaterialCodeItem::getId, materialIds)
.list(); .list();
List<String> materialNos = materialCodeItems.stream() List<String> materialNos = materialCodeItems.stream()
.map(WmsShipmentMaterialCodeItem::getMaterialNo) .map(WmsShipmentMaterialCodeItem::getMaterialNo)
.distinct() .distinct()
.toList(); .toList();
List<WmsShipmentMaterial> shipmentMaterials = materialService.lambdaQuery() List<WmsShipmentMaterial> shipmentMaterials = materialService.lambdaQuery()
.in(WmsShipmentMaterial::getNo, materialNos) .in(WmsShipmentMaterial::getNo, materialNos)
.list(); .list();
// 将主数据转换成PDF需要的DTO列表 // 将主数据转换成PDF需要的DTO列表
List<MaterialPdfDTO> items = Convert.toList(MaterialPdfDTO.class, materialCodeItems); List<MaterialPdfDTO> items = Convert.toList(MaterialPdfDTO.class, materialCodeItems);
Map<String, WmsShipmentMaterial> materialMap = shipmentMaterials.stream() Map<String, WmsShipmentMaterial> materialMap = shipmentMaterials.stream()
@ -800,7 +796,7 @@ public class MaterialCodeController extends BaseController {
dto.setDrawingNo(mat.getDrawingNo()); dto.setDrawingNo(mat.getDrawingNo());
} }
} }
// 计算总重量 = 单个重量 * 数量 累加 // 计算总重量 = 单个重量 * 数量 累加
BigDecimal allWeight = new BigDecimal(0); BigDecimal allWeight = new BigDecimal(0);
for (WmsShipmentMaterialCodeItem temp : materialCodeItems) { for (WmsShipmentMaterialCodeItem temp : materialCodeItems) {
@ -813,23 +809,23 @@ public class MaterialCodeController extends BaseController {
BigDecimal num = temp.getActualNum() == null ? BigDecimal.ZERO : temp.getActualNum(); BigDecimal num = temp.getActualNum() == null ? BigDecimal.ZERO : temp.getActualNum();
allWeight = allWeight.add(weight.multiply(num)); allWeight = allWeight.add(weight.multiply(num));
} }
// materialIds 中获取第一条数据 // materialIds 中获取第一条数据
WmsShipmentMaterialCodeItem firstItem = materialCodeItems.get(0); WmsShipmentMaterialCodeItem firstItem = materialCodeItems.get(0);
// 根据物料码主表ID查询清单信息清单编号机台编号销售订单号客户名称下单日期 // 根据物料码主表ID查询清单信息清单编号机台编号销售订单号客户名称下单日期
WmsShipmentMaterialCode materialCode = null; WmsShipmentMaterialCode materialCode = null;
if (firstItem.getMaterialCodeId() != null) { if (firstItem.getMaterialCodeId() != null) {
materialCode = materialCodeService.lambdaQuery() materialCode = materialCodeService.lambdaQuery()
.select(WmsShipmentMaterialCode::getNo, .select(WmsShipmentMaterialCode::getNo,
WmsShipmentMaterialCode::getDeviceNo, WmsShipmentMaterialCode::getDeviceNo,
WmsShipmentMaterialCode::getSoNo, WmsShipmentMaterialCode::getSoNo,
WmsShipmentMaterialCode::getCustomerName, WmsShipmentMaterialCode::getCustomerName,
WmsShipmentMaterialCode::getOrderDate) WmsShipmentMaterialCode::getOrderDate)
.eq(WmsShipmentMaterialCode::getId, firstItem.getMaterialCodeId()) .eq(WmsShipmentMaterialCode::getId, firstItem.getMaterialCodeId())
.one(); .one();
} }
// 构建表头数据 // 构建表头数据
MaterialPdfVO material = new MaterialPdfVO(); MaterialPdfVO material = new MaterialPdfVO();
// 优先使用从数据库查询的清单信息如果没有则使用前端传入的数据 // 优先使用从数据库查询的清单信息如果没有则使用前端传入的数据
@ -840,16 +836,16 @@ public class MaterialCodeController extends BaseController {
material.setCustomerName(materialCode != null ? materialCode.getCustomerName() : null); // 客户名称 material.setCustomerName(materialCode != null ? materialCode.getCustomerName() : null); // 客户名称
material.setOrderDay(materialCode != null ? materialCode.getOrderDate() : null); // 下单日期 material.setOrderDay(materialCode != null ? materialCode.getOrderDate() : null); // 下单日期
material.setWeight(allWeight); // 总重量 material.setWeight(allWeight); // 总重量
// 用清单编号生成二维码 // 用清单编号生成二维码
String qrCodeNo = materialCode != null ? materialCode.getNo() : ""; String qrCodeNo = materialCode != null ? materialCode.getNo() : "";
material.setQrCode(QRCodeUtil.generateQRCodeBase64(qrCodeNo, 100, 100)); material.setQrCode(QRCodeUtil.generateQRCodeBase64(qrCodeNo, 100, 100));
// 制作pdf // 制作pdf
Map<String, Object> variables = new HashMap<>(); Map<String, Object> variables = new HashMap<>();
variables.put("info", material); variables.put("info", material);
variables.put("pages", PdfPageDTO.create(items, perPage, new MaterialPdfDTO())); variables.put("pages", PdfPageDTO.create(items, perPage, new MaterialPdfDTO()));
// 根据每页数量选择对应模板 // 根据每页数量选择对应模板
String templateName = "物料老鼠图" + perPage; String templateName = "物料老鼠图" + perPage;
String html = ThymeleafUtil.generator( String html = ThymeleafUtil.generator(
@ -870,25 +866,24 @@ public class MaterialCodeController extends BaseController {
/** /**
* 导出标签图片PDF打印预览 * 导出标签图片PDF打印预览
*
* @param response HTTP响应 * @param response HTTP响应
* @param list 物料码主表列表 * @param list 物料码主表列表
*/ */
@PostMapping("exportToPdf") @PostMapping("exportToPdf")
public void exportToPdf(HttpServletResponse response, @RequestBody @NotEmpty List<ShipmentMaterialCodeQRVO> list) throws Exception { public void exportToPdf(HttpServletResponse response, @RequestBody @NotEmpty List<ShipmentMaterialCodeQRVO> list) throws Exception {
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(list)).throwMessage("物料数据不存在"); VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(list)).throwMessage("物料数据不存在");
// 收集所有物料码主表ID // 收集所有物料码主表ID
List<Long> materialCodeIds = list.stream() List<Long> materialCodeIds = list.stream()
.map(ShipmentMaterialCodeQRVO::getId) .map(ShipmentMaterialCodeQRVO::getId)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.toList(); .toList();
VUtil.trueThrowBusinessError(materialCodeIds.isEmpty()).throwMessage("物料码ID不能为空"); VUtil.trueThrowBusinessError(materialCodeIds.isEmpty()).throwMessage("物料码ID不能为空");
// 根据物料码主表ID查询物料明细包含二维码信息和客户名称 // 根据物料码主表ID查询物料明细包含二维码信息和客户名称
List<ShipmentMaterialCodeQRVO> qrDatas = materialCodeItemQrService.getListVOByCodeIds(materialCodeIds); List<ShipmentMaterialCodeQRVO> qrDatas = materialCodeItemQrService.getListVOByCodeIds(materialCodeIds);
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(qrDatas)).throwMessage("没有需要打印的二维码数据"); VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(qrDatas)).throwMessage("没有需要打印的二维码数据");
// 构建客户名称Map从传入的list中获取key为物料码主表ID // 构建客户名称Map从传入的list中获取key为物料码主表ID
Map<Long, String> customerNameMap = list.stream() Map<Long, String> customerNameMap = list.stream()
.filter(item -> item.getId() != null && StrUtil.isNotBlank(item.getCustomerName())) .filter(item -> item.getId() != null && StrUtil.isNotBlank(item.getCustomerName()))
@ -897,7 +892,7 @@ public class MaterialCodeController extends BaseController {
ShipmentMaterialCodeQRVO::getCustomerName, ShipmentMaterialCodeQRVO::getCustomerName,
(v1, v2) -> v1 (v1, v2) -> v1
)); ));
// 根据物料编号查询物料图片 // 根据物料编号查询物料图片
Map<String, String> images = materialService.lambdaQuery() Map<String, String> images = materialService.lambdaQuery()
.select(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage) .select(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage)
@ -905,36 +900,36 @@ public class MaterialCodeController extends BaseController {
.list() .list()
.stream() .stream()
.collect(Collectors.toMap(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage)); .collect(Collectors.toMap(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage));
// 构建打印数据 // 构建打印数据
Map<String, Object> variables = new HashMap<>(); Map<String, Object> variables = new HashMap<>();
List<Map<String, Object>> printList = new ArrayList<>(); List<Map<String, Object>> printList = new ArrayList<>();
for (ShipmentMaterialCodeQRVO item : qrDatas) { for (ShipmentMaterialCodeQRVO item : qrDatas) {
// 优先使用从list中获取的客户名称如果没有则使用SQL查询的customerName // 优先使用从list中获取的客户名称如果没有则使用SQL查询的customerName
String customerName = customerNameMap.get(item.getMaterialCodeId()); String customerName = customerNameMap.get(item.getMaterialCodeId());
if (StrUtil.isBlank(customerName)) { if (StrUtil.isBlank(customerName)) {
customerName = item.getCustomerName(); customerName = item.getCustomerName();
} }
Map<String, Object> info = new HashMap<>(); Map<String, Object> info = new HashMap<>();
info.put("no", item.getNo()); info.put("no", item.getNo());
info.put("materialNo", item.getMaterialNo()); info.put("materialNo", item.getMaterialNo());
info.put("numText", item.getNumText()); info.put("numText", item.getNumText());
info.put("customerName", customerName); info.put("customerName", customerName);
Map<String, String> ext = new HashMap<>(); Map<String, String> ext = new HashMap<>();
ext.put("qrCode", QRCodeUtil.generateQRCodeBase64(item.getNo(), 200, 200)); ext.put("qrCode", QRCodeUtil.generateQRCodeBase64(item.getNo(), 200, 200));
ext.put("lst", QRCodeUtil.imageUrlToBase64(images.get(item.getMaterialNo()))); ext.put("lst", QRCodeUtil.imageUrlToBase64(images.get(item.getMaterialNo())));
Map<String, Object> printData = new HashMap<>(); Map<String, Object> printData = new HashMap<>();
printData.put("info", info); printData.put("info", info);
printData.put("ext", ext); printData.put("ext", ext);
printList.add(printData); printList.add(printData);
} }
variables.put("list", printList); variables.put("list", printList);
String html = ThymeleafUtil.generator("/template/label/", "material-pdf", ".html", variables); String html = ThymeleafUtil.generator("/template/label/", "material-pdf", ".html", variables);
URL baseUrl = new ClassPathResource("template/label/").getURL(); URL baseUrl = new ClassPathResource("template/label/").getURL();
PdfGeneratorUtil.generatePdf("物料码标签", html, baseUrl.toString(), response); PdfGeneratorUtil.generatePdf("物料码标签", html, baseUrl.toString(), response);
@ -942,14 +937,13 @@ public class MaterialCodeController extends BaseController {
/** /**
* 根据明细ID导出物料明细PDF打印预览 * 根据明细ID导出物料明细PDF打印预览
*
* @param response HTTP响应 * @param response HTTP响应
* @param list 物料明细列表包含qrCodes二维码数组 * @param list 物料明细列表包含qrCodes二维码数组
*/ */
@PostMapping("exportItemToPdf") @PostMapping("exportItemToPdf")
public void exportItemToPdf(HttpServletResponse response, @RequestBody @NotEmpty List<ShipmentMaterialCodeQRVO> list) throws Exception { public void exportItemToPdf(HttpServletResponse response, @RequestBody @NotEmpty List<ShipmentMaterialCodeQRVO> list) throws Exception {
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(list)).throwMessage("没有需要导出的数据"); VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(list)).throwMessage("没有需要导出的数据");
// 收集所有二维码编号 // 收集所有二维码编号
List<String> allQrCodes = new ArrayList<>(); List<String> allQrCodes = new ArrayList<>();
for (ShipmentMaterialCodeQRVO item : list) { for (ShipmentMaterialCodeQRVO item : list) {
@ -958,13 +952,13 @@ public class MaterialCodeController extends BaseController {
} }
} }
VUtil.trueThrowBusinessError(allQrCodes.isEmpty()).throwMessage("没有需要打印的二维码"); VUtil.trueThrowBusinessError(allQrCodes.isEmpty()).throwMessage("没有需要打印的二维码");
// 根据物料码主表ID查询客户名称 // 根据物料码主表ID查询客户名称
Set<Long> materialCodeIds = list.stream() Set<Long> materialCodeIds = list.stream()
.map(ShipmentMaterialCodeQRVO::getMaterialCodeId) .map(ShipmentMaterialCodeQRVO::getMaterialCodeId)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Map<Long, String> customerNameMap = new HashMap<>(); Map<Long, String> customerNameMap = new HashMap<>();
if (!materialCodeIds.isEmpty()) { if (!materialCodeIds.isEmpty()) {
customerNameMap = materialCodeService.lambdaQuery() customerNameMap = materialCodeService.lambdaQuery()
@ -974,7 +968,7 @@ public class MaterialCodeController extends BaseController {
.stream() .stream()
.collect(Collectors.toMap(WmsShipmentMaterialCode::getId, WmsShipmentMaterialCode::getCustomerName)); .collect(Collectors.toMap(WmsShipmentMaterialCode::getId, WmsShipmentMaterialCode::getCustomerName));
} }
// 根据物料编号查询物料图片 // 根据物料编号查询物料图片
Map<String, String> images = materialService.lambdaQuery() Map<String, String> images = materialService.lambdaQuery()
.select(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage) .select(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage)
@ -982,44 +976,44 @@ public class MaterialCodeController extends BaseController {
.list() .list()
.stream() .stream()
.collect(Collectors.toMap(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage)); .collect(Collectors.toMap(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage));
// 构建打印数据支持多个二维码生成多页 // 构建打印数据支持多个二维码生成多页
Map<String, Object> variables = new HashMap<>(); Map<String, Object> variables = new HashMap<>();
List<Map<String, Object>> printList = new ArrayList<>(); List<Map<String, Object>> printList = new ArrayList<>();
for (ShipmentMaterialCodeQRVO item : list) { for (ShipmentMaterialCodeQRVO item : list) {
if (item.getQrCodes() == null || item.getQrCodes().isEmpty()) { if (item.getQrCodes() == null || item.getQrCodes().isEmpty()) {
continue; continue;
} }
// 获取客户名称 // 获取客户名称
String customerName = customerNameMap.get(item.getMaterialCodeId()); String customerName = customerNameMap.get(item.getMaterialCodeId());
for (String qrCode : item.getQrCodes()) { for (String qrCode : item.getQrCodes()) {
Map<String, Object> info = new HashMap<>(); Map<String, Object> info = new HashMap<>();
info.put("no", qrCode); info.put("no", qrCode);
info.put("materialNo", item.getMaterialNo()); info.put("materialNo", item.getMaterialNo());
info.put("numText", item.getNumText()); info.put("numText", item.getNumText());
info.put("customerName", customerName); info.put("customerName", customerName);
Map<String, String> ext = new HashMap<>(); Map<String, String> ext = new HashMap<>();
ext.put("qrCode", QRCodeUtil.generateQRCodeBase64(qrCode, 200, 200)); ext.put("qrCode", QRCodeUtil.generateQRCodeBase64(qrCode, 200, 200));
ext.put("lst", QRCodeUtil.imageUrlToBase64(images.get(item.getMaterialNo()))); ext.put("lst", QRCodeUtil.imageUrlToBase64(images.get(item.getMaterialNo())));
Map<String, Object> printData = new HashMap<>(); Map<String, Object> printData = new HashMap<>();
printData.put("info", info); printData.put("info", info);
printData.put("ext", ext); printData.put("ext", ext);
printList.add(printData); printList.add(printData);
} }
} }
variables.put("list", printList); variables.put("list", printList);
// 生成 PDF // 生成 PDF
String html = ThymeleafUtil.generator("/template/label/", "material-pdf", ".html", variables); String html = ThymeleafUtil.generator("/template/label/", "material-pdf", ".html", variables);
ClassPathResource resource = new ClassPathResource("template/label/"); ClassPathResource resource = new ClassPathResource("template/label/");
VUtil.trueThrowBusinessError(!resource.exists()).throwMessage("PDF模板不存在"); VUtil.trueThrowBusinessError(!resource.exists()).throwMessage("PDF模板不存在");
URL baseUrl = resource.getURL(); URL baseUrl = resource.getURL();
PdfGeneratorUtil.generatePdf("物料标签", html, baseUrl.toString(), response); PdfGeneratorUtil.generatePdf("物料标签", html, baseUrl.toString(), response);
} }

View File

@ -13,12 +13,14 @@ spring:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud: cloud:
nacos: nacos:
username: wms username: ${nacos.username:}
password: wms password: ${nacos.password:}
config: config:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms
group: ${spring.profiles.active} group: ${spring.profiles.active}
file-extension: properties
refresh-enabled: true
discovery: discovery:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms

View File

@ -13,12 +13,14 @@ spring:
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
cloud: cloud:
nacos: nacos:
username: wms username: ${nacos.username:}
password: wms password: ${nacos.password:}
config: config:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms
group: ${spring.profiles.active} group: ${spring.profiles.active}
file-extension: properties
refresh-enabled: true
discovery: discovery:
server-addr: ${nacos.server-addr:192.168.163.83:8848} server-addr: ${nacos.server-addr:192.168.163.83:8848}
namespace: wms namespace: wms