Browse Source

药房现在是从数据库动态开的了

xiaochan 5 months ago
parent
commit
125944eb7b

+ 9 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/YizhuLuRuController.java

@@ -18,6 +18,7 @@ import thyyxxk.webserver.entity.inpatient.patient.Overview;
 import thyyxxk.webserver.entity.inpatient.patient.Patient;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.SiLimitRequest;
+import thyyxxk.webserver.entity.medicine.vo.YpZdGroupNameVo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.OneClickOrder;
 import thyyxxk.webserver.entity.zhuyuanyisheng.dto.doctorAuth.DoctorAuthParams;
 import thyyxxk.webserver.entity.zhuyuanyisheng.vo.doctorAuth.DoctorAuthRest;
@@ -26,6 +27,7 @@ import thyyxxk.webserver.service.hutoolcache.CacheEnums;
 import thyyxxk.webserver.service.hutoolcache.DrugCache;
 import thyyxxk.webserver.service.hutoolcache.ExtraCache;
 import thyyxxk.webserver.service.zhuyuanyisheng.YiZhuLuRuServer;
+import thyyxxk.webserver.utils.R;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
 
@@ -277,4 +279,11 @@ public class YizhuLuRuController {
         return ResultVoUtil.success(yp.getJiLiang());
     }
 
+    @GetMapping("/getYpZdGroup")
+    @PassToken
+    public ResultVo<Map<String, List<YpZdGroupNameVo>>> getYpZdGroup() {
+        return R.ok(server.getYpZdGroup());
+    }
+
+
 }

+ 16 - 0
src/main/java/thyyxxk/webserver/dao/his/hutoolcache/HutoolCacheDao.java

@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.entity.medicine.YpZdGroupName;
 import thyyxxk.webserver.entity.settings.IntergrationMenu;
 import thyyxxk.webserver.entity.settings.IntergrationPlatformRoleMenu;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.YzZdOrderItemConfirm;
@@ -93,4 +94,19 @@ public interface HutoolCacheDao {
     @Select("select * " +
             "from yz_zd_order_item_confirm")
     List<YzZdOrderItemConfirm> getYzZdOrderItemConfirm();
+
+    @Select("select group_no, group_name,start_time, end_time " +
+            "from yp_zd_group_name\n" +
+            "where zy_flag = 1\n" +
+            "  and del_flag = 0\n" +
+            "  and xy_flag = 1")
+    List<YpZdGroupName> selectYpZdGroup();
+
+
+    @Select("select group_no, group_name,start_time, end_time " +
+            "from yp_zd_group_name\n" +
+            "where zy_flag = 1\n" +
+            "  and del_flag = 0\n" +
+            "  and zcy_flag = 1")
+    List<YpZdGroupName> selectYpCyGroup();
 }

+ 16 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -11,6 +11,7 @@ import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
 import thyyxxk.webserver.entity.inpatient.patient.Overview;
 import thyyxxk.webserver.entity.inpatient.patient.Patient;
 import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.entity.medicine.YpZdGroupName;
 import thyyxxk.webserver.entity.yzcheck.ChargeLimitations;
 import thyyxxk.webserver.entity.zhuyuanyisheng.DoctorSOrderFee;
 import thyyxxk.webserver.entity.zhuyuanyisheng.OneClickOrder;
@@ -1447,4 +1448,19 @@ public interface YiZhuLuRuDao {
             "group by charge_date, limit_day, limit_times")
     List<ChargeLimitations> getChargeDay(String patNo, Integer times, Integer ledgerSn, String chargeCode);
 
+    @Select("select group_no, group_name,start_time, end_time " +
+            "from yp_zd_group_name\n" +
+            "where zy_flag = 1\n" +
+            "  and del_flag = 0\n" +
+            "  and xy_flag = 1")
+    List<YpZdGroupName> selectYpZdGroup();
+
+
+    @Select("select group_no, group_name,start_time, end_time " +
+            "from yp_zd_group_name\n" +
+            "where zy_flag = 1\n" +
+            "  and del_flag = 0\n" +
+            "  and zcy_flag = 1")
+    List<YpZdGroupName> selectYpCyGroup();
+
 }

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/medicine/YpZdGroupName.java

@@ -30,4 +30,6 @@ public class YpZdGroupName implements Serializable {
     private String mzFlag;
     private String yfFlag;
 
+    private String startTime;
+    private String endTime;
 }

+ 10 - 0
src/main/java/thyyxxk/webserver/entity/medicine/vo/YpZdGroupNameVo.java

@@ -0,0 +1,10 @@
+package thyyxxk.webserver.entity.medicine.vo;
+
+import lombok.Data;
+
+@Data
+public class YpZdGroupNameVo {
+    private String code;
+    private String name;
+    private Boolean isDefault;
+}

+ 13 - 1
src/main/java/thyyxxk/webserver/service/hutoolcache/ExtraCache.java

@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Component;
 import thyyxxk.webserver.dao.his.hutoolcache.HutoolCacheDao;
+import thyyxxk.webserver.entity.medicine.YpZdGroupName;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.YzZdOrderItemConfirm;
 
 import java.util.*;
