| | |
| | | import com.panzhihua.common.enums.PopulCultureLevelEnum; |
| | | import com.panzhihua.common.enums.PopulHouseUseEnum; |
| | | import com.panzhihua.common.enums.PopulIsOksEnum; |
| | | import com.panzhihua.common.enums.PopulMarriageEnum; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.dtos.community.*; |
| | | import com.panzhihua.common.model.dtos.community.bigscreen.BigScreenEventDetailDTO; |
| | | import com.panzhihua.common.model.dtos.grid.PagePopulationListDTO; |
| | | import com.panzhihua.common.model.dtos.user.PageInputUserDTO; |
| | | import com.panzhihua.common.model.helper.AESUtil; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.area.AreaAddressVO; |
| | | import com.panzhihua.common.model.vos.community.*; |
| | | import com.panzhihua.common.model.vos.screen.ComActPopulationCultureVO; |
| | | import com.panzhihua.common.model.vos.community.bigscreen.BigScreenStatisticPartyBuild; |
| | | import com.panzhihua.common.model.vos.community.screen.civil.CivilPopulationStatisticsVO; |
| | | import com.panzhihua.common.model.vos.community.screen.civil.CivilStatisticsVO; |
| | |
| | | import com.panzhihua.common.model.vos.community.screen.index.*; |
| | | import com.panzhihua.common.model.vos.grid.EventGridDataVO; |
| | | import com.panzhihua.common.model.vos.grid.EventResourceVO; |
| | | import com.panzhihua.common.model.vos.grid.PopulationDetailVO; |
| | | import com.panzhihua.common.model.vos.grid.PopulationListVO; |
| | | import com.panzhihua.common.model.vos.screen.ComActPopulationCultureVO; |
| | | import com.panzhihua.common.model.vos.screen.ComActPopulationScreenVO; |
| | | import com.panzhihua.common.model.vos.screen.ComMngPopulationAgeVO; |
| | | import com.panzhihua.common.model.vos.user.*; |
| | | import com.panzhihua.common.utlis.*; |
| | | import com.panzhihua.common.utlis.AgeUtils; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.*; |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.ComMngPopulationHouseUserService; |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.crypto.BadPaddingException; |
| | | import javax.crypto.IllegalBlockSizeException; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | Long pageNum = comMngPopulationVO.getPageNum(); |
| | | Long pageSize = comMngPopulationVO.getPageSize(); |
| | | if (null == pageNum || 0 == pageNum) { |
| | | pageNum = 1l; |
| | | pageNum = 1L; |
| | | } |
| | | if (null == pageSize || 0 == pageSize) { |
| | | pageSize = 10l; |
| | | pageSize = 10L; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | |
| | | .eq(ComMngPopulationDO::getCardNo,cardNoAES)); |
| | | if(populationDO == null){ |
| | | //不存在实有人口,则新增 |
| | | populationDO = savePopulationDO(vo,comActDO,comMngVillageDO,cardNoAES); |
| | | populationDO = savePopulationDO(vo, comActDO, comMngVillageDO); |
| | | }else { |
| | | //如果存在人口信息,且是自用房,则更新人口默认的房屋信息 |
| | | if(vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())){ |
| | | populationDO = updatePopulationHouseUse(vo,populationDO,cardNoAES); |
| | | populationDO = updatePopulationHouseUse(vo, populationDO); |
| | | } |
| | | } |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | private ComMngPopulationDO updatePopulationHouseUse(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO,String cardNoAES) throws Exception { |
| | | private ComMngPopulationDO updatePopulationHouseUse(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO) throws Exception { |
| | | populationDO.setRoad(vo.getRoad()); |
| | | populationDO.setDoorNo(vo.getDoorNo()); |
| | | populationDO.setFloor(vo.getFloor()); |
| | | populationDO.setUnitNo(vo.getUnitNo()); |
| | | populationDO.setHouseNo(vo.getHouseNo()); |
| | | populationDO.setCardNo(cardNoAES); |
| | | populationDO.setCardNo(vo.getCardNo()); |
| | | populationDO.setCardNoStr(vo.getCardNo()); |
| | | if(StringUtils.isNotEmpty(populationDO.getPhone())){ |
| | | populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey)); |
| | | // populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey)); |
| | | populationDO.setPhone(populationDO.getPhone()); |
| | | } |
| | | this.baseMapper.updateById(populationDO); |
| | | return populationDO; |
| | | } |
| | | |
| | | private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComActDO comActDO, ComMngVillageDO comMngVillageDO,String cardNoAES) { |
| | | private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComActDO comActDO, ComMngVillageDO comMngVillageDO) { |
| | | ComMngPopulationDO populationDO = new ComMngPopulationDO(); |
| | | BeanUtils.copyProperties(vo,populationDO); |
| | | populationDO.setId(Snowflake.getId()); |
| | |
| | | populationDO.setStreetId(comActDO.getStreetId()); |
| | | populationDO.setLabel(Joiner.on(",").join(userTag)); |
| | | populationDO.setVillageName(comMngVillageDO.getGroupAt()); |
| | | populationDO.setCardNo(cardNoAES); |
| | | populationDO.setCardNo(vo.getCardNo()); |
| | | populationDO.setCardNoStr(vo.getCardNo()); |
| | | populationDO.setUpdateAt(new Date()); |
| | | this.baseMapper.insert(populationDO); |
| | |
| | | |
| | | /** |
| | | * 确认导入实有人口(有则更新,无则新建) |
| | | * |
| | | * @param list 用户信息 |
| | | * @param communityId 社区id |
| | | * @return 导入结果 |
| | |
| | | |
| | | /** |
| | | * 根据id修改实有人口标签 |
| | | * |
| | | * @param populationTagDTO 请求参数 |
| | | * @return 修改结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 批量删除实有人口 |
| | | * |
| | | * @param Ids |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据社区id查询所有实有人口 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据id集合查询实有人口 |
| | | * |
| | | * @param Ids 实有人口id集合 |
| | | * @return 查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除特殊群体人员 |
| | | * |
| | | * @param id 特殊群体id |
| | | * @return 删除结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询实有人口电子档信息 |
| | | * |
| | | * @param populationId 实有人口id |
| | | * @return 实有人口电子档信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 实有人口统计 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | |
| | | return R.ok(this.baseMapper.getPopulationTotalByAdmin(communityId)); |
| | | } |
| | | |
| | | @Override |
| | | public R editTagPopulationByCardNo(ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO) { |
| | | ComMngPopulationDO comMngPopulationDO = getPopulationByCardNo(comMngPopulationTagCardNoDTO.getCardNo()); |
| | | if (comMngPopulationDO == null) { |
| | | return R.fail("未查询到人口记录"); |
| | | } |
| | | ComMngPopulationDO comMngPopulation = new ComMngPopulationDO(); |
| | | if (comMngPopulationDO.getLabel() != null) { |
| | | if (!comMngPopulationDO.getLabel().contains(comMngPopulationTagCardNoDTO.getLabel())) { |
| | | comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel().concat(",").concat(comMngPopulationDO.getLabel())); |
| | | } |
| | | } else { |
| | | comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel()); |
| | | } |
| | | comMngPopulation.setCardNo(null); |
| | | comMngPopulation.setId(comMngPopulationDO.getId()); |
| | | int nub = populationDAO.updateById(comMngPopulation); |
| | | if (nub < 1) { |
| | | return R.fail(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public ComMngPopulationDO getPopulationByCardNo(String cardNo) { |
| | | try { |
| | | String aesCardNo = AESUtil.encrypt128(cardNo, aesKey); |
| | | return baseMapper.selectOne( |
| | | new QueryWrapper<ComMngPopulationDO>() |
| | | .eq("card_no", aesCardNo) |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("根据身份证查询业务-加密证件信息出错:{}", e.getCause()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 首页大屏统计接口 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 事件大屏统计接口 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | |
| | | List<EventGridIncidentStatisticsVO> gridIncidentList = this.baseMapper.getEventScreenEventList(communityId); |
| | | statisticsVO.setGridIncidentList(gridIncidentList); |
| | | |
| | | //查询小区列表 |
| | | List<CivilVillageStatisticsVO> villageStatisticsList = this.baseMapper.getCivilScreenVillageList(communityId); |
| | | if(!villageStatisticsList.isEmpty()){ |
| | | villageStatisticsList.forEach(village -> { |
| | | CivilVillageStatisticsVO villageStatisticsVO = this.baseMapper.getCivilScreenVillageStatistics(village.getVillageId()); |
| | | if(villageStatisticsVO != null){ |
| | | BeanUtils.copyProperties(villageStatisticsVO,village); |
| | | } |
| | | }); |
| | | } |
| | | statisticsVO.setVillageStatisticsList(villageStatisticsList); |
| | | |
| | | //查询统计人口数据 |
| | | ComMngPopulationTotalVO populationTotalVO = populationDAO.getPopulationTotalByAdmin(communityId); |
| | | statisticsVO.setPopulationTotalVO(populationTotalVO); |
| | | |
| | | return R.ok(statisticsVO); |
| | | } |
| | | |
| | | /** |
| | | * 民生大屏统计接口 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R editTagPopulationByCardNo(ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO) { |
| | | ComMngPopulationDO comMngPopulationDO = getPopulationByCardNo(comMngPopulationTagCardNoDTO.getCardNo()); |
| | | if (comMngPopulationDO == null) { |
| | | return R.fail("未查询到人口记录"); |
| | | } |
| | | ComMngPopulationDO comMngPopulation = new ComMngPopulationDO(); |
| | | if(comMngPopulationDO.getLabel()!=null) { |
| | | if(!comMngPopulationDO.getLabel().contains(comMngPopulationTagCardNoDTO.getLabel())) { |
| | | comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel().concat(",").concat(comMngPopulationDO.getLabel())); |
| | | } |
| | | }else{ |
| | | comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel()); |
| | | } |
| | | comMngPopulation.setCardNo(null); |
| | | comMngPopulation.setId(comMngPopulationDO.getId()); |
| | | int nub = populationDAO.updateById(comMngPopulation); |
| | | if (nub < 1) { |
| | | return R.fail(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public ComMngPopulationDO getPopulationByCardNo(String cardNo) { |
| | | try { |
| | | String aesCardNo = AESUtil.encrypt128(cardNo, aesKey); |
| | | return baseMapper.selectOne( |
| | | new QueryWrapper<ComMngPopulationDO>() |
| | | .eq("card_no",aesCardNo) |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("根据身份证查询业务-加密证件信息出错"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R screenStatistic(Long communityId) { |
| | | ComActPopulationScreenVO comActPopulationScreenVO = new ComActPopulationScreenVO(); |
| | | ComMngPopulationTotalVO vo = populationDAO.getPopulationTotalByAdmin(communityId); |
| | |
| | | setAgeGroup(comActPopulationScreenVO,communityId); |
| | | //统计学历 |
| | | setCultureGroup(comActPopulationScreenVO,communityId); |
| | | |
| | | //查询网格数据 |
| | | List<EventGridStatisticsVO> gridStatisticsList = this.baseMapper.getEventScreenGridData(communityId); |
| | | comActPopulationScreenVO.setGridStatisticsList(gridStatisticsList); |
| | | |
| | | //查询小区列表 |
| | | List<CivilVillageStatisticsVO> villageStatisticsList = this.baseMapper.getCivilScreenVillageList(communityId); |
| | | comActPopulationScreenVO.setVillageStatisticsList(villageStatisticsList); |
| | | |
| | | return R.ok(comActPopulationScreenVO); |
| | | } |
| | |
| | | |
| | | //查询事件流转记录 |
| | | List<EventTransferRecordVO> transferRecordList = this.baseMapper.getEventScreenEventTransList(eventDetailDTO.getEventId()); |
| | | if(!transferRecordList.isEmpty()){ |
| | | transferRecordList.forEach(transfer -> { |
| | | if(transfer.getFromType().equals(EventTransferRecordVO.fromType.wgy)){ |
| | | //查询上级网格信息 |
| | | EventTransferRecordDetailVO transferRecordDetailVO = this.baseMapper.getEventScreenEventTransDetail(transfer.getEventId()); |
| | | transfer.setSuperiorRelationship(transferRecordDetailVO.getStreetName() + "-" |
| | | + transferRecordDetailVO.getCommunityName() + "-" + transferRecordDetailVO.getGridName()); |
| | | }else if(transfer.getFromType().equals(EventTransferRecordVO.fromType.sq)){ |
| | | //查询上级社区信息 |
| | | EventTransferRecordDetailVO transferRecordDetailVO = this.baseMapper.getEventScreenEventTransDetailByCommunityId(transfer.getFromId()); |
| | | transfer.setSuperiorRelationship(transferRecordDetailVO.getStreetName() + "-" |
| | | + transferRecordDetailVO.getCommunityName()); |
| | | } |
| | | }); |
| | | } |
| | | statisticsVO.setTransferRecordList(transferRecordList); |
| | | } |
| | | } |
| | | return R.ok(statisticsVO); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // List<ComMngPopulationHouseUserDO> distinctClass = populationHouseUserDOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getPopulId() + ";" + o.getHouseId() + ";" + o.getId() + ";" + o.getRelation()))), ArrayList::new)); |
| | | @Override |
| | | public R pagePopulationListApp(PagePopulationListDTO populationListDTO){ |
| | | IPage<PopulationListVO> pagePopulationList = this.baseMapper.pagePopulationListApp(new Page(populationListDTO.getPageNum(),populationListDTO.getPageSize()),populationListDTO); |
| | | if(!pagePopulationList.getRecords().isEmpty()){ |
| | | pagePopulationList.getRecords().forEach(population -> { |
| | | population.setAge(IdcardUtil.getAgeByIdCard(population.getCardNo())); |
| | | }); |
| | | } |
| | | return R.ok(pagePopulationList); |
| | | } |
| | | |
| | | @Override |
| | | public R getPopulationDetailApp(Long populationId){ |
| | | PopulationDetailVO detail = this.baseMapper.getPopulationDetailApp(populationId); |
| | | if(detail != null){ |
| | | detail.setAge(IdcardUtil.getAgeByIdCard(detail.getCardNo())); |
| | | if(StringUtils.isNotEmpty(detail.getCultureLevel())){ |
| | | detail.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(Integer.parseInt(detail.getCultureLevel()))); |
| | | } |
| | | if(StringUtils.isNotEmpty(detail.getMarriage())){ |
| | | detail.setMarriage(PopulMarriageEnum.getCnDescByName(Integer.parseInt(detail.getMarriage()))); |
| | | } |
| | | } |
| | | return R.ok(detail); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R getPopulationRepairByApp(){ |
| | | List<ComMngPopulationDO> populationDOList = this.baseMapper.selectList(new QueryWrapper<ComMngPopulationDO>()); |
| | | if(!populationDOList.isEmpty()){ |
| | | populationDOList.forEach(population -> { |
| | | this.baseMapper.updateById(population); |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |