|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|