diff --git a/pom.xml b/pom.xml index 68e3bf5..c5dec66 100644 --- a/pom.xml +++ b/pom.xml @@ -216,14 +216,14 @@ javax.xml jaxrpc - - org.apache.aximo - axiom-api - - - org.apache.aximo - axiom-impl - + + + + + + + + org.apache.commons.logging commons-logging @@ -258,10 +258,10 @@ - - nl.cloudfarming.client - lib-geotools - + + + + @@ -742,11 +742,11 @@ - - nl.cloudfarming.client - lib-geotools - ${geotool.version} - + + + + + com.google.code.gson @@ -802,6 +802,18 @@ /test7 --> + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + ${env.JAVA_HOME}/jre/lib/rt.jar + + @@ -858,7 +870,7 @@ 3.0 3.5.1 1.4.5 - 1.3 + 1.4 0.2 1.1 1.2.13 diff --git a/pom.xml b/pom.xml index 68e3bf5..c5dec66 100644 --- a/pom.xml +++ b/pom.xml @@ -216,14 +216,14 @@ javax.xml jaxrpc - - org.apache.aximo - axiom-api - - - org.apache.aximo - axiom-impl - + + + + + + + + org.apache.commons.logging commons-logging @@ -258,10 +258,10 @@ - - nl.cloudfarming.client - lib-geotools - + + + + @@ -742,11 +742,11 @@ - - nl.cloudfarming.client - lib-geotools - ${geotool.version} - + + + + + com.google.code.gson @@ -802,6 +802,18 @@ /test7 --> + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + ${env.JAVA_HOME}/jre/lib/rt.jar + + @@ -858,7 +870,7 @@ 3.0 3.5.1 1.4.5 - 1.3 + 1.4 0.2 1.1 1.2.13 diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index 07b562d..e637c66 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -230,6 +230,34 @@ } + public String uploadImg(String fileName, String fileBuffer){ + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePath = null; + try { + if (fileBuffer != null && fileName != null) { + filePath = webPath + fileName; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffer); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()){ + destDir.mkdirs(); + } + File imageFile = new File(destDir, fileName); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } catch (Exception e) { + return null; + } + return filePath; + } + public boolean editMarkerAndPhoto(MarkerDto markerDto, Long companyId,String[] fileNames, String[] fileBuffers){ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String strDirPath = request.getSession().getServletContext().getRealPath(""); @@ -237,12 +265,15 @@ String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 - String filePaths = ""; + String[] filePaths = new String[3]; + String[] oldPhots = markerDto.getPhotos().split(","); + System.arraycopy(oldPhots,0,filePaths,0,oldPhots.length); try { for (int i = 0; i < fileBuffers.length; i++) { if (fileBuffers[i] != null && fileNames[i] != null) { // filePaths += toDir+fileNames[i]+","; - filePaths += webPath + fileNames[i] + ","; +// filePaths += webPath + fileNames[i] + ","; + filePaths[i] = webPath + fileNames[i]; byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 File destDir = new File(toDir); if (!destDir.exists()) @@ -254,13 +285,19 @@ fos.close(); } } - if (filePaths.endsWith(",")) { - filePaths = filePaths.substring(0, filePaths.length() - 1); - } +// if (filePaths.endsWith(",")) { +// filePaths = filePaths.substring(0, filePaths.length() - 1); +// } } catch (Exception e) { return false; } - markerDto.setPhotos(filePaths); + List photos = new ArrayList<>(); + for(int i =0 ;i0){ + photos.add(filePaths[i]); + } + } + markerDto.setPhotos(StringUtils.join(photos,",")); List markerDtos = new ArrayList(); markerDtos.add(markerDto); batchSave(markerDtos,companyId); diff --git a/pom.xml b/pom.xml index 68e3bf5..c5dec66 100644 --- a/pom.xml +++ b/pom.xml @@ -216,14 +216,14 @@ javax.xml jaxrpc - - org.apache.aximo - axiom-api - - - org.apache.aximo - axiom-impl - + + + + + + + + org.apache.commons.logging commons-logging @@ -258,10 +258,10 @@ - - nl.cloudfarming.client - lib-geotools - + + + + @@ -742,11 +742,11 @@ - - nl.cloudfarming.client - lib-geotools - ${geotool.version} - + + + + + com.google.code.gson @@ -802,6 +802,18 @@ /test7 --> + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + ${env.JAVA_HOME}/jre/lib/rt.jar + + @@ -858,7 +870,7 @@ 3.0 3.5.1 1.4.5 - 1.3 + 1.4 0.2 1.1 1.2.13 diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index 07b562d..e637c66 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -230,6 +230,34 @@ } + public String uploadImg(String fileName, String fileBuffer){ + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePath = null; + try { + if (fileBuffer != null && fileName != null) { + filePath = webPath + fileName; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffer); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()){ + destDir.mkdirs(); + } + File imageFile = new File(destDir, fileName); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } catch (Exception e) { + return null; + } + return filePath; + } + public boolean editMarkerAndPhoto(MarkerDto markerDto, Long companyId,String[] fileNames, String[] fileBuffers){ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String strDirPath = request.getSession().getServletContext().getRealPath(""); @@ -237,12 +265,15 @@ String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 - String filePaths = ""; + String[] filePaths = new String[3]; + String[] oldPhots = markerDto.getPhotos().split(","); + System.arraycopy(oldPhots,0,filePaths,0,oldPhots.length); try { for (int i = 0; i < fileBuffers.length; i++) { if (fileBuffers[i] != null && fileNames[i] != null) { // filePaths += toDir+fileNames[i]+","; - filePaths += webPath + fileNames[i] + ","; +// filePaths += webPath + fileNames[i] + ","; + filePaths[i] = webPath + fileNames[i]; byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 File destDir = new File(toDir); if (!destDir.exists()) @@ -254,13 +285,19 @@ fos.close(); } } - if (filePaths.endsWith(",")) { - filePaths = filePaths.substring(0, filePaths.length() - 1); - } +// if (filePaths.endsWith(",")) { +// filePaths = filePaths.substring(0, filePaths.length() - 1); +// } } catch (Exception e) { return false; } - markerDto.setPhotos(filePaths); + List photos = new ArrayList<>(); + for(int i =0 ;i0){ + photos.add(filePaths[i]); + } + } + markerDto.setPhotos(StringUtils.join(photos,",")); List markerDtos = new ArrayList(); markerDtos.add(markerDto); batchSave(markerDtos,companyId); diff --git a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java index ddf89de..cb6591d 100644 --- a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java +++ b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java @@ -18,7 +18,7 @@ import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import org.apache.commons.collections.CollectionUtils; -import org.geotools.styling.Mark; +//import org.geotools.styling.Mark; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -189,6 +189,33 @@ return map; } + @RequestMapping("marker-upload-img") + @ResponseBody + public Map markerUploadImg(@RequestParam(value = "fileBuffer", required = true) MultipartFile fileBuffer){ + String id = UUID.randomUUID().toString(); + String fileName = id + "_" + fileBuffer.getOriginalFilename(); + Map map = new HashMap(); + try { + byte[] fis = fileBuffer.getBytes(); + String photoBuffer = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + String filePath = markerManager.uploadImg(fileName,photoBuffer); + if(filePath!=null){ + map.put("success", true); + map.put("message", "上传成功"); + map.put("data",filePath); + }else{ + map.put("success", false); + map.put("message", "上传失败"); + } + }catch (Exception e){ + e.printStackTrace(); + map.put("success", false); + map.put("message", "上传失败"); + return map; + } + return map; + } + /** * 保存标识器属性及图片信息 * @param fileBuffer1 diff --git a/pom.xml b/pom.xml index 68e3bf5..c5dec66 100644 --- a/pom.xml +++ b/pom.xml @@ -216,14 +216,14 @@ javax.xml jaxrpc - - org.apache.aximo - axiom-api - - - org.apache.aximo - axiom-impl - + + + + + + + + org.apache.commons.logging commons-logging @@ -258,10 +258,10 @@ - - nl.cloudfarming.client - lib-geotools - + + + + @@ -742,11 +742,11 @@ - - nl.cloudfarming.client - lib-geotools - ${geotool.version} - + + + + + com.google.code.gson @@ -802,6 +802,18 @@ /test7 --> + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + ${env.JAVA_HOME}/jre/lib/rt.jar + + @@ -858,7 +870,7 @@ 3.0 3.5.1 1.4.5 - 1.3 + 1.4 0.2 1.1 1.2.13 diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index 07b562d..e637c66 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -230,6 +230,34 @@ } + public String uploadImg(String fileName, String fileBuffer){ + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePath = null; + try { + if (fileBuffer != null && fileName != null) { + filePath = webPath + fileName; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffer); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()){ + destDir.mkdirs(); + } + File imageFile = new File(destDir, fileName); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } catch (Exception e) { + return null; + } + return filePath; + } + public boolean editMarkerAndPhoto(MarkerDto markerDto, Long companyId,String[] fileNames, String[] fileBuffers){ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String strDirPath = request.getSession().getServletContext().getRealPath(""); @@ -237,12 +265,15 @@ String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 - String filePaths = ""; + String[] filePaths = new String[3]; + String[] oldPhots = markerDto.getPhotos().split(","); + System.arraycopy(oldPhots,0,filePaths,0,oldPhots.length); try { for (int i = 0; i < fileBuffers.length; i++) { if (fileBuffers[i] != null && fileNames[i] != null) { // filePaths += toDir+fileNames[i]+","; - filePaths += webPath + fileNames[i] + ","; +// filePaths += webPath + fileNames[i] + ","; + filePaths[i] = webPath + fileNames[i]; byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 File destDir = new File(toDir); if (!destDir.exists()) @@ -254,13 +285,19 @@ fos.close(); } } - if (filePaths.endsWith(",")) { - filePaths = filePaths.substring(0, filePaths.length() - 1); - } +// if (filePaths.endsWith(",")) { +// filePaths = filePaths.substring(0, filePaths.length() - 1); +// } } catch (Exception e) { return false; } - markerDto.setPhotos(filePaths); + List photos = new ArrayList<>(); + for(int i =0 ;i0){ + photos.add(filePaths[i]); + } + } + markerDto.setPhotos(StringUtils.join(photos,",")); List markerDtos = new ArrayList(); markerDtos.add(markerDto); batchSave(markerDtos,companyId); diff --git a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java index ddf89de..cb6591d 100644 --- a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java +++ b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java @@ -18,7 +18,7 @@ import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import org.apache.commons.collections.CollectionUtils; -import org.geotools.styling.Mark; +//import org.geotools.styling.Mark; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -189,6 +189,33 @@ return map; } + @RequestMapping("marker-upload-img") + @ResponseBody + public Map markerUploadImg(@RequestParam(value = "fileBuffer", required = true) MultipartFile fileBuffer){ + String id = UUID.randomUUID().toString(); + String fileName = id + "_" + fileBuffer.getOriginalFilename(); + Map map = new HashMap(); + try { + byte[] fis = fileBuffer.getBytes(); + String photoBuffer = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + String filePath = markerManager.uploadImg(fileName,photoBuffer); + if(filePath!=null){ + map.put("success", true); + map.put("message", "上传成功"); + map.put("data",filePath); + }else{ + map.put("success", false); + map.put("message", "上传失败"); + } + }catch (Exception e){ + e.printStackTrace(); + map.put("success", false); + map.put("message", "上传失败"); + return map; + } + return map; + } + /** * 保存标识器属性及图片信息 * @param fileBuffer1 diff --git a/src/main/webapp/content/marker/marker-info-edit-new.jsp b/src/main/webapp/content/marker/marker-info-edit-new.jsp index 18634f5..c8fb4e4 100644 --- a/src/main/webapp/content/marker/marker-info-edit-new.jsp +++ b/src/main/webapp/content/marker/marker-info-edit-new.jsp @@ -1 +1 @@ -<%@page contentType="text/html;charset=UTF-8" %> <%@include file="/taglibs.jsp" %> <%pageContext.setAttribute("currentMenu", "marker1");%> 地下管线电子标识系统 <%@include file="/common/layout/header.jsp" %>
<%@include file="/common/layout/menu_new.jsp" %>
<%--<%@include file="/common/layout/second-menu-user.jsp"%>--%>
标识器管理信息编辑
操作失败:
添加成功
毫米
<%@include file="/common/layout/footer.jsp" %> <%----%> \ No newline at end of file +<%@page contentType="text/html;charset=UTF-8" %> <%@include file="/taglibs.jsp" %> <%pageContext.setAttribute("currentMenu", "marker1");%> 地下管线电子标识系统 <%@include file="/common/layout/header.jsp" %>
<%@include file="/common/layout/menu_new.jsp" %>
<%--<%@include file="/common/layout/second-menu-user.jsp"%>--%>
标识器管理信息编辑
操作失败:
添加成功
毫米
<%@include file="/common/layout/footer.jsp" %> <%----%> \ No newline at end of file diff --git a/pom.xml b/pom.xml index 68e3bf5..c5dec66 100644 --- a/pom.xml +++ b/pom.xml @@ -216,14 +216,14 @@ javax.xml jaxrpc
- - org.apache.aximo - axiom-api - - - org.apache.aximo - axiom-impl - + + + + + + + + org.apache.commons.logging commons-logging @@ -258,10 +258,10 @@ - - nl.cloudfarming.client - lib-geotools - + + + + @@ -742,11 +742,11 @@ - - nl.cloudfarming.client - lib-geotools - ${geotool.version} - + + + + + com.google.code.gson @@ -802,6 +802,18 @@ /test7 --> + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + ${env.JAVA_HOME}/jre/lib/rt.jar + + @@ -858,7 +870,7 @@ 3.0 3.5.1 1.4.5 - 1.3 + 1.4 0.2 1.1 1.2.13 diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index 07b562d..e637c66 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -230,6 +230,34 @@ } + public String uploadImg(String fileName, String fileBuffer){ + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePath = null; + try { + if (fileBuffer != null && fileName != null) { + filePath = webPath + fileName; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffer); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()){ + destDir.mkdirs(); + } + File imageFile = new File(destDir, fileName); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } catch (Exception e) { + return null; + } + return filePath; + } + public boolean editMarkerAndPhoto(MarkerDto markerDto, Long companyId,String[] fileNames, String[] fileBuffers){ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String strDirPath = request.getSession().getServletContext().getRealPath(""); @@ -237,12 +265,15 @@ String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 - String filePaths = ""; + String[] filePaths = new String[3]; + String[] oldPhots = markerDto.getPhotos().split(","); + System.arraycopy(oldPhots,0,filePaths,0,oldPhots.length); try { for (int i = 0; i < fileBuffers.length; i++) { if (fileBuffers[i] != null && fileNames[i] != null) { // filePaths += toDir+fileNames[i]+","; - filePaths += webPath + fileNames[i] + ","; +// filePaths += webPath + fileNames[i] + ","; + filePaths[i] = webPath + fileNames[i]; byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 File destDir = new File(toDir); if (!destDir.exists()) @@ -254,13 +285,19 @@ fos.close(); } } - if (filePaths.endsWith(",")) { - filePaths = filePaths.substring(0, filePaths.length() - 1); - } +// if (filePaths.endsWith(",")) { +// filePaths = filePaths.substring(0, filePaths.length() - 1); +// } } catch (Exception e) { return false; } - markerDto.setPhotos(filePaths); + List photos = new ArrayList<>(); + for(int i =0 ;i0){ + photos.add(filePaths[i]); + } + } + markerDto.setPhotos(StringUtils.join(photos,",")); List markerDtos = new ArrayList(); markerDtos.add(markerDto); batchSave(markerDtos,companyId); diff --git a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java index ddf89de..cb6591d 100644 --- a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java +++ b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java @@ -18,7 +18,7 @@ import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import org.apache.commons.collections.CollectionUtils; -import org.geotools.styling.Mark; +//import org.geotools.styling.Mark; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -189,6 +189,33 @@ return map; } + @RequestMapping("marker-upload-img") + @ResponseBody + public Map markerUploadImg(@RequestParam(value = "fileBuffer", required = true) MultipartFile fileBuffer){ + String id = UUID.randomUUID().toString(); + String fileName = id + "_" + fileBuffer.getOriginalFilename(); + Map map = new HashMap(); + try { + byte[] fis = fileBuffer.getBytes(); + String photoBuffer = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + String filePath = markerManager.uploadImg(fileName,photoBuffer); + if(filePath!=null){ + map.put("success", true); + map.put("message", "上传成功"); + map.put("data",filePath); + }else{ + map.put("success", false); + map.put("message", "上传失败"); + } + }catch (Exception e){ + e.printStackTrace(); + map.put("success", false); + map.put("message", "上传失败"); + return map; + } + return map; + } + /** * 保存标识器属性及图片信息 * @param fileBuffer1 diff --git a/src/main/webapp/content/marker/marker-info-edit-new.jsp b/src/main/webapp/content/marker/marker-info-edit-new.jsp index 18634f5..c8fb4e4 100644 --- a/src/main/webapp/content/marker/marker-info-edit-new.jsp +++ b/src/main/webapp/content/marker/marker-info-edit-new.jsp @@ -1 +1 @@ -<%@page contentType="text/html;charset=UTF-8" %> <%@include file="/taglibs.jsp" %> <%pageContext.setAttribute("currentMenu", "marker1");%> 地下管线电子标识系统 <%@include file="/common/layout/header.jsp" %>
<%@include file="/common/layout/menu_new.jsp" %>
<%--<%@include file="/common/layout/second-menu-user.jsp"%>--%>
标识器管理信息编辑
操作失败:
添加成功
毫米
<%@include file="/common/layout/footer.jsp" %> <%----%> \ No newline at end of file +<%@page contentType="text/html;charset=UTF-8" %> <%@include file="/taglibs.jsp" %> <%pageContext.setAttribute("currentMenu", "marker1");%> 地下管线电子标识系统 <%@include file="/common/layout/header.jsp" %>
<%@include file="/common/layout/menu_new.jsp" %>
<%--<%@include file="/common/layout/second-menu-user.jsp"%>--%>
标识器管理信息编辑
操作失败:
添加成功
毫米
<%@include file="/common/layout/footer.jsp" %> <%----%> \ No newline at end of file diff --git a/src/main/webapp/s/app/ems/ems-gd.js b/src/main/webapp/s/app/ems/ems-gd.js index e9c9aec..6884ea0 100644 --- a/src/main/webapp/s/app/ems/ems-gd.js +++ b/src/main/webapp/s/app/ems/ems-gd.js @@ -81,7 +81,6 @@ } hadRequest = false; map.off("complete", requestMarkers()); - console.log(markerData) }, error: function (d) {//请求出错 hadRequest = false; @@ -96,7 +95,6 @@ // 处理鼠标单击事件 function processClickInfo(emsBean){ - console.log("processClickInfo") var msg = ""; if (emsBean.recordType == 1) { msg = msg + "管线种类:" + emsBean.markerObjectType + "
" + @@ -140,7 +138,6 @@ } msg = msg + '' } - console.log(msg); return msg; } @@ -153,24 +150,26 @@ //删除标识器 emsDelCallBack: function () { + console.log("1111") //绘制矩形区域: if (drawOverlays.length == 0) { swal("请先绘制区域", "", "warning"); return; } - var pointArray = new Array(); var readyToDel = ""; for (var i = 0; i < drawOverlays.length; i++) { + // debugger var layer = drawOverlays[i]; try { // 生成判断是否在多边形内的数据格式 var path = []; - for (var k = 0; k < layer.He.path.length; k++) { + for (var k = 0; k < layer.Ge.path.length; k++) { var pos = []; - pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + pos.push(layer.Ge.path[k].lng, layer.Ge.path[k].lat); path.push(pos); } + console.log("path"+path); for (var j = 0; j < markerData.length; j++) { var emsBean = markerData[j]; var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); @@ -614,7 +613,6 @@ map.setFitView(viewMarkers); mass.on("click", function(e) { - console.log("mass.onmass.on") var index = parseInt(e.data.id); var emsBean = viewMarkers[index].Tag; console.log(emsBean) @@ -639,7 +637,6 @@ var content = titleName + '
' + '' + msg + '
'; - console.log(content) var infowindow = new AMap.AdvancedInfoWindow({ content: content, width: 290, //宽度 diff --git a/pom.xml b/pom.xml index 68e3bf5..c5dec66 100644 --- a/pom.xml +++ b/pom.xml @@ -216,14 +216,14 @@ javax.xml jaxrpc
- - org.apache.aximo - axiom-api - - - org.apache.aximo - axiom-impl - + + + + + + + + org.apache.commons.logging commons-logging @@ -258,10 +258,10 @@ - - nl.cloudfarming.client - lib-geotools - + + + + @@ -742,11 +742,11 @@ - - nl.cloudfarming.client - lib-geotools - ${geotool.version} - + + + + + com.google.code.gson @@ -802,6 +802,18 @@ /test7 --> + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + ${env.JAVA_HOME}/jre/lib/rt.jar + + @@ -858,7 +870,7 @@ 3.0 3.5.1 1.4.5 - 1.3 + 1.4 0.2 1.1 1.2.13 diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index 07b562d..e637c66 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -230,6 +230,34 @@ } + public String uploadImg(String fileName, String fileBuffer){ + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePath = null; + try { + if (fileBuffer != null && fileName != null) { + filePath = webPath + fileName; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffer); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()){ + destDir.mkdirs(); + } + File imageFile = new File(destDir, fileName); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } catch (Exception e) { + return null; + } + return filePath; + } + public boolean editMarkerAndPhoto(MarkerDto markerDto, Long companyId,String[] fileNames, String[] fileBuffers){ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String strDirPath = request.getSession().getServletContext().getRealPath(""); @@ -237,12 +265,15 @@ String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 - String filePaths = ""; + String[] filePaths = new String[3]; + String[] oldPhots = markerDto.getPhotos().split(","); + System.arraycopy(oldPhots,0,filePaths,0,oldPhots.length); try { for (int i = 0; i < fileBuffers.length; i++) { if (fileBuffers[i] != null && fileNames[i] != null) { // filePaths += toDir+fileNames[i]+","; - filePaths += webPath + fileNames[i] + ","; +// filePaths += webPath + fileNames[i] + ","; + filePaths[i] = webPath + fileNames[i]; byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 File destDir = new File(toDir); if (!destDir.exists()) @@ -254,13 +285,19 @@ fos.close(); } } - if (filePaths.endsWith(",")) { - filePaths = filePaths.substring(0, filePaths.length() - 1); - } +// if (filePaths.endsWith(",")) { +// filePaths = filePaths.substring(0, filePaths.length() - 1); +// } } catch (Exception e) { return false; } - markerDto.setPhotos(filePaths); + List photos = new ArrayList<>(); + for(int i =0 ;i0){ + photos.add(filePaths[i]); + } + } + markerDto.setPhotos(StringUtils.join(photos,",")); List markerDtos = new ArrayList(); markerDtos.add(markerDto); batchSave(markerDtos,companyId); diff --git a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java index ddf89de..cb6591d 100644 --- a/src/main/java/com/casic/accessControl/marker/web/MarkerController.java +++ b/src/main/java/com/casic/accessControl/marker/web/MarkerController.java @@ -18,7 +18,7 @@ import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import org.apache.commons.collections.CollectionUtils; -import org.geotools.styling.Mark; +//import org.geotools.styling.Mark; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -189,6 +189,33 @@ return map; } + @RequestMapping("marker-upload-img") + @ResponseBody + public Map markerUploadImg(@RequestParam(value = "fileBuffer", required = true) MultipartFile fileBuffer){ + String id = UUID.randomUUID().toString(); + String fileName = id + "_" + fileBuffer.getOriginalFilename(); + Map map = new HashMap(); + try { + byte[] fis = fileBuffer.getBytes(); + String photoBuffer = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + String filePath = markerManager.uploadImg(fileName,photoBuffer); + if(filePath!=null){ + map.put("success", true); + map.put("message", "上传成功"); + map.put("data",filePath); + }else{ + map.put("success", false); + map.put("message", "上传失败"); + } + }catch (Exception e){ + e.printStackTrace(); + map.put("success", false); + map.put("message", "上传失败"); + return map; + } + return map; + } + /** * 保存标识器属性及图片信息 * @param fileBuffer1 diff --git a/src/main/webapp/content/marker/marker-info-edit-new.jsp b/src/main/webapp/content/marker/marker-info-edit-new.jsp index 18634f5..c8fb4e4 100644 --- a/src/main/webapp/content/marker/marker-info-edit-new.jsp +++ b/src/main/webapp/content/marker/marker-info-edit-new.jsp @@ -1 +1 @@ -<%@page contentType="text/html;charset=UTF-8" %> <%@include file="/taglibs.jsp" %> <%pageContext.setAttribute("currentMenu", "marker1");%> 地下管线电子标识系统 <%@include file="/common/layout/header.jsp" %>
<%@include file="/common/layout/menu_new.jsp" %>
<%--<%@include file="/common/layout/second-menu-user.jsp"%>--%>
标识器管理信息编辑
操作失败:
添加成功
毫米
<%@include file="/common/layout/footer.jsp" %> <%----%> \ No newline at end of file +<%@page contentType="text/html;charset=UTF-8" %> <%@include file="/taglibs.jsp" %> <%pageContext.setAttribute("currentMenu", "marker1");%> 地下管线电子标识系统 <%@include file="/common/layout/header.jsp" %>
<%@include file="/common/layout/menu_new.jsp" %>
<%--<%@include file="/common/layout/second-menu-user.jsp"%>--%>
标识器管理信息编辑
操作失败:
添加成功
毫米
<%@include file="/common/layout/footer.jsp" %> <%----%> \ No newline at end of file diff --git a/src/main/webapp/s/app/ems/ems-gd.js b/src/main/webapp/s/app/ems/ems-gd.js index e9c9aec..6884ea0 100644 --- a/src/main/webapp/s/app/ems/ems-gd.js +++ b/src/main/webapp/s/app/ems/ems-gd.js @@ -81,7 +81,6 @@ } hadRequest = false; map.off("complete", requestMarkers()); - console.log(markerData) }, error: function (d) {//请求出错 hadRequest = false; @@ -96,7 +95,6 @@ // 处理鼠标单击事件 function processClickInfo(emsBean){ - console.log("processClickInfo") var msg = ""; if (emsBean.recordType == 1) { msg = msg + "管线种类:" + emsBean.markerObjectType + "
" + @@ -140,7 +138,6 @@ } msg = msg + '' } - console.log(msg); return msg; } @@ -153,24 +150,26 @@ //删除标识器 emsDelCallBack: function () { + console.log("1111") //绘制矩形区域: if (drawOverlays.length == 0) { swal("请先绘制区域", "", "warning"); return; } - var pointArray = new Array(); var readyToDel = ""; for (var i = 0; i < drawOverlays.length; i++) { + // debugger var layer = drawOverlays[i]; try { // 生成判断是否在多边形内的数据格式 var path = []; - for (var k = 0; k < layer.He.path.length; k++) { + for (var k = 0; k < layer.Ge.path.length; k++) { var pos = []; - pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + pos.push(layer.Ge.path[k].lng, layer.Ge.path[k].lat); path.push(pos); } + console.log("path"+path); for (var j = 0; j < markerData.length; j++) { var emsBean = markerData[j]; var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); @@ -614,7 +613,6 @@ map.setFitView(viewMarkers); mass.on("click", function(e) { - console.log("mass.onmass.on") var index = parseInt(e.data.id); var emsBean = viewMarkers[index].Tag; console.log(emsBean) @@ -639,7 +637,6 @@ var content = titleName + '
' + '' + msg + '
'; - console.log(content) var infowindow = new AMap.AdvancedInfoWindow({ content: content, width: 290, //宽度 diff --git a/src/main/webapp/s/app/marker/marker-info-edit.js b/src/main/webapp/s/app/marker/marker-info-edit.js index fa55842..8983513 100644 --- a/src/main/webapp/s/app/marker/marker-info-edit.js +++ b/src/main/webapp/s/app/marker/marker-info-edit.js @@ -40,16 +40,29 @@ } function editPhotoInit(photos) { - console.log(photos); - console.log($('#context').val()) - console.log(window.location.host) - var imgs = photos.split(",") + var imgs = new Array(); + if(photos){ + imgs = photos.split(",") + } for(var i=0;i