Commit 02269f217762397e92e2a4b26a6ae10891a3e385

Authored by cfl
1 parent f9e2a4ddfe
Exists in dev

增加更新患者孕周高危病重名称的定时任务功能

Showing 9 changed files with 140 additions and 0 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/PregnantResult.java View file @ 02269f2
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import lombok.Data;
  4 +import lombok.ToString;
  5 +
  6 +@Data
  7 +@ToString
  8 +public class PregnantResult {
  9 +
  10 + private Integer pid;
  11 +
  12 + private String idno;
  13 +
  14 + private Integer pcid;
  15 +
  16 + private Integer illID;
  17 +
  18 + private String iname;
  19 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java View file @ 02269f2
... ... @@ -2,8 +2,11 @@
2 2  
3 3 import com.lyms.talkonlineweb.domain.LymsIllness;
4 4 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import com.lyms.talkonlineweb.domain.PregnantResult;
5 6 import org.apache.ibatis.annotations.Param;
6 7  
  8 +import java.util.List;
  9 +
7 10 /**
8 11 * @Entity com.lyms.talkonlineweb.domain.LymsIllness
9 12 */
... ... @@ -17,6 +20,8 @@
17 20 * @return
18 21 */
19 22 Integer queryPatientHasIllnessCode(@Param("pid") Integer pid, @Param("illCode") Integer illCode,@Param("hid") Integer hid);
  23 +
  24 + List<PregnantResult> queryMayPregnant();
20 25  
21 26 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsIllnessService.java View file @ 02269f2
... ... @@ -2,11 +2,19 @@
2 2  
3 3 import com.lyms.talkonlineweb.domain.LymsIllness;
4 4 import com.baomidou.mybatisplus.extension.service.IService;
  5 +import com.lyms.talkonlineweb.domain.PregnantResult;
5 6  
  7 +import java.util.List;
  8 +
6 9 /**
7 10 *
8 11 */
9 12 public interface LymsIllnessService extends IService<LymsIllness> {
10 13  
  14 + /**
  15 + * 查询病名可能未孕妇的数据
  16 + * @return
  17 + */
  18 + List<PregnantResult> queryMayPregnant();
11 19 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsIllnessServiceImpl.java View file @ 02269f2
... ... @@ -2,10 +2,14 @@
2 2  
3 3 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 4 import com.lyms.talkonlineweb.domain.LymsIllness;
  5 +import com.lyms.talkonlineweb.domain.PregnantResult;
5 6 import com.lyms.talkonlineweb.service.LymsIllnessService;
6 7 import com.lyms.talkonlineweb.mapper.LymsIllnessMapper;
  8 +import org.springframework.beans.factory.annotation.Autowired;
7 9 import org.springframework.stereotype.Service;
8 10  
  11 +import java.util.List;
  12 +
9 13 /**
10 14 *
11 15 */
... ... @@ -13,5 +17,12 @@
13 17 public class LymsIllnessServiceImpl extends ServiceImpl<LymsIllnessMapper, LymsIllness>
14 18 implements LymsIllnessService{
15 19  
  20 +
  21 + @Autowired
  22 + LymsIllnessMapper lymsIllnessMapper;
  23 + @Override
  24 + public List<PregnantResult> queryMayPregnant() {
  25 + return lymsIllnessMapper.queryMayPregnant();
  26 + }
16 27 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/RefreshPregnantIllNameTask.java View file @ 02269f2
  1 +package com.lyms.talkonlineweb.task;
  2 +
  3 +
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.lyms.talkonlineweb.domain.LymsIllness;
  6 +import com.lyms.talkonlineweb.domain.PregnantResult;
  7 +import com.lyms.talkonlineweb.service.LymsIllnessService;
  8 +import com.lyms.talkonlineweb.service.LymsPatientService;
  9 +import com.lyms.talkonlineweb.service.LymsPcaseService;
  10 +import com.lyms.talkonlineweb.util.CommonUtil;
  11 +import com.lyms.talkonlineweb.util.Constant;
  12 +import com.lyms.talkonlineweb.util.HttpUtil;
  13 +import com.lyms.talkonlineweb.util.StringUtil;
  14 +import lombok.extern.log4j.Log4j2;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.beans.factory.annotation.Value;
  17 +import org.springframework.scheduling.annotation.Scheduled;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +import java.util.List;
  21 +
  22 +/**
  23 + * 定时更新孕妇疾病名称task
  24 + */
  25 +@Component
  26 +@Log4j2
  27 +public class RefreshPregnantIllNameTask {
  28 +
  29 + @Autowired
  30 + LymsIllnessService illnessService;
  31 +
  32 + @Value("${platform.url}")
  33 + private String PlatformUrl;
  34 +
  35 + @Scheduled(cron = "0 0 2 * * ?")
  36 + public void refreshPregnant(){
  37 + log.info("refreshPregnant task start");
  38 + List<PregnantResult> pregnantResults = illnessService.queryMayPregnant();
  39 + log.info("refreshPregnant size={} ",pregnantResults.size());
  40 + for(PregnantResult result : pregnantResults){
  41 + if(CommonUtil.isPregnantByIllName(result.getIname())){
  42 + try{
  43 + String data = HttpUtil.getData(PlatformUrl + Constant.PLATFORM_QUERY_PREGNANT_URL + "?cardNo=" + result.getIdno());
  44 + log.info("调用孕产婴平台返回:{}",data);
  45 + if(StringUtil.isNotEmpty(data)){
  46 + JSONObject jsonObject = JSONObject.parseObject(data);
  47 + if(jsonObject.getInteger("errorcode") == 0){
  48 + String illName = jsonObject.getString("object");
  49 + if(StringUtil.isNotEmpty(illName) && !illName.equals(result.getIname())){
  50 + LymsIllness ill = new LymsIllness();
  51 + ill.setId(result.getIllID());
  52 + ill.setIname(illName);
  53 + illnessService.updateById(ill);
  54 + }
  55 + }
  56 +
  57 + }else{
  58 +
  59 + }
  60 + }catch (Exception e){
  61 + log.error("调用孕产婴平台异常",e);
  62 + }
  63 + }else{
  64 + log.info("该记录不属于孕妇标识:{}",result);
  65 + }
  66 +
  67 + }
  68 + }
  69 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java View file @ 02269f2
... ... @@ -80,5 +80,9 @@
80 80 * 公众号AppSecret 测试
81 81 */
82 82 public static final String GZ_SECRET_CS ="1c4b5543a54c74dd363a6655ca1cbffe";
  83 +
  84 +
  85 +
  86 + public static String PLATFORM_QUERY_PREGNANT_URL = "/patientDueWeekAndRisk";
83 87 }
talkonlineweb/src/main/resources/application-dev.yml View file @ 02269f2
... ... @@ -50,6 +50,10 @@
50 50 #需要预建医院获得id(Integer)
51 51 hospital: 11
52 52  
  53 +#孕产婴平台接口地址
  54 +platform:
  55 + url: https://dev-rp-api.healthbaby.com.cn
  56 +
53 57 #微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突)
54 58 getAccessToken:
55 59 #on/off 会转义boolean
talkonlineweb/src/main/resources/application-prod.yml View file @ 02269f2
... ... @@ -44,6 +44,10 @@
44 44 #需要预建医院获得id(Integer)
45 45 hospital: 16
46 46  
  47 +#孕产婴平台接口地址
  48 +platform:
  49 + url: https://rp-api.healthbaby.com.cn
  50 +
47 51 #微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突)
48 52 getAccessToken:
49 53 on_off: on
talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml View file @ 02269f2
... ... @@ -8,6 +8,7 @@
8 8 <id property="id" column="id" jdbcType="INTEGER"/>
9 9 <result property="pcid" column="pcid" jdbcType="INTEGER"/>
10 10 <result property="iid" column="iid" jdbcType="INTEGER"/>
  11 + <result property="iname" column="iname" jdbcType="VARCHAR"/>
11 12 <result property="createdby" column="createdby" jdbcType="INTEGER"/>
12 13 <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
13 14 <result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
... ... @@ -28,6 +29,21 @@
28 29 and pcase.pid = #{pid}
29 30 and pcase.hid = #{hid}
30 31 and i.iid = #{illCode}
  32 + </select>
  33 + <select id="queryMayPregnant" resultType="com.lyms.talkonlineweb.domain.PregnantResult">
  34 + select p.id as pid,
  35 + p.idno,
  36 + pcase.pcid,
  37 + ill.id as illID,
  38 + ill.iname
  39 + from
  40 + lyms_patient p,
  41 + lyms_pcase pcase,
  42 + lyms_illness ill
  43 + where p.id = pcase.pid
  44 + and pcase.pcid = ill.pcid
  45 + and ill.iname like '%孕%'
  46 + and ill.iname like '%周%'
31 47 </select>
32 48 </mapper>