lidongdong
2023-11-23 0f287f6dfd18b17ae22543f35025efc3bbec24a7
优化花城数据查询太慢
4个文件已修改
132 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDynDAO.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDynServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActDynDOMapper.xml 108 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/ComActIntegralUsersServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDynDAO.java
@@ -68,6 +68,12 @@
//        + " order by d.is_topping desc, d.create_at desc " + "</script>")
    IPage<ComActDynVO> pageDynamicByAdmin(Page page, @Param("comActDynVO") ComActDynVO comActDynVO);
    String getContent(@Param("id") String id);
    int getReadNum(@Param("dynId") String dynId);
    @Select("SELECT " + " count( cad.id ) AS dynTotal, "
        + " (select count(id) from com_act_dyn where community_id = ${communityId} and create_at LIKE CONCAT(#{nowDate},'%')) as currentNum "
        + "FROM " + " com_act_dyn AS cad  " + "WHERE " + " community_id = ${communityId}")
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDynServiceImpl.java
@@ -203,12 +203,24 @@
        IPage<ComActDynVO> iPage = comActDynDAO.pageDynamicByAdmin(page, comActDynVO);
        List<ComActDynVO> records = iPage.getRecords();
        if (!ObjectUtils.isEmpty(records)) {
            records.forEach(comActDynVO1 -> {
                String content = comActDynVO1.getContent();
            records.forEach(comActDynVO1 ->
            {
//                String content = comActDynVO1.getContent();
//                if (!ObjectUtils.isEmpty(content)) {
//                    String text = RichTextUtil.getText(content);
//                    comActDynVO1.setContentText(text);
//                }
                String content = comActDynDAO.getContent(comActDynVO1.getId()+"");
                int num=comActDynDAO.getReadNum(comActDynVO1.getId()+"");
                comActDynVO1.setReadNum(num);
                comActDynVO1.setContent(content);
                if (!ObjectUtils.isEmpty(content)) {
                    String text = RichTextUtil.getText(content);
                    comActDynVO1.setContentText(text);
                }
            });
        }
        return R.ok(iPage);
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActDynDOMapper.xml
@@ -195,9 +195,70 @@
        </if>
        ORDER BY d.is_topping DESC, d.create_at DESC
    </select>
<!--    <select id="pageDynamicByAdmin" resultType="com.panzhihua.common.model.vos.community.ComActDynVO">-->
<!--        SELECT d.id, d.title,(SELECT COUNT(u.id) FROM com_act_dyn_user u WHERE d.id = u.dyn_id ) readNum,-->
<!--               d.`status`, d.`content`, d.`cover`, d.`type`, d.`cover_mode`,-->
<!--        d.is_topping, d.publish_at, d.create_at, cadt.`name` as typeName, ca.name as communityName,d.release_time-->
<!--        FROM com_act_dyn d-->
<!--        LEFT JOIN com_act_dyn_type as cadt ON cadt.id = d.type-->
<!--        LEFT JOIN com_act ca ON d.community_id = ca.community_id-->
<!--        WHERE 1=1-->
<!--        <if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">-->
<!--            and d.community_id in (${comActDynVO.communityId})-->
<!--        </if>-->
<!--        <if test="comActDynVO.communityId == null  and  comActDynVO.streetId != null"  >-->
<!--            and d.community_id in (select community_id from com_act where street_id=#{comActDynVO.streetId})-->
<!--        </if>-->
<!--        <if test="comActDynVO.category != null and comActDynVO.category != '' ">-->
<!--            AND d.category = #{comActDynVO.category}-->
<!--        </if>-->
<!--        <if test="comActDynVO.title != null and comActDynVO.title.trim() != '' ">-->
<!--            AND d.title like concat(#{comActDynVO.title},'%')-->
<!--        </if>-->
<!--        <if test="comActDynVO.isTopping != null and comActDynVO.isTopping != '' ">-->
<!--            AND d.is_topping = #{comActDynVO.isTopping}-->
<!--        </if>-->
<!--        <if test="comActDynVO.status != null and comActDynVO.status != '' ">-->
<!--            AND d.`status` = #{comActDynVO.status}-->
<!--        </if>-->
<!--        <if test="comActDynVO.typeS == null or comActDynVO.typeS != 2 ">-->
<!--            <if test="comActDynVO.type != null and comActDynVO.type != '' ">-->
<!--                AND d.type = #{comActDynVO.type}-->
<!--            </if>-->
<!--        </if>-->
<!--         <if test="comActDynVO.typeS != null and comActDynVO.typeS == 2 ">-->
<!--             AND d.type in (-->
<!--             SELECT cadt.id FROM `com_act_dyn_type` as cadt WHERE cadt.name in-->
<!--             <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">-->
<!--                 #{id}-->
<!--             </foreach>-->
<!--             <if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">-->
<!--                 and cadt.community_id in (${comActDynVO.communityId})-->
<!--             </if>-->
<!--             union-->
<!--             SELECT cadt2.id FROM `com_act_dyn_type` as cadt2 WHERE  cadt2.area=1 and cadt2.name in-->
<!--             <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">-->
<!--                 #{id}-->
<!--             </foreach>-->
<!--             )-->
<!--        </if>-->
<!--        <if test="comActDynVO.publishAtBegin != null and comActDynVO.publishAtBegin != '' ">-->
<!--            AND (d.publish_at BETWEEN #{comActDynVO.publishAtBegin} AND #{comActDynVO.publishAtEnd})-->
<!--        </if>-->
<!--        order by d.is_topping desc, d.create_at desc-->
<!--    </select>-->
    <select id="pageDynamicByAdmin" resultType="com.panzhihua.common.model.vos.community.ComActDynVO">
        SELECT d.id, d.title,(SELECT COUNT(u.id) FROM com_act_dyn_user u WHERE d.id = u.dyn_id ) readNum,
               d.`status`, d.`content`, d.`cover`, d.`type`, d.`cover_mode`,
        SELECT d.id, d.title,
        d.`status`, d.`cover`, d.`type`, d.`cover_mode`,
        d.is_topping, d.publish_at, d.create_at, cadt.`name` as typeName, ca.name as communityName,d.release_time
        FROM com_act_dyn d
        LEFT JOIN com_act_dyn_type as cadt ON cadt.id = d.type
@@ -230,22 +291,22 @@
            </if>
        </if>
         <if test="comActDynVO.typeS != null and comActDynVO.typeS == 2 ">
             AND d.type in (
             SELECT cadt.id FROM `com_act_dyn_type` as cadt WHERE cadt.name in
             <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">
                 #{id}
             </foreach>
             <if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">
                 and cadt.community_id in (${comActDynVO.communityId})
             </if>
             union
             SELECT cadt2.id FROM `com_act_dyn_type` as cadt2 WHERE  cadt2.area=1 and cadt2.name in
             <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">
                 #{id}
             </foreach>
        <if test="comActDynVO.typeS != null and comActDynVO.typeS == 2 ">
            AND d.type in (
            SELECT cadt.id FROM `com_act_dyn_type` as cadt WHERE cadt.name in
            <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
            <if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">
                and cadt.community_id in (${comActDynVO.communityId})
            </if>
            union
            SELECT cadt2.id FROM `com_act_dyn_type` as cadt2 WHERE  cadt2.area=1 and cadt2.name in
            <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
             )
            )
        </if>
        <if test="comActDynVO.publishAtBegin != null and comActDynVO.publishAtBegin != '' ">
@@ -253,4 +314,17 @@
        </if>
        order by d.is_topping desc, d.create_at desc
    </select>
    <select id="getContent" resultType="String" parameterType="String">
        SELECT content FROM `com_act_dyn` WHERE id=#{id}
    </select>
    <select id="getReadNum" resultType="Integer" parameterType="String">
        SELECT COUNT(id) FROM `com_act_dyn_user` WHERE dyn_id=#{dynId}
    </select>
</mapper>
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/ComActIntegralUsersServiceImpl.java
@@ -236,7 +236,7 @@
        //积分总数加减
        if (item.getAddOrReduce() == ComActIntegralUserTrade.changeType.reduce)
        {
            integralUserDO.setIntegralSum(addIntegral(integralSum - amount));
//            integralUserDO.setIntegralSum(addIntegral(integralSum - amount));
            integralUserDO.setIntegralAvailableSum(addIntegral(integralAvailableSum - amount));
        }
        else {