|
@ -0,0 +1,1191 @@
|
|
|
package com.yihu.jw.article.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.article.dao.*;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.menu.BaseLinkDictDO;
|
|
|
import com.yihu.jw.entity.base.menu.BaseMenuDictDO;
|
|
|
import com.yihu.jw.entity.base.menu.BaseMenuDictUserDO;
|
|
|
import com.yihu.jw.entity.base.menu.BaseMenuShowDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
|
|
|
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDoctorDO;
|
|
|
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class BaseMenuManageService {
|
|
|
@Autowired
|
|
|
private BaseMenuDictDao baseMenuDictDao;
|
|
|
@Autowired
|
|
|
private BaseMenuShowDao baseMenuShowDao;
|
|
|
@Autowired
|
|
|
private BaseLinkDictDao baseLinkDictDao;
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
@Autowired
|
|
|
private KnowledgeArticleDictDao knowledgeArticleDictDao;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private BaseMenuDictUserDao baseMenuDictUserDao;
|
|
|
@Autowired
|
|
|
private BasePatientDao patientDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private KnowledgeArticleUserDao knowledgeArticleUserDao;
|
|
|
@Autowired
|
|
|
private KnowledgeArticleDoctorDao knowledgeArticleDoctorDao;
|
|
|
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param id
|
|
|
* @param flag 1收藏2阅读3点赞4分享
|
|
|
* @param status
|
|
|
* @return
|
|
|
*/
|
|
|
public BaseMenuDictDO setCollectionById(String id, Integer flag, Integer status, String user, String userType){
|
|
|
BaseMenuDictDO dictDO = baseMenuDictDao.findByIdAndDel(id);
|
|
|
if(dictDO==null){
|
|
|
return null;
|
|
|
}
|
|
|
BaseMenuDictUserDO dictUserDO =baseMenuDictUserDao.findByRelationCodeAndUserAndDel(id,user);
|
|
|
if (dictUserDO==null){
|
|
|
dictUserDO = new BaseMenuDictUserDO();
|
|
|
dictUserDO.setRelationCode(id);
|
|
|
dictUserDO.setRelationName(dictDO.getMenuTitle());
|
|
|
dictUserDO.setRelationType(1);
|
|
|
dictUserDO.setDel(1);
|
|
|
dictUserDO.setUser(user);
|
|
|
if (StringUtils.isNoneBlank(userType)&&userType.equalsIgnoreCase("1")){
|
|
|
BasePatientDO patientDO = patientDao.findById(user);
|
|
|
if (patientDO!=null){
|
|
|
dictUserDO.setUserName(patientDO.getName());
|
|
|
}
|
|
|
}else if (StringUtils.isNoneBlank(userType)&&userType.equalsIgnoreCase("2")){
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(user);
|
|
|
if (doctorDO!=null){
|
|
|
dictUserDO.setUserName(doctorDO.getName());
|
|
|
}
|
|
|
}
|
|
|
dictUserDO.setCreateTime(new Date());
|
|
|
}
|
|
|
|
|
|
if (flag!=null&&flag==1){
|
|
|
dictUserDO.setCollection(status);
|
|
|
}else if (flag!=null&&flag==2){
|
|
|
dictUserDO.setIsRead(status);
|
|
|
}else if (flag!=null&&flag==3){
|
|
|
dictUserDO.setFabulous(status);
|
|
|
}else if (flag!=null&&flag==4){
|
|
|
dictUserDO.setShare(status);
|
|
|
}
|
|
|
baseMenuDictUserDao.save(dictUserDO);
|
|
|
|
|
|
return dictDO;
|
|
|
}
|
|
|
|
|
|
//删除菜单字典
|
|
|
public void deletMenuDict(String id) throws Exception{
|
|
|
BaseMenuDictDO baseMenuDictDO= baseMenuDictDao.findOne(id);
|
|
|
if (baseMenuDictDO!=null){
|
|
|
if ("0".equalsIgnoreCase(baseMenuDictDO.getParentId())){
|
|
|
List<BaseMenuDictDO> childList = baseMenuDictDao.findByParentId(baseMenuDictDO.getId());
|
|
|
if (childList!=null&&childList.size()>0){
|
|
|
throw new Exception("存在子菜单不允许删除");
|
|
|
}else {
|
|
|
baseMenuDictDO.setIsDel("0");
|
|
|
}
|
|
|
}else {
|
|
|
if (1==baseMenuDictDO.getStatus()){
|
|
|
throw new Exception("生效的子菜单不允许删除");
|
|
|
}else{
|
|
|
baseMenuDictDO.setIsDel("0");
|
|
|
}
|
|
|
}
|
|
|
baseMenuDictDao.save(baseMenuDictDO);
|
|
|
}
|
|
|
}
|
|
|
//菜单词典查询
|
|
|
public List<Map<String,Object>> findMenuDictByKey(String parentId, String name,Integer status,Integer type){
|
|
|
String sql = "select t.id as \"id\", " +
|
|
|
" t.parent_id as \"parentId\", " +
|
|
|
" t.name as \"name\", " +
|
|
|
" t.menu_sort as \"menuSort\", " +
|
|
|
" t.icon as \"icon\", " +
|
|
|
" t.url as \"url\", " +
|
|
|
" t.is_show as \"isShow\", " +
|
|
|
" t.status as \"status\", " +
|
|
|
" t.create_time as \"createTime\", " +
|
|
|
" t.remark as \"remark\", " +
|
|
|
" t.function_type as \"functionType\", " +
|
|
|
" t.menu_level as \"menuLevel\", " +
|
|
|
" t.menu_location as \"menuLocation\", " +
|
|
|
" t.bg_img as \"bgImg\", " +
|
|
|
" t.menu_title as \"menuTitle\", " +
|
|
|
" t.describtion as \"describtion\", " +
|
|
|
" t.menu_img as \"menuImg\" " +
|
|
|
"from base_menu_dict t where 1=1 and t.is_del ='1' and t.type="+type;
|
|
|
String sqlParent ="select t.id as \"id\", " +
|
|
|
" t.parent_id as \"parentId\", " +
|
|
|
" t.name as \"name\", " +
|
|
|
" t.menu_sort as \"menuSort\", " +
|
|
|
" t.icon as \"icon\", " +
|
|
|
" t.url as \"url\", " +
|
|
|
" t.is_show as \"isShow\", " +
|
|
|
" t.status as \"status\", " +
|
|
|
" t.create_time as \"createTime\", " +
|
|
|
" t.remark as \"remark\", " +
|
|
|
" t.function_type as \"functionType\", " +
|
|
|
" t.menu_level as \"menuLevel\", " +
|
|
|
" t.bg_img as \"bgImg\", " +
|
|
|
" t.menu_title as \"menuTitle\", " +
|
|
|
" t.describtion as \"describtion\", " +
|
|
|
" t.menu_location as \"menuLocation\", " +
|
|
|
" t.menu_img as \"menuImg\" " +
|
|
|
"from base_menu_dict t where 1=1 and t.is_del ='1' and t.type="+type;
|
|
|
if (StringUtils.isNoneBlank(parentId)){
|
|
|
sql+=" and t.parent_id = '"+parentId+"'";
|
|
|
sqlParent+=" and t.id = '"+parentId+"'";
|
|
|
}else {
|
|
|
sqlParent+=" and t.parent_id = '0'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)){
|
|
|
sql+=" and t.name like '%"+name+"%'";
|
|
|
sqlParent+=" and t.name like '%"+name+"%'";
|
|
|
}
|
|
|
if (status!=null){
|
|
|
sql += " and t.status = '"+status+"' ";
|
|
|
sqlParent+=" and t.status = '"+status+"' " ;
|
|
|
}
|
|
|
|
|
|
sql+=" order by t.parent_id asc ,t.menu_sort asc ";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
List<Map<String,Object>> listParent = hibenateUtils.createSQLQuery(sqlParent);
|
|
|
List<WlyyHospitalSysDictDO> menuLocation = wlyyHospitalSysDictDao.findByDictName("menuLocation");
|
|
|
List<WlyyHospitalSysDictDO> menuFunction = wlyyHospitalSysDictDao.findByDictName("menuFunction");
|
|
|
List<WlyyHospitalSysDictDO> effect = wlyyHospitalSysDictDao.findByDictName("isEffect");
|
|
|
List<WlyyHospitalSysDictDO> releaseType = wlyyHospitalSysDictDao.findByDictName("releaseType");
|
|
|
for (Map<String,Object> map:listParent){
|
|
|
List<Map<String,Object>> childList = new ArrayList<>();
|
|
|
Integer articleParentNum= knowledgeArticleDictDao.getCountByCategoryFirst(map.get("id").toString());
|
|
|
map.put("articleNum",articleParentNum);
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:effect){
|
|
|
if (map.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
map.put("statusName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
map.put("isShow",map.get("status").toString().equalsIgnoreCase("1")?"是":"否");
|
|
|
}
|
|
|
}
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:menuLocation){
|
|
|
if (map.get("menuLocation").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
map.put("menuLocationName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
for (Map<String,Object> mapchild:list){
|
|
|
if (mapchild.get("parentId").toString().equalsIgnoreCase(map.get("id").toString())){
|
|
|
List<String> list1 = new ArrayList<>();
|
|
|
list1.add(mapchild.get("id").toString());
|
|
|
Integer articleChildNum= knowledgeArticleDictDao.getCountByCategorySecond(list1);
|
|
|
mapchild.put("articleNum",articleChildNum);
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:effect){
|
|
|
if (mapchild.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
mapchild.put("statusName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
mapchild.put("isShow",mapchild.get("status").toString().equalsIgnoreCase("1")?"是":"否");
|
|
|
}
|
|
|
}
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:menuFunction){
|
|
|
if (mapchild.get("functionType").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
mapchild.put("functionTypeName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
childList.add(mapchild);
|
|
|
}
|
|
|
}
|
|
|
map.put("childList",childList);
|
|
|
}
|
|
|
|
|
|
return listParent;
|
|
|
}
|
|
|
//查询单挑菜单字典
|
|
|
public BaseMenuDictDO findOneMenuDict(String id,String patient){
|
|
|
BaseMenuDictDO baseMenuDictDO= baseMenuDictDao.findOne(id);
|
|
|
if (baseMenuDictDO!=null){
|
|
|
WlyyHospitalSysDictDO effect = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("isEffect",baseMenuDictDO.getStatus().toString());
|
|
|
baseMenuDictDO.setShowName(baseMenuDictDO.getStatus().equals("1")?"是":"否");
|
|
|
baseMenuDictDO.setStatusName(effect.getDictValue());
|
|
|
if (!"0".equalsIgnoreCase(baseMenuDictDO.getParentId())){
|
|
|
BaseMenuDictDO parentDo= baseMenuDictDao.findOne(baseMenuDictDO.getParentId());;
|
|
|
if (parentDo!=null){
|
|
|
baseMenuDictDO.setParentName(parentDo.getName());
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(baseMenuDictDO.getFunctionType())){
|
|
|
WlyyHospitalSysDictDO menuFunction = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("menuFunction",baseMenuDictDO.getFunctionType());
|
|
|
if(menuFunction!=null){
|
|
|
baseMenuDictDO.setFunctionName(menuFunction.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
WlyyHospitalSysDictDO menuLocation = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("menuLocation",baseMenuDictDO.getMenuLocation());
|
|
|
if (menuLocation==null||menuLocation.getDictValue() == null){
|
|
|
baseMenuDictDO.setLocaTionName("无");
|
|
|
}else {
|
|
|
baseMenuDictDO.setLocaTionName(menuLocation.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return baseMenuDictDO;
|
|
|
}
|
|
|
/**
|
|
|
* 二级菜单下移
|
|
|
* @param
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public BaseMenuDictDO downMenu(String id) throws Exception{
|
|
|
BaseMenuDictDO baseMenuDictDO= baseMenuDictDao.findOne(id);
|
|
|
int maxSort = baseMenuDictDao.getMaxSort(baseMenuDictDO.getParentId());
|
|
|
int sort = 0;
|
|
|
if(null!=baseMenuDictDO){
|
|
|
sort = baseMenuDictDO.getMenuSort();
|
|
|
}
|
|
|
if (maxSort==sort){
|
|
|
throw new Exception("不能下移");
|
|
|
}
|
|
|
String sql = "select t.id AS \"id\" from base_menu_dict t where t.is_del='1' and t.menu_sort > "+sort+" and " +
|
|
|
" t.parent_id='"+baseMenuDictDO.getParentId()+"' order by t.menu_sort asc ";
|
|
|
System.out.println(sql);
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,1,1);
|
|
|
BaseMenuDictDO upPrevious = new BaseMenuDictDO();
|
|
|
if (list.size()>0){
|
|
|
String prviousBannerId = list.get(0).get("id").toString();
|
|
|
upPrevious =baseMenuDictDao.findOne(prviousBannerId);;
|
|
|
}
|
|
|
|
|
|
//交换sort值
|
|
|
baseMenuDictDO.setMenuSort(upPrevious.getMenuSort());
|
|
|
upPrevious.setMenuSort(sort);
|
|
|
baseMenuDictDao.save(baseMenuDictDO);
|
|
|
baseMenuDictDao.save(upPrevious);
|
|
|
return baseMenuDictDO;
|
|
|
}
|
|
|
/**
|
|
|
* 二级菜单上移
|
|
|
* * @param
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public BaseMenuDictDO upMenu(String id) throws Exception{
|
|
|
//当前
|
|
|
BaseMenuDictDO baseMenuDictDO = baseMenuDictDao.findOne(id);
|
|
|
int minSort = baseMenuDictDao.getMinSort(baseMenuDictDO.getParentId());
|
|
|
int sort = 0;
|
|
|
if(null!=baseMenuDictDO){
|
|
|
sort = baseMenuDictDO.getMenuSort();
|
|
|
}
|
|
|
if (minSort==sort){
|
|
|
throw new Exception("不能上移");
|
|
|
}
|
|
|
String sql = " select id AS \"id\" from base_menu_dict where is_del='1' and menu_sort < "+sort+" and" +
|
|
|
" parent_id='"+baseMenuDictDO.getParentId()+"'order by menu_sort desc ";
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,1,1);
|
|
|
BaseMenuDictDO downPrevious = new BaseMenuDictDO();
|
|
|
if (list.size()>0){
|
|
|
String prviousBannerId = list.get(0).get("id").toString();
|
|
|
downPrevious =baseMenuDictDao.findOne(prviousBannerId);;
|
|
|
}
|
|
|
//获取的下一条b
|
|
|
//交换sort值
|
|
|
baseMenuDictDO.setMenuSort(downPrevious.getMenuSort());
|
|
|
downPrevious.setMenuSort(sort);
|
|
|
baseMenuDictDao.save(baseMenuDictDO);
|
|
|
baseMenuDictDao.save(downPrevious);
|
|
|
return baseMenuDictDO;
|
|
|
}
|
|
|
/**
|
|
|
* 设置生效和失效
|
|
|
* @param id
|
|
|
* @param status
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateStatus(String id,Integer status){
|
|
|
BaseMenuDictDO menuDictDO = baseMenuDictDao.findByIdAndDel(id);
|
|
|
if (menuDictDO.getParentId().equalsIgnoreCase("0")){
|
|
|
List<BaseMenuDictDO> baseMenuDictDOS = baseMenuDictDao.findByParentId(id);
|
|
|
for (BaseMenuDictDO menuDictDO1:baseMenuDictDOS){
|
|
|
baseMenuDictDao.updateStatus(menuDictDO1.getId(),status);
|
|
|
}
|
|
|
}
|
|
|
baseMenuDictDao.updateStatus(id,status);
|
|
|
}
|
|
|
//新增修改菜单
|
|
|
public BaseMenuDictDO createOrUpdateMenu(String json,Integer type) throws Exception{
|
|
|
BaseMenuDictDO menuDO = objectMapper.readValue(json,BaseMenuDictDO.class);
|
|
|
if (StringUtils.isNoneBlank(menuDO.getId())){
|
|
|
BaseMenuDictDO menuOld = baseMenuDictDao.findOne(menuDO.getId());;
|
|
|
if (menuOld!=null){
|
|
|
menuOld.setParentId(menuDO.getParentId());
|
|
|
menuOld.setName(menuDO.getName());
|
|
|
menuOld.setMenuLocation(menuDO.getMenuLocation());
|
|
|
menuOld.setFunctionType(menuDO.getFunctionType());
|
|
|
menuOld.setType(type);
|
|
|
//menuOld.setIsShow(menuDO.getIsShow());
|
|
|
menuOld.setMenuImg(menuDO.getMenuImg());
|
|
|
menuOld.setDescribtion(menuDO.getDescribtion());
|
|
|
menuOld.setMenuTitle(menuDO.getMenuTitle());
|
|
|
menuOld.setBgImg(menuDO.getBgImg());
|
|
|
menuOld.setUpdateTime(new Date());
|
|
|
menuOld.setIsDel("1");
|
|
|
menuDO = baseMenuDictDao.save(menuOld);
|
|
|
}
|
|
|
}else {
|
|
|
if (!"0".equalsIgnoreCase(menuDO.getParentId())){
|
|
|
Integer maxSort=baseMenuDictDao.getMaxSort(menuDO.getParentId());
|
|
|
menuDO.setMenuSort((maxSort==null?0:maxSort)+1);
|
|
|
menuDO.setIsDel("1");
|
|
|
menuDO.setIsShow(menuDO.getStatus()==1?"1":"0");
|
|
|
}else{
|
|
|
menuDO.setIsDel("1");
|
|
|
menuDO.setIsShow(menuDO.getStatus()==1?"1":"0");
|
|
|
menuDO.setMenuSort(1);
|
|
|
}
|
|
|
menuDO.setType(type);
|
|
|
menuDO = baseMenuDictDao.save(menuDO);
|
|
|
}
|
|
|
return menuDO;
|
|
|
}
|
|
|
//新增修改友情链接
|
|
|
public BaseLinkDictDO createOrUpdateLink(String json) throws Exception{
|
|
|
BaseLinkDictDO linkDictDO = objectMapper.readValue(json,BaseLinkDictDO.class);
|
|
|
Integer maxSort=baseLinkDictDao.getMaxSort();
|
|
|
if (StringUtils.isNoneBlank(linkDictDO.getId())){
|
|
|
BaseLinkDictDO baseLinkDictDO=baseLinkDictDao.findOne(linkDictDO.getId());
|
|
|
if (baseLinkDictDO!=null){
|
|
|
baseLinkDictDO.setName(linkDictDO.getName());
|
|
|
baseLinkDictDO.setLinkUrl(linkDictDO.getLinkUrl());
|
|
|
//baseLinkDictDO.setLinkSort((maxSort==null?0:maxSort)+1);
|
|
|
baseLinkDictDO.setIsShow(linkDictDO.getIsShow());
|
|
|
baseLinkDictDO.setStatus(linkDictDO.getStatus());
|
|
|
baseLinkDictDO.setIsDel("1");
|
|
|
linkDictDO = baseLinkDictDao.save(baseLinkDictDO);
|
|
|
}else {
|
|
|
throw new NoSuchElementException();
|
|
|
}
|
|
|
}else {
|
|
|
linkDictDO.setLinkSort((maxSort==null?0:maxSort)+1);
|
|
|
linkDictDO.setIsDel("1");
|
|
|
linkDictDO = baseLinkDictDao.save(linkDictDO);
|
|
|
}
|
|
|
return linkDictDO;
|
|
|
}
|
|
|
public List<Map<String,Object>> findLinkDict(String name,String status){
|
|
|
String sql="select t.id as \"id\"," +
|
|
|
" t.name as \"name\"," +
|
|
|
" t.link_url as \"linkUrl\"," +
|
|
|
" t.is_show as \"isShow\"," +
|
|
|
" t.status as \"status\"," +
|
|
|
" t.link_sort as \"linkSort\"," +
|
|
|
" t.create_time as \"createTime\"," +
|
|
|
" t.is_del as \"isDel\" " +
|
|
|
" from base_link_dict t where 1=1 and t.is_del='1'";
|
|
|
if (StringUtils.isNoneBlank(name)){
|
|
|
sql+=" and t.name like '%"+name+"%'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)){
|
|
|
sql+=" and t.status = '"+status+"'";
|
|
|
}
|
|
|
sql+=" order by t.link_sort asc";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
List<WlyyHospitalSysDictDO> effect = wlyyHospitalSysDictDao.findByDictName("isEffect");
|
|
|
for (Map<String,Object> map:list){
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:effect){
|
|
|
if (map.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
map.put("statusName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
map.put("isShow",map.get("status").toString().equalsIgnoreCase("1")?"是":"否");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
public BaseLinkDictDO findOneLinkDict(String id){
|
|
|
BaseLinkDictDO baseLinkDictDO= baseLinkDictDao.findOne(id);
|
|
|
if (baseLinkDictDO!=null){
|
|
|
WlyyHospitalSysDictDO effect = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("isEffect",baseLinkDictDO.getStatus());
|
|
|
baseLinkDictDO.setShowName(baseLinkDictDO.getStatus().equalsIgnoreCase("1")?"是":"否");
|
|
|
baseLinkDictDO.setStatusName(effect.getDictValue());
|
|
|
}
|
|
|
return baseLinkDictDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 友情链接下移
|
|
|
* @param
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public BaseLinkDictDO downlink(String id) throws Exception{
|
|
|
BaseLinkDictDO baseLinkDictDO= baseLinkDictDao.findOne(id);
|
|
|
int maxSort = baseLinkDictDao.getMaxSort();
|
|
|
int sort = 0;
|
|
|
if(null!=baseLinkDictDO){
|
|
|
sort = baseLinkDictDO.getLinkSort();
|
|
|
}
|
|
|
if (maxSort==sort){
|
|
|
throw new Exception("不能下移");
|
|
|
}
|
|
|
String sql = "select t.id AS \"id\" from base_link_dict t where t.is_del='1' and t.link_sort > "+sort+" order by t.link_sort asc ";
|
|
|
System.out.println(sql);
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,1,1);
|
|
|
BaseLinkDictDO upPrevious = new BaseLinkDictDO();
|
|
|
if (list.size()>0){
|
|
|
String prviousBannerId = list.get(0).get("id").toString();
|
|
|
upPrevious =baseLinkDictDao.findOne(prviousBannerId);;
|
|
|
}
|
|
|
|
|
|
//交换sort值
|
|
|
baseLinkDictDO.setLinkSort(upPrevious.getLinkSort());
|
|
|
upPrevious.setLinkSort(sort);
|
|
|
baseLinkDictDao.save(baseLinkDictDO);
|
|
|
baseLinkDictDao.save(upPrevious);
|
|
|
return baseLinkDictDO;
|
|
|
}
|
|
|
/**
|
|
|
* 友情链接上移
|
|
|
* * @param
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public BaseLinkDictDO upLink(String id) throws Exception{
|
|
|
//当前
|
|
|
BaseLinkDictDO baseLinkDictDO = baseLinkDictDao.findOne(id);
|
|
|
int minSort = baseLinkDictDao.getMinSort();
|
|
|
int sort = 0;
|
|
|
if(null!=baseLinkDictDO){
|
|
|
sort = baseLinkDictDO.getLinkSort();
|
|
|
}
|
|
|
if (minSort==sort){
|
|
|
throw new Exception("不能上移");
|
|
|
}
|
|
|
String sql = " select id AS \"id\" from base_link_dict where is_del='1' and link_sort < "+sort+" order by link_sort desc ";
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,1,1);
|
|
|
BaseLinkDictDO downPrevious = new BaseLinkDictDO();
|
|
|
if (list.size()>0){
|
|
|
String prviousBannerId = list.get(0).get("id").toString();
|
|
|
downPrevious =baseLinkDictDao.findOne(prviousBannerId);;
|
|
|
}
|
|
|
//获取的下一条b
|
|
|
//交换sort值
|
|
|
baseLinkDictDO.setLinkSort(downPrevious.getLinkSort());
|
|
|
downPrevious.setLinkSort(sort);
|
|
|
baseLinkDictDao.save(baseLinkDictDO);
|
|
|
baseLinkDictDao.save(downPrevious);
|
|
|
return baseLinkDictDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置生效和失效
|
|
|
* @param id
|
|
|
* @param status
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateLinkStatus(String id,String status){
|
|
|
baseLinkDictDao.updateStatus(id,status);
|
|
|
}
|
|
|
/**
|
|
|
* 设置生效和失效
|
|
|
* @param id
|
|
|
* @param status
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateLinkShow(String id,String status){
|
|
|
baseLinkDictDao.updateShow(id,status);
|
|
|
}
|
|
|
/**
|
|
|
* 友情链接删除
|
|
|
* @param id
|
|
|
*
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateLinkDel(String id){
|
|
|
baseLinkDictDao.updateDel(id,"0");
|
|
|
}
|
|
|
/**
|
|
|
* 移除首页菜单
|
|
|
* @param menuId
|
|
|
*
|
|
|
*/
|
|
|
public BaseMenuShowDO removeMenu(String menuId){
|
|
|
BaseMenuShowDO baseMenuShowDO = baseMenuShowDao.findOne(menuId);
|
|
|
baseMenuShowDO.setIsDel("0");
|
|
|
baseMenuShowDao.save(baseMenuShowDO);
|
|
|
return baseMenuShowDO;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<Map<String,Object>> findMenuShow(){
|
|
|
String modelSql = "select t.id as \"id\"," +
|
|
|
" t.model_id as \"modelId\", " +
|
|
|
" t.model_name as \"modelName\" from base_menu_show t where t.is_del ='1'" +
|
|
|
" group by t.model_id, t.model_name" ;
|
|
|
List<Map<String,Object>> listModel=hibenateUtils.createSQLQuery(modelSql);
|
|
|
String sql =" select t.id as \"id\", " +
|
|
|
" t.model_id as \"modelId\", " +
|
|
|
" t.model_name as \"modelName\", " +
|
|
|
" t.menu_id as \"menuId\", " +
|
|
|
" m.name as \"menuName\", " +
|
|
|
" t.is_del as \"isDel\"," +
|
|
|
" m.status as \"status\"," +
|
|
|
" t.create_time as \"createTime\"," +
|
|
|
" t.menu_sort as \"menuSort\"," +
|
|
|
" t.style_code as \"styleCode\"," +
|
|
|
" m.bg_img as \"bgImg\"," +
|
|
|
" m.menu_title as \"menuTitle\"," +
|
|
|
" m.describtion as \"describtion\"," +
|
|
|
" t.style_name as \"styleName\", " +
|
|
|
" m.parent_id as \"parentId\" " +
|
|
|
" from base_menu_show t left join " +
|
|
|
" base_menu_dict m on t.menu_id= m.id" +
|
|
|
" where t.is_del ='1' order by t.model_id asc ,t.menu_sort asc ";
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql);
|
|
|
for (Map<String,Object> map:list){
|
|
|
if (map.get("parentId")!=null){
|
|
|
String parentId = map.get("parentId").toString();
|
|
|
BaseMenuDictDO parentDo= baseMenuDictDao.findOne(parentId);
|
|
|
if (parentDo!=null){
|
|
|
map.put("parentName",parentDo.getName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String sqlLink =" select t.id as \"id\", " +
|
|
|
" t.model_id as \"modelId\", " +
|
|
|
" t.model_name as \"modelName\", " +
|
|
|
" t.menu_id as \"menuId\", " +
|
|
|
" m.name as \"menuName\", " +
|
|
|
" t.is_del as \"isDel\"," +
|
|
|
" t.create_time as \"createTime\"," +
|
|
|
" t.menu_sort as \"menuSort\"," +
|
|
|
" m.link_url as \"linkUrl\"," +
|
|
|
" t.style_code as \"styleCode\"," +
|
|
|
" m.status as \"status\"," +
|
|
|
" t.style_name as \"styleName\" " +
|
|
|
" from base_menu_show t left join " +
|
|
|
" base_link_dict m on t.menu_id= m.id" +
|
|
|
" where t.is_del ='1' and t.model_id='03' order by t.menu_sort asc ";
|
|
|
List<Map<String,Object>> listLink=hibenateUtils.createSQLQuery(sqlLink);
|
|
|
for (Map<String,Object> map:listModel){
|
|
|
List<Map<String,Object>> child = new ArrayList<>();
|
|
|
if("03".equalsIgnoreCase(map.get("modelId").toString())){
|
|
|
map.put("childList",listLink);
|
|
|
map.put("childListNum",listLink==null?0:listLink.size());
|
|
|
}else {
|
|
|
for (Map<String,Object> childMap:list){
|
|
|
if (childMap.get("modelId").toString().equalsIgnoreCase(map.get("modelId").toString())){
|
|
|
child.add(childMap);
|
|
|
}
|
|
|
}
|
|
|
map.put("childList",child);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return listModel;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 首页菜单展示下移
|
|
|
* @param
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public BaseMenuShowDO downMenuShow(String id) throws Exception{
|
|
|
BaseMenuShowDO baseMenuShowDO= baseMenuShowDao.findOne(id);
|
|
|
int maxSort = baseMenuShowDao.getMaxSort(baseMenuShowDO.getModelId());
|
|
|
int sort = 0;
|
|
|
if(null!=baseMenuShowDO){
|
|
|
sort = baseMenuShowDO.getMenuSort();
|
|
|
}
|
|
|
if (maxSort==sort){
|
|
|
throw new Exception("不能下移");
|
|
|
}
|
|
|
String sql = "select t.id AS \"id\" from base_menu_show t where t.is_del='1' and t.menu_sort > "+sort+" " +
|
|
|
" and t.model_id='"+baseMenuShowDO.getModelId()+"'order by t.menu_sort asc ";
|
|
|
System.out.println(sql);
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,1,1);
|
|
|
BaseMenuShowDO upPrevious = new BaseMenuShowDO();
|
|
|
if (list.size()>0){
|
|
|
String prviousBannerId = list.get(0).get("id").toString();
|
|
|
upPrevious =baseMenuShowDao.findOne(prviousBannerId);
|
|
|
}
|
|
|
|
|
|
//交换sort值
|
|
|
baseMenuShowDO.setMenuSort(upPrevious.getMenuSort());
|
|
|
upPrevious.setMenuSort(sort);
|
|
|
baseMenuShowDao.save(baseMenuShowDO);
|
|
|
baseMenuShowDao.save(upPrevious);
|
|
|
return baseMenuShowDO;
|
|
|
}
|
|
|
/**
|
|
|
* 首页菜单展示上移
|
|
|
* * @param
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public BaseMenuShowDO upMenuShow(String id) throws Exception{
|
|
|
//当前
|
|
|
BaseMenuShowDO baseMenuShowDO = baseMenuShowDao.findOne(id);
|
|
|
int minSort = baseMenuShowDao.getMinSort(baseMenuShowDO.getModelId());
|
|
|
int sort = 0;
|
|
|
if(null!=baseMenuShowDO){
|
|
|
sort = baseMenuShowDO.getMenuSort();
|
|
|
}
|
|
|
if (minSort==sort){
|
|
|
throw new Exception("不能上移");
|
|
|
}
|
|
|
String sql = " select id AS \"id\" from base_menu_show where is_del='1' and menu_sort < "+sort+" " +
|
|
|
" and model_id ='"+baseMenuShowDO.getModelId()+"'order by menu_sort desc ";
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,1,1);
|
|
|
BaseMenuShowDO downPrevious = new BaseMenuShowDO();
|
|
|
if (list.size()>0){
|
|
|
String prviousBannerId = list.get(0).get("id").toString();
|
|
|
downPrevious =baseMenuShowDao.findOne(prviousBannerId);
|
|
|
}
|
|
|
//获取的下一条b
|
|
|
//交换sort值
|
|
|
baseMenuShowDO.setMenuSort(downPrevious.getMenuSort());
|
|
|
downPrevious.setMenuSort(sort);
|
|
|
baseMenuShowDao.save(baseMenuShowDO);
|
|
|
baseMenuShowDao.save(downPrevious);
|
|
|
return baseMenuShowDO;
|
|
|
}
|
|
|
public void saveMenuShow(String json) throws Exception{
|
|
|
List<BaseMenuShowDO> menuShowDO = JSON.parseArray(json,BaseMenuShowDO.class);
|
|
|
List<WlyyHospitalSysDictDO> list = wlyyHospitalSysDictDao.findByDictName("menuStyle");
|
|
|
int i =1;
|
|
|
for (BaseMenuShowDO baseMenuShowDO:menuShowDO){
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
|
|
|
if (StringUtils.isNoneBlank(baseMenuShowDO.getStyleCode())){
|
|
|
if (baseMenuShowDO.getStyleCode().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
baseMenuShowDO.setStyleName(wlyyHospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String modelSql = "select t.id as \"id\"," +
|
|
|
" t.model_id as \"modelId\", max(t.menu_sort) as \"maxSort\"" +
|
|
|
" from base_menu_show t where t.is_del ='1'" +"and t.model_id='"+baseMenuShowDO.getModelId()+"'"+
|
|
|
" group by t.model_id " ;
|
|
|
List<Map<String,Object>> listModel=hibenateUtils.createSQLQuery(modelSql);
|
|
|
if (listModel!=null&&listModel.size()>0){
|
|
|
baseMenuShowDO.setMenuSort((listModel.get(0).get("maxSort")==null?0:Integer.valueOf(listModel.get(0).get("maxSort").toString()))+i);
|
|
|
}else {
|
|
|
baseMenuShowDO.setMenuSort(1);
|
|
|
}
|
|
|
baseMenuShowDO.setIsDel("1");
|
|
|
baseMenuShowDO.setCreateTime(new Date());
|
|
|
i++;
|
|
|
}
|
|
|
baseMenuShowDao.save(menuShowDO);
|
|
|
}
|
|
|
public List<Map<String,Object>> findByParentId(String parentId,Integer status){
|
|
|
String sql = "select t.id as \"id\", " +
|
|
|
" t.parent_id as \"parentId\", " +
|
|
|
" t.name as \"name\", " +
|
|
|
" t.menu_sort as \"menuSort\", " +
|
|
|
" t.icon as \"icon\", " +
|
|
|
" t.url as \"url\", " +
|
|
|
" t.is_show as \"isShow\", " +
|
|
|
" t.status as \"status\", " +
|
|
|
" t.create_time as \"createTime\", " +
|
|
|
" t.remark as \"remark\", " +
|
|
|
" t.function_type as \"functionType\", " +
|
|
|
" t.menu_level as \"menuLevel\", " +
|
|
|
" t.menu_location as \"menuLocation\", " +
|
|
|
" t.bg_img as \"bgImg\", " +
|
|
|
" t.menu_title as \"menuTitle\", " +
|
|
|
" t.describtion as \"describtion\", " +
|
|
|
" t.menu_img as \"menuImg\" " +
|
|
|
"from base_menu_dict t where 1=1 and t.is_del ='1' ";
|
|
|
if (StringUtils.isNoneBlank(parentId)){
|
|
|
sql+=" and t.parent_id='"+parentId+"' ";
|
|
|
}
|
|
|
if (status!=null){
|
|
|
sql+=" and t.status="+status+"";
|
|
|
}
|
|
|
sql+=" order by t.menu_sort asc";
|
|
|
System.out.print("sql"+sql);
|
|
|
List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public MixEnvelop findArticleByMenuId(String menuId,String title,Integer page,Integer pageSize,String isContent){
|
|
|
Pageable pageRequest = new PageRequest(page-1,pageSize);
|
|
|
List<String> menuIds = new ArrayList<>();
|
|
|
if (StringUtils.isNoneBlank(menuId)){
|
|
|
String str[]= menuId.split(",");
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
menuIds.add(str[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
System.out.print("menuId"+menuId);
|
|
|
Integer count;
|
|
|
List<KnowledgeArticleDictDO> list;
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
count = knowledgeArticleDictDao.getCountByCategorySecond(menuIds,title);
|
|
|
list=knowledgeArticleDictDao.findByCategorySecondAndPage(menuIds,title,pageRequest);
|
|
|
}else {
|
|
|
count = knowledgeArticleDictDao.getCountByCategorySecond(menuIds);
|
|
|
list=knowledgeArticleDictDao.findByCategorySecondAndPage(menuIds,pageRequest);
|
|
|
}
|
|
|
List<KnowledgeArticleDictDO> listnew = new ArrayList<>();
|
|
|
BeanUtils.copyProperties(listnew,list);
|
|
|
if(!"1".equals(isContent)){
|
|
|
for (KnowledgeArticleDictDO dictDO:list){
|
|
|
dictDO.setContent(null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
MixEnvelop mixEnvelop = new MixEnvelop();
|
|
|
mixEnvelop.setTotalCount(count);
|
|
|
mixEnvelop.setDetailModelList(list);
|
|
|
mixEnvelop.setPageSize(pageSize);
|
|
|
mixEnvelop.setCurrPage(page);
|
|
|
return mixEnvelop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//菜单词典查询
|
|
|
public List<Map<String,Object>> findMenuDictParent(String parentId, String name){
|
|
|
String sqlParent ="select t.id as \"id\", " +
|
|
|
" t.parent_id as \"parentId\", " +
|
|
|
" t.name as \"name\", " +
|
|
|
" t.menu_sort as \"menuSort\", " +
|
|
|
" t.icon as \"icon\", " +
|
|
|
" t.url as \"url\", " +
|
|
|
" t.is_show as \"isShow\", " +
|
|
|
" t.status as \"status\", " +
|
|
|
" t.create_time as \"createTime\", " +
|
|
|
" t.remark as \"remark\", " +
|
|
|
" t.function_type as \"functionType\", " +
|
|
|
" t.menu_level as \"menuLevel\", " +
|
|
|
" t.menu_location as \"menuLocation\", " +
|
|
|
" t.bg_img as \"bgImg\", " +
|
|
|
" t.menu_title as \"menuTitle\", " +
|
|
|
" t.describtion as \"describtion\", " +
|
|
|
" t.menu_img as \"menuImg\" " +
|
|
|
"from base_menu_dict t where 1=1 and t.is_del ='1' and t.status =1";
|
|
|
if (StringUtils.isNoneBlank(parentId)){
|
|
|
sqlParent+=" and t.id = '"+parentId+"'";
|
|
|
}else {
|
|
|
sqlParent+=" and t.parent_id = '0'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)){
|
|
|
sqlParent+=" and t.name like '%"+name+"%'";
|
|
|
}
|
|
|
List<Map<String,Object>> listParent = hibenateUtils.createSQLQuery(sqlParent);
|
|
|
List<WlyyHospitalSysDictDO> menuLocation = wlyyHospitalSysDictDao.findByDictName("menuLocation");
|
|
|
List<WlyyHospitalSysDictDO> effect = wlyyHospitalSysDictDao.findByDictName("isEffect");
|
|
|
for (Map<String,Object> map:listParent){
|
|
|
Integer articleParentNum= knowledgeArticleDictDao.getCountByCategoryFirst(map.get("id").toString());
|
|
|
map.put("articleNum",articleParentNum);
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:effect){
|
|
|
if (map.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
map.put("statusName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
map.put("isShow",map.get("status").toString().equalsIgnoreCase("1")?"是":"否");
|
|
|
}
|
|
|
}
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:menuLocation){
|
|
|
if (map.get("menuLocation").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
map.put("menuLocationName",wlyyHospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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) AND kad.category_first IN(SELECT md.parent_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) AND kad.category_first IN(SELECT md.parent_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+"' AND kad.category_second IN(SELECT md.id from base_menu_dict md where md.status=1 and md.is_del= 1) AND kad.category_first IN(SELECT md.parent_id from base_menu_dict md where md.status=1 and md.is_del= 1) ";
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增医生文章/医生操作(评论、点赞、收藏)
|
|
|
*
|
|
|
* @param articleDoctorDO
|
|
|
* @return
|
|
|
*/
|
|
|
public KnowledgeArticleDoctorDO insert(KnowledgeArticleDoctorDO articleDoctorDO){
|
|
|
articleDoctorDO.setCreateTime(new Date());
|
|
|
articleDoctorDO.setUpdateTime(new Date());
|
|
|
return knowledgeArticleDoctorDao.save(articleDoctorDO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消点赞和收藏
|
|
|
*/
|
|
|
public void deleteArticleDoctorById(String baseArticleDoctorId,String relationCode,Integer type,String user){
|
|
|
if (StringUtils.isNoneBlank(baseArticleDoctorId)){
|
|
|
knowledgeArticleDoctorDao.deletByBaseArticleDoctorIdAndType(baseArticleDoctorId,user,type);
|
|
|
}else {
|
|
|
knowledgeArticleDoctorDao.deletByRelationCodeAndType(relationCode,user,type);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询医生关联文章回复数据
|
|
|
* @param id
|
|
|
* @param type 1
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop selectArticleDoctorById(String user,String id,Integer type,Integer page,Integer size){
|
|
|
String orderBy = " order by create_time desc ";
|
|
|
String condition = " ";
|
|
|
String sql = "SELECT\n" +
|
|
|
"\tid,\n" +
|
|
|
"\tbase_article_doctor_id baseArticleDoctorId,\n" +
|
|
|
"\trelation_code AS relationCode,\n" +
|
|
|
"\trelation_type AS relationType,\n" +
|
|
|
"\tuser,\n" +
|
|
|
"\tuser_name AS userName,\n" +
|
|
|
"\ttype,\n" +
|
|
|
"\tdate_format(\n" +
|
|
|
"\t\tcreate_time,\n" +
|
|
|
"\t\t'%Y-%m-%d %H:%i:%S'\n" +
|
|
|
"\t) AS createTime,\n" +
|
|
|
"\tcontent\n" +
|
|
|
"FROM\n" +
|
|
|
"\tbase_knowledge_article_doctor\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tbase_article_doctor_id IS NULL ";
|
|
|
if (StringUtils.isNoneBlank(id)){
|
|
|
condition +=" and relation_code = '"+id+"' ";
|
|
|
}
|
|
|
if (type!=null){
|
|
|
condition +=" and type ="+type+" ";
|
|
|
}
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql+condition+orderBy, page, size);
|
|
|
for (Map<String,Object> map:list){
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(map.get("user").toString());
|
|
|
map.put("doctor",doctorDO);
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOS = knowledgeArticleDoctorDao.findByBaseArticleDoctorIdAndType(map.get("id").toString(),1);//获取评论列表
|
|
|
map.put("replyList",knowledgeArticleDoctorDOS);//获取评论列表
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOList = knowledgeArticleDoctorDao.findByBaseArticleDoctorIdAndType(map.get("id").toString(),2);//获取评论的点赞
|
|
|
map.put("replyApoint",knowledgeArticleDoctorDOList.size());//获取评论的点赞
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOList1 = knowledgeArticleDoctorDao.findByBaseArticleDoctorIdAndRelationCodeAndTypeAndUser(map.get("relationCode").toString(),2,user,map.get("id").toString());
|
|
|
if (knowledgeArticleDoctorDOList1!=null&&knowledgeArticleDoctorDOList1.size()>0) {
|
|
|
map.put("appointFlag", 1);//1已点赞
|
|
|
}else {
|
|
|
map.put("appointFlag", 0);//0未点赞
|
|
|
}
|
|
|
}
|
|
|
String sqlCount ="select COUNT(1) as total from base_knowledge_article_doctor where base_article_doctor_id IS NULL ";
|
|
|
List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(sqlCount+condition+orderBy);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = Long.parseLong(rstotal.get(0).get("total").toString());
|
|
|
}
|
|
|
return MixEnvelop.getSuccessListWithPage("success", list, page, size, count);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取某篇问章的统计数据
|
|
|
* @param articleId
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject findArticleStaticsByArticleId(String articleId){
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOS = knowledgeArticleDoctorDao.findByRelationCodeAndType(articleId,2);//获取点赞
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOList = knowledgeArticleDoctorDao.findByRelationCodeAndType(articleId,3);//获取收藏
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOList1 = knowledgeArticleDoctorDao.findByRelationCodeAndType(articleId,1);//获取评论
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("eulogyTotal",knowledgeArticleDoctorDOS.size());//点赞数量
|
|
|
object.put("collectTotal",knowledgeArticleDoctorDOList.size());//收藏数量
|
|
|
object.put("commentTotal",knowledgeArticleDoctorDOList1.size());//评论数量
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 判断该文章当前医生是否点赞或者收藏
|
|
|
*
|
|
|
* @param articleId
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selectArticleDoctorByArticleIdAndUser(String articleId,String user){
|
|
|
boolean eulogy= false;
|
|
|
boolean collect = false;
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOS = knowledgeArticleDoctorDao.findByRelationCodeAndTypeAndUser(articleId,2,user);//获取点赞
|
|
|
List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOList = knowledgeArticleDoctorDao.findByRelationCodeAndTypeAndUser(articleId,3,user);//获取收藏
|
|
|
JSONObject object = new JSONObject();
|
|
|
if (knowledgeArticleDoctorDOS!=null&&knowledgeArticleDoctorDOS.size()>0){
|
|
|
eulogy = true;
|
|
|
}
|
|
|
if (knowledgeArticleDoctorDOList !=null && knowledgeArticleDoctorDOList.size()>0){
|
|
|
collect = true;
|
|
|
}
|
|
|
object.put("eulogy",eulogy);
|
|
|
object.put("collect",collect);
|
|
|
return object;
|
|
|
}
|
|
|
}
|