From 9526971c403417c1c007804f24884c443b9e6cd7 Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期三, 04 九月 2024 00:34:40 +0800 Subject: [PATCH] 代码提交 --- smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 46 insertions(+), 14 deletions(-) diff --git a/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java index f0f82f9..537374f 100644 --- a/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java +++ b/smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java @@ -1,12 +1,23 @@ 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; /** * 鎮h�呴棬璇婅褰昐ervice涓氬姟灞傚鐞� @@ -15,10 +26,13 @@ * @date 2023-03-04 */ @Service -public class PatMedOuthospServiceImpl implements IPatMedOuthospService -{ +public class PatMedOuthospServiceImpl implements IPatMedOuthospService { @Autowired private PatMedOuthospMapper patMedOuthospMapper; + + @Autowired + private SysUserDeptMapper sysUserDeptMapper; + /** * 鏌ヨ鎮h�呴棬璇婅褰� @@ -27,8 +41,7 @@ * @return 鎮h�呴棬璇婅褰� */ @Override - public PatMedOuthosp selectPatMedOuthospById(Long id) - { + public PatMedOuthosp selectPatMedOuthospById(Long id) { return patMedOuthospMapper.selectPatMedOuthospById(id); } @@ -39,8 +52,7 @@ * @return 鎮h�呴棬璇婅褰� */ @Override - public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) - { + public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) { return patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); } @@ -51,8 +63,7 @@ * @return 缁撴灉 */ @Override - public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp) - { + public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp) { patMedOuthosp.setCreateTime(DateUtils.getNowDate()); patMedOuthosp.setUpdateTime(DateUtils.getNowDate()); return patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); @@ -65,8 +76,7 @@ * @return 缁撴灉 */ @Override - public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp) - { + public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp) { patMedOuthosp.setUpdateTime(DateUtils.getNowDate()); return patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp); } @@ -78,8 +88,7 @@ * @return 缁撴灉 */ @Override - public int deletePatMedOuthospByIds(Long[] ids) - { + public int deletePatMedOuthospByIds(Long[] ids) { return patMedOuthospMapper.deletePatMedOuthospByIds(ids); } @@ -90,8 +99,31 @@ * @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); + } } -- Gitblit v1.9.3