diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java index d4f65cc..a6600e5 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java @@ -2,21 +2,17 @@ package com.lyms.talkonlineweb.task; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.lyms.talkonlineweb.domain.LymsDict; import com.lyms.talkonlineweb.domain.LymsDoctor; import com.lyms.talkonlineweb.domain.LymsPushedart; -import com.lyms.talkonlineweb.service.LymsArticleService; -import com.lyms.talkonlineweb.service.LymsDoctorService; -import com.lyms.talkonlineweb.service.LymsPushedartService; -import com.lyms.talkonlineweb.service.PatientInfoService; +import com.lyms.talkonlineweb.service.*; import com.lyms.talkonlineweb.util.HXService; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Component @@ -28,26 +24,36 @@ public class HXTask { @Autowired private HXService hxService; + @Autowired + private LymsDictService lymsDictService; + @Scheduled(initialDelay=1000, fixedRate=5000) public void checkDoctorStat(){ - List dLst=lymsDoctorService.list(); - List dlLst=dLst.stream().map(d->d.getDlogin()).collect(Collectors.toList()); - String[] usernames = new String[dlLst.size()]; - JSONObject jsonObject=hxService.chkUserStatus(dlLst.toArray(usernames)); - - jsonObject.getJSONArray("data").stream().forEach(e->{ - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - LymsDoctor doctor=new LymsDoctor(); - String[] json=e.toString().replaceAll("\\{","").replaceAll("}","").split(":"); - if("online".equals(json[1].replaceAll("\"",""))){ - doctor.setStat((byte) 1); - }else { - doctor.setStat((byte)0); + Map param=new HashMap<>(); + + param.put("vtype",999); + List dcLst=lymsDictService.listByMap(param); + if (dcLst.size()>0 && dcLst.get(0).getCode()==1){ + List dLst=lymsDoctorService.list(); + List dlLst=dLst.stream().map(d->d.getDlogin()).collect(Collectors.toList()); + String[] usernames = new String[dlLst.size()]; + JSONObject jsonObject=hxService.chkUserStatus(dlLst.toArray(usernames)); + + jsonObject.getJSONArray("data").stream().forEach(e->{ + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + LymsDoctor doctor=new LymsDoctor(); + String[] json=e.toString().replaceAll("\\{","").replaceAll("}","").split(":"); + if("online".equals(json[1].replaceAll("\"",""))){ + doctor.setStat((byte) 1); + }else { + doctor.setStat((byte)0); + } + updateWrapper.eq("dlogin",json[0].replaceAll("\"","")); + boolean f=lymsDoctorService.update(doctor,updateWrapper); + + }); } - updateWrapper.eq("dlogin",json[0].replaceAll("\"","")); - boolean f=lymsDoctorService.update(doctor,updateWrapper); - }); } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java index 6e5d9a8..b5ad32c 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java @@ -2,9 +2,11 @@ package com.lyms.talkonlineweb.task; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.lyms.talkonlineweb.domain.LymsArticle; +import com.lyms.talkonlineweb.domain.LymsDict; import com.lyms.talkonlineweb.domain.LymsPushedart; import com.lyms.talkonlineweb.domain.PatientInfo; import com.lyms.talkonlineweb.service.LymsArticleService; +import com.lyms.talkonlineweb.service.LymsDictService; import com.lyms.talkonlineweb.service.LymsPushedartService; import com.lyms.talkonlineweb.service.PatientInfoService; import lombok.extern.log4j.Log4j2; @@ -13,7 +15,9 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 推送文章任务 @@ -30,25 +34,36 @@ public class PushArticleTask { @Autowired private LymsPushedartService lymsPushedartService;//推送的历史记录 + @Autowired + private LymsDictService lymsDictService; + @Scheduled(initialDelay=1000, fixedRate=5000) public void pushArtcle(){ - log.debug("开始给患者推送文章>>>>>>"); - List aLst=lymsArticleService.sltNeedPush();//获取待推送文章 - - aLst.forEach(e->{ - PatientInfo patientInfo=new PatientInfo(); - patientInfo.setIid(e.getIid());//针对特定疾病人群推送文章 - List pLst=patientInfoService.list(Wrappers.query(patientInfo)); - - pLst.forEach(p->{ - LymsPushedart pushedart=new LymsPushedart(); - pushedart.setPid(p.getId()); - pushedart.setAid(e.getAid()); - pushedart.setCreatedtime(new Date()); - pushedart.setIsread((byte) 0); - lymsPushedartService.save(pushedart);//插入到提送记录 + + Map param=new HashMap<>(); + + param.put("vtype",999); + List dcLst=lymsDictService.listByMap(param); + if (dcLst.size()>0 && dcLst.get(0).getCode()==1){ + log.debug("开始给患者推送文章>>>>>>"); + List aLst=lymsArticleService.sltNeedPush();//获取待推送文章 + + aLst.forEach(e->{ + PatientInfo patientInfo=new PatientInfo(); + patientInfo.setIid(e.getIid());//针对特定疾病人群推送文章 + List pLst=patientInfoService.list(Wrappers.query(patientInfo)); + + pLst.forEach(p->{ + LymsPushedart pushedart=new LymsPushedart(); + pushedart.setPid(p.getId()); + pushedart.setAid(e.getAid()); + pushedart.setCreatedtime(new Date()); + pushedart.setIsread((byte) 0); + lymsPushedartService.save(pushedart);//插入到提送记录 + }); + }); + } - }); } }