Merge remote-tracking branch 'origin/huacheng_test' into huacheng_test
| | |
| | | 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; |
| | |
| | | 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 javax.servlet.http.HttpServletRequest; |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | private RedisUtils redisUtils; |
| | | |
| | | private static WxXCXTempSend wxXCXTempSend; |
| | | |
| | | /** |
| | | * url转变为 MultipartFile对象 |
| | | * |
| | |
| | | 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); |
| | | } |
| | | |
| | | return accessToken; |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | HttpServletRequest request = ServletUtils.getRequest(); |
| | | String requestURI = request.getRequestURI(); |
| | | //加上时间戳 |
| | | String datetime = new SimpleDateFormat("yyyyMMdd").format(new Date()); |
| | | //这里是 Redis key的前缀,如: sys:tabieId:表名 如果不需要去掉表名也可以 |
| | | String key = MessageFormat.format("{0}:{1}:{2}", "request_incr",datetime,requestURI); |
| | | //查询 key 是否存在, 不存在返回 1 ,存在的话则自增加1 |
| | | wxXCXTempSend.stringRedisTemplate.opsForValue().increment(key, 1); |
| | | |
| | | } catch (IOException ioe) { |
| | | log.error("小程序http请求异常"); |
| | | ioe.printStackTrace(); |
| | |
| | | |
| | | /** |
| | | * 发布消息时重新设置access_token 防止过期 |
| | | * |
| | | * @param appId |
| | | * @param appSecret |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | public String getAccessTokenValid(String appId,Integer index) throws Exception { |
| | | if (index % 100 == 0){ |
| | | if (index % 1000 == 0) { |
| | | return getAccessToken(appId); |
| | | }else { |
| | | return wxXCXTempSend.stringRedisTemplate.boundValueOps("access_token:access_token:"+appId).get(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public String getWsAccessToken() throws Exception { |
| | | String accessToken = "0"; |
| | | try { |
| | |
| | | } |
| | | return accessToken; |
| | | } |
| | | |
| | | /** |
| | | * 获取西区社区通微信token |
| | | * |
| | | * @return 西区社区通微信token |
| | | * @throws Exception 异常 |
| | | */ |
| | |
| | | * |
| | | * @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"; |
| | |
| | | @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(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}") |
| | |
| | | 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(); |
| | |
| | | |
| | | /** |
| | | * 根据手机号查询社区团队表中用户数量 |
| | | * |
| | | * @param phone 手机号 |
| | | * @return 用户数量 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询西区所有街道列表以及统计人数 |
| | | * |
| | | * @return 西区所有街道列表以及统计人数 |
| | | */ |
| | | List<IndexUserStreetVo> getUserStreetList(@Param("areaCode") String areaCode); |
| | | |
| | | /** |
| | | * 查询街道下社区列表以及统计人数 |
| | | * |
| | | * @param streetId 街道id |
| | | * @return 社区列表以及统计人数 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询街道下社区注册人数统计数据导出 |
| | | * |
| | | * @return 社区注册人数统计数据导出 |
| | | */ |
| | | List<IndexUserStreetExcelExportVo> getUserCommunityExcelExport(String areaCode); |
| | | |
| | | /** |
| | | * 查看是否是社区物业人员 |
| | | * |
| | | * @param userId |
| | | * @param userCommunityId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 查看是否社工 |
| | | * |
| | | * @param phone |
| | | * @param communityId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 查看是否社会组织 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查看是否是微团队成员 |
| | | * |
| | | * @param phone |
| | | * @param userCommunityId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 查询街道信息 |
| | | * |
| | | * @param streetId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询是否是社会组织成员 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询是否社会组织联系人 |
| | | * |
| | | * @param phone |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询是否人大代表 |
| | | * |
| | | * @param phone |
| | | * @param userCommunityId |
| | | * @return |
| | | */ |
| | | int selectCountDpc(@Param("phone") String phone, @Param("userCommunityId") Long userCommunityId); |
| | | |
| | | /** |
| | | * 查看是否网格员 |
| | | * |
| | | * @param phone |
| | | * @param userCommunityId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 查询防疫工作人员信息 |
| | | * |
| | | * @param phone |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询单位管理员 |
| | | * |
| | | * @param phone |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询报道单位id |
| | | * |
| | | * @param phone |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据社区名称查询区县社区联动关系 |
| | | * |
| | | * @param relationName |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据街道id查询区域名称 |
| | | * |
| | | * @param streetId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 看板用户统计:用户占比统计 |
| | | * */ |
| | | */ |
| | | 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); |
| | | |
| | | /** |
| | | * 统计该街道内的所有用户数 |
| | | * */ |
| | | */ |
| | | Integer streetUserCount(@Param("id") Long id,@Param("areaCode")Long areaCode); |
| | | |
| | | /** |
| | | * 街道用户统计 |
| | | * */ |
| | | */ |
| | | 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); |
| | | |
| | | List<UsersStatisticsDTO> getDailyAdd(@Param("createAt") String createAt, @Param("id") Long streetId, @Param("areaCode") Long areaCode, @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); |
| | | |
| | | /** |
| | | * 获取账户id |
| | | * */ |
| | | */ |
| | | List<Integer> selectIdsByAccount(@Param("array") String[] streetList); |
| | | |
| | | List<CommunityVO> selectCommunityByStreetName(String name); |
| | |
| | | |
| | | /** |
| | | * 是否为专家 |
| | | * */ |
| | | */ |
| | | ComSanshuoExpertVO isExpert(String phone); |
| | | |
| | | /** |
| | | * 当前账号是否为专家后台账号 |
| | | * */ |
| | | */ |
| | | int isIndustryCenterAccount(String account); |
| | | |
| | | /** |
| | | * 当前账号是否为专家后台账号 |
| | | * */ |
| | | */ |
| | | int isExpertAccount(String account); |
| | | |
| | | /** |
| | | * 是否为党员 |
| | | * */ |
| | | int isDpcMember(@Param("phone") String phone,@Param("name")String name); |
| | | |
| | | /** |
| | | * 查询两个appid的用户做更新 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | List<SysUserDO> selectByUserId(@Param("userId") Long userId); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public R updateUserPartyStatus(Long userId) { |
| | | SysUserDO sysUserDO = userDao.selectById(userId); |
| | | List<SysUserDO> sysUserDOs = userDao.selectByUserId(userId); |
| | | for (SysUserDO sysUserDO : sysUserDOs) { |
| | | if (sysUserDO != null) { |
| | | sysUserDO.setIsPartymember(1); |
| | | int updated = userDao.updateById(sysUserDO); |
| | |
| | | stringRedisTemplate.delete(userKey); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | String accessToken = ""; |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | accessToken = util.getAccessToken(); |
| | | accessToken = util.getAccessToken("wx118de8a734d269f0"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | 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> |