Explorar o código

定时执行归档接口归档(3天前到今天)

cb hai 6 meses
pai
achega
439830b493

+ 36 - 38
src/main/java/com/diagbot/facade/data/ABehospitalInfoFacade.java

@@ -24,11 +24,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.Date;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Component
 public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
@@ -288,41 +285,42 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
             return RespDTO.onError(e.getMessage());
         }
     }
-    public RespDTO updatePlacefile(String endDate){
-        try {
-            //验证数据是否存在
-            if(StringUtil.isBlank(endDate)){
-                return RespDTO.onError("请输入截止时间!");
-            }else{
-
-                LocalDateTime endDateTime = LocalDateTime.parse(endDate + "T23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
-                QueryWrapper<BehospitalInfo> queryWrapper = new QueryWrapper();
-                queryWrapper.eq("hospital_id", "5")
-                        .eq("is_deleted", IsDeleteEnum.N)
-                        .lt("leave_hospital_date", endDateTime);
-
-                // 查询符合条件的数据,并提取 behospital_code 字段
-                List<BehospitalInfo> behospitalInfoList = behospitalInfoMapper.selectList(queryWrapper);
-                List<String> isPlaceFileInfoList = behospitalInfoList.stream()
-                        .map(BehospitalInfo::getBehospitalCode) // 提取 behospital_code
-                        .collect(Collectors.toList());
-                if (isPlaceFileInfoList.isEmpty()) {
-                    return RespDTO.onError("未找到病历!");
-                }
-                UpdateWrapper<BehospitalInfo> updateWrapper=new UpdateWrapper<>();
-                updateWrapper.eq("hospital_id", "5")
-                        .eq("is_deleted",IsDeleteEnum.N)
-                        .in("behospital_code", isPlaceFileInfoList)
-                        .set("is_placefile","1")
-                        .set("gmt_modified", DateUtil.now());
-
-                Boolean flag=update(new BehospitalInfo(),updateWrapper);
-                return RespDTO.onSuc(flag);
-            }
-        }catch (Exception e){
-            return RespDTO.onError(e.getMessage());
-        }
-    }
+    //暂时停用
+//    public RespDTO updatePlacefile(String endDate){
+//        try {
+//            //验证数据是否存在
+//            if(StringUtil.isBlank(endDate)){
+//                return RespDTO.onError("请输入截止时间!");
+//            }else{
+//
+//                LocalDateTime endDateTime = LocalDateTime.parse(endDate + "T23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
+//                QueryWrapper<BehospitalInfo> queryWrapper = new QueryWrapper();
+//                queryWrapper.eq("hospital_id", "5")
+//                        .eq("is_deleted", IsDeleteEnum.N)
+//                        .lt("leave_hospital_date", endDateTime);
+//
+//                // 查询符合条件的数据,并提取 behospital_code 字段
+//                List<BehospitalInfo> behospitalInfoList = behospitalInfoMapper.selectList(queryWrapper);
+//                List<String> isPlaceFileInfoList = behospitalInfoList.stream()
+//                        .map(BehospitalInfo::getBehospitalCode) // 提取 behospital_code
+//                        .collect(Collectors.toList());
+//                if (isPlaceFileInfoList.isEmpty()) {
+//                    return RespDTO.onError("未找到病历!");
+//                }
+//                UpdateWrapper<BehospitalInfo> updateWrapper=new UpdateWrapper<>();
+//                updateWrapper.eq("hospital_id", "5")
+//                        .eq("is_deleted",IsDeleteEnum.N)
+//                        .in("behospital_code", isPlaceFileInfoList)
+//                        .set("is_placefile","1")
+//                        .set("gmt_modified", DateUtil.now());
+//
+//                Boolean flag=update(new BehospitalInfo(),updateWrapper);
+//                return RespDTO.onSuc(flag);
+//            }
+//        }catch (Exception e){
+//            return RespDTO.onError(e.getMessage());
+//        }
+//    }
 
     public RespDTO sendDateInfo(String startDate, String endDate, String isLeave){
         try {

+ 5 - 6
src/main/java/com/diagbot/task/PlacefileTask.java

@@ -1,7 +1,6 @@
 package com.diagbot.task;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.entity.SysTaskCron;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.facade.SysTaskCronFacade;
@@ -14,7 +13,6 @@ import org.springframework.scheduling.Trigger;
 import org.springframework.scheduling.TriggerContext;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.SchedulingConfigurer;
-import org.springframework.scheduling.config.ScheduledTask;
 import org.springframework.scheduling.config.ScheduledTaskRegistrar;
 import org.springframework.scheduling.support.CronTrigger;
 
@@ -43,11 +41,12 @@ public class PlacefileTask implements SchedulingConfigurer {
                         && task.getIsUsed().equals(1)) {
                     log.info("执行动态定时任务: " + LocalDateTime.now().toLocalTime());
                     //执行归档操作,若归档接口不能用可能会失效
-                    String endDate = LocalDateTime.now()
+                    String startDate = LocalDateTime.now()
                             .minusDays(3)
                             .format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-
-                    aBehospitalInfoFacade.updatePlacefile(endDate);
+                    String endDate = LocalDateTime.now()
+                            .format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                    aBehospitalInfoFacade.updatePlace(startDate,endDate);
                 }
             }
         }, new Trigger() {
@@ -57,7 +56,7 @@ public class PlacefileTask implements SchedulingConfigurer {
                 task = sysTaskCronFacade.getOne(new QueryWrapper<SysTaskCron>()
                         .eq("cron_code", "PLACEFILETASK"), false);
                 // 下面是默认,当数据库中获取不到动态执行周期时,则使用默认的
-                //每天晚上12点执行,可以在数据库里加上
+                //每天晚上12点执行
                 String cron = "0 0 0 * * ?";
                 //2.2 合法性校验.
                 if (null != task && StringUtil.isNotBlank(task.getCron())) {

+ 13 - 12
src/main/java/com/diagbot/web/DataController.java

@@ -76,18 +76,19 @@ public class DataController {
     public RespDTO<List<ABasDeptInfoDTO>> sendDeptInfos(@RequestBody List<ABasDeptInfoVO> list){
         return aBasDeptInfoFacade.executeDept(list);
     }
-    @ApiOperation(value = "数据引擎-更新医院所有有效科室的基本信息(病区id)")
-    @PostMapping("/updateDeptInfos")
-    @SysLogger("updateDeptInfos")
-    public void updateDeptInfos(){
-        aBasDeptInfoFacade.executeDeptCampusId();
-    }
-    @ApiOperation(value = "数据引擎-更新医院所有病人的基本信息(病区id)")
-    @PostMapping("/updatePatientInfos")
-    @SysLogger("updatePatientInfos")
-    public void updatePatientInfos(@RequestBody String startDate, String endDate){
-        aBehospitalInfoFacade.executePatientCampusId();
-    }
+    //TODO 院区id补入接口
+//    @ApiOperation(value = "数据引擎-更新医院所有有效科室的基本信息(院区id)")
+//    @PostMapping("/updateDeptInfos")
+//    @SysLogger("updateDeptInfos")
+//    public void updateDeptInfos(){
+//        aBasDeptInfoFacade.executeDeptCampusId();
+//    }
+//    @ApiOperation(value = "数据引擎-更新医院所有病人的基本信息(院区id)")
+//    @PostMapping("/updatePatientInfos")
+//    @SysLogger("updatePatientInfos")
+//    public void updatePatientInfos(@RequestBody String startDate, String endDate){
+//        aBehospitalInfoFacade.executePatientCampusId();
+//    }
 
     @ApiOperation(value = "数据引擎-获取医院所有文书模板基本信息")
     @PostMapping("/sendRecordTypes")