liujie
2025-06-09 70d2a5d0f9c6951b2d4cac954041ed73582ff7eb
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActActivityDAO.java
@@ -4,6 +4,7 @@
import java.util.List;
import java.util.Map;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.community.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -13,7 +14,15 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.PageBaseDTO;
import com.panzhihua.common.model.dtos.community.bigscreen.work.ScreenActActivityListDTO;
import com.panzhihua.common.model.vos.community.ComActActivityStatisticsVO;
import com.panzhihua.common.model.vos.community.ComActActivityTypeVO;
import com.panzhihua.common.model.vos.community.ComActActivityVO;
import com.panzhihua.common.model.vos.community.CommunityActivitiesVO;
import com.panzhihua.common.model.vos.community.PartyActivityStatics;
import com.panzhihua.common.model.vos.community.PartyActivityTypeChart;
import com.panzhihua.common.model.vos.community.StatisticsCommVO;
import com.panzhihua.common.model.vos.community.screen.work.ActActivityListVO;
import com.panzhihua.common.model.vos.screen.CarouselInfoVO;
import com.panzhihua.service_community.model.dos.ComActActivityDO;
@@ -36,30 +45,35 @@
    // " </if> " +
    // " </where>" +
    // "</script>")
    @Select("<script> " + "SELECT  " + "a.id, " + "a.activity_name, " + "u.`name` sponsorName, "
        + "a.activity_addr, " + "a.aattend_people,"
        + "a.`status`, " + "a.is_qr_code, " + "a.publish_at, " + "a.begin_at, " + "a.cover, " + "a.end_at, " + "a.volunteer_max, "
        + "count(if(s.is_volunteer=1,s.id,null))volunteer_now, "
        + "count(if(s.is_volunteer=0,s.id,null))participant_now, " + "a.participant_max, " + "a.sign_up_begin, "
        + "a.sign_up_end, " + "ca.name as communityName,a.type  " + "FROM " + "com_act_activity a  "
        + "left join sys_user u on a.sponsor_id=u.user_id " + "left join (select * from com_act_act_sign where `status` = 1) s on a.id=s.activity_id  "
        + "left join com_act ca on a.community_id=ca.community_id  " + " where 1=1 " +
        "<if test='comActActivityVO.choice == 0 '>" + "AND a.community_id=#{comActActivityVO.communityId} " + " </if> "
        +
        "<if test='comActActivityVO.activityName != null and comActActivityVO.activityName.trim() != &quot;&quot;'>"
        + " and a.activity_name like concat(#{comActActivityVO.activityName},'%')   " + " </if> "
        + "<if test='comActActivityVO.status != null and comActActivityVO.status !=0 and comActActivityVO.isIng==null'>"
        + "AND a.`status` = #{comActActivityVO.status}  " + " </if> "
        + "<if test='comActActivityVO.status != null and comActActivityVO.status !=0 and comActActivityVO.isIng!=null and comActActivityVO.isIng==1'>"
        + "AND a.`status` in (3,4)  " + " </if> "
        + "<if test='comActActivityVO.isApplets != null and comActActivityVO.isApplets ==1'>"
        + "AND a.`status` != 1 AND  a.`status` != 6   " + " </if> " + "<if test='comActActivityVO.beginAt != null '>"
        + "AND a.begin_at <![CDATA[ >= ]]> #{comActActivityVO.beginAt} AND a.end_at <![CDATA[ <= ]]> #{comActActivityVO.endAt}  "
        + " </if> " + "<if test='comActActivityVO.type != null'>"
        + "AND a.type=#{comActActivityVO.type} " + " </if> "
        + " group by a.id " + " ORDER BY a.status = 99 desc,a.publish_at DESC " + "</script>")
