地质所 沉降监测网建设项目
chenhuan
2024-05-20 c6f79f5720c5d4a700b8b759a93393559409fd1c
javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectDataController.java
@@ -1,16 +1,22 @@
package com.javaweb.geo.controller;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import com.javaweb.common.config.Global;
import com.javaweb.geo.domain.Hole;
import com.javaweb.geo.domain.HoleMedia;
import com.javaweb.geo.service.IHoleMediaService;
import com.javaweb.geo.vo.FileVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import com.javaweb.common.annotation.Log;
import com.javaweb.common.enums.BusinessType;
import com.javaweb.geo.domain.ProjectData;
@@ -19,6 +25,9 @@
import com.javaweb.common.core.domain.AjaxResult;
import com.javaweb.common.utils.poi.ExcelUtil;
import com.javaweb.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
/**
 * 项目资料Controller
@@ -34,12 +43,56 @@
    @Autowired
    private IProjectDataService projectDataService;
    @Autowired
    private IHoleMediaService holeMediaService;
    @RequiresPermissions("geo:projectData:view")
    @GetMapping()
    public String projectData(String id, String type, ModelMap mmap) {
        mmap.put("projectId", id);
        mmap.put("type", type);
        return prefix + "/projectData";
    }
    @RequiresPermissions("geo:projectData:view")
    @GetMapping("/2")
    public String projectData2(String id, String type, ModelMap mmap) {
        mmap.put("projectId", id);
        mmap.put("type", type);
        return prefix + "/projectData2";
    }
    /**
     * 导入压缩包
     */
    @GetMapping("/importImg")
    public String importPdf(String projectDataId,ModelMap mmap){
        mmap.put("projectDataId",projectDataId);
        return prefix + "/upload";
    }
    /**
     * 图片展示
     */
    @GetMapping("/viewImage")
    public String viewImage(ModelMap mmap, @RequestParam("id") String id){
        ProjectData data = projectDataService.selectProjectDataById(id);
        String path = "";
        if (!ObjectUtils.isEmpty(data)){
            path = data.getDataUrl();
        }
        mmap.put("urlAddress",path);
        return  prefix + "/image_view";
    }
    /**
     * 项目文件列表页面
     * @return
     */
    @GetMapping("/projectDataFileList")
    public String projectDataFileList(String id ,ModelMap modelMap){
        modelMap.put("id",id);
        return prefix + "/files";
    }
    /**
@@ -119,4 +172,39 @@
    public AjaxResult remove(String ids) {
        return toAjax(projectDataService.deleteProjectDataByIds(ids));
    }
    /**
     * 上传压缩包
     */
    @PostMapping("/uploadZIP")
    @ResponseBody
    public AjaxResult uploadZIP(MultipartFile file, HttpServletRequest request){
        return projectDataService.uploadZIP(file,request);
    }
    /**
     * 获取文件列表
     * @param id
     * @return
     */
    @PostMapping( "/listFile")
    @ResponseBody
    public TableDataInfo listFile(String id){
        List<FileVo> paths = new ArrayList<>();
        HoleMedia holeMedia = new HoleMedia();
        holeMedia.setRecordId(id);
        List<HoleMedia> holeMedias =holeMediaService.selectHoleMediaList(holeMedia);
        if(ObjectUtil.isNotEmpty(holeMedias)){
            for(HoleMedia holeMedia1 :holeMedias ){
                FileVo vo = new FileVo() ;
                vo.setName(holeMedia1.getName());
                vo.setPath(holeMedia1.getInternetPath());
                paths.add(vo);
            }
        }
        return getDataTable(paths);
    }
}