| | |
| | | package com.panzhihua.service_community.api; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.*; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.dtos.community.*; |
| | | import com.panzhihua.common.model.dtos.community.ComActEasyPhotoCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActEasyPhotoCommentUserDTO; |
| | | import com.panzhihua.common.model.dtos.community.EldersAuthAddByFamilyDTO; |
| | | import com.panzhihua.common.model.dtos.community.EldersAuthAddDTO; |
| | | import com.panzhihua.common.model.dtos.community.EldersAuthDeleteDTO; |
| | | import com.panzhihua.common.model.dtos.community.EldersAuthEditDTO; |
| | | import com.panzhihua.common.model.dtos.community.EldersAuthFeedbackAddDTO; |
| | | import com.panzhihua.common.model.dtos.community.GrantRewardDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComActDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComActEasyPhotoCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageEldersAuthDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageQuestnaireAnswerDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageQuestnaireDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageQuestnaireSubDetailsDTO; |
| | | import com.panzhihua.common.model.dtos.community.easyPhoto.ExportEasyPhotoDTO; |
| | | import com.panzhihua.common.model.dtos.community.questnaire.StatisticsSummaryDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.SystemmanagementConfigVO; |
| | | import com.panzhihua.common.model.vos.community.*; |
| | | import com.panzhihua.common.model.vos.community.ComActActRegistVO; |
| | | import com.panzhihua.common.model.vos.community.ActivitySignVO; |
| | | import com.panzhihua.common.model.vos.community.BatchhouseVO; |
| | | import com.panzhihua.common.model.vos.community.ComActActEvaluateVO; |
| | | import com.panzhihua.common.model.vos.community.ComActActPrizeVO; |
| | | import com.panzhihua.common.model.vos.community.ComActActivityVO; |
| | | import com.panzhihua.common.model.vos.community.ComActDynVO; |
| | | import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO; |
| | | import com.panzhihua.common.model.vos.community.ComActMessageBackVO; |
| | | import com.panzhihua.common.model.vos.community.ComActMessageVO; |
| | | import com.panzhihua.common.model.vos.community.ComActMicroWishVO; |
| | | import com.panzhihua.common.model.vos.community.ComActVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngStructAreaVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngStructHouseVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngStructOtherBuildVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngVolunteerMngAppletsVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO; |
| | | import com.panzhihua.common.model.vos.community.EldersAuthDetailsVO; |
| | | import com.panzhihua.common.model.vos.community.EldersAuthVO; |
| | | import com.panzhihua.common.model.vos.community.ResetComActMessageVO; |
| | | import com.panzhihua.common.model.vos.community.SignactivityVO; |
| | | import com.panzhihua.common.model.vos.community.TodoEventsVO; |
| | | import com.panzhihua.common.model.vos.community.questnaire.EditComActQuestnaireVo; |
| | | import com.panzhihua.common.model.vos.community.questnaire.QuestnaireVO; |
| | | import com.panzhihua.common.model.vos.community.questnaire.UsersAnswerQuestnaireVO; |
| | |
| | | import com.panzhihua.common.model.vos.user.SysUserNoticeVO; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.*; |
| | | import com.panzhihua.common.utlis.AgeUtils; |
| | | import com.panzhihua.common.utlis.ClazzUtils; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.IdCard; |
| | | import com.panzhihua.common.utlis.WxUtil; |
| | | import com.panzhihua.common.utlis.WxXCXTempSend; |
| | | import com.panzhihua.service_community.dao.ComActActSignDAO; |
| | | import com.panzhihua.service_community.dao.ComEldersAuthHistoryRecordMapper; |
| | | import com.panzhihua.service_community.dao.ComMngPopulationDAO; |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.*; |
| | | |
| | | import cn.hutool.core.util.IdcardUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private ComActEasyPhotoActivityService comActEasyPhotoActivityService; |
| | | @Resource |
| | | private ComActActEvaluateService comActActEvaluateService; |
| | | @Resource |
| | | private ComEldersAuthElderlyService comEldersAuthElderlyService; |
| | | |
| | | /** |
| | | * 新增社区活动 |
| | |
| | | comActActivityVO.setComActActEvaluateVOList(comActActEvaluateVOList); |
| | | //活动评价总数 |
| | | comActActivityVO.setEvaluateAmount(comActActEvaluateDOList.size()); |
| | | //当前用户对活动的评分 |
| | | Optional.ofNullable(userId).ifPresent(currentUserId -> { |
| | | Optional<ComActActEvaluateDO> optional = comActActEvaluateDOList.stream() |
| | | .filter(comActActEvaluateDO -> comActActEvaluateDO.getUserId().equals(currentUserId)).findFirst(); |
| | | if (optional.isPresent()) { |
| | | comActActivityVO.setMyRating(optional.get().getStarLevel()); |
| | | } |
| | | }); |
| | | } |
| | | //签到时间 |
| | | Optional.ofNullable(userId).ifPresent(currentUserId -> { |
| | | R listSignInResult = comActActivityService.listSignInActivity(currentUserId); |
| | | if (R.isOk(listSignInResult) && !ObjectUtils.isEmpty(listSignInResult.getData())) { |
| | | Optional<ComActActRegistVO> optional = JSONArray.parseArray(JSONArray.toJSONString(listSignInResult.getData()), ComActActRegistVO.class).stream() |
| | | .filter(activitySignInVO -> activitySignInVO.getActivityId().equals(id)) |
| | | .sorted(Comparator.comparing(ComActActRegistVO::getCreateAt).reversed()).findFirst(); |
| | | if (optional.isPresent()) { |
| | | comActActivityVO.setActivitySignInDate(optional.get().getCreateAt()); |
| | | } |
| | | } |
| | | }); |
| | | //活动报名名单 |
| | | ActivitySignVO activitySignVO = new ActivitySignVO(); |
| | | activitySignVO.setActivityId(id); |
| | |
| | | } |
| | | comActActivityVO.setIntegral(0); |
| | | return R.ok(comActActivityVO); |
| | | } |
| | | |
| | | /** |
| | | * 活动签到 |
| | | * |
| | | * @param comActActRegistVO 请求参数 |
| | | * @return 签到结果 |
| | | */ |
| | | @PostMapping("activity/sign-in") |
| | | public R activitySignIn(@RequestBody ComActActRegistVO comActActRegistVO) { |
| | | return comActActivityService.activitySignIn(comActActRegistVO); |
| | | } |
| | | |
| | | /** |
| | | * 用户签到列表 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 用户签到记录列表 |
| | | */ |
| | | @GetMapping("/sign-in/user/list") |
| | | public R listSignInActivity(@RequestParam("userId") Long userId) { |
| | | return comActActivityService.listSignInActivity(userId); |
| | | } |
| | | |
| | | /** |
| | | * 社区活动评价 |
| | | * |
| | | * @param comActActEvaluateVO 社区评价VO |
| | | * @return 评价结果 |
| | | */ |
| | | @PostMapping("activity/evaluate") |
| | | public R activityEvaluate(@RequestBody ComActActEvaluateVO comActActEvaluateVO) { |
| | | return comActActEvaluateService.activityEvaluate(comActActEvaluateVO); |
| | | } |
| | | |
| | | /** |
| | | * 用户评价列表 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 当前用户对所有活动的评价列表 |
| | | */ |
| | | @GetMapping("/evaluate/user/list") |
| | | public R listEvaluate(@RequestParam("userId") Long userId) { |
| | | return comActActEvaluateService.listEvaluate(userId); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * description getRegistLists 查询活动未签到 |
| | | * @param comActActRegistVO 查询参数 |
| | | * @return R 查询结果 |
| | | * @author txb |
| | | * @date 2021/8/25 9:33 |
| | | */ |
| | | @PostMapping("activity/noRegist/getList") |
| | | public R getNoRegistLists(@RequestBody ComActActRegistVO comActActRegistVO){ |
| | | return comActActivityService.getNoRegistLists(comActActRegistVO); |
| | | } |
| | | |
| | | /** |
| | | * description activityStagistics 活动数据统计 |
| | | * @param activityId 活动id |
| | | * @return R 统计结果 |
| | |
| | | @GetMapping("activity/statistics") |
| | | public R activityStatistics(@RequestParam("activityId") Long activityId){ |
| | | return comActActivityService.activityStatistics(activityId); |
| | | } |
| | | |
| | | /** |
| | | * 获取活动历史封面 getPictureList |
| | | * @param userId 用户id |
| | | * @return R 统计结果 |
| | | * @author txb |
| | | * @date 2021/8/27 13:33 |
| | | */ |
| | | @GetMapping("/activity/picture/getList") |
| | | public R getPictureList(@RequestParam("userId") Long userId){ |
| | | return comActActivityService.getPictureList(userId); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (authUserDO == null) { |
| | | return R.fail("未查询到老人信息"); |
| | | } |
| | | |
| | | Long elderId = authUserDO.getId(); |
| | | boolean canReAuthThisMonth = comEldersAuthUserService.checkReAuthAgain(elderId); |
| | | if (!canReAuthThisMonth) { |
| | | return R.fail("当月已认证,不能再次进行认证"); |
| | | } |
| | | |
| | | //根据身份证获取出生日期并获取岁数 |
| | | String idCard = authUserDO.getIdCard(); |
| | | |
| | | Long loginUserId = eldersAuthAddByFamilyDTO.getUserId(); |
| | | EldersAuthDO eldersAuthDO = new EldersAuthDO(); |
| | | eldersAuthDO.setSumitUserId(loginUserId); |
| | | eldersAuthDO.setCreateBy(loginUserId); |
| | | eldersAuthDO.setCreateAt(new Date()); |
| | | eldersAuthDO.setIdCard(idCard); |
| | | eldersAuthDO.setAuthUserName(authUserDO.getName()); |
| | | eldersAuthDO.setVideoUrl(eldersAuthAddByFamilyDTO.getVideoUrl()); |
| | | eldersAuthDO.setFamilyUserId(authUserDO.getId()); |
| | | eldersAuthDO.setAge(IdcardUtil.getAgeByIdCard(idCard)); |
| | | // 根据身份证查询出籍贯 出生日期 |
| | | // String domicile = IdCard.domicile(eldersAuthDO.getIdCard()); |
| | | String domicile = eldersAuthService.queryDomicile(eldersAuthDO.getIdCard()); |
| | | if (StringUtils.isEmpty(domicile)) { |
| | | domicile = "暂无"; |
| | | } |
| | | |
| | | Date birthDay = IdCard.birthDay(idCard); |
| | | eldersAuthDO.setDomicile(domicile); |
| | | eldersAuthDO.setBirthDay(birthDay); |
| | | int add = eldersAuthService.getBaseMapper().insert(eldersAuthDO); |
| | | if (add == 1) { |
| | | // 设置认证成功 |
| | | Long familyUserId = eldersAuthDO.getFamilyUserId(); |
| | | ComEldersAuthUserDO comEldersAuthUserDO = new ComEldersAuthUserDO(); |
| | | comEldersAuthUserDO.setId(familyUserId); |
| | | comEldersAuthUserDO.setIsAuth(1); |
| | | boolean updated = comEldersAuthUserService.updateById(comEldersAuthUserDO); |
| | | if (!updated) { |
| | | throw new ServiceException("添加认证失败,更新认证状态"); |
| | | } |
| | | // 认证成功 添加认证记录 |
| | | List<ComEldersAuthHistoryRecordDO> authHistoryRecordDOList = |
| | | comEldersAuthHistoryRecordMapper.selectList(new QueryWrapper<ComEldersAuthHistoryRecordDO>().lambda() |
| | | .eq(ComEldersAuthHistoryRecordDO::getIdCard, idCard) |
| | | .ge(ComEldersAuthHistoryRecordDO::getCreateAt, DateUtils.getFirstDayOfMonth())); |
| | | if (authHistoryRecordDOList.isEmpty()) { |
| | | ComEldersAuthHistoryRecordDO authHistoryRecordDO = new ComEldersAuthHistoryRecordDO(); |
| | | authHistoryRecordDO.setUserId(eldersAuthAddByFamilyDTO.getFamilyUserId()); |
| | | authHistoryRecordDO.setAuthId(eldersAuthDO.getId()); |
| | | BeanUtils.copyProperties(eldersAuthDO, authHistoryRecordDO); |
| | | authHistoryRecordDO.setId(null); |
| | | authHistoryRecordDO.setBrithday(AgeUtils.getAgeFormatBirthday(IdcardUtil.getBirthByIdCard(idCard))); |
| | | authHistoryRecordDO.setAge(IdcardUtil.getAgeByIdCard(idCard)); |
| | | authHistoryRecordDO.setIsAuth(1); |
| | | authHistoryRecordDO.setDomicile(domicile); |
| | | comEldersAuthHistoryRecordMapper.insert(authHistoryRecordDO); |
| | | } |
| | | return R.ok(eldersAuthDO.getId()); |
| | | } |
| | | long year=DateUtil.betweenYear(birthDay,DateUtil.date(),true); |
| | | if(authUserDO.getBigAgeId()!=null){ |
| | | ComEldersAuthElderlyDO comEldersAuthElderlyDO=comEldersAuthElderlyService.getById(authUserDO.getBigAgeId()); |
| | | if(comEldersAuthElderlyDO!=null&&comEldersAuthElderlyDO.getIsExist()==ComEldersAuthElderlyDO.isExist.yes&&comEldersAuthElderlyDO.getIsBigAge()==ComEldersAuthElderlyDO.isBigAge.yes&&year>=80){ |
| | | Long elderId = authUserDO.getId(); |
| | | boolean canReAuthThisMonth = comEldersAuthUserService.checkReAuthAgain(elderId); |
| | | if (!canReAuthThisMonth) { |
| | | return R.fail("当月已认证,不能再次进行认证"); |
| | | } |
| | | Long loginUserId = eldersAuthAddByFamilyDTO.getUserId(); |
| | | EldersAuthDO eldersAuthDO = new EldersAuthDO(); |
| | | eldersAuthDO.setSumitUserId(loginUserId); |
| | | eldersAuthDO.setCreateBy(loginUserId); |
| | | eldersAuthDO.setCreateAt(new Date()); |
| | | eldersAuthDO.setIdCard(idCard); |
| | | eldersAuthDO.setAuthUserName(authUserDO.getName()); |
| | | eldersAuthDO.setVideoUrl(eldersAuthAddByFamilyDTO.getVideoUrl()); |
| | | eldersAuthDO.setFamilyUserId(authUserDO.getId()); |
| | | eldersAuthDO.setAge(IdcardUtil.getAgeByIdCard(idCard)); |
| | | // 根据身份证查询出籍贯 出生日期 |
| | | // String domicile = IdCard.domicile(eldersAuthDO.getIdCard()); |
| | | String domicile = eldersAuthService.queryDomicile(eldersAuthDO.getIdCard()); |
| | | if (StringUtils.isEmpty(domicile)) { |
| | | domicile = "暂无"; |
| | | } |
| | | eldersAuthDO.setDomicile(domicile); |
| | | eldersAuthDO.setBirthDay(birthDay); |
| | | int add = eldersAuthService.getBaseMapper().insert(eldersAuthDO); |
| | | if (add == 1) { |
| | | // 设置认证成功 |
| | | Long familyUserId = eldersAuthDO.getFamilyUserId(); |
| | | ComEldersAuthUserDO comEldersAuthUserDO = new ComEldersAuthUserDO(); |
| | | comEldersAuthUserDO.setId(familyUserId); |
| | | comEldersAuthUserDO.setIsAuth(1); |
| | | boolean updated = comEldersAuthUserService.updateById(comEldersAuthUserDO); |
| | | if (!updated) { |
| | | throw new ServiceException("添加认证失败,更新认证状态"); |
| | | } |
| | | // 认证成功 添加认证记录 |
| | | List<ComEldersAuthHistoryRecordDO> authHistoryRecordDOList = |
| | | comEldersAuthHistoryRecordMapper.selectList(new QueryWrapper<ComEldersAuthHistoryRecordDO>().lambda() |
| | | .eq(ComEldersAuthHistoryRecordDO::getIdCard, idCard) |
| | | .ge(ComEldersAuthHistoryRecordDO::getCreateAt, DateUtils.getFirstDayOfMonth())); |
| | | if (authHistoryRecordDOList.isEmpty()) { |
| | | ComEldersAuthHistoryRecordDO authHistoryRecordDO = new ComEldersAuthHistoryRecordDO(); |
| | | authHistoryRecordDO.setUserId(eldersAuthAddByFamilyDTO.getFamilyUserId()); |
| | | authHistoryRecordDO.setAuthId(eldersAuthDO.getId()); |
| | | BeanUtils.copyProperties(eldersAuthDO, authHistoryRecordDO); |
| | | authHistoryRecordDO.setId(null); |
| | | authHistoryRecordDO.setBrithday(AgeUtils.getAgeFormatBirthday(IdcardUtil.getBirthByIdCard(idCard))); |
| | | authHistoryRecordDO.setAge(IdcardUtil.getAgeByIdCard(idCard)); |
| | | authHistoryRecordDO.setIsAuth(1); |
| | | authHistoryRecordDO.setDomicile(domicile); |
| | | comEldersAuthHistoryRecordMapper.insert(authHistoryRecordDO); |
| | | } |
| | | return R.ok(eldersAuthDO.getId()); |
| | | } |
| | | |
| | | return R.fail(); |
| | | } |
| | | return R.fail("不满足认证条件"); |
| | | } |
| | | return R.fail("未查询到高龄老人库数据"); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取首页弹窗接口 |
| | | * |
| | | * @param userId |
| | | * 用户id |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 首页弹窗接口 |
| | | */ |
| | | @PostMapping("easyphoto/getUserRewards") |
| | | public R getUserRewards(@RequestParam("userId") Long userId, @RequestParam("communityId") Long communityId) { |
| | | return comActEasyPhotoService.getUserReward(userId, communityId); |
| | | } |
| | | |
| | | /** |
| | | * 读取用户随手拍奖励 |
| | | * |
| | | * @param userId |
| | |
| | | } |
| | | |
| | | /** |
| | | * 定时任务针对活动结束后7天还未评价的用户默认好评 |
| | | */ |
| | | @PostMapping("activity/default-praise") |
| | | public R timedTaskActivityDefaultPraise() { |
| | | return comActActEvaluateService.timedTaskActivityDefaultPraise(); |
| | | } |
| | | |
| | | /** |
| | | * 小程序-新增问卷调查浏览数量 |
| | | * |
| | | * @param questId |