Compare commits
3 Commits
d679fd47bd
...
30c726d080
| Author | SHA1 | Date |
|---|---|---|
|
|
30c726d080 | |
|
|
05b9005120 | |
|
|
f1345a3249 |
|
|
@ -0,0 +1,22 @@
|
|||
package com.nflg.wms.admin.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PathUtils {
|
||||
|
||||
public static String getPath() {
|
||||
String classPath = PathUtils.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
System.out.println("classPath:" + classPath);
|
||||
// 如果是jar包运行,获取jar包所在目录
|
||||
if (classPath.contains(".jar")) {
|
||||
File jarFile = new File(classPath);
|
||||
return jarFile.getParent();
|
||||
}
|
||||
// 如果是开发环境,获取target/classes目录的父目录
|
||||
File classDir = new File(classPath);
|
||||
if (classDir.getName().equals("classes")) {
|
||||
return classDir.getParentFile().getParentFile().getAbsolutePath();
|
||||
}
|
||||
return new File(classPath).getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,33 @@
|
|||
package com.nflg.wms.admin.util;
|
||||
|
||||
import com.lowagie.text.pdf.BaseFont;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.xhtmlrenderer.pdf.ITextRenderer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class PdfGeneratorUtil {
|
||||
|
||||
private static final String fontPath = "fonts/simsun.ttc";
|
||||
private static final Set<String> SUPPORTED_EXTENSIONS = new HashSet<>(Arrays.asList(
|
||||
"ttf", "ttc", "otf", "pfb"
|
||||
));
|
||||
|
||||
public static void generatePdf(String name,String html, HttpServletResponse response) throws Exception {
|
||||
URL baseUrl = new ClassPathResource("template/").getURL();
|
||||
|
|
@ -23,7 +36,7 @@ public class PdfGeneratorUtil {
|
|||
|
||||
public static void generatePdf(String name,String html,String baseUrl, HttpServletResponse response) throws Exception {
|
||||
ITextRenderer renderer = new ITextRenderer();
|
||||
renderer.getFontResolver().addFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
||||
loadFonts(renderer);
|
||||
renderer.setDocumentFromString(html,baseUrl);
|
||||
renderer.layout();
|
||||
renderer.createPDF(response.getOutputStream());
|
||||
|
|
@ -39,9 +52,21 @@ public class PdfGeneratorUtil {
|
|||
|
||||
public static void generatePdf(String name,String html,String baseUrl,OutputStream output) throws Exception {
|
||||
ITextRenderer renderer = new ITextRenderer();
|
||||
renderer.getFontResolver().addFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
||||
loadFonts(renderer);
|
||||
renderer.setDocumentFromString(html,baseUrl);
|
||||
renderer.layout();
|
||||
renderer.createPDF(output);
|
||||
}
|
||||
|
||||
private static void loadFonts(ITextRenderer renderer) throws IOException {
|
||||
Path fontsDir = Paths.get(PathUtils.getPath(), "fonts");
|
||||
VUtil.trueThrowBusinessError(!Files.exists(fontsDir) || !Files.isDirectory(fontsDir))
|
||||
.throwMessage("fonts文件夹不存在: " + fontsDir);
|
||||
File directory = fontsDir.toFile();
|
||||
File[] fonts = directory.listFiles((dir, name) -> SUPPORTED_EXTENSIONS.contains(FilenameUtils.getExtension(name)));
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(fonts) || fonts.length == 0).throwMessage("未找到有效字体");
|
||||
for (File font : fonts) {
|
||||
renderer.getFontResolver().addFont(font.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,8 @@ public class DeployTest {
|
|||
sshUtil.connect("192.168.163.84", 22, "root", "CMP2025nf");
|
||||
//处理主jar包
|
||||
handleFile(sshUtil, localPath + jarName, remotePath + jarName);
|
||||
//处理字体目录
|
||||
handleDir(sshUtil, localPath, remotePath, "fonts");
|
||||
//处理lib目录
|
||||
handleDir(sshUtil, localPath, remotePath, "lib");
|
||||
//执行脚本启动服务
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package com.nflg.wms.common.pojo;
|
|||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.wms.common.constant.Constant;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import lombok.Data;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -15,7 +17,8 @@ public class ApiResult<T> implements Serializable {
|
|||
private String type;
|
||||
private String message;
|
||||
private Object extras;
|
||||
private LocalDateTime time=LocalDateTime.now();
|
||||
private LocalDateTime time = LocalDateTime.now();
|
||||
private String traceId = MDC.get(Constant.TRACE_ID);
|
||||
private T result;
|
||||
|
||||
public static <T> ApiResult<T> success(T value) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
|
@ -13,6 +15,7 @@ public class PackageMaterialDTO {
|
|||
/**
|
||||
* 编号
|
||||
*/
|
||||
@NotBlank
|
||||
private String no;
|
||||
|
||||
/**
|
||||
|
|
@ -28,16 +31,19 @@ public class PackageMaterialDTO {
|
|||
/**
|
||||
* 工位
|
||||
*/
|
||||
@NotBlank
|
||||
private String station;
|
||||
|
||||
/**
|
||||
* 托盘
|
||||
*/
|
||||
@NotBlank
|
||||
private String tray;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@NotNull
|
||||
private BigDecimal num;
|
||||
|
||||
/**
|
||||
|
|
@ -52,6 +58,7 @@ public class PackageMaterialDTO {
|
|||
/**
|
||||
* 版本
|
||||
*/
|
||||
@NotNull
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
|
@ -71,6 +72,7 @@ public class PackageAddQO {
|
|||
/**
|
||||
* 零件清单
|
||||
*/
|
||||
@Valid
|
||||
@NotEmpty
|
||||
private List<PackageMaterialDTO> materials;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class TrayVO {
|
|||
private String tray;
|
||||
|
||||
/**
|
||||
* 状态,0:未打包;1:已打包;2-在途;
|
||||
* 状态,0:未打包;1:已打包;2-在途;3:已收货
|
||||
*/
|
||||
private Short state;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,30 +3,25 @@
|
|||
<mapper namespace="com.nflg.wms.repository.mapper.WmsStructuralPackageMapper">
|
||||
|
||||
<select id="search" resultType="com.nflg.wms.common.pojo.vo.PackageVO">
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT DISTINCT ON ("no") id,"no","order_no","name",drawing_no,weight,cate,eco,version,remark,enable,create_by
|
||||
,create_time,update_by,update_time,get_modelnos(model_ids) as "modelNos"
|
||||
FROM wms_structural_package
|
||||
<where>
|
||||
<if test="request.no!=null and request.no!=''">
|
||||
and ("no" ilike concat('%', #{request.no}, '%') or "name" ilike concat('%', #{request.no}, '%'))
|
||||
</if>
|
||||
<if test="request.eco!=null and request.eco!=''">
|
||||
and eco ilike concat('%', #{request.eco}, '%')
|
||||
</if>
|
||||
<if test="request.drawingNo!=null and request.drawingNo!=''">
|
||||
and drawing_no like concat('%', #{request.drawingNo}, '%')
|
||||
</if>
|
||||
<if test="request.modelId!=null">
|
||||
and find_in_set(#{request.modelId},model_ids)>0
|
||||
</if>
|
||||
<if test="request.type==0">
|
||||
and latest=true
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY "no",id DESC
|
||||
) t
|
||||
SELECT *,get_modelnos(model_ids) as "modelNos"
|
||||
FROM wms_structural_package
|
||||
<where>
|
||||
<if test="request.no!=null and request.no!=''">
|
||||
and ("no" ilike concat('%', #{request.no}, '%') or "name" ilike concat('%', #{request.no}, '%'))
|
||||
</if>
|
||||
<if test="request.eco!=null and request.eco!=''">
|
||||
and eco ilike concat('%', #{request.eco}, '%')
|
||||
</if>
|
||||
<if test="request.drawingNo!=null and request.drawingNo!=''">
|
||||
and drawing_no like concat('%', #{request.drawingNo}, '%')
|
||||
</if>
|
||||
<if test="request.modelId!=null">
|
||||
and find_in_set(#{request.modelId},model_ids)>0
|
||||
</if>
|
||||
<if test="request.type==0">
|
||||
and latest=true
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue