|
@ -1,12 +1,15 @@
|
|
|
package com.yihu.jw.hospital.service.consult;
|
|
|
|
|
|
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
|
|
|
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
|
|
|
import com.yihu.jw.mysql.query.BaseJpaService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@ -21,16 +24,38 @@ public class KnowledgeArticleUserService extends BaseJpaService<KnowledgeArticle
|
|
|
@Autowired
|
|
|
private KnowledgeArticleUserDao knowledgeArticleUserDao;
|
|
|
|
|
|
@Autowired
|
|
|
BasePatientBusinessDao basePatientBusinessDao;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 用户和文章的关系
|
|
|
* -- 1医生给患者发 2医生给自己发
|
|
|
*/
|
|
|
public List<KnowledgeArticleUserDO> sendArticleToUser(List<KnowledgeArticleUserDO> knowledgeArticleUserDOList) {
|
|
|
ArrayList<KnowledgeArticleUserDO> list = new ArrayList<>();
|
|
|
if (knowledgeArticleUserDOList != null && knowledgeArticleUserDOList.size() > 0) {
|
|
|
for (KnowledgeArticleUserDO articleUserDO : knowledgeArticleUserDOList) {
|
|
|
KnowledgeArticleUserDO userDO = knowledgeArticleUserDao.save(articleUserDO);
|
|
|
list.add(userDO);
|
|
|
KnowledgeArticleUserDO knowledgeArticleUserDO = knowledgeArticleUserDao.findByrelationCodeAndUserAndDel(articleUserDO.getRelationCode(), articleUserDO.getUser());
|
|
|
if (knowledgeArticleUserDO == null) {
|
|
|
KnowledgeArticleUserDO userDO = knowledgeArticleUserDao.save(articleUserDO);
|
|
|
list.add(userDO);
|
|
|
} else {
|
|
|
list.add(knowledgeArticleUserDO);
|
|
|
}
|
|
|
BasePatientBusinessDO businessDO = new BasePatientBusinessDO();
|
|
|
businessDO.setPatient(articleUserDO.getUser());
|
|
|
businessDO.setPatientName(articleUserDO.getUserName());
|
|
|
businessDO.setDoctor(articleUserDO.getCreateUser());
|
|
|
businessDO.setDoctorName(articleUserDO.getCreateUserName());
|
|
|
businessDO.setRelationType(articleUserDO.getRelationType());
|
|
|
businessDO.setDel(1);
|
|
|
businessDO.setCreateTime(new Date());
|
|
|
businessDO.setUpdateTime(new Date());
|
|
|
basePatientBusinessDao.save(businessDO);
|
|
|
}
|
|
|
}
|
|
|
System.out.println("保存数量==>"+list.size());
|
|
|
System.out.println("保存数量==>" + list.size());
|
|
|
return list;
|
|
|
}
|
|
|
}
|