diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/PregnantResult.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/PregnantResult.java new file mode 100644 index 0000000..17ad88b --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/PregnantResult.java @@ -0,0 +1,19 @@ +package com.lyms.talkonlineweb.domain; + +import lombok.Data; +import lombok.ToString; + +@Data +@ToString +public class PregnantResult { + + private Integer pid; + + private String idno; + + private Integer pcid; + + private Integer illID; + + private String iname; +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java index 5965429..6ca9e4b 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java @@ -2,8 +2,11 @@ package com.lyms.talkonlineweb.mapper; import com.lyms.talkonlineweb.domain.LymsIllness; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lyms.talkonlineweb.domain.PregnantResult; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @Entity com.lyms.talkonlineweb.domain.LymsIllness */ @@ -18,6 +21,8 @@ public interface LymsIllnessMapper extends BaseMapper { */ Integer queryPatientHasIllnessCode(@Param("pid") Integer pid, @Param("illCode") Integer illCode,@Param("hid") Integer hid); + List queryMayPregnant(); + } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsIllnessService.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsIllnessService.java index 68614dc..1c3b73b 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsIllnessService.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsIllnessService.java @@ -2,10 +2,18 @@ package com.lyms.talkonlineweb.service; import com.lyms.talkonlineweb.domain.LymsIllness; import com.baomidou.mybatisplus.extension.service.IService; +import com.lyms.talkonlineweb.domain.PregnantResult; + +import java.util.List; /** * */ public interface LymsIllnessService extends IService { + /** + * 查询病名可能未孕妇的数据 + * @return + */ + List queryMayPregnant(); } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsIllnessServiceImpl.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsIllnessServiceImpl.java index 2397f0c..5bc6a14 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsIllnessServiceImpl.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsIllnessServiceImpl.java @@ -2,10 +2,14 @@ package com.lyms.talkonlineweb.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.lyms.talkonlineweb.domain.LymsIllness; +import com.lyms.talkonlineweb.domain.PregnantResult; import com.lyms.talkonlineweb.service.LymsIllnessService; import com.lyms.talkonlineweb.mapper.LymsIllnessMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * */ @@ -13,6 +17,13 @@ import org.springframework.stereotype.Service; public class LymsIllnessServiceImpl extends ServiceImpl implements LymsIllnessService{ + + @Autowired + LymsIllnessMapper lymsIllnessMapper; + @Override + public List queryMayPregnant() { + return lymsIllnessMapper.queryMayPregnant(); + } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/RefreshPregnantIllNameTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/RefreshPregnantIllNameTask.java new file mode 100644 index 0000000..0cc6797 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/RefreshPregnantIllNameTask.java @@ -0,0 +1,69 @@ +package com.lyms.talkonlineweb.task; + + +import com.alibaba.fastjson.JSONObject; +import com.lyms.talkonlineweb.domain.LymsIllness; +import com.lyms.talkonlineweb.domain.PregnantResult; +import com.lyms.talkonlineweb.service.LymsIllnessService; +import com.lyms.talkonlineweb.service.LymsPatientService; +import com.lyms.talkonlineweb.service.LymsPcaseService; +import com.lyms.talkonlineweb.util.CommonUtil; +import com.lyms.talkonlineweb.util.Constant; +import com.lyms.talkonlineweb.util.HttpUtil; +import com.lyms.talkonlineweb.util.StringUtil; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 定时更新孕妇疾病名称task + */ +@Component +@Log4j2 +public class RefreshPregnantIllNameTask { + + @Autowired + LymsIllnessService illnessService; + + @Value("${platform.url}") + private String PlatformUrl; + + @Scheduled(cron = "0 0 2 * * ?") + public void refreshPregnant(){ + log.info("refreshPregnant task start"); + List pregnantResults = illnessService.queryMayPregnant(); + log.info("refreshPregnant size={} ",pregnantResults.size()); + for(PregnantResult result : pregnantResults){ + if(CommonUtil.isPregnantByIllName(result.getIname())){ + try{ + String data = HttpUtil.getData(PlatformUrl + Constant.PLATFORM_QUERY_PREGNANT_URL + "?cardNo=" + result.getIdno()); + log.info("调用孕产婴平台返回:{}",data); + if(StringUtil.isNotEmpty(data)){ + JSONObject jsonObject = JSONObject.parseObject(data); + if(jsonObject.getInteger("errorcode") == 0){ + String illName = jsonObject.getString("object"); + if(StringUtil.isNotEmpty(illName) && !illName.equals(result.getIname())){ + LymsIllness ill = new LymsIllness(); + ill.setId(result.getIllID()); + ill.setIname(illName); + illnessService.updateById(ill); + } + } + + }else{ + + } + }catch (Exception e){ + log.error("调用孕产婴平台异常",e); + } + }else{ + log.info("该记录不属于孕妇标识:{}",result); + } + + } + } +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java index 74f7de5..c677c0f 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java @@ -80,4 +80,8 @@ public class Constant { * 公众号AppSecret 测试 */ public static final String GZ_SECRET_CS ="1c4b5543a54c74dd363a6655ca1cbffe"; + + + + public static String PLATFORM_QUERY_PREGNANT_URL = "/patientDueWeekAndRisk"; } diff --git a/talkonlineweb/src/main/resources/application-dev.yml b/talkonlineweb/src/main/resources/application-dev.yml index 4d058b2..b8c7729 100644 --- a/talkonlineweb/src/main/resources/application-dev.yml +++ b/talkonlineweb/src/main/resources/application-dev.yml @@ -50,6 +50,10 @@ patient: #需要预建医院获得id(Integer) hospital: 11 +#孕产婴平台接口地址 +platform: + url: https://dev-rp-api.healthbaby.com.cn + #微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突) getAccessToken: #on/off 会转义boolean diff --git a/talkonlineweb/src/main/resources/application-prod.yml b/talkonlineweb/src/main/resources/application-prod.yml index 26d1143..3d9a85c 100644 --- a/talkonlineweb/src/main/resources/application-prod.yml +++ b/talkonlineweb/src/main/resources/application-prod.yml @@ -44,6 +44,10 @@ patient: #需要预建医院获得id(Integer) hospital: 16 +#孕产婴平台接口地址 +platform: + url: https://rp-api.healthbaby.com.cn + #微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突) getAccessToken: on_off: on \ No newline at end of file diff --git a/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml b/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml index df2ba51..2d3ae3c 100644 --- a/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml +++ b/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml @@ -8,6 +8,7 @@ + @@ -29,4 +30,19 @@ and pcase.hid = #{hid} and i.iid = #{illCode} +