Browse Source

Merge branch 'wxz_feign_exception_show' into develop

# Conflicts:
#	epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/ExceptionUtils.java
master
wxz 4 years ago
parent
commit
19619c886c
  1. 12
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/ExceptionUtils.java
  2. 14
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java
  3. 1
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  4. 1
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml
  5. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
  6. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
  7. 20
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java
  8. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenCustomerWorkRecordDictServiceImpl.java
  9. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java
  10. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/plugins/impl/ScreenWorkRecordOrgMonthlyServiceImpl.java
  11. 7
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java

12
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/ExceptionUtils.java

@ -25,22 +25,16 @@ public class ExceptionUtils {
* @return 返回异常信息 * @return 返回异常信息
*/ */
public static String getErrorStackTrace(Exception ex){ public static String getErrorStackTrace(Exception ex){
return getErrorStackTraceOfThrowable(ex); return getThrowableErrorStackTrace(ex);
} }
/** public static String getThrowableErrorStackTrace(Throwable ex) {
* @Description Throwable级别的错误信息
* @return
* @author wxz
* @date 2021.07.07 14:37
*/
public static String getErrorStackTraceOfThrowable(Throwable t) {
StringWriter sw = null; StringWriter sw = null;
PrintWriter pw = null; PrintWriter pw = null;
try { try {
sw = new StringWriter(); sw = new StringWriter();
pw = new PrintWriter(sw, true); pw = new PrintWriter(sw, true);
t.printStackTrace(pw); ex.printStackTrace(pw);
}finally { }finally {
try { try {
if(pw != null) { if(pw != null) {

14
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<ScreenW
} }
returnDto.setParticipateTotal(participateTotal); returnDto.setParticipateTotal(participateTotal);
returnDto.setParticipateUserTotal(participateUserTotal); returnDto.setParticipateUserTotal(participateUserTotal);
returnDto.setSubRankList(CollectionUtils.isNotEmpty(returnDto.getSubRankList()) && returnDto.getSubRankList().size() >= formDTO.getTopRow() ? //按照组织次数降序排列
returnDto.getSubRankList().subList(NumConstant.ZERO, formDTO.getTopRow()) : returnDto.getSubRankList()); if(CollectionUtils.isNotEmpty(returnDto.getSubRankList())){
Collections.sort(returnDto.getSubRankList(), new Comparator<WorkRecordSubRank>() {
@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; return returnDto;
} }

1
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml

@ -321,6 +321,7 @@
and sca.PID=#{agencyId} and sca.PID=#{agencyId}
</otherwise> </otherwise>
</choose> </choose>
order by CONVERT ( sca.AGENCY_NAME USING gbk ) ASC
</select> </select>
<!-- 根据agencyId查询网格 --> <!-- 根据agencyId查询网格 -->

1
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

@ -137,5 +137,6 @@
and m.PARENT_AGENCY_ID=#{agencyId} and m.PARENT_AGENCY_ID=#{agencyId}
</otherwise> </otherwise>
</choose> </choose>
order by CONVERT ( m.grid_name USING gbk ) ASC
</select> </select>
</mapper> </mapper>

4
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.screen.form.InitCustomerIndexForm;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBack; import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBack;
import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBackFactory;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -20,7 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody;
* @author: jianjun liu * @author: jianjun liu
*/ */
//url="http://localhost:8108" //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 { public interface DataStatisticalOpenFeignClient {
/** /**

2
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 * @author: jianjun liu
* email:liujianjun@git.elinkit.com.cn * email:liujianjun@git.elinkit.com.cn
*/ */
@Component //@Component
public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOpenFeignClient { public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOpenFeignClient {
/** /**

20
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<DataStatisticalOpenFeignClient> {
private DataStatisticalOpenFeignClientFallBack fallback = new DataStatisticalOpenFeignClientFallBack();
@Override
public DataStatisticalOpenFeignClient create(Throwable cause) {
log.error(ExceptionUtils.getThrowableErrorStackTrace(cause));//自己写的工具类
return fallback;
}
}

3
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.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -108,7 +109,7 @@ public class ScreenCustomerWorkRecordDictServiceImpl extends BaseServiceImpl<Scr
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) @DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override @Override
public void collect(ScreenCollFormDTO<ScreenCustomerWorkRecordDictDTO> data) { public void collect(ScreenCollFormDTO<ScreenCustomerWorkRecordDictDTO> data) {
if(data.getIsFirst()){ if (data.getIsFirst() && !CollectionUtils.isEmpty(data.getDataList())) {
int affectedRows = baseDao.deleteBatch(data.getCustomerId()); int affectedRows = baseDao.deleteBatch(data.getCustomerId());
while(affectedRows > 0){ while(affectedRows > 0){
affectedRows = baseDao.deleteBatch(data.getCustomerId()); affectedRows = baseDao.deleteBatch(data.getCustomerId());

3
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.epmet.service.plugins.ScreenWorkRecordOrgDailyService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/** /**
* 工作日志-组织按日统计(累计值) * 工作日志-组织按日统计(累计值)
@ -42,7 +43,7 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) @DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override @Override
public void collectOrgDaily(ScreenCollFormDTO<ScreenWorkRecordCommonFormDTO> data) { public void collectOrgDaily(ScreenCollFormDTO<ScreenWorkRecordCommonFormDTO> data) {
if(data.getIsFirst()){ if (data.getIsFirst() && !CollectionUtils.isEmpty(data.getDataList())) {
int affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getDateId()); int affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getDateId());
while(affectedRows > 0){ while(affectedRows > 0){
affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getDateId()); affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getDateId());

3
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 com.google.common.collect.Lists;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/** /**
* 工作日志-组织按月统计 * 工作日志-组织按月统计
@ -51,7 +52,7 @@ public class ScreenWorkRecordOrgMonthlyServiceImpl extends BaseServiceImpl<Scree
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) @DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override @Override
public void collect(ScreenCollFormDTO<ScreenWorkRecordCommonFormDTO> data) { public void collect(ScreenCollFormDTO<ScreenWorkRecordCommonFormDTO> data) {
if(data.getIsFirst()){ if(data.getIsFirst() && !CollectionUtils.isEmpty(data.getDataList())){
int affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getMonthId()); int affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getMonthId());
while(affectedRows > 0){ while(affectedRows > 0){
affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getMonthId()); affectedRows = baseDao.deleteBatch(data.getCustomerId(),data.getMonthId());

7
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java

@ -8,8 +8,10 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.feign.DataStatisticalOpenFeignClient;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; 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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -24,10 +26,15 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("demo") @RequestMapping("demo")
@Api(tags="定时任务") @Api(tags="定时任务")
public class DemoController { public class DemoController {
@Autowired
private DataStatisticalOpenFeignClient client;
@GetMapping("testAlarm") @GetMapping("testAlarm")
public void testAlarm() { public void testAlarm() {
//for (int i = 0; i < 20; i++) { //for (int i = 0; i < 20; i++) {
log.error("测试消息"); log.error("测试消息");
//} //}
client.agencyGridIssueStats(null);
} }
} }

Loading…
Cancel
Save