lighter 1 year ago
parent
commit
387785ccf8

+ 4 - 3
src/main/java/thyyxxk/webserver/dao/his/inpatient/casefrontsheet/QualityVerificationDao.java

@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import org.mapstruct.Mapper;
 import thyyxxk.webserver.entity.casefrontsheet.FrontsheetQualityVerification;
+import thyyxxk.webserver.entity.casefrontsheet.state.AuditState;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 
 import java.util.List;
@@ -33,7 +34,7 @@ public interface QualityVerificationDao extends BaseMapper<FrontsheetQualityVeri
     @Update("update t_frontsheet_quality_verification set audit_state='INITIAL' where id=#{id} ")
     int revokeApprovedAudit(String id);
 
-    @Select("select audit_state from t_frontsheet_quality_verification " +
-            "where pat_no=#{patNo} and times=#{times}")
-    List<String> selectStates(String patNo, int times);
+    @Select("select top 1 audit_state from t_frontsheet_quality_verification " +
+            "where pat_no=#{patNo} and times=#{times} order by application_time desc ")
+    AuditState selectStates(String patNo, int times);
 }

+ 16 - 9
src/main/java/thyyxxk/webserver/service/inpatient/casefrontsheet/CaseFrontSheetMainService.java

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -390,17 +391,23 @@ public class CaseFrontSheetMainService {
             sheet.setUseAntibiotic(antibioticCounts > 0 ? "1" : "2");
         }
 
-        List<String> auditStates = qualityVerificationDao.selectStates(patNo, times);
-        if (auditStates.isEmpty()) {
-            sheet.setAuditState(AuditState.NONE);
-        } else {
-            if (auditStates.contains("APPROVED")) {
+        AuditState auditState = qualityVerificationDao.selectStates(patNo, times);
+        if (null == auditState) {
+            auditState = AuditState.NONE;
+        }
+        switch (auditState) {
+            case NONE:
+                sheet.setAuditState(AuditState.NONE);
+                break;
+            case INITIAL:
+                sheet.setAuditState(AuditState.INITIAL);
+                break;
+            case APPROVED:
                 sheet.setAuditState(AuditState.APPROVED);
-            } else if (auditStates.contains("REJECTED")) {
+                break;
+            case REJECTED:
                 sheet.setAuditState(AuditState.REJECTED);
-            } else {
-                sheet.setAuditState(AuditState.INITIAL);
-            }
+                break;
         }
     }