wangzhinan 1 éve
szülő
commit
8fd4cf8118
34 módosított fájl, 3363 hozzáadás és 190 törlés
  1. 26 0
      business/base-service/src/main/java/com/yihu/jw/article/dao/BaseLinkDictDao.java
  2. 25 0
      business/base-service/src/main/java/com/yihu/jw/article/dao/BaseMenuDictDao.java
  3. 16 0
      business/base-service/src/main/java/com/yihu/jw/article/dao/BaseMenuDictUserDao.java
  4. 17 0
      business/base-service/src/main/java/com/yihu/jw/article/dao/BaseMenuShowDao.java
  5. 3 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeArticleDeptDao.java
  6. 46 0
      business/base-service/src/main/java/com/yihu/jw/article/dao/KnowledgeArticleDictDao.java
  7. 38 0
      business/base-service/src/main/java/com/yihu/jw/article/dao/KnowledgeArticleDoctorDao.java
  8. 4 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeArticleUserDao.java
  9. 1191 0
      business/base-service/src/main/java/com/yihu/jw/article/service/BaseMenuManageService.java
  10. 551 0
      business/base-service/src/main/java/com/yihu/jw/article/service/KnowledgeArticleDictService.java
  11. 52 0
      business/base-service/src/main/java/com/yihu/jw/contant/CommonContant.java
  12. 26 0
      business/base-service/src/main/java/com/yihu/jw/contant/DeviceHealthContant.java
  13. 18 0
      business/base-service/src/main/java/com/yihu/jw/contant/DictContant.java
  14. 18 3
      business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorRoleDao.java
  15. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  16. 25 0
      business/base-service/src/main/java/com/yihu/jw/user/UserDao.java
  17. 13 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorRoleDO.java
  18. 143 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/menu/BaseAppMenu.java
  19. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/menu/BaseMenuDictDO.java
  20. 132 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/menu/BaseMenuDictUserDO.java
  21. 75 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDictDO.java
  22. 78 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDoctorDO.java
  23. 15 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  24. 4 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  25. 182 163
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  26. 261 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleDictEndpoint.java
  27. 1 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleEndpoint.java
  28. 281 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuManageEndpoint.java
  29. 106 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuNoLoginEndpoint.java
  30. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  31. 1 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/BasePatientBusinessService.java
  32. 2 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java
  33. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleUserService.java
  34. 0 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java

+ 26 - 0
business/base-service/src/main/java/com/yihu/jw/article/dao/BaseLinkDictDao.java

@ -0,0 +1,26 @@
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.base.menu.BaseLinkDictDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
public interface BaseLinkDictDao extends JpaRepository<BaseLinkDictDO, String>, JpaSpecificationExecutor<BaseLinkDictDO> {
    @Query( value = "select max(t.link_sort) AS \"zuida\" from base_link_dict t where t.is_del='1'",nativeQuery = true)
    Integer getMaxSort();
    @Query( value = "select min(t.link_sort) AS \"zuixiao\" from base_link_dict t  where t.is_del='1'",nativeQuery = true)
    Integer getMinSort();
    @Modifying
    @Query("update BaseLinkDictDO p set p.status=?2 where p.id=?1")
    void updateStatus(String id,String status);
    @Modifying
    @Query("update BaseLinkDictDO p set p.isShow=?2 where p.id=?1")
    void updateShow(String id,String status);
    @Modifying
    @Query("update BaseLinkDictDO p set p.isDel=?2 where p.id=?1")
    void updateDel(String id,String status);
}

+ 25 - 0
business/base-service/src/main/java/com/yihu/jw/article/dao/BaseMenuDictDao.java

@ -0,0 +1,25 @@
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.base.menu.BaseMenuDictDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface BaseMenuDictDao extends JpaRepository<BaseMenuDictDO, String>, JpaSpecificationExecutor<BaseMenuDictDO> {
    @Query( value = "select max(t.menu_sort) AS \"zuida\" from base_menu_dict t where t.parent_id=?1 and t.is_del='1'",nativeQuery = true)
    Integer getMaxSort(String parentId);
    @Query( value = "select min(t.menu_sort) AS \"zuixiao\" from base_menu_dict t where t.parent_id=?1 and t.is_del='1'",nativeQuery = true)
    Integer getMinSort(String parentId);
    @Modifying
    @Query("update BaseMenuDictDO p set p.status=?2 where p.id=?1")
    void updateStatus(String id,Integer status);
    @Query("from BaseMenuDictDO p where p.parentId=?1 and p.isDel='1'")
    List<BaseMenuDictDO> findByParentId(String parentId);
    @Query("select a from BaseMenuDictDO a where a.isDel='1' and a.id=?1")
    BaseMenuDictDO findByIdAndDel(String id);
}

+ 16 - 0
business/base-service/src/main/java/com/yihu/jw/article/dao/BaseMenuDictUserDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.base.menu.BaseMenuDictUserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
 * Created by yeshijie on 2023/5/4.
 */
public interface BaseMenuDictUserDao  extends JpaRepository<BaseMenuDictUserDO, String>, JpaSpecificationExecutor<BaseMenuDictUserDO> {
    @Query("select a from BaseMenuDictUserDO a where a.del=1 and a.relationCode=?1 and a.user=?2")
    BaseMenuDictUserDO findByRelationCodeAndUserAndDel(String relationCode, String user);
}

+ 17 - 0
business/base-service/src/main/java/com/yihu/jw/article/dao/BaseMenuShowDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.base.menu.BaseMenuShowDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
public interface BaseMenuShowDao  extends JpaRepository<BaseMenuShowDO, String>, JpaSpecificationExecutor<BaseMenuShowDO> {
    @Modifying
    @Query("update BaseMenuShowDO p set p.isDel=?2 where p.id=?1")
    BaseMenuShowDO updateStatus(String id,String status);
    @Query( value = "select max(t.menu_sort) AS \"zuida\" from base_menu_show t where t.is_del='1' and t.model_id=?1",nativeQuery = true)
    Integer getMaxSort(String modelId);
    @Query( value = "select min(t.menu_sort) AS \"zuixiao\" from base_menu_show t where t.is_del='1' and t.model_id=?1",nativeQuery = true)
    Integer getMinSort(String modelId);
}

+ 3 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeArticleDeptDao.java

@ -1,8 +1,8 @@
package com.yihu.jw.hospital.dao.consult;
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -11,7 +11,7 @@ import java.util.List;
 * @author huangwenjie
 * @date 2019/9/18 10:03
 */
public interface KnowledgeArticleDeptDao extends PagingAndSortingRepository<KnowledgeArticleDeptDO, String>, JpaSpecificationExecutor<KnowledgeArticleDeptDO> {
public interface KnowledgeArticleDeptDao extends JpaRepository<KnowledgeArticleDeptDO, String>, JpaSpecificationExecutor<KnowledgeArticleDeptDO> {
	
	List<KnowledgeArticleDeptDO> findByArticleId(String articleId);
	

+ 46 - 0
business/base-service/src/main/java/com/yihu/jw/article/dao/KnowledgeArticleDictDao.java

@ -0,0 +1,46 @@
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
 * 健康文章DAO
 * @author huangwenjie
 * @date 2019/9/10 14:07
 */
public interface KnowledgeArticleDictDao extends JpaRepository<KnowledgeArticleDictDO, String>, JpaSpecificationExecutor<KnowledgeArticleDictDO> {
	@Query("select a from KnowledgeArticleDictDO a where a.del=1 and (categoryFirst = ?1 or categorySecond=?1)")
	List<KnowledgeArticleDictDO> findByCategory(String category);
	@Query("select a from KnowledgeArticleDictDO a where a.del=1 and categoryFirst = ?1 ")
	List<KnowledgeArticleDictDO> findByCategoryFirst(String category);
	@Query("select a from KnowledgeArticleDictDO a where a.del=1 and  categorySecond=?1")
	List<KnowledgeArticleDictDO> findByCategorySecond(String category);
	@Query("select a from KnowledgeArticleDictDO a where a.del=1 and a.id=?1")
	KnowledgeArticleDictDO findByIdAndDel(String id);
	@Query("select count(*) from KnowledgeArticleDictDO a where a.del=1 and a.categoryFirst = ?1 and a.releaseStatus=1 ")
	Integer getCountByCategoryFirst(String category);
	@Query(" select count(*) from KnowledgeArticleDictDO a where a.del=1 and  a.categorySecond IN (?1) and a.releaseStatus=1")
	Integer getCountByCategorySecond(List<String> category);
	@Query(" select count(*) from KnowledgeArticleDictDO a where a.del=1 and  a.categorySecond IN (?1) and a.releaseStatus=1 and a.title like %?2%")
	Integer getCountByCategorySecond(List<String> category,String title);
	@Query("select a from KnowledgeArticleDictDO a where a.del=1 and  a.categorySecond IN ( ?1 ) and a.releaseStatus=1 order by  a.releaseTime desc,a.createTime desc ")
	List<KnowledgeArticleDictDO> findByCategorySecondAndPage(List<String> category,Pageable pageRequest);
	@Query("select a from KnowledgeArticleDictDO a where a.del=1 and  a.categorySecond IN ( ?1 ) and a.releaseStatus=1 and a.title like %?2% order by  a.releaseTime desc,a.createTime desc ")
	List<KnowledgeArticleDictDO> findByCategorySecondAndPage(List<String> category,String title,Pageable pageRequest);
}

+ 38 - 0
business/base-service/src/main/java/com/yihu/jw/article/dao/KnowledgeArticleDoctorDao.java

@ -0,0 +1,38 @@
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDoctorDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
 * 医生文章关系表
 */
public interface KnowledgeArticleDoctorDao extends JpaRepository<KnowledgeArticleDoctorDO, String>, JpaSpecificationExecutor<KnowledgeArticleDoctorDO> {
    @Query("select a from KnowledgeArticleDoctorDO a where a.baseArticleDoctorId=?1 and a.type=?2 order by a.createTime desc")
    List<KnowledgeArticleDoctorDO> findByBaseArticleDoctorIdAndType(String baseArticleDoctorId,Integer type);
    @Query("select a from KnowledgeArticleDoctorDO a where a.relationCode=?1 and a.type=?2 and a.user=?3 order by a.createTime desc")
    List<KnowledgeArticleDoctorDO> findByRelationCodeAndTypeAndUser(String relationCode,Integer type,String user);//根据业务code获取医生文章/医生关系
    @Query("select a from KnowledgeArticleDoctorDO a where a.relationCode=?1 and a.type=?2 and a.user=?3 and a.baseArticleDoctorId=?4 order by a.createTime desc")
    List<KnowledgeArticleDoctorDO> findByBaseArticleDoctorIdAndRelationCodeAndTypeAndUser(String relationCode,Integer type,String user,String baseArticleDoctorId);//根据业务code获取医生文章/医生关系
    @Modifying
    @Query("delete from KnowledgeArticleDoctorDO  where baseArticleDoctorId=?1 and user=?2 and type=?3")
    void deletByBaseArticleDoctorIdAndType(String baseArticleDoctorId,String user,Integer type);
    @Modifying
    @Query("delete from KnowledgeArticleDoctorDO  where relationCode=?1 and user=?2 and type=?3 ")
    void deletByRelationCodeAndType(String relationCode,String user,Integer type);
    @Query("select a from KnowledgeArticleDoctorDO a where a.relationCode=?1 and a.type=?2 order by a.createTime desc")
    List<KnowledgeArticleDoctorDO> findByRelationCodeAndType(String relationCode,Integer type);
}

+ 4 - 5
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeArticleUserDao.java

@ -1,17 +1,16 @@
package com.yihu.jw.hospital.dao.consult;
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 健康文章中间库DAO
 * @author
 * @date 2019/9/10 14:07
 */
public interface KnowledgeArticleUserDao extends PagingAndSortingRepository<KnowledgeArticleUserDO, String>, JpaSpecificationExecutor<KnowledgeArticleUserDO> {
public interface KnowledgeArticleUserDao extends JpaRepository<KnowledgeArticleUserDO, String>, JpaSpecificationExecutor<KnowledgeArticleUserDO> {
	@Query("select a from KnowledgeArticleUserDO a where a.del=1 and a.relationCode=?1 and a.user=?2")
	KnowledgeArticleUserDO findByrelationCodeAndUserAndDel(String relationCode,String user);
	KnowledgeArticleUserDO findByrelationCodeAndUserAndDel(String relationCode, String user);
}

+ 1191 - 0
business/base-service/src/main/java/com/yihu/jw/article/service/BaseMenuManageService.java

@ -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;
    }
}

+ 551 - 0
business/base-service/src/main/java/com/yihu/jw/article/service/KnowledgeArticleDictService.java

@ -0,0 +1,551 @@
package com.yihu.jw.article.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.*;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.menu.BaseMenuDictDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
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.survey.WlyySurveyTemplateDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.dao.SurveyUserDao;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.user.UserDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * 健康文章业务层代码
 * @author huangwenjie
 * @date 2019/9/10 13:54
 */
@Service
public class KnowledgeArticleDictService extends BaseJpaService<KnowledgeArticleDictDO, KnowledgeArticleDictDao> {
	
