From da6cce0d9f01b98d20b9ed89b438cd32006a8dd8 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 22 十一月 2024 17:17:10 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java |   75 +++++++++++++++++++++++++++----------
 1 files changed, 54 insertions(+), 21 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 062e758..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,96 +1,129 @@
 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涓氬姟灞傚鐞�
- * 
+ *
  * @author smartor
  * @date 2023-03-04
  */
 @Service
-public class PatMedOuthospServiceImpl implements IPatMedOuthospService 
-{
+public class PatMedOuthospServiceImpl implements IPatMedOuthospService {
     @Autowired
     private PatMedOuthospMapper patMedOuthospMapper;
 
+    @Autowired
+    private SysUserDeptMapper sysUserDeptMapper;
+
+
     /**
      * 鏌ヨ鎮h�呴棬璇婅褰�
-     * 
+     *
      * @param id 鎮h�呴棬璇婅褰曚富閿�
      * @return 鎮h�呴棬璇婅褰�
      */
     @Override
-    public PatMedOuthosp selectPatMedOuthospById(Long id)
-    {
+    public PatMedOuthosp selectPatMedOuthospById(Long id) {
         return patMedOuthospMapper.selectPatMedOuthospById(id);
     }
 
     /**
      * 鏌ヨ鎮h�呴棬璇婅褰曞垪琛�
-     * 
+     *
      * @param patMedOuthosp 鎮h�呴棬璇婅褰�
      * @return 鎮h�呴棬璇婅褰�
      */
     @Override
-    public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp)
-    {
+    public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
         return patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp);
     }
 
     /**
      * 鏂板鎮h�呴棬璇婅褰�
-     * 
+     *
      * @param patMedOuthosp 鎮h�呴棬璇婅褰�
      * @return 缁撴灉
      */
     @Override
-    public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp)
-    {
+    public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp) {
         patMedOuthosp.setCreateTime(DateUtils.getNowDate());
+        patMedOuthosp.setUpdateTime(DateUtils.getNowDate());
         return patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp);
     }
 
     /**
      * 淇敼鎮h�呴棬璇婅褰�
-     * 
+     *
      * @param patMedOuthosp 鎮h�呴棬璇婅褰�
      * @return 缁撴灉
      */
     @Override
-    public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp)
-    {
+    public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp) {
         patMedOuthosp.setUpdateTime(DateUtils.getNowDate());
         return patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp);
     }
 
     /**
      * 鎵归噺鍒犻櫎鎮h�呴棬璇婅褰�
-     * 
+     *
      * @param ids 闇�瑕佸垹闄ょ殑鎮h�呴棬璇婅褰曚富閿�
      * @return 缁撴灉
      */
     @Override
-    public int deletePatMedOuthospByIds(Long[] ids)
-    {
+    public int deletePatMedOuthospByIds(Long[] ids) {
         return patMedOuthospMapper.deletePatMedOuthospByIds(ids);
     }
 
     /**
      * 鍒犻櫎鎮h�呴棬璇婅褰曚俊鎭�
-     * 
+     *
      * @param id 鎮h�呴棬璇婅褰曚富閿�
      * @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