|
@ -1,6 +1,7 @@
|
|
package com.yihu.jw.article.service;
|
|
package com.yihu.jw.article.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.yihu.jw.article.dao.*;
|
|
import com.yihu.jw.article.dao.*;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
@ -11,6 +12,7 @@ import com.yihu.jw.entity.base.menu.BaseMenuDictUserDO;
|
|
import com.yihu.jw.entity.base.menu.BaseMenuShowDO;
|
|
import com.yihu.jw.entity.base.menu.BaseMenuShowDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
|
|
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
|
|
|
|
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
@ -52,6 +54,8 @@ public class BaseMenuManageService {
|
|
private BasePatientDao patientDao;
|
|
private BasePatientDao patientDao;
|
|
@Autowired
|
|
@Autowired
|
|
private BaseDoctorDao doctorDao;
|
|
private BaseDoctorDao doctorDao;
|
|
|
|
@Autowired
|
|
|
|
private KnowledgeArticleUserDao knowledgeArticleUserDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -198,16 +202,6 @@ public class BaseMenuManageService {
|
|
map.put("menuLocationName",wlyyHospitalSysDictDO.getDictValue());
|
|
map.put("menuLocationName",wlyyHospitalSysDictDO.getDictValue());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:menuLocation){
|
|
|
|
if (map.get("menuLocation").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
|
map.put("menuLocationName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:releaseType){
|
|
|
|
if (map.get("releaseType").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
|
map.put("releaseTypeName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Map<String,Object> mapchild:list){
|
|
for (Map<String,Object> mapchild:list){
|
|
if (mapchild.get("parentId").toString().equalsIgnoreCase(map.get("id").toString())){
|
|
if (mapchild.get("parentId").toString().equalsIgnoreCase(map.get("id").toString())){
|
|
List<String> list1 = new ArrayList<>();
|
|
List<String> list1 = new ArrayList<>();
|
|
@ -259,18 +253,6 @@ public class BaseMenuManageService {
|
|
baseMenuDictDO.setLocaTionName(menuLocation.getDictValue());
|
|
baseMenuDictDO.setLocaTionName(menuLocation.getDictValue());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(baseMenuDictDO.getDoctors())){
|
|
|
|
String doctors = "'"+baseMenuDictDO.getDoctors().replace(",","','")+"'";
|
|
|
|
String sql = "select * from base_doctor where id in ("+doctors+")";
|
|
|
|
List<BaseDoctorDO> doctorDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
|
|
|
|
baseMenuDictDO.setDoctorList(doctorDOList);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(patient)){
|
|
|
|
//点赞收藏相关
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
return baseMenuDictDO;
|
|
return baseMenuDictDO;
|
|
}
|
|
}
|
|
@ -365,10 +347,6 @@ public class BaseMenuManageService {
|
|
menuOld.setDescribtion(menuDO.getDescribtion());
|
|
menuOld.setDescribtion(menuDO.getDescribtion());
|
|
menuOld.setMenuTitle(menuDO.getMenuTitle());
|
|
menuOld.setMenuTitle(menuDO.getMenuTitle());
|
|
menuOld.setBgImg(menuDO.getBgImg());
|
|
menuOld.setBgImg(menuDO.getBgImg());
|
|
menuOld.setReleaseType(menuDO.getReleaseType());
|
|
|
|
menuOld.setDoctors(menuDO.getDoctors());
|
|
|
|
menuOld.setAuthor(menuDO.getAuthor());
|
|
|
|
menuOld.setMusicUrl(menuDO.getMusicUrl());
|
|
|
|
menuOld.setUpdateTime(new Date());
|
|
menuOld.setUpdateTime(new Date());
|
|
menuOld.setIsDel("1");
|
|
menuOld.setIsDel("1");
|
|
menuDO = baseMenuDictDao.save(menuOld);
|
|
menuDO = baseMenuDictDao.save(menuOld);
|
|
@ -841,4 +819,240 @@ public class BaseMenuManageService {
|
|
|
|
|
|
return listParent;
|
|
return listParent;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 患者对文章操作
|
|
|
|
*
|
|
|
|
* @param flag 1点赞2收藏3常用4分享5阅读
|
|
|
|
* @param articleId 文章id
|
|
|
|
* @param userCode 用户编码
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public KnowledgeArticleUserDO updateArticleUser(Integer flag, String articleId, String userCode, Integer status){
|
|
|
|
KnowledgeArticleUserDO knowledgeArticleUserDO = knowledgeArticleUserDao.findByrelationCodeAndUserAndDel(articleId,userCode);
|
|
|
|
BasePatientDO patientDO = patientDao.findByIdAndDel(userCode,"1");
|
|
|
|
KnowledgeArticleDictDO knowledgeArticleDictDO = knowledgeArticleDictDao.findByIdAndDel(articleId);
|
|
|
|
if (knowledgeArticleUserDO!=null){
|
|
|
|
if (flag==1){
|
|
|
|
knowledgeArticleUserDO.setFabulous(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setFabulous(knowledgeArticleDictDO.getFabulous()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setFabulous(knowledgeArticleDictDO.getFabulous()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==2){
|
|
|
|
knowledgeArticleUserDO.setCollection(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setCollection(knowledgeArticleDictDO.getFabulous()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setCollection(knowledgeArticleDictDO.getFabulous()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==3){
|
|
|
|
knowledgeArticleUserDO.setUsed(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setUsed(knowledgeArticleDictDO.getUsed()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setUsed(knowledgeArticleDictDO.getUsed()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==4){
|
|
|
|
knowledgeArticleUserDO.setShare(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setShare(knowledgeArticleDictDO.getShare()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setShare(knowledgeArticleDictDO.getShare()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==5){
|
|
|
|
knowledgeArticleUserDO.setIsRead(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setReadCount(knowledgeArticleDictDO.getReadCount()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setReadCount(knowledgeArticleDictDO.getReadCount()-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
knowledgeArticleUserDO = knowledgeArticleUserDao.save(knowledgeArticleUserDO);
|
|
|
|
knowledgeArticleDictDao.save(knowledgeArticleDictDO);
|
|
|
|
}else {
|
|
|
|
knowledgeArticleUserDO = new KnowledgeArticleUserDO();
|
|
|
|
knowledgeArticleUserDO.setUser(userCode);
|
|
|
|
knowledgeArticleUserDO.setUserName(patientDO.getName());
|
|
|
|
knowledgeArticleUserDO.setDel(1);
|
|
|
|
knowledgeArticleUserDO.setRelationType(1);
|
|
|
|
knowledgeArticleUserDO.setRelationName(knowledgeArticleDictDO.getTitle());
|
|
|
|
knowledgeArticleUserDO.setRelationCode(articleId);
|
|
|
|
knowledgeArticleUserDO.setCreateTime(new Date());
|
|
|
|
knowledgeArticleUserDO.setUpdateTime(new Date());
|
|
|
|
knowledgeArticleUserDO.setFabulous(0);
|
|
|
|
knowledgeArticleUserDO.setIsRead(0);
|
|
|
|
knowledgeArticleUserDO.setUsed(0);
|
|
|
|
knowledgeArticleUserDO.setShare(0);
|
|
|
|
knowledgeArticleUserDO.setCollection(0);
|
|
|
|
if (flag==1){
|
|
|
|
knowledgeArticleUserDO.setFabulous(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setFabulous(knowledgeArticleDictDO.getFabulous()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setFabulous(knowledgeArticleDictDO.getFabulous()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==2){
|
|
|
|
knowledgeArticleUserDO.setCollection(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setCollection(knowledgeArticleDictDO.getFabulous()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setCollection(knowledgeArticleDictDO.getFabulous()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==3){
|
|
|
|
knowledgeArticleUserDO.setUsed(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setUsed(knowledgeArticleDictDO.getUsed()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setUsed(knowledgeArticleDictDO.getUsed()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==4){
|
|
|
|
knowledgeArticleUserDO.setShare(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setShare(knowledgeArticleDictDO.getShare()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setShare(knowledgeArticleDictDO.getShare()-1);
|
|
|
|
}
|
|
|
|
}else if (flag==5){
|
|
|
|
knowledgeArticleUserDO.setIsRead(status);
|
|
|
|
if (status==1){
|
|
|
|
knowledgeArticleDictDO.setReadCount(knowledgeArticleDictDO.getReadCount()+1);
|
|
|
|
}else if (status==0){
|
|
|
|
knowledgeArticleDictDO.setReadCount(knowledgeArticleDictDO.getReadCount()-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
knowledgeArticleUserDO = knowledgeArticleUserDao.save(knowledgeArticleUserDO);
|
|
|
|
knowledgeArticleDictDao.save(knowledgeArticleDictDO);
|
|
|
|
}
|
|
|
|
return knowledgeArticleUserDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询患者关注文章列表分类
|
|
|
|
*
|
|
|
|
* @param userCode 用户id
|
|
|
|
* @param flag 1点赞2收藏3常用4分享5阅读
|
|
|
|
* @param status 1或者0
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<Map<String,Object>> selectMenuList(String userCode,Integer flag,Integer status){
|
|
|
|
String sql = "SELECT\n" +
|
|
|
|
"\tkad.category_first as categoryFirst,\n" +
|
|
|
|
"\tkad.category_first_name as categoryFirstName,\n" +
|
|
|
|
"\tkad.category_second as categorySecond,\n" +
|
|
|
|
"\tkad.category_second_name as categorySecondName \n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\twlyy_knowledge_article_user kau\n" +
|
|
|
|
"LEFT JOIN wlyy_knowledge_article_dict kad ON kad.id = kau.relation_code\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tkau.user_code = '"+userCode+"' AND kad.category_second IN(SELECT md.id from base_menu_dict md where md.status=1 and md.is_del= 1) ";
|
|
|
|
String condition = "";
|
|
|
|
if (flag==1){
|
|
|
|
condition+=" and kau.fabulous = "+status;
|
|
|
|
}
|
|
|
|
if (flag==2){
|
|
|
|
condition+=" and kau.collection = "+status;
|
|
|
|
}
|
|
|
|
if (flag==3){
|
|
|
|
condition+=" and kau.used = "+status;
|
|
|
|
}
|
|
|
|
if (flag==4){
|
|
|
|
condition+=" and kau.is_share = "+status;
|
|
|
|
}
|
|
|
|
if (flag==5){
|
|
|
|
condition+=" and kau.is_read = "+status;
|
|
|
|
}
|
|
|
|
condition += " GROUP BY kad.category_first ";
|
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql+condition);
|
|
|
|
return mapList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询患者关注文章列表分类
|
|
|
|
*
|
|
|
|
* @param userCode 用户id
|
|
|
|
* @param flag 1点赞2收藏3常用4分享5阅读
|
|
|
|
* @param status 1或者0
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public JSONObject selectArticleListByCategory(String categoryFirst,String categorySecond,String userCode,Integer flag,Integer status,Integer page,Integer size){
|
|
|
|
String sql = "SELECT kad.category_first as categoryFirst,\n" +
|
|
|
|
"\tkad.category_first_name as categoryFirstName,\n" +
|
|
|
|
"\tkad.category_second as categorySecond,\n" +
|
|
|
|
"\tkad.category_second_name as categorySecondName,\n" +
|
|
|
|
"\tkad.id as id,\n" +
|
|
|
|
"\tkad.title as title,\n" +
|
|
|
|
"\tkad.intro as intro,\n" +
|
|
|
|
"\tkad.content as content,\n" +
|
|
|
|
"\tkad.image as image,\n" +
|
|
|
|
"\tkad.img as img,\n" +
|
|
|
|
"\tkad.puplish_type as puplishType,\n" +
|
|
|
|
"\tkad.puplish_type_name as puplishTypeName,\n" +
|
|
|
|
"\tkad.vedio_url as vedioUrl,\n" +
|
|
|
|
"\tkad.create_user as createUser,\n" +
|
|
|
|
"\tkad.create_user_name as createUserName,\n" +
|
|
|
|
"\tkad.source as source \n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\twlyy_knowledge_article_user kau\n" +
|
|
|
|
"LEFT JOIN wlyy_knowledge_article_dict kad ON kad.id = kau.relation_code \n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tkau.user_code = '"+userCode+"' AND kad.category_second IN(SELECT md.id from base_menu_dict md where md.status=1 and md.is_del= 1) ";
|
|
|
|
String condition = "";
|
|
|
|
if (StringUtils.isNoneBlank(categoryFirst)){
|
|
|
|
condition =" and kad.category_first = '"+categoryFirst+"' ";
|
|
|
|
}
|
|
|
|
if (StringUtils.isNoneBlank(categorySecond)){
|
|
|
|
condition =" and kad.category_second ='"+categorySecond+"' ";
|
|
|
|
}
|
|
|
|
if (flag==1){
|
|
|
|
condition+=" and kau.fabulous = "+status;
|
|
|
|
}
|
|
|
|
if (flag==2){
|
|
|
|
condition+=" and kau.collection = "+status;
|
|
|
|
}
|
|
|
|
if (flag==3){
|
|
|
|
condition+=" and kau.used = "+status;
|
|
|
|
}
|
|
|
|
if (flag==4){
|
|
|
|
condition+=" and kau.is_share = "+status;
|
|
|
|
}
|
|
|
|
if (flag==5){
|
|
|
|
condition+=" and kau.is_read = "+status;
|
|
|
|
}
|
|
|
|
condition += " order by kau.create_time desc ";
|
|
|
|
List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql+condition,page,size);
|
|
|
|
|
|
|
|
String sqlTotal = "SELECT count(1) as total "+
|
|
|
|
"FROM\n" +
|
|
|
|
"\twlyy_knowledge_article_user kau\n" +
|
|
|
|
"LEFT JOIN wlyy_knowledge_article_dict kad ON kad.id = kau.relation_code \n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tkau.user_code = '"+userCode+"' ";
|
|
|
|
List<Map<String,Object>> mapTotalList = hibenateUtils.createSQLQuery(sqlTotal+condition);
|
|
|
|
Long count = 0L;
|
|
|
|
if(mapTotalList!=null){
|
|
|
|
count = Long.parseLong(mapTotalList.get(0).get("total").toString());
|
|
|
|
}
|
|
|
|
JSONObject object = new JSONObject();
|
|
|
|
object.put("data",mapList);
|
|
|
|
object.put("page",page);
|
|
|
|
object.put("size",size);
|
|
|
|
object.put("total",count);
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询患者关联的文章
|
|
|
|
* @param userCode
|
|
|
|
* @param articleId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public KnowledgeArticleUserDO findArticleUserById(String userCode,String articleId){
|
|
|
|
return knowledgeArticleUserDao.findByrelationCodeAndUserAndDel(articleId,userCode);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|