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