张天森
2022-07-08 7c38a8639974436095dc914e94c855f403f8ffc0
双争后台统计范围修改,新数据看板
1个文件已删除
9个文件已修改
3个文件已添加
506 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/IndexDataAnalysisVO.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/IndexDataVO.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/RealUser.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/UserProportion.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/UserApi.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActNeighborCircleDOMapper.xml 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/IndexDataAnalysisVO.java
New file
@@ -0,0 +1,72 @@
package com.panzhihua.common.model.vos.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@ApiModel("首页统计结果")
public class IndexDataAnalysisVO implements Serializable {
    @ApiModelProperty("用户总数")
    private Integer allUser;
    @ApiModelProperty("实名用户总数")
    private Integer realUser;
    @ApiModelProperty("实名用户占比")
    private Double realUserRate;
    @ApiModelProperty("新增用户")
    private Integer addUser;
    @ApiModelProperty("日活跃用户")
    private Integer activeDayUser;
    @ApiModelProperty("周活跃用户")
    private Integer activeWeekUser;
    @ApiModelProperty("其他用户数(按街道,社区划分时使用)")
    private Integer otherUser;
    @ApiModelProperty("其他用户占比(按街道,社区划分时使用)")
    private Double otherUserRate;
    @ApiModelProperty("用户占比(累计)")
    private List<UserProportion> userProportionTotal;
    @ApiModelProperty("用户占比(本月)")
    private List<UserProportion> userProportionMonth;
    @ApiModelProperty("实名用户(累计)")
    private List<RealUser> realUsersTotal;
    @ApiModelProperty("实名用户(本月)")
    private List<RealUser> realUsersMonth;
    @ApiModelProperty("用户行为X轴(累计过去20天)")
    private List<Date> userActivityXAll;
    @ApiModelProperty("用户行为X轴(本月)")
    private List<Date> userActivityXMonth;
    @ApiModelProperty("新增用户Y轴(累计过去20天)")
    private List<String> addUserYAll;
    @ApiModelProperty("新增用户Y轴(本月)")
    private List<String> addUserYWeek;
    @ApiModelProperty("日活用户Y轴(累计过去20天)")
    private List<String> activeUserYAll;
    @ApiModelProperty("日活用户Y轴(本月)")
    private List<String> activeUserYMonth;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/IndexDataVO.java
File was deleted
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/RealUser.java
New file
@@ -0,0 +1,25 @@
package com.panzhihua.common.model.vos.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "实名用户统计")
public class RealUser {
    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("人数")
    private Integer count;
    @ApiModelProperty("社区名")
    private String communityName;
    @ApiModelProperty("街道名")
    private String streetName;
    @ApiModelProperty("区域code")
    private String areaCode;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/UserProportion.java
New file
@@ -0,0 +1,28 @@
package com.panzhihua.common.model.vos.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "用户占比统计")
public class UserProportion {
    @ApiModelProperty("区县code(所有区县时使用)")
    private Long areaCode;
    @ApiModelProperty("用户数")
    private Integer user;
    @ApiModelProperty("用户占比")
    private Double rate;
    @ApiModelProperty("街道名(按街道分组时使用)")
    private String streetName;
    @ApiModelProperty("社区名(按社区分组或指定街道时使用)")
    private String communityName;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java
@@ -1221,4 +1221,8 @@
     */
    @PostMapping("/update/user/party/status")
    R updateUserPartyStatus(@RequestParam("userId") Long userId);
    @GetMapping("/indexData")
    R newIndexData(@RequestParam(value = "type",required = false) Integer type,
                   @RequestParam(value = "type",required = false) Long streetId);
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/UserApi.java
@@ -2,6 +2,9 @@
import javax.annotation.Resource;
import com.panzhihua.common.model.vos.user.IndexDataAnalysisVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -67,4 +70,15 @@
        return userService.listmenu(userId);
    }
    @PostMapping("/indexData")
    @ApiOperation(value = "新数据统计看板",response = IndexDataAnalysisVO.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "数据范围,1:所有区县,2:所有街道,3:所有社区,4:跟据街道筛选",dataType = "Integer"),
            @ApiImplicitParam(name = "streetId",value = "街道ID",dataType = "Long")
    })
    public R indexData(@RequestParam(value = "type",required = false) Integer type,
                       @RequestParam(value = "type",required = false) Long streetId){
        return userService.newIndexData(type,streetId);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java
@@ -156,4 +156,5 @@
    List<UnitActivityAnalysisVO> institutionalUnitActivityAnalysis(@Param("beginTime") String beginTime, @Param("endTime") String endTIme, @Param("belongTo") String belongTo);
    List<PartyMemberAnalysisVO> institutionalPartyMemberServiceAnalysis(@Param("beginTime") String beginTime, @Param("endTime") String endTIme, @Param("belongTo") String belongTo);
    List<PartyMemberAnalysisVO> institutionalPartyMemberActAnalysis(@Param("beginTime") String beginTime, @Param("endTime") String endTIme, @Param("belongTo") String belongTo);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActNeighborCircleServiceImpl.java
@@ -1067,6 +1067,24 @@
        }
        //获取党员活动统计数据
        List<PartyMemberAnalysisVO> partyMemberAnalysisVOS = comActNeighborCircleDAO.institutionalPartyMemberServiceAnalysis(beginTime, endTime, belongTo);
        List<PartyMemberAnalysisVO> partyMemberAnalysisVOS1 = comActNeighborCircleDAO.institutionalPartyMemberActAnalysis(beginTime, endTime, belongTo);
        if (partyMemberAnalysisVOS1.size()>0){
            for (PartyMemberAnalysisVO vo : partyMemberAnalysisVOS1) {
                if (ObjectUtils.isNotEmpty(vo)){
                    if (ObjectUtils.isNotEmpty(vo.getMemberId())){
                        Map<String, Integer> param = memberAlreadyAnalysis(vo.getMemberId(), partyMemberAnalysisVOS);
                        if (param.get("flag")==1){
                            Integer serviceTime = vo.getServiceTime();
                            Integer serviceTimes = vo.getServiceTimes();
                            partyMemberAnalysisVOS.get(param.get("index")).setServiceTime(partyMemberAnalysisVOS.get(param.get("index")).getServiceTime()+serviceTime);
                            partyMemberAnalysisVOS.get(param.get("index")).setServiceTimes(partyMemberAnalysisVOS.get(param.get("index")).getServiceTimes()+serviceTimes);
                        }else{
                            partyMemberAnalysisVOS.add(vo);
                        }
                    }
                }
            }
        }
        //统计总时长和总次数
        Integer unitServiceCount=0;
        Integer unitServiceTotalTime=0;
