| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.codec.Base64; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.model.dtos.community.building.BuildingDto; |
| | | import com.panzhihua.common.model.dtos.community.large.AreaStreetDetail; |
| | | import com.panzhihua.common.model.dtos.community.large.AreaStreetDetailResp; |
| | | import com.panzhihua.common.model.dtos.community.large.SumAreaStreetResp; |
| | | import com.panzhihua.common.model.dtos.partybuilding.QryReportResp; |
| | | import com.panzhihua.common.model.vos.StreetVO; |
| | | import com.panzhihua.common.model.vos.area.StreetAndBuildVO; |
| | | import com.panzhihua.common.model.vos.community.bigscreen.ScreenStatics; |
| | | import com.panzhihua.common.model.vos.community.screen.event.EventPopulationSpecialStatisticsVO; |
| | | import com.panzhihua.common.model.vos.neighbor.ActivityAnalysisVO; |
| | | import com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO; |
| | | import com.panzhihua.common.model.vos.user.AdministratorsUserVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.service_community.dao.ComEventMapper; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.service_community.dao.*; |
| | | |
| | | import com.panzhihua.service_community.entity.ComEvent; |
| | | |
| | | import com.panzhihua.service_community.service.ComAreaTownCommunityService; |
| | | import com.panzhihua.service_community.util.MyAESUtil; |
| | | import com.panzhihua.service_community.util.WxDataUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActVO; |
| | | import com.panzhihua.common.model.vos.community.ComStreetVO; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComStreetDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ComStreetDO; |
| | | import com.panzhihua.service_community.service.ComStreetService; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | /** |
| | | * @author: llming |
| | |
| | | |
| | | @Resource |
| | | private ComEventMapper comEventMapper; |
| | | |
| | | @Autowired |
| | | private CommunityService communityService; |
| | | |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | /** |
| | | * 新增社区 |
| | |
| | | administratorsUserVO.setRoleId(777777777L); |
| | | administratorsUserVO.setStreetId(0L); |
| | | administratorsUserVO.setName(comStreetVO.getName()); |
| | | administratorsUserVO.setUserId(Snowflake.getId()); |
| | | R r=userService.addUserBackstageProperty(administratorsUserVO); |
| | | if(R.isOk(r)){ |
| | | BeanUtils.copyProperties(comStreetVO, comStreetDO); |
| | |
| | | return R.ok(comStreetDAO.updateById(comStreetDO)); |
| | | } |
| | | |
| | | @Override |
| | | public R panzhihuaMap(String areaCode) { |
| | | |
| | | List<ComActVO> comActVOS = comActDAO.panzhihuaMap(areaCode); |
| | | return R.ok(comActVOS); |
| | | } |
| | | |
| | | @Override |
| | | public R searchStreet(BuildingDto buildingDto) { |
| | | QueryWrapper<ComStreetDO> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq(buildingDto.getAreaCode()!= null,"area_code",buildingDto.getAreaCode()); |
| | | wrapper.eq("app_id","wx118de8a734d269f0"); |
| | | List<ComStreetDO> comStreetDOS = comStreetDAO.selectList(wrapper); |
| | | // ArrayList<ComStreetDO> collect = comStreetDOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>( |
| | | // Comparator.comparing(ComStreetDO::getAreaCode))), ArrayList::new)); |
| | | List<StreetVO> list = comStreetDOS.stream().map(v -> { |
| | | StreetVO vo = new StreetVO(); |
| | | vo.setStreetId(String.valueOf(v.getStreetId())); |
| | | vo.setName(v.getName()); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @Override |
| | | public R oneTagThreeReal(Long street) { |
| | | List<StreetAndBuildVO> streetAndBuildVOS = comActDAO.oneTagThreeReal(street); |
| | | return R.ok(streetAndBuildVOS); |
| | | } |
| | | |
| | | @Override |
| | | public R getScreenStatics() { |
| | | ScreenStatics screenStatics = comActDAO.getScreenStatics(); |
| | | WxDataUtil wxDataUtil=new WxDataUtil(); |
| | | //微信查询较慢 数据时有 时没有 缓存到 redis 里 |
| | | //日 活跃 |
| | | if(null != wxDataUtil.getDayUser()){ |
| | | stringRedisTemplate.opsForValue().set("WxDataUtil_Day",String.valueOf(wxDataUtil.getDayUser())); |
| | | screenStatics.setDayUser(wxDataUtil.getDayUser()); |
| | | }else { |
| | | Object obj = stringRedisTemplate.opsForValue().get("WxDataUtil_Day"); |
| | | screenStatics.setDayUser(Integer.valueOf((String)obj)); |
| | | } |
| | | //月 活跃 |
| | | if(null != wxDataUtil.getMonthUser()){ |
| | | stringRedisTemplate.opsForValue().set("WxDataUtil_Month",String.valueOf(wxDataUtil.getMonthUser())); |
| | | screenStatics.setCountUser(wxDataUtil.getMonthUser()); |
| | | }else { |
| | | Object obj = stringRedisTemplate.opsForValue().get("WxDataUtil_Month"); |
| | | screenStatics.setCountUser(Integer.valueOf((String)obj)); |
| | | } |
| | | return R.ok(screenStatics); |
| | | } |
| | | |
| | | @Override |
| | | public R populationStatics(Long streetId) { |
| | | StreetAndBuildVO vo = new StreetAndBuildVO(); |
| | | List<StreetAndBuildVO> list = comActDAO.oneTagThreeReal(streetId); |
| | | if(list != null){ |
| | | for (StreetAndBuildVO basics : list) { |
| | | vo.setPeopleNum(vo.getPeopleNum() + basics.getPeopleNum()); |
| | | vo.setVillageNum(vo.getVillageNum() + basics.getVillageNum()); |
| | | vo.setBuildNum(vo.getBuildNum() + basics.getBuildNum()); |
| | | } |
| | | } |
| | | EventPopulationSpecialStatisticsVO populationSpecial = comActDAO.getPopulationSpecial(streetId); |
| | | if(populationSpecial != null){ |
| | | populationSpecial.setOtherTotal(populationSpecial.getZjTotal() + populationSpecial.getSfTotal() |
| | | + populationSpecial.getXsTotal() + populationSpecial.getXjTotal() |
| | | + populationSpecial.getJzTotal() + populationSpecial.getXdTotal()); |
| | | populationSpecial.setLnTotal(comActDAO.getPopulationAge(streetId,60)); |
| | | populationSpecial.setGlTotal(comActDAO.getPopulationAge(streetId,80)); |
| | | vo.setSpecialStatisticsVo(populationSpecial); |
| | | } |
| | | vo.setSpecialStatisticsVo(populationSpecial); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | @Override |
| | | public R probably(Integer year,String belongTo) { |
| | | ActivityAnalysisVO activityVO=new ActivityAnalysisVO(); |
| | | // String beginTime=null; |
| | | // String endTime=null; |
| | | // if (null != year){ |
| | | // //设置开始,截止时间 |
| | | // beginTime=year.toString().concat("-01-01"); |
| | | // endTime=year.toString().concat("-12-31"); |
| | | // } |
| | | activityVO.setUnitCount(comActDAO.arriveUnit(belongTo)); |
| | | R r = communityService.institutionalUnitServiceAnalysis(year, null, null, null, |
| | | null, null, belongTo, null, null,null); |
| | | Object data = r.getData(); |
| | | String jsonString = JSON.toJSONString(data); |
| | | ActivityAnalysisVO activityAnalysisVO = JSON.parseObject(jsonString, ActivityAnalysisVO.class); |
| | | activityVO.setUnitServiceTotalTime(activityAnalysisVO.getUnitServiceTotalTime()); |
| | | return R.ok(activityVO); |
| | | } |
| | | |
| | | @Override |
| | | public SumAreaStreetResp sumAreaStreet() { |
| | | SumAreaStreetResp resp = comActDAO.sumAreaStreet(); |
| | | return resp; |
| | | } |
| | | |
| | | @Override |
| | | public AreaStreetDetail areaStreetDetail(String code, String type) { |
| | | //根据层级 查询 社区id |
| | | LambdaQueryWrapper<ComActDO> qry = new LambdaQueryWrapper<>(); |
| | | if(type.equals("1")){// 1 查询 大区 |
| | | qry.eq( !StringUtils.isEmpty(code),ComActDO::getAreaCode,code); |
| | | } |
| | | if(type.equals("2")){// 2 查询 街道 |
| | | qry.eq( !StringUtils.isEmpty(code),ComActDO::getStreetId,code); |
| | | } |
| | | if(type.equals("3")){// 3 查询 小区 |
| | | qry.eq( !StringUtils.isEmpty(code),ComActDO::getCommunityId,code); |
| | | } |
| | | // qry.eq(ComActDO::getAppId,"wx118de8a734d269f0"); |
| | | List<ComActDO> doList = comActDAO.selectList(qry); |
| | | //解析 社区id |
| | | List<Long> ids = doList.stream().map(ComActDO::getCommunityId).collect(Collectors.toList()); |
| | | |
| | | AreaStreetDetail result = new AreaStreetDetail(); |
| | | if(CollectionUtil.isNotEmpty(ids)){ |
| | | //查询 街道相关信息 |
| | | AreaStreetDetailResp village = comActDAO.selectVillage(ids,type); |
| | | result.setAreaStreetDetailResp(village); |
| | | //查询 人口相关数据 |
| | | EventPopulationSpecialStatisticsVO eventResult = comActDAO.selectEvent(ids); |
| | | result.setEventPopulationVO(eventResult); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<QryReportResp> qryReport(String yearTime) { |
| | | List<QryReportResp> result = comActDAO.qryReport(yearTime); |
| | | return result; |
| | | } |
| | | } |