|
@ -2,6 +2,7 @@ package com.epmet.controller; |
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
|
|
import com.epmet.commons.tools.enums.BizTypeEnum; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
@ -15,10 +16,7 @@ import com.epmet.service.evaluationindex.extract.toscreen.ScreenGrassrootsGovern |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.LinkedHashSet; |
|
|
import java.util.LinkedHashSet; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -38,8 +36,8 @@ public class ShiBeiICJobController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private RedisUtils redisUtils; |
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
|
@PostMapping("userPointAndProjectStatus") |
|
|
@PostMapping("userPointAndProjectStatus/{bizType}") |
|
|
public Result<String> userPointAndProjectStatus(@RequestBody ExtractOriginFormDTO formDTO) { |
|
|
public Result<String> userPointAndProjectStatus(@PathVariable("bizType") String bizType, @RequestBody ExtractOriginFormDTO formDTO) { |
|
|
if (StringUtils.isBlank(formDTO.getCustomerId())){ |
|
|
if (StringUtils.isBlank(formDTO.getCustomerId())){ |
|
|
return new Result<String>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误cid不能为空"); |
|
|
return new Result<String>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误cid不能为空"); |
|
|
} |
|
|
} |
|
@ -48,23 +46,30 @@ public class ShiBeiICJobController { |
|
|
if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) { |
|
|
if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) { |
|
|
List<String> daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate()); |
|
|
List<String> daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate()); |
|
|
daysBetween.forEach(d -> { |
|
|
daysBetween.forEach(d -> { |
|
|
this.extractUserPointData(formDTO.getCustomerId(), d); |
|
|
executeMethod(bizType, formDTO.getCustomerId(), d); |
|
|
this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId()); |
|
|
|
|
|
result.add(d); |
|
|
result.add(d); |
|
|
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); |
|
|
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus-"+bizType), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
if (StringUtils.isBlank(formDTO.getDateId())){ |
|
|
if (StringUtils.isBlank(formDTO.getDateId())){ |
|
|
formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); |
|
|
formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); |
|
|
} |
|
|
} |
|
|
this.extractUserPointData(formDTO.getCustomerId(), formDTO.getDateId()); |
|
|
executeMethod(bizType, formDTO.getCustomerId(), formDTO.getDateId()); |
|
|
this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId()); |
|
|
|
|
|
result.add(formDTO.getDateId()); |
|
|
result.add(formDTO.getDateId()); |
|
|
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); |
|
|
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus-"+bizType), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); |
|
|
} |
|
|
} |
|
|
long end = System.currentTimeMillis(); |
|
|
long end = System.currentTimeMillis(); |
|
|
long l = (end - start) / 1000; |
|
|
long l = (end - start) / 1000; |
|
|
return new Result<String>().ok("userPointAndProjectStatus耗时" + l + "s"); |
|
|
return new Result<String>().ok("userPointAndProjectStatus耗时-"+bizType + l + "s"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void executeMethod(String bizType, String customerId, String d) { |
|
|
|
|
|
if (bizType.equals(BizTypeEnum.PROJECT.getType())){ |
|
|
|
|
|
this.extractUserPointData(customerId, d); |
|
|
|
|
|
} |
|
|
|
|
|
if (bizType.equals(BizTypeEnum.USER.getType())) { |
|
|
|
|
|
this.agencyProjectStats(customerId, d); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|