Browse Source

修改:

1.志愿者分布逻辑优化
master
wangxianzhang 4 years ago
parent
commit
5d64746211
  1. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java
  3. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java
  4. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java
  5. 31
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java
  6. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml
  7. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java
  8. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java

@ -10,6 +10,10 @@ import lombok.Data;
*/ */
@Data @Data
public class DemandServiceCountResultDTO { public class DemandServiceCountResultDTO {
// 服务者ID
private String serverId; private String serverId;
// 服务类型
private String serviceType; private String serviceType;
// 服务次数
private int serveTimes;
} }

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java

@ -40,5 +40,5 @@ public interface IcUserDemandServiceDao extends BaseDao<IcUserDemandServiceEntit
* @param customerId 客户id * @param customerId 客户id
* @param serviceType 服务者类型 * @param serviceType 服务者类型
*/ */
List<DemandServiceCountResultDTO> listDemandServiceCountPage(@Param("customerId") String customerId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType); List<DemandServiceCountResultDTO> listDemandServeTimes(@Param("customerId") String customerId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType);
} }

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java

@ -11,5 +11,5 @@ import java.util.List;
*@Date 2021/12/8 *@Date 2021/12/8
*/ */
public interface HeartDemandService { public interface HeartDemandService {
List<DemandServiceCountResultDTO> listDemandServiceCountPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize); List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize);
} }

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java

@ -29,11 +29,11 @@ public class HeartDemandServiceImpl implements HeartDemandService {
private IcUserDemandServiceDao demandServiceDao; private IcUserDemandServiceDao demandServiceDao;
@Override @Override
public List<DemandServiceCountResultDTO> listDemandServiceCountPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) { public List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) {
return PageHelper.startPage(serviceCountPageNo, serviceCountPageSize).doSelectPage(new ISelect() { return PageHelper.startPage(serviceCountPageNo, serviceCountPageSize).doSelectPage(new ISelect() {
@Override @Override
public void doSelect() { public void doSelect() {
demandServiceDao.listDemandServiceCountPage(customerId, endTime, "volunteer"); demandServiceDao.listDemandServeTimes(customerId, endTime, "volunteer");
} }
}); });
} }

31
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java

