| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | 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.panzhihua.service_community.model.dos.ComMngVaccinesDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngVaccinesEnrollRecordDO; |
| | | import com.panzhihua.service_community.service.ComMngVaccinesEnrollRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComMngVaccinesEnrollRecordServiceImpl extends ServiceImpl<ComMngVaccinesEnrollRecordDAO, ComMngVaccinesEnrollRecordDO> implements ComMngVaccinesEnrollRecordService { |
| | | public class ComMngVaccinesEnrollRecordServiceImpl |
| | | extends ServiceImpl<ComMngVaccinesEnrollRecordDAO, ComMngVaccinesEnrollRecordDO> |
| | | implements ComMngVaccinesEnrollRecordService { |
| | | |
| | | @Resource |
| | | private ComMngVaccinesDAO comMngVaccinesDAO; |
| | | |
| | | /** |
| | | * 小程序-疫苗类型对应家庭成员接种列表 |
| | | * @return 疫苗类型对应家庭成员接种列表 |
| | | * |
| | | * @return 疫苗类型对应家庭成员接种列表 |
| | | */ |
| | | @Override |
| | | public R getVaccinesUserListByApp(VaccinesEnrollUserByAppDTO enrollUserByAppDTO){ |
| | | //查询当前用户的家庭成员列表 |
| | | public R getVaccinesUserListByApp(VaccinesEnrollUserByAppDTO enrollUserByAppDTO) { |
| | | // 查询当前用户的家庭成员列表 |
| | | List<VaccinesEnrollUserByAppVO> userLists = new ArrayList<>(); |
| | | //将自己的信息组装进家庭成员列表中 |
| | | // 将自己的信息组装进家庭成员列表中 |
| | | VaccinesEnrollUserByAppVO ownUser = this.baseMapper.getSysUser(enrollUserByAppDTO.getUserId()); |
| | | if(ownUser != null){ |
| | | if (ownUser != null) { |
| | | ownUser.setIsUser(1); |
| | | //计算年龄 |
| | | // 计算年龄 |
| | | ownUser.setAge(IdCard.IdNOToAge(ownUser.getIdCard())); |
| | | userLists.add(ownUser); |
| | | } |
| | | List<VaccinesEnrollUserByAppVO> userList = this.baseMapper.getFamilyUserList(enrollUserByAppDTO.getUserId()); |
| | | if(!userList.isEmpty()){ |
| | | if (!userList.isEmpty()) { |
| | | userLists.addAll(userList); |
| | | } |
| | | |
| | | if(!userLists.isEmpty()){ |
| | | if (!userLists.isEmpty()) { |
| | | userLists.forEach(user -> { |
| | | if(user.getIsUser() == null){ |
| | | if (user.getIsUser() == null) { |
| | | user.setIsUser(2); |
| | | } |
| | | if(StringUtils.isEmpty(user.getJob())){ |
| | | if (StringUtils.isEmpty(user.getJob())) { |
| | | user.setJob("暂无"); |
| | | } |
| | | //查询当前用户是否已经报名 |
| | | ComMngVaccinesEnrollRecordDO enrollRecordDO = this.baseMapper.selectOne(new QueryWrapper<ComMngVaccinesEnrollRecordDO>() |
| | | .lambda().eq(ComMngVaccinesEnrollRecordDO::getFamilyUserId,user.getUserId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getType,enrollUserByAppDTO.getVaccinesId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getFamilyUserType,user.getIsUser())); |
| | | if(enrollRecordDO != null){ |
| | | // 查询当前用户是否已经报名 |
| | | ComMngVaccinesEnrollRecordDO enrollRecordDO = |
| | | this.baseMapper.selectOne(new QueryWrapper<ComMngVaccinesEnrollRecordDO>().lambda() |
| | | .eq(ComMngVaccinesEnrollRecordDO::getFamilyUserId, user.getUserId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getType, enrollUserByAppDTO.getVaccinesId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getFamilyUserType, user.getIsUser())); |
| | | if (enrollRecordDO != null) { |
| | | user.setIsEnroll(VaccinesEnrollUserByAppVO.isEnroll.yes); |
| | | }else{ |
| | | } else { |
| | | user.setIsEnroll(VaccinesEnrollUserByAppVO.isEnroll.no); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | List<VaccinesEnrollUserByAppVO> newUserLists = userLists.stream().sorted(Comparator.comparing(VaccinesEnrollUserByAppVO::getIsEnroll).reversed() |
| | | .thenComparing(Comparator.comparing(VaccinesEnrollUserByAppVO::getCreateAt).reversed())).collect(Collectors.toList()); |
| | | List<VaccinesEnrollUserByAppVO> newUserLists = userLists.stream() |
| | | .sorted(Comparator.comparing(VaccinesEnrollUserByAppVO::getIsEnroll).reversed() |
| | | .thenComparing(Comparator.comparing(VaccinesEnrollUserByAppVO::getCreateAt).reversed())) |
| | | .collect(Collectors.toList()); |
| | | return R.ok(newUserLists); |
| | | } |
| | | |
| | | /** |
| | | * 用户疫苗报名 |
| | | * @param enrollByAppDTO 请求参数 |
| | | * @return 报名结果 |
| | | * |
| | | * @param enrollByAppDTO |
| | | * 请求参数 |
| | | * @return 报名结果 |
| | | */ |
| | | @Override |
| | | public R VaccinesEnrollByApp(VaccinesEnrollByAppDTO enrollByAppDTO){ |
| | | //查询疫苗信息 |
| | | public R VaccinesEnrollByApp(VaccinesEnrollByAppDTO enrollByAppDTO) { |
| | | // 查询疫苗信息 |
| | | ComMngVaccinesDO vaccinesDO = comMngVaccinesDAO.selectById(enrollByAppDTO.getVaccinesId()); |
| | | if(vaccinesDO == null){ |
| | | if (vaccinesDO == null) { |
| | | return R.fail("未找到到疫苗信息"); |
| | | } |
| | | List<ComMngVaccinesEnrollRecordDO> vaccinesEnrollRecordDOList = new ArrayList<>(); |
| | | if(!enrollByAppDTO.getEnrollUserList().isEmpty()){ |
| | | for (EnrollUserByAppDTO userByAppDTO:enrollByAppDTO.getEnrollUserList()) { |
| | | ComMngVaccinesEnrollRecordDO enrollRecordDO = this.baseMapper.selectOne(new QueryWrapper<ComMngVaccinesEnrollRecordDO>() |
| | | .lambda().eq(ComMngVaccinesEnrollRecordDO::getFamilyUserType,userByAppDTO.getIsUser()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getFamilyUserId,userByAppDTO.getUserId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getUserId,enrollByAppDTO.getUserId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getType,enrollByAppDTO.getVaccinesId())); |
| | | if(enrollRecordDO != null){ |
| | | if (!enrollByAppDTO.getEnrollUserList().isEmpty()) { |
| | | for (EnrollUserByAppDTO userByAppDTO : enrollByAppDTO.getEnrollUserList()) { |
| | | ComMngVaccinesEnrollRecordDO enrollRecordDO = |
| | | this.baseMapper.selectOne(new QueryWrapper<ComMngVaccinesEnrollRecordDO>().lambda() |
| | | .eq(ComMngVaccinesEnrollRecordDO::getFamilyUserType, userByAppDTO.getIsUser()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getFamilyUserId, userByAppDTO.getUserId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getUserId, enrollByAppDTO.getUserId()) |
| | | .eq(ComMngVaccinesEnrollRecordDO::getType, enrollByAppDTO.getVaccinesId())); |
| | | if (enrollRecordDO != null) { |
| | | continue; |
| | | } |
| | | //报名疫苗填充对象 |
| | | // 报名疫苗填充对象 |
| | | ComMngVaccinesEnrollRecordDO vaccinesEnrollRecordDO = new ComMngVaccinesEnrollRecordDO(); |
| | | if(userByAppDTO.getIsUser().equals(EnrollUserByAppDTO.isUser.yes)){ |
| | | //如果是自己就查询自己的信息 |
| | | VaccinesEnrollUserByAppVO enrollUserByAppVO = this.baseMapper.getSysUser(enrollByAppDTO.getUserId()); |
| | | if(enrollUserByAppVO != null){ |
| | | if (userByAppDTO.getIsUser().equals(EnrollUserByAppDTO.isUser.yes)) { |
| | | // 如果是自己就查询自己的信息 |
| | | VaccinesEnrollUserByAppVO enrollUserByAppVO = |
| | | this.baseMapper.getSysUser(enrollByAppDTO.getUserId()); |
| | | if (enrollUserByAppVO != null) { |
| | | vaccinesEnrollRecordDO.setName(enrollUserByAppVO.getName()); |
| | | vaccinesEnrollRecordDO.setIdCard(enrollUserByAppVO.getIdCard()); |
| | | vaccinesEnrollRecordDO.setAge(enrollUserByAppVO.getAge()); |
| | |
| | | vaccinesEnrollRecordDO.setSex(IdCard.sex(enrollUserByAppVO.getIdCard())); |
| | | } |
| | | vaccinesEnrollRecordDO.setFamilyUserType(ComMngVaccinesEnrollRecordDO.familyUserType.mini); |
| | | }else{ |
| | | VaccinesEnrollUserByAppVO enrollUserByAppVO = this.baseMapper.getFamilyUser(userByAppDTO.getUserId()); |
| | | if(enrollUserByAppVO != null){ |
| | | } else { |
| | | VaccinesEnrollUserByAppVO enrollUserByAppVO = |
| | | this.baseMapper.getFamilyUser(userByAppDTO.getUserId()); |
| | | if (enrollUserByAppVO != null) { |
| | | vaccinesEnrollRecordDO.setName(enrollUserByAppVO.getName()); |
| | | vaccinesEnrollRecordDO.setIdCard(enrollUserByAppVO.getIdCard()); |
| | | vaccinesEnrollRecordDO.setAge(enrollUserByAppVO.getAge()); |
| | |
| | | vaccinesEnrollRecordDOList.add(vaccinesEnrollRecordDO); |
| | | } |
| | | } |
| | | if(!vaccinesEnrollRecordDOList.isEmpty()){ |
| | | if (!vaccinesEnrollRecordDOList.isEmpty()) { |
| | | this.saveBatch(vaccinesEnrollRecordDOList); |
| | | } |
| | | return R.ok(); |
| | |
| | | |
| | | /** |
| | | * 查询疫苗登记列表 |
| | | * @param vaccinesByAdminDTO 请求参数 |
| | | * @return 登记列表 |
| | | * |
| | | * @param vaccinesByAdminDTO |
| | | * 请求参数 |
| | | * @return 登记列表 |
| | | */ |
| | | @Override |
| | | public R getVaccinesEnrollListByAdmin(VaccinesEnrollByAdminDTO vaccinesByAdminDTO){ |
| | | IPage<VaccinesEnrollByAdminVO> enrollByAdminVOIPage = this.baseMapper.getVaccinesEnrollListByAdmin(new Page<VaccinesEnrollByAdminVO>(vaccinesByAdminDTO.getPageNum(),vaccinesByAdminDTO.getPageSize()),vaccinesByAdminDTO); |
| | | if(!enrollByAdminVOIPage.getRecords().isEmpty()){ |
| | | for (VaccinesEnrollByAdminVO enroll:enrollByAdminVOIPage.getRecords()) { |
| | | if(enroll.getIdCard().length() != 18){ |
| | | public R getVaccinesEnrollListByAdmin(VaccinesEnrollByAdminDTO vaccinesByAdminDTO) { |
| | | IPage<VaccinesEnrollByAdminVO> enrollByAdminVOIPage = this.baseMapper.getVaccinesEnrollListByAdmin( |
| | | new Page<VaccinesEnrollByAdminVO>(vaccinesByAdminDTO.getPageNum(), vaccinesByAdminDTO.getPageSize()), |
| | | vaccinesByAdminDTO); |
| | | if (!enrollByAdminVOIPage.getRecords().isEmpty()) { |
| | | for (VaccinesEnrollByAdminVO enroll : enrollByAdminVOIPage.getRecords()) { |
| | | if (enroll.getIdCard().length() != 18) { |
| | | enroll.setSex(3); |
| | | }else{ |
| | | } else { |
| | | enroll.setSex(IdCard.sex(enroll.getIdCard())); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据条件导出疫苗登记记录 |
| | | * @param vaccinesByAdminDTO 请求参数 |
| | | * @return 导出登记列表 |
| | | * |
| | | * @param vaccinesByAdminDTO |
| | | * 请求参数 |
| | | * @return 导出登记列表 |
| | | */ |
| | | @Override |
| | | public R exportVaccinesEnrollListByAdmin(VaccinesEnrollByAdminDTO vaccinesByAdminDTO){ |
| | | public R exportVaccinesEnrollListByAdmin(VaccinesEnrollByAdminDTO vaccinesByAdminDTO) { |
| | | return R.ok(this.baseMapper.exportVaccinesEnrollListByAdmin(vaccinesByAdminDTO)); |
| | | } |
| | | } |