	@Autowired
	private KnowledgeArticleDictDao knowledgeArticleDictDao;
	@Autowired
	private BaseMenuDictDao baseMenuDictDao;
	@Autowired
	private KnowledgeArticleDeptDao knowledgeArticleDeptDao;
	@Autowired
	private WlyyHospitalSysDictDao hospitalSysDictDao;
	@Autowired
	private BasePatientBusinessDao patientBusinessDao;
	@Autowired
	private KnowledgeArticleUserDao knowledgeArticleUserDao;
	@Autowired
	private BaseDoctorHospitalDao doctorHospitalDao;
	@Autowired
	private BaseDoctorDao doctorDao;
	@Autowired
	private SurveyUserDao surveyUserDao;
	@Autowired
	private SurveyTemplateDao surveyTemplateDao;
	@Autowired
    private HibenateUtils hibenateUtils;
	@Autowired
	private UserDao userDao;
	@Autowired
	private BasePatientDao patientDao;
	@Autowired
	private KnowledgeArticleDoctorDao knowledgeArticleDoctorDao;
	//查询文章列表
	public List<Map<String,Object>> findArticleList(String first,String second,Integer type ,String key,Integer page ,Integer pageSize){
		String sql ="select b.id as \"id\", " +
				" b.title as \"title\"," +
				" b.intro as \"intro\"," +
				" b.category_first as \"categoryFirst\"," +
				" b.category_first_name as \"categoryFirstName\"," +
				" b.category_second as \"category_second\"," +
				" b.category_second_name as \"categorySecondName\"," +
				" b.create_user as \"createUser\"," +
				" b.status as \"status\"," +
				" b.used as \"used\"," +
				" b.create_user_name as \"createUserName\"," +
				" b.create_time as \"createTime\"," +
				" b.check_time as \"checkTime\"," +
				" b.release_status as \"releaseStatus\"," +
				" t.menu_id as \"menuId\"," +
				" t.parent_id as \"parentId\"," +
				" t.menu_name as \"menuName\"  " +
				" from wlyy_knowledge_article_menu t left join wlyy_knowledge_article_dict b" +
				" on t.article_id=b.id left join base_menu_dict c " +
				" on c.id= t.menu_id where t.del=1 and b.type="+type;
		if (StringUtils.isNotBlank(first)){
			sql+=" and t.category_first ='"+first+"'";
		}
		if (StringUtils.isNotBlank(second)){
			sql+=" and t.category_second ='"+second+"'";
		}
		if (StringUtils.isNotBlank(key)){
			sql+=" and (t.title like '%"+first+"&' or t.intro like '%"+key+"%' or t.content like '%"+key+"%')";
		}
		List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
		for (Map<String,Object> map:list){
			if (!"0".equalsIgnoreCase(map.get("parentId").toString())){
				BaseMenuDictDO baseMenuDictDO = baseMenuDictDao.findOne(map.get("parentId").toString());;
				if (baseMenuDictDO!=null){
					map.put("parentName",baseMenuDictDO.getName());
				}
			}else {
				map.put("parentName",map.get("menuName").toString());
			}
		}
		return list;
	}
	public boolean delArticle(String id){
		String str[]= id.split(",");
		for (int i=0;i<str.length;i++){
			KnowledgeArticleDictDO knowledgeArticleDictDO = knowledgeArticleDictDao.findByIdAndDel(str[i]);
			if (knowledgeArticleDictDO!=null){
				knowledgeArticleDictDO.setDel(0);
				knowledgeArticleDictDao.save(knowledgeArticleDictDO);
			}
		}
		return true;
	}
	public KnowledgeArticleDictDO findById(String id){
		return knowledgeArticleDictDao.findByIdAndDel(id);
	}
	/**
	 * 更新/保存健康文章
	 * @param jsonData
	 * @return
	 * @throws Exception
	 */
	public KnowledgeArticleDictDO saveArticle(String jsonData,Integer type) throws  Exception {
		KnowledgeArticleDictDO knowledgeArticleDO = EntityUtils.jsonToEntity(jsonData, KnowledgeArticleDictDO.class);
		WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("articleNeedCheck");;
		Boolean articleNeedCheck= true;
		if (wlyyHospitalSysDictDO!=null){
			if (!wlyyHospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
				articleNeedCheck=false;
			}
		}
		if (!StringUtils.isNotBlank(knowledgeArticleDO.getId()) ) {
			// 新增
			knowledgeArticleDO.setId(UUID.randomUUID().toString().replace("-", ""));
			knowledgeArticleDO.setCreateTime(new Date());
			knowledgeArticleDO.setStatus(0);
			knowledgeArticleDO.setReleaseStatus(0);
			knowledgeArticleDO.setDel(1);
			knowledgeArticleDO.setType(type);
			knowledgeArticleDO.setFabulous(0);
			knowledgeArticleDO.setReadCount(0);
			knowledgeArticleDO.setUsed(0);
			knowledgeArticleDO.setCollection(0);
			knowledgeArticleDO.setIsUsed(0);
			if(type==1){
				UserDO userDO = userDao.findOne(knowledgeArticleDO.getCreateUser());;
				if (userDO!=null){
					knowledgeArticleDO.setCreateUserName(userDO.getName());
				}
			}else {
				UserDO userDO = userDao.findOne(knowledgeArticleDO.getCreateUser());;
				if (userDO!=null){
					knowledgeArticleDO.setCreateUserName(userDO.getName());
				}
			}
			if (!articleNeedCheck){
				knowledgeArticleDO.setStatus(1);
				knowledgeArticleDO.setReleaseStatus(1);
			}
			knowledgeArticleDO = knowledgeArticleDictDao.save(knowledgeArticleDO);
			return knowledgeArticleDO;
		} else {
			KnowledgeArticleDictDO one = knowledgeArticleDictDao.findOne(knowledgeArticleDO.getId());;
			one.setTitle(knowledgeArticleDO.getTitle());
			one.setContent(knowledgeArticleDO.getContent());
			one.setImage(knowledgeArticleDO.getImage());
			one.setIntro(knowledgeArticleDO.getIntro());
			one.setUpdateTime(new Date());
			one.setCategoryFirst(knowledgeArticleDO.getCategoryFirst());
			one.setCategoryFirstName(knowledgeArticleDO.getCategoryFirstName());
			one.setCategorySecond(knowledgeArticleDO.getCategorySecond());
			one.setCategorySecondName(knowledgeArticleDO.getCategorySecondName());
			one.setReleaseTime(knowledgeArticleDO.getReleaseTime());
			one.setStatus(0);
			one.setPuplishType(knowledgeArticleDO.getPuplishType());
			one.setPuplishTypeName(knowledgeArticleDO.getPuplishTypeName());
			one.setSource(knowledgeArticleDO.getSource());
			one.setUrl(knowledgeArticleDO.getUrl());
			one.setVedioUrl(knowledgeArticleDO.getVedioUrl());
			one.setRecommendDoctor(knowledgeArticleDO.getRecommendDoctor());
			one.setRecommendDoctorName(knowledgeArticleDO.getRecommendDoctorName());
			if (!articleNeedCheck){
				one.setStatus(1);
				one.setReleaseStatus(1);
			}
			knowledgeArticleDictDao.save(one);
			return  one;
		}
	}
	/**
	 * 获取doctorId获取医生发布的文章统计数据
	 * @param doctorId
	 * @return
	 */
	public JSONObject findArticleStaticsByDoctorId(String doctorId){
		String eulogySql = " select * from base_knowledge_article_doctor kad where kad.type=2 and kad.relation_code in (select ad.id from wlyy_knowledge_article_dict ad where ad.create_user ='"+doctorId+"') ";
		List<Map<String,Object>> mapList = jdbcTemplate.queryForList(eulogySql);//点赞数量
		String startDate = DateUtil.getNextDay(new Date(),-7)+" 00:00:00";
		String endDate = DateUtil.getStringDateShort()+" 23:59:59";
		String dateCondition = " and kad.create_time >='"+startDate+"' and kad.create_time <='"+endDate+"' ";
		String eulogy7Sql = " select * from base_knowledge_article_doctor kad where kad.type=2 and kad.relation_code in (select ad.id from wlyy_knowledge_article_dict ad where ad.create_user ='"+doctorId+"') "+dateCondition;
		List<Map<String,Object>> map7List = jdbcTemplate.queryForList(eulogy7Sql);//7日点赞数量
		//收藏数量
		String collectSql = " select * from base_knowledge_article_doctor kad where kad.type=3 and kad.relation_code in (select ad.id from wlyy_knowledge_article_dict ad where ad.create_user ='"+doctorId+"') ";
		List<Map<String,Object>> collectList = jdbcTemplate.queryForList(collectSql);//收藏数量
		String collect7Sql = " select * from base_knowledge_article_doctor kad where kad.type=3 and kad.relation_code in (select ad.id from wlyy_knowledge_article_dict ad where ad.create_user ='"+doctorId+"') "+dateCondition;
		List<Map<String,Object>> collect7List = jdbcTemplate.queryForList(collect7Sql);//7日收藏数量
		//评论数量
		String commentSql = " select * from base_knowledge_article_doctor kad where kad.type=1 and kad.relation_code in (select ad.id from wlyy_knowledge_article_dict ad where ad.create_user ='"+doctorId+"') ";
		List<Map<String,Object>> commentList = jdbcTemplate.queryForList(commentSql);//评论数量
		String comment7Sql = " select * from base_knowledge_article_doctor kad where kad.type=1 and kad.relation_code in (select ad.id from wlyy_knowledge_article_dict ad where ad.create_user ='"+doctorId+"') "+dateCondition;
		List<Map<String,Object>> comment7List = jdbcTemplate.queryForList(comment7Sql);//7日评论数量
		JSONObject object = new JSONObject();
		object.put("eulogyTotal",mapList.size());//点赞数量
		object.put("eulogy7Total",map7List.size());//7日新增点赞数量
		object.put("collectTotal",collectList.size());//收藏数量
		object.put("collect7Total",collect7List.size());//7日新增收藏数量
		object.put("commentTotal",commentList.size());//评论数量
		object.put("comment7Total",comment7List.size());//7日新增评论数量
		return object;
	}
	
