169 changed files with 3970 additions and 201 deletions
@ -0,0 +1,19 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 需求完成,如果服务方是区域化党建单位,重新计算这个单位的满意度,或者直接计算整个客户 |
|||
*/ |
|||
@Data |
|||
public class CalPartyUnitSatisfactionFormDTO implements Serializable { |
|||
public interface AddUserInternalGroup { |
|||
} |
|||
@NotBlank(message = "客户id不能为空",groups = AddUserInternalGroup.class) |
|||
private String customerId; |
|||
private String partyUnitId; |
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.epmet.dto.result.heart; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 描述 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/10 4:24 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Data |
|||
public class VolunteerDemandServiceStatsResultDTO { |
|||
|
|||
private String customerId; |
|||
private String dateId; |
|||
/** |
|||
* 客户下志愿者总数 |
|||
*/ |
|||
private Integer volunteerTotal; |
|||
/** |
|||
* 客户下志愿者中,党员数量 |
|||
*/ |
|||
private Integer partyTotal; |
|||
/** |
|||
* 客户下志愿者中,居民数量 |
|||
*/ |
|||
private Integer resiTotal; |
|||
/** |
|||
* 客户下志愿者服务总次数 |
|||
*/ |
|||
private Integer serviceTotal; |
|||
/** |
|||
* 客户下党员志愿者服务次数 |
|||
*/ |
|||
private Integer partyServiceTotal; |
|||
/** |
|||
* 客户下居民志愿者服务次数 |
|||
*/ |
|||
private Integer resiServiceTotal; |
|||
|
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.epmet.datareport.controller.heart; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.datareport.service.heart.DemandService; |
|||
import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @Description 描述 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/10 3:55 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("heart/demand") |
|||
public class DataReportHeartDemandController { |
|||
|
|||
@Autowired |
|||
private DemandService demandService; |
|||
|
|||
/** |
|||
* 查询志愿者需求服务统计信息 |
|||
* @param loginUser |
|||
* @return |
|||
*/ |
|||
@PostMapping("volunteer/service") |
|||
public Result<VolunteerDemandServiceStatsResultDTO> getVolunteerServiceStats(@LoginUser TokenDto loginUser) { |
|||
String customerId = loginUser.getCustomerId(); |
|||
VolunteerDemandServiceStatsResultDTO r = demandService.getVolunteerServiceStats(customerId); |
|||
return new Result<VolunteerDemandServiceStatsResultDTO>().ok(r); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,43 @@ |
|||
/** |
|||
* 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.fact; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.datareport.entity.heart.FactVolunteerServiceDailyEntity; |
|||
import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 志愿者服务情况统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-12-08 |
|||
*/ |
|||
@Mapper |
|||
public interface FactVolunteerServiceDailyDao extends BaseDao<FactVolunteerServiceDailyEntity> { |
|||
|
|||
/** |
|||
* 查询最新一条"志愿者需求服务统计信息" |
|||
* @param customerId |
|||
* @return |
|||
*/ |
|||
VolunteerDemandServiceStatsResultDTO getLatestVolunteerDemandServiceStats(@Param("customerId") String customerId); |
|||
} |
@ -0,0 +1,83 @@ |
|||
/** |
|||
* 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.entity.heart; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 志愿者服务情况统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-12-08 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("fact_volunteer_service_daily") |
|||
public class FactVolunteerServiceDailyEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* yyyyMMdd |
|||
*/ |
|||
private String dateId; |
|||
|
|||
/** |
|||
* yyyyMM |
|||
*/ |
|||
private String monthId; |
|||
|
|||
/** |
|||
* 截止到当前dateId,当前客户下,共有多少个爱心互助的志愿者 |
|||
*/ |
|||
private Integer volunteerTotal; |
|||
|
|||
/** |
|||
* 截止到当前dateId,当前客户下,XX个爱心互助志愿者中,党员有多少个 |
|||
*/ |
|||
private Integer partyTotal; |
|||
|
|||
/** |
|||
* 截止到当前dateId,当前客户下,XX个爱心互助志愿者中,居民有多少个 |
|||
*/ |
|||
private Integer resiTotal; |
|||
|
|||
/** |
|||
* 服务总次数 |
|||
*/ |
|||
private Integer serviceTotal; |
|||
|
|||
/** |
|||
* 党员服务总次数 |
|||
*/ |
|||
private Integer partyServiceTotal; |
|||
|
|||
/** |
|||
* 居民服务总次数 |
|||
*/ |
|||
private Integer resiServiceTotal; |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.datareport.service.heart; |
|||
|
|||
import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; |
|||
|
|||
/** |
|||
* @Description 需求服务 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/10 4:18 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
public interface DemandService { |
|||
VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId); |
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.epmet.datareport.service.heart.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.datareport.dao.fact.FactVolunteerServiceDailyDao; |
|||
import com.epmet.datareport.entity.heart.FactVolunteerServiceDailyEntity; |
|||
import com.epmet.datareport.service.heart.DemandService; |
|||
import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @Description 需求服务 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/10 4:20 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Service |
|||
public class DemandServiceImpl implements DemandService { |
|||
|
|||
@Autowired |
|||
private FactVolunteerServiceDailyDao factVolunteerServiceDailyDao; |
|||
|
|||
@Override |
|||
public VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId) { |
|||
return factVolunteerServiceDailyDao.getLatestVolunteerDemandServiceStats(customerId); |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
<?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.fact.FactVolunteerServiceDailyDao"> |
|||
|
|||
<resultMap type="com.epmet.datareport.entity.heart.FactVolunteerServiceDailyEntity" id="factVolunteerServiceDailyMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="dateId" column="DATE_ID"/> |
|||
<result property="monthId" column="MONTH_ID"/> |
|||
<result property="volunteerTotal" column="VOLUNTEER_TOTAL"/> |
|||
<result property="partyTotal" column="PARTY_TOTAL"/> |
|||
<result property="resiTotal" column="RESI_TOTAL"/> |
|||
<result property="serviceTotal" column="SERVICE_TOTAL"/> |
|||
<result property="partyServiceTotal" column="PARTY_SERVICE_TOTAL"/> |
|||
<result property="resiServiceTotal" column="RESI_SERVICE_TOTAL"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<select id="getLatestVolunteerDemandServiceStats" |
|||
resultType="com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO"> |
|||
select * |
|||
from fact_volunteer_service_daily |
|||
where DEL_FLAG = 0 |
|||
and CUSTOMER_ID = #{customerId} |
|||
order by DATE_ID desc |
|||
limit 1 |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,19 @@ |
|||
package com.epmet.dto.heart.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 描述 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/8 4:39 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Data |
|||
public class DemandServiceCountResultDTO { |
|||
// 服务者ID
|
|||
private String serverId; |
|||
// 服务类型
|
|||
private String serviceType; |
|||
// 服务次数
|
|||
private int serveTimes; |
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.service.DemandService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
/** |
|||
* @Description 描述 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/8 10:44 上午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("demand") |
|||
public class DemandController { |
|||
|
|||
@Autowired |
|||
private DemandService demandStatsService; |
|||
|
|||
/** |
|||
* wangxianzhang |
|||
* |
|||
* 计算客户下志愿者服务相关数据 |
|||
* |
|||
* @param customerId 客户ID,可以为空,为空则计算所有客户 |
|||
* @return |
|||
*/ |
|||
@PostMapping("volunteer/daily") |
|||
public Result statsVolunteerDemandServicesDaily(@RequestParam(value = "customer-id", required = false) String customerId) { |
|||
|
|||
demandStatsService.statsVolunteerDemandServicesDaily(customerId); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
/** |
|||
* 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.dao.heart; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.heart.result.DemandServiceCountResultDTO; |
|||
import com.epmet.entity.heart.IcUserDemandServiceEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 居民需求服务记录表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-11-19 |
|||
*/ |
|||
@Mapper |
|||
public interface IcUserDemandServiceDao extends BaseDao<IcUserDemandServiceEntity> { |
|||
|
|||
/** |
|||
* 需求服务次数查询 |
|||
* @param customerId 客户id |
|||
* @param serviceType 服务者类型 |
|||
*/ |
|||
List<DemandServiceCountResultDTO> listDemandServeTimes(@Param("customerId") String customerId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType); |
|||
} |
@ -0,0 +1,33 @@ |
|||
/** |
|||
* 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.dao.heart; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.heart.VolunteerInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 志愿者信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-12-08 |
|||
*/ |
|||
@Mapper |
|||
public interface VolunteerInfoDao extends BaseDao<VolunteerInfoEntity> { |
|||
|
|||
} |
@ -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.dao.stats; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 志愿者服务情况统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-12-08 |
|||
*/ |
|||
@Mapper |
|||
public interface FactVolunteerServiceDailyDao extends BaseDao<FactVolunteerServiceDailyEntity> { |
|||
|
|||
/** |
|||
* 删除指定客户,指定dateId的志愿者服务统计记录 |
|||
* @param customerIds |
|||
* @param dateDimId |
|||
*/ |
|||
void clearVolunteerDemandServiceDailyStats(@Param("customerIds") List<String> customerIds, @Param("dateDimId") String dateDimId); |
|||
} |
@ -0,0 +1,75 @@ |
|||
/** |
|||
* 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.entity.heart; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 居民需求服务记录表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-11-19 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_user_demand_service") |
|||
public class IcUserDemandServiceEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 需求id |
|||
*/ |
|||
private String demandRecId; |
|||
|
|||
/** |
|||
* 服务方类型:志愿者:volunteer;社会组织:social_org;社区自组织:community_org;区域党建单位:party_unit; |
|||
*/ |
|||
private String serviceType; |
|||
|
|||
/** |
|||
* 志愿者:居民端爱心互助的志愿者userId; |
|||
*/ |
|||
private String serverId; |
|||
|
|||
/** |
|||
* 实际服务开始时间 |
|||
*/ |
|||
private Date serviceStartTime; |
|||
|
|||
/** |
|||
* 实际服务结束时间 |
|||
*/ |
|||
private Date serviceEndTime; |
|||
|
|||
/** |
|||
* 完成情况 |
|||
*/ |
|||
private String finishDesc; |
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
/** |
|||
* 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.entity.heart; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 志愿者信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-12-08 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("volunteer_info") |
|||
public class VolunteerInfoEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 用户id |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 志愿者自我介绍 |
|||
*/ |
|||
private String volunteerIntroduce; |
|||
|
|||
/** |
|||
* 志愿者签名 |
|||
*/ |
|||
private String volunteerSignature; |
|||
|
|||
/** |
|||
* 网格id |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 网格名称 |
|||
*/ |
|||
private String gridName; |
|||
|
|||
} |
@ -0,0 +1,86 @@ |
|||
/** |
|||
* 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.entity.stats; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 志愿者服务情况统计 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-12-08 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("fact_volunteer_service_daily") |
|||
public class FactVolunteerServiceDailyEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* yyyyMMdd |
|||
*/ |
|||
private String dateId; |
|||
|
|||
/** |
|||
* yyyyMM |
|||
*/ |
|||
private String monthId; |
|||
|
|||
/** |
|||
* 截止到当前dateId,当前客户下,共有多少个爱心互助的志愿者 |
|||
*/ |
|||
private Integer volunteerTotal; |
|||
|
|||
/** |
|||
* 截止到当前dateId,当前客户下,XX个爱心互助志愿者中,党员有多少个 |
|||
*/ |
|||
private Integer partyTotal; |
|||
|
|||
/** |
|||
* 截止到当前dateId,当前客户下,XX个爱心互助志愿者中,居民有多少个 |
|||
*/ |
|||
private Integer resiTotal; |
|||
|
|||
/** |
|||
* 服务总次数 |
|||
*/ |
|||
private Integer serviceTotal; |
|||
|
|||
/** |
|||
* 党员服务总次数 |
|||
*/ |
|||
private Integer partyServiceTotal; |
|||
|
|||
/** |
|||
* 居民服务总次数 |
|||
*/ |
|||
private Integer resiServiceTotal; |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.service; |
|||
|
|||
/** |
|||
* @Description 需求service |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/8 12:14 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
public interface DemandService { |
|||
|
|||
/** |
|||
* wangxianzhang |
|||
* |
|||
* 按日统计 |
|||
* |
|||
* @param customerId 客户ID,可为空,为空计算所有 |
|||
*/ |
|||
void statsVolunteerDemandServicesDaily(String customerId); |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.epmet.service.heart; |
|||
|
|||
import com.epmet.dto.heart.result.DemandServiceCountResultDTO; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
*@Description 爱心互助,需求service |
|||
*@Author wangxianzhang |
|||
*@Date 2021/12/8 |
|||
*/ |
|||
public interface HeartDemandService { |
|||
List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize); |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.epmet.service.heart; |
|||
|
|||
import com.epmet.entity.heart.VolunteerInfoEntity; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
*@Description heart 志愿者service |
|||
*@Author wangxianzhang |
|||
*@Date 2021/12/8 |
|||
*/ |
|||
public interface HeartVolunteerService { |
|||
List<VolunteerInfoEntity> listVolunteers(String customerId, Date endCreateTime); |
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.epmet.service.heart.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.dao.heart.IcUserDemandServiceDao; |
|||
import com.epmet.dto.heart.result.DemandServiceCountResultDTO; |
|||
import com.epmet.service.heart.HeartDemandService; |
|||
import com.github.pagehelper.ISelect; |
|||
import com.github.pagehelper.Page; |
|||
import com.github.pagehelper.PageHelper; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 爱心互助,需求service |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/8 12:33 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Service |
|||
@DataSource(DataSourceConstant.EPMET_HEART) |
|||
public class HeartDemandServiceImpl implements HeartDemandService { |
|||
|
|||
@Autowired |
|||
private IcUserDemandServiceDao demandServiceDao; |
|||
|
|||
@Override |
|||
public List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) { |
|||
return PageHelper.startPage(serviceCountPageNo, serviceCountPageSize).doSelectPage(new ISelect() { |
|||
@Override |
|||
public void doSelect() { |
|||
demandServiceDao.listDemandServeTimes(customerId, endTime, "volunteer"); |
|||
} |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.epmet.service.heart.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.dao.heart.VolunteerInfoDao; |
|||
import com.epmet.entity.heart.VolunteerInfoEntity; |
|||
import com.epmet.service.heart.HeartVolunteerService; |
|||
import com.github.pagehelper.ISelect; |
|||
import com.github.pagehelper.Page; |
|||
import com.github.pagehelper.PageHelper; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 描述 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/8 1:35 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Service |
|||
@DataSource(DataSourceConstant.EPMET_HEART) |
|||
public class HeartVolunteerServiceImpl implements HeartVolunteerService { |
|||
|
|||
@Autowired |
|||
private VolunteerInfoDao volunteerInfoDao; |
|||
|
|||
@Override |
|||
public List<VolunteerInfoEntity> listVolunteers(String customerId, Date endCreateTime) { |
|||
LambdaQueryWrapper<VolunteerInfoEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(VolunteerInfoEntity::getCustomerId, customerId); |
|||
query.lt(VolunteerInfoEntity::getCreatedTime, endCreateTime); |
|||
return volunteerInfoDao.selectList(query); |
|||
} |
|||
} |
@ -0,0 +1,176 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.dto.heart.result.DemandServiceCountResultDTO; |
|||
import com.epmet.entity.crm.CustomerEntity; |
|||
import com.epmet.entity.heart.VolunteerInfoEntity; |
|||
import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; |
|||
import com.epmet.service.DemandService; |
|||
import com.epmet.service.crm.CustomerService; |
|||
import com.epmet.service.heart.HeartDemandService; |
|||
import com.epmet.service.heart.HeartVolunteerService; |
|||
import com.epmet.service.stats.DemandStatsService; |
|||
import com.epmet.service.user.UserService; |
|||
import com.epmet.util.DimIdGenerator; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Description 需求service |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/8 12:14 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Service |
|||
public class DemandServiceImpl implements DemandService { |
|||
|
|||
@Autowired |
|||
private HeartDemandService heartDemandService; |
|||
|
|||
@Autowired |
|||
private HeartVolunteerService heartVolunteerService; |
|||
|
|||
@Autowired |
|||
private UserService userService; |
|||
|
|||
@Autowired |
|||
private DemandStatsService demandStatsService; |
|||
|
|||
@Autowired |
|||
private CustomerService customerService; |
|||
|
|||
@Override |
|||
public void statsVolunteerDemandServicesDaily(String customerId) { |
|||
|
|||
Date now = new Date(); |
|||
Date today = DateUtils.integrate(now, "yyyy-MM-dd"); |
|||
Date yestoday = DateUtils.addDateDays(today, -1); |
|||
|
|||
if (StringUtils.isNotBlank(customerId)) { |
|||
// 只计算单个客户
|
|||
clearOldDatas(Arrays.asList(customerId), yestoday); |
|||
statsVolunteerDemandServicesDaily4Customer(customerId, today, yestoday); |
|||
} else { |
|||
// 查询所有客户ID
|
|||
List<String> customerIds = customerService.listValidCustomersByCreateTime(null, null).stream().map(c -> c.getId()).collect(Collectors.toList()); |
|||
clearOldDatas(customerIds, yestoday); |
|||
customerIds.stream().forEach(cId -> { |
|||
statsVolunteerDemandServicesDaily4Customer(cId, today, yestoday); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 清理旧数据 |
|||
* @param targetDate 要清理哪天的数据 |
|||
* @param customerIds 要清理哪些客户的 |
|||
*/ |
|||
private void clearOldDatas(List<String> customerIds, Date targetDate) { |
|||
|
|||
String dateDimId = DimIdGenerator.getDateDimId(targetDate); |
|||
|
|||
demandStatsService.clearVolunteerDemandServiceDailyStats(customerIds, dateDimId); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 统计单个客户的志愿者服务情况 |
|||
* @param customerId 客户ID |
|||
* @param endTime 统计截止时间(<endTime) |
|||
*/ |
|||
private void statsVolunteerDemandServicesDaily4Customer(String customerId, Date endTime, Date belongTime) { |
|||
// 1.志愿者分流为党员志愿者&普通居民志愿者
|
|||
Integer volunteerTotalCount = 0; |
|||
// 党员志愿者数量
|
|||
Integer partymemberVolunteerCount = 0; |
|||
// 居民志愿者数量
|
|||
Integer resiVolunteerCount = 0; |
|||
|
|||
// 党员志愿者用户id列表
|
|||
List<String> partymemberVolunteerUserIds = new ArrayList<>(16); |
|||
|
|||
List<VolunteerInfoEntity> volunteers = heartVolunteerService.listVolunteers(customerId, endTime); |
|||
|
|||
volunteerTotalCount = volunteers.size(); |
|||
|
|||
// 分片开始下标
|
|||
int shardingStartIndex = 0; |
|||
// 分片大小(条数)
|
|||
int shardingSize = 100; |
|||
|
|||
// 分片去确定党员身份,防止in条件过大
|
|||
while (true) { |
|||
int realShardingSize = Math.min(shardingSize, volunteerTotalCount - shardingStartIndex); |
|||
|
|||
if (realShardingSize <= 0) { |
|||
break; |
|||
} |
|||
|
|||
int shardingEndIndex = shardingStartIndex + realShardingSize; |
|||
List<String> volunteerUserIds = volunteers.subList(shardingStartIndex, shardingEndIndex) |
|||
.stream() |
|||
.map((volunteerInfoEntity) -> volunteerInfoEntity.getUserId()) |
|||
.collect(Collectors.toList()); |
|||
|
|||
List<String> tempPartymemberUserIds = userService.filterUserIds(volunteerUserIds, EpmetRoleKeyConstant.PARTYMEMBER); |
|||
|
|||
partymemberVolunteerUserIds.addAll(tempPartymemberUserIds); |
|||
|
|||
shardingStartIndex = shardingEndIndex; |
|||
} |
|||
|
|||
partymemberVolunteerCount = partymemberVolunteerUserIds.size(); |
|||
resiVolunteerCount = volunteerTotalCount - partymemberVolunteerCount; |
|||
|
|||
//2. 查询志愿者服务次数
|
|||
|
|||
// 总服务次数
|
|||
int totalDemandServeTimes = 0; |
|||
// 党员服务次数
|
|||
int partymemberDemandServeTimes = 0; |
|||
// 居民服务次数
|
|||
int resiDemandServeTimes = 0; |
|||
|
|||
int serviceCountPageNo = 0; |
|||
int serviceCountPageSize = 1000; |
|||
while (true) { |
|||
|
|||
// 取出每一个服务者的服务次数
|
|||
List<DemandServiceCountResultDTO> damendServeTimes = heartDemandService.listDemandServeTimesPage(customerId, endTime, serviceCountPageNo, serviceCountPageSize); |
|||
|
|||
for (DemandServiceCountResultDTO damendServiceTimes : damendServeTimes) { |
|||
String serverId = damendServiceTimes.getServerId(); |
|||
if (partymemberVolunteerUserIds.contains(serverId)) { |
|||
partymemberDemandServeTimes += damendServiceTimes.getServeTimes(); |
|||
} else { |
|||
resiDemandServeTimes += damendServiceTimes.getServeTimes(); |
|||
} |
|||
} |
|||
|
|||
if (damendServeTimes.size() <= serviceCountPageSize) { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
totalDemandServeTimes = partymemberDemandServeTimes + resiDemandServeTimes; |
|||
|
|||
// 3.持久化
|
|||
FactVolunteerServiceDailyEntity insert = new FactVolunteerServiceDailyEntity(); |
|||
insert.setDateId(DimIdGenerator.getDateDimId(belongTime)); |
|||
insert.setCustomerId(customerId); |
|||
insert.setMonthId(DimIdGenerator.getMonthDimId(belongTime)); |
|||
insert.setPartyServiceTotal(partymemberDemandServeTimes); |
|||
insert.setServiceTotal(totalDemandServeTimes); |
|||
insert.setPartyTotal(partymemberVolunteerCount); |
|||
insert.setResiServiceTotal(resiDemandServeTimes); |
|||
insert.setResiTotal(resiVolunteerCount); |
|||
insert.setVolunteerTotal(volunteerTotalCount); |
|||
|
|||
demandStatsService.addVolunteerServiceDaily(insert); |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
package com.epmet.service.stats; |
|||
|
|||
import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
*@Description 统计客户下的志愿者需求服务数据 |
|||
*@Author wangxianzhang |
|||
*@Date 2021/12/8 |
|||
*/ |
|||
public interface DemandStatsService { |
|||
|
|||
|
|||
void addVolunteerServiceDaily(FactVolunteerServiceDailyEntity entity); |
|||
|
|||
void clearVolunteerDemandServiceDailyStats(List<String> customerIds, String dateDimId); |
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.epmet.service.stats.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.dao.stats.FactVolunteerServiceDailyDao; |
|||
import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; |
|||
import com.epmet.service.stats.DemandStatsService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 描述 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/8 10:54 上午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Service |
|||
@DataSource(DataSourceConstant.STATS) |
|||
public class DemandStatsServiceImpl implements DemandStatsService { |
|||
|
|||
@Autowired |
|||
private FactVolunteerServiceDailyDao factVolunteerServiceDailyDao; |
|||
|
|||
@Override |
|||
public void addVolunteerServiceDaily(FactVolunteerServiceDailyEntity entity) { |
|||
factVolunteerServiceDailyDao.insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
public void clearVolunteerDemandServiceDailyStats(List<String> customerIds, String dateDimId) { |
|||
factVolunteerServiceDailyDao.clearVolunteerDemandServiceDailyStats(customerIds, dateDimId); |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
CREATE TABLE epmet_data_statistical.`fact_volunteer_service_daily` |
|||
( |
|||
`ID` varchar(64) NOT NULL COMMENT '主键', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', |
|||
`DATE_ID` varchar(8) NOT NULL COMMENT 'yyyyMMdd', |
|||
`MONTH_ID` varchar(6) NOT NULL COMMENT 'yyyyMM', |
|||
`VOLUNTEER_TOTAL` int(11) NOT NULL COMMENT '截止到当前dateId,当前客户下,共有多少个爱心互助的志愿者', |
|||
`PARTY_TOTAL` int(11) NOT NULL COMMENT '截止到当前dateId,当前客户下,XX个爱心互助志愿者中,党员有多少个', |
|||
`RESI_TOTAL` int(11) NOT NULL COMMENT '截止到当前dateId,当前客户下,XX个爱心互助志愿者中,居民有多少个', |
|||
`SERVICE_TOTAL` int(11) NOT NULL COMMENT '服务总次数', |
|||
`PARTY_SERVICE_TOTAL` int(11) NOT NULL COMMENT '党员服务总次数', |
|||
`RESI_SERVICE_TOTAL` int(11) NOT NULL COMMENT '居民服务总次数', |
|||
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', |
|||
`REVISION` int(11) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`), |
|||
UNIQUE KEY `uni_vsd` (`CUSTOMER_ID`,`DATE_ID`,`DEL_FLAG`) |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='志愿者服务情况统计' |
@ -0,0 +1,34 @@ |
|||
<?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.dao.heart.IcUserDemandServiceDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.heart.IcUserDemandServiceEntity" id="icUserDemandServiceMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="demandRecId" column="DEMAND_REC_ID"/> |
|||
<result property="serviceType" column="SERVICE_TYPE"/> |
|||
<result property="serverId" column="SERVER_ID"/> |
|||
<result property="serviceStartTime" column="SERVICE_START_TIME"/> |
|||
<result property="serviceEndTime" column="SERVICE_END_TIME"/> |
|||
<result property="finishDesc" column="FINISH_DESC"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<select id="listDemandServeTimes" resultType="com.epmet.dto.heart.result.DemandServiceCountResultDTO"> |
|||
select service.SERVER_ID, SERVICE_TYPE, count(1) as SERVE_TIMES |
|||
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) |
|||
where damend.DEL_FLAG = 0 |
|||
and damend.STATUS = 'finished' |
|||
and damend.CUSTOMER_ID = #{customerId} |
|||
and service.SERVICE_END_TIME <![CDATA[<]]> #{endTime} |
|||
and service.SERVICE_TYPE = #{serviceType} |
|||
group by service.SERVER_ID, SERVICE_TYPE |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,23 @@ |
|||
<?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.dao.VolunteerInfoDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.heart.VolunteerInfoEntity" id="volunteerInfoMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="userId" column="USER_ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="volunteerIntroduce" column="VOLUNTEER_INTRODUCE"/> |
|||
<result property="volunteerSignature" column="VOLUNTEER_SIGNATURE"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
<result property="gridId" column="GRID_ID"/> |
|||
<result property="gridName" column="GRID_NAME"/> |
|||
</resultMap> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,37 @@ |
|||
<?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.dao.stats.FactVolunteerServiceDailyDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.stats.FactVolunteerServiceDailyEntity" id="factVolunteerServiceDailyMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="dateId" column="DATE_ID"/> |
|||
<result property="monthId" column="MONTH_ID"/> |
|||
<result property="volunteerTotal" column="VOLUNTEER_TOTAL"/> |
|||
<result property="partyTotal" column="PARTY_TOTAL"/> |
|||
<result property="resiTotal" column="RESI_TOTAL"/> |
|||
<result property="serviceTotal" column="SERVICE_TOTAL"/> |
|||
<result property="partyServiceTotal" column="PARTY_SERVICE_TOTAL"/> |
|||
<result property="resiServiceTotal" column="RESI_SERVICE_TOTAL"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<delete id="clearVolunteerDemandServiceDailyStats"> |
|||
delete |
|||
from fact_volunteer_service_daily |
|||
where DATE_ID=#{dateDimId} |
|||
and CUSTOMER_ID in |
|||
<foreach collection="customerIds" open="(" separator="," close=")" item="customerId"> |
|||
#{customerId} |
|||
</foreach> |
|||
|
|||
</delete> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,41 @@ |
|||
package com.epmet.dto.form.demand; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 服务措施分析-柱状图入参 |
|||
*/ |
|||
@Data |
|||
public class CategoryAnalysisFormDTO implements Serializable { |
|||
|
|||
public interface AddUserInternalGroup { |
|||
} |
|||
|
|||
public interface AddUserShowGroup extends CustomerClientShowGroup { |
|||
} |
|||
|
|||
@NotBlank(message = "先选择组织或网格", groups = AddUserShowGroup.class) |
|||
private String orgId; |
|||
|
|||
@NotBlank(message = "组织:agency,网格:grid", groups = AddUserShowGroup.class) |
|||
private String orgType; |
|||
@NotBlank(message = "起止日期不能为空,格式yyyy-MM-dd", groups = AddUserShowGroup.class) |
|||
private String startDateId; |
|||
@NotBlank(message = "截止日期不能为空,格式yyyy-MM-dd", groups = AddUserShowGroup.class) |
|||
private String endDateId; |
|||
|
|||
@NotBlank(message = "先选择组织或网格", groups = AddUserInternalGroup.class) |
|||
private String cusotmerId; |
|||
|
|||
|
|||
/** |
|||
* orgType=agency时pid拼接上orgId |
|||
*/ |
|||
private String gridPids; |
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.epmet.dto.form.resi; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/10 6:10 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Data |
|||
public class VolunteerCommonFormDTO { |
|||
|
|||
public interface VolunteerPage { |
|||
} |
|||
|
|||
@NotBlank(message = "客户ID不能为空", groups = {VolunteerPage.class}) |
|||
private String customerId; |
|||
|
|||
private Integer pageNo = 0; |
|||
|
|||
private Integer pageSize = 20; |
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class CategoryAnalysisDTO implements Serializable { |
|||
private static final long serialVersionUID = 3007202497989446585L; |
|||
private String categoryCode; |
|||
private String categoryName; |
|||
private Integer total; |
|||
private List<CategoryAnalysisDetail> detail; |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class CategoryAnalysisDetail implements Serializable { |
|||
private static final long serialVersionUID = -4606305611297470078L; |
|||
/** |
|||
* 区域党建单位:party_unit; |
|||
* 社会组织:social_org; |
|||
* 社区自组织:community_org; |
|||
* 志愿者:volunteer; |
|||
* 未完成:unfinished |
|||
*/ |
|||
private String legendCode; |
|||
|
|||
/** |
|||
* 服务方类型名称 |
|||
*/ |
|||
private String legendName; |
|||
|
|||
/** |
|||
* 服务方的个数 |
|||
*/ |
|||
private Integer totalService; |
|||
/** |
|||
* 需求个数 |
|||
*/ |
|||
private Integer serviceDemandTotal; |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class CategoryAnalysisResDTO implements Serializable { |
|||
private static final long serialVersionUID = -3112952115061180189L; |
|||
private List<LegendDTO> legend; |
|||
private List<CategoryAnalysisDTO> categoryList; |
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class CategoryDetailDTO extends CategoryAnalysisDetail implements Serializable { |
|||
private static final long serialVersionUID = 4459219163308113201L; |
|||
private String categoryCode; |
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class DemandDataDTO implements Serializable { |
|||
private String firstCategoryCode; |
|||
private String firstCategoryName; |
|||
private List<IcResiUserReportDemandRes> demandList; |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 完成需求时,是否需要计算 区域化党建单位的满意度 |
|||
* |
|||
*/ |
|||
@Data |
|||
public class FinishResultDTO implements Serializable { |
|||
private Boolean sendCalStatisfaction; |
|||
private String partyUnitId; |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import com.epmet.dto.result.HouseUserDTO; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 数据分析-个人档案-需求详情,研判分析 |
|||
* 案件居民、家属 |
|||
*/ |
|||
@Data |
|||
public class HouseMemResDTO implements Serializable { |
|||
/** |
|||
* 居民信息及家属列表 |
|||
*/ |
|||
private String icResiUserId; |
|||
private String icUserName; |
|||
private String houseId; |
|||
private List<HouseUserDTO> houseUserList; |
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 服务措施分析-柱状图 |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class LegendDTO implements Serializable { |
|||
private static final long serialVersionUID = 7205666632591639499L; |
|||
/** |
|||
* 区域党建单位:party_unit; |
|||
* 社会组织:social_org; |
|||
* 社区自组织:community_org; |
|||
* 志愿者:volunteer; |
|||
* 未完成:unfinished |
|||
*/ |
|||
private String legendCode; |
|||
private String legendName; |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.epmet.dto.result.demand; |
|||
|
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
public class ServiceStatDTO implements Serializable { |
|||
/** |
|||
* 服务方id |
|||
*/ |
|||
private String serverId; |
|||
/** |
|||
* 总分 |
|||
*/ |
|||
private BigDecimal totalScore; |
|||
/** |
|||
* 服务的需求个数 |
|||
*/ |
|||
private Integer demandCount; |
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.epmet.dto.result.resi; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 志愿者信息分页查询结果 |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/10 6:17 下午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Data |
|||
public class PageVolunteerInfoResultDTO { |
|||
private String userId; |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.epmet.mq; |
|||
|
|||
import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; |
|||
import com.epmet.commons.rocketmq.constants.TopicConstants; |
|||
import com.epmet.commons.rocketmq.register.MQAbstractRegister; |
|||
import com.epmet.commons.rocketmq.register.MQConsumerProperties; |
|||
import com.epmet.mq.listener.PartyUnitSatisfactionCalEventListener; |
|||
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description 如果rocketmq.enable=true,这里必须实现,且 实例化 |
|||
* @author wxz |
|||
* @date 2021.07.14 17:13:41 |
|||
*/ |
|||
@Component |
|||
public class RocketMQConsumerRegister extends MQAbstractRegister { |
|||
|
|||
@Override |
|||
public void registerAllListeners(String env, MQConsumerProperties consumerProperties) { |
|||
// 客户初始化监听器注册
|
|||
register(consumerProperties, |
|||
ConsomerGroupConstants.CAL_PARTY_UNIT_SATISFACTION, |
|||
MessageModel.CLUSTERING, |
|||
TopicConstants.CAL_PARTY_UNIT_SATISFACTION, |
|||
"*", |
|||
new PartyUnitSatisfactionCalEventListener()); |
|||
|
|||
// ...其他监听器类似
|
|||
} |
|||
} |
@ -0,0 +1,104 @@ |
|||
package com.epmet.mq.listener; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.rocketmq.constants.MQUserPropertys; |
|||
import com.epmet.commons.rocketmq.messages.CalPartyUnitSatisfactionFormDTO; |
|||
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.commons.tools.utils.SpringContextUtils; |
|||
import com.epmet.service.IcPartyUnitService; |
|||
import org.apache.commons.lang.StringUtils; |
|||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; |
|||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; |
|||
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; |
|||
import org.apache.rocketmq.common.message.MessageExt; |
|||
import org.redisson.api.RLock; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.util.List; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
/** |
|||
* @Description 计算区域化党建单位,群众满意度=分数相加➗ 需求的总个数。 |
|||
* @author wxz |
|||
* @date 2021.10.13 15:21:48 |
|||
*/ |
|||
public class PartyUnitSatisfactionCalEventListener implements MessageListenerConcurrently { |
|||
|
|||
private Logger logger = LoggerFactory.getLogger(getClass()); |
|||
|
|||
private RedisUtils redisUtils; |
|||
|
|||
@Override |
|||
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) { |
|||
|
|||
if (redisUtils == null) { |
|||
redisUtils = SpringContextUtils.getBean(RedisUtils.class); |
|||
} |
|||
|
|||
try { |
|||
msgs.forEach(msg -> consumeMessage(msg)); |
|||
} catch (Exception e) { |
|||
logger.error(ExceptionUtils.getErrorStackTrace(e)); |
|||
return ConsumeConcurrentlyStatus.RECONSUME_LATER; |
|||
} |
|||
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; |
|||
} |
|||
|
|||
private void consumeMessage(MessageExt messageExt) { |
|||
// msg即为消息体
|
|||
// tags为SystemMessageType.java中的项,为具体的操作,此处拿到tags,判断是创建还是变更,来做响应的后续操作即可
|
|||
String msg = new String(messageExt.getBody()); |
|||
String topic = messageExt.getTopic(); |
|||
String tags = messageExt.getTags(); |
|||
String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); |
|||
|
|||
logger.info("【计算区域化党建单位群众满意度事件监听器】-需求完成-收到消息内容:{},操作:{}", msg, tags); |
|||
CalPartyUnitSatisfactionFormDTO obj = JSON.parseObject(msg, CalPartyUnitSatisfactionFormDTO.class); |
|||
|
|||
DistributedLock distributedLock = null; |
|||
RLock lock = null; |
|||
try { |
|||
distributedLock = SpringContextUtils.getBean(DistributedLock.class); |
|||
lock = distributedLock.getLock(String.format("lock:ic_warn_stats:%s", obj.getCustomerId()), |
|||
30L, 30L, TimeUnit.SECONDS); |
|||
//待执行方法
|
|||
SpringContextUtils.getBean(IcPartyUnitService.class).calPartyUnitSatisfation(obj); |
|||
} catch (RenException e) { |
|||
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
|
|||
logger.error("【计算区域化党建单位群众满意度事件监听器】-MQ失败:".concat(ExceptionUtils.getErrorStackTrace(e))); |
|||
} catch (Exception e) { |
|||
// 不是我们自己抛出的异常,可以让MQ重试
|
|||
logger.error("【计算区域化党建单位群众满意度监听器】-MQ失败:".concat(ExceptionUtils.getErrorStackTrace(e))); |
|||
throw e; |
|||
} finally { |
|||
distributedLock.unLock(lock); |
|||
} |
|||
|
|||
if (StringUtils.isNotBlank(pendingMsgLabel)) { |
|||
try { |
|||
removePendingMqMsgCache(pendingMsgLabel); |
|||
} catch (Exception e) { |
|||
logger.error("【计算区域化党建单位群众满意度监听器】-删除mq阻塞消息缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @description |
|||
* |
|||
* @param pendingMsgLabel |
|||
* @return |
|||
* @author wxz |
|||
* @date 2021.10.14 16:32:32 |
|||
*/ |
|||
private void removePendingMqMsgCache(String pendingMsgLabel) { |
|||
String key = RedisKeys.blockedMqMsgKey(pendingMsgLabel); |
|||
redisUtils.delete(key); |
|||
//logger.info("【开放数据事件监听器】删除mq阻塞消息缓存成功,blockedMsgLabel:{}", pendingMsgLabel);
|
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.epmet.task; |
|||
|
|||
import com.epmet.feign.DataStatisticalOpenFeignClient; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author wangxianzhang |
|||
* @Date 2021/12/13 9:40 上午 |
|||
* @Version 1.0 |
|||
*/ |
|||
@Component("statsDemandTask") |
|||
public class StatsDemandTask implements ITask { |
|||
|
|||
@Autowired |
|||
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; |
|||
|
|||
@Override |
|||
public void run(String params) { |
|||
dataStatisticalOpenFeignClient.statsVolunteerDemandServicesDaily(null); |
|||
} |
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue