Pārlūkot izejas kodu

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangjun 4 gadi atpakaļ
vecāks
revīzija
150acd1633

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/doctor/dao/BaseDoctorBackgroundDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.hospital.doctor.dao;
import com.yihu.jw.entity.base.doctor.BaseDoctorBackgroundDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 *
 */
public interface BaseDoctorBackgroundDao extends PagingAndSortingRepository<BaseDoctorBackgroundDO, String>, JpaSpecificationExecutor<BaseDoctorBackgroundDO> {
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
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;
/**
 *
 */
public interface BasePatientBusinessDao extends PagingAndSortingRepository<BasePatientBusinessDO, String>, JpaSpecificationExecutor<BasePatientBusinessDO> {
    @Query("select a from BasePatientBusinessDO a where a.del=1 and a.id=?1")
    BasePatientBusinessDO findByIdAndDel(String id);
}

+ 2 - 2
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -1482,7 +1482,7 @@ public class ImService {
		net.sf.json.JSONObject data = new net.sf.json.JSONObject();
		data.put("name",patient.getName());
		data.put("age",IdCardUtil.getAgeForIdcard(patient.getIdcard()));
		data.put("gender",patient.getSex().toString());
		data.put("gender", StringUtils.isEmpty(patient.getSex())?null:patient.getSex().toString());
		data.put("question",consultTeam.getSymptoms());
		String type="";
@ -2801,7 +2801,7 @@ public class ImService {
						" left join wlyy_prescription p on p.outpatient_id = op.id "+
					"WHERE op.patient=patient.id " +
					"AND op.doctor='"+doctorCode+"' " +
					"AND op.status in ('0','1') and  op.pay_status=1 ";
					"AND op.status in ('0','1','2') and  op.pay_status=1 ";
			if("9".equals(type)){
				//图文复诊
				sql =sql +"AND op.type=1 AND op.outpatient_type=1 ";

+ 48 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorBackgroundDO.java

@ -0,0 +1,48 @@
package com.yihu.jw.entity.base.doctor;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 医生背景图实体
*
* @author
*
*/
@Entity
@Table(name = "base_doctor_background")
public class BaseDoctorBackgroundDO extends UuidIdentityEntityWithOperator {
    /**
     * 医生code
     */
    private String doctor;
    /**
     * 背景图片地址;
     */
    private String background;
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "background")
    public String getBackground() {
        return background;
    }
    public void setBackground(String background) {
        this.background = background;
    }
}

+ 99 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -2,7 +2,6 @@ package com.yihu.jw.entity.base.doctor;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import org.hibernate.annotations.Where;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -195,6 +194,42 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
     */
    private String fee;
    /**
     * 医生风采图,图片逗号隔开
     */
    private String img;
    /**
     * 医生出诊医院code
     */
    private String visitHospital;
    /**
     * 医生出诊医院名称
     */
    private String visitHospitalName;
    /**
     * 出诊科室code
     */
    private String visitDept;
    /**
     * 出诊科室名称
     */
    private String visitDeptName;
    /**
     * 背景图片
     */
    private String background;
    /**
     * 背景图片code
     */
    private String backgroundId;
	@Column(name = "password")
    public String getPassword() {
        return password;
@ -477,4 +512,67 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    public void setFee(String fee) {
        this.fee = fee;
    }
    @Column(name = "img")
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    @Column(name = "visit_hospital")
    public String getVisitHospital() {
        return visitHospital;
    }
    public void setVisitHospital(String visitHospital) {
        this.visitHospital = visitHospital;
    }
    @Column(name = "visit_hospital_name")
    public String getVisitHospitalName() {
        return visitHospitalName;
    }
    public void setVisitHospitalName(String visitHospitalName) {
        this.visitHospitalName = visitHospitalName;
    }
    @Column(name = "visit_dept")
    public String getVisitDept() {
        return visitDept;
    }
    public void setVisitDept(String visitDept) {
        this.visitDept = visitDept;
    }
    @Column(name = "visit_dept_name")
    public String getVisitDeptName() {
        return visitDeptName;
    }
    public void setVisitDeptName(String visitDeptName) {
        this.visitDeptName = visitDeptName;
    }
    @Column(name = "background")
    public String getBackground() {
        return background;
    }
    public void setBackground(String background) {
        this.background = background;
    }
    @Column(name = "background_id")
    public String getBackgroundId() {
        return backgroundId;
    }
    public void setBackgroundId(String backgroundId) {
        this.backgroundId = backgroundId;
    }
}

+ 205 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientBusinessDO.java

@ -0,0 +1,205 @@
package com.yihu.jw.entity.base.patient;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 居民业务关联实体
 *
 * @author
 */
@Entity
@Table(name = "base_patient_business")
public class BasePatientBusinessDO extends UuidIdentityEntityWithOperator {
    /**
     * 患者code
     */
    private String patient;
    /**
     * 患者名字
     */
    private String patientName;
    /**
     * 医生code
     */
    private String doctor;
    /**
     * 医生名字
     */
    private String doctorName;
    /**
     * 业务code
     */
    private String relationCode;
    /**
     * 业务名称
     */
    private String relationName;
    /**
     * 业务类型1、文章2、问卷
     */
    private Integer relationType;
    /**
     * 是否收藏
     */
    private Integer collection;
    /**
     * 1已读0未读
     */
    private Integer isRead;
    /**
     * 1已赞,0未赞
     */
    private Integer fabulous;
    /**
     * 1分享0未分享
     */
    private Integer share;
    /**
     * 状态1正常0删除
     */
    private Integer del;
    @Transient
    KnowledgeArticleDO knowledgeArticleDO;
    @Transient
    WlyySurveyTemplateDO wlyySurveyTemplateDO;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    public String getRelationName() {
        return relationName;
    }
    public void setRelationName(String relationName) {
        this.relationName = relationName;
    }
    public Integer getRelationType() {
        return relationType;
    }
    public void setRelationType(Integer relationType) {
        this.relationType = relationType;
    }
    public Integer getCollection() {
        return collection;
    }
    public void setCollection(Integer collection) {
        this.collection = collection;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Transient
    public KnowledgeArticleDO getKnowledgeArticleDO() {
        return knowledgeArticleDO;
    }
    public void setKnowledgeArticleDO(KnowledgeArticleDO knowledgeArticleDO) {
        this.knowledgeArticleDO = knowledgeArticleDO;
    }
    @Transient
    public WlyySurveyTemplateDO getWlyySurveyTemplateDO() {
        return wlyySurveyTemplateDO;
    }
    public void setWlyySurveyTemplateDO(WlyySurveyTemplateDO wlyySurveyTemplateDO) {
        this.wlyySurveyTemplateDO = wlyySurveyTemplateDO;
    }
    public Integer getFabulous() {
        return fabulous;
    }
    public void setFabulous(Integer fabulous) {
        this.fabulous = fabulous;
    }
    public Integer getShare() {
        return share;
    }
    public void setShare(Integer share) {
        this.share = share;
    }
    public Integer getIsRead() {
        return isRead;
    }
    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }
}

+ 69 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDO.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
@ -35,6 +36,16 @@ public class KnowledgeArticleDO extends UuidIdentityEntity {
	private Integer del; // 是否删除,1正常,0删除
	private Integer status;// 0未审核 1已审核
	private String cancelReason;//退回理由
	private Integer used;//1常用0不常用
	private Integer readCount;//已读数
	private Integer collection;//收藏数量
	private Integer fabulous;//点赞数量
	private Integer share;//分享 数量
	@Transient
	private String deptName;
	@Transient
	private String hospitalName;
	
	
	public String getCreateUser() {
@ -172,4 +183,62 @@ public class KnowledgeArticleDO extends UuidIdentityEntity {
	public void setCreateUserDeptName(String createUserDeptName) {
		this.createUserDeptName = createUserDeptName;
	}
	public Integer getUsed() {
		return used;
	}
	public void setUsed(Integer used) {
		this.used = used;
	}
	@Transient
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	@Transient
	public String getHospitalName() {
		return hospitalName;
	}
	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}
	public Integer getCollection() {
		return collection;
	}
	public void setCollection(Integer collection) {
		this.collection = collection;
	}
	public Integer getFabulous() {
		return fabulous;
	}
	public void setFabulous(Integer fabulous) {
		this.fabulous = fabulous;
	}
	public Integer getShare() {
		return share;
	}
	public void setShare(Integer share) {
		this.share = share;
	}
	public Integer getReadCount() {
		return readCount;
	}
	public void setReadCount(Integer readCount) {
		this.readCount = readCount;
	}
}

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

@ -1,8 +1,6 @@
package com.yihu.jw.rm.hospital;
import com.sun.javafx.image.PixelUtils;
/**
 * Created by Trick on 2019/5/16.
 */
@ -1061,7 +1059,18 @@ public class BaseHospitalRequestMapping {
    
        //设置部门发送文章
        public static final String saveDeptArticle  = "/saveDeptArticle";
        
        //发送居民业务
        public static final String sendPatientBusiness  = "/sendPatientBusiness";
        //设置为常用/不常用
        public static final String setArticleUsed  = "/setArticleUsed";
        //获取患者文章列表
        public static final String searchPatientArticle  = "/searchPatientArticle";
        //设置文章状态
        public static final String setArticleCollection  = "/setArticleCollection";
        
    }

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

@ -16,4 +16,8 @@ import java.util.List;
public interface KnowledgeArticleDao extends PagingAndSortingRepository<KnowledgeArticleDO, String>, JpaSpecificationExecutor<KnowledgeArticleDO> {
	@Query("select a from KnowledgeArticleDO a where a.del=1 and (categoryFirst = ?1 or categorySecond=?1)")
	List<KnowledgeArticleDO> findByCategory(String category);
	@Query("select a from KnowledgeArticleDO a where a.del=1 and a.id=?1")
	KnowledgeArticleDO findByIdAndDel(String id);
}

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

@ -1,10 +1,16 @@
package com.yihu.jw.hospital.endpoint.article;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.hospital.service.consult.BasePatientBusinessService;
import com.yihu.jw.hospital.service.consult.KnowledgeArticleService;
import com.yihu.jw.hospital.service.consult.KnowledgeCategoryService;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -34,6 +40,13 @@ public class ArticleEndpoint extends EnvelopRestEndpoint {
	
	@Autowired
	private KnowledgeCategoryService knowledgeCategoryService;
	@Autowired
	private BasePatientBusinessService patientBusinessService;
	@Autowired
	private BaseDoctorHospitalDao doctorHospitalDao;
	@Autowired
	private BasePatientBusinessDao basePatientBusinessDao;
	
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.searchKnowledgePageList)
	@ApiOperation(value = "获取文章列表")
@ -67,6 +80,14 @@ public class ArticleEndpoint extends EnvelopRestEndpoint {
		}
		
		List<KnowledgeArticleDO> list  = knowledgeArticleService.search(fields,filters,sorts,page,pageSize);
		for (KnowledgeArticleDO knowledgeArticleDO:list){
			List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(knowledgeArticleDO.getCreateUser());
			if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
				BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
				knowledgeArticleDO.setDeptName(doctorHospitalDO.getDeptName());
				knowledgeArticleDO.setHospitalName(doctorHospitalDO.getOrgName());
			}
		}
		List<KnowledgeArticleDO> totals  = knowledgeArticleService.search(fields,filters,sorts);
		
		JSONObject result = new JSONObject();
@ -195,4 +216,87 @@ public class ArticleEndpoint extends EnvelopRestEndpoint {
	                                 @RequestParam(value = "sdJsons",required = false)String sdJsons)throws Exception {
		return success(knowledgeArticleService.saveDeptArticle(dept,sdJsons));
	}
	@PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.sendPatientBusiness)
	@ApiOperation(value = "发送文章/问卷")
	public ListEnvelop sendPatientBusiness(@ApiParam(name = "json", value = "患者业务关联表")
									  @RequestParam(value = "json",required = false)String json)throws Exception {
		ListEnvelop listEnvelop = new ListEnvelop();
		JSONArray jsonArray = JSONArray.parseArray(json);
		List<BasePatientBusinessDO> patientBusinessDOList = new ArrayList<>();
		for (int i=0;i<jsonArray.size();i++){
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			BasePatientBusinessDO patientBusinessDO = toEntity(jsonObject.toJSONString(),BasePatientBusinessDO.class);
			patientBusinessDOList.add(patientBusinessDO);
		}
		listEnvelop.setDetailModelList(knowledgeArticleService.sendBusinessToPatient(patientBusinessDOList));
		return  listEnvelop;
	}
	@PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.setArticleUsed)
	@ApiOperation(value = "设置文章为常用/不常用")
	public ObjEnvelop setArticleUsed(@ApiParam(name = "id", value = "文章id")
									  @RequestParam(value = "id",required = true)String id,
									  @ApiParam(name = "used", value = "常用")
									  @RequestParam(value = "used",required = false)Integer used)throws Exception {
		return success(knowledgeArticleService.setUsed(id,used));
	}
	@GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.searchPatientArticle)
	@ApiOperation(value = "获取患者文章列表")
	public Envelop searchPatientArticle(
			@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{
		if(StringUtils.isBlank(filters)){
			filters=filters+"del=1";
		}else{
			filters=filters+";del=1";
		}
		List<BasePatientBusinessDO> list  = patientBusinessService.search(fields,filters,sorts,page,pageSize);
		for (BasePatientBusinessDO patientBusinessDO:list){
			Integer type = patientBusinessDO.getRelationType();
			if (type==1){
				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleService.selectById(patientBusinessDO.getRelationCode());
				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());
					}
				}
				patientBusinessDO.setKnowledgeArticleDO(knowledgeArticleDO);
			}
		}
		List<BasePatientBusinessDO> totals  = patientBusinessService.search(fields,filters,sorts);
		JSONObject result = new JSONObject();
		result.put("total",totals.size());
		result.put("detailModelList",list);
		return success(result);
	}
	@PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.setArticleCollection)
	@ApiOperation(value = "设置文章状态")
	public ObjEnvelop setArticleCollection(@ApiParam(name = "id", value = "文章id")
									 @RequestParam(value = "id",required = true)String id,
									 @ApiParam(name = "flag", value = "1收藏2阅读3点赞4分享")
									 @RequestParam(value = "flag",required = false)Integer flag,
									 @ApiParam(name = "status", value = "收藏(1收藏0未收藏)/阅读(1已读0未读)/点赞(1已赞0未赞)分享(1已分享0未分享)")
									 @RequestParam(value = "status",required = false)Integer status)throws Exception {
		return success(patientBusinessService.setCollectionById(id,flag,status));
	}
}

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

