459242451@qq.com 3 years ago
parent
commit
6895ecd76c

+ 6 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhdd/IncidentController.java

@@ -134,21 +134,21 @@ public class IncidentController extends BaseController {
     public AjaxResult<Map<String, Object>> getInfo(@NotNull(message = "主键不能为空")
                                                    @PathVariable("id") String id) {
         Map<String, Object> map = new HashMap<>();
+        String fileUrl = "";
         IncidentVo incidentVo = iIncidentService.queryById(id);
         map.put("baseInfo", incidentVo);
         // 查询所属预案
         List<PlanVo> voOne = planService.listVo(Wrappers.<Plan>lambdaQuery().eq(Plan::getType, incidentVo.getType()).eq(Plan::getCreateDept, incidentVo.getCreateDept()));
         if (voOne != null && voOne.size() > 0) {
             map.put("baseTask", planTaskService.queryPlanTaskByPlanId(voOne.get(0).getId()));
+            // 查询预案附件
+            List<PlanFileVo> planFileVos = planFileService.listVo(Wrappers.<PlanFile>lambdaQuery().eq(PlanFile::getPlanId, voOne.get(0).getId()));
+            if (planFileVos != null && planFileVos.size() > 0) {
+                fileUrl = planFileVos.get(0).getFileUrl();
+            }
         } else {
             map.put("baseTask", null);
         }
-        // 查询预案附件
-        List<PlanFileVo> planFileVos = planFileService.listVo(Wrappers.<PlanFile>lambdaQuery().eq(PlanFile::getPlanId, voOne.get(0).getId()));
-        String fileUrl = "";
-        if (planFileVos != null && planFileVos.size() > 0) {
-            fileUrl = planFileVos.get(0).getFileUrl();
-        }
         map.put("planFile", fileUrl);
         // 查询处置方案
         map.put("task", incidentTaskService.listTaskInfo(id));

+ 16 - 10
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java

@@ -2,8 +2,10 @@ package com.ruoyi.framework.config;
 
 import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
 import org.springframework.web.filter.CorsFilter;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@@ -19,6 +21,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 public class ResourcesConfig implements WebMvcConfigurer {
     @Autowired
     private RepeatSubmitInterceptor repeatSubmitInterceptor;
+    @Value("${spring.profiles.active}")
+    private String env;
 
     @Override
     public void addResourceHandlers(ResourceHandlerRegistry registry) {
@@ -38,17 +42,19 @@ public class ResourcesConfig implements WebMvcConfigurer {
     @Bean
     public CorsFilter corsFilter() {
         UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
-        /*CorsConfiguration config = new CorsConfiguration();
-        config.setAllowCredentials(true);
-        // 设置访问源地址
-        config.addAllowedOrigin("*");
+        if ("dev".equals(env)) {
+            CorsConfiguration config = new CorsConfiguration();
+            config.setAllowCredentials(true);
+            // 设置访问源地址
+            config.addAllowedOrigin("*");
 //		config.addAllowedOriginPattern("*");
-        // 设置访问源请求头
-        config.addAllowedHeader("*");
-        // 设置访问源请求方法
-        config.addAllowedMethod("*");
-        // 对接口配置跨域设置
-        source.registerCorsConfiguration("/**", config);*/
+            // 设置访问源请求头
+            config.addAllowedHeader("*");
+            // 设置访问源请求方法
+            config.addAllowedMethod("*");
+            // 对接口配置跨域设置
+            source.registerCorsConfiguration("/**", config);
+        }
         return new CorsFilter(source);
     }