소스 검색

定时任务初稿

zhoutg 5 년 전
부모
커밋
316d738250

+ 7 - 0
src/main/java/com/diagbot/client/AuthServiceClient.java

@@ -1,10 +1,14 @@
 package com.diagbot.client;
 
 import com.diagbot.client.hystrix.AuthServiceHystrix;
+import com.diagbot.dto.AnalyzeDTO;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.JWT;
+import com.diagbot.vo.AnalyzeVO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.security.oauth2.common.OAuth2AccessToken;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestParam;
 
@@ -25,6 +29,9 @@ public interface AuthServiceClient {
 
     @PostMapping(value = "/oauth/check_token")
     OAuth2AccessToken checkToken(@RequestHeader(value = "Authorization") String authorization, @RequestParam("token") String token);
+
+    @PostMapping(value = "/qc/behospitalInfo/analyze_rpc")
+    RespDTO<AnalyzeDTO> analyze_rpc(@RequestBody AnalyzeVO analyzeVO);
 }
 
 

+ 9 - 0
src/main/java/com/diagbot/client/hystrix/AuthServiceHystrix.java

@@ -2,7 +2,10 @@ package com.diagbot.client.hystrix;
 
 
 import com.diagbot.client.AuthServiceClient;
+import com.diagbot.dto.AnalyzeDTO;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.JWT;
+import com.diagbot.vo.AnalyzeVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.oauth2.common.OAuth2AccessToken;
 import org.springframework.stereotype.Component;
@@ -32,4 +35,10 @@ public class AuthServiceHystrix implements AuthServiceClient {
         log.error("【hystrix】调用{}异常", "checkToken");
         return null;
     }
+
+    @Override
+    public RespDTO<AnalyzeDTO> analyze_rpc(AnalyzeVO analyzeVO) {
+        log.error("【hystrix】调用{}异常", "analyze_rpc");
+        return null;
+    }
 }

+ 3 - 4
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -3,7 +3,6 @@ package com.diagbot.config;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
@@ -14,7 +13,6 @@ import org.springframework.security.jwt.crypto.sign.RsaVerifier;
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
 import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
 import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
-import org.springframework.security.oauth2.provider.token.TokenStore;
 import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
 import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
 import org.springframework.util.FileCopyUtils;
@@ -45,9 +43,10 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/sys/dictionaryInfo/getDictionary").permitAll()
                 .antMatchers("/oauth/token").permitAll()
                 .antMatchers("/oauth/check_token").permitAll()
-                .antMatchers("/qc/behospitalInfo/analyze").permitAll()
                 .antMatchers("/cache/clear").permitAll()
-                .antMatchers("/qc/mode/getMenu").permitAll()
+                .antMatchers("/qc/behospitalInfo/execule").permitAll()
+                .antMatchers("/qc/behospitalInfo/analyze_rpc").permitAll()
+                .antMatchers("/qc/behospitalInfo/analyze").permitAll()
                 .antMatchers("/**").authenticated();
 //                .antMatchers("/**").permitAll();
     }

+ 3 - 2
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -86,9 +86,10 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/sys/user/checkToken", request)
                 || matchers("/oauth/token", request)
                 || matchers("/oauth/check_token", request)
-                || matchers("/qc/behospitalInfo/analyze", request)
                 || matchers("/cache/clear", request)
-                || matchers("/qc/mode/getMenu", request)
+                || matchers("/qc/behospitalInfo/execule", request)
+                || matchers("/qc/behospitalInfo/analyze_rpc", request)
+                || matchers("/qc/behospitalInfo/analyze", request)
                 || matchers("/", request)) {
             return true;
         }

+ 1 - 1
src/main/java/com/diagbot/entity/BehospitalInfo.java

@@ -28,7 +28,7 @@ public class BehospitalInfo implements Serializable {
     /**
      * 医院ID
      */
-    private String hospitalId;
+    private Long hospitalId;
 
     /**
      * 姓名

+ 37 - 2
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -3,6 +3,7 @@ package com.diagbot.facade;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.client.AuthServiceClient;
 import com.diagbot.client.QcServiceClient;
 import com.diagbot.dto.AlgorithmDTO;
 import com.diagbot.dto.AnalyzeDTO;
@@ -83,6 +84,8 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     private QcresultInfoFacade qcresultInfoFacade;
     @Autowired
     QcModeFacade qcModeFacade;
+    @Autowired
+    AuthServiceClient authServiceClient;
 
     public IPage<BehospitalInfoDTO> pageFac(BehospitalPageVO behospitalPageVO) {
 
@@ -144,7 +147,10 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     }
 
     public AnalyzeDTO analyze(AnalyzeVO analyzeVO) {
-        Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
+        Long hospitalId = analyzeVO.getHospitalId();
+        if (!analyzeVO.getIsTask()) {
+            hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
+        }
 //        Long hospitalId = 1L; // 写死
         analyzeVO.setHospitalId(hospitalId);
         // 获取质控条目
@@ -258,7 +264,7 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         List<QcModeDTO> qcModeDTOList = qcModeFacade.getMenu(pageMap);
         String menuData = JSON.toJSONString(qcModeDTOList);
 
-        Date date = qcresultInfoFacade.saveQcResult(algorithmDTO, algorithmVO, analyzeVO, pageData, menuData);
+        Date date = qcresultInfoFacade.saveQcResult(algorithmDTO, algorithmVO, analyzeVO, pageData, menuData, analyzeVO.getIsTask());
 
         // 返回提示信息
         List<MsgDTO> msgDTOList = getMsg(analyzeVO);
@@ -520,4 +526,33 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         }
         return age;
     }
+
+    /**
+     * 执行未评分的病历
+     */
+    public void execute() {
+//        List<BehospitalInfo> behospitalInfoList = getNoGrade();
+//        for (BehospitalInfo bean : behospitalInfoList) {
+//            AnalyzeVO analyzeVO = new AnalyzeVO();
+//            analyzeVO.setHospitalId(bean.getHospitalId());
+//            analyzeVO.setBehospitalCode(bean.getBehospitalCode());
+//            mrqcsysServiceClient.analyze(analyzeVO);
+//        }
+
+        List<BehospitalInfo> behospitalInfoList = this.list(new QueryWrapper<BehospitalInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+        );
+
+        int i = 1;
+        while(i < 100) {
+            for (BehospitalInfo bean : behospitalInfoList) {
+                AnalyzeVO analyzeVO = new AnalyzeVO();
+                analyzeVO.setIsTask(true);
+                analyzeVO.setHospitalId(bean.getHospitalId());
+                analyzeVO.setBehospitalCode(bean.getBehospitalCode());
+                authServiceClient.analyze_rpc(analyzeVO);
+                System.out.println(i++);
+            }
+        }
+    }
 }