	//审核/退回文章
	public KnowledgeArticleDictDO reviewArticle(String articleId,Integer status,String reason) throws Exception{
		KnowledgeArticleDictDO knowledgeArticleDO = knowledgeArticleDictDao.findOne(articleId);;
		if (null == knowledgeArticleDO) {
			throw new Exception("该文章不存在");
		} else {
			knowledgeArticleDO.setStatus(status);
			knowledgeArticleDO.setCheckTime(new Date());
			if(StringUtils.isNotBlank(reason)){
				knowledgeArticleDO.setCancelReason(reason);
			}
			knowledgeArticleDO.setReleaseStatus(status);
			knowledgeArticleDictDao.save(knowledgeArticleDO);
			return  knowledgeArticleDO;
		}
	}
	
	/**
	 * 保存文章科室关系
	 * @param articleId
	 * @param sdJsons
	 * @return
	 * @throws Exception
	 */
	public Boolean saveArticleDept(String articleId,String sdJsons)throws Exception{
		
		//删除之前关系
		List<KnowledgeArticleDeptDO> list = knowledgeArticleDeptDao.findByArticleId(articleId);
		if(list!=null&&list.size()>0){
			knowledgeArticleDeptDao.delete(list);
		}
		
		if(org.apache.commons.lang3.StringUtils.isNotBlank(sdJsons)){
			List<KnowledgeArticleDeptDO> _list = EntityUtils.jsonToList(sdJsons,KnowledgeArticleDeptDO.class);
			if(_list!=null&&_list.size()>0){
				knowledgeArticleDeptDao.save(_list);
			}
		}
		return true;
	}
	
	/**
	 * 查询文章下科室
	 * @param articleId
	 * @return
	 */
	public List<Map<String,Object>> findDeptByArticle(String articleId)throws Exception{
		String sql ="SELECT " +
				" d.article_id AS articleId," +
				" d.dept, " +
				" d.dept_name AS deptName " +
				" FROM " +
				" wlyy_knowledge_article t " +
				" JOIN wlyy_knowledge_article_dept d ON t.id = d.article_id " +
				" WHERE " +
				" t.id = '"+articleId+"'";
		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
		return list;
	}
	
	/**
	 * 查询部门下的文章
	 * @param dept
	 * @return
	 */
	public List<Map<String,Object>> findArticleByDept(String dept)throws Exception{
		String sql = "SELECT " +
				" t.id as \"id\", " +
				" t.title as \"title\", " +
				" t.create_time AS \"create_time\" ," +
				" t.image AS \"image\" " +
				" FROM " +
				" wlyy_knowledge_article t " +
				" JOIN wlyy_knowledge_article_dept d ON t.id = d.article_id " +
				" WHERE " +
				" d.dept = '"+dept+"'";
		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
		return list;
	}
	
	/**
	 * 设置部门发送文章
	 * @param dept
	 * @param sdJsons
	 * @return
	 */
	public Boolean saveDeptArticle(String dept, String sdJsons) throws Exception{
		
		//删除之前关系
		List<KnowledgeArticleDeptDO> dels = knowledgeArticleDeptDao.findByDept(dept);
		if(dels!=null&&dels.size()>0){
			knowledgeArticleDeptDao.delete(dels);
		}
		
		if(org.apache.commons.lang3.StringUtils.isNotBlank(sdJsons)){
			List<KnowledgeArticleDeptDO> list = EntityUtils.jsonToList(sdJsons,KnowledgeArticleDeptDO.class);
			if(list!=null&&list.size()>0){
				knowledgeArticleDeptDao.save(list);
			}
		}
		return true;
	}
	public KnowledgeArticleDictDO releaseArticle(String articleId,Integer releaseStatus ){
		String ids[] = articleId.split(",");
		KnowledgeArticleDictDO knowledgeArticleDictDO = new KnowledgeArticleDictDO();
		for (int i=0;i<ids.length;i++){
			knowledgeArticleDictDO = knowledgeArticleDictDao.findByIdAndDel(ids[i]);
			if (null!=knowledgeArticleDictDO){
				knowledgeArticleDictDO.setReleaseStatus(releaseStatus);
				knowledgeArticleDictDao.save(knowledgeArticleDictDO);
			}
		}
		return knowledgeArticleDictDO;
	}
	/**
	 *	患者接收问卷/文章
	 * @param businessDOS
	 * @return
	 */
	public List<BasePatientBusinessDO> sendBusinessToPatient(List<BasePatientBusinessDO> businessDOS) throws Exception {
		if (businessDOS!=null&&businessDOS.size()!=0){
			for (BasePatientBusinessDO patientBusinessDO:businessDOS){
				BasePatientBusinessDO basePatientBusinessDO = patientBusinessDao.findByPatientAndRelationCodeAndDel(patientBusinessDO.getPatient(),patientBusinessDO.getRelationCode());
				if (basePatientBusinessDO != null) {
					throw new Exception("已发送过!");
				}
				patientBusinessDO.setCreateTime(new Date());
				patientBusinessDO.setUpdateTime(new Date());
				patientBusinessDO.setCreateUser(patientBusinessDO.getDoctor());
				patientBusinessDO.setUpdateUser(patientBusinessDO.getDoctor());
				patientBusinessDO.setCreateUserName(patientBusinessDO.getDoctorName());
				patientBusinessDO.setUpdateUserName(patientBusinessDO.getUpdateUserName());
				patientBusinessDO.setCollection(0);
				patientBusinessDO.setDel(1);
				patientBusinessDO = patientBusinessDao.save(patientBusinessDO);
					if (patientBusinessDO.getRelationType()==1){
						KnowledgeArticleDictDO knowledgeArticleDO = knowledgeArticleDictDao.findByIdAndDel(patientBusinessDO.getRelationCode());
					System.out.println("content:"+JSON.toJSONString(knowledgeArticleDO));
					JSONObject object = new JSONObject();
					object.put("id",knowledgeArticleDO.getId());
					object.put("title",knowledgeArticleDO.getTitle());
					object.put("content",knowledgeArticleDO.getIntro());
					object.put("img",knowledgeArticleDO.getImage());
				}else {
					WlyySurveyUserDO wlyySurveyUserDO = new WlyySurveyUserDO();
					String doctor = patientBusinessDO.getDoctor();
					BaseDoctorDO doctorDO = doctorDao.findById(doctor);;
					wlyySurveyUserDO.setDept(doctorDO.getVisitDept());
					wlyySurveyUserDO.setDeptName(doctorDO.getVisitDeptName());
					wlyySurveyUserDO.setDoctor(doctor);
					wlyySurveyUserDO.setDoctorName(doctorDO.getName());
					wlyySurveyUserDO.setStatus(0);
					wlyySurveyUserDO.setPatient(patientBusinessDO.getPatient());
					wlyySurveyUserDO.setPatientName(patientBusinessDO.getPatientName());
					wlyySurveyUserDO.setSurveyTempCode(patientBusinessDO.getRelationCode());
					wlyySurveyUserDO.setSurveyTempTitle(patientBusinessDO.getRelationName());
					wlyySurveyUserDO.setCreateTime(new Date());
					wlyySurveyUserDO.setEndTime(new Date());
					wlyySurveyUserDO = surveyUserDao.save(wlyySurveyUserDO);
					JSONObject object = new JSONObject();
					WlyySurveyTemplateDO wlyySurveyTemplateDO = surveyTemplateDao.findOne(wlyySurveyUserDO.getSurveyTempCode());;
					if (null!=wlyySurveyTemplateDO){
						object.put("title",wlyySurveyTemplateDO.getTitle());
						object.put("content",wlyySurveyTemplateDO.getTemplateComment());
						object.put("id",wlyySurveyTemplateDO.getId());
					}
				}
			}
		}
		return businessDOS;
	}
	/**
	 * 设置为1常用或者0不常用
	 * @param id
	 * @param used
	 * @return
	 */
	public KnowledgeArticleDictDO setUsed(String id,Integer used,String doctor){
		KnowledgeArticleDictDO knowledgeArticleDO = knowledgeArticleDictDao.findByIdAndDel(id);
		BaseDoctorDO doctorDO = doctorDao.findById(doctor);
		KnowledgeArticleUserDO knowledgeArticleUserDO =knowledgeArticleUserDao.findByrelationCodeAndUserAndDel(id,doctor);
		if (knowledgeArticleUserDO==null){
			knowledgeArticleUserDO = new KnowledgeArticleUserDO();
			knowledgeArticleUserDO.setRelationCode(id);
			knowledgeArticleUserDO.setRelationName(knowledgeArticleDO.getTitle());
			knowledgeArticleUserDO.setRelationType(1);
			knowledgeArticleUserDO.setDel(1);
			knowledgeArticleUserDO.setUser(doctor);
			if (doctorDO!=null){
				knowledgeArticleUserDO.setUserName(doctorDO.getName());
				knowledgeArticleUserDO.setCreateUserName(doctorDO.getName());
			}
			knowledgeArticleUserDO.setCreateTime(new Date());
			knowledgeArticleUserDO.setUpdateTime(new Date());
			knowledgeArticleUserDO.setCreateUser(doctor);
			knowledgeArticleUserDO.setUpdateUser(doctor);
			knowledgeArticleUserDO.setUsed(used);
			knowledgeArticleUserDO = knowledgeArticleUserDao.save(knowledgeArticleUserDO);
		}
        if (knowledgeArticleDO!=null){
            if (knowledgeArticleDO.getUsed()!=null){
            	if (used==1){
					knowledgeArticleUserDO.setUsed(1);
					knowledgeArticleDO.setUsed(knowledgeArticleDO.getUsed()+1);
				}else if (used==0){
            		knowledgeArticleUserDO.setUsed(0);
            		knowledgeArticleDO.setUsed(knowledgeArticleDO.getUsed()-1);
				}
			}else {
				if (used==1){
					knowledgeArticleDO.setUsed(1);
				}else if (used==0){
					knowledgeArticleDO.setUsed(0);
				}
			}
        }
		knowledgeArticleUserDO.setRelationName(knowledgeArticleDO.getTitle());
        knowledgeArticleUserDao.save(knowledgeArticleUserDO);
		return knowledgeArticleDictDao.save(knowledgeArticleDO);
	}
	public KnowledgeArticleDictDO selectById(String id){
		return knowledgeArticleDictDao.findByIdAndDel(id);
	}
	//根据分类查询文章
	public MixEnvelop findArticleByCategoryAndName(String categoryFirst, String categorySecond, String keyWords, Integer page, Integer pageSize){
		MixEnvelop objEnvelop = new MixEnvelop();
		String sql = "select t.id as \"id\",t.title as \"title\",t.read_count as \"readCount\"," +
				"t.collection as \"collection\",t.fabulous as \"fabulous\",t.is_share as \"share\"," +
                " t.intro as \"intro\",t.category_first_name as \"categoryFirstName\"," +
                " t.category_second_name as \"categorySecondName\" ," +
                "t.content as \"content\",t.image as \"image\",t.create_user_name as \"createUserName\",c.job_title_name as \"jobTitleName\"," +
                "b.dept_name as \"deptName\",b.org_name as \"hospitalName\"," +
				"t.create_time as \"createTime\" " +
				" from wlyy_knowledge_article t left join wlyy_knowledge_article_dept a " +
                " on a.article_id = t.id left join base_doctor_hospital b on b.doctor_code = t.create_user" +
				" left join base_doctor c on c.id = t.create_user where 1=1 and t.del = 1 and t.status = 1";
		if (StringUtils.isNotBlank(categoryFirst)){
		    sql+=" and t.category_first = '"+categoryFirst+"'";
        }
		if (StringUtils.isNotBlank(categorySecond)){
			sql+=" and t.category_second ='"+categorySecond+"'";
		}
        if (StringUtils.isNotBlank(keyWords)){
            sql+=" and (t.create_user_name like '%"+keyWords+"%' or t.title like '%"+keyWords+"%' or t.content like '%"+keyWords+"%' or a.dept_name like '%"+keyWords+"%' )";
        }
		sql+=" group by t.id ,t.title ,t.intro,t.category_first_name ,t.category_second_name ,c.job_title_name," +
				"t.read_count,t.collection,t.fabulous,t.is_share,t.content ,t.image ,t.create_user_name ,b.dept_name ,b.org_name,t.create_time " +
				" order by t.create_time desc";
        List<Map<String,Object>> result = hibenateUtils.createSQLQuery(sql,page,pageSize);
        List<Map<String,Object>> countList = hibenateUtils.createSQLQuery(sql);
        objEnvelop.setObj(result);
        objEnvelop.setTotalCount(countList.size());
        objEnvelop.setPageSize(pageSize);
        objEnvelop.setCurrPage(page);
        return objEnvelop;
	}
	//查询患者收藏的文章列表
	public JSONObject findPatientFavorite(String patient,Integer page,Integer pageSize){
		String sql = "select t.id as \"id\",t.user_code as \"user\",t.user_name as \"userName\"," +
				"t.relation_code as \"relationCode\"," +
				"t.relation_type as \"relationType\"," +
				"t.relation_name as \"relationName\"," +
				"t.is_read as \"isRead\",t.fabulous as \"fabulous\"," +
				"t.is_share as \"share\"," +
				"t.collection as \"collection\",t.used as \"used\",t.del as \"del\"";
		sql+=" from wlyy_knowledge_article_user t left join wlyy_knowledge_article a" +
				" on t.relation_code = a.id where 1=1 and a.del=1 and a.collection=1 ";
		if (StringUtils.isNotEmpty(patient)){
			sql+=" and t.user_code = '"+patient+"'";
		}
		List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
		if(list!=null&&list.size()>0){
			for (Map<String,Object> map:list){
				String relationCode = map.get("relationCode").toString();
				String type =  map.get("relationType").toString();
				if ("1".equalsIgnoreCase(type)){
					KnowledgeArticleDictDO knowledgeArticleDO = this.selectById(relationCode);
					if (knowledgeArticleDO!=null){
						List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(knowledgeArticleDO.getCreateUser());
						if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
							knowledgeArticleDO.setDeptName(doctorHospitalDOS.get(0).getDeptName());
							knowledgeArticleDO.setHospitalName(doctorHospitalDOS.get(0).getOrgName());
						}
					}
					map.put("KnowledgeArticleUserDO",knowledgeArticleDO);
				}
			}
		}
		List<Map<String,Object>> listCount = hibenateUtils.createSQLQuery(sql);
		JSONObject result = new JSONObject();
		result.put("total",listCount.size());
		result.put("detailModelList",list);
		return result;
	}
}

