Просмотр исходного кода

Merge branch 'dev' of huangwenjie/wlyy2.0 into dev

huangwenjie 5 лет назад
Родитель
Сommit
a18c6d3e4f

+ 56 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDeptDO.java

@ -0,0 +1,56 @@
package com.yihu.jw.entity.hospital.article;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 健康文章部门关系表
 * @author huangwenjie
 * @date 2019/9/18 10:00
 */
@Entity
@Table(name = "wlyy_knowledge_article_dept")
public class KnowledgeArticleDeptDO extends UuidIdentityEntity {
	
	/**
	 * 文章ID
	 */
	private String articleId;
	
	/**
	 * 部门
	 */
	private String dept;
	
	/**
	 * 部门名称
	 */
	private String deptName;
	
	
	public String getDept() {
		return dept;
	}
	
	public void setDept(String dept) {
		this.dept = dept;
	}
	
	public String getDeptName() {
		return deptName;
	}
	
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	
	public String getArticleId() {
		return articleId;
	}
	
	public void setArticleId(String articleId) {
		this.articleId = articleId;
	}
}

+ 65 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeCategoryDO.java

@ -0,0 +1,65 @@
package com.yihu.jw.entity.hospital.article;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康文章分类
 * @author huangwenjie
 */
@Entity
@Table(name = "wlyy_knowledge_category")
public class KnowledgeCategoryDO extends UuidIdentityEntity {
	private String name;    // 分类名称
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date createTime;  // 添加时间
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date updateTime;  // 编辑时间
	private Integer del;    // 是否删除,1正常,0删除'
	private Long pid;   // 父id
	
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Date getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	public Date getUpdateTime() {
		return updateTime;
	}
	
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	public Integer getDel() {
		return del;
	}
	
	public void setDel(Integer del) {
		this.del = del;
	}
	
	public Long getPid() {
		return pid;
	}
	
	public void setPid(Long pid) {
		this.pid = pid;
	}
}

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