@@ -1195,6 +1213,29 @@
        }
    }
    /**
     * 判断党员的统计是是否已存在
     * */
    public Map<String,Integer> memberAlreadyAnalysis(Long memberId,List<PartyMemberAnalysisVO> list){
        Map<String,Integer> map=new HashMap<>();
        if (memberId != null && list.size() > 0){
            for (int i=0;i<list.size();i++) {
                PartyMemberAnalysisVO vo = list.get(i);
                if (ObjectUtils.isNotEmpty(vo)){
                    if (ObjectUtils.isNotEmpty(vo.getMemberId())){
                        if (memberId.equals(vo.getMemberId())){
                            map.put("index",i );
                            map.put("flag",1 );
                            return map;
                        }
                    }
                }
            }
        }
        map.put("flag",0 );
        return map;
    }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActNeighborCircleDOMapper.xml
@@ -273,6 +273,7 @@
            and belong_to=#{belongTo}
        </if>
        group by(canc.solve_unit_id)
        having serviceTimes&lt;>'' and serviceTime&lt;>''
        order by serviceTime
    </select>
    <select id="institutionalUnitActivityAnalysis"
@@ -280,7 +281,8 @@
        SELECT count(caa.check_unit_id) as serviceTimes,sum(caa.duration) as serviceTime,caa.check_unit_id as unitId,caa.community_id as communityId,cpcu.belong_to
        FROM com_act_activity as caa
        left join com_pb_check_unit as cpcu on caa.check_unit_id=cpcu.id
        where check_unit_id&lt;>''
        where caa.check_unit_id&lt;>''
        and caa.type=5
        <if test="beginTime != null">
            and caa.create_at between #{beginTime} and #{endTime}
        </if>
@@ -288,6 +290,7 @@
            and belong_to=#{belongTo}
        </if>
        GROUP BY (caa.check_unit_id)
        having serviceTimes&lt;>'' and serviceTime&lt;>''
        order by serviceTime
    </select>
