Commit d956e1c9 authored by danfuman's avatar danfuman
parents 490a8e20 1a239ebd
...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -69,17 +70,6 @@ public class BusinessFileController extends BaseController { ...@@ -69,17 +70,6 @@ public class BusinessFileController extends BaseController {
return getDataTable(allFiles); return getDataTable(allFiles);
} }
/* *//**
* 上传文件及文件夹
* @param url
* @param folderPath
* @return
*//*
@GetMapping("/upload/{url}/{folderPath}")
public AjaxResult uploadFolder(@PathVariable("url") String url,@PathVariable("folderPath") String folderPath) throws IOException {
return toAjax(FileUtils.uploadFolder(url, LOCALPATH + folderPath));
}*/
/** /**
* 上传文件及文件夹 * 上传文件及文件夹
* @param file 文件流 * @param file 文件流
...@@ -87,7 +77,7 @@ public class BusinessFileController extends BaseController { ...@@ -87,7 +77,7 @@ public class BusinessFileController extends BaseController {
* @return * @return
*/ */
@PostMapping("/upload") @PostMapping("/upload")
public AjaxResult uploadFolder(@RequestPart("file") MultipartFile file,HttpServletRequest request){ public AjaxResult uploadFolder(@RequestPart("file") MultipartFile file, HttpServletRequest request){
try { try {
String businessFileName = request.getHeader("FilePath"); String businessFileName = request.getHeader("FilePath");
// 上传文件路径 // 上传文件路径
...@@ -96,7 +86,7 @@ public class BusinessFileController extends BaseController { ...@@ -96,7 +86,7 @@ public class BusinessFileController extends BaseController {
String fileName = FileUploadUtils.upload(filePath, file); String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("url", url); ajax.put("url", fileName);
return ajax; return ajax;
} catch (IOException e) { } catch (IOException e) {
return AjaxResult.error(e.getMessage()); return AjaxResult.error(e.getMessage());
...@@ -105,12 +95,11 @@ public class BusinessFileController extends BaseController { ...@@ -105,12 +95,11 @@ public class BusinessFileController extends BaseController {
/** /**
* 下载文件 * 下载文件
* @param url * @param filePath 要下载的文件路径
* @param targetFolder * @param response 返回的响应
* @return
*/ */
@GetMapping("/download/{url}/{targetFolder}") @PostMapping("/download")
public AjaxResult downloadFolder(@PathVariable("url") String url,@PathVariable("targetFolder") String targetFolder) throws IOException { public void downloadFolder(@RequestBody BusinessIdDto filePath, HttpServletResponse response) {
return toAjax(FileUtils.downloadFolder(url, targetFolder)); FileUtils.downloadByFilePath(filePath.getFilePath(),response);
} }
} }
package com.dsk.web.controller.search.macroMarket; package com.dsk.web.controller.search.macroMarket;
import com.dsk.common.core.domain.AjaxResult; import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.dtos.ComposeQueryDto; import com.dsk.common.dtos.ComposeQueryDto;
import com.dsk.system.service.RegionalEnterprisesService; import com.dsk.system.service.RegionalEnterprisesService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -24,7 +24,7 @@ public class RegionalEnterprisesController { ...@@ -24,7 +24,7 @@ public class RegionalEnterprisesController {
private RegionalEnterprisesService regionalEnterprisesService; private RegionalEnterprisesService regionalEnterprisesService;
@PostMapping("regional/page") @PostMapping("regional/page")
public AjaxResult page(@RequestBody ComposeQueryDto compose) { public TableDataInfo page(@RequestBody ComposeQueryDto compose) throws Exception{
return regionalEnterprisesService.page(compose); return regionalEnterprisesService.page(compose);
} }
} }
...@@ -18,5 +18,6 @@ public class EnterpriseStatisticBody ...@@ -18,5 +18,6 @@ public class EnterpriseStatisticBody
*/ */
@NotNull(message = "企业id不能为空") @NotNull(message = "企业id不能为空")
private Integer companyId; private Integer companyId;
private Boolean isFy = false;
} }
...@@ -4,6 +4,7 @@ import com.dsk.common.config.RuoYiConfig; ...@@ -4,6 +4,7 @@ import com.dsk.common.config.RuoYiConfig;
import com.dsk.common.core.domain.entity.BusinessFileVo; import com.dsk.common.core.domain.entity.BusinessFileVo;
import com.dsk.common.exception.base.BaseException; import com.dsk.common.exception.base.BaseException;
import com.dsk.common.utils.DateUtils; import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.ServletUtils;
import com.dsk.common.utils.StringUtils; import com.dsk.common.utils.StringUtils;
import com.dsk.common.utils.uuid.IdUtils; import com.dsk.common.utils.uuid.IdUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -29,8 +30,6 @@ import java.nio.charset.StandardCharsets; ...@@ -29,8 +30,6 @@ import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/** /**
* 文件处理工具类 * 文件处理工具类
...@@ -313,46 +312,95 @@ public class FileUtils ...@@ -313,46 +312,95 @@ public class FileUtils
} }
/** /**
* 下载文件 * 根据文件路径下载文件
* @param url 要下载的文件链接 * @param filePath 要下载的文件路径
* @param targetFolder 目标文件 * @param response 返回的响应
*/
public static void downloadByFilePath(String filePath, HttpServletResponse response) {
try {
// path是指想要下载的文件的路径
File file = new File(filePath);
// log.info(file.getPath());
if (!file.exists()) throw new BaseException("文件不存在!");
// 获取文件名
String filename = file.getName();
// log.info("文件名: "+filename);
// 获取文件后缀名
// String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
// log.info("文件后缀名:" + ext);
// 将文件写入输入流
FileInputStream fileInputStream = new FileInputStream(file);
InputStream fis = new BufferedInputStream(fileInputStream);
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
// 清空response
response.reset();
// 设置response的Header
response.setCharacterEncoding("UTF-8");
//文件类型
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
//文件名称
response.addHeader("Download-filename", URLEncoder.encode(filename, "UTF-8"));
// 告知浏览器文件的大小
response.addHeader("Content-Length", "" + file.length());
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
outputStream.write(buffer);
fis.close();
outputStream.flush();
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* 根据文件url下载文件
* @param filePath 要下载的文件链接
* @param response 响应体
* @return * @return
* @throws IOException * @throws IOException
*/ */
public static boolean downloadFolder(String url, String targetFolder) throws IOException { public static void downloadByUrl(String filePath, HttpServletResponse response){
URL downloadUrl = new URL(url); // String fileUrl = request.getParameter("fileUrl"); // 获取文件链接
HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
connection.setRequestMethod("GET");
connection.connect();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { try {
throw new RuntimeException("下载文件夹失败: " + connection.getResponseMessage()); URL url = new URL(filePath);
} HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
try (ZipInputStream zipInputStream = new ZipInputStream(connection.getInputStream())) { // 设置响应头,告诉浏览器下载文件
ZipEntry entry; String contentType = connection.getContentType(); // 获取文件类型
while ((entry = zipInputStream.getNextEntry()) != null) { response.setContentType(contentType);
String entryName = entry.getName(); String filename = extractFilenameFromUrl(filePath); // 从链接中提取文件名
if (StringUtils.isBlank(entryName)) { response.setHeader("Content-Disposition", "attachment; filename=" + filename + "");
continue;
}
File entryFile = new File(targetFolder, entryName); // 将文件流写入响应输出流
if (entry.isDirectory()) { InputStream inputStream = connection.getInputStream();
entryFile.mkdirs(); byte[] buffer = new byte[4096];
} else { int bytesRead = -1;
File parent = entryFile.getParentFile(); while ((bytesRead = inputStream.read(buffer)) != -1) {
if (!parent.exists()) { response.getOutputStream().write(buffer, 0, bytesRead);
parent.mkdirs();
} }
inputStream.close();
try (FileOutputStream outputStream = new FileOutputStream(entryFile)) { connection.disconnect();
IOUtils.copy(zipInputStream, outputStream); } catch (Exception e) {
} e.printStackTrace();
} }
} }
// 从文件链接中提取文件名
public static String extractFilenameFromUrl(String url) {
int slashIndex = url.lastIndexOf('/');
int dotIndex = url.lastIndexOf('.');
if (dotIndex == -1 || dotIndex < slashIndex) {
return "download";
} }
return true; return url.substring(slashIndex + 1);
} }
/** /**
...@@ -568,4 +616,17 @@ public class FileUtils ...@@ -568,4 +616,17 @@ public class FileUtils
String baseName = FilenameUtils.getBaseName(fileName); String baseName = FilenameUtils.getBaseName(fileName);
return baseName; return baseName;
} }
/**
* 获取本地服务的域名,端口
* @return
*/
public static String getUrl()
{
HttpServletRequest request = ServletUtils.getRequest();
StringBuffer url = request.getRequestURL();
String contextPath = request.getServletContext().getContextPath();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
}
} }
...@@ -11,12 +11,6 @@ import java.util.List; ...@@ -11,12 +11,6 @@ import java.util.List;
**/ **/
@Data @Data
public class BusinessListDto { public class BusinessListDto {
/**
* 拜访方式
*/
private String visitWay;
/** /**
* 项目名称 * 项目名称
*/ */
......
...@@ -121,9 +121,14 @@ public class BusinessBrowseVo { ...@@ -121,9 +121,14 @@ public class BusinessBrowseVo {
private Integer backlogCount; private Integer backlogCount;
/** /**
* 资料文档统计 * 相关企业统计
*/ */
private Integer relateCompanyCount; private Integer relateCompanyCount;
/**
* 资料文档统计
*/
private Integer fileCount;
} }
...@@ -3,6 +3,7 @@ package com.dsk.system.mapper; ...@@ -3,6 +3,7 @@ package com.dsk.system.mapper;
import com.dsk.common.core.domain.entity.BusinessFollowRecord; import com.dsk.common.core.domain.entity.BusinessFollowRecord;
import com.dsk.system.domain.BusinessIdDto; import com.dsk.system.domain.BusinessIdDto;
import com.dsk.system.domain.BusinessListDto; import com.dsk.system.domain.BusinessListDto;
import com.dsk.system.domain.vo.BusinessListVo;
import java.util.List; import java.util.List;
...@@ -20,7 +21,7 @@ public interface BusinessFollowRecordMapper ...@@ -20,7 +21,7 @@ public interface BusinessFollowRecordMapper
* @param userId * @param userId
* @return * @return
*/ */
List<String> selectRelateProject (Integer userId); List<BusinessListVo> selectRelateProject (Integer userId);
/** /**
* 查询关联业主企业 * 查询关联业主企业
......
...@@ -3,6 +3,7 @@ package com.dsk.system.service; ...@@ -3,6 +3,7 @@ package com.dsk.system.service;
import com.dsk.common.core.domain.entity.BusinessFollowRecord; import com.dsk.common.core.domain.entity.BusinessFollowRecord;
import com.dsk.system.domain.BusinessIdDto; import com.dsk.system.domain.BusinessIdDto;
import com.dsk.system.domain.BusinessListDto; import com.dsk.system.domain.BusinessListDto;
import com.dsk.system.domain.vo.BusinessListVo;
import java.util.List; import java.util.List;
...@@ -59,7 +60,7 @@ public interface IBusinessFollowRecordService ...@@ -59,7 +60,7 @@ public interface IBusinessFollowRecordService
* @param userId * @param userId
* @return * @return
*/ */
List<String> selectRelateProject (Integer userId); List<BusinessListVo> selectRelateProject (Integer userId);
/** /**
* 查询关联业主企业 * 查询关联业主企业
......
package com.dsk.system.service; package com.dsk.system.service;
import com.dsk.common.core.domain.AjaxResult; import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.dtos.ComposeQueryDto; import com.dsk.common.dtos.ComposeQueryDto;
/** /**
...@@ -19,5 +19,5 @@ public interface RegionalEnterprisesService { ...@@ -19,5 +19,5 @@ public interface RegionalEnterprisesService {
*@Author: Dgm *@Author: Dgm
*@date: 2023/5/18 10:25 *@date: 2023/5/18 10:25
*/ */
AjaxResult page(ComposeQueryDto compose); TableDataInfo page(ComposeQueryDto compose) throws Exception;
} }
package com.dsk.system.service.impl; package com.dsk.system.service.impl;
import com.dsk.common.core.domain.entity.BusinessFollowRecord; import com.dsk.common.core.domain.entity.BusinessFollowRecord;
import com.dsk.common.exception.base.BaseException;
import com.dsk.common.utils.DateUtils; import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.BusinessIdDto; import com.dsk.system.domain.BusinessIdDto;
import com.dsk.system.domain.BusinessListDto; import com.dsk.system.domain.BusinessListDto;
import com.dsk.system.domain.vo.BusinessListVo;
import com.dsk.system.mapper.BusinessFollowRecordMapper; import com.dsk.system.mapper.BusinessFollowRecordMapper;
import com.dsk.system.service.IBusinessFollowRecordService; import com.dsk.system.service.IBusinessFollowRecordService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -45,11 +48,11 @@ public class BusinessFollowRecordServiceImpl implements IBusinessFollowRecordSer ...@@ -45,11 +48,11 @@ public class BusinessFollowRecordServiceImpl implements IBusinessFollowRecordSer
@Override @Override
public List<BusinessFollowRecord> allFollow(BusinessListDto dto) { public List<BusinessFollowRecord> allFollow(BusinessListDto dto) {
//userId不传值,就查询全部门项目 //userId不传值,就查询全部门项目
// if (dto.getUserId() == null) { if (dto.getUserId() == null) {
// Long deptId = SecurityUtils.getLoginUser().getDeptId(); Long deptId = SecurityUtils.getLoginUser().getDeptId();
// if (deptId == null) throw new BaseException("请登录"); if (deptId == null) throw new BaseException("请登录");
// dto.setDeptId(deptId.intValue()); dto.setDeptId(deptId.intValue());
// } }
return businessFollowRecordMapper.allFollow(dto); return businessFollowRecordMapper.allFollow(dto);
} }
...@@ -72,7 +75,7 @@ public class BusinessFollowRecordServiceImpl implements IBusinessFollowRecordSer ...@@ -72,7 +75,7 @@ public class BusinessFollowRecordServiceImpl implements IBusinessFollowRecordSer
} }
@Override @Override
public List<String> selectRelateProject(Integer userId) { public List<BusinessListVo> selectRelateProject(Integer userId) {
return businessFollowRecordMapper.selectRelateProject(userId); return businessFollowRecordMapper.selectRelateProject(userId);
} }
......
...@@ -80,11 +80,11 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -80,11 +80,11 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
@Override @Override
public List<BusinessListVo> selectBusinessInfoList(BusinessListDto dto) { public List<BusinessListVo> selectBusinessInfoList(BusinessListDto dto) {
//userId不传值,就查询全部门项目 //userId不传值,就查询全部门项目
// if (dto.getUserId() == null) { if (dto.getUserId() == null) {
// Long deptId = SecurityUtils.getLoginUser().getDeptId(); Long deptId = SecurityUtils.getLoginUser().getDeptId();
// if (deptId == null) throw new BaseException("请登录"); if (deptId == null) throw new BaseException("请登录");
// dto.setDeptId(deptId.intValue()); dto.setDeptId(deptId.intValue());
// } }
return businessInfoMapper.selectBusinessInfoList(dto); return businessInfoMapper.selectBusinessInfoList(dto);
} }
...@@ -105,7 +105,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -105,7 +105,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
businessBrowseVo.setFollowRecordCount(total.getFollowRecordCount()); businessBrowseVo.setFollowRecordCount(total.getFollowRecordCount());
businessBrowseVo.setRelateCompanyCount(total.getRelateCompanyCount()); businessBrowseVo.setRelateCompanyCount(total.getRelateCompanyCount());
//资料文档统计 //资料文档统计
businessBrowseVo.setRelateCompanyCount(FileUtils.getAllFileNames(RuoYiConfig.getProfile()+businessId).size()); businessBrowseVo.setFileCount(FileUtils.getAllFileNames(RuoYiConfig.getProfile()+businessId).size());
return businessBrowseVo; return businessBrowseVo;
} }
......
package com.dsk.system.service.impl; package com.dsk.system.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.dsk.common.core.domain.AjaxResult; import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.dtos.ComposeQueryDto; import com.dsk.common.dtos.ComposeQueryDto;
import com.dsk.common.utils.DskOpenApiUtil; import com.dsk.common.utils.DskOpenApiUtil;
import com.dsk.system.service.RegionalEnterprisesService; import com.dsk.system.service.RegionalEnterprisesService;
...@@ -24,8 +24,8 @@ public class RegionalEnterprisesServiceImpl implements RegionalEnterprisesServic ...@@ -24,8 +24,8 @@ public class RegionalEnterprisesServiceImpl implements RegionalEnterprisesServic
private DskOpenApiUtil dskOpenApiUtil; private DskOpenApiUtil dskOpenApiUtil;
@Override @Override
public AjaxResult page(ComposeQueryDto compose) { public TableDataInfo page(ComposeQueryDto compose) throws Exception {
Map<String, Object> map = dskOpenApiUtil.requestBody("/nationzj/enterprice/page", BeanUtil.beanToMap(compose, false, false)); Map<String, Object> map = dskOpenApiUtil.requestBody("/nationzj/enterprice/page", BeanUtil.beanToMap(compose, false, false));
return BeanUtil.toBean(map, AjaxResult.class); return dskOpenApiUtil.responsePage(map);
} }
} }
...@@ -75,29 +75,20 @@ ...@@ -75,29 +75,20 @@
<if test="deptId != null"> <if test="deptId != null">
and u.dept_id = #{deptId} and u.dept_id = #{deptId}
</if> </if>
<if test="projectName != null and projectName != ''">
and i.project_name = #{projectName}
</if>
<if test="ownerCompany != null and ownerCompany != ''">
and i.construction_unit = #{ownerCompany}
</if>
<if test="visitWay != null and visitWay != ''">
and f.visit_way = #{visitWay}
</if>
</where> </where>
ORDER BY f.creat_time DESC ORDER BY f.creat_time DESC
</select> </select>
<select id="selectRelateProject" resultType="java.lang.String"> <select id="selectRelateProject" resultType="com.dsk.system.domain.vo.BusinessListVo">
select i.project_name select i.id,i.project_name as projectName
from business_info i from business_info i
left join business_follow_record f on f.business_id = i.id left join business_user u on u.business_id = i.id
where f.user_id = #{userId} where u.user_id = #{userId}
</select> </select>
<select id="selectRelateCompany" resultType="java.lang.String"> <select id="selectRelateCompany" resultType="java.lang.String">
select i.construction_unit select i.construction_unit
from business_info i from business_info i
left join business_follow_record f on f.business_id = i.id left join business_user u on u.business_id = i.id
where f.user_id = #{userId} where u.user_id = #{userId}
</select> </select>
<insert id="insertBusinessFollowRecord" parameterType="com.dsk.common.core.domain.entity.BusinessFollowRecord" useGeneratedKeys="true" <insert id="insertBusinessFollowRecord" parameterType="com.dsk.common.core.domain.entity.BusinessFollowRecord" useGeneratedKeys="true"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment