|
@@ -7,13 +7,21 @@ import com.zjugis.business.bean.entity.Project;
|
|
import com.zjugis.business.bean.request.ProjectChildRequest;
|
|
import com.zjugis.business.bean.request.ProjectChildRequest;
|
|
import com.zjugis.business.bean.request.ProjectRequest;
|
|
import com.zjugis.business.bean.request.ProjectRequest;
|
|
import com.zjugis.business.bean.response.ProjectCalculateResponse;
|
|
import com.zjugis.business.bean.response.ProjectCalculateResponse;
|
|
|
|
+import com.zjugis.business.bean.response.ProjectExcelResponse;
|
|
import com.zjugis.business.bean.response.ProjectResponse;
|
|
import com.zjugis.business.bean.response.ProjectResponse;
|
|
import com.zjugis.business.service.ProjectService;
|
|
import com.zjugis.business.service.ProjectService;
|
|
import com.zjugis.framework.common.pojo.CommonResult;
|
|
import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
|
+import com.zjugis.framework.excel.core.util.ExcelUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -95,5 +103,24 @@ public class ProjectController{
|
|
public CommonResult<ProjectCalculateResponse> cost(ProjectDto projectDto) {
|
|
public CommonResult<ProjectCalculateResponse> cost(ProjectDto projectDto) {
|
|
return CommonResult.success(projectService.calculate(projectDto));
|
|
return CommonResult.success(projectService.calculate(projectDto));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @GetMapping("/export")
|
|
|
|
+ public void export( ProjectDto projectDto,
|
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
|
+ Page<Project> page = projectService.page(new Page<>(projectDto.getPageNo(),-1L),projectDto);
|
|
|
|
+ List<Project> projects = page.getRecords();
|
|
|
|
+
|
|
|
|
+ List<ProjectExcelResponse> excelList = new ArrayList<>(projects.size());
|
|
|
|
+ projects.forEach(project -> {
|
|
|
|
+ ProjectExcelResponse projectExcelResponse = new ProjectExcelResponse();
|
|
|
|
+ BeanUtils.copyProperties(project,projectExcelResponse);
|
|
|
|
+ excelList.add(projectExcelResponse);
|
|
|
|
+ });
|
|
|
|
+ response.setContentType("multipart/form-data");
|
|
|
|
+ response.setCharacterEncoding(String.valueOf(StandardCharsets.UTF_8));
|
|
|
|
+ response.setHeader("Content-Disposition",
|
|
|
|
+ "attachment;filename*=utf-8'zh-cn'" + URLEncoder.encode("项目.xlsx", String.valueOf(StandardCharsets.UTF_8)));
|
|
|
|
+ ExcelUtils.write(response, "项目.xlsx", "项目列表", ProjectExcelResponse.class, excelList);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|