+ 52 - 0
business/base-service/src/main/java/com/yihu/jw/contant/CommonContant.java

@ -0,0 +1,52 @@
package com.yihu.jw.contant;
/**
 * 常量
 * @author yeshijie on 2018/9/27.
 */
public class CommonContant {
    /**
     * 默认父类id 0
     */
    public static final String DEFAULT_PARENTID = "0";
    /**
     * 默认父类无
     */
    public static final String DEFAULT_PARENTNAME = "无";
    //是否必选0-表示非必选,1-表示必选
    public static final String IS_MUST = "1";
    /**
     * 接口返回通用提示消息
     */
    public static class Message {
        public static final String GET_SUCCESS = "获取成功";
        public static final String GET_ERROR = "获取失败";
        public static final String SAVE_SUCCESS ="保存成功";
        public static final String SAVE_ERROR ="保存失败";
        public static final String OPERATE_SUCCESS ="操作成功";
        public static final String OPERATE_ERROR ="操作失败";
        public static final String CREATE =  "/create";
        public static final String DELETE = "/delete";
        public static final String UPDATE = "/update";
        public static final String PAGE = "/page";
        public static final String LIST = "/list";
        public static final String FINDBYID = "/findById";
        public static final String FIND_MODULE_BY_SAASID = "/findModuleBySaasId";
        public static final String STATUS = "/status";
    }
    /**
     * DR 开头表示医生角色
     */
    /**
     * 住院病区审核员
     */
    public static final String DR_INPATIENTAREA = "inpatientArea";
    /**
     * 文章审核员
     */
    public static final String DR_ARTICLEREVIEWER = "articleReviewer";
}

+ 26 - 0
business/base-service/src/main/java/com/yihu/jw/contant/DeviceHealthContant.java

@ -0,0 +1,26 @@
package com.yihu.jw.contant;
/**
 * 设备健康常量
 * Created by yeshijie on 2023/2/13.
 */
public class DeviceHealthContant {
    // 血糖餐前最小值
    public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
    // 血糖餐前最大值
    public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
    // 血糖餐后最小值
    public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
    // 血糖餐后最大值
    public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
    // 舒张压最小值
    public static final double HEALTH_STANDARD_SZY_MIN = 60;
    // 舒张压最大值
    public static final double HEALTH_STANDARD_SZY_MAX = 90;
    // 收缩压最小值
    public static final double HEALTH_STANDARD_SSY_MIN = 90;
    // 收缩压最大值
    public static final double HEALTH_STANDARD_SSY_MAX = 140;
}

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/contant/DictContant.java

@ -0,0 +1,18 @@
package com.yihu.jw.contant;
/**
 * Created by yeshijie on 2022/12/5.
 */
public class DictContant {
    /**
     * 住院登记状态
     */
    public static final String INPATIENTREGIST_STATUS = "inpatientRegist_status";
    /**
     * 住院性质
     */
    public static final String INPATIENT_NATURE = "inpatient_nature";
}

+ 18 - 3
business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorRoleDao.java

@ -3,6 +3,7 @@ package com.yihu.jw.doctor.dao;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -24,12 +25,26 @@ import java.util.Set;
 */