+ 6 - 3
src/main/java/com/diagbot/facade/QcresultInfoFacade.java

@@ -97,7 +97,7 @@ public class QcresultInfoFacade extends QcresultInfoServiceImpl {
         AnalyzeVO analyzeVO = new AnalyzeVO();
         analyzeVO.setHospitalId(hospitalId);
         analyzeVO.setBehospitalCode(qcresultVO.getBehospitalCode());
-        Date date = this.saveQcResult(algorithmDTO, algorithmVO, analyzeVO,null, null);
+        Date date = this.saveQcResult(algorithmDTO, algorithmVO, analyzeVO,null, null, false);
         //返回参数组装
         AnalyzeDTO analyzeDTO = new AnalyzeDTO();
         analyzeDTO.setBehospitalCode(qcresultVO.getBehospitalCode());
@@ -111,9 +111,12 @@ public class QcresultInfoFacade extends QcresultInfoServiceImpl {
     }
 
     public Date saveQcResult(AlgorithmDTO algorithmDTO, AlgorithmVO algorithmVO, AnalyzeVO analyzeVO,
-                             String pageData, String menuData) {
+                             String pageData, String menuData, Boolean isTask) {
         //更新质控评分结果信息
-        Long useId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
+        Long useId = 0L;
+        if (!isTask) {
+            useId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
+        }
         Date now = DateUtil.now();
         //获取旧记录
         QcresultInfo qcresultInfo

+ 3 - 0
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -41,4 +41,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @return
      */
     public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO);
+
+
+    public List<BehospitalInfo> getNoGrade();
 }

+ 3 - 0
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -41,4 +41,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @return
      */
     public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO);
+
+
+    public List<BehospitalInfo> getNoGrade();
 }

+ 5 - 0
src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java

@@ -57,4 +57,9 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO) {
         return baseMapper.resultStatisticsByDept(filterVO);
     }
+
+    @Override
+    public List<BehospitalInfo> getNoGrade() {
+        return baseMapper.getNoGrade();
+    }
 }

+ 0 - 3
src/main/java/com/diagbot/task/BehospitalInfoAnalyzeTask.java

@@ -6,14 +6,11 @@ import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.facade.SysTaskCronFacade;
 import com.diagbot.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
 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.ScheduledTaskRegistrar;
 import org.springframework.scheduling.support.CronTrigger;
-import org.springframework.stereotype.Component;
 
 import java.time.LocalDateTime;
 import java.util.Date;

+ 2 - 0
src/main/java/com/diagbot/vo/AnalyzeVO.java

@@ -14,4 +14,6 @@ public class AnalyzeVO {
     private String behospitalCode; // 病历id
     @ApiModelProperty(hidden = true)
     private Long hospitalId; //医院ID
+    @ApiModelProperty(hidden = true)
+    private Boolean isTask = false;
 }

+ 18 - 0
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -73,6 +73,15 @@ public class BehospitalInfoController {
         return RespDTO.onSuc(behospitalInfoFacade.analyze(analyzeVO));
     }
 
+    @ApiOperation(value = "评分[by:zhoutg]",
+            notes = "")
+    @PostMapping("/analyze_rpc")
+    @SysLogger("analyze_rpc")
+    @Transactional
+    public RespDTO<AnalyzeDTO> analyze_rpc(@RequestBody AnalyzeVO analyzeVO) {
+        return RespDTO.onSuc(behospitalInfoFacade.analyze(analyzeVO));
+    }
+
     @ApiOperation(value = "新增质控条目[by:zhoutg]",
             notes = "")
     @PostMapping("/addCase")
@@ -100,4 +109,13 @@ public class BehospitalInfoController {
         qcresultVO.setType(3);
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
     }
+
+    @ApiOperation(value = "批量执行[by:zhoutg]",
+            notes = "")
+    @PostMapping("/execule")
+    @SysLogger("execule")
+    public RespDTO<Boolean> execule(){
+        behospitalInfoFacade.execute();
+        return RespDTO.onSuc(true);
+    }
 }

+ 17 - 0
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -199,4 +199,21 @@
         ) t2
         )
     </select>
+
+
+    <select id="getNoGrade">
+        select * from select * from med_behospital_info a
+            where a.is_deleted = 'N'
+            and
+            not EXISTS (
+            SELECT
+                1
+            FROM
+                med_qcresult_info b
+            WHERE
+                b.is_deleted = 'N'
+            AND a.hospital_id = b.hospital_id
+            AND a.behospital_code = b.behospital_code
+            )
+    </select>
 </mapper>