15 changed files with 232 additions and 24 deletions
			
			
		| @ -0,0 +1,106 @@ | |||
| package com.epmet.controller; | |||
| 
 | |||
| import com.epmet.commons.tools.constant.NumConstant; | |||
| 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.redis.RedisKeys; | |||
| import com.epmet.commons.tools.redis.RedisUtils; | |||
| import com.epmet.commons.tools.utils.DateUtils; | |||
| import com.epmet.commons.tools.utils.Result; | |||
| import com.epmet.dto.StatsFormDTO; | |||
| import com.epmet.dto.extract.form.ExtractOriginFormDTO; | |||
| import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; | |||
| import com.epmet.service.StatsProjectService; | |||
| import com.epmet.service.evaluationindex.extract.toscreen.ScreenGrassrootsGovernDataAbsorptionService; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| 
 | |||
| import java.util.LinkedHashSet; | |||
| import java.util.List; | |||
| import java.util.Set; | |||
| 
 | |||
| /** | |||
|  * desc:市北数字社区 单独部署 job入口 【用户积分排名及项目状态数据】 | |||
|  */ | |||
| @RequestMapping("shibeiICJob") | |||
| @RestController | |||
| @Slf4j | |||
| public class ShiBeiICJobController { | |||
|     @Autowired | |||
|     private ScreenGrassrootsGovernDataAbsorptionService screenGrassrootsGovernDataAbsorptionService; | |||
|     @Autowired | |||
|     private StatsProjectService statsProjectService; | |||
|     @Autowired | |||
|     private RedisUtils redisUtils; | |||
| 
 | |||
|     @PostMapping("userPointAndProjectStatus/{bizType}") | |||
|     public Result<String> userPointAndProjectStatus(@PathVariable("bizType") String bizType, @RequestBody ExtractOriginFormDTO formDTO) { | |||
|         if (StringUtils.isBlank(formDTO.getCustomerId())){ | |||
|             return new Result<String>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误cid不能为空"); | |||
|         } | |||
|         long start = System.currentTimeMillis(); | |||
|         Set<String> result = new LinkedHashSet<>(); | |||
|         if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) { | |||
|             List<String> daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate()); | |||
|             daysBetween.forEach(d -> { | |||
|                 executeMethod(bizType, formDTO.getCustomerId(), d); | |||
|                 result.add(d); | |||
|                 redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus-"+bizType), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); | |||
|             }); | |||
|         } else { | |||
|             if (StringUtils.isBlank(formDTO.getDateId())){ | |||
|                 formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); | |||
|             } | |||
|             executeMethod(bizType, formDTO.getCustomerId(), formDTO.getDateId()); | |||
|             result.add(formDTO.getDateId()); | |||
|             redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus-"+bizType), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); | |||
|         } | |||
|         long end = System.currentTimeMillis(); | |||
|         long l = (end - start) / 1000; | |||
|         return new Result<String>().ok("userPointAndProjectStatus耗时-"+bizType + l + "s"); | |||
|     } | |||
| 
 | |||
|     private void executeMethod(String bizType, String customerId, String d) { | |||
|         if (bizType.equals(BizTypeEnum.USER.getType())){ | |||
|             this.extractUserPointData(customerId, d); | |||
|         } | |||
|         if (bizType.equals(BizTypeEnum.PROJECT.getType())) { | |||
|             this.agencyProjectStats(customerId, d); | |||
|         } | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * @Author sun | |||
|      * @Description 数据-项目-机关日(月)统计 | |||
|      **/ | |||
|     private Result agencyProjectStats(String customerId, String dateId) { | |||
|         try { | |||
|             if (StringUtils.isNotBlank(dateId)) { | |||
|                 dateId = DateUtils.format(DateUtils.parseDate(dateId, DateUtils.DATE_PATTERN_YYYYMMDD)); | |||
|             } | |||
|             StatsFormDTO formDTO = new StatsFormDTO(); | |||
|             formDTO.setCustomerId(customerId); | |||
|             formDTO.setDate(dateId); | |||
| 
 | |||
|             statsProjectService.agencyProjectStats(formDTO); | |||
|         } catch (Exception e) { | |||
|             log.error("市北-项目状态数据写入失败,参数为:{}" + customerId + StrConstant.HYPHEN + dateId, e); | |||
|         } | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     private void extractUserPointData(String customerId, String dateId) { | |||
|         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); | |||
|         } | |||
|     } | |||
| } | |||
| @ -0,0 +1,33 @@ | |||
| package com.epmet.task.ic; | |||
| 
 | |||
| 
 | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.epmet.commons.tools.enums.BizTypeEnum; | |||
| import com.epmet.commons.tools.utils.Result; | |||
| import com.epmet.dto.extract.form.ExtractOriginFormDTO; | |||
| import com.epmet.feign.DataStatisticalOpenFeignClient; | |||
| import com.epmet.task.ITask; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| 
 | |||
| /** | |||
|  * desc:数字社区私有化部署 任务之一还有【autoEvaluateDemandTask,statsDemandTask,dailyStatisticalVoteTask,IcPrivateDeploySupportUserPointTask】 | |||
|  */ | |||
| @Slf4j | |||
| @Component("icPrivateDeploySupportProjectTask") | |||
| public class IcPrivateDeploySupportProjectTask implements ITask { | |||
|     @Autowired | |||
|     private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; | |||
| 
 | |||
|     @Override | |||
|     public void run(String params) { | |||
|         ExtractOriginFormDTO formDTO = new ExtractOriginFormDTO(); | |||
|         if (StringUtils.isNotBlank(params)) { | |||
|             formDTO = JSON.parseObject(params, ExtractOriginFormDTO.class); | |||
|         } | |||
|         Result result = dataStatisticalOpenFeignClient.userPointAndProjectStatus(BizTypeEnum.PROJECT.getType(), formDTO); | |||
|         log.info("icPrivateDeploySupportProjectTask excute end,param:{},result:{}",params,result); | |||
|     } | |||
| } | |||
| @ -0,0 +1,33 @@ | |||
| package com.epmet.task.ic; | |||
| 
 | |||
| 
 | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.epmet.commons.tools.enums.BizTypeEnum; | |||
| import com.epmet.commons.tools.utils.Result; | |||
| import com.epmet.dto.extract.form.ExtractOriginFormDTO; | |||
| import com.epmet.feign.DataStatisticalOpenFeignClient; | |||
| import com.epmet.task.ITask; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| 
 | |||
| /** | |||
|  * desc:数字社区私有化部署 任务之一还有【autoEvaluateDemandTask,statsDemandTask,dailyStatisticalVoteTask,icPrivateDeploySupportProjectTask】 | |||
|  */ | |||
| @Slf4j | |||
| @Component("icPrivateDeploySupportUserPointTask") | |||
| public class IcPrivateDeploySupportUserPointTask implements ITask { | |||
|     @Autowired | |||
|     private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; | |||
| 
 | |||
|     @Override | |||
|     public void run(String params) { | |||
|         ExtractOriginFormDTO formDTO = new ExtractOriginFormDTO(); | |||
|         if (StringUtils.isNotBlank(params)) { | |||
|             formDTO = JSON.parseObject(params, ExtractOriginFormDTO.class); | |||
|         } | |||
|         Result result = dataStatisticalOpenFeignClient.userPointAndProjectStatus(BizTypeEnum.USER.getType(), formDTO); | |||
|         log.info("icPrivateDeploySupportUserPointTask excute end,param:{},result:{}",params,result); | |||
|     } | |||
| } | |||
					Loading…
					
					
				
		Reference in new issue