From 4f979b5c919a861912b11b66f3331952caaf7d2e Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 14 Jul 2021 14:06:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=BB=84=E7=BB=87=E6=AC=A1=E6=95=B0=E3=80=81?= =?UTF-8?q?=E6=80=BB=E5=8F=82=E4=B8=8E=E4=BA=BA=E6=AC=A1=EF=BC=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=8C=89=E7=85=A7=E7=BB=84=E7=BB=87=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E9=99=8D=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ScreenWorkRecordOrgDailyServiceImpl.java | 14 ++++++++++++-- .../mapper/screen/ScreenCustomerAgencyDao.xml | 1 + .../mapper/screen/ScreenCustomerGridDao.xml | 1 + .../ScreenCustomerWorkRecordDictServiceImpl.java | 3 ++- .../impl/ScreenWorkRecordOrgDailyServiceImpl.java | 3 ++- .../ScreenWorkRecordOrgMonthlyServiceImpl.java | 3 ++- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java index 52de467168..313d7008b6 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java @@ -167,8 +167,18 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl= formDTO.getTopRow() ? - returnDto.getSubRankList().subList(NumConstant.ZERO, formDTO.getTopRow()) : returnDto.getSubRankList()); + //按照组织次数降序排列 + if(CollectionUtils.isNotEmpty(returnDto.getSubRankList())){ + Collections.sort(returnDto.getSubRankList(), new Comparator() { + @Override + public int compare(WorkRecordSubRank o1, WorkRecordSubRank o2) { + return o2.getParticipateTotal().compareTo(o1.getParticipateTotal()); + } + }); + if(returnDto.getSubRankList().size() >= formDTO.getTopRow()){ + returnDto.getSubRankList().subList(NumConstant.ZERO, formDTO.getTopRow()); + } + } return returnDto; } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml index 183e74bb02..6f83783845 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml @@ -321,6 +321,7 @@ and sca.PID=#{agencyId} + order by CONVERT ( sca.AGENCY_NAME USING gbk ) ASC diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml index a700e40792..ac5f466642 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml @@ -137,5 +137,6 @@ and m.PARENT_AGENCY_ID=#{agencyId} + order by CONVERT ( m.grid_name USING gbk ) ASC \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenCustomerWorkRecordDictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenCustomerWorkRecordDictServiceImpl.java index 7a6291717a..e082a9af8c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenCustomerWorkRecordDictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenCustomerWorkRecordDictServiceImpl.java @@ -35,6 +35,7 @@ import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.Arrays; import java.util.List; @@ -108,7 +109,7 @@ public class ScreenCustomerWorkRecordDictServiceImpl extends BaseServiceImpl data) { - if(data.getIsFirst()){ + if (data.getIsFirst() && !CollectionUtils.isEmpty(data.getDataList())) { int affectedRows = baseDao.deleteBatch(data.getCustomerId()); while(affectedRows > 0){ affectedRows = baseDao.deleteBatch(data.getCustomerId()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java index 8f4d4f7c84..504a948c50 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java @@ -28,6 +28,7 @@ import com.epmet.entity.plugins.ScreenWorkRecordOrgDailyEntity; import com.epmet.service.plugins.ScreenWorkRecordOrgDailyService; import com.google.common.collect.Lists; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; /** * 工作日志-组织按日统计(累计值) @@ -42,7 +43,7 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl data) { - if(data.getIsFirst()){ + if (data.getIsFirst() && !CollectionUtils.isEmpty(data.getDataList())) { int affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getDateId()); while(affectedRows > 0){ affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getDateId()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgMonthlyServiceImpl.java index 7ecd3c4eb6..a153cbac9e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgMonthlyServiceImpl.java @@ -29,6 +29,7 @@ import com.epmet.service.plugins.ScreenWorkRecordOrgMonthlyService; import com.google.common.collect.Lists; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; /** * 工作日志-组织按月统计 @@ -51,7 +52,7 @@ public class ScreenWorkRecordOrgMonthlyServiceImpl extends BaseServiceImpl data) { - if(data.getIsFirst()){ + if(data.getIsFirst() && !CollectionUtils.isEmpty(data.getDataList())){ int affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getMonthId()); while(affectedRows > 0){ affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getMonthId()); From 9eecb70e187407f4237eece7014476a6134a6436 Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 15 Jul 2021 09:17:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BD=BF=E7=94=A8FeignCL?= =?UTF-8?q?ientFallbackFactory=E6=96=B9=E5=BC=8F=E8=B0=83=E7=94=A8datastat?= =?UTF-8?q?istical?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/ExceptionUtils.java | 4 ++++ .../feign/DataStatisticalOpenFeignClient.java | 4 +++- ...ataStatisticalOpenFeignClientFallBack.java | 2 +- ...isticalOpenFeignClientFallBackFactory.java | 20 +++++++++++++++++++ .../com/epmet/controller/DemoController.java | 7 +++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/ExceptionUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/ExceptionUtils.java index a5e559cbfa..6837104b36 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/ExceptionUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/ExceptionUtils.java @@ -25,6 +25,10 @@ public class ExceptionUtils { * @return 返回异常信息 */ public static String getErrorStackTrace(Exception ex){ + return getThrowableErrorStackTrace(ex); + } + + public static String getThrowableErrorStackTrace(Throwable ex) { StringWriter sw = null; PrintWriter pw = null; try { diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java index ee5daf2a47..360cb3c71a 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java @@ -8,6 +8,7 @@ import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.screen.form.InitCustomerIndexForm; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBack; +import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -20,7 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody; * @author: jianjun liu */ //url="http://localhost:8108" -@FeignClient(name = ServiceConstant.DATA_STATISTICAL_SERVER, fallback = DataStatisticalOpenFeignClientFallBack.class) +//@FeignClient(name = ServiceConstant.DATA_STATISTICAL_SERVER, fallback = DataStatisticalOpenFeignClientFallBack.class, url = "http://localhost:6666") +@FeignClient(name = ServiceConstant.DATA_STATISTICAL_SERVER, fallbackFactory = DataStatisticalOpenFeignClientFallBackFactory.class) public interface DataStatisticalOpenFeignClient { /** diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java index 4846a3e557..e15214e9d7 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java @@ -19,7 +19,7 @@ import org.springframework.stereotype.Component; * @author: jianjun liu * email:liujianjun@git.elinkit.com.cn */ -@Component +//@Component public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOpenFeignClient { /** diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java new file mode 100644 index 0000000000..70768329c8 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.impl; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.DataStatisticalOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class DataStatisticalOpenFeignClientFallBackFactory implements FallbackFactory { + + private DataStatisticalOpenFeignClientFallBack fallback = new DataStatisticalOpenFeignClientFallBack(); + + @Override + public DataStatisticalOpenFeignClient create(Throwable cause) { + log.error(ExceptionUtils.getThrowableErrorStackTrace(cause));//自己写的工具类 + return fallback; + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java index ccb3d23d6a..8745239867 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java @@ -8,8 +8,10 @@ package com.epmet.controller; +import com.epmet.feign.DataStatisticalOpenFeignClient; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -24,10 +26,15 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("demo") @Api(tags="定时任务") public class DemoController { + + @Autowired + private DataStatisticalOpenFeignClient client; + @GetMapping("testAlarm") public void testAlarm() { //for (int i = 0; i < 20; i++) { log.error("测试消息"); //} + client.agencyGridIssueStats(null); } }