public interface BaseDoctorRoleDao extends PagingAndSortingRepository<BaseDoctorRoleDO, Integer>, JpaSpecificationExecutor<BaseDoctorRoleDO>  {
    @Query("from BaseDoctorRoleDO where roleCode = ?1 and del=1")
    List<BaseDoctorRoleDO> findByRoleCode(String roleCode);
    @Query("select id from BaseDoctorRoleDO where doctorCode = ?1")
    @Query("select id from BaseDoctorRoleDO where doctorCode = ?1 and del=1")
    Set<Object> findIdListByDoctorCode(String doctorCode);
    @Query("from BaseDoctorRoleDO where doctorCode = ?1 and del=1")
    List<BaseDoctorRoleDO> findByDoctorCode(String doctorCode);
    @Query("from BaseDoctorRoleDO where doctorCode = ?1 and roleCode = ?2")
    BaseDoctorRoleDO findByDoctorCodeAndroleCode(String doctorCode,String roleCode);
    @Query("from BaseDoctorRoleDO where doctorCode = ?1 and roleCode = ?2 and del=1")
    BaseDoctorRoleDO findByDoctorCodeAndRoleCode(String doctorCode,String roleCode);
    @Query("from BaseDoctorRoleDO where doctorCode = ?1 and roleCode = ?2 and del=?3")
    BaseDoctorRoleDO findByDoctorCodeAndRoleCodeAndDel(String doctorCode,String roleCode,Integer del);
    @Modifying
    @Query("update BaseDoctorRoleDO set del=?3 where doctorCode = ?1 and roleCode = ?2")
    int updDel(String doctorCode,String roleCode,Integer del);
    @Modifying
    @Query("delete from BaseDoctorRoleDO where doctorCode = ?1 and roleCode = ?2")
    int delRole(String doctorCode,String roleCode);
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -4029,7 +4029,7 @@ public class EntranceService {
                                        baseDoctorHospitalDO.setDel("1");
                                        baseDoctorHospitalDao.save(baseDoctorHospitalDO);
                                    }
                                    BaseDoctorRoleDO roleList = baseDoctorRoleDao.findByDoctorCodeAndroleCode(baseDoctorDO.getId(), "specialist");
                                    BaseDoctorRoleDO roleList = baseDoctorRoleDao.findByDoctorCodeAndRoleCode(baseDoctorDO.getId(), "specialist");
                                    if (roleList == null) {
                                        roleList = new BaseDoctorRoleDO();
                                        roleList.setDoctorCode(baseDoctorDO.getId());

+ 25 - 0
business/base-service/src/main/java/com/yihu/jw/user/UserDao.java

@ -0,0 +1,25 @@
package com.yihu.jw.user;
import com.yihu.jw.entity.base.user.UserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
 * Dao - 后台管理员
 * Created by progr1mmer on 2018/8/20.
 */
public interface UserDao extends JpaRepository<UserDO, String>, JpaSpecificationExecutor<UserDO> {
    List<UserDO> findByEnabled(boolean enabled);
    UserDO findByMobile(String mobile);
    boolean existsByMobile(String mobile);
    boolean existsByUsername(String username);
    UserDO findByUsername(String username);
}

+ 13 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorRoleDO.java

@ -28,8 +28,20 @@ public class BaseDoctorRoleDO extends IntegerIdentityEntity {
	 */
	private String roleCode;
    /**
     * 是否生效 1生效 0失效(默认1)
     */
    private Integer del;
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
	@Column(name = "doctor_code")
    @Column(name = "doctor_code")
    public String getDoctorCode() {
        return doctorCode;
    }

+ 143 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/menu/BaseAppMenu.java

@ -0,0 +1,143 @@
package com.yihu.jw.entity.base.menu;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.List;
/**
 * app端菜单配置
 * Created by yeshijie on 2022/9/27.
 */
@Entity
@Table(name = "base_app_menu")
public class BaseAppMenu extends UuidIdentityEntityWithCreateTime {
    public final static String topPid = "0";//顶级父id
    private String pid;//父类id(第一级pid为0)
    private String name;//菜单名称
    private String code;//菜单编码
    private String img;//图标
    private String url;//跳转链接
    private Integer type;//类型 1医生 2居民
    private Integer del;//删除标志 1正常0删除
    private Integer status;//状态(1有效,0失效)
    private String statusName;
    private Integer sort;//排序字段
    private String remark;//备注
    private List<BaseAppMenu> children = new ArrayList<>(); // 子节点
    @Column(name = "pid")
    public String getPid() {
        return pid;
    }
    public void setPid(String pid) {
        this.pid = pid;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "img")
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    @Column(name = "url")
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "sort")
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Transient
    public List<BaseAppMenu> getChildren() {
        return children;
    }
    public void setChildren(List<BaseAppMenu> children) {
        this.children = children;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/menu/BaseMenuDictDO.java

@ -32,6 +32,16 @@ public class BaseMenuDictDO extends UuidIdentityEntityWithOperator {
    private String bgImg;
    private String menuTitle;
    private String describtion;
    private Integer type;//类型 1 官网菜单 2app文章菜单
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "bg_img")
    public String getBgImg() {
        return bgImg;

+ 132 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/menu/BaseMenuDictUserDO.java

@ -0,0 +1,132 @@
package com.yihu.jw.entity.base.menu;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 菜单文章中间表
 * @author
 * @date
 */
@Entity
@Table(name = "base_menu_dict_user")
public class BaseMenuDictUserDO extends UuidIdentityEntityWithCreateTime {
	private String user;//用户code
	private String userName;//用户名称
	private String relationCode;//文章code或者问卷code
	private Integer relationType;//1文章2问卷
	private String relationName;//文章名称
	private Integer fabulous;//1已赞0未赞
	private Integer isRead;//1已读0未读
	private Integer share;//1已分享0未分享
	private Integer collection;//是否收藏1是0否
	private Integer used;//1常用0不常用
	private Integer del;//是否删除,1正常,0删除
	private BaseMenuDictDO baseMenuDictDO;
	@Column(name = "user_code")
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getRelationCode() {
		return relationCode;
	}
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
	public Integer getRelationType() {
		return relationType;
	}
	public void setRelationType(Integer relationType) {
		this.relationType = relationType;
	}
	public String getRelationName() {
		return relationName;
	}
	public void setRelationName(String relationName) {
		this.relationName = relationName;
	}
	public Integer getFabulous() {
		return fabulous;
	}
	public void setFabulous(Integer fabulous) {
		this.fabulous = fabulous;
	}
	public Integer getIsRead() {
		return isRead;
	}
	public void setIsRead(Integer isRead) {
		this.isRead = isRead;
	}
	@Column(name = "is_share")
	public Integer getShare() {
		return share;
	}
	public void setShare(Integer share) {
		this.share = share;
	}
	public Integer getCollection() {
		return collection;
	}
	public void setCollection(Integer collection) {
		this.collection = collection;
	}
	public Integer getUsed() {
		return used;
	}
	public void setUsed(Integer used) {
		this.used = used;
	}
	public Integer getDel() {
		return del;
	}
	public void setDel(Integer del) {
		this.del = del;
	}
	@Transient
	public BaseMenuDictDO getBaseMenuDictDO() {
		return baseMenuDictDO;
	}
	public void setBaseMenuDictDO(BaseMenuDictDO baseMenuDictDO) {
		this.baseMenuDictDO = baseMenuDictDO;
	}
}

+ 75 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDictDO.java

@ -8,6 +8,8 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 健康文章
@ -43,6 +45,7 @@ public class KnowledgeArticleDictDO extends UuidIdentityEntity {
	private Integer readCount;//已读数
	private Integer collection;//收藏数量
	private Integer fabulous;//点赞数量
	private Integer comment;//评论数量
	@Column(name = "is_share")
	private Integer share;//分享 数量
	private String intro;//简介
@ -61,6 +64,78 @@ public class KnowledgeArticleDictDO extends UuidIdentityEntity {
	private Date checkTime;
	private Integer releaseStatus;
	private Integer puplishType;//1、图文2、视频3、音频
	private String puplishTypeName;//1、图文2、视频3、音频
	private String recommendDoctor;//推荐医生,以逗号隔开
	private String recommendDoctorName;//推荐医生,以逗号隔开
	private Integer type;//类型 1官网 2app文章
	@Transient
	private List<Map<String,Object>> doctorList;//推荐医生信息
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public Integer getPuplishType() {
		return puplishType;
	}
	public void setPuplishType(Integer puplishType) {
		this.puplishType = puplishType;
	}
	public String getPuplishTypeName() {
		return puplishTypeName;
	}
	public void setPuplishTypeName(String puplishTypeName) {
		this.puplishTypeName = puplishTypeName;
	}
	public String getRecommendDoctor() {
		return recommendDoctor;
	}
	public void setRecommendDoctor(String recommendDoctor) {
		this.recommendDoctor = recommendDoctor;
	}
	public String getRecommendDoctorName() {
		return recommendDoctorName;
	}
	public void setRecommendDoctorName(String recommendDoctorName) {
		this.recommendDoctorName = recommendDoctorName;
	}
	@Transient
	public List<Map<String, Object>> getDoctorList() {
		return doctorList;
	}
	public void setDoctorList(List<Map<String, Object>> doctorList) {
		this.doctorList = doctorList;
	}
	public Integer getComment() {
		return comment;
	}
	public void setComment(Integer comment) {
		this.comment = comment;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date releaseTime;
	@Column(name = "release_time")

+ 78 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDoctorDO.java

@ -0,0 +1,78 @@
package com.yihu.jw.entity.hospital.article;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 医生文章关系表
 */
@Entity
@Table(name = "base_knowledge_article_doctor")
public class KnowledgeArticleDoctorDO extends UuidIdentityEntityWithOperator {
	
	private String baseArticleDoctorId;//回复关联
	private String relationCode;//文章id/医生code
	private Integer relationType;//1文章2医生
	private String user;//用户code
	private String userName;//用户名称
	private Integer type;//1评论2点赞3收藏
	private String content;//评论内容及回复内容
	public String getBaseArticleDoctorId() {
		return baseArticleDoctorId;
	}
	public void setBaseArticleDoctorId(String baseArticleDoctorId) {
		this.baseArticleDoctorId = baseArticleDoctorId;
	}
	public String getRelationCode() {
		return relationCode;
	}
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
	public Integer getRelationType() {
		return relationType;
	}
	public void setRelationType(Integer relationType) {
		this.relationType = relationType;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
}

+ 15 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1229,6 +1229,21 @@ public class BaseHospitalRequestMapping {
        public static final String findArticleByCategoryAndName  = "/findArticleByCategoryAndName";
        public static final String getArticleGroup  = "/getArticleGroup";
        public static final String findPatientFavorite  = "/findPatientFavorite";
        public static final String findArticleStaticsByDoctorId="/findArticleStaticsByDoctorId";
        public static final String updateArticleUser= "/updateArticleUser";
        public static final String selectMenuList= "/selectMenuList";
        public static final String selectArticleListByCategory= "/selectArticleListByCategory";
        public static final String findArticleUserById= "/findArticleUserById";
        public static final String insertArticleOperate= "/insertArticleOperate";
        public static final String selectArticleDoctorById= "/selectArticleDoctorById";
        public static final String selectArticleDoctorByArticleIdAndUser= "/selectArticleDoctorByArticleIdAndUser";
        public static final String deleteArticleDoctorById= "/deleteArticleDoctorById";
    }
    /**

+ 4 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -964,6 +964,10 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        this.getJdbcTemplate().update("update base_doctor p set p.openid = ? where p.id= ?", openid, userId);
    }
    public void updateDoctorOnline(String online, String userId) {
        this.getJdbcTemplate().update("update base_doctor p set p.consult_status = ? where p.id= ?", online, userId);
    }
    public void updateOpenIdAndWechatId(String openid, String userId,String wechatId) {
        List<BasePatientWechatDo> patientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,userId);
        if (patientWechatDos!=null&&patientWechatDos.size()!=0){

+ 182 - 163
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -1,5 +1,6 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.code.kaptcha.impl.DefaultKaptcha;
@ -331,106 +332,106 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
     */
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
            logger.info("login:登录进入1");
            //图形验证码验证
            String key = parameters.get("key");
            String text = parameters.get("text");
        logger.info("login:登录进入1");
        //图形验证码验证
        String key = parameters.get("key");
        String text = parameters.get("text");
            if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
                if(!verifyCaptcha(key,text)){
                    throw new ImgCaptchaException("验证码错误!");
                }
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
                throw new ImgCaptchaException("验证码错误!");
            }
            logger.info("login:登录进入2");
        }
        logger.info("login:登录进入2");
            String flag = parameters.get("flag");
        String flag = parameters.get("flag");
            String username = parameters.get("username");
            logger.info(username);
        String username = parameters.get("username");
        logger.info(username);
            if (StringUtils.isEmpty(username)&&StringUtils.isEmpty(flag)) {
                throw new InvalidRequestException("username");
        if (StringUtils.isEmpty(username)&&StringUtils.isEmpty(flag)) {
            throw new InvalidRequestException("username");
        }
        String client_id = parameters.get("client_id");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if("alipay".equals(flag)||"family".equals(flag)){
            //支付宝登录||家人登录
            parameters.put("grant_type", flag);
            String encdata = parameters.get("encdata");
            if("alipay".equals(flag)){
                encdata = AES.decrypt(encdata);
            }else{
                encdata = AesEncryptUtils.agDecrypt(encdata);
            }
            String data[] = encdata.split(":");
            username = data[1];
            parameters.put("username", username);
        }else if("dingTalk".equals(flag)){
            //钉钉免登录
            parameters.put("grant_type", "dingTalk");
            String authCode = parameters.get("authCode");
            if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                throw new InvalidRequestException("请求参数错误");
            }
            String registerRes= httpClientUtil.get("http://127.0.0.1:10301/doctor/dingtalk_app_user?authCode="+authCode,"UTF-8");
            JSONObject jsonObject= JSONObject.parseObject(registerRes);
            if (jsonObject.getInteger("status") == 200){
                parameters.put("username", jsonObject.getString("message"));
            }else{
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("message"), -1, null);
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
            String client_id = parameters.get("client_id");
            if (StringUtils.isEmpty(client_id)) {
                throw new InvalidRequestException("client_id");
            }
            if("alipay".equals(flag)||"family".equals(flag)){
                //支付宝登录||家人登录
                parameters.put("grant_type", flag);
                String encdata = parameters.get("encdata");
                if("alipay".equals(flag)){
                    encdata = AES.decrypt(encdata);
                }else{
                    encdata = AesEncryptUtils.agDecrypt(encdata);
                }
                String data[] = encdata.split(":");
                username = data[1];
                parameters.put("username", username);
            }else if("dingTalk".equals(flag)){
                //钉钉免登录
                parameters.put("grant_type", "dingTalk");
                String authCode = parameters.get("authCode");
                if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                    throw new InvalidRequestException("请求参数错误");
                }
                String registerRes= httpClientUtil.get("http://127.0.0.1:10301/doctor/dingtalk_app_user?authCode="+authCode,"UTF-8");
                JSONObject jsonObject= JSONObject.parseObject(registerRes);
                if (jsonObject.getInteger("status") == 200){
                    parameters.put("username", jsonObject.getString("message"));
                }else{
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
                    Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("message"), -1, null);
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
            }else if("wxApplets".equals(flag)){
                //微信小程序登录
                parameters.put("grant_type", "dingTalk");
                String authCode = parameters.get("authCode");
                if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                    throw new InvalidRequestException("请求参数错误");
                }
                String userPhone = wechatService.getUserPhoneByApplets(authCode);
                if (!StringUtils.isEmpty(userPhone)){
                    parameters.put("username", userPhone);
                }else{
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
                    Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>("获取用户手机号失败", -1, null);
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
            }else if (StringUtils.isEmpty(parameters.get("captcha"))) {
                parameters.put("grant_type", "password");
                //解密密码
                if (parameters.get("password") != null) {
                    KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                    String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                    parameters.put("password", password);
                } else {
                    //第三方同步账号模式登录
                    parameters.put("grant_type", "ihealthCode");
                }
        }else if("wxApplets".equals(flag)){
            //微信小程序登录
            parameters.put("grant_type", "dingTalk");
            String authCode = parameters.get("authCode");
            if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                throw new InvalidRequestException("请求参数错误");
            }
            String userPhone = wechatService.getUserPhoneByApplets(authCode);
            if (!StringUtils.isEmpty(userPhone)){
                parameters.put("username", userPhone);
            }else{
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>("获取用户手机号失败", -1, null);
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
        }else if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            //解密密码
            if (parameters.get("password") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                parameters.put("password", password);
            } else {
                parameters.put("grant_type", "captcha");
                //第三方同步账号模式登录
                parameters.put("grant_type", "ihealthCode");
            }
            logger.info("login:登录进入3");
        } else {
            parameters.put("grant_type", "captcha");
        }
        logger.info("login:登录进入3");
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            if (null == authenticatedClient) {
                throw new InvalidRequestException("client_id");
            }
            logger.info("login:登录进入4"+authenticatedClient.getClientId());
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        if (null == authenticatedClient) {
            throw new InvalidRequestException("client_id");
        }
        logger.info("login:登录进入4"+authenticatedClient.getClientId());
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
            OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
            //账户密码登录的才验证密码强度
        if ("hz_yyyzh_wx".equals(wechatId)||
@ -448,58 +449,63 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
            if("1".equals(kickEachOther)){
                HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
                if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                    if (tokenStore.readAccessToken(token.getValue())!=null){
                        tokenStore.removeAccessToken(token.getValue());
                        tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                        token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                    }
                }
                if (token == null) {
                    throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        if("1".equals(kickEachOther)){
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                if (tokenStore.readAccessToken(token.getValue())!=null){
                    tokenStore.removeAccessToken(token.getValue());
                    tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                    token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                }
            }
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
        }
            WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
            if ("pad".equals(parameters.get("clientType"))&&!("1".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
                throw new InvalidGrantException("不允许登录该平台");
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        if ("pad".equals(parameters.get("clientType"))&&!("1".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
            throw new InvalidGrantException("不允许登录该平台");
        }
        logger.info("wlyyUserSimple::"+wlyyUserSimple);
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
        wlyyUserSimple.setExpiresIn(token.getExpiresIn());
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        String openid = parameters.get("openid");
        String xopenid = parameters.get("xopenid");
        String unionid = parameters.get("unionid");
        String wechatId = parameters.get("wechatId");
        logger.info("login:登录进入7");
        //医生更新
        if ("2".equals(loginType)){
            logger.info("医生登录修改在线状态为在线");
            userDetailsService.updateDoctorOnline("1",wlyyUserSimple.getId());
        }
        //更新患者openId
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        logger.info("gengxin开始");
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(openid);
            logger.info("gengxin进入"+openid);
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                logger.info("gengxin进入"+wechatId);
                userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
            }
            logger.info("wlyyUserSimple::"+wlyyUserSimple);
            wlyyUserSimple.setAccessToken(token.getValue());
            wlyyUserSimple.setTokenType(token.getTokenType());
            wlyyUserSimple.setExpiresIn(token.getExpiresIn());
            wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
            wlyyUserSimple.setUser(parameters.get("username"));
            wlyyUserSimple.setState(parameters.get("state"));
            String loginType = parameters.get("login_type");
            String openid = parameters.get("openid");
            String xopenid = parameters.get("xopenid");
            String unionid = parameters.get("unionid");
            String wechatId = parameters.get("wechatId");
            logger.info("login:登录进入7");
            //更新患者openId
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            logger.info("gengxin开始");
            if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
                baseLoginLogDO.setOpenid(openid);
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")&&wechatId.equalsIgnoreCase("xm_ihealth_wx")){
                userDetailsService.updateOpenIdAndWechatId(userDetailsService.getZsyyOpenid(wlyyUserSimple.getIdcard()),wlyyUserSimple.getId(),wxId);
            }
        }else if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("2".equals(loginType))) {
            if (wechatId.equalsIgnoreCase("xm_mlwyy_wx")){
                logger.info("gengxin进入"+openid);
                userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
                if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                    logger.info("gengxin进入"+wechatId);
                    userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
                }
                if (wxId.equalsIgnoreCase("xm_zsyy_wx")&&wechatId.equalsIgnoreCase("xm_ihealth_wx")){
                    userDetailsService.updateOpenIdAndWechatId(userDetailsService.getZsyyOpenid(wlyyUserSimple.getIdcard()),wlyyUserSimple.getId(),wxId);
                }
            }else if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("2".equals(loginType))) {
                if (wechatId.equalsIgnoreCase("xm_mlwyy_wx")){
                    logger.info("gengxin进入"+openid);
                    userDetailsService.updateDoctorOpenId(openid, wlyyUserSimple.getId());
                }
                userDetailsService.updateDoctorOpenId(openid, wlyyUserSimple.getId());
            }
        }
        if (!StringUtils.isEmpty(xopenid) && !"undefined".equalsIgnoreCase(xopenid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(xopenid);
            logger.info("gengxin进入"+xopenid);
@ -509,34 +515,34 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            }
        }
            if (parameters.get("password") != null) {
                //使用密码登录成功后, 更新失败次数为 0
                userDetailsService.addFailureCount(username, 0);
            }
            logger.info("login:登录进入8");
            wlyyUserSimple.setOpenid(openid);
            userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        if (parameters.get("password") != null) {
            //使用密码登录成功后, 更新失败次数为 0
            userDetailsService.addFailureCount(username, 0);
        }
        logger.info("login:登录进入8");
        wlyyUserSimple.setOpenid(openid);
        userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
            logger.info("login:登录进入9");
            String clientType = parameters.get("clientType");
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogDO.setName(wlyyUserSimple.getName());
            baseLoginLogDO.setClientType(clientType);
            baseLoginLogDO.setToken(token.getValue());
            baseLoginLogService.save(baseLoginLogDO);
            logger.info("login:登录进入10");
            //个推 clientId
            String clientId = parameters.get("getuiClientId");
            String getuiClientType = parameters.get("getuiClientType");
            String padImei = parameters.get("padImei");
            //客户端类型 app,wx,pad,pc
            userDetailsService.updateInfo(clientId,getuiClientType,padImei,loginType,wlyyUserSimple.getId(),baseLoginLogDO);
            return getResponse(wlyyUserSimple);
        logger.info("login:登录进入9");
        String clientType = parameters.get("clientType");
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
        baseLoginLogDO.setCreateTime(new Date());
        String userAgent = JSONObject.toJSONString(wlyyUserSimple);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogDO.setName(wlyyUserSimple.getName());
        baseLoginLogDO.setClientType(clientType);
        baseLoginLogDO.setToken(token.getValue());
        baseLoginLogService.save(baseLoginLogDO);
        logger.info("login:登录进入10");
        //个推 clientId
        String clientId = parameters.get("getuiClientId");
        String getuiClientType = parameters.get("getuiClientType");
        String padImei = parameters.get("padImei");
        //客户端类型 app,wx,pad,pc
        userDetailsService.updateInfo(clientId,getuiClientType,padImei,loginType,wlyyUserSimple.getId(),baseLoginLogDO);
        return getResponse(wlyyUserSimple);
    }
@ -616,6 +622,19 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (null == token) {
            token = parameters.get("token");
        }
        String userAgent = request.getHeader("userAgent");
        if (StringUtils.isEmpty(userAgent)) {
            userAgent = request.getHeader("User-Agent");
        }
        JSONObject json = JSON.parseObject(userAgent);
        String uuid = json.getString("uid");
        String loginType = parameters.get("login_type");
        //医生更新
        if (!StringUtils.isEmpty(loginType)&&"2".equals(loginType)){
            logger.info("医生登录修改在线状态为离线");
            userDetailsService.updateDoctorOnline("0",uuid);
        }
        OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(token);
        if (oAuth2AccessToken != null) {
            tokenStore.removeAccessToken(oAuth2AccessToken.getValue());

+ 261 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleDictEndpoint.java

@ -0,0 +1,261 @@
package com.yihu.jw.hospital.endpoint.article;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.service.BaseMenuManageService;
import com.yihu.jw.article.service.KnowledgeArticleDictService;
import com.yihu.jw.contant.CommonContant;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * app文章
 * @author yeshijie
 */
@RestController
@RequestMapping(value = "articleDict")
@Api(value = "app文章管理接口",  tags = {"app文章管理接口"})
public class ArticleDictEndpoint extends EnvelopRestEndpoint {
	
	@Autowired
	private KnowledgeArticleDictService knowledgeArticleDictService;
	@Autowired
	private KnowledgeArticleDictDao knowledgeArticleDictDao;
	@Autowired
	private BaseDoctorDao doctorDao;
	@Autowired
	private BaseDoctorRoleDao doctorRoleDao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private BaseMenuManageService menuManageService;
	
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.searchKnowledgePageList)
	@ApiOperation(value = "获取文章列表")
	public Envelop searchKnowledgePageList(
			@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
			@RequestParam(value = "fields", required = false) String fields,
			@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
			@RequestParam(value = "filters", required = false) String filters,
			@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
			@RequestParam(value = "sorts", required = false) String sorts,
			@ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
			@RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
			@ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
			@RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize)throws Exception{
		try {
			String userId=getUID();
			BaseDoctorRoleDO roleDO = doctorRoleDao.findByDoctorCodeAndRoleCode(userId, CommonContant.DR_ARTICLEREVIEWER);
			boolean queryAll=false;
			if (roleDO!=null){
				queryAll=true;
			}
			if (queryAll){
				if(StringUtils.isBlank(filters)){
					filters=filters+"del=1";
				}else{
					filters=filters+";del=1";
				}
			}else {
				if(StringUtils.isBlank(filters)){
					filters=filters+"del=1"+";createUser="+userId+"";
				}else{
					filters=filters+";del=1"+";createUser="+userId+"";
				}
			}
			filters += ";type=2";
			List<KnowledgeArticleDictDO> list  = knowledgeArticleDictService.search(fields,filters,sorts,page,pageSize);
			for (KnowledgeArticleDictDO articleDictDO:list){
				JSONObject object = menuManageService.findArticleStaticsByArticleId(articleDictDO.getId());
				if (object!=null){
					articleDictDO.setCollection(Integer.parseInt(object.getString("collectTotal")));
					articleDictDO.setComment(Integer.parseInt(object.getString("commentTotal")));
					articleDictDO.setFabulous(Integer.parseInt(object.getString("eulogyTotal")));
				}
			}
			List<KnowledgeArticleDictDO> totals  = knowledgeArticleDictService.search(fields,filters,sorts);
			JSONObject result = new JSONObject();
			result.put("total",totals.size());
			result.put("detailModelList",list);
			return success(result);
		}catch (Exception e){
			return failedException2(e);
		}
	}
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.searchKnowledgeList)
	@ApiOperation(value = "获取文章列表")
	public Envelop searchKnowledgeList(
			@ApiParam(name = "first", value = "second")
			@RequestParam(value = "first", required = false) String first,
			@ApiParam(name = "second", value = "second")
			@RequestParam(value = "second", required = false) String second,
			@ApiParam(name = "key", value = "关键字")
			@RequestParam(value = "key", required = false) String key,
			@ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
			@RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
			@ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
			@RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize){
		try {
			return success(knowledgeArticleDictService.findArticleList(first,second,2,key,page,pageSize));
		}catch (Exception e){
			return failedException2(e);
		}
	}
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.queryById)
	@ApiOperation(value = "根据id查询文章")
	public Envelop queryByCode(
			@ApiParam(name = "id", value = "id", required = true)
			@RequestParam(value = "id", required = true)String id){
		try {
			KnowledgeArticleDictDO articleDO = knowledgeArticleDictDao.findOne(id);
			return success(articleDO);
		}catch (Exception e){
			return failedException2(e);
		}
	}
	
	@PostMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.deleteById)
	@ApiOperation(value = "根据id删除文章")
	public Envelop deleteById(
			@ApiParam(name = "id", value = "id,多个使用英文逗号分隔", required = true)
			@RequestParam(value = "id", required = true)String id){
			try {
				knowledgeArticleDictService.delArticle(id);
				return success("操作成功");
			}catch (Exception e){
				return failedException2(e);
			}
	}
	
