From fd0ffe0a4cd11540a32b57e7f479db407ecb56a1 Mon Sep 17 00:00:00 2001 From: zhangyongzhangyong <2012005003@qq.coom> Date: Mon, 14 Sep 2020 10:02:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8C=87=E6=95=B0=20-=20=E5=B9=B4=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E8=AE=A1=E7=AE=97=EF=BC=8C=E4=B9=98=E4=BB=A5=E6=9D=83?= =?UTF-8?q?=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../evaluationindex/screen/ScreenIndexDataMonthlyDao.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml index b699ec7d6b..f192c1373c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml @@ -71,9 +71,9 @@ PARENT_ID parentId, ORG_NAME orgName, SUM(INDEX_TOTAL) / #{monthCount} as indexTotal, - SUM(PARTY_DEV_ABLITY) / #{monthCount} as partyDevAblity, - SUM(SERVICE_ABLITY) / #{monthCount} as serviceAblity, - SUM(GOVERN_ABLITY) / #{monthCount} as governAblity + SUM(PARTY_DEV_ABLITY * PARTY_DEV_WEIGHT) / #{monthCount} as partyDevAblity, + SUM(SERVICE_ABLITY * SERVICE_ABLITY_WEIGHT) / #{monthCount} as serviceAblity, + SUM(GOVERN_ABLITY * GOVERN_ABLITY_WEIGHT) / #{monthCount} as governAblity FROM screen_index_data_monthly WHERE DEL_FLAG = '0' AND YEAR_ID = #{yearId} From 8f507bbd3551b40325d91ec0b6ab5187437d3637 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 14 Sep 2020 10:24:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=BD=92=E4=B8=80?= =?UTF-8?q?=E7=AE=97=E6=B3=95=20=E8=BF=94=E5=9B=9E=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/enums/EnvEnum.java | 1 + .../controller/IndexCalculateController.java | 8 ++-- .../batch/BatchScoreCalculator.java | 39 +------------------ .../stats/test/normalizing/DemoScoreCal.java | 9 +++++ 4 files changed, 15 insertions(+), 42 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java index 0c3f798318..ed782790e8 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java @@ -11,6 +11,7 @@ import org.springframework.core.env.Environment; * @date 2020-07-03 11:14 **/ public enum EnvEnum { + LOCAL("local", "本地环境"), DEV("dev", "开发环境"), TEST("test", "体验环境"), PROD("prod", "生产环境"), diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java index 4cecf7f168..b7499bd76f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java @@ -2,6 +2,7 @@ package com.epmet.controller; import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth; import com.epmet.commons.extappauth.bean.ExternalAppRequestParam; +import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; @@ -24,10 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -186,7 +184,7 @@ public class IndexCalculateController { future.cancel(true); redisUtils.delete(RedisKeys.getCustomerStatsCalFlag(customerId)); futureMap.remove(customerId); - HttpClientManager.getInstance().sendAlarmMsg(String.format("数据统计服务-中止计算成功,customerId:%s", customerId)); + HttpClientManager.getInstance().sendAlarmMsg(String.format(EnvEnum.getCurrentEnv().getName() + "数据统计服务-中止计算成功,customerId:%s", customerId)); } return new Result(); } @@ -195,7 +193,7 @@ public class IndexCalculateController { public Result calculateAll(@RequestBody CalculateCommonFormDTO formDTO) { long start = System.currentTimeMillis(); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); - HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + formDTO.getCustomerId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); + HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); if (aBoolean) { return new Result().ok(true); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index b0ee8fa0ad..1e049b17c7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java @@ -57,8 +57,8 @@ public class BatchScoreCalculator { for (SampleValue vo : indexValueVOs) { String sampleId = vo.getSampleId(); //归一后的值 - BigDecimal normalizeValue = getFinalSampleValue(vo.getSampleValue(), threshold); - BigDecimal score = scoreCalculator.normalize(normalizeValue, weight).setScale(6, RoundingMode.HALF_UP); + BigDecimal normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold)); + BigDecimal score = normalizeValue.multiply(weight).setScale(6, RoundingMode.HALF_UP); CalculateResult result = scoreCountOfSamples.get(sampleId); if (result == null) { @@ -78,40 +78,6 @@ public class BatchScoreCalculator { return scoreCountOfSamples; } - /** - * 执行计算,以样本的所有指标总得分 - * - * @param indexInputVOS - * @return - */ - public HashMap getScoreCountOfSampleId(List indexInputVOS) { - - // 每个样本的总得分 - HashMap scoreCountOfSamples = new HashMap<>(); - - for (IndexInputVO idx : indexInputVOS) { - // 每个指标循环一次 - List indexValueVOs = idx.getIndexValueVOs(); - BigDecimal weight = idx.getWeight(); - ScoreCalculator scoreCalculator = idx.getScoreCalculator(); - BigDecimal threshold = idx.getThreshold(); - - for (SampleValue vo : indexValueVOs) { - String sampleId = vo.getSampleId(); - BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight); - if (scoreCountOfSamples.containsKey(sampleId)) { - BigDecimal newScore = scoreCountOfSamples.get(sampleId).add(score).setScale(6, RoundingMode.HALF_UP); - scoreCountOfSamples.put(sampleId, newScore); - } else { - score.setScale(6, RoundingMode.HALF_UP); - scoreCountOfSamples.put(sampleId, score); - } - } - } - - return scoreCountOfSamples; - } - /** * 获取最终样本值 * @@ -128,5 +94,4 @@ public class BatchScoreCalculator { return (bdRealValue.compareTo(threshold) < 0) || (bdRealValue.equals(threshold)) ? bdRealValue : threshold; - } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java index 15e029b3e6..37b70e5297 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java +++ b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java @@ -172,11 +172,20 @@ public class DemoScoreCal { BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); HashMap result = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + HashMap result2 = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); + System.err.println("----------------1----------------"); result.forEach((key, value) -> { System.out.println(key.concat("的得分为:").concat(value.toString())); }); System.err.println("-----------------2---------------"); + + + System.err.println("----------------123123123123----------------"); + result2.forEach((key, value) -> { + System.out.println(key.concat("的得分为:").concat(value.toString())); + }); + System.err.println("-----------------2---------------"); } From 174358f68f6e952a1e4107e6b3dab95541a318b7 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 14 Sep 2020 10:25:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=BD=92=E4=B8=80?= =?UTF-8?q?=E7=AE=97=E6=B3=95=20=E8=BF=94=E5=9B=9E=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/support/normalizing/batch/BatchScoreCalculator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index 1e049b17c7..c439df6213 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java @@ -94,4 +94,5 @@ public class BatchScoreCalculator { return (bdRealValue.compareTo(threshold) < 0) || (bdRealValue.equals(threshold)) ? bdRealValue : threshold; + } }