Browse Source

患者类型定时任务修改

songxinlu 4 years ago
parent
commit
3f0c4582dd

+ 11 - 52
src/main/java/com/diagbot/facade/MedCheckWorkFacade.java

@@ -22,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.*;
-import java.util.stream.Collectors;
 
 
 /**
@@ -137,34 +136,21 @@ public class MedCheckWorkFacade {
 
 
         //定义批量插入的集合
-        HashMap<String, MedBehospitalType> medBehospitalTypeMap = null;
-        //1.判断患者类型表是否有记录
-        int count = medBehospitalTypeServiceImpl.count();
-        if (count > 0) {
-            medBehospitalTypeMap = new HashMap<>();
-            //2.1获取最近指定归档时间间隔的患者
-            RecordTypeVO recordContentVO = new RecordTypeVO();
-            recordContentVO.setHospitalId(hospiatlId);
-            recordContentVO.setModeList(new ArrayList<String>(typeValue.keySet()));
-            recordContentVO.setIsPlacefile(1l);//获取已归档的患者
-            recordContentVO.setStartTime(DateUtil.formatDateTime(DateUtil.addMinutes(DateUtil.now(), -30)));
-            recordContentVO.setEndTime(DateUtil.formatDateTime(DateUtil.now()));
-            putBehospitalTypeMap(medBehospitalTypeMap,recordContentVO,typeValue,typeName,hospiatlId,searchSize);
-        } else {
-            //2.2添加今天之前所有患者的类型
-            //2.2.1获取所有数据数量
-            medBehospitalTypeMap = new HashMap<>();
-            RecordTypeVO recordContentVO = new RecordTypeVO();
-            recordContentVO.setHospitalId(hospiatlId);
-            recordContentVO.setModeList(new ArrayList<String>(typeValue.keySet()));
-            recordContentVO.setIsPlacefile(1l);//获取已归档的患者
-            putBehospitalTypeMap(medBehospitalTypeMap,recordContentVO,typeValue,typeName,hospiatlId,searchSize);
+        HashMap<String, MedBehospitalType> medBehospitalTypeMap = new HashMap<>();
+        //1.获取有指定文书、没有患者类型的患者数据
+        RecordTypeVO recordContentVO = new RecordTypeVO();
+        recordContentVO.setHospitalId(hospiatlId);
+        recordContentVO.setModeList(new ArrayList<>(typeValue.keySet()));
+        List<MedicalRecordDTO> medicalRecordList = medicalRecordServiceImpl.getMedicalRecord(recordContentVO);
+        if(medicalRecordList!=null&&!medicalRecordList.isEmpty())
+        {
+            getPatientRecordType(medBehospitalTypeMap,medicalRecordList, typeValue, typeName, hospiatlId);
         }
-        //3.批量执行插入操作
+        //2.批量执行插入操作
         try {
             if (medBehospitalTypeMap!=null&&medBehospitalTypeMap.size() > 0) {
                 List<MedBehospitalType> medBehospitalTypeList = new ArrayList<>(medBehospitalTypeMap.values());
-                medBehospitalTypeServiceImpl.saveBatch(medBehospitalTypeList, batchSize);
+                medBehospitalTypeServiceImpl.saveOrUpdateBatch(medBehospitalTypeList, batchSize);
             }
         }
         catch(Exception e)
@@ -173,33 +159,6 @@ public class MedCheckWorkFacade {
         }
     }
 
-    private void putBehospitalTypeMap(HashMap<String, MedBehospitalType> medBehospitalTypeMap,
-                                      RecordTypeVO recordContentVO, JSONObject typeValue,
-                                      JSONObject typeName, Long hospiatlId,int searchSize) {
-        int num = medicalRecordServiceImpl.getRecordCount(recordContentVO);
-        if (num > 0) {
-
-            if (num < searchSize) {
-                //执行一次
-                recordContentVO.setStart(0L);
-                recordContentVO.setEnd(num + 0L);
-                getPatientRecordType(medBehospitalTypeMap,
-                        medicalRecordServiceImpl.getMedicalRecord(recordContentVO), typeValue, typeName, hospiatlId);
-            }
-            else
-            {
-                int i = num / searchSize + 1;
-                for (int j = 0; j < i; j++) {
-                    //5000个一次循环添加
-                    recordContentVO.setStart(j * searchSize * 1L);
-                    recordContentVO.setEnd(searchSize * 1L);
-                    getPatientRecordType(medBehospitalTypeMap,
-                            medicalRecordServiceImpl.getMedicalRecord(recordContentVO), typeValue, typeName, hospiatlId);
-                }
-            }
-        }
-    }
-
     /**
      * @Author songxl
      * @Description 获取患者类型存入批量插入map

+ 10 - 15
src/main/resources/mapper/MedicalRecordMapper.xml

@@ -72,27 +72,22 @@
         ) a
     </select>
 
-
-
     <select id="getMedicalRecord"  resultType="com.diagbot.dto.MedicalRecordDTO">
-        select  DISTINCT behospital_code,mode_id  from med_medical_record where behospital_code in
-          (select  behospital_code from med_behospital_info   where hospital_id = #{hospitalId}
-            <if test="isPlacefile !=null and isPlacefile !=''">
-                and is_placefile  =#{isPlacefile}
-            </if>
-            <if test="startTime !=null and endTime !=null">
-                and placefile_date BETWEEN #{startTime} AND #{endTime}
-            </if>
-            )
+        SELECT DISTINCT
+        a.behospital_code,
+        c.mode_id
+        from
+        med_behospital_info a LEFT JOIN med_behospital_type b
+        on a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N' and b.is_deleted = 'N'
+        LEFT JOIN med_medical_record c
+        on a.behospital_code = c.behospital_code and a.hospital_id = c.hospital_id and a.is_deleted = 'N' and c.is_deleted = 'N'
+        where  b.`value` is null
         <if test="modeList != null and modeList.size() > 0">
-            and mode_id in
+            and c.mode_id in
             <foreach collection="modeList" open="(" separator="," close=")" item="item">
                 '${item}'
             </foreach>
         </if>
-        <if test="start != null and end !=null">
-            limit #{start},#{end}
-        </if>
     </select>
 
     <update id="updateBatchByKey">