	@PostMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.saveArticle)
	@ApiOperation(value = "保存/更新文章")
	public Envelop saveArticle(
			@ApiParam(name = "jsonData", value = "Json数据", required = true)
			@RequestParam String jsonData) {
		try {
			knowledgeArticleDictService.saveArticle(jsonData,2);
			return success("操作成功");
		}catch (Exception e){
			e.printStackTrace();
			return failedException2(e);
		}
	}
	@GetMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.findArticleStaticsByDoctorId)
	@ApiOperation(value = "获取doctorId获取医生发布的文章统计数据")
	public Envelop findArticleStaticsByDoctorId(
			@ApiParam(name = "doctorId", value = "医生id", required = true)
			@RequestParam String doctorId) {
		try {
			return success("查询成功",knowledgeArticleDictService.findArticleStaticsByDoctorId(doctorId));
		}catch (Exception e){
			e.printStackTrace();
			return failedException2(e);
		}
	}
	
	@PostMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.reviewArticle)
	@ApiOperation(value = "审核/退回文章")
	public Envelop saveArticle(
			@ApiParam(name = "articleId", value = "文章ID")
			@RequestParam(value = "articleId", required = true) String articleId,
			@ApiParam(name = "status", value = "0未审核,1已审核,2退回")
			@RequestParam(value = "status", required = true) Integer status,
			@ApiParam(name = "reason", value = "退回理由")
			@RequestParam(value = "reason", required = false) String reason
	){
		try {
			knowledgeArticleDictService.reviewArticle(articleId,status,reason);
			return success("操作成功");
		}catch (Exception e){
			return failedException2(e);
		}
	}
	@PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.setArticleUsed)
	@ApiOperation(value = "发布文章")
	public ObjEnvelop setArticleUsed(@ApiParam(name = "id", value = "文章id")
									  @RequestParam(value = "id",required = true)String id,
									  @ApiParam(name = "status", value = "1发布0未发布")
									  @RequestParam(value = "status",required = false)Integer status){
		try {
			return success(knowledgeArticleDictService.releaseArticle(id,status));
		}catch (Exception e){
			return failedObjEnvelopException2(e);
		}
	}
	//居民免登录
	@GetMapping(value = "open/searchKnowledgePageList")
	@ApiOperation(value = "获取文章列表")
	public Envelop searchKnowledgePageListOpen(
			@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
			@RequestParam(value = "fields", required = false) String fields,
			@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
			@RequestParam(value = "filters", required = false) String filters,
			@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
			@RequestParam(value = "sorts", required = false) String sorts,
			@ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
			@RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
			@ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
			@RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize)throws Exception{
		try {
			if(StringUtils.isBlank(filters)){
				filters=filters+"del=1;type=2;status=1";
			}else{
				filters=filters+";del=1;type=2;status=1";
			}
			List<KnowledgeArticleDictDO> list  = knowledgeArticleDictService.search(fields,filters,sorts,page,pageSize);
			List<KnowledgeArticleDictDO> totals  = knowledgeArticleDictService.search(fields,filters,sorts);
			JSONObject result = new JSONObject();
			result.put("total",totals.size());
			result.put("detailModelList",list);
			return success(result);
		}catch (Exception e){
			return failedException2(e);
		}
	}
	@GetMapping(value = "open/queryById")
	@ApiOperation(value = "根据id查询文章")
	public Envelop queryByCodeOpen(
			@ApiParam(name = "id", value = "id", required = true)
			@RequestParam(value = "id", required = true)String id){
		try {
			KnowledgeArticleDictDO articleDO = knowledgeArticleDictDao.findOne(id);
			return success(articleDO);
		}catch (Exception e){
			return failedException2(e);
		}
	}
}

