ly 5 сар өмнө
parent
commit
8561f35217

+ 9 - 0
pom.xml

@@ -333,6 +333,15 @@
             <artifactId>opencsv</artifactId>
             <version>3.8</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.PolarDB</groupId>
+            <artifactId>my-PolarDB-jar</artifactId>
+            <version>1.0.0</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/PolarDB-JDBC-42.5.4.0.10.5-jre8.jar</systemPath>
+        </dependency>
+
     </dependencies>
 
 

+ 47 - 43
src/main/java/io/renren/modules/common/AspenController.java

@@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
 import java.io.FileReader;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Date;
 @Component
 @Configuration      //1.主要用于标记配置类,兼备Component的效果。
@@ -34,12 +35,12 @@ public class AspenController extends AbstractController {
     @Autowired
     private TDailyProductionReportDao tDailyProductionReportDao;
 
-    @Scheduled(cron = "0 */1 * * * ?")
-//    @Scheduled(cron = "0 */15 * * * ?")
+//    @Scheduled(cron = "0 */1 * * * ?")
+    @Scheduled(cron = "0 */15 * * * ?")
     public void getExcelData(){
         logger.info("实时获取数据");
-        String csvFile = "D://ssyFile/wuliao.csv";
-//        String csvFile = "C://dashboardAspen/wuliao.csv";
+//        String csvFile = "D://ssyFile/wuliao.csv";
+        String csvFile = "C://dashboardAspen/wuliao.csv";
         TDashboarddataEntity dashboarddataEntity = new TDashboarddataEntity();
         CSVReader reader = null;
         try {
@@ -554,23 +555,23 @@ public class AspenController extends AbstractController {
                     .last("where REPORT_DATE = (select max(t2.REPORT_DATE) from t_daily_production_report t2)")
             );
             logger.info("TDailyProductionReport:" + JSON.toJSONString(report));
-            dashboarddataEntity.setNapOne(rounding0(report.getSctfStorageCltf1621()));
-            dashboarddataEntity.setNapTwo(rounding0(report.getSctfStorageCltf1622()));
-            dashboarddataEntity.setNapThree(rounding0(report.getSctfStorageCltf1623()));
-            dashboarddataEntity.setEhtOne(rounding0(report.getSctfStorageTk1061()));
-            dashboarddataEntity.setEhtTwo(rounding0(report.getSctfStorageTk1062()));
-            dashboarddataEntity.setEhtThree(rounding0(report.getSctfStorageTk1063()));
-            dashboarddataEntity.setEhtFour(rounding0(report.getSctfStorageTk1064()));
-            dashboarddataEntity.setEhtFive(rounding0(report.getSctfStorageTk1065Off()));
-            dashboarddataEntity.setAcrOne(rounding0(report.getSctfStorageTk1011()));
-            dashboarddataEntity.setAcrTwo(rounding0(report.getSctfStorageTk1012()));
-            dashboarddataEntity.setAcrThree(rounding0(report.getSctfStorageTk1013()));
-            dashboarddataEntity.setAcrFour(rounding0(report.getSctfStorageTk1014()));
-            dashboarddataEntity.setAcrZero(rounding0(report.getSctfStorageTk1040Off()));
-            dashboarddataEntity.setProTwo(rounding0(report.getSctfStorageTk1520Rpg()));
-            dashboarddataEntity.setProOne(rounding0(report.getSctfStorageTk1510B()));
-            dashboarddataEntity.setProThree(rounding0(report.getSctfStorageTk1360T()));
-            dashboarddataEntity.setProFour(rounding0(report.getSctfStorageTk1410X()));
+            dashboarddataEntity.setNapOne(rounding0(report.getSctfStorageCltf1621(), "33000" ));
+            dashboarddataEntity.setNapTwo(rounding0(report.getSctfStorageCltf1622(), "33000" ));
+            dashboarddataEntity.setNapThree(rounding0(report.getSctfStorageCltf1623(), "33000" ));
+            dashboarddataEntity.setEhtOne(rounding0(report.getSctfStorageTk1061(), "517" ));
+            dashboarddataEntity.setEhtTwo(rounding0(report.getSctfStorageTk1062(), "517" ));
+            dashboarddataEntity.setEhtThree(rounding0(report.getSctfStorageTk1063(), "517" ));
+            dashboarddataEntity.setEhtFour(rounding0(report.getSctfStorageTk1064(), "517" ));
+            dashboarddataEntity.setEhtFive(rounding0(report.getSctfStorageTk1065Off(), "517" ));
+            dashboarddataEntity.setAcrOne(rounding0(report.getSctfStorageTk1011(), "1200" ));
+            dashboarddataEntity.setAcrTwo(rounding0(report.getSctfStorageTk1012(), "1200" ));
+            dashboarddataEntity.setAcrThree(rounding0(report.getSctfStorageTk1013(), "1200" ));
+            dashboarddataEntity.setAcrFour(rounding0(report.getSctfStorageTk1014(), "1200" ));
+            dashboarddataEntity.setAcrZero(rounding0(report.getSctfStorageTk1040Off(), "1200" ));
+            dashboarddataEntity.setProTwo(rounding0(report.getSctfStorageTk1520Rpg(), "13500" ));
+            dashboarddataEntity.setProOne(rounding0(report.getSctfStorageTk1510B(), "3900" ));
+            dashboarddataEntity.setProThree(rounding0(report.getSctfStorageTk1360T(), "3800" ));
+            dashboarddataEntity.setProFour(rounding0(report.getSctfStorageTk1410X(), "1560" ));
 
             logger.info("dashboardData:" + dashboarddataEntity);
             tDashboarddataService.save(dashboarddataEntity);
@@ -589,23 +590,23 @@ public class AspenController extends AbstractController {
         TDashboarddataEntity data = tDashboarddataService.getOne( new QueryWrapper<TDashboarddataEntity>()
               .eq("id" , "811")
         );
-        data.setNapOne(rounding0(report.getSctfStorageCltf1621()));
-        data.setNapTwo(rounding0(report.getSctfStorageCltf1622()));
-        data.setNapThree(rounding0(report.getSctfStorageCltf1623()));
-        data.setEhtOne(rounding0(report.getSctfStorageTk1061()));
-        data.setEhtTwo(rounding0(report.getSctfStorageTk1062()));
-        data.setEhtThree(rounding0(report.getSctfStorageTk1063()));
-        data.setEhtFour(rounding0(report.getSctfStorageTk1064()));
-        data.setEhtFive(rounding0(report.getSctfStorageTk1065Off()));
-        data.setAcrOne(rounding0(report.getSctfStorageTk1011()));
-        data.setAcrTwo(rounding0(report.getSctfStorageTk1012()));
-        data.setAcrThree(rounding0(report.getSctfStorageTk1013()));
-        data.setAcrFour(rounding0(report.getSctfStorageTk1014()));
-        data.setAcrZero(rounding0(report.getSctfStorageTk1040Off()));
-        data.setProTwo(rounding0(report.getSctfStorageTk1520Rpg()));
-        data.setProOne(rounding0(report.getSctfStorageTk1510B()));
-        data.setProThree(rounding0(report.getSctfStorageTk1360T()));
-        data.setProFour(rounding0(report.getSctfStorageTk1410X()));
+        data.setNapOne(rounding0(report.getSctfStorageCltf1621(), "33000" ));
+        data.setNapTwo(rounding0(report.getSctfStorageCltf1622(), "33000" ));
+        data.setNapThree(rounding0(report.getSctfStorageCltf1623(), "33000" ));
+        data.setEhtOne(rounding0(report.getSctfStorageTk1061(), "517" ));
+        data.setEhtTwo(rounding0(report.getSctfStorageTk1062(), "517" ));
+        data.setEhtThree(rounding0(report.getSctfStorageTk1063(), "517" ));
+        data.setEhtFour(rounding0(report.getSctfStorageTk1064(), "517" ));
+        data.setEhtFive(rounding0(report.getSctfStorageTk1065Off(), "517" ));
+        data.setAcrOne(rounding0(report.getSctfStorageTk1011(), "1200" ));
+        data.setAcrTwo(rounding0(report.getSctfStorageTk1012(), "1200" ));
+        data.setAcrThree(rounding0(report.getSctfStorageTk1013(), "1200" ));
+        data.setAcrFour(rounding0(report.getSctfStorageTk1014(), "1200" ));
+        data.setAcrZero(rounding0(report.getSctfStorageTk1040Off(), "1200" ));
+        data.setProTwo(rounding0(report.getSctfStorageTk1520Rpg(), "13500" ));
+        data.setProOne(rounding0(report.getSctfStorageTk1510B(), "3900" ));
+        data.setProThree(rounding0(report.getSctfStorageTk1360T(), "3800" ));
+        data.setProFour(rounding0(report.getSctfStorageTk1410X(), "1560" ));
         tDashboarddataService.saveOrUpdate(data);
     }
 
@@ -636,22 +637,25 @@ public class AspenController extends AbstractController {
             return "0.0";
         }
     };
-    public String rounding0(String lineNum) {
+    public String rounding0(String lineNum , String allNum) {
         try {
             logger.info("读数:" + lineNum);
+            lineNum =  new BigDecimal(lineNum).divide(new BigDecimal(allNum),4, RoundingMode.CEILING).multiply(new BigDecimal("100")).toString();
             if (lineNum.equals("")) {
                 lineNum = "0.0";
             }else {
                 if (!Character.isDigit(lineNum.charAt(0))) {
                     if ("-".equals(lineNum.substring(0,1))){
-                        int b = new BigDecimal(Double.parseDouble(lineNum)).intValue();
-                        lineNum = String.valueOf(b);
+                        BigDecimal b = new BigDecimal(Double.parseDouble(lineNum));
+                        double f = b.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
+                        lineNum = String.valueOf(f);
                     }else {
                         lineNum = "0.0";
                     }
                 }else {
-                    int b = new BigDecimal(Double.parseDouble(lineNum)).intValue();
-                    lineNum = String.valueOf(b);
+                    BigDecimal b = new BigDecimal(Double.parseDouble(lineNum));
+                    double f = b.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
+                    lineNum = String.valueOf(f);
                 }
             }
             logger.info(lineNum);

+ 6 - 6
src/main/resources/application-dev.yml

@@ -7,12 +7,12 @@ spring:
       #            username: ENC(Jnap8dU25YV9cE1pJKpISg==)
       #            password: ENC(tjXpQ4vKnTCS/zeRsZdx6oTxW36qkJt9)
 #      driver-class-name: oracle.jdbc.OracleDriver
-      url: jdbc:oracle:thin:@47.114.101.16:1521:XE
-      username: newcpms
-      password: ssy666666
-#      url: jdbc:oracle:thin:@10.138.6.6:1521:moct
-#      username: NEWCPMS
-#      password: pw4Test!
+#      url: jdbc:oracle:thin:@47.114.101.16:1521:XE
+#      username: newcpms
+#      password: ssy666666
+      url: jdbc:oracle:thin:@10.138.6.6:1521:moct
+      username: NEWCPMS
+      password: pw4Test!
       initial-size: 10
       max-active: 100
       min-idle: 10

+ 5 - 5
src/main/resources/application-prod.yml

@@ -2,10 +2,10 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     druid:
-      driver-class-name: oracle.jdbc.OracleDriver
-      url: jdbc:oracle:thin:@47.114.101.16:1521:XE
-      username: ENC(csIyCwnADKqFxJFT6iDeyQ==)
-      password: ENC(cldkI35IaILWyefSIil69FSSSrBBOj+u)
+      driver-class-name: com.aliyun.polardb2.Driver
+      url: jdbc:polardb://pc-uf6ct70s42z69z7o6.rwlb.rds.aliyuncs.com:1521/cpms_prod?boolAsInt=true
+      username: cpms_app
+      password: ANd7rBK7HgnX
       initial-size: 10
       max-active: 100
       min-idle: 10
@@ -37,4 +37,4 @@ logging:
   level:
     root: info
   file:
-    name: logs/app.log
+    name: logs/app.log

BIN
src/main/resources/lib/PolarDB-JDBC-42.5.4.0.10.5-jre8.jar