@@ -22,10 +23,11 @@ public class ExtraCache implements HutoolCacheInterface<Object> {
 
     /**
      * 注意
+     *
      * @param key
      * @param function
-     * @return
      * @param <T>
+     * @return
      */
     @SuppressWarnings("unchecked")
     public <T> T getValue(String key, Supplier<T> function) {
@@ -109,6 +111,16 @@ public class ExtraCache implements HutoolCacheInterface<Object> {
         return map;
     }
 
+
+    public Map<String, List<YpZdGroupName>> getYf() {
+        return this.getValue("住院药房", () -> {
+            Map<String, List<YpZdGroupName>> rst = new HashMap<>();
+            rst.put("xy", dao.selectYpZdGroup());
+            rst.put("cy", dao.selectYpCyGroup());
+            return rst;
+        });
+    }
+
     @Override
     public String getLabel() {
         return "其他缓存";

+ 28 - 3
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -7,7 +7,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.Data;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.session.ExecutorType;
@@ -18,7 +17,6 @@ import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.envionment.YzConfig;
 import thyyxxk.webserver.config.exception.BizException;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
-import thyyxxk.webserver.constants.sidicts.ChargeStatus;
 import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.RoleCode;
@@ -32,7 +30,8 @@ import thyyxxk.webserver.entity.inpatient.patient.Overview;
 import thyyxxk.webserver.entity.inpatient.patient.Patient;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.SiLimitRequest;
-import thyyxxk.webserver.entity.zhuyuanyisheng.DoctorSOrderFee;
+import thyyxxk.webserver.entity.medicine.YpZdGroupName;
+import thyyxxk.webserver.entity.medicine.vo.YpZdGroupNameVo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.OneClickOrder;
 import thyyxxk.webserver.entity.zhuyuanyisheng.ZyOrderZk;
 import thyyxxk.webserver.entity.zhuyuanyisheng.dto.doctorAuth.DoctorAuthParams;
@@ -1495,4 +1494,30 @@ public class YiZhuLuRuServer {
         dao.updateChargeWard(patNo, times, opRecordWard, yzConfig.getShoushubingqu());
     }
 
+    /**
+     * <el-option value="71" label="门诊" />
+     * <el-option value="73" label="住院" />
+     *
+     * @return
+     */
+    public Map<String, List<YpZdGroupNameVo>> getYpZdGroup() {
+        Map<String, List<YpZdGroupName>> value = extraCache.getYf();
+        String now = DateUtil.formatDate(new Date(), "HH:mm:ss");
+        Map<String, List<YpZdGroupNameVo>> map = new HashMap<>();
+        for (Map.Entry<String, List<YpZdGroupName>> item : value.entrySet()) {
+            item.getValue().forEach(i -> {
+                YpZdGroupNameVo vo = new YpZdGroupNameVo();
+                vo.setCode(i.getGroupNo());
+                vo.setName(i.getGroupName());
+                vo.setIsDefault(false);
+                if (i.getStartTime() != null && i.getEndTime() != null) {
+                    vo.setIsDefault(DateUtil.isInTimeRange(now, i.getStartTime(), i.getEndTime()));
+                }
+                map.computeIfAbsent(item.getKey(), (k) -> new ArrayList<>()).add(vo);
+            });
+        }
+        return map;
+    }
+
+
 }

+ 3 - 2
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/yizhuverify/YiZhuCheckData.java

@@ -10,6 +10,7 @@ import thyyxxk.webserver.config.envionment.YzConfig;
 import thyyxxk.webserver.constants.Capacity;
 import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
 import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.entity.medicine.YpZdGroupName;
 import thyyxxk.webserver.entity.yzcheck.ChargeLimitations;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYzActOrder;
@@ -19,6 +20,7 @@ import thyyxxk.webserver.utils.*;
 
 import java.util.*;
 import java.util.function.Consumer;
+import java.util.stream.Collectors;
 
 @Slf4j
 public class YiZhuCheckData {
@@ -73,8 +75,7 @@ public class YiZhuCheckData {
     private UserInfo userInfo;
     @Getter
     private Boolean passTheAudit = true;
-    private final List<String> groupList = Arrays.asList("71", "73");
-
+    private final List<String> groupList = extraCache.getYf().get("xy").stream().map(YpZdGroupName::getGroupNo).collect(Collectors.toList());
     private boolean checkForRestrictedMedication = false;
 
     /**

+ 16 - 0
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.utils;
 
+import cn.hutool.core.date.DateTime;
 import lombok.extern.slf4j.Slf4j;
 import thyyxxk.webserver.constants.GetDateFormat;
 
@@ -529,6 +530,21 @@ public class DateUtil extends cn.hutool.core.date.DateUtil {
         return addNaturalDays(date, days);
     }
 
+    public static boolean isInTimeRange(String startTimeStr, String endTimeStr, String currentTimeStr) {
+        // 1. 将时间字符串转换为今天的日期对象(Hutool 自动补全年月日)
+        DateTime startTime = DateUtil.parseTimeToday(startTimeStr);
+        DateTime endTime = DateUtil.parseTimeToday(endTimeStr);
+        DateTime currentTime = DateUtil.parseTimeToday(currentTimeStr);
+
+        // 2. 判断时间范围(支持跨天场景,如 22:00:00 - 02:00:00)
+        if (endTime.isBeforeOrEquals(startTime)) {
+            // 结束时间 <= 开始时间,说明跨天(通宵时段)
+            return currentTime.isAfterOrEquals(startTime) || currentTime.isBeforeOrEquals(endTime);
+        } else {
+            // 普通时段
+            return currentTime.isAfterOrEquals(startTime) && currentTime.isBeforeOrEquals(endTime);
+        }
+    }
 
 }