@ -442,6 +442,9 @@ public class BaseHospitalRequestMapping {
        //添加/修改文章
        public static final String saveArticle  = "/saveArticle";
    
        //审核/退回文章
        public static final String reviewArticle  = "/reviewArticle";
    
        //新增/修改分类
        public static final String saveCategory  = "/saveCategory";
        
@ -450,6 +453,18 @@ public class BaseHospitalRequestMapping {
        
        //根据分类code删除分类
        public static final String updateDel  = "/updateDel";
    
        //设置文章发送的科室
        public static final String saveArticleDept  = "/saveArticleDept";
    
        //根据文章查找科室
        public static final String findDeptByArticle  = "/findDeptByArticle";
    
        //根据科室查找文章
        public static final String findArticleByDept  = "/findArticleByDept";
    
        //设置部门发送文章
        public static final String saveDeptArticle  = "/saveDeptSurvey";
        
        
    }

+ 6 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeArticleDao.java

@ -2,7 +2,11 @@ package com.yihu.jw.hospital.dao.consult;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * 健康文章DAO
@ -10,4 +14,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * @date 2019/9/10 14:07
 */
public interface KnowledgeArticleDao extends PagingAndSortingRepository<KnowledgeArticleDO, String>, JpaSpecificationExecutor<KnowledgeArticleDO> {
	@Query("select a from KnowledgeArticleDO a where a.del=1 and category = :category")
	List<KnowledgeArticleDO> findByCategory(@Param("category") String category);
}

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

@ -0,0 +1,19 @@
package com.yihu.jw.hospital.dao.consult;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 健康文章部门关系DAO
 * @author huangwenjie
 * @date 2019/9/18 10:03
 */
public interface KnowledgeArticleDeptDao extends PagingAndSortingRepository<KnowledgeArticleDeptDO, String>, JpaSpecificationExecutor<KnowledgeArticleDeptDO> {
	
	List<KnowledgeArticleDeptDO> findByArticleId(String articleId);
	
	List<KnowledgeArticleDeptDO> findByDept(String dept);
}

+ 18 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeCategoryDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.hospital.dao.consult;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
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;
import org.springframework.data.repository.query.Param;
/**
 * 健康文章分类
 * @author huangwenjie
 */
public interface KnowledgeCategoryDao extends PagingAndSortingRepository<KnowledgeCategoryDO, String>, JpaSpecificationExecutor<KnowledgeCategoryDO> {
	@Query("update KnowledgeCategoryDO c set c.del = 0 where c.id = :id")
	@Modifying
	void updateDel(@Param("id") String id);
}

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

@ -1,9 +1,12 @@
package com.yihu.jw.hospital.endpoint.article;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.hospital.service.consult.KnowledgeArticleService;
import com.yihu.jw.hospital.service.consult.KnowledgeCategoryService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
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;
@ -26,6 +29,9 @@ public class ArticleEndpoint extends EnvelopRestEndpoint {
	@Autowired
	private KnowledgeArticleService  knowledgeArticleService;
	
	@Autowired
	private KnowledgeCategoryService knowledgeCategoryService;
	
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.searchKnowledgePageList)
	@ApiOperation(value = "获取文章列表")
	public ListEnvelop searchKnowledgePageList(
@ -81,4 +87,89 @@ public class ArticleEndpoint extends EnvelopRestEndpoint {
		knowledgeArticleService.saveArticle(jsonData);
		return success("操作成功");
	}
	
	@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
	)throws Exception {
		knowledgeArticleService.reviewArticle(articleId,status);
		return success("操作成功");
	}
	
	
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.searchCategoryList)
	@ApiOperation(value = "获取分类列表")
	public ListEnvelop searchCategoryList(
			@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{
		List<KnowledgeCategoryDO> result  = knowledgeCategoryService.search(fields,filters,sorts,page,pageSize);
		return success(result);
	}
	
	@PostMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.saveCategory)
	@ApiOperation(value = "保存/更新分类")
	public Envelop saveCategory(
			@ApiParam(name = "jsonData", value = "Json数据", required = true)
			@RequestParam String jsonData)throws Exception {
		knowledgeCategoryService.saveCategory(jsonData);
		return success("操作成功");
	}
	
	@PostMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.updateDel)
	@ApiOperation(value = "根据分类code删除分类")
	public Envelop updateDel(
			@ApiParam(name = "id", value = "id", required = true)
			@RequestParam(value = "id", required = true)String id)throws Exception {
		Boolean flag = knowledgeCategoryService.updateDel(id);
		if (!flag) {
			return success("操作成功");
		}else{
			return failed("操作失败");
		}
		
	}
	@PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.saveArticleDept)
	@ApiOperation(value = "设置文章发送的科室")
	public ObjEnvelop saveArticleDept(@ApiParam(name = "articleId", value = "文章ID")
	                                 @RequestParam(value = "articleId",required = true)String articleId,
	                                 @ApiParam(name = "sdJsons", value = "部门与科室关系json")
	                                 @RequestParam(value = "sdJsons",required = true)String sdJsons)throws Exception {
		return success(knowledgeArticleService.saveArticleDept(articleId,sdJsons));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.findDeptByArticle)
	@ApiOperation(value = "查询文章下的科室")
	public ListEnvelop findDeptByArticle(@ApiParam(name = "articleId", value = "文章ID")
	                                    @RequestParam(value = "articleId",required = true)String articleId)throws Exception {
		return success(knowledgeArticleService.findDeptByArticle(articleId));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.findArticleByDept)
	@ApiOperation(value = "查询部门下发放的文章")
	public ListEnvelop findArticleByDept(@ApiParam(name = "dept", value = "科室")
	                                    @RequestParam(value = "dept",required = true)String dept)throws Exception {
		return success(knowledgeArticleService.findArticleByDept(dept));
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.saveDeptArticle)
	@ApiOperation(value = "设置科室发送的文章")
	public ObjEnvelop saveDeptArticle(@ApiParam(name = "dept", value = "部门code")
	                                 @RequestParam(value = "dept",required = true)String dept,
	                                 @ApiParam(name = "sdJsons", value = "部门与科室关系json")
	                                 @RequestParam(value = "sdJsons",required = false)String sdJsons)throws Exception {
		return success(knowledgeArticleService.saveDeptArticle(dept,sdJsons));
	}
}

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

