Browse Source

Merge remote-tracking branch 'origin/dev_bugfix_ljj' into dev_bugfix_ljj

dev_shibei_match
sunyuchao 4 years ago
parent
commit
b3be85bc44
  1. 35
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
  2. 11
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  3. 96
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetException.java
  4. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenException.java
  5. 38
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java
  6. 11
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/AssertUtils.java
  7. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  8. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java
  9. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreCalculator.java
  10. 21
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java
  11. 16
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java
  12. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

35
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java

@ -67,7 +67,15 @@ public abstract class BaseRequestLogAspect {
log.info(">>>>>>>>请求信息>>>>>>>>:事务流水号:{},url:{} ,method:{},请求参数:{}", transactionSerial, requestURI, method, objectsToString(args));
result = point.proceed();
resultInfoLog(transactionSerial, getExecPeriod(startTime), result);
} catch (RenException e) {
} catch (EpmetException e) {
result = handleRenException(e);
if (e.getCode() > 8000) {
resultWarnLog(transactionSerial, getExecPeriod(startTime), result, e.getInternalMsg(), ExceptionUtils.getErrorStackTrace(e));
} else {
resultErrorLog(transactionSerial, getExecPeriod(startTime), result, e.getInternalMsg(), ExceptionUtils.getErrorStackTrace(e));
}
return result;
} catch (RenException e) {
result = handleRenException(e);
if (e.getCode() > 8000) {
resultWarnLog(transactionSerial, getExecPeriod(startTime), result, e.getInternalMsg(), ExceptionUtils.getErrorStackTrace(e));
@ -213,6 +221,31 @@ public abstract class BaseRequestLogAspect {
return result;
}
/**
* 处理EpmetException
* @param e
* @return
*/
private Result handleRenException(EpmetException e) {
if (e.getCode() > 8000) {
Result result;
if (StringUtils.isNotBlank(e.getMsg())) {
// 抛出异常的时候填写了自定义显示信息,把显示信息返回
result = new Result().error(e.getCode(), e.getMsg());
} else {
// 没有填写显示信息,则根据code找固定的显示信息
result = new Result().error(e.getCode());
}
result.setInternalMsg(e.getInternalMsg());
return result;
}
// 转化成服务器开小差...
Result result=new Result().error();
result.setInternalMsg(e.getInternalMsg());
//result.setMsg(e.getMsg());
return result;
}
/**
* 将请求对象转换为String
* @param args

11
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -7,6 +7,9 @@ package com.epmet.commons.tools.exception;
*/
public enum EpmetErrorCode {
/**
* 错误code及消息
*/
ERR10002( 10002,"数据库中已存在该记录"),
/**
* 账号或密码错误ACCOUNT_NOT_EXIST
@ -212,8 +215,14 @@ public enum EpmetErrorCode {
SAME_RULE_NAME(8916,"该积分事件已存在,请重新调整保存"),
UP_LIMIT_POINT(8917,"积分上限需为单位积分倍数,请重新调整保存"),
BADGE_CHECK(8918,"");
BADGE_CHECK(8918,""),
//通用错误码 start
//通用的 错误消息自己定义返回
EPMET_COMMON_OPERATION_FAIL(9999,"网络开小差..."),
//通用错误码 end
;
private int code;
private String msg;

96
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetException.java

@ -0,0 +1,96 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.epmet.commons.tools.exception;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.MessageUtils;
import org.apache.commons.lang3.StringUtils;
/**
* Epmet产品 自定义异常
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
public class EpmetException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* desc:错误码
*/
protected int code;
/**
* 显示给客户的消息
*/
protected String msg;
/**
* 内部消息用于服务之间传递错误信息排错用
*/
protected String internalMsg;
/**
* desc:指定错误码异常 外部异常内容为错误码对应的异常
* @param code
*/
public EpmetException(int code) {
this(code, StrConstant.EPMETY_STR);
}
/**
* desc:指定内部错误消息的异常 外部异常内容为错误码对应的异常
* @param code
* @param internalMsg
*/
public EpmetException(int code, String internalMsg) {
super(internalMsg);
this.code = code;
if (StringUtils.isBlank(internalMsg)) {
this.internalMsg = EpmetErrorCode.getMsg(code);
if (StringUtils.isBlank(this.internalMsg)) {
this.internalMsg = MessageUtils.getMessage(code, internalMsg);
}
} else {
this.internalMsg = internalMsg;
}
}
/**
* desc指定错误码 内外部错误消息异常
* @param code
* @param internalMsg
* @param externalMsg
*/
public EpmetException(int code, String internalMsg, String externalMsg) {
this(code, internalMsg);
this.msg = externalMsg;
}
/**
* desc:指定内部消息异常 外部错误码及消息为8000服务器开小差
* @param internalMsg
*/
public EpmetException(String internalMsg) {
super(internalMsg);
this.code = EpmetErrorCode.SERVER_ERROR.getCode();
this.internalMsg = internalMsg;
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
public String getInternalMsg() {
return internalMsg;
}
}

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenException.java

@ -35,11 +35,12 @@ public class RenException extends RuntimeException {
* 内部消息用于服务之间传递错误信息排错用
*/
private String internalMsg;
@Deprecated //已废弃 被EpmetException替代
public RenException(int code) {
this(code, "");
}
@Deprecated //已废弃 被EpmetException替代
public RenException(int code, String internalMsg) {
super(internalMsg);
this.code = code;
@ -53,11 +54,13 @@ public class RenException extends RuntimeException {
}
}
@Deprecated //已废弃 被EpmetException替代
public RenException(int code, String internalMsg, String msg, MessageMode mode) {
this(code, internalMsg);
this.msg = msg;
}
@Deprecated //已废弃 被EpmetException替代
public RenException(String internalMsg) {
super(internalMsg);
// this.code = ErrorCode.INTERNAL_SERVER_ERROR;
@ -65,15 +68,12 @@ public class RenException extends RuntimeException {
this.internalMsg = internalMsg;
}
@Deprecated //已废弃 被EpmetException替代
public RenException(String internalMsg, String msg) {
this(internalMsg);
this.msg = msg;
}
public RenException(int code, String... params) {
this.code = code;
this.internalMsg = EpmetErrorCode.getMsg(code);

38
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java

@ -743,44 +743,6 @@ public class DateUtils {
return minusMonthId;
}
/**
* @Description 根据传入的时间维度判断格式
* @param dimension
* @return
* @author wangc
* @date 2020.09.24 10:11
**/
public static String identifyTimeDimension(String dimension){
//yyyyMMdd DATE_PATTERN_YYYYMMDD
//yyyyMM DATE_PATTERN_YYYYMM
//yyyy DATE_PATTERN_YYYY
//yyyyWcc
//yyyyQc
if(dimension.length() == NumConstant.EIGHT){
SimpleDateFormat df = new SimpleDateFormat(DATE_PATTERN_YYYYMMDD);
try{ df.parse(dimension); }catch (ParseException e){ return null; }
return "date";
}else if(dimension.length() == NumConstant.FOUR){
SimpleDateFormat df = new SimpleDateFormat(DATE_PATTERN_YYYY);
try{df.parse(dimension);}catch (ParseException e){return null;}
return "year";
}else if(dimension.length() == NumConstant.SEVEN){
if(dimension.contains("W")){
return "week";
}else return null;
}else if(dimension.length() == NumConstant.SIX){
if(dimension.contains("Q")){
return "quarter";
}else{
SimpleDateFormat df = new SimpleDateFormat(DATE_PATTERN_YYYYMM);
try{df.parse(dimension);}catch (ParseException e){return null;}
return "month";
}
}else return null;
}
/**
* 指定月份的开始时间
* @param date

11
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/AssertUtils.java

@ -11,6 +11,7 @@ package com.epmet.commons.tools.validator;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ErrorCode;
import com.epmet.commons.tools.exception.RenException;
import org.apache.commons.lang3.StringUtils;
@ -32,7 +33,7 @@ public class AssertUtils {
public static void isBlank(String str, Integer code, String... params) {
if(code == null){
throw new RenException(ErrorCode.NOT_NULL, "code");
throw new EpmetException(ErrorCode.NOT_NULL, "code");
}
if (StringUtils.isBlank(str)) {
@ -46,7 +47,7 @@ public class AssertUtils {
public static void isNull(Object object, Integer code, String... params) {
if(code == null){
throw new RenException(ErrorCode.NOT_NULL, "code");
throw new EpmetException(ErrorCode.NOT_NULL, "code");
}
if (object == null) {
@ -60,7 +61,7 @@ public class AssertUtils {
public static void isArrayEmpty(Object[] array, Integer code, String... params) {
if(code == null){
throw new RenException(ErrorCode.NOT_NULL, "code");
throw new EpmetException(ErrorCode.NOT_NULL, "code");
}
if(ArrayUtil.isEmpty(array)){
@ -74,7 +75,7 @@ public class AssertUtils {
public static void isListEmpty(List<?> list, Integer code, String... params) {
if(code == null){
throw new RenException(ErrorCode.NOT_NULL, "code");
throw new EpmetException(ErrorCode.NOT_NULL, "code");
}
if(CollUtil.isEmpty(list)){
@ -88,7 +89,7 @@ public class AssertUtils {
public static void isMapEmpty(Map map, Integer code, String... params) {
if(code == null){
throw new RenException(ErrorCode.NOT_NULL, "code");
throw new EpmetException(ErrorCode.NOT_NULL, "code");
}
if(MapUtil.isEmpty(map)){

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java

@ -2,6 +2,7 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.distributedlock.LockConstants;
import com.epmet.commons.tools.enums.EnvEnum;
@ -229,6 +230,15 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
log.error("基层治理-难点赌点抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
}
try {
//基层治理 - 热心市民 screen_party_user_rank_data
ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO();
param.setCustomerId(customerId);
param.setDateId(dateId);
screenGrassrootsGovernDataAbsorptionService.userScoreDataHub(param);
} catch (Exception e) {
log.error("大屏热心市民/党员得分数据写入失败,参数为:{}" + customerId+ StrConstant.HYPHEN +dateId, e);
}
} finally {
latch.countDown();
log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
@ -426,7 +436,8 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("党建引领抽取到大屏失败,参数为:" + JSON.toJSONString(formDTO), e);
}
try {
//已经挪到天抽取的抽取里了
/* try {
//基层治理 - 热心市民 screen_party_user_rank_data
ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO();
param.setCustomerId(customerId);
@ -434,7 +445,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
screenGrassrootsGovernDataAbsorptionService.userScoreDataHub(param);
} catch (Exception e) {
log.error("大屏热心市民/党员得分数据写入失败,参数为:{}" + JSON.toJSONString(formDTO), e);
}
}*/
try {
// 项目(事件)数量分析按网格_按月统计
screenProjectQuantityGridMonthlyService.extractionProjectGridMonthly(customerId, monthId);

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java

@ -88,6 +88,10 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
**/
@Override
public void userScoreDataHub(ScreenCentralZoneDataFormDTO param) {
if (StringUtils.isNotBlank(param.getDateId()) && param.getDateId().length()!= NumConstant.EIGHT){
log.error("userScoreDataHub param dateId must be dateId(eg:20211212)");
return;
}
//1.查询出客户下的网格注册用户
List<ScreenPartyUserRankDataEntity> registeredUsers = userService.getRegisteredUserList(param.getCustomerId());
@ -100,19 +104,15 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
Map<String, Integer> pointMap = userPointService.getUserPointMap(param.getCustomerId());
//4.查询出客户下党员的分值
String dateId = param.getDateId();
if (StringUtils.isEmpty(dateId)) {
//如果没有传月份,则使用当前时间的上一个月
final String finalDateId = dateId;
String currentMonthId = DateUtils.getBeforeNMonth(0);
if (StringUtils.isEmpty(dateId) || dateId.contains(currentMonthId)) {
//如果没有传月份 或者传的为日期为当前月则,则使用当前时间的上一个月
dateId = DateUtils.getBeforeNMonth(NumConstant.ONE);
} else {
String dateType = DateUtils.identifyTimeDimension(dateId);
if (StringUtils.isEmpty(dateType) || !StringUtils.equalsAny(dateType, "date", "month")) {
dateId = DateUtils.getBeforeNMonth(NumConstant.ONE);
} else if (StringUtils.equals(dateType, "date")) {
dateId = dateId.substring(NumConstant.ZERO, dateId.length() - NumConstant.TWO);
}
dateId = dateId.substring(NumConstant.ZERO, dateId.length() - NumConstant.TWO);
}
final String finalDateId = dateId;
// 查询党员积分
// 查询党员指标得分 按月查
Map<String, BigDecimal> scoreMap = cpcIndexCalculateService.getCpcScore(param.getCustomerId(), dateId);
//剔除垃圾数据

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreCalculator.java

@ -76,16 +76,14 @@ public abstract class ScoreCalculator<T> {
throw new RuntimeException("入参数组错误:请设置sourceValue");
}
BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue));
if (correlation == Correlation.POSITIVE) {
// 正相关
BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue));
BigDecimal score = minScore.add(x);
return score;
} else if (correlation == Correlation.NEGATIVE) {
// 负相关
BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue));
BigDecimal score = minScore.add(x);
return maxScore.subtract(score, MathContext.DECIMAL32);
return maxScore.subtract(x, MathContext.DECIMAL32);
} else {
throw new RuntimeException("错误的相关性");
}

21
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java

@ -76,19 +76,24 @@ public class BatchScoreCalculator {
if (idx.getScoreCalculator().getMaxValue().compareTo(idx.getScoreCalculator().getMinValue()) == 0) {
//*((max-min)/ (Math.PI/2))+min
//Math.atan(new Double(vo.getSampleValue().toString()))*
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)))
.add(minScoreValue).setScale(6, RoundingMode.HALF_UP);
if (Correlation.POSITIVE.getCode().equals(scoreCalculator.getCorrelation().getCode())) {
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)))
.add(minScoreValue).setScale(6, RoundingMode.HALF_UP);
}else{
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)).multiply(new BigDecimal(-1)))
.add(maxScoreValue).setScale(6, RoundingMode.HALF_UP);
}
} else {
normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
}
//如果是负相关 则用100-归一后的值为最大值减
/* //如果是负相关 则用100-归一后的值为最大值减
if (Correlation.NEGATIVE.getCode().equals(scoreCalculator.getCorrelation().getCode())) {
normalizeValue = maxScoreValue.subtract(normalizeValue);
}
}*/
}
//如果归一后的值小于0 则置为0
if (normalizeValue.compareTo(NumConstant.ZERO_DECIMAL)<=-1){

16
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java

@ -20,10 +20,20 @@ public class MathUtilTest {
BigDecimal maxValue = new BigDecimal(100);
BigDecimal minValue = new BigDecimal(60);
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);
//((max-min)/ (Math.PI/2))+min
BigDecimal sampleValue = new BigDecimal(Math.atan(new Double("0")));
BigDecimal normalizeValue = sampleValue
.multiply(maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP))
.add(minValue).setScale(6, RoundingMode.HALF_UP);
BigDecimal normalizeValue2 = sampleValue
.multiply(maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP).multiply(new BigDecimal(-1)))
.add(maxValue).setScale(6, RoundingMode.HALF_UP);
System.out.println(normalizeValue);
System.out.println(normalizeValue2);
//new BigDecimal(Math.atan(new Double(vo.getSampleValue().toString())) / Math.PI * 100).setScale(6, RoundingMode.HALF_UP);
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -623,7 +623,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String bindResult = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_OPEN_GET + authorizerAccessToken, JSON.toJSONString(bindInfoForm)).getData();
Map<String, Object> bindInfo = JSON.parseObject(bindResult, Map.class);
boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID);
if (bindStatus != true) {
if (!bindStatus) {
Integer authCount = customerMpDao.selectAuthCount(customerId);
String openPlatformId = null;
if (authCount > 0) {
@ -658,6 +658,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
default:
}
} else if (authCount > NumConstant.ZERO) {
log.info("该客户已创建过开放平台账号,直接绑定");
@ -685,6 +687,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
throw new RenException(NOT_ALLOWED_OPERATE);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR:
throw new RenException(TO_LIMIT);
default:
}
}
//插入 binding_account
@ -706,7 +709,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
public Date countExpirationTime(String expiresIn) {
expiresIn = expiresIn + "000";
Date date = new Date();
long l = date.getTime() + Long.valueOf(expiresIn);
long l = date.getTime() + Long.parseLong(expiresIn);
date.setTime(l);
return date;
}
@ -727,7 +730,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
* @author zxc
*/
public Date sToDate(String t) {
Long aLong = Long.valueOf(t + "000");
long aLong = Long.parseLong(t + "000");
Date date = new Date();
date.setTime(aLong);
return date;

Loading…
Cancel
Save