Parcourir la source

表结构更新

0027005599 il y a 2 ans
Parent
commit
5d52822040

+ 86 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/projectcache/HisMedicalProjectCache.java

@@ -0,0 +1,86 @@
+package org.jeecg.modules.medical.ruleengine.projectcache;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.jeecg.modules.medical.Constant;
+import org.jeecg.modules.medical.entity.MaterialItems;
+import org.jeecg.modules.medical.entity.MedicalInsuranceDrugs;
+import org.jeecg.modules.medical.entity.TreatmentItems;
+import org.jeecg.modules.medical.service.IMaterialItemsService;
+import org.jeecg.modules.medical.service.IMedicalInsuranceDrugsService;
+import org.jeecg.modules.medical.service.ITreatmentItemsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+
+/**
+ * 医保和医院项目编码映射
+ */
+@Component
+public class HisMedicalProjectCache {
+    @Autowired
+    RedisTemplate redisTemplate;
+    @Autowired
+    IMedicalInsuranceDrugsService medicalInsuranceDrugsService;
+    @Autowired
+    ITreatmentItemsService treatmentItemsService;
+    @Autowired
+    IMaterialItemsService materialItemsService;
+
+    @PostConstruct
+    public void initHisMedicalProjectCache(){
+        long count = medicalInsuranceDrugsService.count();
+
+        if(count>0) {
+            long pageNum = count / 1000;
+            long modNum = count % 1000;
+            if (modNum > 0) {
+                pageNum = pageNum + 1;
+            }
+            for (int i = 0; i < pageNum; i++) {
+                IPage page = new Page(i, 1000);
+                List<MedicalInsuranceDrugs> medicalInsuranceDrugsList = medicalInsuranceDrugsService.page(page).getRecords();
+                for (MedicalInsuranceDrugs medicalInsuranceDrugs : medicalInsuranceDrugsList) {
+                    redisTemplate.opsForHash().put(Constant.HIS_MEDICAL_DICT_KEY, medicalInsuranceDrugs.getItemIdHosp(), medicalInsuranceDrugs.getMedicineCode());
+                    redisTemplate.opsForHash().put(Constant.MEDICAL_CODE_NAME_KEY, medicalInsuranceDrugs.getMedicineCode(), medicalInsuranceDrugs.getMedicineName());
+                }
+            }
+        }
+        count = treatmentItemsService.count();
+        if(count>0) {
+            long pageNum = count / 1000;
+            long modNum = count % 1000;
+            if (modNum > 0) {
+                pageNum = pageNum + 1;
+            }
+            for (int i = 0; i < pageNum; i++) {
+                IPage page = new Page(i, 1000);
+                List<TreatmentItems> treatmentItemsList = treatmentItemsService.page(page).getRecords();
+                for (TreatmentItems treatmentItems : treatmentItemsList) {
+                    redisTemplate.opsForHash().put(Constant.HIS_MEDICAL_DICT_KEY, treatmentItems.getItemIdHosp(), treatmentItems.getItemId());
+                    redisTemplate.opsForHash().put(Constant.MEDICAL_CODE_NAME_KEY, treatmentItems.getItemId(), treatmentItems.getItemName());
+                }
+            }
+        }
+
+        count = materialItemsService.count();
+        if(count>0) {
+            long pageNum = count / 1000;
+            long modNum = count % 1000;
+            if (modNum > 0) {
+                pageNum = pageNum + 1;
+            }
+            for (int i = 1; i <= pageNum; i++) {
+                IPage page = new Page(i, 1000);
+                List<MaterialItems> materialItemsList = materialItemsService.page(page).getRecords();
+                for (MaterialItems materialItem : materialItemsList) {
+                    redisTemplate.opsForHash().put(Constant.HIS_MEDICAL_DICT_KEY, materialItem.getItemIdHosp(), materialItem.getItemId());
+                    redisTemplate.opsForHash().put(Constant.MEDICAL_CODE_NAME_KEY, materialItem.getItemId(), materialItem.getItemName());
+                }
+            }
+        }
+    }
+}