@ -0,0 +1,117 @@
package com.yihu.jw.hospital.service.consult;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 患者文章业务层代码
 */
@Service
public class BasePatientBusinessService extends BaseJpaService<BasePatientBusinessDO, BasePatientBusinessDao> {
	@Autowired
	private BasePatientBusinessDao patientBusinessDao;
	@Autowired
	private KnowledgeArticleDao knowledgeArticleDao;
	/**
	 *
	 * @param id
	 * @param flag 1收藏2阅读3点赞4分享
	 * @param status
	 * @return
	 */
	public BasePatientBusinessDO setCollectionById(String id,Integer flag,Integer status){
		BasePatientBusinessDO patientBusinessDO = patientBusinessDao.findByIdAndDel(id);
		if (patientBusinessDO!=null){
			if (flag!=null&&flag==1){
				patientBusinessDO.setCollection(status);
				patientBusinessDao.save(patientBusinessDO);
				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
				if (knowledgeArticleDO!=null){
					if (knowledgeArticleDO.getCollection()!=null){
						if (status==1){
							knowledgeArticleDO.setCollection(knowledgeArticleDO.getCollection()+1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}else {
							knowledgeArticleDO.setCollection(knowledgeArticleDO.getCollection()-1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}else {
						if (status==1){
							knowledgeArticleDO.setCollection(1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}
				}
			}else if (flag!=null&&flag==2){
				patientBusinessDO.setIsRead(status);
				patientBusinessDao.save(patientBusinessDO);
				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
				if (knowledgeArticleDO!=null){
					if (knowledgeArticleDO.getReadCount()!=null){
						if (status==1){
							knowledgeArticleDO.setReadCount(knowledgeArticleDO.getReadCount()+1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}else {
							knowledgeArticleDO.setReadCount(knowledgeArticleDO.getReadCount()-1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}else {
						if (status==1){
							knowledgeArticleDO.setReadCount(1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}
				}
			}else if (flag!=null&&flag==3){
				patientBusinessDO.setFabulous(status);
				patientBusinessDao.save(patientBusinessDO);
				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
				if (knowledgeArticleDO!=null){
					if (knowledgeArticleDO.getFabulous()!=null){
						if (status==1){
							knowledgeArticleDO.setFabulous(knowledgeArticleDO.getFabulous()+1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}else {
							knowledgeArticleDO.setFabulous(knowledgeArticleDO.getFabulous()-1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}else {
						if (status==1){
							knowledgeArticleDO.setFabulous(1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}
				}
			}else if (flag!=null&&flag==4){
				patientBusinessDO.setShare(status);
				patientBusinessDao.save(patientBusinessDO);
				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
				if (knowledgeArticleDO!=null){
					if (knowledgeArticleDO.getShare()!=null){
						if (status==1){
							knowledgeArticleDO.setShare(knowledgeArticleDO.getShare()+1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}else {
							knowledgeArticleDO.setShare(knowledgeArticleDO.getShare()-1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}else {
						if (status==1){
							knowledgeArticleDO.setShare(1);
							knowledgeArticleDao.save(knowledgeArticleDO);
						}
					}
				}
			}
		}
		return patientBusinessDO;
	}
}

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

@ -1,10 +1,13 @@
package com.yihu.jw.hospital.service.consult;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
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.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDeptDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
@ -29,6 +32,10 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
	
	@Autowired
	private KnowledgeArticleDeptDao knowledgeArticleDeptDao;
	@Autowired
	private WlyyHospitalSysDictDao hospitalSysDictDao;
	@Autowired
	private BasePatientBusinessDao patientBusinessDao;
	
	/**
	 * 删除,支持批量
@ -52,6 +59,7 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
	 * @throws Exception
	 */
	public KnowledgeArticleDO saveArticle(String jsonData) throws  Exception {
		WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("EXAMINE");
		KnowledgeArticleDO knowledgeArticleDO = EntityUtils.jsonToEntity(jsonData, KnowledgeArticleDO.class);
		if (null == knowledgeArticleDO.getId()) {
			// 新增
@ -59,6 +67,10 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
			knowledgeArticleDO.setCreateTime(new Date());
//			knowledgeArticleDO.setSource("客服");
			knowledgeArticleDO.setDel(1);
			if (wlyyHospitalSysDictDO!=null&&wlyyHospitalSysDictDO.getDictValue().equalsIgnoreCase("0")){
				knowledgeArticleDO.setStatus(1);
			}
			knowledgeArticleDO.setUsed(0);
			knowledgeArticleDO = knowledgeArticleDao.save(knowledgeArticleDO);
			return knowledgeArticleDO;
		} else {
@ -67,6 +79,9 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
			one.setContent(knowledgeArticleDO.getContent());
			one.setImage(knowledgeArticleDO.getImage());
			one.setUpdateTime(new Date());
			if (wlyyHospitalSysDictDO!=null&&wlyyHospitalSysDictDO.getDictValue().equalsIgnoreCase("0")){
				one.setStatus(1);
			}
			knowledgeArticleDao.save(one);
			return  one;
		}
@ -174,4 +189,51 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
		}
		return true;
	}
	/**
	 *	患者接收问卷/文章
	 * @param businessDOS
	 * @return
	 */
	public List<BasePatientBusinessDO> sendBusinessToPatient(List<BasePatientBusinessDO> businessDOS){
		if (businessDOS!=null&&businessDOS.size()!=0){
			for (BasePatientBusinessDO patientBusinessDO:businessDOS){
				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);
				patientBusinessDao.save(patientBusinessDO);
			}
		}
		return businessDOS;
	}
	/**
	 * 设置为常用或者不常用
	 * @param id
	 * @param used
	 * @return
	 */
	public KnowledgeArticleDO setUsed(String id,Integer used){
		KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(id);
        if (knowledgeArticleDO!=null){
            knowledgeArticleDO.setUsed(used);
        }
		return knowledgeArticleDao.save(knowledgeArticleDO);
	}
	public KnowledgeArticleDO selectById(String id){
		return knowledgeArticleDao.findByIdAndDel(id);
	}
}