From cc816055746ae0ffa870734e5a411b2a2aabb96a Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 22 四月 2024 16:16:26 +0800 Subject: [PATCH] 添加附件dwg的转换 --- src/main/java/com/lf/server/service/show/CadService.java | 34 +++++++++++++++++++++++++++++----- 1 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/lf/server/service/show/CadService.java b/src/main/java/com/lf/server/service/show/CadService.java index 3416433..dc1c05e 100644 --- a/src/main/java/com/lf/server/service/show/CadService.java +++ b/src/main/java/com/lf/server/service/show/CadService.java @@ -2,8 +2,11 @@ import com.lf.server.entity.all.StaticData; import com.lf.server.entity.data.MetaEntity; +import com.lf.server.entity.sys.AttachEntity; import com.lf.server.helper.PathHelper; +import com.lf.server.helper.StringHelper; import com.lf.server.service.data.MetaService; +import com.lf.server.service.sys.AttachService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Value; @@ -31,6 +34,9 @@ MetaService metaService; @Resource + AttachService attachService; + + @Resource PathHelper pathHelper; private final static Log log = LogFactory.getLog(CadService.class); @@ -38,19 +44,19 @@ /** * 鏍煎紡杞寲 */ - public String convert(int metaId) { - MetaEntity me = metaService.selectById(metaId); - if (null == me || StringUtils.isEmpty(me.getPath()) || !StaticData.DWG.equals(me.getType())) { + public String convert(int id, Boolean isAttach) { + String path = getFilePath(id, isAttach); + if (StringHelper.isEmpty(path)) { return ""; } - String dwg = pathHelper.getConfig().getUploadPath() + File.separator + me.getPath(); + String dwg = pathHelper.getConfig().getUploadPath() + File.separator + path; File file = new File(dwg); if (!file.exists() || file.isDirectory()) { return ""; } - String[] strs = me.getPath().replace("\\", "/").split("/"); + String[] strs = path.replace("\\", "/").split("/"); String outPath = targetPath + "/" + strs[0]; String outName = strs[1].replace(".dwg", ".mxweb"); file = new File(outPath + "/" + outName); @@ -65,6 +71,24 @@ return ""; } + private String getFilePath(int id, Boolean isAttach) { + if (null == isAttach || !isAttach) { + MetaEntity me = metaService.selectById(id); + if (null == me || StringUtils.isEmpty(me.getPath()) || !StaticData.DWG.equals(me.getType())) { + return null; + } + + return me.getPath(); + } + + AttachEntity ae = attachService.selectById(id); + if (null == ae || StringUtils.isEmpty(ae.getPath()) || !ae.getPath().toLowerCase().contains(StaticData.DWG)) { + return null; + } + + return ae.getPath(); + } + /** * 璋冪敤鏍煎紡杞崲 */ -- Gitblit v1.9.3