diff --git a/src/main/java/com/bonus/digitalSignage/basic/controller/DownloadController.java b/src/main/java/com/bonus/digitalSignage/basic/controller/DownloadController.java new file mode 100644 index 0000000..7b295c0 --- /dev/null +++ b/src/main/java/com/bonus/digitalSignage/basic/controller/DownloadController.java @@ -0,0 +1,71 @@ +package com.bonus.digitalSignage.basic.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.util.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.ResourceLoader; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +@Api(tags = "下载") +@RestController +@RequestMapping("/download") +@Slf4j +public class DownloadController { + public static Logger logger = LoggerFactory.getLogger(DownloadController.class); + + @Resource + private ResourceLoader resourceLoader; + + @ApiOperation(value = "模板", httpMethod = "GET") + @GetMapping("download") + public void download(HttpServletRequest request, HttpServletResponse response, String filename) { + InputStream inputStream = null; + ServletOutputStream servletOutputStream = null; + try { + String path = "download/" + filename; + org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:" + path); + response.setContentType("application/vnd.ms-excel"); + response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate"); + response.addHeader("charset", "utf-8"); + response.addHeader("Pragma", "no-cache"); + String encodeName = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString()); + response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName); + + inputStream = resource.getInputStream(); + servletOutputStream = response.getOutputStream(); + IOUtils.copy(inputStream, servletOutputStream); + response.flushBuffer(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (servletOutputStream != null) { + servletOutputStream.close(); + } + if (inputStream != null) { + inputStream.close(); + } + // 召唤jvm的垃圾回收器 + System.gc(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + +} diff --git a/src/main/java/com/bonus/digitalSignage/basic/dao/ProManagementDao.java b/src/main/java/com/bonus/digitalSignage/basic/dao/ProManagementDao.java index 1ec8f91..62cae74 100644 --- a/src/main/java/com/bonus/digitalSignage/basic/dao/ProManagementDao.java +++ b/src/main/java/com/bonus/digitalSignage/basic/dao/ProManagementDao.java @@ -15,14 +15,12 @@ public interface ProManagementDao { List getAll(); - ProManagementVo getProId(ProManagementVo bean); - int addPro(ProManagementVo bean); int updatePro(ProManagementVo bean); int deletePro(ProManagementVo bean); -// int getProId(ProManagementVo bean); + int getProId(ProManagementVo bean); } diff --git a/src/main/java/com/bonus/digitalSignage/basic/service/impl/ProManagementServiceImpl.java b/src/main/java/com/bonus/digitalSignage/basic/service/impl/ProManagementServiceImpl.java index 29727e8..4fba1bb 100644 --- a/src/main/java/com/bonus/digitalSignage/basic/service/impl/ProManagementServiceImpl.java +++ b/src/main/java/com/bonus/digitalSignage/basic/service/impl/ProManagementServiceImpl.java @@ -48,8 +48,7 @@ public class ProManagementServiceImpl implements ProManagementService { @Override public int getProId(ProManagementVo bean) { - return 0; -// return dao.getProId(bean); + return dao.getProId(bean); } diff --git a/src/main/java/com/bonus/digitalSignage/config/BnsSecurityConfig.java b/src/main/java/com/bonus/digitalSignage/config/BnsSecurityConfig.java index 2a04ec1..7e0f58f 100644 --- a/src/main/java/com/bonus/digitalSignage/config/BnsSecurityConfig.java +++ b/src/main/java/com/bonus/digitalSignage/config/BnsSecurityConfig.java @@ -54,7 +54,7 @@ public class BnsSecurityConfig extends WebSecurityConfigurerAdapter { http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); http.authorizeRequests() .antMatchers("/", "/*.html", "/favicon.ico", "/css/**", "/js/**", "/fonts/**", "/layui/**", "/img/**" - , "/webjars/**", "/pages/**","/login","/loginApp/**", + , "/webjars/**", "/pages/**","/login","/loginApp/**","/download/**", "/statics/**","/websocketServer/**","/api/download/**") .permitAll().anyRequest().authenticated(); http.formLogin().loginProcessingUrl("/login") diff --git a/src/main/resources/download/杆塔管理-2000国家大地坐标系导入模版.xlsx b/src/main/resources/download/杆塔管理-2000国家大地坐标系导入模版.xlsx new file mode 100644 index 0000000..60bcf56 Binary files /dev/null and b/src/main/resources/download/杆塔管理-2000国家大地坐标系导入模版.xlsx differ diff --git a/src/main/resources/download/杆塔管理-WGS-84地心坐标系导入模版.xlsx b/src/main/resources/download/杆塔管理-WGS-84地心坐标系导入模版.xlsx new file mode 100644 index 0000000..2348e14 Binary files /dev/null and b/src/main/resources/download/杆塔管理-WGS-84地心坐标系导入模版.xlsx differ diff --git a/src/main/resources/mappers/basic/ProManagementMapper.xml b/src/main/resources/mappers/basic/ProManagementMapper.xml index f6d4569..de620bd 100644 --- a/src/main/resources/mappers/basic/ProManagementMapper.xml +++ b/src/main/resources/mappers/basic/ProManagementMapper.xml @@ -15,9 +15,9 @@ po.is_active = '1' - + SELECT count(1) FROM `tb_project` + WHERE depart_id = #{id} diff --git a/src/main/resources/static/js/basic/lineManagement/child/importTower.js b/src/main/resources/static/js/basic/lineManagement/child/importTower.js index fb1fc2a..8141774 100644 --- a/src/main/resources/static/js/basic/lineManagement/child/importTower.js +++ b/src/main/resources/static/js/basic/lineManagement/child/importTower.js @@ -1,4 +1,10 @@ +let form, layer, util,laydate, idParam, phoneParam,proId; +let arr = ['background', 'web', 'mobile', 'wx']; +let background, web, mobile, wx; function setParams(params) { + console.log(params) + idParam = JSON.parse(params).id; + proId = JSON.parse(params).proId; layui.use(['upload', 'layer'], function(){ var upload = layui.upload; var layer = layui.layer; @@ -27,26 +33,45 @@ function setParams(params) { document.getElementById('downloadTemplateWGS84').addEventListener('click', function() { layer.msg('开始下载WGS-84坐标系模板'); // 实际项目中替换为真实的下载链接 - // window.location.href = 'path/to/wgs84_template.xlsx'; + window.location.href =ctxPath + '/download/download?filename=杆塔管理-WGS-84地心坐标系导入模版.xlsx'; }); // 2000国家大地坐标系模板下载 document.getElementById('downloadTemplate2000').addEventListener('click', function() { layer.msg('开始下载2000国家大地坐标系模板'); // 实际项目中替换为真实的下载链接 - // window.location.href = 'path/to/2000_template.xlsx'; + window.location.href = ctxPath +'/download/download?filename=杆塔管理-2000国家大地坐标系导入模版.xlsx'; }); + let WG = { + uploadType: '1', + proId:proId + } + console.log("WG",WG) + let paramsWG = { + encryptedData: encryptCBC(JSON.stringify(WG)) + } + + let WG2 = { + uploadType: '2', + proId:proId + } + console.log("WG2",WG2) + let paramsWG2 = { + encryptedData: encryptCBC(JSON.stringify(WG2)) + } + // WGS-84坐标系文件上传 upload.render({ elem: '#uploadFileWGS84', - url: '', // 上传接口 + url: ctxPath + '/tbTower/tbTowerImport', // 上传接口 + headers: { + "token": tokens + }, accept: 'file', exts: 'xls|xlsx', size: 10240, // 限制文件大小10MB - data: { - system: 'wgs84' - }, + data: paramsWG, before: function(obj) { layer.load(); // 上传loading }, @@ -67,13 +92,14 @@ function setParams(params) { // 2000国家大地坐标系文件上传 upload.render({ elem: '#uploadFile2000', - url: '', // 上传接口 + url: ctxPath + '/tbTower/tbTowerImport', // 上传接口 + headers: { + "token": tokens + }, accept: 'file', exts: 'xls|xlsx', size: 10240, // 限制文件大小10MB - data: { - system: '2000' - }, + data: paramsWG2, before: function(obj) { layer.load(); // 上传loading }, diff --git a/src/main/resources/static/js/basic/lineManagement/child/threeSpanList.js b/src/main/resources/static/js/basic/lineManagement/child/threeSpanList.js index dd524f4..2fc4781 100644 --- a/src/main/resources/static/js/basic/lineManagement/child/threeSpanList.js +++ b/src/main/resources/static/js/basic/lineManagement/child/threeSpanList.js @@ -70,7 +70,11 @@ function initTable(dataList, limit, page) { return (page - 1) * limit + d.LAY_INDEX; } }, - {field: "towerName", title: "杆塔号", unresize: true, align: "center"}, + {field: "towerName", title: "杆塔号", unresize: true, align: "center", + templet: function (d) { + return d.towerName+"-"+d.nextTowerName; + } + }, {field: "", title: "跨越类型", unresize: true, align: "center", templet: function (d) { if(d.spanType == 1){ diff --git a/src/main/resources/static/js/basic/lineManagement/child/towerList.js b/src/main/resources/static/js/basic/lineManagement/child/towerList.js index 73ac338..063f13f 100644 --- a/src/main/resources/static/js/basic/lineManagement/child/towerList.js +++ b/src/main/resources/static/js/basic/lineManagement/child/towerList.js @@ -182,59 +182,6 @@ function delData(id) { }) } -// 启用/停用/解除锁定 -function editUserAccountStatus(id, status, type) { - let url = dataUrl + "/sys/user/editUserAccountStatus?token=" + token; - let params = { - 'id': id, - 'accountStatus': status, - 'type': type - } - ajaxRequest(url, "POST", params, true, function () { - }, function (result) { - if (result.code === 200) { - if (type) { - reloadData(); - } - parent.layer.msg(result.msg, {icon: 1}) - } else if (result.code === 500) { - layer.alert(result.msg, {icon: 2}) - } - }, function (xhr) { - error(xhr) - }); -} - -// 管理员修改密码 -function resetPwd(id) { - let param = { - 'id': id, - 'type': '1' - } - openIframe2("addOrEditUnifyUser", '修改密码', "password.html", '770px', '400px', param); -} - -function addTower(id){ - let param = { - 'id': id - } - openIframe2("tower", '杆塔管理', "child/towerList.html", '1200px', '625px', param); -} - -function addThreeSpan(id){ - let param = { - 'id': id - } - openIframe2("threeSpan", '“三跨”管理', "child/threeSpanList.html", '1200px', '625px', param); -} - -function addRopeway(id){ - let param = { - 'id': id - } - openIframe2("ropeway", '索道运输', "child/ropewayList.html", '1200px', '625px', param); -} - function exportTower(){ let obj = { towerName: $('#towerName').val(), @@ -269,7 +216,8 @@ function exportTower(){ function importTower(){ let param = { - 'id': '' + 'id': '', + 'proId':idParam } openIframe2("ropeway", '数据导入', "importTower.html", '1000px', '625px', param); } \ No newline at end of file