Compare commits
No commits in common. "30c726d0809598e5c46b8e72dcc0a29dc7ddc95b" and "d679fd47bdb561d0c77332a189a83c5d0645b554" have entirely different histories.
30c726d080
...
d679fd47bd
|
|
@ -1,22 +0,0 @@
|
||||||
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,33 +1,20 @@
|
||||||
package com.nflg.wms.admin.util;
|
package com.nflg.wms.admin.util;
|
||||||
|
|
||||||
import com.lowagie.text.pdf.BaseFont;
|
import com.lowagie.text.pdf.BaseFont;
|
||||||
import com.nflg.wms.common.util.VUtil;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.xhtmlrenderer.pdf.ITextRenderer;
|
import org.xhtmlrenderer.pdf.ITextRenderer;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
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 {
|
public class PdfGeneratorUtil {
|
||||||
|
|
||||||
private static final Set<String> SUPPORTED_EXTENSIONS = new HashSet<>(Arrays.asList(
|
private static final String fontPath = "fonts/simsun.ttc";
|
||||||
"ttf", "ttc", "otf", "pfb"
|
|
||||||
));
|
|
||||||
|
|
||||||
public static void generatePdf(String name,String html, HttpServletResponse response) throws Exception {
|
public static void generatePdf(String name,String html, HttpServletResponse response) throws Exception {
|
||||||
URL baseUrl = new ClassPathResource("template/").getURL();
|
URL baseUrl = new ClassPathResource("template/").getURL();
|
||||||
|
|
@ -36,7 +23,7 @@ public class PdfGeneratorUtil {
|
||||||
|
|
||||||
public static void generatePdf(String name,String html,String baseUrl, HttpServletResponse response) throws Exception {
|
public static void generatePdf(String name,String html,String baseUrl, HttpServletResponse response) throws Exception {
|
||||||
ITextRenderer renderer = new ITextRenderer();
|
ITextRenderer renderer = new ITextRenderer();
|
||||||
loadFonts(renderer);
|
renderer.getFontResolver().addFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
||||||
renderer.setDocumentFromString(html,baseUrl);
|
renderer.setDocumentFromString(html,baseUrl);
|
||||||
renderer.layout();
|
renderer.layout();
|
||||||
renderer.createPDF(response.getOutputStream());
|
renderer.createPDF(response.getOutputStream());
|
||||||
|
|
@ -52,21 +39,9 @@ public class PdfGeneratorUtil {
|
||||||
|
|
||||||
public static void generatePdf(String name,String html,String baseUrl,OutputStream output) throws Exception {
|
public static void generatePdf(String name,String html,String baseUrl,OutputStream output) throws Exception {
|
||||||
ITextRenderer renderer = new ITextRenderer();
|
ITextRenderer renderer = new ITextRenderer();
|
||||||
loadFonts(renderer);
|
renderer.getFontResolver().addFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
|
||||||
renderer.setDocumentFromString(html,baseUrl);
|
renderer.setDocumentFromString(html,baseUrl);
|
||||||
renderer.layout();
|
renderer.layout();
|
||||||
renderer.createPDF(output);
|
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,8 +35,6 @@ public class DeployTest {
|
||||||
sshUtil.connect("192.168.163.84", 22, "root", "CMP2025nf");
|
sshUtil.connect("192.168.163.84", 22, "root", "CMP2025nf");
|
||||||
//处理主jar包
|
//处理主jar包
|
||||||
handleFile(sshUtil, localPath + jarName, remotePath + jarName);
|
handleFile(sshUtil, localPath + jarName, remotePath + jarName);
|
||||||
//处理字体目录
|
|
||||||
handleDir(sshUtil, localPath, remotePath, "fonts");
|
|
||||||
//处理lib目录
|
//处理lib目录
|
||||||
handleDir(sshUtil, localPath, remotePath, "lib");
|
handleDir(sshUtil, localPath, remotePath, "lib");
|
||||||
//执行脚本启动服务
|
//执行脚本启动服务
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,8 @@ package com.nflg.wms.common.pojo;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.nflg.wms.common.constant.Constant;
|
|
||||||
import com.nflg.wms.common.constant.STATE;
|
import com.nflg.wms.common.constant.STATE;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.slf4j.MDC;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
@ -17,8 +15,7 @@ public class ApiResult<T> implements Serializable {
|
||||||
private String type;
|
private String type;
|
||||||
private String message;
|
private String message;
|
||||||
private Object extras;
|
private Object extras;
|
||||||
private LocalDateTime time = LocalDateTime.now();
|
private LocalDateTime time=LocalDateTime.now();
|
||||||
private String traceId = MDC.get(Constant.TRACE_ID);
|
|
||||||
private T result;
|
private T result;
|
||||||
|
|
||||||
public static <T> ApiResult<T> success(T value) {
|
public static <T> ApiResult<T> success(T value) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.nflg.wms.common.pojo.dto;
|
package com.nflg.wms.common.pojo.dto;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
|
@ -15,7 +13,6 @@ public class PackageMaterialDTO {
|
||||||
/**
|
/**
|
||||||
* 编号
|
* 编号
|
||||||
*/
|
*/
|
||||||
@NotBlank
|
|
||||||
private String no;
|
private String no;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,19 +28,16 @@ public class PackageMaterialDTO {
|
||||||
/**
|
/**
|
||||||
* 工位
|
* 工位
|
||||||
*/
|
*/
|
||||||
@NotBlank
|
|
||||||
private String station;
|
private String station;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 托盘
|
* 托盘
|
||||||
*/
|
*/
|
||||||
@NotBlank
|
|
||||||
private String tray;
|
private String tray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数量
|
* 数量
|
||||||
*/
|
*/
|
||||||
@NotNull
|
|
||||||
private BigDecimal num;
|
private BigDecimal num;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,7 +52,6 @@ public class PackageMaterialDTO {
|
||||||
/**
|
/**
|
||||||
* 版本
|
* 版本
|
||||||
*/
|
*/
|
||||||
@NotNull
|
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.nflg.wms.common.pojo.qo;
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
@ -72,7 +71,6 @@ public class PackageAddQO {
|
||||||
/**
|
/**
|
||||||
* 零件清单
|
* 零件清单
|
||||||
*/
|
*/
|
||||||
@Valid
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private List<PackageMaterialDTO> materials;
|
private List<PackageMaterialDTO> materials;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class TrayVO {
|
||||||
private String tray;
|
private String tray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态,0:未打包;1:已打包;2-在途;3:已收货
|
* 状态,0:未打包;1:已打包;2-在途;
|
||||||
*/
|
*/
|
||||||
private Short state;
|
private Short state;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,25 +3,30 @@
|
||||||
<mapper namespace="com.nflg.wms.repository.mapper.WmsStructuralPackageMapper">
|
<mapper namespace="com.nflg.wms.repository.mapper.WmsStructuralPackageMapper">
|
||||||
|
|
||||||
<select id="search" resultType="com.nflg.wms.common.pojo.vo.PackageVO">
|
<select id="search" resultType="com.nflg.wms.common.pojo.vo.PackageVO">
|
||||||
SELECT *,get_modelnos(model_ids) as "modelNos"
|
SELECT *
|
||||||
FROM wms_structural_package
|
FROM (
|
||||||
<where>
|
SELECT DISTINCT ON ("no") id,"no","order_no","name",drawing_no,weight,cate,eco,version,remark,enable,create_by
|
||||||
<if test="request.no!=null and request.no!=''">
|
,create_time,update_by,update_time,get_modelnos(model_ids) as "modelNos"
|
||||||
and ("no" ilike concat('%', #{request.no}, '%') or "name" ilike concat('%', #{request.no}, '%'))
|
FROM wms_structural_package
|
||||||
</if>
|
<where>
|
||||||
<if test="request.eco!=null and request.eco!=''">
|
<if test="request.no!=null and request.no!=''">
|
||||||
and eco ilike concat('%', #{request.eco}, '%')
|
and ("no" ilike concat('%', #{request.no}, '%') or "name" ilike concat('%', #{request.no}, '%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="request.drawingNo!=null and request.drawingNo!=''">
|
<if test="request.eco!=null and request.eco!=''">
|
||||||
and drawing_no like concat('%', #{request.drawingNo}, '%')
|
and eco ilike concat('%', #{request.eco}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="request.modelId!=null">
|
<if test="request.drawingNo!=null and request.drawingNo!=''">
|
||||||
and find_in_set(#{request.modelId},model_ids)>0
|
and drawing_no like concat('%', #{request.drawingNo}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="request.type==0">
|
<if test="request.modelId!=null">
|
||||||
and latest=true
|
and find_in_set(#{request.modelId},model_ids)>0
|
||||||
</if>
|
</if>
|
||||||
</where>
|
<if test="request.type==0">
|
||||||
|
and latest=true
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY "no",id DESC
|
||||||
|
) t
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue