| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.dtos.community.ExportSpecialUserDTO; |
| | | import com.panzhihua.common.model.dtos.community.ExportUserDTO; |
| | | import com.panzhihua.common.model.dtos.user.ComMngUserTagDTO; |
| | | import com.panzhihua.common.model.dtos.user.EexcelUserDTO; |
| | | import com.panzhihua.common.model.dtos.user.InputUserTagsDTO; |
| | | import com.panzhihua.common.model.dtos.user.PageInputUserDTO; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngStructAreaVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngStructHouseVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO; |
| | | import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO; |
| | | import com.panzhihua.common.model.vos.user.ComMngTagVO; |
| | | import com.panzhihua.common.model.vos.user.CommunityUserInfoVO; |
| | | import com.panzhihua.common.model.vos.user.InputUserInfoVO; |
| | | import com.panzhihua.common.utlis.IdCard; |
| | | import com.panzhihua.common.utlis.SensitiveUtil; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_user.dao.ComMngUserTagDAO; |
| | | import com.panzhihua.service_user.dao.SysUserInputDAO; |
| | | import com.panzhihua.service_user.model.dos.ComMngFamilyInfoDO; |
| | | import com.panzhihua.service_user.model.dos.ComMngUserTagDO; |
| | | import com.panzhihua.service_user.model.dos.SysUserDO; |
| | | import com.panzhihua.service_user.model.dos.SysUserInputDO; |
| | | import com.panzhihua.service_user.service.SysUserInputService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private SysUserInputDAO sysUserInputDAO; |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | @Resource |
| | | private ComMngUserTagDAO comMngUserTagDAO; |
| | | /** |
| | | * 批量导入居民用户 |
| | | * @param list 居民用户集合 |
| | |
| | | } |
| | | List<ComMngStructHouseVO> comMngStructHouseVOS1=comMngStructHouseVOS; |
| | | list.forEach(eexcelUserDTO -> { |
| | | SysUserInputDO sysUserInputDO=new SysUserInputDO(); |
| | | String doorNumber = eexcelUserDTO.getDoorNumber(); |
| | | List<ComMngStructHouseVO> collect = comMngStructHouseVOS1.stream().filter(comMngStructHouseVO -> comMngStructHouseVO.getHouseName().equals(doorNumber)).collect(Collectors.toList()); |
| | | if (ObjectUtils.isEmpty(collect)) { |
| | | throw new ServiceException("门牌号后台不存在或格式错误,错误门牌号为"+doorNumber); |
| | | }else{ |
| | | sysUserInputDO.setHouseCode(collect.get(0).getHouseCode()); |
| | | } |
| | | sysUserInputDO.setAreaId(comMngStructAreaVO.getId()); |
| | | sysUserInputDO.setCommunityId(comMngStructAreaVO.getCommunityId()); |
| | | sysUserInputDO.setCompany(eexcelUserDTO.getCompany()); |
| | | sysUserInputDO.setDoorNumber(doorNumber); |
| | | sysUserInputDO.setEducation(eexcelUserDTO.getEducation()); |
| | | sysUserInputDO.setIdCard(eexcelUserDTO.getIdCard()); |
| | | sysUserInputDO.setIsContact(eexcelUserDTO.getIsContact().equals("是")?1:0); |
| | | sysUserInputDO.setIsPanzhihua(eexcelUserDTO.getIsPanZhiHua().equals("是")?1:0); |
| | | sysUserInputDO.setIsRent(eexcelUserDTO.getIsRent().equals("是")?1:0); |
| | | sysUserInputDO.setKeyPersonnel(eexcelUserDTO.getKeyPersonnel().equals("是")?1:0); |
| | | sysUserInputDO.setLowincomeHouseholds(eexcelUserDTO.getLowIncomeHouseholds().equals("是")?1:0); |
| | | sysUserInputDO.setLowincomePeople(eexcelUserDTO.getLowIncomePeople().equals("是")?1:0); |
| | | sysUserInputDO.setMajor(eexcelUserDTO.getMajor().equals("是")?1:0); |
| | | sysUserInputDO.setMaritalStatus(eexcelUserDTO.getMaritalStatus().equals("是")?1:0); |
| | | sysUserInputDO.setName(eexcelUserDTO.getName()); |
| | | sysUserInputDO.setNation(eexcelUserDTO.getNation()); |
| | | sysUserInputDO.setOldPeople(eexcelUserDTO.getOldPeople().equals("是")?1:0); |
| | | sysUserInputDO.setDisability(eexcelUserDTO.getDisability().equals("是")?1:0); |
| | | sysUserInputDO.setPhone(eexcelUserDTO.getPhone()); |
| | | String politicalOutlook = eexcelUserDTO.getPoliticalOutlook(); |
| | | sysUserInputDO.setPoliticalOutlook(politicalOutlook.equals("党员")?1:politicalOutlook.equals("团员")?2:3); |
| | | sysUserInputDO.setResidence(eexcelUserDTO.getResidence()); |
| | | sysUserInputDO.setSituation(eexcelUserDTO.getSituation()); |
| | | sysUserInputDO.setSoldier(eexcelUserDTO.getSoldier().equals("是")?1:0); |
| | | sysUserInputDO.setSpecialServiceFamily(eexcelUserDTO.getSpecialServiceFamily().equals("是")?1:0); |
| | | //判断身份证和门牌号是否重复 |
| | | int count = sysUserInputDAO.selectCount(new QueryWrapper<SysUserInputDO>().lambda() |
| | | .eq(SysUserInputDO::getIdCard,eexcelUserDTO.getIdCard()) |
| | | .and(wrapper->wrapper.eq(SysUserInputDO::getDoorNumber,eexcelUserDTO.getDoorNumber())) |
| | | ); |
| | | if(count==0){ |
| | | SysUserInputDO sysUserInputDO=new SysUserInputDO(); |
| | | String doorNumber = eexcelUserDTO.getDoorNumber(); |
| | | //暂时注释门牌号匹配设置房屋编号功能 |
| | | // List<ComMngStructHouseVO> collect = comMngStructHouseVOS1.stream().filter(comMngStructHouseVO -> comMngStructHouseVO.getHouseName().equals(doorNumber)).collect(Collectors.toList()); |
| | | // if (ObjectUtils.isEmpty(collect)) { |
| | | // throw new ServiceException("门牌号后台不存在或格式错误,错误门牌号为"+doorNumber); |
| | | // }else{ |
| | | // sysUserInputDO.setHouseCode(collect.get(0).getHouseCode()); |
| | | // } |
| | | sysUserInputDO.setAreaId(comMngStructAreaVO.getId()); |
| | | sysUserInputDO.setCommunityId(comMngStructAreaVO.getCommunityId()); |
| | | sysUserInputDO.setCompany(eexcelUserDTO.getCompany()); |
| | | sysUserInputDO.setDoorNumber(doorNumber); |
| | | sysUserInputDO.setEducation(eexcelUserDTO.getEducation()); |
| | | sysUserInputDO.setIdCard(eexcelUserDTO.getIdCard()); |
| | | sysUserInputDO.setIsContact(eexcelUserDTO.getIsContact().equals("是")?1:0); |
| | | sysUserInputDO.setIsPanzhihua(eexcelUserDTO.getIsPanZhiHua().equals("是")?1:0); |
| | | sysUserInputDO.setIsRent(eexcelUserDTO.getIsRent().equals("是")?1:0); |
| | | sysUserInputDO.setKeyPersonnel(eexcelUserDTO.getKeyPersonnel().equals("是")?1:0); |
| | | sysUserInputDO.setLowincomeHouseholds(eexcelUserDTO.getLowIncomeHouseholds().equals("是")?1:0); |
| | | sysUserInputDO.setLowincomePeople(eexcelUserDTO.getLowIncomePeople().equals("是")?1:0); |
| | | sysUserInputDO.setMajor(eexcelUserDTO.getMajor().equals("是")?1:0); |
| | | sysUserInputDO.setMaritalStatus(eexcelUserDTO.getMaritalStatus().equals("是")?1:0); |
| | | sysUserInputDO.setName(eexcelUserDTO.getName()); |
| | | sysUserInputDO.setNation(eexcelUserDTO.getNation()); |
| | | sysUserInputDO.setOldPeople(eexcelUserDTO.getOldPeople().equals("是")?1:0); |
| | | sysUserInputDO.setDisability(eexcelUserDTO.getDisability().equals("是")?1:0); |
| | | sysUserInputDO.setPhone(eexcelUserDTO.getPhone()); |
| | | String politicalOutlook = eexcelUserDTO.getPoliticalOutlook(); |
| | | if(!ObjectUtils.isEmpty(politicalOutlook)){ |
| | | sysUserInputDO.setPoliticalOutlook(politicalOutlook.equals("党员")?1:politicalOutlook.equals("团员")?2:3); |
| | | }else{ |
| | | sysUserInputDO.setPoliticalOutlook(3); |
| | | } |
| | | sysUserInputDO.setResidence(eexcelUserDTO.getResidence()); |
| | | sysUserInputDO.setSituation(eexcelUserDTO.getSituation()); |
| | | sysUserInputDO.setSoldier(eexcelUserDTO.getSoldier().equals("是")?1:0); |
| | | sysUserInputDO.setSpecialServiceFamily(eexcelUserDTO.getSpecialServiceFamily().equals("是")?1:0); |
| | | |
| | | sysUserInputDOS.add(sysUserInputDO); |
| | | sysUserInputDOS.add(sysUserInputDO); |
| | | } |
| | | }); |
| | | this.saveBatch(sysUserInputDOS); |
| | | } |
| | |
| | | } |
| | | return communityUserInfoVO; |
| | | } |
| | | |
| | | @Override |
| | | public R pageInputUser(PageInputUserDTO pageInputUserDTO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = pageInputUserDTO.getPageNum(); |
| | | Long pageSize = pageInputUserDTO.getPageSize(); |
| | | if (null==pageNum||0==pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null==pageSize||0==pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<InputUserInfoVO> iPage = sysUserInputDAO.pageInputUser(page, pageInputUserDTO); |
| | | iPage.getRecords().forEach(record->{ |
| | | record.setPhone(SensitiveUtil.desensitizedPhoneNumber(record.getPhone())); |
| | | record.setIdCard(SensitiveUtil.desensitizedIdNumber(record.getIdCard())); |
| | | if(!StringUtils.isEmpty(record.getTags()) && record.getTags().endsWith(",")){ |
| | | record.setTags(record.getTags().substring(0,record.getTags().length()-1)); |
| | | } |
| | | }); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R putUserTag(InputUserTagsDTO inputUserTagsDTO) { |
| | | SysUserInputDO userInputDO=new SysUserInputDO(); |
| | | userInputDO.setId(inputUserTagsDTO.getId()); |
| | | userInputDO.setTags(inputUserTagsDTO.getTags()); |
| | | List<SysUserInputDO> all = sysUserInputDAO.selectList(new QueryWrapper<SysUserInputDO>().lambda().eq(SysUserInputDO::getId,userInputDO.getId())); |
| | | all.forEach(d->{ |
| | | if(!StringUtils.isEmpty(d.getTags())){ |
| | | d.setTags(d.getTags()+","+inputUserTagsDTO.getTags()); |
| | | }else{ |
| | | d.setTags(inputUserTagsDTO.getTags()); |
| | | } |
| | | sysUserInputDAO.updateById(userInputDO); |
| | | |
| | | }); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R exportInputUser(ExportUserDTO exportUserDTO) { |
| | | List<EexcelUserDTO> eexcelUserDTOS=sysUserInputDAO.selectExport(exportUserDTO); |
| | | return R.ok(eexcelUserDTOS); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R inputUserDetail(Long id) { |
| | | InputUserInfoVO inputUserInfoVO = new InputUserInfoVO(); |
| | | SysUserInputDO sysUserInputDO = sysUserInputDAO.selectById(id); |
| | | if (!org.springframework.util.ObjectUtils.isEmpty(sysUserInputDO)) { |
| | | BeanUtils.copyProperties(sysUserInputDO,inputUserInfoVO); |
| | | String idCard = sysUserInputDO.getIdCard(); |
| | | if (!org.springframework.util.ObjectUtils.isEmpty(idCard)) { |
| | | inputUserInfoVO.setAge(IdCard.IdNOToAge(idCard)); |
| | | inputUserInfoVO.setBirthday(IdCard.birthDay(idCard)); |
| | | inputUserInfoVO.setIdCard(idCard); |
| | | inputUserInfoVO.setSex(IdCard.sex(idCard)); |
| | | } |
| | | Integer keyPersonnel = sysUserInputDO.getKeyPersonnel(); |
| | | Integer specialServiceFamily = sysUserInputDO.getSpecialServiceFamily(); |
| | | Integer soldier = sysUserInputDO.getSoldier(); |
| | | Integer lowincomeHouseholds = sysUserInputDO.getLowincomeHouseholds(); |
| | | Integer lowincomePeople = sysUserInputDO.getLowincomePeople(); |
| | | Integer oldPeople = sysUserInputDO.getOldPeople(); |
| | | Integer disability = sysUserInputDO.getDisability(); |
| | | |
| | | StringBuilder stringBuilder=new StringBuilder(""); |
| | | if (keyPersonnel.intValue()==1) { |
| | | stringBuilder.append("重点人员,"); |
| | | } |
| | | if (specialServiceFamily.intValue()==1) { |
| | | stringBuilder.append("特服家庭,"); |
| | | } |
| | | if (soldier.intValue()==1) { |
| | | stringBuilder.append("军人,"); |
| | | } |
| | | if (lowincomeHouseholds.intValue()==1) { |
| | | stringBuilder.append("低保户,"); |
| | | } |
| | | if (lowincomePeople.intValue()==1) { |
| | | stringBuilder.append("低收入人员,"); |
| | | } |
| | | if (oldPeople.intValue()==1) { |
| | | stringBuilder.append("高龄老人,"); |
| | | } |
| | | if (disability.intValue()==1) { |
| | | stringBuilder.append("残疾人,"); |
| | | } |
| | | inputUserInfoVO.setTags(stringBuilder.toString()); |
| | | String doorNumber = sysUserInputDO.getDoorNumber(); |
| | | List<ComMngFamilyInfoVO> comMngFamilyInfoVOS = sysUserInputDAO.selectListFamily(doorNumber,id); |
| | | inputUserInfoVO.setComMngFamilyInfoVOS(comMngFamilyInfoVOS); |
| | | List<ComMngStructHouseVO> comMngStructHouseVOS = sysUserInputDAO.selectUserHouseList(inputUserInfoVO.getIdCard()); |
| | | inputUserInfoVO.setComMngStructHouseVOS(comMngStructHouseVOS); |
| | | } |
| | | return R.ok(inputUserInfoVO); |
| | | } |
| | | |
| | | @Override |
| | | public R specialInputUser(PageInputUserDTO pageInputUserDTO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = pageInputUserDTO.getPageNum(); |
| | | Long pageSize = pageInputUserDTO.getPageSize(); |
| | | if (null==pageNum||0==pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null==pageSize||0==pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<InputUserInfoVO> iPage = sysUserInputDAO.specialInputUser(page, pageInputUserDTO); |
| | | iPage.getRecords().forEach(record->{ |
| | | record.setPhone(SensitiveUtil.desensitizedPhoneNumber(record.getPhone())); |
| | | record.setIdCard(SensitiveUtil.desensitizedIdNumber(record.getIdCard())); |
| | | }); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R specialInputUserTags(ComMngUserTagDTO comMngUserTagDTO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = comMngUserTagDTO.getPageNum(); |
| | | Long pageSize = comMngUserTagDTO.getPageSize(); |
| | | if (null==pageNum||0==pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null==pageSize||0==pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComMngTagVO> iPage = comMngUserTagDAO.pageSpecialInputUserTags(page, comMngUserTagDTO); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R saveSpecialInputUserTags(ComMngTagVO comMngTagVO) { |
| | | if(null!=comMngTagVO.getId()&&comMngTagVO.getId()!=0){ |
| | | ComMngUserTagDO comMngUserTagDO = comMngUserTagDAO.selectById(comMngTagVO.getId()); |
| | | if(null==comMngUserTagDO){ |
| | | return R.fail("标签不存在"); |
| | | } |
| | | if(comMngUserTagDO.getSysFlag()==1){ |
| | | return R.fail("系统预置标签不可修改"); |
| | | } |
| | | ComMngUserTagDO exist = comMngUserTagDAO.selectOne(new QueryWrapper<ComMngUserTagDO>().lambda().eq(ComMngUserTagDO::getTagName,comMngTagVO.getTagName())); |
| | | if(null!=exist && exist.getId()!=comMngUserTagDO.getId()){ |
| | | return R.fail("标签重复"); |
| | | } |
| | | comMngUserTagDO.setTagName(comMngTagVO.getTagName()); |
| | | comMngUserTagDAO.updateById(comMngUserTagDO); |
| | | }else{ |
| | | int count = comMngUserTagDAO.selectCount(new QueryWrapper<ComMngUserTagDO>().lambda().eq(ComMngUserTagDO::getTagName,comMngTagVO.getTagName())); |
| | | if(count>0){ |
| | | return R.fail("标签重复"); |
| | | } |
| | | ComMngUserTagDO comMngUserTagDO = new ComMngUserTagDO(); |
| | | comMngUserTagDO.setTagName(comMngTagVO.getTagName()); |
| | | comMngUserTagDO.setCommunityId(comMngTagVO.getCommunityId()); |
| | | comMngUserTagDO.setSysFlag(0); |
| | | comMngUserTagDO.setCreateAt(new Date()); |
| | | comMngUserTagDAO.insert(comMngUserTagDO); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R deleteSpecialInputUserTags(Long id) { |
| | | ComMngUserTagDO comMngUserTagDO = comMngUserTagDAO.selectById(id); |
| | | if(null==comMngUserTagDO){ |
| | | return R.fail("标签不存在"); |
| | | } |
| | | if(comMngUserTagDO.getSysFlag()==1){ |
| | | return R.fail("系统预置标签不可删除"); |
| | | } |
| | | int delete = comMngUserTagDAO.deleteById(id); |
| | | if(delete>0){ |
| | | return R.ok(); |
| | | } |
| | | return R.fail("删除失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R deleteSpecialInputUser(Long id) { |
| | | SysUserInputDO sysUserInputDO = sysUserInputDAO.selectById(id); |
| | | if(null==sysUserInputDO){ |
| | | return R.fail("用户不存在"); |
| | | } |
| | | List<SysUserInputDO> sysUserInputDOS = sysUserInputDAO.selectList(new QueryWrapper<SysUserInputDO>().lambda().eq(SysUserInputDO::getIdCard,sysUserInputDO.getIdCard())); |
| | | sysUserInputDOS.forEach(sysUserInput ->{ |
| | | sysUserInput.setTags(null); |
| | | sysUserInput.setKeyPersonnel(0); |
| | | sysUserInput.setSpecialServiceFamily(0); |
| | | sysUserInput.setSoldier(0); |
| | | sysUserInput.setLowincomeHouseholds(0); |
| | | sysUserInput.setLowincomePeople(0); |
| | | sysUserInput.setOldPeople(0); |
| | | sysUserInput.setDisability(0); |
| | | }); |
| | | boolean update = this.updateBatchById(sysUserInputDOS); |
| | | if(update){ |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R specialUserExport(ExportSpecialUserDTO exportSpecialUserDTO) { |
| | | List<EexcelUserDTO> eexcelUserDTOS=sysUserInputDAO.specialUserExport(exportSpecialUserDTO); |
| | | return R.ok(eexcelUserDTOS); |
| | | } |
| | | } |