+ 1 - 5
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.endpoint.article;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
@ -9,7 +10,6 @@ import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.service.consult.BasePatientBusinessService;
import com.yihu.jw.hospital.service.consult.KnowledgeArticleService;
import com.yihu.jw.hospital.service.consult.KnowledgeArticleUserService;
@ -23,15 +23,11 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.apache.commons.collections.IteratorUtils;
import org.apache.commons.lang.StringUtils;
import org.jboss.netty.handler.codec.http.multipart.MixedAttribute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**

+ 281 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuManageEndpoint.java

@ -0,0 +1,281 @@
package com.yihu.jw.hospital.endpoint.article;
import com.yihu.jw.article.service.BaseMenuManageService;
import com.yihu.jw.entity.base.menu.BaseMenuDictDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDoctorDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author yeshijie on 2018/9/26.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.MenuDict.PREFIX)
@Api(value = "app文章分类管理", tags = {"app文章分类管理"})
public class BaseMenuManageEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseMenuManageService menuService;
    @PostMapping(value = "setCollection")
    @ApiOperation(value = "设置文章状态")
    public ObjEnvelop setCollection(@ApiParam(name = "id", value = "文章id")
                                           @RequestParam(value = "id",required = true)String id,
                                           @ApiParam(name = "flag", value = "1收藏2阅读3点赞4分享")
                                           @RequestParam(value = "flag",required = true)Integer flag,
                                           @ApiParam(name = "status", value = "收藏(1收藏0未收藏)/阅读(1已读0未读)/点赞(1已赞0未赞)分享(1已分享0未分享)")
                                           @RequestParam(value = "status",required = true)Integer status,
                                           @ApiParam(name = "user", value = "用户code")
                                           @RequestParam(value = "user",required = true)String user,
                                           @ApiParam(name = "userType", value = "用户类型(1患者2医生)")
                                           @RequestParam(value = "userType",required = true)String userType)throws Exception {
        try {
            return success(menuService.setCollectionById(id,flag,status,user,userType));
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @PostMapping(value = BaseRequestMapping.MenuDict.deleteMenuDict)
    @ApiOperation(value = "删除菜单")
    public Envelop deleteMenuDict(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) {
        try {
            menuService.deletMenuDict(id);
            return success("删除成功");
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = BaseRequestMapping.MenuDict.createMenuDict)
    @ApiOperation(value = "新建或修改")
    public Envelop create (
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) {
        try {
            BaseMenuDictDO baseMenuDictDO = menuService.createOrUpdateMenu(jsonData,2);
            return success(baseMenuDictDO);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseRequestMapping.MenuDict.findOneMenuDict)
    @ApiOperation(value = "根据id查询链接单条")
    public Envelop findOneMenuDict(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id,
            @ApiParam(name = "patient", value = "居民id", required = false)
            @RequestParam(value = "patient", required = false) String patient) {
        try {
            return success(menuService.findOneMenuDict(id,patient));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = BaseRequestMapping.MenuDict.MOVE_DOWN)
    @ApiOperation(value = "下移")
    public Envelop moveDown(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) {
        try {
            BaseMenuDictDO baseMenuDictDO = menuService.downMenu(id);
            return success(baseMenuDictDO);
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = BaseRequestMapping.MenuDict.MOVE_UP)
    @ApiOperation(value = "上移")
    public Envelop moveUp(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) {
        try {
            BaseMenuDictDO baseMenuDictDO = menuService.upMenu(id);
            return success(baseMenuDictDO);
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = BaseRequestMapping.MenuDict.STATUS)
    @ApiOperation(value = "生效/失效")
    public Envelop status(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id,
            @ApiParam(name = "status", value = "1生效,0失效", required = true)
            @RequestParam(value = "status") Integer status) {
        try {
            menuService.updateStatus(id, status);
            return success("修改成功");
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseRequestMapping.MenuDict.LIST)
    @ApiOperation(value = "查询菜单字典列表")
    public Envelop findMenuDictByKey(
            @ApiParam(name = "parentId", value = "parentId", required = false)
            @RequestParam(value = "parentId",required = false) String parentId,
            @ApiParam(name = "name", value = "name", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "status", value = "status", required = false)
            @RequestParam(value = "status",required = false) Integer status) {
        try {
            return success(menuService.findMenuDictByKey(parentId, name,status,2));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.updateArticleUser)
    @ApiOperation(value = "患者更新文章状态")
    public Envelop updateArticleUser( @ApiParam(name = "flag", value = "1点赞2收藏3常用4分享5阅读")
                                      @RequestParam(value = "flag",required = false)Integer flag,
                                      @ApiParam(name = "articleId", value = "文章id")
                                      @RequestParam(value = "articleId",required = false)String articleId,
                                      @ApiParam(name = "userCode", value = "用户编码")
                                      @RequestParam(value = "userCode",required = false)String userCode,
                                      @ApiParam(name = "status", value = "对应的状态(0,1)")
                                      @RequestParam(value = "status",required = false)Integer status)throws Exception {
        try {
            return success(menuService.updateArticleUser(flag,articleId,userCode,status));
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.selectMenuList)
    @ApiOperation(value = "查询患者关注文章列表分类")
    public Envelop selectMenuList( @ApiParam(name = "flag", value = "1点赞2收藏3常用4分享5阅读")
                                      @RequestParam(value = "flag",required = false)Integer flag,
                                      @ApiParam(name = "userCode", value = "用户编码")
                                      @RequestParam(value = "userCode",required = false)String userCode,
                                      @ApiParam(name = "status", value = "对应的状态(0,1)")
                                      @RequestParam(value = "status",required = false)Integer status)throws Exception {
        try {
            return success(menuService.selectMenuList(userCode,flag,status));
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.selectArticleListByCategory)
    @ApiOperation(value = "根据分类查找患者关注文章列表")
    public Envelop selectArticleListByCategory( @ApiParam(name = "categoryFirst", value = "一级分类")
                                       @RequestParam(value = "categoryFirst",required = false)String categoryFirst,
                                   @ApiParam(name = "categorySecond", value = "二级分类")
                                   @RequestParam(value = "categorySecond",required = false)String categorySecond,
                                   @ApiParam(name = "flag", value = "1点赞2收藏3常用4分享5阅读")
                                   @RequestParam(value = "flag",required = false)Integer flag,
                                   @ApiParam(name = "userCode", value = "用户编码")
                                   @RequestParam(value = "userCode",required = false)String userCode,
                                   @ApiParam(name = "status", value = "对应的状态(0,1)")
                                   @RequestParam(value = "status",required = false)Integer status,
                                   @ApiParam(name = "page", value = "页码")
                                       @RequestParam(value = "page",required = false)Integer page,
                                   @ApiParam(name = "size", value = "每一页大小")
                                       @RequestParam(value = "size",required = false)Integer size)throws Exception {
        try {
            return success(menuService.selectArticleListByCategory(categoryFirst,categorySecond,userCode,flag,status,page,size));
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.findArticleUserById)
    @ApiOperation(value = "查询患者关联的文章")
    public Envelop selectArticleListByCategory(@ApiParam(name = "userCode", value = "用户编码")
                                                @RequestParam(value = "userCode",required = false)String userCode,
                                                @ApiParam(name = "articleId", value = "文章id")
                                                @RequestParam(value = "articleId",required = false)String articleId)throws Exception {
        try {
            return success(menuService.findArticleUserById(userCode,articleId));
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.insertArticleOperate)
    @ApiOperation(value = "新增医生文章/医生操作(评论、点赞、收藏)")
    public Envelop insert(@ApiParam(name = "json", value = "json实体")
                          @RequestParam(value = "json",required = false)String json)throws Exception {
        try {
            KnowledgeArticleDoctorDO knowledgeArticleDoctorDO = toEntity(json,KnowledgeArticleDoctorDO.class);
            return success(menuService.insert(knowledgeArticleDoctorDO));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.deleteArticleDoctorById)
    @ApiOperation(value = "取消点赞/收藏")
    public Envelop deleteArticleDoctorById(@ApiParam(name = "baseArticleDoctorId", value = "评论id")
                                            @RequestParam(value = "baseArticleDoctorId",required = false)String baseArticleDoctorId,
                                           @ApiParam(name = "relationCode", value = "文章id")
                                           @RequestParam(value = "relationCode",required = false)String relationCode,
                                           @ApiParam(name = "type", value = "类型2点赞3收藏")
                                               @RequestParam(value = "type",required = false)Integer type,
                                           @ApiParam(name = "user", value = "用户编码")
                                               @RequestParam(value = "user",required = false)String user)throws Exception {
        try {
            menuService.deleteArticleDoctorById(baseArticleDoctorId,relationCode,type,user);
            return success();
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.selectArticleDoctorById)
    @ApiOperation(value = "查询医生关联文章回复数据")
    public Envelop selectArticleDoctorById(@ApiParam(name = "user", value = "用户id")
                                               @RequestParam(value = "user",required = false)String user,
                                           @ApiParam(name = "id", value = "文章id")
                                           @RequestParam(value = "id",required = false)String id,
                                           @ApiParam(name = "page", value = "当前页")
                                           @RequestParam(value = "page",required = false)Integer page,
                                           @ApiParam(name = "size", value = "分页大小)")
                                           @RequestParam(value = "size",required = false)Integer size)throws Exception {
        try {
            return success(menuService.selectArticleDoctorById(user,id,1,page,size));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.selectArticleDoctorByArticleIdAndUser)
    @ApiOperation(value = "判断该文章当前医生是否点赞或者收藏")
    public Envelop selectArticleDoctorByArticleIdAndUser(@ApiParam(name = "id", value = "文章id")
                                                         @RequestParam(value = "id",required = false)String id,
                                                         @ApiParam(name = "user", value = "用户编码")
                                                         @RequestParam(value = "user",required = false)String user)throws Exception {
        try {
            return success(menuService.selectArticleDoctorByArticleIdAndUser(id,user));
        }catch (Exception e){
            return failedException(e);
        }
    }
}

+ 106 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuNoLoginEndpoint.java

@ -0,0 +1,106 @@
package com.yihu.jw.hospital.endpoint.article;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.service.BaseMenuManageService;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = BaseRequestMapping.MenuNologin.PREFIX+"/article")
@Api(value = "首页菜单管理免登录接口", description = "首页菜单管理免登录接口", tags = {"基础服务 - 首页菜单管理免登录接口"})
public class BaseMenuNoLoginEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseMenuManageService menuService;
    @Resource
    private KnowledgeArticleDictDao knowledgeArticleDictDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @GetMapping(value = BaseRequestMapping.MenuNologin.findAllMenu)
    @ApiOperation(value = "查询首页列表")
    public Envelop findMenuShowByKey(
            @ApiParam(name = "parentId", value = "parentId", required = false)
            @RequestParam(value = "parentId",required = false) String parentId,
            @ApiParam(name = "name", value = "name", required = false)
            @RequestParam(value = "name",required = false) String name) {
        try {
            return success(menuService.findMenuShow());
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseRequestMapping.MenuNologin.findMenuByParentId)
    @ApiOperation(value = "查询二级菜单")
    public Envelop findMenuByParentId(
            @ApiParam(name = "parentId", value = "parentId", required = false)
            @RequestParam(value = "parentId",required = false) String parentId,
            @ApiParam(name = "status", value = "status", required = false)
            @RequestParam(value = "status",required = false) Integer status) {
        try {
            return success(menuService.findByParentId(parentId,status));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseRequestMapping.MenuNologin.findArticleByMenuId)
    @ApiOperation(value = "查询文章")
    public Envelop findArticleByMenuid(
            @ApiParam(name = "menuId", value = "menuId", required = false)
            @RequestParam(value = "menuId",required = true) String menuId,
            @ApiParam(name = "title", value = "menuId", required = false)
            @RequestParam(value = "title",required = false) String title,
            @ApiParam(name = "page", value = "page", required = false)
            @RequestParam(value = "page",required = true) Integer page,
            @ApiParam(name = "pageSize", value = "pageSize", required = false)
            @RequestParam(value = "pageSize",required = true) Integer pageSize) {
        try {
            return success(menuService.findArticleByMenuId(menuId,title,page,pageSize,"0"));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseRequestMapping.MenuNologin.queryById)
    @ApiOperation(value = "根据id查询文章")
    public Envelop queryByCode(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id", required = true)String id) throws Exception{
        try {
            KnowledgeArticleDictDO articleDO = knowledgeArticleDictDao.findOne(id);
            String recommendDoctor = articleDO.getRecommendDoctor();
            if (recommendDoctor!=null&&recommendDoctor!=""){
                recommendDoctor = recommendDoctor.replace(",","','");
                String sql = "select d.id,\n" +
                        "\td.NAME as name,\n" +
                        "\td.job_title_code AS jobTitleCode,\n" +
                        "\td.job_title_name AS jobTitleName,\n" +
                        "\tCONCAT(dh.dept_name) as deptName,\n" +
                        "\td.introduce as introduce,\n" +
                        "\td.expertise as expertise,\n" +
                        "\td.photo from base_doctor d LEFT JOIN base_doctor_hospital dh ON dh.doctor_code= d.id where d.id in ('"+recommendDoctor+"') GROUP BY d.id ";
                List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
                articleDO.setDoctorList(mapList);
            }
            return success(articleDO);
        }catch (Exception e){
            return failedException(e);
        }
    }
}

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.endpoint.patient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.dict.service.BaseDictJobTitleService;
import com.yihu.jw.dict.service.HospitalDeptService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -32,7 +33,6 @@ import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.healthUpload.service.BaseDoctorHealthUploadService;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;

+ 1 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/BasePatientBusinessService.java

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.service.consult;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
@ -8,7 +9,6 @@ import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.service.SurveyService;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
@ -16,12 +16,10 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.survey.WlyySurveyLabelInfoVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.provider.HibernateUtils;
import org.springframework.stereotype.Service;
import java.util.Date;

+ 2 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java

@ -2,6 +2,8 @@ package com.yihu.jw.hospital.service.consult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleDeptDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -14,8 +16,6 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDeptDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.dao.SurveyUserDao;

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleUserService.java

@ -1,7 +1,7 @@
package com.yihu.jw.hospital.service.consult;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;

+ 0 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java

@ -12,12 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * 健康文章分类