Browse Source

公众参与概况/公众参与排行榜根据areaCode检索(查找子客户列表返回失败时默认没有子客户)

master
wangchao 5 years ago
parent
commit
aca279ee52
  1. 5
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/GrassRootsGovernController.java
  2. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenPublicPartiTotalDataDao.java
  3. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenUserJoinDao.java
  4. 47
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java
  5. 9
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/PartyMemberLeadServiceImpl.java
  6. 6
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPioneerDataDao.xml
  7. 39
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPublicPartiTotalDataDao.xml
  8. 29
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml

5
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/GrassRootsGovernController.java

@ -8,10 +8,7 @@ import com.epmet.evaluationindex.screen.dto.form.AgencyFormDTO;
import com.epmet.evaluationindex.screen.dto.form.AgencyNumTypeParamFormDTO;
import com.epmet.evaluationindex.screen.dto.result.*;
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 org.springframework.web.bind.annotation.*;
import java.util.List;

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenPublicPartiTotalDataDao.java

@ -39,4 +39,16 @@ public interface ScreenPublicPartiTotalDataDao{
* @date 2020.08.20 16:00
**/
List<PublicPartiRankResultDTO> selectPublicPartiTotal(@Param("agencyId") String agencyId);
/**
* @Description 根据areaCode查询公众参与各类总数
* @param areaCode
* @return
* @author wangc
* @date 2020.08.20 16:00
**/
List<PublicPartiRankResultDTO> selectPublicPartiTotalByAreaCode(@Param("areaCode") String areaCode,
@Param("customerId")String customerId,
@Param("list")List<String> subCustomers);
}

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenUserJoinDao.java

