forked from luyan/epmet-cloud-lingshan
				
			
				 4 changed files with 148 additions and 0 deletions
			
			
		@ -0,0 +1,101 @@ | 
				
			|||||
 | 
					package com.epmet.controller; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.constant.NumConstant; | 
				
			||||
 | 
					import com.epmet.commons.tools.constant.StrConstant; | 
				
			||||
 | 
					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.PostMapping; | 
				
			||||
 | 
					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.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") | 
				
			||||
 | 
					    public Result<String> userPointAndProjectStatus(@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 -> { | 
				
			||||
 | 
					                this.extractUserPointData(formDTO.getCustomerId(), d); | 
				
			||||
 | 
					                this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId()); | 
				
			||||
 | 
					                result.add(d); | 
				
			||||
 | 
					                redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); | 
				
			||||
 | 
					            }); | 
				
			||||
 | 
					        } else { | 
				
			||||
 | 
					            if (StringUtils.isBlank(formDTO.getDateId())){ | 
				
			||||
 | 
					                formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); | 
				
			||||
 | 
					            } | 
				
			||||
 | 
					            this.extractUserPointData(formDTO.getCustomerId(), formDTO.getDateId()); | 
				
			||||
 | 
					            this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId()); | 
				
			||||
 | 
					            result.add(formDTO.getDateId()); | 
				
			||||
 | 
					            redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					        long end = System.currentTimeMillis(); | 
				
			||||
 | 
					        long l = (end - start) / 1000; | 
				
			||||
 | 
					        return new Result<String>().ok("userPointAndProjectStatus耗时" + l + "s"); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * @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,31 @@ | 
				
			|||||
 | 
					package com.epmet.task; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.alibaba.fastjson.JSON; | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			||||
 | 
					import com.epmet.dto.extract.form.ExtractOriginFormDTO; | 
				
			||||
 | 
					import com.epmet.feign.DataStatisticalOpenFeignClient; | 
				
			||||
 | 
					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】 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Slf4j | 
				
			||||
 | 
					@Component("icPrivateDeploySupportTask") | 
				
			||||
 | 
					public class IcPrivateDeploySupportTask 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(formDTO); | 
				
			||||
 | 
					        log.info("IcPrivateDeploySupportTask excute end,param:{},result:{}",params,result); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue