| | |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.project.common.CalculateDateUtils; |
| | | import com.ruoyi.project.domain.ServiceDonationwitness; |
| | | import com.ruoyi.project.domain.vo.EthicalReviewVO; |
| | | import com.ruoyi.project.domain.vo.MedicalEvaluationVO; |
| | | import com.ruoyi.project.mapper.ServiceDonationwitnessMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.project.mapper.ServiceEthicalreviewopinionsMapper; |
| | | import com.ruoyi.project.domain.ServiceEthicalreviewopinions; |
| | | import com.ruoyi.project.service.IServiceEthicalreviewopinionsService; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | /** |
| | | * 伦理审查专家意见Service业务层处理 |
| | |
| | | * @author ruoyi |
| | | * @date 2021-11-23 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ServiceEthicalreviewopinionsServiceImpl extends ServiceImpl<ServiceEthicalreviewopinionsMapper, ServiceEthicalreviewopinions> implements IServiceEthicalreviewopinionsService { |
| | | |
| | | @Autowired |
| | | ServiceEthicalreviewopinionsMapper serviceEthicalreviewopinionsMapper; |
| | | |
| | | @Autowired |
| | | ServiceDonationwitnessMapper serviceDonationwitnessMapper; |
| | | |
| | | /** |
| | | * 查询伦理审查专家意见列表 |
| | |
| | | } |
| | | List<EthicalReviewVO> ethicalReviewVOS = serviceEthicalreviewopinionsMapper.selectVOList(ethicalReviewVO); |
| | | |
| | | // 一次性取出各捐献基础对应的死亡时间,避免在循环里按捐献基础ID逐条查见证表(N+1) |
| | | List<Long> infoIds = new ArrayList<>(); |
| | | for (EthicalReviewVO item : ethicalReviewVOS) { |
| | | if (item.getId() != null) { |
| | | infoIds.add(item.getId()); |
| | | } |
| | | } |
| | | Map<Long, Date> deathTimeMap = new HashMap<>(); |
| | | if (!infoIds.isEmpty()) { |
| | | for (ServiceDonationwitness witness : serviceDonationwitnessMapper.selectDeathTimeByInfoIds(infoIds)) { |
| | | if (witness.getInfoid() != null && !deathTimeMap.containsKey(witness.getInfoid())) { |
| | | deathTimeMap.put(witness.getInfoid(), witness.getDeathtime()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (EthicalReviewVO ethicalReviewVO1 : ethicalReviewVOS) { |
| | | if (ethicalReviewVO1.getBirthday() != null) { |
| | | Map<String, String> map = CalculateDateUtils.calculateAge(ethicalReviewVO1.getBirthday().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now()); |
| | | //先给个年龄默认值(因为age是数字类型,不能放横杠,所以就所横扛放到单位上) |
| | | ethicalReviewVO1.setAgeunit("-"); |
| | | ethicalReviewVO1.setAge(null); |
| | | ethicalReviewVO1.setAge2(null); |
| | | //获取死亡时间,如果获取见证里有死亡时间,则进行计算他的年龄 |
| | | Date deathtime = deathTimeMap.get(ethicalReviewVO1.getId()); |
| | | if (ObjectUtils.isNotEmpty(deathtime) && ethicalReviewVO1.getBirthday() != null) { |
| | | Map<String, String> map = CalculateDateUtils.calculateAge(ethicalReviewVO1.getBirthday().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), deathtime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); |
| | | if (ObjectUtils.isEmpty(map)) { |
| | | log.error("EthicalReviewVO出生日期:{},EthicalReviewVO死亡日期:{}", ethicalReviewVO1.getBirthday(), deathtime); |
| | | continue; |
| | | } |
| | | ethicalReviewVO1.setAge(org.apache.commons.lang3.ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null); |
| | | ethicalReviewVO1.setAgeunit(map.get("ageUnit")); |
| | | ethicalReviewVO1.setAge2(org.apache.commons.lang3.ObjectUtils.isNotEmpty(map.get("age2")) ? Long.valueOf(map.get("age2")) : null); |
| | | ethicalReviewVO1.setAgeunit2(map.get("ageUnit2")); |
| | | } |
| | | |
| | | } |
| | | return ethicalReviewVOS; |
| | | } |