From bf214698a65a9a076d3bc822591f54b09a6a1532 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 15 Oct 2020 15:01:27 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=8F=8D=E6=AD=A3=E5=88=87=E5=87=BD?= =?UTF-8?q?=E6=95=B0=20=E5=85=BC=E5=AE=B9=E6=AD=A3=E8=B4=9F=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/normalizing/batch/BatchScoreCalculator.java | 7 ++++++- .../com/epmet/stats/test/normalizing/MathUtilTest.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) 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 75e78ea215..b4f2fd4677 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 @@ -1,5 +1,6 @@ package com.epmet.support.normalizing.batch; +import com.epmet.support.normalizing.Correlation; import com.epmet.support.normalizing.ScoreCalculator; import java.math.BigDecimal; @@ -70,9 +71,13 @@ public class BatchScoreCalculator { if (maxValue.compareTo(minValue) == 0) { //*((max-min)/ (Math.PI/2))+min //Math.atan(new Double(vo.getSampleValue().toString()))* - normalizeValue = new BigDecimal(Math.atan(new Double(vo.getSampleValue().toString()))) + normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString()))) .multiply( (maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.UNNECESSARY))).add(minValue).setScale(6, RoundingMode.HALF_UP); + // + if (scoreCalculator.getCorrelation().getCode().equals(Correlation.NEGATIVE)) { + normalizeValue = maxValue.subtract(normalizeValue); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java index ff0811d4c5..408f837691 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java +++ b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java @@ -20,7 +20,7 @@ public class MathUtilTest { BigDecimal maxValue = new BigDecimal(100); BigDecimal minValue = new BigDecimal(60); - BigDecimal normalizeValue = new BigDecimal(Math.atan(new Double("4"))) + BigDecimal normalizeValue = new BigDecimal(Math.atan(new Double("0"))) .multiply( (maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP))).add(minValue).setScale(6, RoundingMode.HALF_UP); System.out.println(normalizeValue); From ed696007e1cda61b4510cce83e8fd73d01cfbb58 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 15 Oct 2020 17:48:19 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8E=92=E9=99=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extract/todata/impl/FactOriginExtractServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java index ec8269c8a6..f8bfe1826c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java @@ -70,7 +70,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { param.setDateId(extractOriginFormDTO.getDateId()); param.setStartDate(extractOriginFormDTO.getStartDate()); param.setEndDate(extractOriginFormDTO.getEndDate()); - log.debug("extractAll param:{}", JSON.toJSONString(param)); + log.info("extractAll param:{}", JSON.toJSONString(param)); submitJob(param); }); From 6e80fe73665901ae2356b170070d3f563fd5703a Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 15 Oct 2020 17:59:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8E=92=E9=99=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extract/todata/impl/FactOriginExtractServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java index f8bfe1826c..9413b13209 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java @@ -27,7 +27,7 @@ import java.util.concurrent.*; public class FactOriginExtractServiceImpl implements FactOriginExtractService { ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() .setNameFormat("factOriginExtract-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(1, 1, + ExecutorService threadPool = new ThreadPoolExecutor(3, 6, 10L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @@ -98,6 +98,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { } }); threadPool.submit(() -> { + log.info("extractAll start param:{}", JSON.toJSONString(param)); if(StringUtils.isNotBlank(param.getDateId())){ try { factOriginTopicMainDailyService.topicCleaning(param); @@ -110,12 +111,14 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { for (int i = 0; i < daysBetween.size(); i++) { String dateDimId = daysBetween.get(i); param.setDateId(dateDimId); + log.info("extractAll cal param:{}", JSON.toJSONString(param)); factOriginTopicMainDailyService.topicCleaning(param); } } catch (Exception e) { log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(param), e); } } + log.info("extractAll end param:{}", JSON.toJSONString(param)); }); threadPool.submit(() -> { if(StringUtils.isNotBlank(param.getDateId())){ From ea86976da2b6057325a543a35e0e8f37d5e5deec Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 16 Oct 2020 09:11:02 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8A=9B=E5=87=BA=20?= =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcoll/impl/FactIndexCollectServiceImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java index 5b7d0fd8a6..8be277cd47 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java @@ -348,7 +348,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { } } if ("".equals(parentAgencyId)){ - throw new RuntimeException("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey()); + log.error("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey()); + continue; } // 补充表中其他字段 monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(), @@ -480,8 +481,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { agencyName = agencyScoreDTO.getAgencyName(); } } - if ("".equals(agencyName)){ - throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey()); + if ("".equals(agencyName)) { + log.error("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey()); + continue; } // 补充表中其他字段 monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(), From b2f0e7a34fa0314c72533729376d6c2dedd1a2bc Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 16 Oct 2020 11:59:14 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9origin=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8A=BD=E5=8F=96=20=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/controller/IndexDictController.java | 2 +- .../impl/FactOriginExtractServiceImpl.java | 155 +++++++++++------- 2 files changed, 94 insertions(+), 63 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java index 6a24b3e98b..0764389e78 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java @@ -44,7 +44,7 @@ public class IndexDictController { * @return */ @PostMapping("initFromExcel") - public Result testTx(@RequestPart("file") MultipartFile file,@RequestParam("customerId") String customerId) { + public Result testTx(@RequestPart("file") MultipartFile file, @RequestParam(value = "customerId", required = false) String customerId) { ExcelReader excelReader = null; try { InputStream inputStream = null; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java index 9413b13209..72e39aecbf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java @@ -2,9 +2,12 @@ package com.epmet.service.evaluationindex.extract.todata.impl; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.dto.extract.form.ExtractOriginFormDTO; +import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.service.evaluationindex.extract.todata.*; +import com.epmet.service.stats.DimCustomerPartymemberService; import com.epmet.service.stats.DimCustomerService; import com.epmet.util.DimIdGenerator; import com.google.common.util.concurrent.ThreadFactoryBuilder; @@ -41,12 +44,14 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { private DimCustomerService dimCustomerService; @Autowired private GroupExtractService groupExtractService; + @Autowired + private DimCustomerPartymemberService dimCustomerPartymemberService; @Override public void extractAll(ExtractOriginFormDTO extractOriginFormDTO) { String customerId = extractOriginFormDTO.getCustomerId(); - if (StringUtils.isBlank(extractOriginFormDTO.getStartDate())||StringUtils.isBlank(extractOriginFormDTO.getEndDate())) { + if (StringUtils.isBlank(extractOriginFormDTO.getDateId()) && (StringUtils.isBlank(extractOriginFormDTO.getStartDate()) && StringUtils.isBlank(extractOriginFormDTO.getEndDate()))) { //如果没有设置开始日期、结束日期,默认查询昨天 extractOriginFormDTO.setDateId(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1))); } @@ -77,116 +82,142 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { } private void submitJob(ExtractOriginFormDTO param) { + boolean isRange = StringUtils.isBlank(param.getDateId()) ? true : false; + List daysBetween = null; + if (isRange) { + daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); + } + List finalDaysBetween = daysBetween; + threadPool.submit(() -> { + CustomerIdAndDateIdFormDTO formDTO = new CustomerIdAndDateIdFormDTO(); + formDTO.setCustomerId(param.getCustomerId()); + if (!isRange) { + try { + formDTO.setDateId(param.getDateId()); + dimCustomerPartymemberService.statsPartyMember(formDTO); + } catch (Exception e) { + log.error("抽取【党员数据】发生异常,参数:" + JSON.toJSONString(formDTO), e); + } + } else { + try { + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + formDTO.setDateId(dateDimId); + dimCustomerPartymemberService.statsPartyMember(formDTO); + } + } catch (Exception e) { + log.error("抽取【党员数据】发生异常,参数:" + JSON.toJSONString(param), e); + } + } + }); threadPool.submit(() -> { - if(StringUtils.isNotBlank(param.getDateId())){ + ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); + if (!isRange) { try { - groupExtractService.extractGroupData(param); + groupExtractService.extractGroupData(paramNew); } catch (Exception e) { - log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } - }else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){ - try{ - List daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); - for (int i = 0; i < daysBetween.size(); i++) { - String dateDimId = daysBetween.get(i); - param.setDateId(dateDimId); - groupExtractService.extractGroupData(param); + } else { + try { + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + paramNew.setDateId(dateDimId); + groupExtractService.extractGroupData(paramNew); } - }catch(Exception e){ - log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(param), e); + } catch (Exception e) { + log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } } }); threadPool.submit(() -> { - log.info("extractAll start param:{}", JSON.toJSONString(param)); - if(StringUtils.isNotBlank(param.getDateId())){ + log.debug("extractAll start param:{}", JSON.toJSONString(param)); + ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); + if (!isRange) { try { - factOriginTopicMainDailyService.topicCleaning(param); + factOriginTopicMainDailyService.topicCleaning(paramNew); } catch (Exception e) { - log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } - }else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){ + } else { try { - List daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); - for (int i = 0; i < daysBetween.size(); i++) { - String dateDimId = daysBetween.get(i); - param.setDateId(dateDimId); - log.info("extractAll cal param:{}", JSON.toJSONString(param)); - factOriginTopicMainDailyService.topicCleaning(param); + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + paramNew.setDateId(dateDimId); + log.info("extractAll cal param:{}", JSON.toJSONString(paramNew)); + factOriginTopicMainDailyService.topicCleaning(paramNew); } } catch (Exception e) { - log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } } - log.info("extractAll end param:{}", JSON.toJSONString(param)); + log.info("extractAll end param:{}", JSON.toJSONString(paramNew)); }); threadPool.submit(() -> { - if(StringUtils.isNotBlank(param.getDateId())){ + ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); + if (!isRange) { try { - issueExtractService.issueExtractMain(param); + issueExtractService.issueExtractMain(paramNew); } catch (Exception e) { - log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(paramNew), e); } try { - issueExtractService.issueExtractLog(param); + issueExtractService.issueExtractLog(paramNew); } catch (Exception e) { - log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(paramNew), e); } - }else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){ + } else { try { - List daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); - for (int i = 0; i < daysBetween.size(); i++) { - String dateDimId = daysBetween.get(i); - param.setDateId(dateDimId); - issueExtractService.issueExtractMain(param); + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + paramNew.setDateId(dateDimId); + issueExtractService.issueExtractMain(paramNew); } } catch (Exception e) { - log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(paramNew), e); } try { - List daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); - for (int i = 0; i < daysBetween.size(); i++) { - String dateDimId = daysBetween.get(i); - param.setDateId(dateDimId); - issueExtractService.issueExtractLog(param); + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + paramNew.setDateId(dateDimId); + issueExtractService.issueExtractLog(paramNew); } } catch (Exception e) { - log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(paramNew), e); } } }); threadPool.submit(() -> { - if(StringUtils.isNotBlank(param.getDateId())){ + ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); + if (!isRange) { try { - projectExtractService.saveOriginProjectDaily(param); + projectExtractService.saveOriginProjectDaily(paramNew); } catch (Exception e) { - log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } try { - projectExtractService.extractProjectPeriodData(param); + projectExtractService.extractProjectPeriodData(paramNew); } catch (Exception e) { - log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } - }else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){ + } else { try { - List daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); - for (int i = 0; i < daysBetween.size(); i++) { - String dateDimId = daysBetween.get(i); - param.setDateId(dateDimId); - projectExtractService.saveOriginProjectDaily(param); + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + paramNew.setDateId(dateDimId); + projectExtractService.saveOriginProjectDaily(paramNew); } } catch (Exception e) { - log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } try { - List daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); - for (int i = 0; i < daysBetween.size(); i++) { - String dateDimId = daysBetween.get(i); - param.setDateId(dateDimId); - projectExtractService.extractProjectPeriodData(param); + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + paramNew.setDateId(dateDimId); + projectExtractService.extractProjectPeriodData(paramNew); } } catch (Exception e) { - log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e); + log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); } } }); From da021134ffc326a51242ee25a94a6415670d5502 Mon Sep 17 00:00:00 2001 From: wangchao Date: Fri, 16 Oct 2020 12:34:12 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=AF=B9=E5=8A=9E=E7=BB=93=E7=8E=87?= =?UTF-8?q?=E3=80=81=E5=8A=9E=E7=BB=93=E6=95=88=E7=8E=87=E7=9A=84=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectParticipatedAgencyResultDTO.java | 2 + .../extract/FactOriginProjectLogDailyDao.java | 29 ++++++- .../impl/IndexCollCommunityServiceImpl.java | 10 ++- .../impl/IndexCollDistrictServiceImpl.java | 11 ++- .../impl/IndexCollStreetServiceImpl.java | 11 ++- .../FactOriginProjectLogDailyService.java | 8 +- .../FactOriginProjectLogDailyServiceImpl.java | 84 +++++++++++-------- .../extract/FactOriginProjectLogDailyDao.xml | 77 +++++++++++++++++ 8 files changed, 182 insertions(+), 50 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java index 0065a286ec..f7714ca882 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java @@ -17,4 +17,6 @@ public class ProjectParticipatedAgencyResultDTO implements Serializable { private String agencyId; private int count; + + private String projectId; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java index 180ce535bc..a4ef520287 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java @@ -23,6 +23,7 @@ import com.epmet.entity.evaluationindex.extract.FactOriginProjectLogDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + import java.util.List; /** @@ -125,7 +126,16 @@ public interface FactOriginProjectLogDailyDao extends BaseDao selectAgencyWhistledCount(@Param("agencies") List agencies, @Param("customerId") String customerId,@Param("dimId") String dimId); - + /*** + * @Description 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + * @param agencies + * @param customerId + * @param dimId + * @return java.util.List + * @author wangc + * @date 2020.10.16 10:43 + */ + List selectWhistledAgencyClosedProjectCount(@Param("agencies") List agencies, @Param("customerId") String customerId,@Param("dimId") String dimId); /*** * @Description 查询机关办结次数 * @param agencies @@ -134,7 +144,24 @@ public interface FactOriginProjectLogDailyDao extends BaseDao selectAgencyHandledProjectCount(@Param("agencies") List agencies,@Param("customerId") String customerId,@Param("dimId") String dimId); + /** + * @Description 查询评价周期内各级别机关办结的项目Id + * @param customerId + * @param dimId + * @return java.util.List + * @author wangc + * @date 2020.10.15 17:29 + */ + List selectProjectIdHandledByAgency(@Param("customerId") String customerId,@Param("dimId") String dimId); + /** + * @Description 计算每个办结项目的总耗时 + * @param projectIds + * @return java.util.List + * @author wangc + * @date 2020.10.15 17:32 + */ + List selectProjectCostTime(@Param("projectIds") List projectIds); /** * 网格项目响应度 * @author zhaoqifeng diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java index e33f7a4982..d8c024085b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java @@ -134,13 +134,17 @@ public class IndexCollCommunityServiceImpl implements IndexCollCommunityService })); } - //办结数 + List agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); + //办结数 Map agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); - Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); + ////评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + Map whistledAgencyClosedProject = factOriginProjectLogDailyService.getWhistledAgencyClosedProjectCount(agencies,customerId,dimId.getMonthId(),"month"); + //处理效率 + Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month"); list.forEach(entity ->{ entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); - BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); + BigDecimal element = new BigDecimal(Optional.ofNullable(whistledAgencyClosedProject.get(entity.getAgencyId())).orElse(NumConstant.ZERO)); //分母,即机关参与过的项目数(去重) //“评价周期内被吹哨且办结的项目数”/“评价周期内被吹哨的所有项目数” Integer denominator = entity.getTransferedCount(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java index 1e576f2ba3..5271e87177 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java @@ -127,14 +127,17 @@ public class IndexCollDistrictServiceImpl implements IndexCollDistrictService { } })); } - //办结数 + List agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); + //办结数 Map agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); - - Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); + //评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + Map whistledAgencyClosedProject = factOriginProjectLogDailyService.getWhistledAgencyClosedProjectCount(agencies,customerId,dimId.getMonthId(),"month"); + //处理效率 + Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month"); list.forEach(entity ->{ entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); - BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); + BigDecimal element = new BigDecimal(Optional.ofNullable(whistledAgencyClosedProject.get(entity.getAgencyId())).orElse(NumConstant.ZERO)); //分母,即机关参与过的项目数(去重) //“评价周期内被吹哨且办结的项目数”/“评价周期内被吹哨的所有项目数” Integer denominator = entity.getTransferedCount(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java index edd1742ec0..6de2c28648 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java @@ -125,14 +125,17 @@ public class IndexCollStreetServiceImpl implements IndexCollStreetService { } })); } - //办结数 + List agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); + //办结数 Map agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); - - Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); + ////评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + Map whistledAgencyClosedProject = factOriginProjectLogDailyService.getWhistledAgencyClosedProjectCount(agencies,customerId,dimId.getMonthId(),"month"); + //处理效率 + Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month"); list.forEach(entity ->{ entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); - BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); + BigDecimal element = new BigDecimal(Optional.ofNullable(whistledAgencyClosedProject.get(entity.getAgencyId())).orElse(NumConstant.ZERO)); //分母,吹哨次数 Integer denominator = entity.getTransferedCount(); if (null != denominator && denominator != NumConstant.ZERO) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java index f8f430eb0a..84a4c06392 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java @@ -178,7 +178,7 @@ public interface FactOriginProjectLogDailyService extends BaseService getProjectHandledAgency(List agencies, String customerId, String dimId,String dateType); /** - * @Description 查询机关单位经手的项目数,去重 + * @Description 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 * @param agencies * @param dimId * @param dateType - 日期维度类型 month date week quarter year @@ -186,16 +186,16 @@ public interface FactOriginProjectLogDailyService extends BaseService getCountOfDealingAgency(List agencies, String customerId,String dimId,String dateType); + Map getWhistledAgencyClosedProjectCount(List agencies, String customerId,String dimId,String dateType); /** * @Description 计算机关办结项目效率 - * @param agencies + * @param customerId * @return * @author wangc * @date 2020.09.21 02:16 **/ - Map getAgencyWorkPieceRatio(List agencies, String customerId,String dimId,String dateType); + Map getAgencyWorkPieceRatio( String customerId,String dimId,String dateType); /** * 网格项目响应度 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java index cff8dc53c1..435990bc38 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java @@ -38,6 +38,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import javax.naming.LinkLoopException; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; @@ -183,7 +184,7 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl getCountOfDealingAgency(List agencies, String customerId,String dimId, String dateType) { + public Map getWhistledAgencyClosedProjectCount(List agencies, String customerId,String dimId, String dateType) { Map result = new HashMap<>(); - List projectAgencyCount = baseDao.selectProjectParticipatedAgency(agencies,customerId,dimId); + List projectAgencyCount = baseDao.selectWhistledAgencyClosedProjectCount(agencies,customerId,dimId); if(!CollectionUtils.isEmpty(projectAgencyCount)){ result = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount)); } @@ -203,48 +204,63 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl getAgencyWorkPieceRatio(List agencies, String customerId,String dimId, String dateType) { - //网格、部门的办结系数 - List gridDeptResponse = projectOrgPeriodDailyDao.selectSubOrgResponseCoefficient(customerId, dimId, dateType); - //机关的办结系数 - List agencyResponse = projectOrgPeriodDailyDao.selectAgencyResponseCoefficient(customerId, dimId, dateType); - Map consumingMap = new HashMap<>(); - Map timeMap = new HashMap<>(); - if(!CollectionUtils.isEmpty(agencyResponse)){ - agencyResponse.forEach(response -> { - consumingMap.put(response.getAgencyId(),response.getResponseTime()); - //注意,这里取的是去重后的项目次数,例如一个部门被项目流转了多次,项目数只算一次 - //如果需要改成不去重,只需response.getProjectTotal() - timeMap.put(response.getAgencyId(),response.getDistinctProjectTotal()); - }); - } - if(!CollectionUtils.isEmpty(gridDeptResponse)){ - gridDeptResponse.forEach(response -> { - if(null != consumingMap.get(response.getAgencyId())){ - consumingMap.put(response.getAgencyId(),consumingMap.get(response.getAgencyId()).add(response.getResponseTime())); - timeMap.put(response.getAgencyId(),timeMap.get(response.getAgencyId()).add(response.getDistinctProjectTotal())); - }else{ - consumingMap.put(response.getAgencyId(),response.getResponseTime()); - timeMap.put(response.getAgencyId(),response.getDistinctProjectTotal()); - } - }); - } - //效率map + public Map getAgencyWorkPieceRatio(String customerId,String dimId, String dateType) { + //计算方法 : 评价周期内办结项目的平均处理时长的倒数 + + + //1.评价周期内结案了的项目 + List projectsHandledByAgency = baseDao.selectProjectIdHandledByAgency(customerId,dimId); Map efficiencyMap = new HashMap<>(); - if(!CollectionUtils.isEmpty(consumingMap)) { - consumingMap.keySet().forEach(agencyId -> { - efficiencyMap.put(agencyId, consumingMap.get(agencyId).divide(timeMap.get(agencyId), NumConstant.SIX, RoundingMode.HALF_UP)); + if(!CollectionUtils.isEmpty(projectsHandledByAgency)){ + Map> agencyProjectsMap = new HashMap<>(); + + projectsHandledByAgency.forEach(o -> { + String agencyId = o.getAgencyId(); + String projectId = o.getProjectId(); + if(CollectionUtils.isEmpty(agencyProjectsMap.get(agencyId))){ + List projectUnit = new LinkedList<>(); + projectUnit.add(projectId); + agencyProjectsMap.put(agencyId,projectUnit); + }else{ + agencyProjectsMap.get(agencyId).add(projectId); + } + }); + + List projects = new LinkedList<>(); + agencyProjectsMap.forEach((key,value) -> {projects.addAll(value);}); + //2.结案项目的总耗时 + List costTimes = baseDao.selectProjectCostTime(projects); + + Map projectCostTime = costTimes.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getProjectId,ProjectParticipatedAgencyResultDTO::getCount)); + agencyProjectsMap.forEach((k,v) -> { + //k -> agencyId v -> projects + int total = NumConstant.ZERO; + if(!CollectionUtils.isEmpty(v)){ + for(String p : v){ + Integer cost = projectCostTime.get(p); + total = total + (null == cost ? NumConstant.ZERO : cost); + } + //每个机关的项目平均耗时 + BigDecimal avgCost = new BigDecimal(total).divide(new BigDecimal(v.size()),4, BigDecimal.ROUND_HALF_UP); + + efficiencyMap.put(k,BigDecimal.ONE.divide(avgCost,4, BigDecimal.ROUND_HALF_UP)); + + }else{ + efficiencyMap.put(k,BigDecimal.ZERO); + } }); } + return efficiencyMap; } + @Override public List getGridResponse(String customerId, String monthId) { return baseDao.selectGridResponse(customerId, monthId); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml index b389aa1aa3..3ec448ae2c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml @@ -180,6 +180,29 @@ GROUP BY AGENCY_ID + + + + + +