//    @Select("<script> " + "SELECT  " + "a.id, " + "a.activity_name, " + "u.`name` sponsorName, "
//        + "a.activity_addr, " + "a.aattend_people,"
//        + "a.`status`, " + "a.is_qr_code, " + "a.publish_at, " + "a.begin_at, " + "a.cover, " + "a.end_at, " + "a.volunteer_max, "
//        + "count(if(s.is_volunteer=1,s.id,null))volunteer_now, "
//        + "count(if(s.is_volunteer=0,s.id,null))participant_now, " + "a.participant_max, " + "a.sign_up_begin, "
//        + "a.sign_up_end, " + "ca.name as communityName,a.type,a.party_member_max  " + "FROM " + "com_act_activity a  "
//        + "left join sys_user u on a.sponsor_id=u.user_id " + "left join (select * from com_act_act_sign where `status` = 1) s on a.id=s.activity_id  "
//        + "left join com_act ca on a.community_id=ca.community_id  " + " where 1=1 " +
//
//        "<if test='comActActivityVO.communityId != null and comActActivityVO.communityId!=0'>" + "AND a.community_id = ${comActActivityVO.communityId} " + " </if> "
//        +
//            "<if test='comActActivityVO.phone != null and comActActivityVO.phone!=&quot;&quot;'>" + "AND a.phone = ${comActActivityVO.phone} " + " </if> "
//            +
//        "<if test='comActActivityVO.areaCode !=null '>" + "AND ca.area_code = ${comActActivityVO.areaCode} " + " </if> "
//        +
//        "<if test='comActActivityVO.checkUnitId !=null '>" + "AND a.check_unit_id = #{comActActivityVO.checkUnitId} " + " </if> "
//        +
//        "<if test='comActActivityVO.activityName != null and comActActivityVO.activityName.trim() != &quot;&quot;'>"
//        + " and a.activity_name like concat(#{comActActivityVO.activityName},'%')   " + " </if> "
//        + "<if test='comActActivityVO.status != null and comActActivityVO.status !=0 and comActActivityVO.isIng==null'>"
//        + "AND a.`status` = #{comActActivityVO.status}  " + " </if> "
//        + "<if test='comActActivityVO.status != null and comActActivityVO.status !=0 and comActActivityVO.isIng!=null and comActActivityVO.isIng==1'>"
//        + "AND a.`status` in (3,4)  " + " </if> "
//        + "<if test='comActActivityVO.isApplets != null and comActActivityVO.isApplets ==1'>"
//        + "AND a.`status` != 1 AND  a.`status` != 6   " + " </if> " + "<if test='comActActivityVO.beginAt != null '>"
//        + "AND a.begin_at <![CDATA[ >= ]]> #{comActActivityVO.beginAt} AND a.end_at <![CDATA[ <= ]]> #{comActActivityVO.endAt}  "
//        + " </if> " + "<if test='comActActivityVO.type != null'>"
//        + "AND a.type=#{comActActivityVO.type} " + " </if> "
//        + " group by a.id " + " ORDER BY a.status = 99 desc,a.publish_at DESC " + "</script>")
    IPage<ComActActivityVO> pageActivity(Page page, @Param("comActActivityVO") ComActActivityVO comActActivityVO);
//    @Select("SELECT  " + "u.name sponsorName, " + "ca.name communityName, "
@@ -98,7 +112,7 @@
        + "</foreach> " + "</script>")
    int updateIdBatch(@Param("longs") List<Long> longs);
    @Update("update com_act_activity set `status`=3 where `status`=1 and TIMESTAMPDIFF(MINUTE,SYSDATE(),publish_at)<=0")
    @Update("update com_act_activity set `status`=3 where `status`=1 and TIMESTAMPDIFF(MINUTE,SYSDATE(),begin_at )<=0")
    int updateStatusToNotBegin();
    @Update("update com_act_activity set `status`=3 where `status`=2 and TIMESTAMPDIFF(MINUTE,SYSDATE(),sign_up_begin)<=0")
@@ -107,13 +121,16 @@
    @Update("update com_act_activity set `status`=5 where `status` in (3,4) and TIMESTAMPDIFF(MINUTE,SYSDATE(),end_at)<=0")
    int updateStatusToBeginActiveOrEnd();
    @Select("select id from com_act_activity   where `status`=3 and TIMESTAMPDIFF(MINUTE,SYSDATE(),sign_up_end)<=0")
    List<Long> selectBeginIds();
