| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUserDept; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.smartor.domain.PatMedReq; |
| | | import com.smartor.domain.PatMedRes; |
| | | import com.smartor.mapper.SysUserDeptMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.smartor.mapper.PatMedOuthospMapper; |
| | | import com.smartor.domain.PatMedOuthosp; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | /** |
| | | * 患者门诊记录Service业务层处理 |
| | |
| | | * @date 2023-03-04 |
| | | */ |
| | | @Service |
| | | public class PatMedOuthospServiceImpl implements IPatMedOuthospService |
| | | { |
| | | public class PatMedOuthospServiceImpl implements IPatMedOuthospService { |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Autowired |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | |
| | | |
| | | /** |
| | | * 查询患者门诊记录 |
| | |
| | | * @return 患者门诊记录 |
| | | */ |
| | | @Override |
| | | public PatMedOuthosp selectPatMedOuthospById(Long id) |
| | | { |
| | | public PatMedOuthosp selectPatMedOuthospById(Long id) { |
| | | return patMedOuthospMapper.selectPatMedOuthospById(id); |
| | | } |
| | | |
| | |
| | | * @return 患者门诊记录 |
| | | */ |
| | | @Override |
| | | public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) |
| | | { |
| | | public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) { |
| | | return patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp) |
| | | { |
| | | public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp) { |
| | | patMedOuthosp.setCreateTime(DateUtils.getNowDate()); |
| | | patMedOuthosp.setUpdateTime(DateUtils.getNowDate()); |
| | | return patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp) |
| | | { |
| | | public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp) { |
| | | patMedOuthosp.setUpdateTime(DateUtils.getNowDate()); |
| | | return patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deletePatMedOuthospByIds(Long[] ids) |
| | | { |
| | | public int deletePatMedOuthospByIds(Long[] ids) { |
| | | return patMedOuthospMapper.deletePatMedOuthospByIds(ids); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deletePatMedOuthospById(Long id) |
| | | { |
| | | public int deletePatMedOuthospById(Long id) { |
| | | return patMedOuthospMapper.deletePatMedOuthospById(id); |
| | | } |
| | | |
| | | @Override |
| | | public PatMedRes selectPatMedOuthospCount(PatMedReq patMedReq) { |
| | | // 获取当前登陆人的部门权限 |
| | | if (CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId); |
| | | List<String> deptCode = new ArrayList<>(); |
| | | for (SysDept sysDept : sysDepts) { |
| | | deptCode.add(sysDept.getDeptId().toString()); |
| | | } |
| | | patMedReq.setDeptcodeList(deptCode); |
| | | } |
| | | return patMedOuthospMapper.selectPatMedOuthospCount(patMedReq); |
| | | } |
| | | |
| | | @Override |
| | | public PatMedOuthosp getDeptCodeByPatId(PatMedOuthosp patMedOuthosp) { |
| | | List<PatMedOuthosp> patMedOuthosps = selectPatMedOuthospList(patMedOuthosp); |
| | | if (!CollectionUtils.isEmpty(patMedOuthosps)) { |
| | | Collections.sort(patMedOuthosps, Comparator.comparing(PatMedOuthosp::getAdmitdate).reversed()); |
| | | } |
| | | return patMedOuthosps.get(0); |
| | | } |
| | | } |