From b9b712a7701eb83c7dbd8367c534d4c880503adb Mon Sep 17 00:00:00 2001
From: zmk <496160012@qq.com>
Date: 星期六, 18 五月 2024 16:51:19 +0800
Subject: [PATCH] 提交代码
---
javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectDataController.java | 3
javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectDataServiceImpl.java | 111 +++++++++++++++++++++---------------
javaweb-plus/javaweb-cms/src/main/resources/templates/geo/project/info.html | 17 ++---
javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/projectData.html | 15 ++--
javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/upload.html | 29 +++------
5 files changed, 93 insertions(+), 82 deletions(-)
diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectDataController.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectDataController.java
index f99e75f..7c274a6 100644
--- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectDataController.java
+++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectDataController.java
@@ -54,7 +54,8 @@
* 瀵煎叆鍘嬬缉鍖�
*/
@GetMapping("/importImg")
- public String importPdf(){
+ public String importPdf(String projectDataId,ModelMap mmap){
+ mmap.put("projectDataId",projectDataId);
return prefix + "/upload";
}
diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectDataServiceImpl.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectDataServiceImpl.java
index ba4ecd0..030592f 100644
--- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectDataServiceImpl.java
+++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/service/impl/ProjectDataServiceImpl.java
@@ -12,12 +12,17 @@
import com.javaweb.common.utils.DateUtils;
import com.javaweb.common.utils.IdGenerate;
import com.javaweb.common.utils.StringUtils;
+import com.javaweb.geo.domain.Hole;
+import com.javaweb.geo.domain.HoleMedia;
+import com.javaweb.geo.mapper.HoleMapper;
+import com.javaweb.geo.mapper.HoleMediaMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.javaweb.geo.mapper.ProjectDataMapper;
import com.javaweb.geo.domain.ProjectData;
import com.javaweb.geo.service.IProjectDataService;
import com.javaweb.common.core.text.Convert;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -33,12 +38,23 @@
public class ProjectDataServiceImpl implements IProjectDataService {
- private static String manUploadPath = "imgupload";
+ private static String zipfile = "zipfile";
+ private static String zipfile2 = "zipfile2";
- private static String imgUploadPath = Global.getProfile() + "\\" + manUploadPath + "\\";
+ //zip 鍘熷鏂囦欢
+ private static String ZIPUploadPath = Global.getProfile() + "\\" + zipfile + "\\";
+
+ //瑙e帇鏂囦欢
+ private static String ZIPUploadPath2 = Global.getProfile() + "\\" + zipfile2 + "\\";
@Autowired
private ProjectDataMapper projectDataMapper;
+ @Autowired
+ private HoleMapper holeMapper;
+
+ @Autowired
+ private HoleMediaMapper mediaMapper;
+
/**
* 鏌ヨ椤圭洰璧勬枡
@@ -116,21 +132,17 @@
@Override
public AjaxResult uploadZIP(MultipartFile file, HttpServletRequest request) {
- String uploadPath = Global.getProfile() + "\\";
String originalFilename = file.getOriginalFilename();
-
- String fieldname = request.getParameter("fieldname");
- if (StringUtils.isEmpty(fieldname)) {
- fieldname = "filename";
- }
+ //浼犲叆鐨勯捇瀛旂殑id
+ String projectDataId = request.getParameter("projectDataId");
//鑾峰彇鍚庣紑.zip 淇濆瓨鐨勬枃浠跺悕
String substring = originalFilename.substring(originalFilename.lastIndexOf("."));
String UID = IdGenerate.nextId();
String dFileName = UID + substring;
- File file2 = new File(uploadPath + dFileName);
+ File file2 = new File(ZIPUploadPath + dFileName);
try {
file.transferTo(file2);
} catch (Exception e) {
@@ -143,53 +155,60 @@
} catch (Exception e) {
return AjaxResult.warn("闄勪欢瑙e帇缂╁け璐ワ紒");
}
- String moveDir = Global.getProfile() + "\\" + UID + "\\" + originalFilename.replace(substring, "");
- List<String> movedFiles = moveFile(moveDir);
- updateFilePath(fieldname, movedFiles);
- FileUtil.del(new File(uploadPath + UID));
- FileUtil.del(file2);
+ //绉诲姩鍒皕ipfile2 瀛樺偍瑙e帇瀹屾瘯鐨勬枃浠�
+ String moveDir = ZIPUploadPath + UID;
+ moveFile(moveDir);
+
+ //鏇存柊鏁版嵁搴�
+ updateFilePath(projectDataId, ZIPUploadPath2 + UID +"\\" + originalFilename.replace(substring, "") );
+
+ ProjectData projectData = new ProjectData();
+
+ //鏇存柊 projectData url
+ String dataUrl = zipfile + "/" + UID +".zip";
+ projectData.setDataUrl(dataUrl);
+ projectData.setId(projectDataId);
+ projectDataMapper.updateProjectData(projectData);
+
+ FileUtil.del(new File(ZIPUploadPath + UID));
+
return AjaxResult.success("涓婁紶鎴愬姛");
}
//绉诲姩 鏂囦欢
- private List<String> moveFile(String moveDir) {
- List<String> list = new ArrayList<>();
+ private void moveFile(String moveDir) {
File file = new File(moveDir);
- String detpath = imgUploadPath;
- if (file.isDirectory()) {
- File[] files = file.listFiles();
+ File dest = new File(ZIPUploadPath2);
+ FileUtil.move(file,dest,true);
+ }
+
+
+ @Transactional(rollbackFor = Exception.class)
+ public void updateFilePath(String projectDataId, String dirpath) {
+
+ ProjectData projectData = projectDataMapper.selectProjectDataById(projectDataId);
+ String projectId= projectData.getProjectId();
+
+ File fileDir = new File(dirpath);
+
+ if (fileDir.isDirectory()) {
+ File[] files = fileDir.listFiles();
int len = files.length;
for (int i = 0; i < len; i++) {
String filename = files[i].getName();
- list.add(filename);
- FileUtil.copy(files[i], new File(detpath + filename), true);
+ String filepath = files[i].getPath();
+ String url = filepath.replace(Global.getProfile(),"").replace("\\","/");
+
+ HoleMedia media = new HoleMedia();
+ media.setIds(IdGenerate.nextId());
+ media.setRecordId(projectDataId);
+ media.setProjectId(projectId);
+ media.setName(filename);
+ media.setInternetPath(url);
+ media.setCreateTime(DateUtils.getNowDate());
+ mediaMapper.insertHoleMedia(media);
}
- }
- return list;
- }
-
- private void updateFilePath(String filedname, List<String> filesPath) {
-
- for (String fileName : filesPath) {
- String substring = fileName.substring(fileName.lastIndexOf("."));
- String docFileName = fileName.replace(substring, "").trim();
- ProjectData param = new ProjectData();
-
- if (filedname.equals("filename")) {
- param.setName(docFileName);
- }
-
- List<ProjectData> list = projectDataMapper.selectProjectDataList(param);
- if (!ObjectUtils.isEmpty(list)) {
- for (ProjectData item : list) {
- ProjectData entity = new ProjectData();
- entity.setId(item.getId());
- entity.setDataUrl(manUploadPath + "/" + fileName);
- projectDataMapper.updateProjectData(entity);
- }
- }
-
}
}
diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/project/info.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/project/info.html
index 1f4867a..32e3404 100644
--- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/project/info.html
+++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/project/info.html
@@ -57,8 +57,9 @@
<div class="row">
<p class="project-name">
- <span class="name-label">鍦哄湴鍚嶇О锛�</span>
- <span class="name-val" th:text="${project.fullName}"></span>
+ <h3>鍦哄湴淇℃伅</h3>
+<!-- <span class="name-label">鍦哄湴鍚嶇О锛�</span>-->
+<!-- <span class="name-val" th:text="${project.fullName}"></span>-->
</p>
<table class="basic-info">
<tr>
@@ -93,6 +94,9 @@
<!-- </div>-->
</div>
+ <div class="row" style="margin-top: 30px;">
+ <h3>鍦哄湴閽诲瓟鍒楄〃</h3>
+ </div>
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
@@ -112,14 +116,7 @@
var options = {
url: prefix + "/list?projectId=" + projectId,
modalName: "閽诲瓟",
- columns: [{
- checkbox: true
- },
- {
- field : 'ids',
- title : '涓婚敭',
- visible: false
- },
+ columns: [
{
field : 'code',
title : '閽诲瓟缂栧彿'
diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/projectData.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/projectData.html
index 50579ed..407098c 100644
--- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/projectData.html
+++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/projectData.html
@@ -41,9 +41,9 @@
<!-- <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="geo:projectData:export">-->
<!-- <i class="fa fa-download"></i> 瀵煎嚭-->
<!-- </a>-->
- <a class="btn btn-danger" data-toggle="modal" onclick="uploadZIP();">
- <i class="fa fa-upload"></i>涓婁紶闄勪欢
- </a>
+<!-- <a class="btn btn-danger" data-toggle="modal" onclick="uploadZIP();">-->
+<!-- <i class="fa fa-upload"></i>涓婁紶闄勪欢-->
+<!-- </a>-->
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
@@ -94,8 +94,10 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
+
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>缂栬緫</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>鍒犻櫎</a> ');
+ actions.push('<a class="btn btn-info btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="uploadZIP(\'' + row.id + '\')"><i class="fa fa-upload"></i>涓婁紶</a> ');
actions.push('<a class="btn btn-info btn-xs ' + '" href="javascript:void(0)" onclick="viewImg(\'' + row.dataUrl + '\' , \'' + row.id + '\')"><i class="glyphicon glyphicon-menu-hamburger"></i>鏌ョ湅闄勪欢</a>');
return actions.join('');
}
@@ -105,11 +107,9 @@
});
// 涓婁紶闄勪欢
- function uploadZIP(){
- $.modal.open('涓婁紶闄勪欢', prefix + "/importImg");
+ function uploadZIP(id){
+ $.modal.open('涓婁紶闄勪欢', prefix + "/importImg?projectDataId="+id);
}
-
-
// 鏌ョ湅鍥剧墖璇︽儏
function viewImg(path, id) {
if(path === null || path === '' || path === 'null'){
@@ -121,4 +121,5 @@
}
</script>
</body>
+
</html>
\ No newline at end of file
diff --git a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/upload.html b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/upload.html
index af16c54..ae27303 100644
--- a/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/upload.html
+++ b/javaweb-plus/javaweb-cms/src/main/resources/templates/geo/projectData/upload.html
@@ -2,7 +2,7 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
- <th:block th:include="include :: header('鏂囨。鎻忚堪鍒楄〃')" />
+ <th:block th:include="include :: header('鏂囦欢涓婁紶')" />
<th:block th:include="include :: select2-css" />
</head>
@@ -13,51 +13,44 @@
<form id="formId" enctype="multipart/form-data">
<div class="select-list">
<ul>
- <li>
- <p>鍖归厤瀛楁锛�</p>
- <select id="docId" name="docId" class="form-control m-b">
- <option value="filename">鍥剧墖鍚嶇О</option>
- </select>
- </li>
-
+
<li>
- <p>鍘嬬缉鍖咃細</p>
+ <p>涓婁紶鏂囦欢锛�</p>
<input type="file" id="file" name="file"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="upload()"><i class="fa fa-search"></i> 涓婁紶</a>
- </li>
-
+ </li>
</ul>
</div>
</form>
</div>
<div class="col-sm-12 select-table table-striped">
- <span>1銆佸崟涓垨鑰呭涓枃浠惰浠�.ZIP鍘嬬缉鍖呯殑褰㈠紡涓婁紶锛屾妸鍗曚釜鎴栬�呭涓枃浠舵斁鍒版枃浠跺す涓紝鍘嬬缉鏂囦欢澶逛负zip鏍煎紡<br> </span>
- <span>1銆侀檮浠跺悕绉伴渶瑕佷笌绯荤粺鍐呯殑璧勬枡鍚嶇О涓�鑷�<br> </span>
- <span>2銆佹枃浠朵笉鍏佽鍖呭惈鐗规畩瀛楃锛氱┖鏍� 銆佹鍙嶆枩绾裤�侀棶鍙枫�佹槦鍙风瓑<br> </span>
- <span>3銆佷笂浼犳枃浠剁粡杩囦簡 瑙e帇 銆� 绉诲姩 銆侀亶鍘� 銆佹洿鏂版暟鎹簱绛夊涓楠わ紝璇疯�愬績绛夊緟<br> </span>
+ <h3>1銆佹敮鎸佸崟鏂囦欢鍜屽鏂囦欢妯″紡<br> </h3>
+ <h3>2銆佸涓枃浠惰浠�.ZIP鍘嬬缉鍖呯殑褰㈠紡涓婁紶锛屾妸鍗曚釜鎴栬�呭涓枃浠舵斁鍒版枃浠跺す涓紝鍘嬬缉鏂囦欢澶逛负zip鏍煎紡<br> </h3>
+ <h3>3銆佹枃浠朵笉鍏佽鍖呭惈鐗规畩瀛楃锛氱┖鏍� 銆佹鍙嶆枩绾裤�侀棶鍙枫�佹槦鍙风瓑<br> </h3>
+ <h3>4銆佷笂浼犳枃浠剁粡杩囦簡 瑙e帇 銆� 绉诲姩 銆侀亶鍘� 銆佹洿鏂版暟鎹簱绛夊涓楠わ紝璇疯�愬績绛夊緟<br> </h3>
</div>
-
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
+ var projectDataId = [[${projectDataId}]];
function upload(){
var file = $('#file').val();
if (file == '' || (!$.common.endWith(file, '.zip'))){
- $.modal.msgWarning("璇烽�夋嫨鍘嬬缉鍖�");
+ $.modal.msgWarning("璇烽�夋嫨寰呬笂浼犵殑鏂囦欢");
return false;
}
var formData = new FormData();
formData.append("file", $('#file')[0].files[0]);
- formData.append("fieldname", $('#docId').val());
+ formData.append("projectDataId", projectDataId);
$.modal.loading("鏁版嵁涓婁紶瑙f瀽涓�");
$.ajax({
--
Gitblit v1.9.1