Jelajahi Sumber

新增准确率接口

zhangchenglong 1 tahun lalu
induk
melakukan
df89723011

+ 3 - 2
pom.xml

@@ -10,8 +10,8 @@
     </parent>
     <groupId>com.syjy</groupId>
     <artifactId>calculation-spring-boot-starter</artifactId>
-    <version>0.0.18</version>
-    <!--<version>0.0.18-SNAPSHOT</version>-->
+    <version>0.0.19</version>
+    <!--<version>0.0.19-SNAPSHOT</version>-->
     <name>calculation</name>
     <description>Demo project for Spring Boot</description>
     <properties>
@@ -146,6 +146,7 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <!--独立打包作为服务和对外接口时候需要注释掉-->
                 <configuration>
                     <skip>true</skip>
                     <mainClass>com.syjy.calculate.CalculationApplication</mainClass>

+ 4 - 0
src/main/java/com/syjy/calculate/entity/CalculateResult.java

@@ -147,6 +147,8 @@ public class CalculateResult extends HashMap<String, Object> {
     public static final String MSG_DB_FAIL = "计算包所用数据库类型不存在或未在配置文件中配置:";
 
     public static final String MSG_CALCULATE_FAIL = "计算失败:";
+    public static final String MSG_AUTHORIZATION_ERROR = "验证信息失败,账号或密码错误";
+    public static final String MSG_USERINFO_ERROR = "数据库中未查到用户信息";
     public static final String MSG_CAP_ZERO = "容量为0";
     public static final String MSG_SIZE_ZERO = "个数为0";
     public static final String STR_TRUE = "1";
@@ -155,6 +157,8 @@ public class CalculateResult extends HashMap<String, Object> {
     public static final String DB_ERROR_TABLE_EXIST = "java.sql.SQLException: [KingbaseES Server]ERROR: relation \"t_calculation_formula\" does not exist";
     public static final String DB_MYSQL = "mysql";
     public static final String DB_KINGBASE = "kingbase";
+    // 授权信息
+    public static final String AUTHORIZATION = "Authorization";
 
 
     /**

+ 9 - 0
src/main/java/com/syjy/calculate/repository/CalculationFormulaRepository.java

@@ -77,5 +77,14 @@ public interface CalculationFormulaRepository {
      */
     List<CalculationInfo> getCalculationInfo();
 
+    /**
+     * 查询接口用户数据
+     *
+     * @return 返回记录
+     */
+    List<CalculationFormula> getUser();
+
+
+
 
 }

+ 15 - 0
src/main/java/com/syjy/calculate/repository/repositoryImpl/CalculationFormulaRepositoryImpl.java

@@ -427,6 +427,21 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
     }
 
     /**
+     * 获取用户密码
+     */
+    @Override
+    public List<CalculationFormula> getUser() {
+        String sql = " SELECT * FROM t_calculation_formula where type = 'USER' ";
+        List<CalculationFormula> list = new ArrayList<>();
+        try {
+            list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(CalculationFormula.class));
+            return list;
+        } catch (EmptyResultDataAccessException ere) {
+            return null;
+        }
+    }
+
+    /**
      * 更新版本
      */
     private void updateVersion() {

+ 28 - 0
src/main/java/com/syjy/calculate/util/Common.java

@@ -1,10 +1,12 @@
 package com.syjy.calculate.util;
 
+import cn.hutool.core.codec.Base64;
 import com.googlecode.aviator.AviatorEvaluator;
 import com.syjy.calculate.entity.CalculateResult;
 import org.springframework.cglib.beans.BeanMap;
 import org.springframework.stereotype.Component;
 
+import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -52,6 +54,32 @@ public class Common {
         return env;
     }
 
+    public static String getBase64Encode(String str) {
+        if (str == null || "".equals(str)) {
+            return "";
+        }
+        try {
+            byte[] bt = str.getBytes("UTF-8");
+            str = String.valueOf(Base64.encode(bt));
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return str;
+    }
+
+    public static String getBase64Decode(String str) {
+        if (str == null || "".equals(str)) {
+            return "";
+        }
+        char[] ch = str.toCharArray();
+        byte[] bt = Base64.decode(String.valueOf(ch));
+        try {
+            str = new String(bt,"UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return str;
+    }
 
 
 }

+ 4 - 1
src/main/resources/application.yml

@@ -10,11 +10,14 @@ spring:
       url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
       driver-class-name: com.mysql.cj.jdbc.Driver
 
-##      金仓数据库
+#      金仓数据库
 #      username: SYSTEM
 #      password: 123456
 #      url: jdbc:kingbase://192.168.1.204:54321/ipfcstV3
 #      driver-class-name: com.kingbase.Driver
 
+#logging:
+#  file:
+#    name: ./logs/calculate.log
 
 version: @project.version@

+ 1 - 0
src/main/resources/sql/t_calculation_formula.sql

@@ -676,5 +676,6 @@ INSERT INTO `t_calculation_formula` VALUES (679, 'ASSESSMENT_ULTRA_SHORT_ACCURAC
 INSERT INTO `t_calculation_formula` VALUES (680, 'RULES', 1, '	let m = seq.map(\"code\", \"500\", \"msg\", \"校验不通过\", \"data\", \"0.00%\");\r\n	if (shortAccuracyRate == nil) {\r\n      m.code = \"500\";\r\n      m.msg = \"短期准确率为空\";\r\n      return m;\r\n    }\r\n	if (ratedCapacity == nil) {\r\n      m.code = \"500\";\r\n      m.msg = \"额定容量量为空\";\r\n      return m;\r\n    }\r\n    m.code = \"200\";\r\n    m.msg = \"校验通过\";\r\n    return m;', 'E36', 'E1;E2', 'ALL', 'ASSESSMENT_SHORT_ACCURACY_RATE', '0', '1', NULL, NULL, NULL, NULL, NULL, NULL);
 INSERT INTO `t_calculation_formula` VALUES (681, 'RULES', 1, '	let m = seq.map(\"code\", \"500\", \"msg\", \"校验不通过\", \"data\", \"0.00%\");\r\n	if (ultraShortAccuracyRate == nil) {\r\n      m.code = \"500\";\r\n      m.msg = \"超短期准确率为空\";\r\n      return m;\r\n    }\r\n	if (ratedCapacity == nil) {\r\n      m.code = \"500\";\r\n      m.msg = \"额定容量为空\";\r\n      return m;\r\n    }\r\n    m.code = \"200\";\r\n    m.msg = \"校验通过\";\r\n    return m;', 'E36', 'E1;E2', 'ALL', 'ASSESSMENT_ULTRA_SHORT_ACCURACY_RATE', '0', '1', NULL, NULL, NULL, NULL, NULL, NULL);
 INSERT INTO `t_calculation_formula` VALUES (682, 'ASSESSMENT_ULTRA_SHORT_ACCURACY_RATE', 1, 'if(ultraShortReportRate>=0.9){\r\n  return 0;\r\n}\r\nreturn (0.9-ultraShortReportRate)*ratedCapacity*0.1*1;', 'E36', 'E2', 'ALL', NULL, '0', '1', NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `t_calculation_formula` VALUES (683, 'USER', 1, 'user:123456', 'E99', 'E1;E2', NULL, NULL, '0', '1', NULL, NULL, NULL, NULL, NULL, NULL);
 
 SET FOREIGN_KEY_CHECKS = 1;