PushArticleTask.java 2.35 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
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;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
* 推送文章任务
*/

@Component
@Log4j2
public class PushArticleTask {

@Autowired
private LymsArticleService lymsArticleService;
@Autowired
private PatientInfoService patientInfoService;
@Autowired
private LymsPushedartService lymsPushedartService;//推送的历史记录

@Autowired
private LymsDictService lymsDictService;

// @Scheduled(initialDelay=10000, fixedRate=60000*10)
@Scheduled(initialDelay=10000, fixedRate=10000)
public void pushArtcle(){

Map<String,Object> param=new HashMap<>();

param.put("vtype",999);
List<LymsDict> dcLst=lymsDictService.listByMap(param);
if (dcLst.size()>0 && dcLst.get(0).getCode()==1){
log.debug("开始给患者推送文章>>>>>>");
List<LymsArticle> aLst=lymsArticleService.sltNeedPush();//获取待推送文章

aLst.forEach(e->{
PatientInfo patientInfo=new PatientInfo();
patientInfo.setIid(e.getIid());//针对特定疾病人群推送文章
List<PatientInfo> 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);//插入到提送记录
});

});
}

}
}