Sfoglia il codice sorgente

jar包中新增页面,可以被访问(前提是在ipfcst的WebSecurityConfig中配置放行,且用到的java类都在StarterAutoConfigure中配置自动装配)

zhangchenglong 2 anni fa
parent
commit
63e27ec91f

+ 5 - 0
pom.xml

@@ -89,6 +89,11 @@
             <artifactId>commons-io</artifactId>
             <version>2.6</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 16 - 0
src/main/java/com/syjy/calculate/config/StarterAutoConfigure.java

@@ -1,5 +1,7 @@
 package com.syjy.calculate.config;
 
+import com.syjy.calculate.conotroller.JarCalculate;
+import com.syjy.calculate.conotroller.Test;
 import com.syjy.calculate.listener.ApplicationListenerImpl;
 import com.syjy.calculate.repository.repositoryImpl.CalculationFormulaRepositoryImpl;
 import com.syjy.calculate.service.AccuracyPassRateCalculateService;
@@ -40,4 +42,18 @@ public class StarterAutoConfigure {
         return new CreateAndInsertSqlUtil();
     }
 
+    @Bean
+    @ConditionalOnMissingBean
+    @ConditionalOnProperty(prefix = "calculate.service", value = "enabled", havingValue = "true")
+    Test test (){
+        return new Test();
+    }
+
+    @Bean
+    @ConditionalOnMissingBean
+    @ConditionalOnProperty(prefix = "calculate.service", value = "enabled", havingValue = "true")
+    JarCalculate jarCalculate (){
+        return new JarCalculate();
+    }
+
 }

+ 15 - 0
src/main/java/com/syjy/calculate/conotroller/JarCalculate.java

@@ -0,0 +1,15 @@
+package com.syjy.calculate.conotroller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+public class JarCalculate {
+    @PostMapping("/jarCalculate/add")
+    @ResponseBody
+    public String test() {
+        String aa = "1112";
+        return aa;
+    }
+}

+ 7 - 6
src/main/java/com/syjy/calculate/conotroller/test.java → src/main/java/com/syjy/calculate/conotroller/Test.java

@@ -3,15 +3,15 @@ package com.syjy.calculate.conotroller;
 import com.alibaba.fastjson.JSONObject;
 import com.syjy.calculate.service.AccuracyPassRateCalculateService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
 import java.util.*;
 
-@RestController
+@Controller
 @RequestMapping("/test")
-public class test {
+public class Test {
     @Autowired
     private AccuracyPassRateCalculateService accuracyPassRateCalculateService;
 
@@ -21,7 +21,7 @@ public class test {
         List<Map<String, Object>> powerData = new ArrayList<>();
         Map<String, Object> dataText = new HashMap<>();
         dataText.put("sj", new BigDecimal(8));
-        dataText.put("yc", new BigDecimal(7));
+        dataText.put("yc", new BigDecimal(0));
         powerData.add(dataText);
         dataText = new HashMap<>();
         dataText.put("sj", new BigDecimal(9));
@@ -39,8 +39,8 @@ public class test {
         powerData.add(dataText);
 
         BigDecimal rl = new BigDecimal("10");
-        String provinceEnum = "E61";
-        String type = "PASS";
+        String provinceEnum = "E64";
+        String type = "POINT_S";
         // 计算
         JSONObject jsonResult = accuracyPassRateCalculateService.calculate(powerData, rl, provinceEnum, type, new BigDecimal("80"));
         // 计算结果
@@ -50,4 +50,5 @@ public class test {
             accuracy = jsonResult.getString("value");
         }
     }
+
 }

+ 30 - 0
src/main/resources/META-INF/resources/calculateView/calculate.html

@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>计算公式</title>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href="./css/bootstrap.css">
+    <script src="./js/jquery-3.6.0.min.js"></script>
+    <script src="./js/bootstrap.js"></script>
+</head>
+<body>
+    <div></div>
+</body>
+
+<script>
+    // 初始化
+    init();
+    // 初始化数据
+    function init() {
+        $.ajax({
+            type: "post",
+            url: "/jarCalculate/add",
+            success: function (data) {
+                console.log("add");
+            }
+        })
+    }
+
+</script>
+</html>