@@ -302,6 +305,7 @@
        left join com_pb_check_unit as cpcu on cpm.check_unit_id=cpcu.id
        left join com_act as ca on cpm.community_id=ca.community_id
        where caa.sponsor_id&lt;>''
        and caa.type=3
        <if test="beginTime != null">
            and caa.create_at between #{beginTime} and #{endTime}
        </if>
@@ -311,6 +315,24 @@
        GROUP BY (caa.sponsor_id)
        having serviceTimes&lt;>'' and serviceTime&lt;>''
    </select>
    <select id="institutionalPartyMemberActAnalysis"
            resultType="com.panzhihua.common.model.vos.neighbor.PartyMemberAnalysisVO">
        SELECT count(canc.solve_id) as serviceTimes,sum(canc.real_service_time) as serviceTime
        ,canc.community_id as communityId,cpm.id as memberId,cpm.name as memberName,cpcu.name as belongUnit,ca.name as belongCommunity,cpcu.belong_to
        FROM `com_act_neighbor_circle` as canc
        left join com_pb_member as cpm on canc.solve_id=cpm.id
        left join com_pb_check_unit as cpcu on cpm.check_unit_id=cpcu.id
        left join com_act as ca on cpm.community_id=ca.community_id
        where canc.solve_id&lt;>''
        <if test="beginTime != null">
            and caa.create_at between #{beginTime} and #{endTime}
        </if>
        <if test="belongTo != null and belongTo != ''">
            and belong_to=#{belongTo}
        </if>
        GROUP BY (canc.solve_id)
        having serviceTimes&lt;>'' and serviceTime&lt;>''
    </select>
</mapper>
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java
@@ -1358,7 +1358,7 @@
        return userService.uuLogin(uuLoginVO);
    }
    @PostMapping("/indexData")
    @GetMapping("/indexData")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "数据范围,1:所有区县,2:所有街道,3:所有社区,4:跟据街道筛选",dataType = "Integer"),
            @ApiImplicitParam(name = "streetId",value = "街道ID",dataType = "Long")
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java
@@ -6,6 +6,7 @@
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO;
import com.panzhihua.common.model.vos.user.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
@@ -27,10 +28,6 @@
import com.panzhihua.common.model.vos.community.screen.event.EventGridMemberVO;
import com.panzhihua.common.model.vos.grid.GridMemberVO;
import com.panzhihua.common.model.vos.partybuilding.ComPbServiceTeamWishVO;
import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
import com.panzhihua.common.model.vos.user.SysUserNoticeVO;
import com.panzhihua.common.model.vos.user.SysUserVO;
import com.panzhihua.common.model.vos.user.UpdateUserArchivesVO;
import com.panzhihua.service_user.model.dos.SysUserDO;
import com.panzhihua.service_user.model.dtos.DataKanbanDTO;
@@ -285,4 +282,31 @@
     * @return
     */
    String selectAreaCodeByStreetId(Long streetId);
    /**
     * 看板用户统计:用户占比统计
     * */
    List<UserProportion> userAnalysis(@Param("type") Integer type,@Param("range") String range,@Param("streetId") Long streetId);
    /**
     * 统计区域实名用户数
     * */
    List<RealUser> realUserCount(@Param("type") Integer type,@Param("range") String range,@Param("streetId") Long streetId);
    /**
     * 统计该街道内的所有用户数
     * */
    Integer streetUserCount(@Param("id") Long id);
    /**
     * 街道用户统计
     * */
    IndexDataKanbanVO dataKanBanStreet(Long streetId);
    /**
     * 获取当天的新增和日活
     * */
    Map<String,Long> getDailyAddAndActive(@Param("date") Date date,@Param("id") Long streetId);
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -4,12 +4,18 @@
import static java.util.Objects.nonNull;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.model.dtos.community.microCommercialStreet.BindUserPhoneDTO;
@@ -149,6 +155,7 @@
    public static final Integer ALLCOUNTY=1;
    public static final Integer ALLSTREET=2;
    public static final Integer ALLCOMMUNITY=3;
    public static final Integer BYSTREET=4;
    // @Resource
    // private GridService gridService;