@ -42,6 +42,18 @@ public interface ScreenUserJoinDao {
**/
UserJoinIndicatorGrowthRateResultDTO selectUserJoinData(@Param("agencyId") String agencyId, @Param("monthId")String monthId);
/**
* @Description 根据地区码查询用户参与数据
* @param areaCode
* @return
* @author wangc
* @date 2020.08.20 15:07
**/
UserJoinIndicatorGrowthRateResultDTO selectUserJoinDataByAreaCode(@Param("areaCode") String areaCode, @Param("monthId")String monthId,
@Param("list") List<String> subCustomers,
@Param("customerId")String customerId);
/**
* @Description 查询月度用户参与数据
* @param agencyId

47
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java

@ -3,16 +3,20 @@ package com.epmet.datareport.service.evaluationindex.screen.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant;
import com.epmet.datareport.dao.evaluationindex.screen.*;
import com.epmet.datareport.service.evaluationindex.screen.GrassRootsGovernService;
import com.epmet.datareport.utils.DateUtils;
import com.epmet.datareport.utils.ModuleConstant;
import com.epmet.dto.result.ScreenCustomerAgencyDTO;
import com.epmet.evaluationindex.screen.dto.form.AgencyAndNumFormDTO;
import com.epmet.evaluationindex.screen.dto.form.AgencyFormDTO;
import com.epmet.evaluationindex.screen.dto.form.AgencyNumTypeParamFormDTO;
import com.epmet.evaluationindex.screen.dto.result.*;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -48,6 +52,10 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService {
private ScreenGovernRankDataDao screenGovernRankDataDao;
@Autowired
private ScreenPublicPartiTotalDataDao screenPublicPartiTotalDataDao;
@Autowired
private OperCrmOpenFeignClient crmClient;
@Autowired
private ScreenCustomerAgencyDao agencyDao;
/**
* @Description 1热心市民积分排行
@ -110,15 +118,26 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService {
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override
public PublicPartiProfileResultDTO publicPartiProfile(AgencyFormDTO param) {
ScreenCustomerAgencyDTO agencyInfo = agencyInfo(param.getAgencyId());
Result<List<String>> crmResp = crmClient.getAllSubCustomerIds(agencyInfo.getCustomerId());
List<String> subCustomers;
if(null == crmResp || !crmResp.success()) {subCustomers = null ;}
else {subCustomers = crmResp.getData();}
String monthId = dateUtils.getCurrentMonthId();
UserJoinIndicatorGrowthRateResultDTO latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId);
UserJoinIndicatorGrowthRateResultDTO latest = CollectionUtils.isEmpty(subCustomers) ?
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) :
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId,
subCustomers,agencyInfo.getCustomerId());
//保证获取公众参与概率数据的最大可能性
int time = NumConstant.TWELVE;
while (null == latest && time > NumConstant.ONE) {
time--;
monthId = dateUtils.getPreviousMonthIdByDest(null, monthId);
latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId);
latest = CollectionUtils.isEmpty(subCustomers) ?
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) :
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId,
subCustomers,agencyInfo.getCustomerId());
}
if (null == latest) return new PublicPartiProfileResultDTO();
@ -146,8 +165,18 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService {
if(NumConstant.ZERO == param.getTopNum()){
param.setTopNum(NumConstant.MAX);
}
ScreenCustomerAgencyDTO agencyInfo = agencyInfo(param.getAgencyId()) ;
List<String> subCustomers;
Result<List<String>> crmResp = crmClient.getAllSubCustomerIds(agencyInfo.getCustomerId());
if(null == crmResp || !crmResp.success()) {subCustomers = null ;}
else {subCustomers = crmResp.getData();}
PageHelper.startPage(NumConstant.ONE,param.getTopNum());
List<PublicPartiRankResultDTO> result = screenPublicPartiTotalDataDao.selectPublicPartiTotal(param.getAgencyId());
List<PublicPartiRankResultDTO> result =
CollectionUtils.isEmpty(subCustomers) ?
screenPublicPartiTotalDataDao.selectPublicPartiTotal(param.getAgencyId())
: screenPublicPartiTotalDataDao.selectPublicPartiTotalByAreaCode(agencyInfo.getAreaCode(),agencyInfo.getCustomerId(),
subCustomers);
if(null == result) {
return new ArrayList<>();
}
@ -254,6 +283,18 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService {
return percentStr.concat(ModuleConstant.SYMBOL_PERCENT);
}
/**
* @Description 通过agencyId获取机关信息
* @param agencyId
* @return java.lang.String
* @author wangc
* @date 2021.02.25 13:46
*/
private ScreenCustomerAgencyDTO agencyInfo(String agencyId){
ScreenCustomerAgencyDTO agencyInfo = agencyDao.selectByAgencyId(agencyId);
if(null == agencyInfo) throw new RenException("获取Agency信息失败");
return agencyInfo;
}
}

9
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/PartyMemberLeadServiceImpl.java

@ -74,10 +74,11 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService {
areaCode = agencyInfo.getAreaCode();
}
Result<List<String>> crmResponse = operCrmOpenFeignClient.getAllSubCustomerIds(customerId);
if(null == crmResponse || !crmResponse.success()){
throw new RenException("获取子客户列表失败");
}
List<String> subCustomers = crmResponse.getData();
List<String> subCustomers;
if(null == crmResponse || !crmResponse.success())
{subCustomers = null;}
else
{subCustomers = crmResponse.getData();}
FineExampleResultDTO fineExampleResultDTO;
if(CollectionUtils.isEmpty(subCustomers))
fineExampleResultDTO = screenPioneerDataDao.selectFineExample(fineExampleFormDTO.getAgencyId());

6
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPioneerDataDao.xml