@ -101,7 +101,7 @@ public class DemandServiceImpl implements DemandService {
// 分片开始下标 // 分片开始下标
int shardingStartIndex = 0; int shardingStartIndex = 0;
// 分片大小(条数) // 分片大小(条数)
int shardingSize = 2; int shardingSize = 100;
// 分片去确定党员身份,防止in条件过大 // 分片去确定党员身份,防止in条件过大
while (true) { while (true) {
@ -130,43 +130,44 @@ public class DemandServiceImpl implements DemandService {
//2. 查询志愿者服务次数 //2. 查询志愿者服务次数
// 总服务次数 // 总服务次数
int totalDemandServiceCount = 0; int totalDemandServeTimes = 0;
// 党员服务次数 // 党员服务次数
int partymemberDemandServiceCount = 0; int partymemberDemandServeTimes = 0;
// 居民服务次数 // 居民服务次数
int resiDemandServiceCount = 0; int resiDemandServeTimes = 0;
int serviceCountPageNo = 0; int serviceCountPageNo = 0;
int serviceCountPageSize = 1000; int serviceCountPageSize = 1000;
while (true) { while (true) {
List<DemandServiceCountResultDTO> damendServiceCounts = heartDemandService.listDemandServiceCountPage(customerId, endTime, serviceCountPageNo, serviceCountPageSize); // 取出每一个服务者的服务次数
List<DemandServiceCountResultDTO> damendServeTimes = heartDemandService.listDemandServeTimesPage(customerId, endTime, serviceCountPageNo, serviceCountPageSize);
for (DemandServiceCountResultDTO damendServiceCount : damendServiceCounts) { for (DemandServiceCountResultDTO damendServiceTimes : damendServeTimes) {
String serverId = damendServiceCount.getServerId(); String serverId = damendServiceTimes.getServerId();
if (partymemberVolunteerUserIds.contains(serverId)) { if (partymemberVolunteerUserIds.contains(serverId)) {
partymemberDemandServiceCount++; partymemberDemandServeTimes += damendServiceTimes.getServeTimes();
} else { } else {
resiDemandServiceCount++; resiDemandServeTimes += damendServiceTimes.getServeTimes();
} }
} }
totalDemandServiceCount += damendServiceCounts.size(); if (damendServeTimes.size() <= serviceCountPageSize) {
if (damendServiceCounts.size() <= serviceCountPageSize) {
break; break;
} }
} }
totalDemandServeTimes = partymemberDemandServeTimes + resiDemandServeTimes;
// 3.持久化 // 3.持久化
FactVolunteerServiceDailyEntity insert = new FactVolunteerServiceDailyEntity(); FactVolunteerServiceDailyEntity insert = new FactVolunteerServiceDailyEntity();
insert.setDateId(DimIdGenerator.getDateDimId(belongTime)); insert.setDateId(DimIdGenerator.getDateDimId(belongTime));
insert.setCustomerId(customerId); insert.setCustomerId(customerId);
insert.setMonthId(DimIdGenerator.getMonthDimId(belongTime)); insert.setMonthId(DimIdGenerator.getMonthDimId(belongTime));
insert.setPartyServiceTotal(partymemberDemandServiceCount); insert.setPartyServiceTotal(partymemberDemandServeTimes);
insert.setServiceTotal(totalDemandServiceCount); insert.setServiceTotal(totalDemandServeTimes);
insert.setPartyTotal(partymemberVolunteerCount); insert.setPartyTotal(partymemberVolunteerCount);
insert.setResiServiceTotal(resiDemandServiceCount); insert.setResiServiceTotal(resiDemandServeTimes);
insert.setResiTotal(resiVolunteerCount); insert.setResiTotal(resiVolunteerCount);
insert.setVolunteerTotal(volunteerTotalCount); insert.setVolunteerTotal(volunteerTotalCount);

7
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml

@ -20,14 +20,15 @@
<result property="updatedTime" column="UPDATED_TIME"/> <result property="updatedTime" column="UPDATED_TIME"/>
</resultMap> </resultMap>
<select id="listDemandServiceCountPage" resultType="com.epmet.dto.heart.result.DemandServiceCountResultDTO"> <select id="listDemandServeTimes" resultType="com.epmet.dto.heart.result.DemandServiceCountResultDTO">
select service.SERVER_ID, SERVICE_TYPE select service.SERVER_ID, SERVICE_TYPE, count(1) as SERVE_TIMES
from ic_user_demand_rec damend from ic_user_demand_rec damend
inner join ic_user_demand_service service on (damend.ID = service.DEMAND_REC_ID and service.DEL_FLAG = 0) inner join ic_user_demand_service service on (damend.ID = service.DEMAND_REC_ID and service.DEL_FLAG = 0)
where damend.DEL_FLAG = 0 where damend.DEL_FLAG = 0
and damend.STATUS = 'finished' and damend.STATUS = 'finished'
and damend.REPORT_TIME <![CDATA[<]]> #{endTime}
and damend.CUSTOMER_ID = #{customerId} and damend.CUSTOMER_ID = #{customerId}
and service.SERVICE_END_TIME <![CDATA[<]]> #{endTime}
and service.SERVICE_TYPE = #{serviceType} and service.SERVICE_TYPE = #{serviceType}
group by service.SERVER_ID, SERVICE_TYPE
</select> </select>
</mapper> </mapper>

6
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java

@ -29,11 +29,6 @@ public class VolunteerController {
@Autowired @Autowired
private VolunteerService volunteerService; private VolunteerService volunteerService;
//public VolunteerController(VolunteerService volunteerService, IcResiUserDao icResiUserDao, GovOrgOpenFeignClient govOrgOpenFeignClient) {
// this.volunteerService = volunteerService;
// System.out.println(this);
//}
/** /**
* 志愿者分布查询 * 志愿者分布查询
* *
@ -42,7 +37,6 @@ public class VolunteerController {
*/ */
@PostMapping("distribution") @PostMapping("distribution")
public Result<VolunteerDistributionResultDTO> getVolunteerDistribution(@RequestBody VolunteerCommonFormDTO input) { public Result<VolunteerDistributionResultDTO> getVolunteerDistribution(@RequestBody VolunteerCommonFormDTO input) {
System.out.println(this);
ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.GetVolunteerDistribution.class); ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.GetVolunteerDistribution.class);
String customerId = input.getCustomerId(); String customerId = input.getCustomerId();

13
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

@ -141,15 +141,16 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve
continue; continue;
} }
List<String> volunteer = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId()); // 查询志愿者类别
if (CollectionUtils.isEmpty(volunteer)) { List<String> volunteerCategories = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId());
// 此人没有志愿者信息 //if (CollectionUtils.isEmpty(volunteerCategories)) {
continue; // // 此人没有志愿者信息
} // continue;
//}
// 将志愿者类型列表字符串,切割放到set中 // 将志愿者类型列表字符串,切割放到set中
Set<String> volunteerTypes = new HashSet(); Set<String> volunteerTypes = new HashSet();
for (String vTypesString : volunteer) { for (String vTypesString : volunteerCategories) {
String[] vTypes = vTypesString.split(","); String[] vTypes = vTypesString.split(",");
if (vTypes != null && vTypes.length > 0) { if (vTypes != null && vTypes.length > 0) {
volunteerTypes.addAll(Arrays.asList(vTypes)); volunteerTypes.addAll(Arrays.asList(vTypes));

Loading…
Cancel
Save