@ -244,14 +244,14 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "when", value = "发病时间")
			@RequestParam(value = "when",required = true) String when,
			@RequestParam(value = "when",required = false) String when,
			@ApiParam(name = "symptoms", value = "主述")
			@RequestParam(value = "symptoms",required = false) String symptoms,
			@ApiParam(name = "images", value = "图片")
			@RequestParam(value = "images",required = false) String images,
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "type", value = "咨询类型:1专家咨询")
			@ApiParam(name = "type", value = "咨询类型:1专家咨询 14导诊助手")
			@RequestParam(value = "type",required = false) Integer type)throws Exception{
		
		System.out.println("symptoms="+symptoms);
@ -264,7 +264,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
//		}
		
		ConsultTeamDo consult = new ConsultTeamDo();
		// 设置咨询类型:9:在线复诊  13专家咨询
		// 设置咨询类型:1专家咨询  14导诊助手
		consult.setType(type);
		// 设置发病时间
		consult.setWhen(when);
@ -279,7 +279,8 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
//		int res = 0;
//		JSONArray dts = null;
		synchronized (patient.intern()){//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
			JSONObject re = imService.addTeamConsult(consult, patient,doctor);
			JSONObject re = null;
			re = imService.addTeamConsult(consult, patient,doctor);
//			res = re.getInteger("status");
//			dts = re.containsKey("doctor")?re.getJSONArray("doctor"):null;
		}

+ 0 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/survey/SurveyEndpoint.java

@ -2,7 +2,6 @@ package com.yihu.jw.hospital.endpoint.survey;
import com.yihu.jw.hospital.survey.service.SurveyService;
import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;

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

@ -1,7 +1,10 @@
package com.yihu.jw.hospital.service.consult;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyDeptDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDeptDao;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
@ -9,6 +12,8 @@ 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;
/**
@ -22,6 +27,9 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
	@Autowired
	private KnowledgeArticleDao knowledgeArticleDao;
	
	@Autowired
	private KnowledgeArticleDeptDao knowledgeArticleDeptDao;
	
	/**
	 * 删除,支持批量
	 * @param id
@ -63,4 +71,104 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
			return  one;
		}
	}
	
	//审核/退回文章
	public KnowledgeArticleDO reviewArticle(String articleId,Integer status) throws Exception{
		
		KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findOne(articleId);
		if (null == knowledgeArticleDO) {
			throw new Exception("该文章不存在");
		} else {
			knowledgeArticleDO.setStatus(status);
			knowledgeArticleDO.setUpdateTime(new Date());
			knowledgeArticleDao.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, " +
				" t.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;
	}
}

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

@ -0,0 +1,59 @@
package com.yihu.jw.hospital.service.consult;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeCategoryDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * 健康文章分类
 * @author huangwenjie
 */
@Service
public class KnowledgeCategoryService extends BaseJpaService<KnowledgeCategoryDO, KnowledgeCategoryDao> {
	@Autowired
	private KnowledgeCategoryDao knowledgeCategoryDao;
	@Autowired
	private KnowledgeArticleDao articleDao;
	
	@Autowired
	private ObjectMapper objectMapper;
	
	public KnowledgeCategoryDO saveCategory(String jsonData) throws Exception {
		jsonData = URLDecoder.decode(jsonData,"utf-8");
		KnowledgeCategoryDO knowledgeCategoryDO = objectMapper.readValue(jsonData, KnowledgeCategoryDO.class);
		if (null == knowledgeCategoryDO.getPid()) {
			knowledgeCategoryDO.setPid(0l);
		}
		if (null == knowledgeCategoryDO.getId()) {
			// 新增
			knowledgeCategoryDO.setCreateTime(new Date());
			knowledgeCategoryDO.setDel(1);
		} else {
			KnowledgeCategoryDO one = knowledgeCategoryDao.findOne(knowledgeCategoryDO.getId());
			knowledgeCategoryDO.setId(one.getId());
			knowledgeCategoryDO.setDel(one.getDel());
			knowledgeCategoryDO.setUpdateTime(new Date());
		}
		return knowledgeCategoryDao.save(knowledgeCategoryDO);
	}
	
	public Boolean updateDel(String code) {
		List<KnowledgeArticleDO> byCategory = articleDao.findByCategory(code);
		if (null != byCategory && byCategory.size() > 0) {
			return false;
		}
		knowledgeCategoryDao.updateDel(code);
		return true;
	}
}