|
@@ -2,10 +2,13 @@ package com.dayou.controller;
|
|
|
|
|
|
import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.lang.UUID;
|
|
import com.dayou.config.FileNetConfig;
|
|
import com.dayou.config.FileNetConfig;
|
|
|
|
+import com.dayou.entity.TmplAssetCalculate;
|
|
import com.dayou.entity.TmplAssetCalculateSection;
|
|
import com.dayou.entity.TmplAssetCalculateSection;
|
|
|
|
+import com.dayou.exception.BusinessException;
|
|
import com.dayou.result.Result;
|
|
import com.dayou.result.Result;
|
|
import com.dayou.result.Status;
|
|
import com.dayou.result.Status;
|
|
import com.dayou.service.TmplAssetCalculateSectionService;
|
|
import com.dayou.service.TmplAssetCalculateSectionService;
|
|
|
|
+import com.dayou.service.TmplAssetCalculateService;
|
|
import com.dayou.utils.FileNetUtil;
|
|
import com.dayou.utils.FileNetUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -29,6 +32,9 @@ import static com.dayou.enums.EqptCalculateTmplCode.MAIN_DETAIL;
|
|
public class FileController {
|
|
public class FileController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private TmplAssetCalculateService tmplAssetCalculateService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
private TmplAssetCalculateSectionService tmplAssetCalculateSectionService;
|
|
private TmplAssetCalculateSectionService tmplAssetCalculateSectionService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -123,17 +129,28 @@ public class FileController {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 下载资产机器设备测算表段落模板
|
|
|
|
|
|
+ * 下载资产业务测算表模板
|
|
* @param request
|
|
* @param request
|
|
* @param response
|
|
* @param response
|
|
|
|
+ * @param tmplCode 模板code
|
|
|
|
+ * @param tmplType 模板类型(MAIN:主模板,SECTION:段落模板)
|
|
*/
|
|
*/
|
|
- @GetMapping("/download/assets/declarationForm")
|
|
|
|
- public void downloadDeclarationForm(HttpServletRequest request, HttpServletResponse response, String tmplCode){
|
|
|
|
|
|
+ @GetMapping("/download/assets/tmpl")
|
|
|
|
+ public void downloadAnalysisMain(HttpServletRequest request, HttpServletResponse response, String tmplCode, String tmplType){
|
|
// 获取模板
|
|
// 获取模板
|
|
- TmplAssetCalculateSection tmpl = tmplAssetCalculateSectionService.getTmplByCode(tmplCode);
|
|
|
|
- String path = fileNetConfig.getBaseDir() + tmpl.getSectionFileUrl() + tmpl.getSectionFileName();
|
|
|
|
- File file = new File(path);
|
|
|
|
- FileNetUtil.writeFile2Response(request,response,file,tmpl.getSectionFileName());
|
|
|
|
|
|
+ if (tmplType.equals("MAIN")) {
|
|
|
|
+ TmplAssetCalculate tmpl = tmplAssetCalculateService.getCalculateTmplByCode(tmplCode);
|
|
|
|
+ String path = fileNetConfig.getBaseDir() + tmpl.getFileUrl() + tmpl.getFileName();
|
|
|
|
+ File file = new File(path);
|
|
|
|
+ FileNetUtil.writeFile2Response(request,response,file,tmpl.getFileName());
|
|
|
|
+ }else if (tmplType.equals("SECTION")){
|
|
|
|
+ TmplAssetCalculateSection tmpl = tmplAssetCalculateSectionService.getTmplByCode(tmplCode);
|
|
|
|
+ String path = fileNetConfig.getBaseDir() + tmpl.getSectionFileUrl() + tmpl.getSectionFileName();
|
|
|
|
+ File file = new File(path);
|
|
|
|
+ FileNetUtil.writeFile2Response(request,response,file,tmpl.getSectionFileName());
|
|
|
|
+ }else {
|
|
|
|
+ throw new BusinessException("无符合条件的模板,请联系管理员");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|