Jelajahi Sumber

代码修改

suqinyi 3 bulan lalu
induk
melakukan
6385cd3a48

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

@ -108,6 +108,14 @@ public class KnowledgeArticleDictDO extends UuidIdentityEntity {
	private String userCollection;
	@Transient
	private String  doctorSendCount;//医生发送次数
	@Transient
	private String  doctorSendPatientSeeCount;//医生发送居民阅读次数
	@Transient
@ -529,4 +537,22 @@ public class KnowledgeArticleDictDO extends UuidIdentityEntity {
	public void setUserCollection(String userCollection) {
		this.userCollection = userCollection;
	}
	@Transient
	public String getDoctorSendCount() {
		return doctorSendCount;
	}
	public void setDoctorSendCount(String doctorSendCount) {
		this.doctorSendCount = doctorSendCount;
	}
	@Transient
	public String getDoctorSendPatientSeeCount() {
		return doctorSendPatientSeeCount;
	}
	public void setDoctorSendPatientSeeCount(String doctorSendPatientSeeCount) {
		this.doctorSendPatientSeeCount = doctorSendPatientSeeCount;
	}
}

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

@ -5,10 +5,8 @@ import com.yihu.jw.article.dao.KnowledgeArticleDao;
import com.yihu.jw.article.dao.KnowledgeArticleDeptDao;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
@ -36,8 +34,6 @@ import org.springframework.stereotype.Service;
import java.util.*;
import static com.yihu.jw.constants.ServiceApi.AppPushMessage.list;
/**
 * 健康文章业务层代码
 *
@ -431,7 +427,7 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
    }
    //查询患者收藏的文章列表
    public JSONObject findPatientFavorite(String patient, String relationType,Integer page, Integer pageSize) {
    public JSONObject findPatientFavorite(String patient, String relationType, 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\"," +
@ -444,8 +440,8 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
        if (StringUtils.isNotEmpty(patient)) {
            sql += " and t.user_code = '" + patient + "'";
        }
        if (StringUtils.isNotBlank(relationType)){
            sql+=" and t.relation_type = '" + relationType + "'";
        if (StringUtils.isNotBlank(relationType)) {
            sql += " and t.relation_type = '" + relationType + "'";
        }
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize);
        if (list != null && list.size() > 0) {
@ -473,21 +469,35 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
    }
    /**
     * 业务类型1、文章2、问卷   relationType
     * 业务类型1、文章2、问卷  relationType
     */
    public HashMap<String, Object> findSendPatientList(String doctorCode, String patientCode, String sendType, int page, int pageSize) {
        String sql = " SELECT DISTINCT \n" +
//                " b.doctor 'sendDoctorCode',b.doctor_name 'sendDoctorName'," +
                " date_format(a.create_time,'%Y-%m-%d %H:%i:%S' ) 'articleCreateTime'," ;
        if (StringUtils.isNotBlank(patientCode)){
            sql+=   " c.fabulous 'userFabulous', c.is_read 'userIsRead',c.is_share 'userShare',c.collection 'userCollection'," ;
        String sql = "SELECT \n";
        if (StringUtils.isNotBlank(doctorCode)) {
            sql += "	(SELECT count(1) FROM base_patient_business q WHERE q.relation_code=aaa.id AND q.doctor='" + doctorCode + "')as 'doctorSendCount',\n" +
                    "	(SELECT\n" +
                    "		count(1)\n" +
                    "	FROM\n" +
                    "		base_patient_business q\n" +
                    "		INNER JOIN wlyy_knowledge_article_user w ON q.patient=w.user_code AND q.relation_code=w.relation_code\n" +
                    "	WHERE\n" +
                    "		q.doctor='" + doctorCode + "'\n" +
                    "		AND w.is_read='1'\n" +
                    "	)as 'doctorSendPatientSeeCount',\n";
        }
        sql += "	aaa.* FROM (SELECT DISTINCT	date_format( a.create_time, '%Y-%m-%d %H:%i:%S' ) 'articleCreateTime',\n";
        if (StringUtils.isNotBlank(patientCode)) {
            sql += " c.fabulous 'userFabulous', c.is_read 'userIsRead',c.is_share 'userShare',c.collection 'userCollection',";
        }
        sql += "	a.* \n" +
                "FROM\n" +
                "	wlyy_knowledge_article_dict a\n" +
                "	INNER JOIN base_patient_business b ON a.id = b.relation_code\n" +
                "	INNER JOIN wlyy_knowledge_article_user c ON a.id = c.relation_code \n" +
                "WHERE\n" +
                "	1 = 1 	AND b.relation_type = '" + sendType + "' \n";
         sql+=       " a.* \n" +
                " FROM wlyy_knowledge_article_dict a " +
                " INNER JOIN base_patient_business b ON a.id=b.relation_code" +
                " LEFT JOIN  wlyy_knowledge_article_user c ON a.id=c.relation_code \n" +
                " WHERE 1=1 AND b.relation_type='" + sendType + "' ";
        if (StringUtils.isNotBlank(doctorCode)) {
            sql += " and  b.doctor='" + doctorCode + "' ";
        }
@ -495,12 +505,13 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
            sql += " and  b.patient='" + patientCode + "' ";
        }
        String countSql = " select count(1) from (" + sql + ") qqq";
        sql += " order by a.create_time desc " + " LIMIT " + (page - 1) * pageSize + "," + pageSize + "";
        System.out.println("sql-->"+sql);
        System.out.println("countSql-->"+countSql);
//        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        List<KnowledgeArticleDictDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(KnowledgeArticleDictDO.class));
        String countSql = " select count(1) from (" + sql + ")aaa ) qqq";
        sql += " order by a.create_time desc " + " LIMIT " + (page - 1) * pageSize + "," + pageSize + " ) aaa";
        System.out.println("sql-->" + sql);
        System.out.println("countSql-->" + countSql);
        List<KnowledgeArticleDictDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(KnowledgeArticleDictDO.class));
        Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
        HashMap<String, Object> resultMap = new HashMap<>();