Explorar o código

1.新增通用的资产业务测算表模板下载接口

GouGengquan hai 3 meses
pai
achega
ed36fe8a5b

+ 24 - 7
biz-base/src/main/java/com/dayou/controller/FileController.java

@@ -2,10 +2,13 @@ package com.dayou.controller;
 
 import cn.hutool.core.lang.UUID;
 import com.dayou.config.FileNetConfig;
+import com.dayou.entity.TmplAssetCalculate;
 import com.dayou.entity.TmplAssetCalculateSection;
+import com.dayou.exception.BusinessException;
 import com.dayou.result.Result;
 import com.dayou.result.Status;
 import com.dayou.service.TmplAssetCalculateSectionService;
+import com.dayou.service.TmplAssetCalculateService;
 import com.dayou.utils.FileNetUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +32,9 @@ import static com.dayou.enums.EqptCalculateTmplCode.MAIN_DETAIL;
 public class FileController {
 
     @Autowired
+    private TmplAssetCalculateService tmplAssetCalculateService;
+
+    @Autowired
     private TmplAssetCalculateSectionService tmplAssetCalculateSectionService;
 
     @Autowired
@@ -123,17 +129,28 @@ public class FileController {
     }
 
     /**
-     * 下载资产机器设备测算表段落模板
+     * 下载资产业务测算表模板
      * @param request
      * @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("无符合条件的模板,请联系管理员");
+        }
     }
 
 }

+ 1 - 1
domain/src/main/java/com/dayou/entity/UserPost.java

@@ -23,7 +23,7 @@ public class UserPost extends BaseEntity implements Serializable {
     private static final long serialVersionUID=1L;
 
     /**
-     * 用户OA id
+     * 用户id
      */
     private Long userId;
 

+ 29 - 0
domain/src/main/java/com/dayou/enums/CRCalculateTmplCode.java

@@ -0,0 +1,29 @@
+package com.dayou.enums;
+
+public enum CRCalculateTmplCode {
+
+    ANALYSIS_MAIN("ANALYSIS_MAIN", "债权分析测算表模板"),;
+
+    private String code;
+
+    private String name;
+
+    CRCalculateTmplCode(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String toString() {
+        return name + ":" + code;
+    }
+
+}

+ 9 - 0
service/src/main/java/com/dayou/service/TmplAssetCalculateService.java

@@ -5,6 +5,7 @@ import com.dayou.entity.TmplAssetCalculate;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dayou.vo.TmplAssetCalculateDetailVO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -35,4 +36,12 @@ public interface TmplAssetCalculateService extends IService<TmplAssetCalculate>
      */
     List<DropDownBoxData> getDropDownBoxData();
 
+
+    /**
+     * 根据测算表模板code获取模板信息
+     * @param tmplCode 模板code
+     * @return TmplAssetCalculate
+     */
+    TmplAssetCalculate getCalculateTmplByCode(String tmplCode);
+
 }

+ 10 - 0
service/src/main/java/com/dayou/service/impl/TmplAssetCalculateServiceImpl.java

@@ -76,4 +76,14 @@ public class TmplAssetCalculateServiceImpl extends ServiceImpl<TmplAssetCalculat
     public List<DropDownBoxData> getDropDownBoxData() {
         return tmplAssetCalculateMapper.getDropDownBoxData();
     }
+
+    /**
+     * 根据测算表模板code获取模板信息
+     * @param tmplCode 模板code
+     * @return TmplAssetCalculate
+     */
+    @Override
+    public TmplAssetCalculate getCalculateTmplByCode(String tmplCode) {
+        return tmplAssetCalculateMapper.getCalculateTmplByCode(tmplCode);
+    }
 }