Browse Source
Conflicts: epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.javadev
44 changed files with 497 additions and 65 deletions
@ -0,0 +1,34 @@ |
|||||
|
package com.epmet.evaluationindex.screen.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @Description 市北数字社区-组织先进排行榜 查询结果dto |
||||
|
* @ClassName OrgRankDataResultDTO |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-08-21 11:16 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OrgRankDataShibeiResultDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -7874641768141936572L; |
||||
|
|
||||
|
private String orgId; |
||||
|
/** |
||||
|
* 名称 XXXX社区党委 |
||||
|
* */ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 党员数 |
||||
|
* */ |
||||
|
private BigDecimal score; |
||||
|
|
||||
|
/** |
||||
|
* 数据所属月份 |
||||
|
*/ |
||||
|
private String monthId; |
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.datareport.dao.evaluationindex.screen; |
||||
|
|
||||
|
import com.epmet.evaluationindex.screen.dto.form.AdvancedBranchRankFormDTO; |
||||
|
import com.epmet.evaluationindex.screen.dto.result.OrgRankDataShibeiResultDTO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 党建引领-组织排行榜 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-08-18 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface ScreenOrgRankDataShibeiDao { |
||||
|
|
||||
|
/** |
||||
|
* @return |
||||
|
* @Description 查询指定机关的所有直属网格月度数据 |
||||
|
* @author wangc |
||||
|
* @date 2020.08.21 13:58 |
||||
|
**/ |
||||
|
List<OrgRankDataShibeiResultDTO> selectGridRankList(AdvancedBranchRankFormDTO formDTO); |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.epmet.datareport.dao.evaluationindex.screen.ScreenOrgRankDataShibeiDao"> |
||||
|
|
||||
|
<!-- 查询指定机关的直属网格月度数据 --> |
||||
|
<select id="selectGridRankList" resultType="com.epmet.evaluationindex.screen.dto.result.OrgRankDataShibeiResultDTO"> |
||||
|
SELECT |
||||
|
rankData.ORG_NAME AS NAME, |
||||
|
round(rankData.SCORE,1) score, |
||||
|
rankData.ORG_ID as orgId, |
||||
|
rankData.MONTH_ID |
||||
|
FROM |
||||
|
screen_org_rank_data_shibei rankData |
||||
|
LEFT JOIN screen_customer_agency agency |
||||
|
ON rankData.PARENT_ID = agency.AGENCY_ID AND agency.DEL_FLAG = 0 |
||||
|
WHERE |
||||
|
rankData.DEL_FLAG = '0' |
||||
|
AND rankData.ORG_TYPE = 'grid' |
||||
|
AND rankData.ALL_PARENT_IDS LIKE CONCAT('%',#{agencyId},'%') |
||||
|
AND rankData.MONTH_ID = #{monthId} |
||||
|
AND rankData.CUSTOMER_ID = #{customerId} |
||||
|
ORDER BY |
||||
|
rankData.SCORE DESC |
||||
|
LIMIT #{topNum} |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
</mapper> |
@ -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 void 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); |
||||
|
} |
||||
|
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