张天森
2022-07-18 449fd341e89d8b1990a054f1df2fa67010c3f40c
社区/村落列表接口更新
9个文件已修改
3个文件已添加
165 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/AreaVOS.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/CommunityVO.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/StreetVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/StreetVOS.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java
@@ -251,4 +251,5 @@
    public static final String INSERT="insert";
    public static final String QUERY="query";
    public static final String DELETE="delete";
    public static final String VILLAGE="村";
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/AreaVOS.java
New file
@@ -0,0 +1,21 @@
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.List;
@Data
@ApiModel
public class AreaVOS implements Serializable {
    @ApiModelProperty("区县名")
    private String name;
    @ApiModelProperty("区县code")
    private Integer id;
    @ApiModelProperty("下属街道列表")
    private List<StreetVOS> childList;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/CommunityVO.java
New file
@@ -0,0 +1,18 @@
package com.panzhihua.common.model.vos.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel
public class CommunityVO implements Serializable {
    @ApiModelProperty("社区/村落名")
    private String name;
    @ApiModelProperty("社区/村落id")
    private String id;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/StreetVO.java
@@ -5,6 +5,7 @@
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel
@@ -15,4 +16,7 @@
    @ApiModelProperty("街道名")
    private String name;
    @ApiModelProperty("下属社区列表")
    private List<CommunityVO> communityList;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/StreetVOS.java
New file
@@ -0,0 +1,20 @@
package com.panzhihua.common.model.vos.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel
public class StreetVOS {
    @ApiModelProperty("街道id")
    private Integer id;
    @ApiModelProperty("街道名")
    private String name;
    @ApiModelProperty("下属社区列表")
    private List<CommunityVO> childList;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java
@@ -1266,4 +1266,7 @@
     */
    @GetMapping("/uuPush")
    R uuPush(@RequestParam("washPhone")String washPhone,@RequestParam("phone")String phone,@RequestParam("washName")String washName,@RequestParam("orderStatus")Integer orderStatus);
    @GetMapping("/communityList")
    R communityList(@RequestParam("type") Integer type);
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java
@@ -3,8 +3,14 @@
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import cn.hutool.core.util.StrUtil;
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.constants.TokenConstant;
import com.panzhihua.common.model.vos.user.IndexDataAnalysisVO;
import com.panzhihua.common.model.vos.user.StreetVO;
import com.panzhihua.common.utlis.AES;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.util.ObjectUtils;
@@ -26,6 +32,8 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -75,4 +83,32 @@
        }
        return r;
    }
    @GetMapping("/communityList")
    @ApiOperation(value = "获取当前账号下的社区/村落列表",response = StreetVO.class)
    public R communityList(){
        //获取当前登录用户的信息
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        // 从获取RequestAttributes中获取HttpServletRequest的信息
        HttpServletRequest request =
                (HttpServletRequest)requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST);
        // 登录对象信息
        String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO);
        boolean empty = ObjectUtils.isEmpty(userInfo);
        if (empty) {
            log.error("获取登录用户信息失败【{}】");
        }
        byte[] bytes = AES.parseHexStr2Byte(userInfo);
        byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY);
        userInfo = new String(decrypt);
        LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(userInfo, LoginUserInfoVO.class);
        //截取社区名
        int length = loginUserInfoVO.getCommunityName().length();
        String sub = StrUtil.sub(loginUserInfoVO.getCommunityName(),length-1,length);
        Integer type=1;
        if (sub.equals(Constants.VILLAGE)){
            type=2;
        }
        return userService.communityList(type);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java
@@ -4,6 +4,7 @@
import javax.annotation.Resource;
import cn.hutool.core.util.StrUtil;
import com.panzhihua.common.model.dtos.DataKanBansDto;
import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO;
import com.panzhihua.common.model.dtos.community.convenient.DisableOrEnableConvenientMerchantDTO;
@@ -1417,4 +1418,9 @@
    public R getAreaAndStreet(){
        return userService.getAreaAndStreet();
    }
    @GetMapping("/communityList")
    public R getCommunityList(@RequestParam(value = "type") Integer type){
        return userService.getCommunityList(type);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java
@@ -323,5 +323,9 @@
     * */
    Integer getMonthUsers(@Param("streetId") Long streetId,@Param("areaCode") Long areaCode,@Param("range") String range);
    /**
     * 获取街道下属村/社区
     * */
    List<CommunityVO> selectCommunityByStreetId(@Param("id") Integer streetId,@Param("type") Integer type);
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java
@@ -899,4 +899,9 @@
     * @return
     */
    R uuPush(@RequestParam("washPhone")String washPhone,@RequestParam("phone")String phone,@RequestParam("washName")String washName,@RequestParam("orderStatus")Integer orderStatus);
    /**
     * 获取城镇或村落列表
     * */
    R getCommunityList(Integer type);
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -13,6 +13,8 @@
import javax.annotation.Resource;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
@@ -41,6 +43,7 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -3444,7 +3447,6 @@
        if (userProportions.size()>0){
            for (UserProportion userProportion : userProportions) {
                if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion)){
                    log.info("统计数据"+userProportion);
                    UserRateAnalysisVO vo=new UserRateAnalysisVO();
                    if (monthRange){
                        if (userProportion.getCommunityId().equals("11")){
@@ -3459,7 +3461,6 @@
                    }
                    vo.setName(typeToName(type,userProportion ));
                    vo.setCount(userProportion.getUser());
                    log.info("统计后数据+"+vo);
                    userRateAnalysisVOList.add(vo);
                }
            }
@@ -3603,6 +3604,38 @@
    }
    @Override
    public R getCommunityList(Integer type) {
        List<Integer> areaList = areaCodeList();
        List<AreaVOS> areaVOList=new ArrayList<>();
        for (Integer code : areaList) {
            AreaVOS areaVO=new AreaVOS();
            areaVO.setId(code);
            areaVO.setName(areaCodeToName(code.longValue()));
            List<StreetVO> streetVOS = userDao.selectStreetByAreaCode(code);
            Iterator<StreetVO> iterator = streetVOS.listIterator();
            while (iterator.hasNext()){
                StreetVO vo = iterator.next();
                List<CommunityVO> communityVOS = userDao.selectCommunityByStreetId(vo.getId(), type);
                vo.setCommunityList(communityVOS);
                if (communityVOS==null || communityVOS.size()==0){
                    iterator.remove();
                }
            }
            List<StreetVOS> list=new ArrayList<>();
            for (StreetVO streetVO : streetVOS) {
                StreetVOS vo=new StreetVOS();
                vo.setId(streetVO.getId());
                vo.setName(streetVO.getName());
                vo.setChildList(streetVO.getCommunityList());
                list.add(vo);
            }
            areaVO.setChildList(list);
            areaVOList.add(areaVO);
        }
        return R.ok(areaVOList);
    }
    @Override
    public R getAreaAndStreet() {
        List<Integer> areaCodeList=areaCodeList();
        List<AreaVO> areaVOList=new ArrayList<>();
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml
@@ -707,5 +707,13 @@
            and t.create_at >= #{range}
        </if>
    </select>
    <select id="selectCommunityByStreetId" resultType="com.panzhihua.common.model.vos.user.CommunityVO">
        select community_id as id,name from com_act where street_id =#{id}
        <if test="type == 1">
            and name like concat('%','社区')
        </if>
        <if test="type == 2">
            and name like concat('%','村')
        </if>
    </select>
</mapper>