@ -55,9 +55,11 @@
data.del_flag = '0'
AND data.org_type = 'agency'
AND agency.area_code LIKE concat(#{areaCode},'%')
<foreach collection="list" item="subId" open="AND ( agency.customer_id = #{customerId} OR " separator=" OR " close=" )">
agency.customer_id = #{subId}
<if test=" null != list and list.size() > 0">
<foreach collection="list" item="subId" open="AND ( data.customer_id = #{customerId} OR " separator=" OR " close=" )">
data.customer_id = #{subId}
</foreach>
</if>
ORDER BY data.data_end_time DESC
LIMIT 1
</select>

39
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPublicPartiTotalDataDao.xml

@ -31,4 +31,43 @@
totalData.PROJECT_TOTAL desc
</select>
<!-- 查询公众参与各类总数 -->
<select id="selectPublicPartiTotalByAreaCode" resultType="com.epmet.evaluationindex.screen.dto.result.PublicPartiRankResultDTO">
SELECT
totalData.ORG_NAME AS NAME,
totalData.REG_USER_TOTAL AS regNum,
totalData.JOIN_USER_TOTAL AS joinNum,
totalData.TOPIC_TOTAL AS topicNum,
totalData.ISSUE_TOTAL AS issueNum,
totalData.PROJECT_TOTAL AS projectNum,
agency.AGENCY_NAME AS parentAgencyName
FROM
screen_public_parti_total_data totalData
LEFT JOIN
screen_customer_agency agency
ON totalData.PARENT_ID = agency.AGENCY_ID
AND agency.DEL_FLAG = '0'
WHERE
totalData.DEL_FLAG = '0'
AND
agency.AREA_CODE like concat(#{areaCode},'%')
<if test=" null != list and list.size() > 0">
<foreach collection="list" item="subId" open="AND ( totalData.customer_id = #{customerId} OR " separator=" OR " close=" )">
totalData.customer_id = #{subId}
</foreach>
</if>
ORDER BY
(totalData.REG_USER_TOTAL + totalData.JOIN_USER_TOTAL + totalData.TOPIC_TOTAL + totalData.ISSUE_TOTAL + totalData.PROJECT_TOTAL) DESC,
totalData.REG_USER_TOTAL desc,
totalData.JOIN_USER_TOTAL desc,
totalData.TOPIC_TOTAL desc,
totalData.ISSUE_TOTAL desc,
totalData.PROJECT_TOTAL desc
</select>
</mapper>

29
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml

@ -24,6 +24,35 @@
AND MONTH_ID = #{monthId}
</select>
<!-- 根据地区码查询用户参与数据 -->
<select id="selectUserJoinDataByAreaCode" resultType="com.epmet.evaluationindex.screen.dto.result.UserJoinIndicatorGrowthRateResultDTO">
SELECT
avg(data.JOIN_TOTAL) AS total,
ROUND( avg(data.AVG_JOIN), 1 ) AS averageJoin,
avg(data.JOIN_TOTAL_UP_RATE) AS monthIncr,
avg(data.JOIN_TOTAL_UP_FLAG) AS monthTrend,
ROUND(avg(data.AVG_ISSUE), 1) AS averageIssue,
avg(data.AVG_ISSUE_UP_RATE) AS issueCompareLatestMonth,
avg(data.AVG_ISSUE_UP_FLAG) AS issueCompareLatestTrend,
avg(data.AGVG_JOIN_UP_RATE) AS joinCompareLatestMonth,
avg(data.AGVG_JOIN_UP_FLAG) AS joinCompareLatestTrend
FROM
screen_user_join data
LEFT JOIN
screen_customer_agency agency
ON data.org_id = agency.agency_id
WHERE
data.DEL_FLAG = '0'
AND data.area_code like concat(#{areaCode},'%')
AND data.MONTH_ID = #{monthId}
<if test=" null != list and list.size() > 0">
<foreach collection="list" item="sub" open="AND ( data.customer_id = #{customerId} or" separator=" OR " close=")">
data.customerId = #{sub}
</foreach>
</if>
</select>
<!-- 查询用户参与月度数据 -->
<select id="selectUserJoinDataMonthly" resultType="com.epmet.evaluationindex.screen.dto.result.UserJoinMonthlyResultDTO">
<!-- 字段完全对不上 -->

Loading…
Cancel
Save