@@ -3296,12 +3303,152 @@
    @Override
    public R newIndexData(Integer type, Long streetId) {
        IndexDataKanbanVO indexDataKanbanVO = userDao.selectIndexDataKanban(null);
        //判断数据范围
        if (type.equals(ALLCOUNTY)){
            //数据范围:全部区县
        IndexDataAnalysisVO vo=new IndexDataAnalysisVO();
        if (ObjectUtils.isEmpty(type)){
            //不传默认为所有区县
            type=ALLCOUNTY;
        }
        if (type.equals(ALLCOUNTY) || type.equals(ALLCOMMUNITY) || type.equals(ALLSTREET)){
            BeanUtils.copyProperties(indexDataKanbanVO,vo);
        }else {
            IndexDataKanbanVO indexDataVO = userDao.dataKanBanStreet(streetId);
            BeanUtils.copyProperties(indexDataVO,vo);
        }
            List<UserProportion> userProportionsTotal = userDao.userAnalysis(type, null, streetId);
            Integer streetUser = userDao.streetUserCount(streetId);
            for (UserProportion userProportion : userProportionsTotal) {
                if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion)){
                    if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion.getUser())){
                        //计算占比
                        //userProportion.setAreaCode(null);
                        if (type.equals(BYSTREET)){
                            userProportion.setRate(getRate(streetUser,userProportion.getUser()));
                        }
                        userProportion.setRate(getRate(vo.getAllUser(),userProportion.getUser()));
                    }
                }
            }
            List<UserProportion> userProportionsMonth = userDao.userAnalysis(type, DateUtil.beginOfMonth(new Date()).toString(), streetId);
            for (UserProportion userProportion : userProportionsMonth) {
                if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion)){
                    if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion.getUser())){
                        //计算占比
                        //userProportion.setAreaCode(null);
                        if (type.equals(BYSTREET)){
                            userProportion.setRate(getRate(streetUser,userProportion.getUser()));
                        }
                        userProportion.setRate(getRate(vo.getAllUser(),userProportion.getUser()));
                    }
                }
            }
            vo.setUserProportionTotal(userProportionsTotal);
            vo.setUserProportionMonth(userProportionsMonth);
            List<RealUser> realUsersTotal = userDao.realUserCount(type, null, streetId);
            List<RealUser> realUsersMonth = userDao.realUserCount(type, DateUtil.beginOfMonth(new Date()).toString(), streetId);
            vo.setRealUsersTotal(realUsersTotal);
            vo.setRealUsersMonth(realUsersMonth);
            vo.setRealUser(getStreetRealUser(realUsersTotal));
            vo.setRealUserRate(getRate(vo.getAllUser(),vo.getRealUser()));
            vo.setUserActivityXAll(getTwentyDays());
            vo.setUserActivityXMonth(getMonthTwentyDays());
            List<String> addUserYAll=new ArrayList<>();
            List<String> addUserYMonth=new ArrayList<>();
            List<String> activeUserYAll=new ArrayList<>();
            List<String> activeUserYMonth=new ArrayList<>();
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            //获取用户行为Y轴
            for (Date date : vo.getUserActivityXAll()) {
                //查询当天的新增和日活
                Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId);
                addUserYAll.add(map.get("addUser").toString());
                activeUserYAll.add(map.get("activeUser").toString());
            }
            for (Date date : vo.getUserActivityXMonth()) {
                Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId);
                addUserYMonth.add(map.get("addUser").toString());
                activeUserYMonth.add(map.get("activeUser").toString());
            }
            vo.setAddUserYAll(addUserYAll);
            vo.setAddUserYWeek(addUserYMonth);
            vo.setActiveUserYAll(activeUserYAll);
            vo.setActiveUserYMonth(activeUserYMonth);
            if (type.equals(BYSTREET) || type.equals(ALLCOMMUNITY) || type.equals(ALLSTREET)){
                //获取其他用户
                vo.setOtherUser(indexDataKanbanVO.getAllUser()-vo.getAllUser());
                vo.setOtherUserRate(getRate(indexDataKanbanVO.getAllUser(),vo.getAllUser()));
            }
        return R.ok(vo);
    }
    /**
     * 获取最近20天数据
     *
     * @return
     */
    private List<Date> getTwentyDays() {
        List<Date> dates = new ArrayList<>();
        Date date = new Date();
        for (int i = 19; i >= 0; i--) {
            Date date1 = DateUtils.addDays(date, -i);
            dates.add(date1);
        }
        return dates;
    }
    /**
     * 获取最近本月20天数据
     *
     * @return
     */
    private List<Date> getMonthTwentyDays() {
        List<Date> dates = new ArrayList<>();
        Date date = new Date();
        Long offset = DateUtil.between(new Date(), DateUtil.beginOfMonth(date), DateUnit.DAY);
        if (offset>=20){
            for (int i = 19; i >= 0; i--) {
                Date date1 = DateUtils.addDays(date, -i);
                dates.add(date1);
            }
        }else{
            //距离月初不足20天
            for (int i = offset.intValue(); i >= 0; i--) {
                Date date1 = DateUtils.addDays(date, -i);
                dates.add(date1);
            }
        }
        return dates;
    }
    /**
     * 计算占比
     * */
    private Double getRate(Integer total,Integer count){
        if (0 != total && null != total){
            if (0 != count && null != count){
                BigDecimal div = NumberUtil.div(count.toString(), total.toString(),1);
                return div.doubleValue();
            }
        }
        return null;
    }
    /**
     * 计算街道实名用户总数
     * */
    private Integer getStreetRealUser(List<RealUser> list){
        Integer count=0;
        if (list.size()>0){
            for (RealUser realUser : list) {
                if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(realUser)){
                    if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(realUser.getCount())){
                        count+=realUser.getCount();
                    }
                }
            }
        }
        return count;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml
