yanghui
2022-10-31 a899a229a54932495097bdfb2655822d06f8dbe1
Merge branch 'local_20221024' into haucheng_panzhihua

# Conflicts:
# springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java
5个文件已修改
186 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/WxXCXTempSend.java 85 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/message/AcidMessage.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/SysUserDOMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/WxXCXTempSend.java
@@ -1,23 +1,16 @@
package com.panzhihua.common.utlis;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.constants.SecurityConstants;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.user.SysAppConfigVO;
import com.panzhihua.common.redis.RedisUtils;
import com.panzhihua.common.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
@@ -25,14 +18,14 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.constants.SecurityConstants;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@@ -54,6 +47,7 @@
    private RedisUtils redisUtils;
    private static WxXCXTempSend wxXCXTempSend;
    /**
     * url转变为 MultipartFile对象
     *
@@ -65,7 +59,7 @@
    private static MultipartFile createFileItem(String url, String fileName) throws Exception {
        FileItem item = null;
        try {
            HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection();
            HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
            conn.setReadTimeout(30000);
            conn.setConnectTimeout(30000);
            // 设置应用程序要从网络连接读取数据
@@ -77,7 +71,7 @@
                FileItemFactory factory = new DiskFileItemFactory(16, null);
                String textFieldName = "uploadfile";
                item =
                    factory.createItem(textFieldName, ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName);
                        factory.createItem(textFieldName, ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName);
                OutputStream os = item.getOutputStream();
                int bytesRead = 0;
@@ -101,30 +95,27 @@
     * @return
     */
    public String getAccessToken() throws Exception {
         String accessToken = "";
        String accessToken = "";
        String appId = this.getAppId();
        accessToken=wxXCXTempSend.stringRedisTemplate.boundValueOps("access_token:access_token:"+ appId).get();
        /*if (appId.equals(APP_ID)){
            accessToken = validAccessToken(accessToken, appId,APP_SECRET);
        }*/
        accessToken = wxXCXTempSend.stringRedisTemplate.boundValueOps("access_token:access_token:" + appId).get();
        return accessToken;
    }
    public String getAccessToken(String appId) throws Exception {
        String accessToken = "";
        accessToken=wxXCXTempSend.stringRedisTemplate.boundValueOps("access_token:access_token:"+appId).get();
        if (appId.equals(APP_ID)){
            accessToken = validAccessToken(accessToken, appId,APP_SECRET);
        accessToken = wxXCXTempSend.stringRedisTemplate.boundValueOps("access_token:access_token:" + appId).get();
        if (appId.equals(APP_ID)) {
            accessToken = validAccessToken(accessToken, appId, APP_SECRET);
        }
        return accessToken;
    }
    private String validAccessToken(String accessToken, String appId,String appSecret) throws Exception {
    private String validAccessToken(String accessToken, String appId, String appSecret) throws Exception {
        if (StrUtil.isEmpty(accessToken)) {
            //重新获取并设置到缓存 该方法暂时只用在花城
            accessToken = getAppAccessToken(appId, appSecret);
            wxXCXTempSend.stringRedisTemplate.opsForValue().set("access_token:access_token:" + appId, accessToken, EXPIRE_TIME,TimeUnit.HOURS);
            wxXCXTempSend.stringRedisTemplate.opsForValue().set("access_token:access_token:" + appId, accessToken, EXPIRE_TIME, TimeUnit.HOURS);
        } else {
            String accessTokenUrl = WX_CALL_BACK + accessToken;
            String result = HttpClientUtil.httpGet(accessTokenUrl, null, null);
@@ -132,13 +123,13 @@
            //如果Access_token过期也重新获取
            if (resultMap.containsKey("errcode")) {
                accessToken = getAppAccessToken(appId, appSecret);
                wxXCXTempSend.stringRedisTemplate.opsForValue().set("access_token:access_token:" + appId, accessToken, EXPIRE_TIME,TimeUnit.HOURS);
                wxXCXTempSend.stringRedisTemplate.opsForValue().set("access_token:access_token:" + appId, accessToken, EXPIRE_TIME, TimeUnit.HOURS);
            }
        }
        return accessToken;
    }
    public String getAppAccessToken(String appId,String appSecret) throws Exception {
    public String getAppAccessToken(String appId, String appSecret) throws Exception {
        String accessToken = "0";
        try {
            log.info("获取微信token参数:appid=" + appId + ",appSecret=" + appSecret);
@@ -157,11 +148,12 @@
    /**
     * 发布消息时重新设置access_token 防止过期
     *
     * @param appId
     * @param appSecret
     * @throws Exception
     */
    public void setAppAccessTokenToCache(String appId,String appSecret) throws Exception{
    public void setAppAccessTokenToCache(String appId, String appSecret) throws Exception {
        String accessToken = "0";
        try {
            log.info("获取微信token参数:appid=" + appId + ",appSecret=" + appSecret);
@@ -170,7 +162,7 @@
            Map<String, Object> resultMap = JSON.parseObject(result, Map.class);
            if (resultMap.containsKey("access_token")) {
                accessToken = resultMap.get("access_token").toString();
                wxXCXTempSend.stringRedisTemplate.opsForValue().set("access_token:access_token:" + appId, accessToken, EXPIRE_TIME,TimeUnit.HOURS);
                wxXCXTempSend.stringRedisTemplate.opsForValue().set("access_token:access_token:" + appId, accessToken, EXPIRE_TIME, TimeUnit.HOURS);
            }
        } catch (IOException ioe) {
            log.error("小程序http请求异常");
@@ -178,19 +170,20 @@
        }
    }
    public String getAccessTokenValid(String appId,Integer index) throws Exception {
        if (index % 1000 == 0){
    public String getAccessTokenValid(String appId, Integer index) throws Exception {
        if (index % 1000 == 0) {
            return getAccessToken(appId);
        }else {
            return wxXCXTempSend.stringRedisTemplate.boundValueOps("access_token:access_token:"+appId).get();
        } else {
            return wxXCXTempSend.stringRedisTemplate.boundValueOps("access_token:access_token:" + appId).get();
        }
    }
    public String getWsAccessToken() throws Exception {
        String accessToken = "0";
        try {
//            log.info("获取微信token参数:appid=" + APP_ID + ",appSecret=" + APP_SECRET);
            String accessTokenUrl = ACCESS_TOKEN_URL + "&appid=wx98d62711dfbd8425"+ "&secret=97a2a10b990c2774ed279724337b5337";
            String accessTokenUrl = ACCESS_TOKEN_URL + "&appid=wx98d62711dfbd8425" + "&secret=97a2a10b990c2774ed279724337b5337";
            String result = HttpClientUtil.httpGet(accessTokenUrl, null, null);
            Map<String, Object> resultMap = JSON.parseObject(result, Map.class);
            if (resultMap.containsKey("access_token")) {
@@ -202,9 +195,11 @@
        }
        return accessToken;
    }
    /**
     * 获取西区社区通微信token
     * @return  西区社区通微信token
     *
     * @return 西区社区通微信token
     * @throws Exception 异常
     */
    public String getXQAppAccessToken() throws Exception {
@@ -237,7 +232,7 @@
                mediaId = getAppMediaId(accessToken);
                valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID, mediaId);
                valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID_TIME,
                    System.currentTimeMillis() + 259000000 + "");
                        System.currentTimeMillis() + 259000000 + "");
            } else {
                mediaId = valueOperations.get(SecurityConstants.APPLETS_ACCESS_MEDIA_ID);
            }
@@ -245,7 +240,7 @@
            mediaId = getAppMediaId(accessToken);
            valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID, mediaId);
            valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID_TIME,
                System.currentTimeMillis() + 259000000 + "");
                    System.currentTimeMillis() + 259000000 + "");
        }
        return mediaId;
    }
@@ -266,15 +261,15 @@
     *
     * @param file
     * @return
     * @author yixiu
     * @throws Exception
     * @author yixiu
     */
    public String uploadFile(MultipartFile file, String access_token) throws Exception {
        String url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + access_token + "&type=image";
        String result = null;
        String fileName = file.getOriginalFilename();
        URL urlObj = new URL(url);
        HttpURLConnection con = (HttpURLConnection)urlObj.openConnection();
        HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
        con.setRequestMethod("POST");
        con.setDoInput(true);
        con.setDoOutput(true);
@@ -346,8 +341,8 @@
    public void init() {
        wxXCXTempSend = this;
        wxXCXTempSend.redisTemplate = this.redisTemplate;
        wxXCXTempSend.stringRedisTemplate=this.stringRedisTemplate;
        wxXCXTempSend.redisUtils=this.redisUtils;
        wxXCXTempSend.stringRedisTemplate = this.stringRedisTemplate;
        wxXCXTempSend.redisUtils = this.redisUtils;
    }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/message/AcidMessage.java
@@ -117,18 +117,13 @@
        try{
            List<String> openIds=sysUserDao.selectOpenId();
            String appId = "wx118de8a734d269f0";
            String appSecret = "0264342daefde5cd70a6adada09ee5b1";
            WxXCXTempSend wxXCXTempSend=new WxXCXTempSend();
//            wxXCXTempSend.setAppAccessTokenToCache(appId,appSecret);
            for (int i = 0; i < openIds.size(); i++) {
                try {
                    WxUtil.sendLongTimeTemplate(openIds.get(i),wxXCXTempSend.getAccessTokenValid(appId,i),"疫情快讯",comActDynVO.getTitle().length()>10?comActDynVO.getTitle().substring(0,10)+"..":comActDynVO.getTitle(),"/pages/community_child/community/detail?id="+comActDynVO.getId()+"&title=疫情快讯详情");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            for(String openId:openIds){
            }
        }catch (Exception e){
            e.printStackTrace();
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java
@@ -201,32 +201,37 @@
    /**
     * 根据手机号查询社区团队表中用户数量
     *
     * @param phone 手机号
     * @return  用户数量
     * @return 用户数量
     */
    Integer getCommunityTeamCount(@Param("phone") String phone);
    /**
     * 查询西区所有街道列表以及统计人数
     * @return  西区所有街道列表以及统计人数
     *
     * @return 西区所有街道列表以及统计人数
     */
    List<IndexUserStreetVo> getUserStreetList(@Param("areaCode") String areaCode);
    /**
     * 查询街道下社区列表以及统计人数
     * @param streetId  街道id
     * @return  社区列表以及统计人数
     *
     * @param streetId 街道id
     * @return 社区列表以及统计人数
     */
    List<IndexUserCommunityVo> getUserCommunityList(@Param("streetId") Long streetId);
    /**
     * 查询街道下社区注册人数统计数据导出
     * @return  社区注册人数统计数据导出
     *
     * @return 社区注册人数统计数据导出
     */
    List<IndexUserStreetExcelExportVo> getUserCommunityExcelExport(String areaCode);
    /**
     * 查看是否是社区物业人员
     *
     * @param userId
     * @param userCommunityId
     * @return
@@ -235,6 +240,7 @@
    /**
     * 查看是否社工
     *
     * @param phone
     * @param communityId
     * @return
@@ -243,6 +249,7 @@
    /**
     * 查看是否社会组织
     *
     * @param userId
     * @return
     */
@@ -251,6 +258,7 @@
    /**
     * 查看是否是微团队成员
     *
     * @param phone
     * @param userCommunityId
     * @return
@@ -259,6 +267,7 @@
    /**
     * 查询街道信息
     *
     * @param streetId
     * @return
     */
@@ -266,6 +275,7 @@
    /**
     * 查询是否是社会组织成员
     *
     * @param userId
     * @return
     */
@@ -273,6 +283,7 @@
    /**
     * 查询是否社会组织联系人
     *
     * @param phone
     * @return
     */
@@ -280,13 +291,16 @@
    /**
     * 查询是否人大代表
     *
     * @param phone
     * @param userCommunityId
     * @return
     */
    int selectCountDpc(@Param("phone") String phone, @Param("userCommunityId") Long userCommunityId);
    /**
     * 查看是否网格员
     *
     * @param phone
     * @param userCommunityId
     * @return
@@ -295,6 +309,7 @@
    /**
     * 查询防疫工作人员信息
     *
     * @param phone
     * @return
     */
@@ -302,6 +317,7 @@
    /**
     * 查询单位管理员
     *
     * @param phone
     * @return
     */
@@ -309,6 +325,7 @@
    /**
     * 查询报道单位id
     *
     * @param phone
     * @return
     */
@@ -316,6 +333,7 @@
    /**
     * 根据社区名称查询区县社区联动关系
     *
     * @param relationName
     * @return
     */
@@ -323,6 +341,7 @@
    /**
     * 根据街道id查询区域名称
     *
     * @param streetId
     * @return
     */
@@ -330,28 +349,28 @@
    /**
     * 看板用户统计:用户占比统计
     * */
    List<UserProportion> userAnalysis(@Param("type") Integer type,@Param("range") String range,@Param("streetId") Long streetId,@Param("areaCode")Long areaCode,@Param("appId")String appId);
     */
    List<UserProportion> userAnalysis(@Param("type") Integer type, @Param("range") String range, @Param("streetId") Long streetId, @Param("areaCode") Long areaCode, @Param("appId") String appId);
    /**
     * 统计区域实名用户数
     * */
    List<RealUser> realUserCount(@Param("type") Integer type,@Param("range") String range,@Param("streetId") Long streetId,@Param("areaCode")Long areaCode,@Param("appId")String appId);
     */
    List<RealUser> realUserCount(@Param("type") Integer type, @Param("range") String range, @Param("streetId") Long streetId, @Param("areaCode") Long areaCode, @Param("appId") String appId);
    /**
     * 统计该街道内的所有用户数
     * */
    Integer streetUserCount(@Param("id") Long id,@Param("areaCode")Long areaCode);
     */
    Integer streetUserCount(@Param("id") Long id, @Param("areaCode") Long areaCode);
    /**
     * 街道用户统计
     * */
    IndexDataKanbanVO dataKanBanStreet(@Param("streetId") Long streetId,@Param("areaCode") Long areaCode,@Param("range") String range);
     */
    IndexDataKanbanVO dataKanBanStreet(@Param("streetId") Long streetId, @Param("areaCode") Long areaCode, @Param("range") String range);
    /**
     * 获取当天的新增和日活
     * */
    Map<String,Long> getDailyAddAndActive(@Param("date") Date date, @Param("id") Long streetId, @Param("areaCode") Long areaCode, @Param("appId") String appId);
     */
    Map<String, Long> getDailyAddAndActive(@Param("date") Date date, @Param("id") Long streetId, @Param("areaCode") Long areaCode, @Param("appId") String appId);
    List<UsersStatisticsDTO> getDailyAdd(@Param("createAt") String createAt, @Param("id") Long streetId, @Param("areaCode") Long areaCode, @Param("appId") String appId);
@@ -370,17 +389,17 @@
    /**
     * 获取本月的
     * */
    Integer getMonthUsers(@Param("streetId") Long streetId,@Param("areaCode") Long areaCode,@Param("range") String range,@Param("appId")String appId);
     */
    Integer getMonthUsers(@Param("streetId") Long streetId, @Param("areaCode") Long areaCode, @Param("range") String range, @Param("appId") String appId);
    /**
     * 获取街道下属村/社区
     * */
    List<CommunityVO> selectCommunityByStreetId(@Param("id") Long streetId,@Param("type") Integer type);
     */
    List<CommunityVO> selectCommunityByStreetId(@Param("id") Long streetId, @Param("type") Integer type);
    /**
     * 获取账户id
     * */
     */
    List<Integer> selectIdsByAccount(@Param("array") String[] streetList);
    List<CommunityVO> selectCommunityByStreetName(String name);
@@ -389,20 +408,27 @@
    /**
     * 是否为专家
     * */
     */
    ComSanshuoExpertVO isExpert(String phone);
    /**
     * 当前账号是否为专家后台账号
     * */
     */
    int isIndustryCenterAccount(String account);
    /**
     * 当前账号是否为专家后台账号
     * */
     */
    int isExpertAccount(String account);
    /**
     * 查询两个appid的用户做更新
     * @param userId
     * @return
     */
    List<SysUserDO> selectByUserId(@Param("userId") Long userId);
    /**
     * 是否为党员
     * */
    int isDpcMember(@Param("phone") String phone,@Param("name")String name);
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -3300,16 +3300,19 @@
    @Override
    public R updateUserPartyStatus(Long userId) {
        SysUserDO sysUserDO = userDao.selectById(userId);
        if (sysUserDO != null) {
            sysUserDO.setIsPartymember(1);
            int updated = userDao.updateById(sysUserDO);
            if (updated > 0) {
                // 删除用户信息缓存
                String userKey = UserConstants.LOGIN_USER_INFO + sysUserDO.getUserId();
                stringRedisTemplate.delete(userKey);
        List<SysUserDO> sysUserDOs = userDao.selectByUserId(userId);
        for (SysUserDO sysUserDO : sysUserDOs) {
            if (sysUserDO != null) {
                sysUserDO.setIsPartymember(1);
                int updated = userDao.updateById(sysUserDO);
                if (updated > 0) {
                    // 删除用户信息缓存
                    String userKey = UserConstants.LOGIN_USER_INFO + sysUserDO.getUserId();
                    stringRedisTemplate.delete(userKey);
                }
            }
        }
        return R.ok();
    }
@@ -3630,7 +3633,7 @@
                String accessToken = "";
                WxXCXTempSend util = new WxXCXTempSend();
                try {
                    accessToken = util.getAccessToken();
                    accessToken = util.getAccessToken("wx118de8a734d269f0");
                } catch (Exception e) {
                    e.printStackTrace();
                }
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/SysUserDOMapper.xml
@@ -105,5 +105,8 @@
        ORDER BY
            u.user_id DESC
    </select>
    <select id="selectByUserId" resultMap="BaseResultMap">
        SELECT u1.* FROM sys_user u1 WHERE u1.phone = (SELECT phone FROM sys_user u2 WHERE u2.user_id=#{userId}) AND u1.app_id in ('wx118de8a734d269f0','wx0cef797390444b75')
    </select>
</mapper>