//    @Select("<script> " + "select t.* from ( " + "SELECT  " + "a.id, " + "a.activity_name, " + "u.`name` sponsorName, "
//        + "a.activity_addr, " + "a.participant_max, " + "count(if(s.is_volunteer=1,null,s.id))participant_now, "
//        + "a.volunteer_max, " + "count(if(s.is_volunteer=1,s.id,null))volunteer_now, " + "a.`status`, "
//        + "a.publish_at, " + "a.is_qr_code, " + "a.begin_at, " + "a.end_at, " + "a.sign_up_begin, " + "a.sign_up_end " + "FROM "
//        + " com_act_activity a  " + " LEFT JOIN sys_user u on a.sponsor_id=u.user_id "
//        + " LEFT JOIN com_act_act_sign s on a.id=s.activity_id " + "WHERE "
//        + "  a.`status` = 1 and a.community_id=#{comActActivityVO.communityId} "
//        + "  a.`status` = 1 and a.community_id = ${comActActivityVO.communityId} "
//        + "<if test='comActActivityVO.activityName != null and comActActivityVO.activityName !=&quot;&quot;'>"
//        + " and a.activity_name LIKE concat( #{comActActivityVO.activityName}, '%' )  " + " </if> "
//        + "<if test='comActActivityVO.status != null and comActActivityVO.status !=0 and comActActivityVO.status !=1'>"
@@ -125,7 +142,7 @@
//        + "count(if(s.is_volunteer=1,s.id,null))volunteer_now, " + "a.`status`, " + "a.publish_at, " + "a.is_qr_code, " + "a.begin_at, "
//        + "a.end_at, " + "a.sign_up_begin, " + "a.sign_up_end " + "FROM " + " com_act_activity a  "
//        + " LEFT JOIN sys_user u on a.sponsor_id=u.user_id " + " LEFT JOIN com_act_act_sign s on a.id=s.activity_id "
//        + "WHERE " + "  a.`status` != 1 and a.community_id=#{comActActivityVO.communityId} "
//        + "WHERE " + "  a.`status` != 1 and a.community_id = ${comActActivityVO.communityId} "
//        + "<if test='comActActivityVO.activityName != null and comActActivityVO.activityName !=&quot;&quot;'>"
//        + " and a.activity_name LIKE concat( #{comActActivityVO.activityName}, '%' )  " + " </if> "
//        + "<if test='comActActivityVO.status != null and comActActivityVO.status !=0 '>"
@@ -147,37 +164,37 @@
    int updateStatusToBeginAfterSingEnd();
    @Select("select GROUP_CONCAT(t.x1,',',t.x2,',',t.x3,',',t.x4) from ( " + "SELECT "
        + "(select COUNT(d.id) from com_act_discuss d where  d.community_id=#{communityId})x1, "
        + "(select COUNT(w.id) from com_act_micro_wish w where  w.community_id=#{communityId})x2, "
        + "(select COUNT(p.id) from com_act_easy_photo p where  p.community_id=#{communityId})x3, "
        + " COUNT( a.id ) x4 " + "FROM " + " com_pb_activity a  " + "WHERE " + "  a.community_id =#{communityId})t")
        + "(select COUNT(d.id) from com_act_discuss d where  d.community_id = ${communityId})x1, "
        + "(select COUNT(w.id) from com_act_micro_wish w where  w.community_id = ${communityId})x2, "
        + "(select COUNT(p.id) from com_act_easy_photo p where  p.community_id = ${communityId})x3, "
        + " COUNT( a.id ) x4 " + "FROM " + " com_pb_activity a  " + "WHERE " + "  a.community_id = ${communityId})t")
    String selectCommunityGovernanceTrendsVO(Long communityId);
    @Select(" " + " SELECT "
        + " (select COUNT(d.id) from com_act_discuss d where DATE_FORMAT(d.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and d.community_id=#{communityId})discuss, "
        + " (select COUNT(w.id) from com_act_micro_wish w where DATE_FORMAT(w.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and w.community_id=#{communityId})microWish, "
        + " (select COUNT(p.id) from com_act_easy_photo p where DATE_FORMAT(p.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and p.community_id=#{communityId})eashPhoto, "
        + " (select COUNT(pa.id) from com_pb_activity pa where DATE_FORMAT(pa.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and pa.community_id=#{communityId})pbActivity, "
        + " (select COUNT(d.id) from com_act_discuss d where DATE_FORMAT(d.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and d.community_id = ${communityId})discuss, "
        + " (select COUNT(w.id) from com_act_micro_wish w where DATE_FORMAT(w.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and w.community_id = ${communityId})microWish, "
        + " (select COUNT(p.id) from com_act_easy_photo p where DATE_FORMAT(p.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and p.community_id = ${communityId})eashPhoto, "
        + " (select COUNT(pa.id) from com_pb_activity pa where DATE_FORMAT(pa.create_at,'%Y-%m-%d')=DATE_FORMAT(#{date},'%Y-%m-%d') and pa.community_id = ${communityId})pbActivity, "
        + "  COUNT( a.id ) actActivity " + " FROM " + "  com_pb_activity a  " + " WHERE "
        + "  DATE_FORMAT( a.create_at, '%Y-%m-%d' )=DATE_FORMAT(#{date},'%Y-%m-%d')  "
        + "  AND a.community_id =#{communityId}")
        + "  AND a.community_id = ${communityId}")
    CommunityActivitiesVO selectCommunityActivitiesVO(@Param("communityId") Long communityId, @Param("date") Date date);
    @Select("SELECT " + " count( caa.id ) as totalNum, "
        + " (select count(id) from com_act_activity where `status` IN (1,2,3,4,5) and volunteer_min = 0 and community_id = #{communityId}) as commonNum, "
        + " (select count(id) from com_act_activity where `status` IN (1,2,3,4,5) and volunteer_min > 0 and community_id = #{communityId}) as volunteerNum, "
        + " (select count(caas.user_id) from (select * from com_act_act_sign where `status` = 1) as caas left join com_act_activity as caa on caa.id = caas.activity_id where caa.`status` IN (1,2,3,4,5) and is_volunteer = 0 and caa.community_id = #{communityId}) as commonPeopleNum, "
        + " (select count(caas.user_id) from (select * from com_act_act_sign where `status` = 1) as caas left join com_act_activity as caa on caa.id = caas.activity_id where caa.`status` IN (1,2,3,4,5) and is_volunteer = 1 and caa.community_id = #{communityId}) as volunteerPeopleNum, "
        + " (select count(id) from com_act_activity where `status` IN (1,2,3,4,5) and community_id = #{communityId} and create_at between date_sub(curdate() - day(curdate()) +1,interval 1 month) and now()) as currentNum "
        + " (select count(id) from com_act_activity where `status` IN (1,2,3,4,5) and volunteer_min = 0 and community_id = ${communityId}) as commonNum, "
        + " (select count(id) from com_act_activity where `status` IN (1,2,3,4,5) and volunteer_min > 0 and community_id = ${communityId}) as volunteerNum, "
        + " (select count(caas.user_id) from (select * from com_act_act_sign where `status` = 1) as caas left join com_act_activity as caa on caa.id = caas.activity_id where caa.`status` IN (1,2,3,4,5) and caas.sign_identity != 3 and caa.community_id = ${communityId}) as commonPeopleNum, "
        + " (select count(caas.user_id) from (select * from com_act_act_sign where `status` = 1) as caas left join com_act_activity as caa on caa.id = caas.activity_id where caa.`status` IN (1,2,3,4,5) and caas.sign_identity = 3 and caa.community_id = ${communityId}) as volunteerPeopleNum, "
        + " (select count(id) from com_act_activity where `status` IN (1,2,3,4,5) and community_id = ${communityId} and create_at between date_sub(curdate() - day(curdate()) +1,interval 1 month) and now()) as currentNum "
        + "FROM " + " com_act_activity AS caa  " + "WHERE "
        + " caa.`status` IN (1,2,3,4,5) and community_id = #{communityId}")
        + " caa.`status` IN (1,2,3,4,5) and community_id = ${communityId}")
    Map<String, Long> countByCommunityId(@Param("communityId") Long communityId, @Param("nowDate") String nowDate);
    @Select("SELECT id,activity_name as content,IF(volunteer_max = 0,'居民活动','志愿者活动') AS typeName  FROM com_act_activity "
        + "WHERE community_id = #{communityId} AND (status = 3 OR status = 4 OR status = 5) ORDER BY create_at DESC LIMIT #{pageSize}")
        + "WHERE community_id = ${communityId} AND (status = 3 OR status = 4 OR status = 5) ORDER BY create_at DESC LIMIT #{pageSize}")
    List<CarouselInfoVO> screenActivity(@Param("communityId") Long communityId, @Param("pageSize") Integer pageSize);
    @Select("SELECT cover FROM com_act_activity WHERE community_id = #{communityId}")
    @Select("SELECT cover FROM com_act_activity WHERE community_id = ${communityId}")
    List<String> listImg(@Param("communityId") Long communityId);
    @Select("<script> " + "SELECT " + " caa.id, " + " su.`name` AS userName , " + " su.image_url, "
@@ -187,7 +204,7 @@
        + " caa.content, " + " caa.activity_addr  " + "FROM " + " com_act_activity AS caa "
        + " LEFT JOIN sys_user AS su ON su.user_id = caa.sponsor_id" + " <where> "
        + "<if test='actActivityListDTO.communityId != null '>"
        + " and caa.community_id = #{actActivityListDTO.communityId} " + " </if> "
        + " and caa.community_id = ${actActivityListDTO.communityId} " + " </if> "
        + "<if test='actActivityListDTO.startTime!=null and actActivityListDTO.startTime != &quot;&quot;'>"
        + " AND DATE_FORMAT(caa.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{actActivityListDTO.startTime} "
        + " </if> " + "<if test='actActivityListDTO.endTime!=null and actActivityListDTO.endTime != &quot;&quot;'>"
@@ -229,6 +246,41 @@
    int addActivityType(@Param("comActActivityTypeVO") ComActActivityTypeVO comActActivityTypeVO);
    /**
     * 居民活动分类统计数据
     * @param communityId
     * @param isResidentAct
     * @return
     */
    List<StatisticsCommVO> selectResidentActHistogramData(@Param("communityId") Long communityId, @Param("isResidentAct") boolean isResidentAct);
    /**
     * 居民活动分类人口参与统计
     * @param communityId
     * @param isResidentAct
     * @return
     */
    List<StatisticsCommVO> getIndexResidentActBaseData(@Param("communityId") Long communityId, @Param("isResidentAct") boolean isResidentAct);
    /**
     * 获取活动新增折线数据
     * @param communityId
     * @param isResidentAct
     * @return
     */
    List<StatisticsCommVO> getActAddPolylineData(@Param("communityId") Long communityId, @Param("isResidentAct") boolean isResidentAct);
    /**
     * 获取活动累计折线数据
     * @param communityId
     * @param isResidentAct
     * @param date
     * @return
     */
    StatisticsCommVO getActTotalPolylineData(@Param("communityId") Long communityId, @Param("isResidentAct") boolean isResidentAct, @Param("date") String date);
    IPage<ComActActivityVO> indexActList(@Param("page") Page page, @Param("pageBaseDTO") PageBaseDTO pageBaseDTO, @Param("isResidentAct") boolean isResidentAct);
    /**
     * 查询项目活动列表
     * @param page
     * @return
@@ -238,24 +290,35 @@
    /**
     * 根据社工id查询活动列表
     * @param page
     * @param id
     * @param commonPage
     * @return
     */
    IPage<ActActivityListVO> selectActivityBySocialWorker(Page page,@Param("id")Long id);
    IPage<ComActActivityVO> selectActivityBySocialWorker(Page page,@Param("commonPage") CommonPage commonPage);
    /**
     * [方法描述] 根据社区ID查询所属城市所在区区域代码,
     *
     * @param communityId
     *            社区ID
     * @return String 区域code
     * @author manailin
     * @date 2022/2/17 10:09
     */
    String getActBelongRegionCode(@Param("communityId") Long communityId);
    /**
     * 查询党员活动数量
     * @param communityId
     * @return
     */
    PartyActivityStatics selectActivityStatics(Long communityId);
    PartyActivityStatics selectActivityStatics(@Param("communityIds") List<Long> communityIds);
    /**
     * 党员活动饼状图
     * @param communityId
     * @return
     */
    List<PartyActivityTypeChart> selectActivityChart(Long communityId);
    List<PartyActivityTypeChart> selectActivityChart(@Param("communityIds") List<Long> communityIds);
    /**
     * 党员活动柱状图
@@ -264,6 +327,47 @@
     * @param date
     * @return
     */
    Integer selectActivityLine(@Param("communityId") Long communityId,@Param("year")String year,@Param("date")String date);
    Integer selectActivityLine(@Param("communityIds") List<Long> communityIds,@Param("year")String year,@Param("date")String date);
    /**
     * 分页查询党员详情活动
     * @param page
     * @param commonPage
     * @return
     */
    IPage<PartyMemberDetailVO> partyMemberDetail(Page page,@Param("commonPage") CommonPage commonPage);
    /**
     * 导出党员详情活动
     * @param commonPage
     * @return
     */
    List<PartyMemberDetailExcelVO> exportPartyMemberDetail(@Param("commonPage") CommonPage commonPage);
    List<ComActActivityVO> selectListByRelationId(@Param("relationId") Long relationId,@Param("date")String date);
    /**
     * 查询进行中活动
     * @param communityId 社区id
     * @return 活动列表
     */
    List<ComActActivityVO> selectListByCommunityId(@Param("communityId") Long communityId,@Param("date") String date,@Param("phone")String phone);
    /**
     * 获取项目活动
     * @param page
     * @param comActActivityVO
     * @return
     */
    IPage<ComActActivityVO> pageProjectActivity(@Param("page") Page page, @Param("comActActivityVO") ComActActivityVO comActActivityVO);
    List<String> selectOpenIdByActivityId(Long id);
    /**
     * 大屏社区活动列表
     * @param page
     * @return
     */
    IPage<ComActActivityBigScreenVO> pageActivityBigScreen(@Param("page") Page page);
}