lyhzzz 1 рік тому
батько
коміт
54a43455ee

+ 1 - 0
src/main/java/com/fdkankan/manage/service/impl/RtkAccountServiceImpl.java

@@ -72,6 +72,7 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
         LambdaQueryWrapper<RtkAccount> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(RtkAccount::getStatus,0,1);
         wrapper.orderByAsc(RtkAccount::getUpdateTime);
+        wrapper.orderByAsc(RtkAccount::getId);
         List<RtkAccount> list = this.list(wrapper);
         if(list == null || list.isEmpty()){
             //账号库存不足,钉钉通知

+ 18 - 2
src/main/java/com/fdkankan/manage/task/DingdingService.java

@@ -4,6 +4,8 @@ import com.fdkankan.dingtalk.DingTalkSendUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -11,6 +13,7 @@ import java.math.RoundingMode;
 
 @Service
 @Slf4j
+@RefreshScope
 public class DingdingService {
 
     @Autowired
@@ -24,7 +27,7 @@ public class DingdingService {
 
     @Value("${main.url}")
     String mainUrl;
-    @Value("${dingtalk.threshold:80}")
+    @Value("${dingtalk.threshold:0.8}")
     String threshold;
 
     public void sendDingDingMsg(Integer count){
@@ -46,7 +49,7 @@ public class DingdingService {
             BigDecimal dbCount = new BigDecimal(size);
 
             BigDecimal divideCount = dbCount.divide(totalCount,2,RoundingMode.HALF_DOWN);
-            BigDecimal thresholdCount = new BigDecimal(this.threshold);
+            BigDecimal thresholdCount = new BigDecimal(this.threshold).setScale(2,RoundingMode.HALF_DOWN);
             if(divideCount.compareTo(thresholdCount) >= 0 ){
                 this.sendDingDingMsg(size);
             }
@@ -55,4 +58,17 @@ public class DingdingService {
         }
 
     }
+
+    public static void main(String[] args) {
+        BigDecimal totalCount = new BigDecimal(5);
+        BigDecimal dbCount = new BigDecimal(4);
+
+        BigDecimal divideCount = dbCount.divide(totalCount,2,RoundingMode.HALF_DOWN);
+        System.out.println(divideCount);
+        BigDecimal thresholdCount = new BigDecimal(0.8).setScale(2,RoundingMode.HALF_DOWN);
+        System.out.println(thresholdCount);
+        if(divideCount.compareTo(thresholdCount) >= 0 ){
+            System.out.println(1);
+        }
+    }
 }

+ 1 - 1
src/main/java/com/fdkankan/manage/task/TaskService.java

@@ -85,7 +85,7 @@ public class TaskService {
             dingdingService.sendDingDingMsg(0);
             return;
         }
-        dingdingService.modelThreshold(list.size() -1,rtkAccountService.count());
+        dingdingService.modelThreshold(list.size(),rtkAccountService.count());
     }