@@ -563,5 +563,89 @@
    <select id="selectCheckUnitId" resultType="Long">
        select check_unit_id from com_pb_member where phone = #{phone} limit 1
    </select>
    <select id="userAnalysis" resultType="com.panzhihua.common.model.vos.user.UserProportion">
        select cs.area_code,cs.name as streetName,ac.name as communityName,count(su.user_id) as user from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        <if test="range != null and range != ''">
            and su.create_at >= #{range}
        </if>
        <if test="type == 4">
            and cs.street_id=#{streetId}
            group by su.community_id
        </if>
        <if test="type == 1">
            group by cs.area_code
        </if>
        <if test="type == 2">
            group by cs.street_id
        </if>
        <if test="type == 3">
            group by su.community_id
        </if>
        order by user desc
        limit 10
    </select>
    <select id="realUserCount" resultType="com.panzhihua.common.model.vos.user.RealUser">
        select cs.area_code as areaCode,cs.street_id,ac.name as communityName,cs.name as StreetName,count(su.user_id) as count from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        and su.id_card&lt;>''
        <if test="range != null and range != ''">
            and su.create_at >= #{range}
        </if>
        <if test="type == 4">
            and cs.street_id=#{streetId}
            group by su.community_id
        </if>
        <if test="type == 1">
            group by cs.area_code
        </if>
        <if test="type == 2">
            group by cs.street_id
        </if>
        <if test="type == 3">
            group by su.community_id
        </if>
        order by count desc
        limit 10
    </select>
    <select id="streetUserCount" resultType="Integer">
        select count(user_id) from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        and cs.street_id=#{id}
    </select>
    <select id="dataKanBanStreet" resultType="com.panzhihua.common.model.vos.IndexDataKanbanVO">
         SELECT
        COUNT(user_id)allUser,
        COUNT(case WHEN DATE_FORMAT(t.create_at,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )addUser,
        COUNT(case WHEN DATE_FORMAT(last_login_time,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )activeDayUser,
        (SELECT count(user_id) FROM sys_user t left join com_act t1 on t.community_id = t1.community_id WHERE t.type = 1  AND last_login_time > date_sub(SYSDATE(), INTERVAL 7 DAY))activeWeekUser
        FROM
        sys_user t LEFT JOIN com_act t1 on t.community_id = t1.community_id
        where t.type=1 and t.community_id is not null
        <if test="streetId != null">
            and t1.street_id=#{streetId}
        </if>
    </select>
    <select id="getDailyAddAndActive" resultType="java.util.Map">
        select COUNT(case WHEN DATE_FORMAT(su.last_login_time,'%m-%d-%Y')=DATE_FORMAT(#{date},'%m-%d-%Y') then user_id else null end) as activeUser,
        count(case WHEN DATE_FORMAT(su.create_at,'%m-%d-%Y')=DATE_FORMAT(#{date},'%m-%d-%Y') then user_id else null end ) as addUser
        from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        <if test="id != null">
            and cs.street_id=#{id}
        </if>
    </select>
</mapper>