Explorar el Código

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

zd_123 hace 7 años
padre
commit
14c0cd04dd
Se han modificado 39 ficheros con 1141 adiciones y 331 borrados
  1. 18 16
      common/common-entity/src/main/java/com/yihu/es/entity/HealthEduArticleES.java
  2. 15 0
      edu-article/JkEdu/src/ArticleQR.sql.xml
  3. 25 14
      edu-article/JkEdu/src/com/yihu/jk/api/ArticleApi.java
  4. 11 8
      edu-article/JkEdu/src/com/yihu/jk/api/ArticleApiTest.java
  5. 23 0
      edu-article/JkEdu/src/com/yihu/jk/api/ArticleQRCodeApi.java
  6. 5 3
      edu-article/JkEdu/src/com/yihu/jk/api/ArticleQRCodeApiTest.java
  7. 13 0
      edu-article/JkEdu/src/com/yihu/jk/api/CategoryApi.java
  8. 8 12
      edu-article/JkEdu/src/com/yihu/jk/api/CategoryApiTest.java
  9. 8 4
      edu-article/JkEdu/src/com/yihu/jk/dao/ArticleDao.java
  10. 16 0
      edu-article/JkEdu/src/com/yihu/jk/dao/ArticleQRCodeDao.java
  11. 13 0
      edu-article/JkEdu/src/com/yihu/jk/dao/CategoryDao.java
  12. 8 0
      edu-article/JkEdu/src/com/yihu/jk/enums/ArticleQRSqlNameEnum.java
  13. 0 1
      edu-article/JkEdu/src/com/yihu/jk/enums/CategorySqlNameEnum.java
  14. 114 0
      edu-article/JkEdu/src/com/yihu/jk/vo/ArticleQR.java
  15. 18 0
      edu-article/JkEdu/src/com/yihu/jk/vo/ArticleStatistic.java
  16. 6 6
      edu-article/JkEdu/src/sys.xml
  17. 3 2
      patient-co/patient-co-statistics-es/pom.xml
  18. 96 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/extract/db/Data2Save.java
  19. 88 26
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentMysqlToEsQuotaJob.java
  20. 4 70
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/EsToEsQuotaJob.java
  21. 11 10
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java
  22. 2 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  23. 5 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  24. 280 88
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java
  25. 49 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jkEduArticle/ThirdJkEduArticleService.java
  26. 17 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  27. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java
  28. 47 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java
  29. 61 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java
  30. 48 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  31. 16 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEdu/DoctorJMJkEduArticleController.java
  32. 9 18
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEduPC/DoctorJMJkEduArticlePCController.java
  33. 6 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java
  34. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/jimeiJkEdu/PatientJMJkEduArticleController.java
  35. 41 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/HealthEduArticlePatientModel.java
  36. 29 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkEduArticle/ThirdJkEduArticleController.java
  37. 2 2
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  38. 3 3
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  39. 3 8
      pom.xml

+ 18 - 16
common/common-entity/src/main/java/com/yihu/es/entity/HealthEduArticleES.java

@ -18,11 +18,11 @@ public class HealthEduArticleES {
    private String id;
    private String batchNo;//批次号记录发送所属批次
    private String patientCode; // 患者标识
    private String patientName; // 患者标识
    private String doctorCode;  //推送的医生code(包括医生本人、卫计委)
    private String doctorName;  //推送的医生名称(包括医生本人、卫计委)
    private String sendCode;   // 发送人code(如管理员推送,保存登陆者code)
    private String sendName;   // 发送人名称(如管理员推送,保存登陆者name)
    private String patientName; // 患者名称
    private String doctorCode;  //发送人code(如管理员推送,保存登陆者code)
    private String doctorName;  //发送人名称(如管理员推送,保存登陆者name)
//    private String sendCode;   // 发送人code(如管理员推送,保存登陆者code)
    private String sendName;   // 推送的医生名称(包括医生本人、卫计委)
    private String sendPic;   // 发送人头像
    private String sendSex;   // 发送人性别
@ -49,7 +49,7 @@ public class HealthEduArticleES {
    private String secondLevelCategoryId;//文章二级类别id
    private String secondLevelCategoryName;//文章二级类别Name
    private String operatorId;//文章作者Id
    private int isRead=0;//文章是否已读 0未读,1已读
    private Integer isRead=0;//文章是否已读 0未读,1已读
    private String articleSource;//文章来源
    private List<RoleVo> roleList;//发送者角色
@ -58,6 +58,8 @@ public class HealthEduArticleES {
    private String currentUserRoleLevel;//发送者当前登录的角色级别
    private Integer sendSource; //1或者为空 i健康后台推送  2PC端推送
    private Integer allCount;//所有的推送数目
    @Transient
    private Boolean newArricleFlag;//新版文章推送标志
    public String getId() {
        return id;
@ -107,14 +109,6 @@ public class HealthEduArticleES {
        this.doctorName = doctorName;
    }
    public String getSendCode() {
        return sendCode;
    }
    public void setSendCode(String sendCode) {
        this.sendCode = sendCode;
    }
    public String getSendName() {
        return sendName;
    }
@ -291,11 +285,11 @@ public class HealthEduArticleES {
        this.operatorId = operatorId;
    }
    public int getIsRead() {
    public Integer getIsRead() {
        return isRead;
    }
    public void setIsRead(int isRead) {
    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }
@ -354,4 +348,12 @@ public class HealthEduArticleES {
    public void setAllCount(Integer allCount) {
        this.allCount = allCount;
    }
    public Boolean getNewArricleFlag() {
        return newArricleFlag;
    }
    public void setNewArricleFlag(Boolean newArricleFlag) {
        this.newArricleFlag = newArricleFlag;
    }
}

+ 15 - 0
edu-article/JkEdu/src/ArticleQR.sql.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<das-client>
	<Sqls> 
		<Sql name='getArticleORCode'>
		 	<![CDATA[
					select * from Config_ArticleQRCode
			]]>
		</Sql>
		<Sql name='getArticleQRDetail'>
			<![CDATA[
					select * from Config_ArticleQRCode where 1=1  @Condition
			]]>
		</Sql>
	</Sqls>
</das-client>

+ 25 - 14
edu-article/JkEdu/src/com/yihu/jk/api/ArticleApi.java

@ -1,27 +1,25 @@
package com.yihu.jk.api;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
import com.common.json.JSONException;
import com.coreframework.db.DB;
import com.coreframework.remoting.standard.DateOper;
import com.coreframework.util.AppConfig;
import com.yihu.jk.dao.ArticleDao;
import com.yihu.jk.dao.ArticlePcDao;
import com.yihu.jk.utils.ApiUtil;
import com.yihu.jk.utils.StringUtil;
import com.yihu.jk.vo.Article;
import com.yihu.jk.vo.ArticleStatistic;
import com.yihu.jk.vo.OrgArticleVo;
import com.yihu.wsgw.api.InterfaceMessage;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import com.common.json.JSONException;
import com.coreframework.db.DB;
import com.coreframework.util.AppConfig;
import com.yihu.jk.dao.ArticleDao;
import com.yihu.jk.utils.ApiUtil;
import com.yihu.jk.utils.StringUtil;
import com.yihu.jk.vo.ArticleStatistic;
import com.yihu.wsgw.api.InterfaceMessage;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
public class ArticleApi {
	private static ArticleDao dao = new ArticleDao();
@ -235,6 +233,8 @@ public class ArticleApi {
					jsonObj.put("titleLevel", StringUtil.getJSONValue(vbo.getTitleLevel()));
					jsonObj.put("operatorImg", StringUtil.getJSONValue(vbo.getOperatorImg()));
					jsonObj.put("userScope", StringUtil.getJSONValue(vbo.getUserScope()));
					jsonObj.put("articleCategoryId", StringUtil.getJSONValue(vbo.getArticleCategoryId()));
					jsonObj.put("articleCategoryName", StringUtil.getJSONValue(vbo.getArticleCategoryName()));
					if (StringUtil.isNotEmpty(userId)) {
						vo.setUserId(userId);
						int pointNumberCount = dao.pointNumberCount(vo);
@ -550,11 +550,22 @@ public class ArticleApi {
			orgArticleVo.setAuthentication(authentication);
			orgArticleVo.setAuthenticationId(authenticationId);
			orgArticleVo.setRoleType(roleType);
			if ("".equals(orgName) && orgName == null) {
			if ("".equals(orgName) || orgName == null) {
				orgName = "无";
			}
			orgArticleVo.setOrgName(orgName);
			orgArticleVo.setArticleSource(orgName);
			//新增文章时 保存分享数,阅读数等数据
//			ArticleStatistic statistic = new ArticleStatistic();
//			statistic.setBrowseNumber(0);
//			statistic.setPointNumber(0);
//			statistic.setCommentNumber(0);
//			statistic.setShareNumber(0);
//			statistic.setCollectionNumber(0);
//			statistic.setArticleId(articleId);
//			dao.insertArticleInitStatistic(statistic);
			dao.insertArticleStatistic(articleId);
			return dao.saveArticle(orgArticleVo).toString();
		}else{
			orgArticleVo.setArticleId(articleId);

+ 11 - 8
edu-article/JkEdu/src/com/yihu/jk/api/ArticleApiTest.java

@ -55,11 +55,11 @@ public class ArticleApiTest {
		ArticleApi api = new ArticleApi();
		InterfaceMessage im = new InterfaceMessage();
		JSONObject obj = new JSONObject();
		obj.put("firstLevelCategoryId","43");
//		obj.put("firstLevelCategoryId","43");
//		obj.put("articleId","0");
		obj.put("isAuthentication","1");
//		obj.put("isAuthentication","1");
//		obj.put("secondLevelCategoryId","74889da6-955e-4454-870f-4da37b466264");
//        obj.put("firstLevelCategoryName","健康文章");
//        obj.put("secondLevelCategoryName","孕检知识");
@ -68,20 +68,23 @@ public class ArticleApiTest {
//		obj.put("articlelevel","1");
//		obj.put("articleTitle","1");
//		obj.put("userCode","0de7295862dd11e69faffa163e8aee56");
		obj.put("roleType",1);
		//obj.put("roleType",1);
		obj.put("currentUserRole","3502110400");
		obj.put("currentUserRoleLevel","4");
//		obj.put("currentUserRole","3502110400");
//		obj.put("currentUserRoleLevel","4");
		//obj.put("userCode","0de7295862dd11e69faffa163e8aee56");//ylp201703150222
		obj.put("isMyArticle",true);
		obj.put("page","0");
		obj.put("pageSize","10");
		obj.put("pageSize","9");
		obj.put("currentUserRoleLevel",4);//
		obj.put("sEcho","1");
//		obj.put("articleTitle","我口试");
		im.setParam(obj.toString());
		initDB();
		try{
//			api.authenticationArticle(im);
			System.out.println(api.queryArticleAPPList(im));
//			System.out.println(api.authenArticlePCList(im));//initArticleStatistic
			api.initArticleStatistic();
		}catch(Exception e){
			e.printStackTrace();
		}

+ 23 - 0
edu-article/JkEdu/src/com/yihu/jk/api/ArticleQRCodeApi.java

@ -47,6 +47,7 @@ public class ArticleQRCodeApi {
			String orgName = StringUtil.isEmpty(json.get("orgName")) ? null : json.getString("orgName"); //创建人所属机构名称
			String operatorRoleCode = StringUtil.isEmpty(json.get("operatorRoleCode")) ? null : json.getString("operatorRoleCode"); //操作人角色code
			String operatorRoleLevel = StringUtil.isEmpty(json.get("operatorRoleLevel")) ? null : json.getString("operatorRoleLevel"); //操作人角色级别
			String identification = StringUtil.isEmpty(json.get("identification")) ? null : json.getString("identification"); //认证标识文字
			ArticleQR bean = new ArticleQR();
			bean.setImgUrl(imgUrl);
			bean.setPosition(Integer.valueOf(position));
@ -56,6 +57,7 @@ public class ArticleQRCodeApi {
			bean.setOrgName(orgName);
			bean.setOperatorRoleCode(operatorRoleCode);
			bean.setOperatorRoleLevel(operatorRoleLevel);
			bean.setIdentification(identification);
			Integer code = dao.saveArticleQRCode(bean);
			if (code != 1) {
				return ApiUtil.getRespJSON(-1, "数据库操作异常").toString();
@ -78,6 +80,7 @@ public class ArticleQRCodeApi {
		String userName = StringUtil.isEmpty(json.get("userName")) ? null : json.getString("userName"); //创建人名称
		String orgId = StringUtil.isEmpty(json.get("orgId")) ? null : json.getString("orgId"); //创建人所属机构ID
		String orgName = StringUtil.isEmpty(json.get("orgName")) ? null : json.getString("orgName"); //创建人所属机构名称
		String identification = StringUtil.isEmpty(json.get("identification")) ? null : json.getString("identification"); //认证标识文字
//		String operatorRoleCode = StringUtil.isEmpty(json.get("operatorRoleCode")) ? null : json.getString("operatorRoleCode"); //操作人角色code
//		String operatorRoleLevel = StringUtil.isEmpty(json.get("operatorRoleLevel")) ? null : json.getString("operatorRoleLevel"); //操作人角色级别
		try {
@ -92,6 +95,7 @@ public class ArticleQRCodeApi {
			bean.setOperatorName(userName);
			bean.setOrgId(orgId);
			bean.setOrgName(orgName);
			bean.setIdentification(identification);
			Integer code = dao.updateArticleQRCode(bean);
			if (code != 1) {
				return ApiUtil.getRespJSON(-1, "数据库操作异常").toString();
@ -103,4 +107,23 @@ public class ArticleQRCodeApi {
			return ApiUtil.getRespJSON(-14444, e.getMessage()).toString();
		}
	}
	public String getArticleQRCodeById(InterfaceMessage im){
		JSONObject json = JSONObject.fromObject(im.getParam());
		Integer id = StringUtil.isEmpty(json.get("id")) ? null : json.getInt("id"); //id
		try {
			ArticleQR bean = new ArticleQR();
			bean.setId(id);
			ArticleQR articleQR = dao.getArticleQRCodeById(bean);
			JSONObject jsonArticleQR = JSONObject.fromObject(articleQR);
			JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
			rv.put("Result", jsonArticleQR.toString());
			return rv.toString();
		}catch (Exception e) {
			e.printStackTrace();
			return ApiUtil.getRespJSON(-14444, e.getMessage()).toString();
		}
	}
}

+ 5 - 3
edu-article/JkEdu/src/com/yihu/jk/api/ArticleQRCodeApiTest.java

@ -27,11 +27,13 @@ public class ArticleQRCodeApiTest {
		ArticleQRCodeApi api = new ArticleQRCodeApi();
		InterfaceMessage im = new InterfaceMessage();
		JSONObject obj = new JSONObject();
		obj.put("currentRoleLevel","1");
		obj.put("currentRoleCode","350200");
//		obj.put("currentRoleLevel","1");
//		obj.put("currentRoleCode","350200");
		obj.put("id",7);
		obj.put("identification","认证");
		im.setParam(obj.toString());
		initDB();
		System.out.println(api.getArticleQRCode(im));
		System.out.println(api.updateArticleQRCode(im));
	}

+ 13 - 0
edu-article/JkEdu/src/com/yihu/jk/api/CategoryApi.java

@ -78,6 +78,19 @@ public class CategoryApi {
		return dao.addCategory(vo).toString();
	}
	public String checkCategory(InterfaceMessage im)throws SQLException{
		JSONObject json = JSONObject.fromObject(im.getParam());
		String categoryName = StringUtil.isEmpty(json.get("categoryName")) ? null : json.getString("categoryName");
		Integer categoryLevel = StringUtil.isEmpty(json.get("categoryLevel")) ? null : json.getInt("categoryLevel");
		Category vo = new Category();
		vo.setCategoryName(categoryName);
		vo.setCategoryLevel(categoryLevel);
		com.common.json.JSONObject  j =dao.getCategoryList(vo);
		return j.toString();
	}
	/**
	 * 更新文章分类
	 * @param im

+ 8 - 12
edu-article/JkEdu/src/com/yihu/jk/api/CategoryApiTest.java

@ -16,7 +16,7 @@ import net.sf.json.JSONObject;
public class CategoryApiTest {
	public static void main(String[] args){
	public static void main(String[] args)throws Exception{
		// getConfigSys();
		// getArticleORCode();
		addCategory();
@ -24,22 +24,18 @@ public class CategoryApiTest {
	}
	// 获取系统配置 认证 评论开关
	public static void addCategory(){
	public static void addCategory()throws Exception{
		CategoryApi api = new CategoryApi();
		InterfaceMessage im = new InterfaceMessage();
		JSONObject obj = new JSONObject();
		obj.put("categoryId","1");
		obj.put("categoryName","1");
		obj.put("categoryLevel","1");
		obj.put("secondLevelId","1");
		obj.put("firstlevelId","1");
		obj.put("orgName","1");
		obj.put("orgId","1");
		obj.put("operatorName","1");
		obj.put("operatorId","1");
		obj.put("categoryName","内部通知");
		obj.put("categoryLevel","2");
		im.setParam(obj.toString());
		initDB();
		System.out.println(api.addCategory(im));
		System.out.println(api.checkCategory(im));
	}

+ 8 - 4
edu-article/JkEdu/src/com/yihu/jk/dao/ArticleDao.java

@ -297,8 +297,8 @@ public class ArticleDao {
	public void insertArticleStatistic(String articleId) throws SQLException {
		Sql sql = DB.me().createSql(ArticleSqlNameEnum.insertArticleStatistic);
		sql.addParamValue(articleId);
		sql.addParamValue(articleId);
		System.out.println(sql.toString());
//		sql.addParamValue(articleId);
//		System.out.println(sql.toString());
		DB.me().insert(MyDatabaseEnum.JkEduDB, sql);
	}
@ -600,6 +600,7 @@ public class ArticleDao {
        if(StringUtil.isNotEmpty(userCode)){
			param2.append(" and  a.UserId='"+userCode+"'");
			param.append(" or  ( OperatorId='"+userCode+"' and UserScope=4 and RoleType = '"+vo.getRoleType()+"')");
		}
//		pageParam.append(" limit ").append(start * pageSize + "," + pageSize);
		sql.addVar("@Condition", param.toString());
@ -683,9 +684,9 @@ public class ArticleDao {
		}else if("4".equals(vo.getOperatorRoleLevel())){//社区、机构
			param.append(" and OperatorRoleCode = '"+vo.getOperatorRoleCode()+"' ");
		}
		param.append(" and UserScope <= ? ");
		if(StringUtil.isNotEmpty(vo.getOperatorRoleLevel())){
		if(StringUtil.isNotEmpty(vo.getOperatorRoleLevel())){
			param.append(" and UserScope <= ? ");
			sql.addParamValue(Integer.valueOf(vo.getOperatorRoleLevel())-1);
		}else{
			sql.addParamValue(3);
@ -697,6 +698,7 @@ public class ArticleDao {
		if(StringUtil.isNotEmpty(userCode)){
			param2.append(" and  a.UserId='"+userCode+"'");
			param.append(" or  ( OperatorId='"+userCode+"' and UserScope=4 and RoleType = '"+vo.getRoleType()+"')");
		}
		pageParam.append(" limit ").append(start * pageSize + "," + pageSize);
		sql.addVar("@Condition", param.toString());
@ -776,6 +778,7 @@ public class ArticleDao {
        Sql sql = DB.me().createSql(ArticleSqlNameEnum.getArticlePcList);
        StringBuffer param = new StringBuffer();
		StringBuffer param2 = new StringBuffer();
        StringBuffer pageParam = new StringBuffer();
        if (StringUtil.isNotEmpty(vo.getFirstLevelCategoryId())) {
            param.append(" and FirstLevelCategoryId = ? ");
@ -809,6 +812,7 @@ public class ArticleDao {
        }
        sql.addVar("@Condition", param.toString());
        sql.addVar("@PageParam", pageParam.toString());
		sql.addVar("@Condition2", param2.toString());
        return DB.me().queryForJson(MyDatabaseEnum.JkEduDB, sql, start, pageSize);
    }

+ 16 - 0
edu-article/JkEdu/src/com/yihu/jk/dao/ArticleQRCodeDao.java

@ -2,13 +2,16 @@ package com.yihu.jk.dao;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
import com.common.json.JSONObject;
import com.coreframework.db.DB;
import com.coreframework.db.Sql;
import com.coreframework.remoting.standard.DateOper;
import com.yihu.jk.enums.*;
import com.yihu.jk.utils.StringUtil;
import com.yihu.jk.vo.ArticleQR;
import com.yihu.jk.vo.ArticleStatistic;
import com.yihu.jk.vo.OperationLogVo;
import org.springframework.stereotype.Component;
@ -112,4 +115,17 @@ public class ArticleQRCodeDao {
		return code;
	}
	public ArticleQR getArticleQRCodeById(ArticleQR vo) throws SQLException {
		Sql sql = DB.me().createSql(ArticleQRSqlNameEnum.getArticleQRDetail);
		StringBuffer param = new StringBuffer();
		if (StringUtil.isNotEmpty(vo.getId())) {
			param.append(" and Id = ").append(vo.getId());
		}
		sql.addVar("@Condition", param.toString());
		ArticleQR articleQR = DB.me().queryForBean(MyDatabaseEnum.JkEduDB, sql, ArticleQR.class);
		return articleQR;
	}
}

+ 13 - 0
edu-article/JkEdu/src/com/yihu/jk/dao/CategoryDao.java

@ -46,7 +46,20 @@ public class CategoryDao {
//		sql.addVar("@UserId", paramUserId.toString());
		sql.addVar("@Condition", param.toString());
		return DB.me().queryForJson(MyDatabaseEnum.JkEduDB, sql, start, pageSize);
	}
	public JSONObject getCategoryList(Category vo) throws SQLException {
		Sql sql = DB.me().createSql(CategorySqlNameEnum.getCategoryList);
		StringBuffer param = new StringBuffer();
		StringBuffer paramUserId = new StringBuffer();
		if (StringUtil.isNotEmpty(vo.getCategoryName())) {
			param.append(" and CategoryName =").append("'"+vo.getCategoryName()+"'");
		}
		if (StringUtil.isNotEmpty(vo.getCategoryLevel())) {
			param.append(" and CategoryLevel =").append(vo.getCategoryLevel());
		}
		sql.addVar("@Condition", param.toString());
		return DB.me().queryForJson(MyDatabaseEnum.JkEduDB, sql);
	}
	// 保存分类

+ 8 - 0
edu-article/JkEdu/src/com/yihu/jk/enums/ArticleQRSqlNameEnum.java

@ -0,0 +1,8 @@
package com.yihu.jk.enums;
import com.coreframework.db.SqlNameEnum;
public enum ArticleQRSqlNameEnum implements SqlNameEnum {
	 getArticleQRDetail
}

+ 0 - 1
edu-article/JkEdu/src/com/yihu/jk/enums/CategorySqlNameEnum.java

@ -7,5 +7,4 @@ public enum CategorySqlNameEnum implements SqlNameEnum {
	getCategoryList,
	addCategory,
	updateCategory,
}

+ 114 - 0
edu-article/JkEdu/src/com/yihu/jk/vo/ArticleQR.java

@ -0,0 +1,114 @@
package com.yihu.jk.vo;
//二维码管理
public class ArticleQR {
	private int id;// 主键ID
	private String imgUrl;// 图片地址
	private Integer position;// 1、顶部 2、底部
	private String insertTime;// 插入时间
	private String updateTime;// √ 修改时间
	private String operatorName;// 创建人
	private String operatorId;// 创建人ID
	private String orgId;// 创建人所属机构ID
	private String orgName;// 创建人所属机构名称
	private String identification;//认证标识文字
	private String operatorRoleCode;//操作人角色code
	private String operatorRoleLevel;//操作人角色级别
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getImgUrl() {
		return imgUrl;
	}
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}
	public Integer getPosition() {
		return position;
	}
	public void setPosition(Integer position) {
		this.position = position;
	}
	public String getInsertTime() {
		return insertTime;
	}
	public void setInsertTime(String insertTime) {
		this.insertTime = insertTime;
	}
	public String getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}
	public String getOperatorName() {
		return operatorName;
	}
	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}
	public String getOperatorId() {
		return operatorId;
	}
	public void setOperatorId(String operatorId) {
		this.operatorId = operatorId;
	}
	public String getOrgId() {
		return orgId;
	}
	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}
	public String getOrgName() {
		return orgName;
	}
	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	public String getIdentification() {
		return identification;
	}
	public void setIdentification(String identification) {
		this.identification = identification;
	}
	public String getOperatorRoleCode() {
		return operatorRoleCode;
	}
	public void setOperatorRoleCode(String operatorRoleCode) {
		this.operatorRoleCode = operatorRoleCode;
	}
	public String getOperatorRoleLevel() {
		return operatorRoleLevel;
	}
	public void setOperatorRoleLevel(String operatorRoleLevel) {
		this.operatorRoleLevel = operatorRoleLevel;
	}
}

+ 18 - 0
edu-article/JkEdu/src/com/yihu/jk/vo/ArticleStatistic.java

@ -26,6 +26,8 @@ public class ArticleStatistic {
	private String endTime;
	private String articleType;// 文章类型
	private Integer isAuthentication;// 是否认证
	private String ArticleCategoryId;// 文章类别Id
	private String ArticleCategoryName;// 文章类别
	private int browseNumber;// 浏览数
	private int pointNumber;// 点赞数
	private int commentNumber;// 评论数
@ -349,4 +351,20 @@ public class ArticleStatistic {
	public void setRoleType(Integer roleType) {
		RoleType = roleType;
	}
	public String getArticleCategoryId() {
		return ArticleCategoryId;
	}
	public void setArticleCategoryId(String articleCategoryId) {
		ArticleCategoryId = articleCategoryId;
	}
	public String getArticleCategoryName() {
		return ArticleCategoryName;
	}
	public void setArticleCategoryName(String articleCategoryName) {
		ArticleCategoryName = articleCategoryName;
	}
}

+ 6 - 6
edu-article/JkEdu/src/sys.xml

@ -8,14 +8,14 @@
  <!-- 数据库连接配置  -->
  <DB.Alias>jkedudb</DB.Alias>
  <DB.DatabaseName>jkedudb</DB.DatabaseName>
  <!--<DB.IP>172.19.103.85</DB.IP>-->
  <!--<DB.Port>3306</DB.Port>-->
  <!--<DB.UserName>linzhou</DB.UserName>-->
  <!--<DB.Password>FDw6DUFgoKg=</DB.Password>-->
  <DB.IP>172.19.103.77</DB.IP>
  <DB.IP>172.19.103.85</DB.IP>
  <DB.Port>3306</DB.Port>
  <DB.UserName>linzhou</DB.UserName>
  <DB.Password>FDw6DUFgoKg=</DB.Password>
  <!--<DB.IP>172.19.103.77</DB.IP>
  <DB.Port>3306</DB.Port>
  <DB.UserName>root</DB.UserName>
  <DB.Password>VYhw4YNnygE=</DB.Password>
  <DB.Password>VYhw4YNnygE=</DB.Password>-->
  <!--<EhrApiUrl>http://ehr.yihu.com/wlyyfz</EhrApiUrl>-->
  <EhrApiUrl>http://192.168.131.131:8080/</EhrApiUrl>

+ 3 - 2
patient-co/patient-co-statistics-es/pom.xml

@ -442,8 +442,9 @@
            <version>2.4.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>delete-by-query</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>

+ 96 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/extract/db/Data2Save.java

@ -0,0 +1,96 @@
package com.yihu.wlyy.statistics.etl.extract.db;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.job.QuartzJobConfig;
import com.yihu.wlyy.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.vo.SaveModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
/**
 * Created by chenweida on 2017/12/28.
 */
@Component
public class Data2Save {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<SaveModel> data2save(List<DataModel> dataModels, QuartzJobConfig quartzJobConfig, Date quotaDate, String timeLevel) {
        //初始化维度的数据
        Map<String, DataModel> dataModelMap = new HashMap<>();
        if (dataModels != null) {
            for (DataModel dataModel : dataModels) {
                dataModelMap.put(dataModel.getTeam(), dataModel);
            }
        }
        List<SaveModel> savelist = new ArrayList<>();
        //得到全部团队
        List<AdminTeam> teams = findAllTeam();
        for (AdminTeam adminTeam : teams) {
            DataModel dataModel = dataModelMap.get(adminTeam.getId().toString());
            SaveModel saveModel = new SaveModel();
            saveModel.setCity("350206");
            saveModel.setCityName("厦门市");
            saveModel.setTown(adminTeam.getTownCode());
            saveModel.setTownName(adminTeam.getTownName());
            saveModel.setHospital(adminTeam.getOrgCode());
            saveModel.setHospitalName(adminTeam.getOrgName());
            saveModel.setTeam(adminTeam.getId().toString());
            saveModel.setTeamName(adminTeam.getName());
            saveModel.setQuotaCode(quartzJobConfig.getQuotaId());
            saveModel.setAreaLevel(SaveModel.teamLevel);
            saveModel.setTimeLevel(timeLevel);
            saveModel.setCreateTime(new Date());
            saveModel.setQuotaDate(quotaDate);
            if (dataModel != null) {
                saveModel.setResult1(dataModel.getResult1());
                saveModel.setResult2(dataModel.getResult1());
            } else {
                saveModel.setResult1(0.0);
                saveModel.setResult2(0.0);
            }
            savelist.add(saveModel);
        }
        return savelist;
    }
    /**
     * 得到全部团队
     *
     * @return
     */
    private List<AdminTeam> findAllTeam() {
        //  Map<String, AdminTeam> adminTeamMap = new HashMap<>();
        String sql = "SELECT " +
                "  wat.id id, " +
                "  wat.name name, " +
                "  h.`code` org_code, " +
                "  h.`name` org_name, " +
                "  h.town   town_code, " +
                "  h.town_name  town_name " +
                "FROM " +
                "  dm_hospital h, " +
                "  wlyy_admin_team wat " +
                "WHERE " +
                "  h.`code` = wat.org_code " +
                "AND wat.available = 1";
        List<AdminTeam> adminTeams = jdbcTemplate.query(sql, new BeanPropertyRowMapper(AdminTeam.class));
//        for (AdminTeam adminTeam : adminTeams) {
//            adminTeamMap.put(adminTeam.getId().toString(), adminTeam);
//        }
        return adminTeams;
    }
}

+ 88 - 26
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentMysqlToEsQuotaJob.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.statistics.etl.cache.Cache;
import com.yihu.wlyy.statistics.etl.compute.ComputeHelper;
import com.yihu.wlyy.statistics.etl.convert.ConvertHelper;
import com.yihu.wlyy.statistics.etl.extract.ExtractHelper;
import com.yihu.wlyy.statistics.etl.extract.db.Data2Save;
import com.yihu.wlyy.statistics.etl.filter.FilterHelper;
import com.yihu.wlyy.statistics.etl.save.SaveHelper;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
@ -77,6 +78,8 @@ public class CurrentMysqlToEsQuotaJob implements Job {
    private QuartzJobConfigDao quartzJobConfigDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private Data2Save data2Save;
    public void execute(JobExecutionContext context)
@ -135,31 +138,11 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        List<QuartzJobConfig> list = quartzJobConfigDao.findByIds();
        list.stream().forEach(one -> {
            try {
                logger.info("========================quotaCode:" + one.getId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + ",timeLevel:" + timeLevel + " start========================");
                QuartzJobLog tjQuotaLog = new QuartzJobLog();
                tjQuotaLog.setJobId(one.getId());
                tjQuotaLog.setJobStartTime(new Date());
                //1..抽取数据 如果是累加就是 List<DataModel>  如果是相除 Map<String,List<DataModel>>
                List<DataModel> dataModels = extract(one);
                //2..根据规则过滤数据
                FilterModel filterModel = filter(dataModels);
                //得到改指标的维度
                List<WlyyDimensionQuota> dimensionQuotas = dimensionQuotaDao.findDimensionQuotasByQuotaCode(one.getId());
                //2.1.从维度的key转换
                if (dimensionQuotas != null && dimensionQuotas.size() > 0) {
                    filterModel = convert(filterModel, dimensionQuotas);
                if (StringUtils.isEmpty(one.getExtractType()) || "1".equals(one.getExtractType())){
                    mysql(one);
                }else if("2".equals(one.getExtractType())){
                    es(one);
                }
                //3.统计数据
                List<SaveModel> sms = compute(filterModel.getData(), dimensionQuotas, timeLevel, one);
                //4.更新数据
                Boolean success = updateData(sms, quotaDate, one.getId(), timeLevel, dimensionQuotas.size());
                tjQuotaLog.setJobType(success ? "1" : "0");
                tjQuotaLog.setJobEndTime(new Date());
                tjQuotaLog.setJobContent(JSONArray.fromObject(filterModel.getErrorModels()).toString());
                saveLog(tjQuotaLog);
                logger.info("========================quotaCode:" + one.getId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + " end========================");
            } catch (Exception e) {
                e.printStackTrace();
            }
@ -169,15 +152,89 @@ public class CurrentMysqlToEsQuotaJob implements Job {
    }
    private void es(QuartzJobConfig one) throws Exception{
        this.endTime = DateUtil.getStringDate("yyyy-MM-dd'T'HH:mm:ssZZZ");
        //初始化统计年份
        this.year = getNowYearByDate();
        //初始化开始时间
        if ("2".equals(timeLevel)) {
            //按年度到达量
            startTime = this.year + "-06-30T17:00:00+0800";
        } else {
            //增量
            this.startTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd") + "T17:00:00+0800"; //2017-06-01 17:00:00
        }
        this.quotaDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
        one.setStartTime(startTime);
        one.setEndTime(endTime);
        logger.info("========================quotaCode:" + one.getQuotaId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + ",timeLevel:" + timeLevel + " start========================");
        QuartzJobLog tjQuotaLog = new QuartzJobLog();
        tjQuotaLog.setJobId( one.getQuotaId());
        tjQuotaLog.setJobStartTime(new Date());
        // 1..抽取数据 如果是累加就是 List<DataModel>  如果是相除 Map<String,List<DataModel>>
        List<DataModel> dataModels = extract2Es(one);
        // 2 DataModel 转SaveModel即可
        List<SaveModel> saveModels = data2Save.data2save(dataModels,one,quotaDate,timeLevel);
        // 3.更新数据
        Boolean success = updateData(saveModels, quotaDate, one.getId(), timeLevel);
        tjQuotaLog.setJobType(success ? "1" : "0");
        tjQuotaLog.setJobEndTime(new Date());
        //tjQuotaLog.setJobContent(JSONArray.fromObject(filterModel.getErrorModels()).toString());
        saveLog(tjQuotaLog);
        logger.info("========================quotaCode:" +  one.getQuotaId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + " end========================");
    }
    private void mysql(QuartzJobConfig one) {
        logger.info("========================quotaCode:" + one.getId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + ",timeLevel:" + timeLevel + " start========================");
        QuartzJobLog tjQuotaLog = new QuartzJobLog();
        tjQuotaLog.setJobId(one.getId());
        tjQuotaLog.setJobStartTime(new Date());
        //1..抽取数据 如果是累加就是 List<DataModel>  如果是相除 Map<String,List<DataModel>>
        List<DataModel> dataModels = extract2Es(one);
        //2..根据规则过滤数据
        FilterModel filterModel = filter(dataModels);
        //得到改指标的维度
        List<WlyyDimensionQuota> dimensionQuotas = dimensionQuotaDao.findDimensionQuotasByQuotaCode(one.getId());
        //2.1.从维度的key转换
        if (dimensionQuotas != null && dimensionQuotas.size() > 0) {
            filterModel = convert(filterModel, dimensionQuotas);
        }
        //3.统计数据
        List<SaveModel> sms = compute(filterModel.getData(), dimensionQuotas, timeLevel, one);
        //4.更新数据
        Boolean success = updateData(sms, quotaDate, one.getId(), timeLevel);
        tjQuotaLog.setJobType(success ? "1" : "0");
        tjQuotaLog.setJobEndTime(new Date());
        tjQuotaLog.setJobContent(JSONArray.fromObject(filterModel.getErrorModels()).toString());
        saveLog(tjQuotaLog);
        logger.info("========================quotaCode:" + one.getId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + " end========================");
    }
    private List<DataModel> extract2Es(QuartzJobConfig one) {
        try {
            List<DataModel> dataModels = SpringUtil.getBean(ExtractHelper.class).extractData(one, startTime, endTime, year, timeLevel);
            logger.info("quotaCode:" + one.getQuotaId() + ",size:" + dataModels.size());
            return dataModels;
        } catch (Exception e) {
            logger.error("extract error:" + e.getMessage());
        }
        return null;
    }
    /**
     * 删除 某个指标某一天的某个timelevel的数据
     *
     * @param quotaDate
     * @param quotaCode
     * @param timeLevel
     * @param size
     */
    private boolean updateData(List<SaveModel> sms, Date quotaDate, String quotaCode, String timeLevel, int size) {
    private boolean updateData(List<SaveModel> sms, Date quotaDate, String quotaCode, String timeLevel) {
        JestClient jestClient = null;
        try {
            jestClient = elasticFactory.getJestClient();
@ -345,4 +402,9 @@ public class CurrentMysqlToEsQuotaJob implements Job {
            return (1900 + today.getYear() - 1) + "";
        }
    }
    public static void main(String[] args) {
        SimpleDateFormat s=new SimpleDateFormat("");
        System.out.println(s.format(new Date()));
    }
}

+ 4 - 70
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/EsToEsQuotaJob.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.wlyy.statistics.etl.compute.ComputeHelper;
import com.yihu.wlyy.statistics.etl.convert.ConvertHelper;
import com.yihu.wlyy.statistics.etl.extract.ExtractHelper;
import com.yihu.wlyy.statistics.etl.extract.db.Data2Save;
import com.yihu.wlyy.statistics.etl.filter.FilterHelper;
import com.yihu.wlyy.statistics.etl.save.SaveHelper;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
@ -74,6 +75,8 @@ public class EsToEsQuotaJob implements Job {
    private String esType;
    @Value("${es.index}")
    private String esIndex;
    @Autowired
    private Data2Save data2Save;
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
@ -150,7 +153,7 @@ public class EsToEsQuotaJob implements Job {
            // 1..抽取数据 如果是累加就是 List<DataModel>  如果是相除 Map<String,List<DataModel>>
            List<DataModel> dataModels = extract();
            // 2 DataModel 转SaveModel即可
            List<SaveModel> saveModels = data2save(dataModels);
            List<SaveModel> saveModels = data2Save.data2save(dataModels,quartzJobConfig,quotaDate,timeLevel);
            // 3.保存数据
            Boolean success = saveDate(saveModels);
@ -164,49 +167,7 @@ public class EsToEsQuotaJob implements Job {
        }
    }
    private List<SaveModel> data2save(List<DataModel> dataModels) {
        //初始化维度的数据
        Map<String,DataModel> dataModelMap=new HashMap<>();
        if(dataModels!=null){
            for(DataModel dataModel:dataModels){
                dataModelMap.put(dataModel.getTeam(),dataModel);
            }
        }
        List<SaveModel> savelist = new ArrayList<>();
        //得到全部团队
        List<AdminTeam>  teams = findAllTeam();
        for(AdminTeam adminTeam:teams){
            DataModel dataModel= dataModelMap.get(adminTeam.getId().toString());
            SaveModel saveModel = new SaveModel();
            saveModel.setCity("350206");
            saveModel.setCityName("厦门市");
            saveModel.setTown(adminTeam.getTownCode());
            saveModel.setTownName(adminTeam.getTownName());
            saveModel.setHospital(adminTeam.getOrgCode());
            saveModel.setHospitalName(adminTeam.getOrgName());
            saveModel.setTeam(adminTeam.getId().toString());
            saveModel.setTeamName(adminTeam.getName());
            saveModel.setQuotaCode(quartzJobConfig.getQuotaId());
            saveModel.setAreaLevel(SaveModel.teamLevel);
            saveModel.setTimeLevel(timeLevel);
            saveModel.setCreateTime(new Date());
            saveModel.setQuotaDate(quotaDate);
            if(dataModel!=null){
                saveModel.setResult1(dataModel.getResult1());
                saveModel.setResult2(dataModel.getResult1());
            }else{
                saveModel.setResult1(0.0);
                saveModel.setResult2(0.0);
            }
            savelist.add(saveModel);
        }
        return savelist;
    }
    /**
     * 删除 某个指标某一天的某个timelevel的数据
@ -348,31 +309,4 @@ public class EsToEsQuotaJob implements Job {
        }
    }
    /**
     * 得到全部团队
     *
     * @return
     */
    private List<AdminTeam> findAllTeam() {
      //  Map<String, AdminTeam> adminTeamMap = new HashMap<>();
        String sql = "SELECT " +
                "  wat.id id, " +
                "  wat.name name, " +
                "  h.`code` org_code, " +
                "  h.`name` org_name, " +
                "  h.town   town_code, " +
                "  h.town_name  town_name " +
                "FROM " +
                "  dm_hospital h, " +
                "  wlyy_admin_team wat " +
                "WHERE " +
                "  h.`code` = wat.org_code " +
                "AND wat.available = 1";
        List<AdminTeam> adminTeams = jdbcTemplate.query(sql, new BeanPropertyRowMapper(AdminTeam.class));
//        for (AdminTeam adminTeam : adminTeams) {
//            adminTeamMap.put(adminTeam.getId().toString(), adminTeam);
//        }
        return adminTeams;
    }
}

+ 11 - 10
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.activemq;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.consult.ConsultService;
@ -46,9 +47,9 @@ public class HealthArtListener implements MessageListener {
    public void onMessage(Message message) {
        try {
            TextMessage textMessage = (TextMessage) message;
            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
            HealthEduArticleES healthEduArticleES = (HealthEduArticleES)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticleES.class);
//            logger.info(jo.toString());
            sendWxTemplateAndIM(healthEduArticlePatient);
            sendWxTemplateAndIM(healthEduArticleES);
            //返回服务器表示消息消费成功
            message.acknowledge();
        } catch (JMSException e) {
@ -58,18 +59,18 @@ public class HealthArtListener implements MessageListener {
    //发送到IM和微信消息模板
    private void sendWxTemplateAndIM(HealthEduArticlePatient one) {
    private void sendWxTemplateAndIM(HealthEduArticleES one) {
        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
//        healthEduArticlePatients.stream().forEach(one -> {
            Patient patient = patientService.findByCode(one.getPatient());
            Patient patient = patientService.findByCode(one.getPatientCode());
            try {
                //卫纪委发送不推IM
                if (1 == one.getSendType()) {
                    consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                    if (StringUtils.isNotBlank(one.getAttachedMessage())) {
                    consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getArticleTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getArticleCover() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                    if (StringUtils.isNotBlank(one.getLeaveWords())) {
                        //发送备注
                        consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), one.getAttachedMessage(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                        consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), one.getLeaveWords(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                    }
                }
                // 推送消息给微信端
@ -77,12 +78,12 @@ public class HealthArtListener implements MessageListener {
                json.put("first", patient.getName() + ",您好! " + one.getSendName() + (one.getSendType()==2 ? "卫计委":"医生") +"给您发来了一篇患教文章");
                json.put("toUser", patient.getCode());
                json.put("article", one.getArticleId() + "");
                json.put("title", one.getAttachedTitle());
                json.put("title", one.getArticleTitle());
                json.put("doctorName", one.getDoctorName()+(one.getSendType()==2 ? "卫计委":"医生"));
                json.put("represented", patient.getCode());//被代理人
                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage());
                json.put("articleUrl",one.getArticleUrl());
                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getLeaveWords()) ? "  " : one.getLeaveWords());
                json.put("newArricleFlag",one.getNewArricleFlag());
                if (StringUtils.isNotBlank(patient.getOpenid())) {
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9,
                            patient.getOpenid(),

+ 2 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -458,8 +458,8 @@ public class PushMsgTask {
            } else if (type == 9) {
                temp.setUrl(url + "jkjy/html/article.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                //如果是ArticleUrl不为空,那就说明是外部系统推送文章(如:集美宣教)
                String articleUrl = json.has("articleUrl") ? json.getString("articleUrl") : null;
                if(StringUtils.isNotEmpty(articleUrl)){
                Boolean articleUrl = json.has("newArricleFlag") ? json.getBoolean("newArricleFlag") : false;
                if(articleUrl.booleanValue()){
                    temp.setUrl(url + "jkjy/html/article2.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                }
                temp_id = template_healthy_article;

+ 5 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -393,9 +393,9 @@ public class SignPatientLabelInfoService extends BaseService {
                sql = "SELECT " +
                        "    t1.* " +
                        " FROM " +
                        "    wlyy_sign_family t1, " +
                        "    wlyy_sign_patient_label_info t2, " +
                        "    wlyy_patient p "+
                        "    wlyy_sign_family t1 " +
                        "    left join wlyy_sign_patient_label_info t2 on t1.patient = t2.patient " +
                        "    left join wlyy_patient p on p.`code` = t1.patient "+
                        " WHERE " +
                        "    t2.label = ? " +
                        "    AND t2.label_type = ? " +
@ -403,7 +403,8 @@ public class SignPatientLabelInfoService extends BaseService {
                        "    AND t1.patient = t2.patient " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? " ;
                        "    AND t1.admin_team_code = ? "+
                        "    AND p.`status` =1 ";
                if(isFollowWeChat){
                    sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
                }

+ 280 - 88
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.yihu.edu.entity.RoleWithAuthorityCheck;
import com.yihu.es.entity.FollowupContentESDO;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.es.entity.RoleVo;
import com.yihu.wlyy.config.es.ElasticFactory;
@ -14,6 +15,7 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
@ -27,8 +29,7 @@ import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.Search;
import io.searchbox.core.SearchResult;
import io.searchbox.core.*;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
@ -57,6 +58,8 @@ public class JMJkEduArticleService extends BaseService {
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    @Autowired
    private AdminTeamService adminTeamService;
    
    @Autowired
    private ElasticFactory elasticFactory;
@ -69,6 +72,8 @@ public class JMJkEduArticleService extends BaseService {
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
    @Autowired
    private GcLabelService labelService;
@ -104,17 +109,17 @@ public class JMJkEduArticleService extends BaseService {
//            sendCode = resultMap.size()>0?resultMap.get(0).get("roleCode").toString():sendCode;
//        }
        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
        StringBuffer sql2 = new StringBuffer("select articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime  from   " + esType +
                " where  doctorCode='" + sendCode + "'");
        if(sendType==1){
            sql2.append(" and sendType='"+sendType+"' ");
        }
        if(!StringUtils.isEmpty(firstLevelCategoryId)){
            sql2.append("and level1Type="+firstLevelCategoryId);
            sql2.append("and firstLevelCategoryId="+firstLevelCategoryId);
        }
        if(!StringUtils.isEmpty(secondLevelCategoryId)){
            sql2.append("and level2Type="+secondLevelCategoryId);
            sql2.append("and secondLevelCategoryId="+secondLevelCategoryId);
        }
        if(myArticle==1){
            sql2.append(" and operatorId="+sendCode);
@ -132,8 +137,8 @@ public class JMJkEduArticleService extends BaseService {
            sendTimeEnd = elasticsearchUtil.changeTime(sendTimeEnd);
            sql2.append(" and createTime <='"+sendTimeEnd+"'");
        }
        sql2.append("  order by createTime limit " + page + "," + pagesize);
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        sql2.append(" group by articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime  order by createTime limit " + page + "," + pagesize);
        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql2.toString(), HealthEduArticleES.class, esIndex, esType);
        Map<String, HealthEduArticlePatientModel> result = new HashMap<>();
        HealthEduArticlePatientModel heapm = null;
        com.alibaba.fastjson.JSONObject article = null;
@ -141,7 +146,7 @@ public class JMJkEduArticleService extends BaseService {
    
        List<HealthEduArticlePatientModel> resultList = new ArrayList<>();
        
        for (HealthEduArticlePatient one : esList) {
        for (HealthEduArticleES one : esList) {
            article = thirdJkEduArticleService.getArticalById(one.getArticleId(),"");
            if (result.get(one.getArticleId()) != null) {
                heapm = result.get(one.getArticleId());
@ -156,28 +161,43 @@ public class JMJkEduArticleService extends BaseService {
            heapm.setAttachedTitle(article.getString("articleTitle"));
            heapm.setAttachedContent(article.getString("articleContent"));
            heapm.setArticleType(article.getString("articleType"));
            heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
            heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
            heapm.setLevel1Type(one.getFirstLevelCategoryId());
            heapm.setLevel1TypeName(one.getFirstLevelCategoryName());
            heapm.setLevel2Type(one.getSecondLevelCategoryId());
            heapm.setLevel2TypeName(one.getSecondLevelCategoryName());
            heapm.setLevel(article.getString("articlelevel"));
            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
            if(article.getString("browseNumber") != null){
//            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
            if(!StringUtils.isEmpty(article.getString("browseNumber"))){
                heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
            }else{
                heapm.setBrowseNumbere(0);//文章浏览数
            }
            if(article.getString("commentNumber") != null){
            if(!StringUtils.isEmpty(article.getString("commentNumber"))){
                heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
            }else{
                heapm.setCommentNumber(0);//文章评论数
            }
            
            if(article.getString("pointNumber") != null){
            if(!StringUtils.isEmpty(article.getString("pointNumber"))){
                heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
            }else{
                heapm.setPointNumber(0);//文章点赞数
            }
            if(!StringUtils.isEmpty(article.getString("collectionNumberCount"))){
                heapm.setCollectionNumber(Integer.valueOf(article.getString("collectionNumberCount")));//文章点赞数
            }else{
                heapm.setCollectionNumber(0);//文章点赞数
            }
            
            heapm.setArticleCover(article.getString("articleCover"));//封面
            if(article.getString("insertTime")!=null){
                heapm.setComputeTime(computeTime(article.getString("insertTime")));
            }
            doctor = doctorDao.findByCode(one.getDoctorCode());
            doctor = doctorDao.findByCode(sendCode);
            heapm.setPhoto(doctor.getPhoto());
            heapm.setOperatorName(article.getString("operatorName"));
            heapm.setArticleSource(one.getArticleSource());
            // heapm.setTime();//时间  xx小时前  2017-10-11
            resultList.add(heapm);
            result.put(one.getArticleId(), heapm);
@ -195,20 +215,20 @@ public class JMJkEduArticleService extends BaseService {
     * @return
     * @throws Exception
     */
    public List<HealthEduArticlePatient> pushArticleListCount(String sendCode,  String firstLevelCategoryId,String secondLevelCategoryId,Integer myArticle,Integer sendType,String currentUserRole,
    public List<HealthEduArticleES> pushArticleListCount(String sendCode,  String firstLevelCategoryId,String secondLevelCategoryId,Integer myArticle,Integer sendType,String currentUserRole,
                                                              String currentUserRoleLevel,String articleTitle,String sendTimeStart,String sendTimeEnd) throws Exception {
        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
                " where  doctorCode='" + sendCode + "'");
        StringBuffer sql2 = new StringBuffer("select articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime  from   " + esType +
                " where  sendCode='" + sendCode + "'");
        if(sendType==1){
            sql2.append(" and sendType='"+sendType+"' ");
        }
        if(!StringUtils.isEmpty(firstLevelCategoryId)){
            sql2.append("and level1Type="+firstLevelCategoryId);
            sql2.append("and firstLevelCategoryId="+firstLevelCategoryId);
        }
        if(!StringUtils.isEmpty(secondLevelCategoryId)){
            sql2.append("and level2Type="+secondLevelCategoryId);
            sql2.append("and secondLevelCategoryId="+secondLevelCategoryId);
        }
        if(myArticle==1){
            sql2.append(" and operatorId="+sendCode);
@ -226,7 +246,8 @@ public class JMJkEduArticleService extends BaseService {
            sendTimeEnd = elasticsearchUtil.changeTime(sendTimeEnd);
            sql2.append(" and createTime <='"+sendTimeEnd+"'");
        }
        List<HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        sql2.append(" group by articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime");
        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql2.toString(),HealthEduArticleES.class, esIndex, esType);
        return esList;
    }
@ -415,7 +436,7 @@ public class JMJkEduArticleService extends BaseService {
     * @param articleId   文章列表
     */
    @Transactional
    public HealthEduArticlePatient savePCPushArticle(Set<String> patientSet,
    public List<HealthEduArticleES> savePCPushArticle(Set<String> patientSet,
                                                     String sendCode,
//                                                  String sendName,
                                                     Integer sendType,
@ -427,17 +448,95 @@ public class JMJkEduArticleService extends BaseService {
                                                     String currentUserRoleLevel) throws Exception {
        String batchNo = UUID.randomUUID().toString();
        List<Patient> patientList = new ArrayList<>();
//        String batchNo = UUID.randomUUID().toString();
//        List<Patient> patientList = new ArrayList<>();
//
//        for (String patient : patientSet) {
//            patientList.add(new Patient(patient));
//        }
//        HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient();
//
//        Doctor doctor = doctorDao.findByCode(sendCode);
//        String sendName = doctor.getName();
//        //1、普通医生,2、管理员
//        if(sendType==2){
//            String resultSql ="";
//            String whereSql ="";
//            switch (currentUserRoleLevel){
//                case "1":{resultSql +=" DISTINCT (province_name) as name";
//                    whereSql+=" and province ='"+currentUserRoleCode+"'";break;}
//                case "2":{resultSql +=" DISTINCT (city_name) as name";
//                    whereSql+=" and city ='"+currentUserRoleCode+"'";break;}
//                case "3":{resultSql +=" DISTINCT (town_name) as name";
//                    whereSql+=" and town ='"+currentUserRoleCode+"'";break;}
//                case "4":{resultSql +=" DISTINCT (name) as name";
//                    whereSql+=" and code ='"+currentUserRoleCode+"'";break;}
//            }
//            String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ;
//            List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql);
//            sendName = returnList.get(0).get("name")+"";
//
//            Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode);
//            List<String> roleList = (List<String>)resultMap.get("roleList");
//            List<RoleVo> roleVoLists= new ArrayList<>();
//            for(String one:roleList){
//                RoleVo roleVo = new RoleVo();
//                roleVo.setCode(one);
//                roleVoLists.add(roleVo);
//            }
//            healthEduArticlePatient.setRoleList(roleVoLists);
//            healthEduArticlePatient.setCurrentUserRoleCode(currentUserRoleCode);
//            healthEduArticlePatient.setCurrentUserRoleLevel(currentUserRoleLevel);
//        }else{
//            healthEduArticlePatient.setCurrentUserRoleCode(doctor.getHospital());
//            healthEduArticlePatient.setCurrentUserRoleLevel("4");
//        }
//        healthEduArticlePatient.setSendType(sendType);
//        healthEduArticlePatient.setDoctorCode(sendCode);
//        healthEduArticlePatient.setSendName(sendName);
//        healthEduArticlePatient.setAdminTeamCode(teamId);
//        healthEduArticlePatient.setLeaveWords(leaveWords);
//        if (doctor != null) {
//            healthEduArticlePatient.setDoctorName(doctor.getName());
//            healthEduArticlePatient.setHospital(doctor.getHospital());
//            healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
//            healthEduArticlePatient.setTown(doctor.getTown());
//            healthEduArticlePatient.setTownName(doctor.getTownName());
//            healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
//            healthEduArticlePatient.setSendPic(doctor.getPhoto());
//            healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
//        }
//        healthEduArticlePatient.setBatchNo(batchNo);
//        healthEduArticlePatient.setCreateTime(new Date());
//
//
//        //通过文章id 获取文章详情
//        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"");
//
//        healthEduArticlePatient.setArticleId(article.get("articleId") + "");
//        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + "");
//        healthEduArticlePatient.setAttachedPic(article.get("articleCover") + "");
//        healthEduArticlePatient.setAttachedContent(article.get("articleContent") + "");
//        healthEduArticlePatient.setAttachedMessage(sendMessage);
//        healthEduArticlePatient.setArticleType(article.get("articleType") + "");
//        healthEduArticlePatient.setLevel(article.get("articlelevel") + "");
//        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + "");
//        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + "");
//        healthEduArticlePatient.setType("1");//文章
////        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId+"&userId="+);
//        healthEduArticlePatient.setPatients(patientList);
        for (String patient : patientSet) {
            patientList.add(new Patient(patient));
        }
        HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient();
        List<HealthEduArticleES> healthEduArticleESList = new ArrayList<>();
        Doctor doctor = doctorDao.findByCode(sendCode);
        String sendName = doctor.getName();
        //1、普通医生,2、管理员
        AdminTeam adminTeam =null;
        if(teamId!=null){
            adminTeam = adminTeamService.getTeam(teamId);
        }
        Patient one = null;
        String batchNo = UUID.randomUUID().toString();
        String sendName = "";
        if(sendType==2){
            String resultSql ="";
            String whereSql ="";
@ -454,60 +553,73 @@ public class JMJkEduArticleService extends BaseService {
            String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ;
            List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql);
            sendName = returnList.get(0).get("name")+"";
            Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode);
            List<String> roleList = (List<String>)resultMap.get("roleList");
            List<RoleVo> roleVoLists= new ArrayList<>();
            for(String one:roleList){
                RoleVo roleVo = new RoleVo();
                roleVo.setCode(one);
                roleVoLists.add(roleVo);
            }
            healthEduArticlePatient.setRoleList(roleVoLists);
            healthEduArticlePatient.setCurrentUserRoleCode(currentUserRoleCode);
            healthEduArticlePatient.setCurrentUserRoleLevel(currentUserRoleLevel);
        }else{
            healthEduArticlePatient.setCurrentUserRoleCode(doctor.getHospital());
            healthEduArticlePatient.setCurrentUserRoleLevel("4");
        }
        healthEduArticlePatient.setSendType(sendType);
        healthEduArticlePatient.setDoctorCode(sendCode);
        healthEduArticlePatient.setSendName(sendName);
        healthEduArticlePatient.setAdminTeamCode(teamId);
        healthEduArticlePatient.setLeaveWords(leaveWords);
        if (doctor != null) {
            healthEduArticlePatient.setDoctorName(doctor.getName());
            healthEduArticlePatient.setHospital(doctor.getHospital());
            healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
            healthEduArticlePatient.setTown(doctor.getTown());
            healthEduArticlePatient.setTownName(doctor.getTownName());
            healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
            healthEduArticlePatient.setSendPic(doctor.getPhoto());
            healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
        Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode);
        List<String> roleList = (List<String>)resultMap.get("roleList");
        List<RoleVo> roleVoLists= new ArrayList<>();
        for(String temp:roleList){
            RoleVo roleVo = new RoleVo();
            roleVo.setCode(temp);
            roleVoLists.add(roleVo);
        }
        healthEduArticlePatient.setBatchNo(batchNo);
        healthEduArticlePatient.setCreateTime(new Date());
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"");
        for (String patient : patientSet) {
            one = patientDao.findByCode(patient);
            HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
            healthEduArticleES.setDoctorCode(doctor.getCode());
            healthEduArticleES.setDoctorName(doctor.getName());
            healthEduArticleES.setBatchNo(batchNo);
            healthEduArticleES.setPatientCode(patient);
            healthEduArticleES.setPatientName(one.getName());
            if(sendType==2){
                healthEduArticleES.setSendName(sendName);
                healthEduArticleES.setSendLevel("4");
            }else{
                healthEduArticleES.setSendName(doctor.getName());
                healthEduArticleES.setSendLevel(doctor.getLevel()+"");
            }
        //通过文章id 获取文章详情
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"");
            healthEduArticleES.setSendPic(doctor.getPhoto());
            healthEduArticleES.setSendSex(doctor.getSex()+"");
            if(adminTeam!=null){
        healthEduArticlePatient.setArticleId(article.get("articleId") + "");
        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + "");
        healthEduArticlePatient.setAttachedPic(article.get("articleCover") + "");
        healthEduArticlePatient.setAttachedContent(article.get("articleContent") + "");
        healthEduArticlePatient.setAttachedMessage(sendMessage);
        healthEduArticlePatient.setArticleType(article.get("articleType") + "");
        healthEduArticlePatient.setLevel(article.get("articlelevel") + "");
        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + "");
        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + "");
        healthEduArticlePatient.setType("1");//文章
//        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId+"&userId="+);
        healthEduArticlePatient.setPatients(patientList);
                healthEduArticleES.setAdminTeamCode(adminTeam.getId());
                healthEduArticleES.setAdminTeamName(adminTeam.getName());
            }
            healthEduArticleES.setHospital(doctor.getHospital());
            healthEduArticleES.setHospitalName(doctor.getHospitalName());
            healthEduArticleES.setTown(doctor.getTown());
            healthEduArticleES.setTownName(doctor.getTownName());
            healthEduArticleES.setCreateTime(new Date());
            healthEduArticleES.setSendType(sendType);
            healthEduArticleES.setArticleId(article.get("articleId") + "");
            healthEduArticleES.setArticleTitle(article.get("articleTitle") + "");
            healthEduArticleES.setArticleCover(article.get("articleCover") + "");
            healthEduArticleES.setArticleContent(article.get("articleContent") + "");
            healthEduArticleES.setArticleCategoryId(article.get("articleCategoryId") + "");
            healthEduArticleES.setFirstLevelCategoryId(article.get("firstLevelCategoryId") + "");
            healthEduArticleES.setFirstLevelCategoryName(article.get("firstLevelCategoryName") + "");
            healthEduArticleES.setSecondLevelCategoryId(article.get("secondLevelCategoryId") + "");
            healthEduArticleES.setSecondLevelCategoryName(article.get("secondLevelCategoryName") + "");
            healthEduArticleES.setOperatorId(article.get("operatorId") + "");
            healthEduArticleES.setArticleSource(article.get("articleSource") + "");
            healthEduArticleES.setRoleList(roleVoLists);
            healthEduArticleES.setLeaveWords(leaveWords);
            healthEduArticleES.setCurrentUserRoleCode(currentUserRoleCode);
            healthEduArticleES.setCurrentUserRoleLevel(currentUserRoleLevel);
//            healthEduArticleES.setSendSource();
            healthEduArticleES.setAllCount(patientSet.size());
            healthEduArticleESList.add(healthEduArticleES);
        }
        //保存到ES中
        elastricSearchSave.save(healthEduArticlePatient, esIndex, esType);
        return healthEduArticlePatient;
        elastricSearchSave.save(healthEduArticleESList, esIndex, esType);
        return healthEduArticleESList;
    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception {
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"");
@ -953,31 +1065,111 @@ public class JMJkEduArticleService extends BaseService {
        
    }
    
    /**
     * 一键修改居民推送文章的文章为已读
     * @param patient
     */
    public void readAllArticleNew(String patient,String firstLevelCategoryId){
        JestClient jestClient = null;
    
        try {
            jestClient = elasticFactory.getJestClient();
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("patientCode", patient))
                            .must(QueryBuilders.matchQuery("firstLevelCategoryId", firstLevelCategoryId))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build();
            SearchResult result = jestClient.execute(search);
            List<HealthEduArticleES> dataList = result.getSourceAsObjectList(HealthEduArticleES.class);
            if(!dataList.isEmpty()){
                //根据id批量删除
                Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
                for (HealthEduArticleES obj : dataList) {
                    Delete index = new Delete.Builder(obj.getId()).build();
                    bulk.addAction(index);
                }
                BulkResult br = jestClient.execute(bulk.build());
            }
            for (HealthEduArticleES healthEduArticleES:dataList) {
                healthEduArticleES.setIsRead(1);
            }
            elastricSearchSave.save(dataList,esIndex,esType);
            jestClient.shutdownClient();
        }catch (Exception e){
            e.printStackTrace();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
    
    /**
     * 居民单条文章增加已读状态
     * @param patient
     * @param articleId
     */
    public void readPatientArticle(String patient,String articleId){
        JestClient jestClient = null;
        
        try {
            jestClient = elasticFactory.getJestClient();
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("patientCode", patient))
                            .must(QueryBuilders.matchQuery("articleId", articleId))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build();
            SearchResult result = jestClient.execute(search);
            List<HealthEduArticleES> dataList = result.getSourceAsObjectList(HealthEduArticleES.class);
            if(!dataList.isEmpty()){
                //根据id批量删除
                Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
                for (HealthEduArticleES obj : dataList) {
                    Delete index = new Delete.Builder(obj.getId()).build();
                    bulk.addAction(index);
                }
                BulkResult br = jestClient.execute(bulk.build());
            }
            for (HealthEduArticleES healthEduArticleES:dataList) {
                healthEduArticleES.setIsRead(1);
            }
            elastricSearchSave.save(dataList,esIndex,esType);
            jestClient.shutdownClient();
        }catch (Exception e){
            e.printStackTrace();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
    
    public JSONArray pushArticleLogs(int page, int pagesize, String patientCode,String level1Type) throws Exception {
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
//
//        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
//                " where  sendCode='" + sendCode + "' ");
//        sql2.append("  order by createTime limit " + page + "," + pagesize);
        String sql = "SELECT * FROM " + esType + "  where nested(patients.code)= '" + patientCode + "' ";
        String sql = "SELECT * FROM " + esType + "  where patientCode= '" + patientCode + "' ";
        
        if(!StringUtils.isEmpty(level1Type)){
            sql= sql + " and level1Type = '"+level1Type+"' ";
            sql= sql + " and firstLevelCategoryId = '"+level1Type+"' ";
        }
        
        if(page !=0 && pagesize !=0){
            sql= sql+  " order by createTime desc limit " + page + "," + pagesize;
        }
        
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql, HealthEduArticleES.class, esIndex, esType);
        HealthEduArticlePatientModel heapm = null;
        com.alibaba.fastjson.JSONObject article = null;
        List<HealthEduArticlePatientModel> result = new ArrayList<>();
        Doctor doctor = null;
        for (HealthEduArticlePatient one : esList) {
        for (HealthEduArticleES one : esList) {
            article = thirdJkEduArticleService.getArticalById(one.getArticleId(),"");
            heapm = new HealthEduArticlePatientModel();
            heapm.setSendName(one.getSendName());
@ -990,7 +1182,7 @@ public class JMJkEduArticleService extends BaseService {
            heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
            heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
            heapm.setLevel(article.getString("articlelevel"));
            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
//            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
            heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
            heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
            heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
@ -998,8 +1190,8 @@ public class JMJkEduArticleService extends BaseService {
            heapm.setComputeTime(computeTime(article.getString("insertTime")));
            heapm.setOperatorName(article.getString("operatorName"));
            heapm.setSendType(one.getSendType());//发送类型
            heapm.setIsread(one.getIsread());//已读未读标识,1已读,2未读
            heapm.setLeaveWords(one.getLeaveWords());
            heapm.setIsread(String.valueOf(one.getIsRead()));//已读未读标识,1已读,2未读
            heapm.setLeaveWords(one.getLeaveWords());//医生留言
            doctor = doctorDao.findByCode(one.getDoctorCode());
            heapm.setPhoto(doctor.getPhoto());
            result.add(heapm);

+ 49 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jkEduArticle/ThirdJkEduArticleService.java

@ -28,6 +28,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import springfox.documentation.spring.web.json.Json;
import java.util.*;
@ -94,6 +95,7 @@ public class ThirdJkEduArticleService extends BaseService {
    /*********************************************** Category ******************************************/
    private String getCategoryList = "JkEdu.Category.getCategoryList";//获取类别接口
    private String addCategory = "JkEdu.Category.addCategory";//新增类别接口
    private String checkCategory = "JkEdu.Category.checkCategory";//验证类别接口
    private String updateCategory = "JkEdu.Category.updateCategory";//更新类别接口
    /*********************************************** ConfigDicSho ***************************************/
    private String getConfigDicShoList = "JkEdu.ConfigDicSho.getConfigDicShoList";//更新类别接口
@ -102,6 +104,7 @@ public class ThirdJkEduArticleService extends BaseService {
    private String updateArticleQRCode = "JkEdu.ArticleQR.updateArticleQRCode";//更新认证标识
    private String saveArticleQRCode = "JkEdu.ArticleQR.saveArticleQRCode";//添加认证标识
    private String getArticleQRCodeById = "JkEdu.ArticleQR.getArticleQRCodeById";//根据id获取认证标识
    private String saveBehavior = "JkEdu.Behavior.saveBehavior";//根据id获取认证标识
    /**
     * 封装入参
     *
@ -724,6 +727,31 @@ public class ThirdJkEduArticleService extends BaseService {
        }
    }
    /**
     * 添加分类
     * @param categoryLevel
     * @return
     * @throws Exception
     */
    public boolean checkCategory(String categoryName,Integer categoryLevel) throws Exception {
        JSONObject json = null;
        try {
            JSONObject param = new JSONObject();
            param.put("categoryName", categoryName);
            param.put("categoryLevel", categoryLevel);
            String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(checkCategory, param.toString(), "1"));
            json = JSON.parseObject(response);
            JSONArray j = (JSONArray) json.get("result");
            if(j!=null&&j.size()>0){
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    /**
     * 更新文章分类
     * @param categoryId
@ -893,6 +921,27 @@ public class ThirdJkEduArticleService extends BaseService {
        }
    }
    /**************************************************** behaver *******************************************************/
    public void saveBehavior(String articleId,String cName,String userId) throws Exception {
        JSONObject json = null;
        try{
            JSONObject param = new JSONObject();
            param.put("articleId",articleId);// 文章ID
            param.put("cName",cName);//用户名称
            param.put("userId",userId);//用户ID
            String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(saveBehavior, param.toString(), "1"));
            json = JSON.parseObject(response);
        }catch (Exception e) {
            e.printStackTrace();
        }
        if (!"10000".equals(json.getString("Code"))) {
            throw new Exception(json.getString("Message"));
        }
    }
    /**************************************************** other *******************************************************/
    /**

+ 17 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -23,6 +23,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -111,12 +113,26 @@ public class ElasticsearchUtil {
                            if (heads.get(i).contains("date_histogram")) {
                                key = "setQuotaDate";
                            }
                            
                            try {
                                //yyyy-MM-dd'T'HH:mm:ssXX
                                value = dateFormat.parse(String.valueOf(one.get(i)));
                            } catch (Exception e) {
                                //yyyy-MM-dd HH:mm:ss
                                value = dateFormat1.parse(String.valueOf(one.get(i)));
                                try {
                                    value = dateFormat1.parse(String.valueOf(one.get(i)));
                                }catch (Exception e1){
                                    Timestamp ts = new Timestamp(Long.parseLong(String.valueOf(one.get(i))));
                                    try {
                                        Date date = new Date();
                                        date = ts;
                                        value =date;
                                    
                                    } catch (Exception e2) {
                                        value = String.valueOf(one.get(i));
                                    }
                                }
                                
                            }
//                            value = DateUtil.strToDate(String.valueOf(value).replace("T00:00:00+0800", " 00:00:00"), "yyyy-MM-dd HH:mm:ss");
                        }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java

@ -47,7 +47,7 @@ public class BaseController {
            JSONObject json = new JSONObject(userAgent);
            return json.getString("uid");
//            return "hqD2016082902";// wjw00000001000e6badcfa163e424589/wjw00000001000e6badcfa163e424525
//            return "xh1D2017031502222";// wjw00000001000e6badcfa163e424589/wjw00000001000e6badcfa163e424525
        } catch (Exception e) {
            return null;
        }

+ 47 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -12,14 +12,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -42,7 +33,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
@ -568,6 +558,53 @@ public class FileUploadController extends BaseController {
        }
    }
    /**
     * 图片上传
     *
     * @return
     * @throws IOException
     * @throws IllegalStateException
     */
    @RequestMapping(value = "pcimage", method = RequestMethod.POST  /*,headers = "Accept=image/png"*/ )
    @ResponseBody
    public String pcimage(HttpServletRequest request, HttpServletResponse response) {
        if (isneiwang) {
            // 圖片列表
            List<String> tempPaths = new ArrayList<String>();
            try {
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                    // 上传文件
                    MultipartFile mf = entity.getValue();
                    InputStream inputStream  = mf.getInputStream();
                    String fileName = mf.getOriginalFilename().substring(0,mf.getOriginalFilename().lastIndexOf("."));
                    ObjectNode imgNode = FastDFSUtil.upload(inputStream,"png",fileName);
                    tempPaths.add(imgNode.get("fid").toString());
                }
                String urls = "";
                for (String image : tempPaths) {
                    if (urls.length() == 0) {
                        urls = image;
                    } else {
                        urls += "," + image;
                    }
                }
                JSONObject json = new JSONObject();
                json.put("status", 200);
                json.put("msg", "上传成功");
                json.put("urls", urls);
                logger.info("图片上传:" + json.toString());
                return json.toString();
            } catch (Exception e) {
                error(e);
                return error(-1, "上传失败");
            }
        } else {
            return CommonUtil.toNeiWang(request, response);
        }
    }
//    @RequestMapping(value = "fastDFSImags", method = RequestMethod.POST)
//    @ApiOperation("编辑文章上传图片")
//    @ResponseBody

+ 61 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java

@ -1,7 +1,10 @@
package com.yihu.wlyy.web.common.sms;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
@ -25,6 +28,8 @@ import java.util.List;
@Api(description = "短信")
public class SMSController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(PrescriptionInfoService.class);
	@Autowired
	public SMSService smsService;
	@Autowired
@ -94,6 +99,62 @@ public class SMSController extends BaseController {
		}
	}
	@RequestMapping(value = "checkCaptcha", method = RequestMethod.POST)
	@ResponseBody
	public String send2(String mobile, int type, @RequestParam(required = false) String captchaToken) {
		try {
			logger.info("in checkCaptcha");
			if (type > 10 || type < 1) {
				return error(-1, "无效的请求!");
			}
			if (StringUtils.isEmpty(mobile)) {
				return error(-1, "手机号码不允许为空!");
			}
//			if (type == 4) {
//				// 登录时校验用户是否存在
//				List<Patient> patients = patientDao.findByMobile(mobile);
//				if (patients == null||patients.size()==0) {
//					return error(-1, "该手机号未注册!");
//				}
//			} else if (type == 5) {
//				// 登录时校验用户是否存在
//				Doctor doctor = doctorDao.findByMobile(mobile);
//				if (doctor == null) {
//					return error(-1, "该手机号未注册!");
//				}
//			}
			if (StringUtils.isNotEmpty(captchaToken)) {
				String ct = request.getSession().getAttribute("captchaToken").toString();
				if (!StringUtils.equalsIgnoreCase(captchaToken, ct)) {
					return error(-1, "图形验证码错误!");
				}
			}
			// 获取ip地址
			String ip = NetworkUtil.getIpAddress(request);
			if (StringUtils.isEmpty(ip)) {
				return error(-1, "无效的ip请求!");
			}
//			String res = smsService.send(mobile, ip, type, getUID());
			String res = null;
			//内网发送 通过redis的队列
			if("local".equals(springProfiles)){
				logger.info("sendToNeiWang");
				res = smsService.sendToNeiWang(mobile, ip, type);
			}else {
				logger.info("smsService.send");
				res = smsService.send(mobile, ip, type, getRepUID());
			}
			if (StringUtils.equals(res, "ok")) {
				return write(200, "验证码短信已发送!");
			} else {
				return error(-1, res);
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "短信发送失败!");
		}
	}
	/**
	 * 验证手机验证码
	 * @param type 消息类型:1微信端注册,2微信端找回密码,3医生端找回密码

+ 48 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -46,6 +46,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -97,6 +98,53 @@ public class DoctorController extends BaseController {
    @Autowired
    private RSAUtils rsaUtils;
    @ApiOperation("获取当前登录医生的角色")
    @RequestMapping(value = "doctorRole",method =RequestMethod.GET)
    @ResponseBody
    public String doctorRole(){
        try{
            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
            Map<String, Object> map = new HashMap<>();
            map.put("id", doctor.getId());
            map.put("uid", doctor.getCode());
            map.put("name", doctor.getName());
            map.put("hospital", doctor.getHospital());
            map.put("hospitalName", doctor.getHospitalName());
            map.put("photo", doctor.getPhoto());
            // 设置医生类型:1专科医生,2全科医生,3健康管理师
            map.put("doctorType", doctor.getLevel());
            //获取医生角色和区域权限
            List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
            map.put("userRole", roleMap);
            //医生当前登录的角色
            if(roleMap.size()>0){
                for(Map<String, String> one:roleMap){
                    if("1".equals(one.get("isManage"))){
                        map.put("currentUserRole", one);
                        continue;
                    }
                }
            }else{
                Map<String, String> one = new HashMap<>();
                one.put("isManage","0");
                one.put("code", doctor.getHospital());
                one.put("name", doctor.getHospitalName());
                one.put("areas", "");
                one.put("level","4");
                one.put("authOperate", "0");
                map.put("currentUserRole", one);
            }
            if ("10" .equals(doctor.getLevel()) && roleMap.size() == 0) {
                return error(-1, "该用户没有管理员权限");
            }
            return write(200, "登录成功", "data", map);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    /**
     * 社区医院下医生列表查询接口 没分页

+ 16 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEdu/DoctorJMJkEduArticleController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.doctor.jimeiJkEdu;
import com.alibaba.fastjson.JSONObject;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.education.HealthEduArticle;
@ -57,21 +58,21 @@ public class DoctorJMJkEduArticleController extends BaseController {
     * 发送到redis
     *
     */
    public void sender(HealthEduArticlePatient healthEduArticlePatient) {
    public void sender(List<HealthEduArticleES> HealthEduArticleES) {
        //送到到队列
        List<Patient> patients = healthEduArticlePatient.getPatients();
        patients.stream().forEach(one -> {
            healthEduArticlePatient.setPatient(one.getCode());
            healthEduArticlePatient.setPatients(null);
//        List<Patient> patients = healthEduArticlePatient.getPatients();
        HealthEduArticleES.stream().forEach(one -> {
//            healthEduArticlePatient.setPatient(one.getCode());
//            healthEduArticlePatient.setPatients(null);
            //temp.setUrl(url + "jkjy/html/article.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
//            healthEduArticlePatient.setArticleUrl(articleBaseUrl+"jkjy/html/article2.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"))
//            healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+healthEduArticlePatient.getArticleId()+"&userId="+one);
            healthEduArticlePatient.setArticleUrl("新版文章请求路径");
            one.setNewArricleFlag(true);
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(healthEduArticlePatient).toString());
                    textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
                    return textMessage;
                }
            });
@ -147,13 +148,13 @@ public class DoctorJMJkEduArticleController extends BaseController {
            jmJkEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType,getUID(),currentRoleCode,currentRoleLevel);
//            patientSet.add(patientService.findByCode("wjw00000001000e6badcfa163e424525"));
            //获取保存发送记录
            patientSet = new HashSet<>();
            patientSet.add("915cc456-5b1d-11e6-8344-fa163e8aee56");
            HealthEduArticlePatient healthEduArticlePatient = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), 2,"", 0L, articleId,leaveWords,currentRoleCode,currentRoleLevel);
//            patientSet = new HashSet<>();
//            patientSet.add("915cc456-5b1d-11e6-8344-fa163e8aee56");
            List<HealthEduArticleES> healthEduArticleESList = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), 2,"", 0L, articleId,leaveWords,currentRoleCode,currentRoleLevel);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
                sender(healthEduArticleESList);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
@ -351,11 +352,11 @@ public class DoctorJMJkEduArticleController extends BaseController {
            if(StringUtils.isEmpty(currentUserRoleLevel)){
                currentUserRoleLevel = getCurrentRoleLevel();
            }
            HealthEduArticlePatient healthEduArticlePatient = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), 1,"", teamCode, articleId,leaveWords,currentUserRole,currentUserRoleLevel);
            List<HealthEduArticleES> healthEduArticleESList = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), 1,"", teamCode, articleId,leaveWords,currentUserRole,currentUserRoleLevel);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
                sender(healthEduArticleESList);
            }).start();
            return new BaseResultModel();
        } catch (Exception e) {
@ -384,11 +385,11 @@ public class DoctorJMJkEduArticleController extends BaseController {
            //得到需要发送的患者
            patientSet.add(patientCode);
//            jmJkEduArticleService.initPatients(patientSet,labelType,condition,groupType,teamId,getUID());
            HealthEduArticlePatient healthEduArticlePatient = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), 1,"", 0L, articleId,leaveWords,currentUserRole,currentUserRoleLevel);
            List<HealthEduArticleES> healthEduArticleESList = jmJkEduArticleService.savePCPushArticle(patientSet, getUID(), 1,"", 0L, articleId,leaveWords,currentUserRole,currentUserRoleLevel);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
                sender(healthEduArticleESList);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {

+ 9 - 18
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEduPC/DoctorJMJkEduArticlePCController.java

@ -2,15 +2,10 @@ package com.yihu.wlyy.web.doctor.jimeiJkEduPC;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -19,10 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -285,18 +276,18 @@ public class DoctorJMJkEduArticlePCController extends BaseController {
            }
            List<HealthEduArticlePatientModel> eduArticlePatients = jmJkEduArticleService.pushArticleList(page, pagesize, getUID(),firstLevelCategoryId,secondLevelCategoryId,myArticle,sendType,currentRoleCode,currentRoleLevel,articleTitle,sendTimeStart,sendTimeEnd);
//            Long count = jmJkEduArticleService.pushArticleListCount(getUID(),2);
            List<HealthEduArticlePatient> eduArticlePatientsCount = jmJkEduArticleService.pushArticleListCount(getUID(),firstLevelCategoryId,secondLevelCategoryId,myArticle,sendType,currentRoleCode,
            List<HealthEduArticleES> eduArticlePatientsCount = jmJkEduArticleService.pushArticleListCount( getUID(),firstLevelCategoryId,secondLevelCategoryId,myArticle,sendType,currentRoleCode,
                    currentRoleLevel, articleTitle,sendTimeStart, sendTimeEnd);
            net.sf.json.JSONObject obj = new net.sf.json.JSONObject();
            obj.put("Code", 100);
            obj.put("Message", "成功");
            JSONArray obj2 = new JSONArray();
            if(!eduArticlePatients.isEmpty()){
                for (int i = 0; i < eduArticlePatients.size(); i++) {
                    obj2.add(eduArticlePatients.get(i));
                }
            }
            obj.put("aaData",  obj2.toString());
//            JSONArray obj2 = new JSONArray();
//            if(!eduArticlePatients.isEmpty()){
//                for (int i = 0; i < eduArticlePatients.size(); i++) {
//                    obj2.add(eduArticlePatients.get(i));
//                }
//            }
            obj.put("aaData",  eduArticlePatients);
            obj.put("iTotalDisplayRecords", eduArticlePatientsCount.size());
            obj.put("iTotalRecords", eduArticlePatientsCount.size());
            obj.put("sEcho", sEcho);

+ 6 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.app.health.HealthEduArticlePatientService;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
@ -57,7 +58,7 @@ public class HealthEduArticleController extends BaseController {
    private ThirdJkEduArticleService healthEducationArticleService;
    
    @Autowired
    private ThirdJkEduArticleService thirdJkEduArticleService;
    private JMJkEduArticleService jmJkEduArticleService;
    /**
     * 查询文章列表
@ -206,11 +207,13 @@ public class HealthEduArticleController extends BaseController {
    @RequestMapping(value = "/readAllArticle", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("对当前用户的所有未读文章设置为已读")
    public String readAllArticle() {
    public String readAllArticle(@ApiParam(name = "firstLevelCategoryId", value = "一级分类ID")
                                     @RequestParam(value = "firstLevelCategoryId", required = true) String firstLevelCategoryId) {
        try {
//            String patient = getUID();
            String patient = getRepUID();
            healthEduArticleService.readAllArticle(patient);
//            healthEduArticleService.readAllArticle(patient);
            jmJkEduArticleService.readAllArticleNew(patient,firstLevelCategoryId);
            return write(200, "更改状态成功!");
        } catch (Exception e) {
            error(e);

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/jimeiJkEdu/PatientJMJkEduArticleController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.patient.jimeiJkEdu;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -28,6 +29,8 @@ public class PatientJMJkEduArticleController extends BaseController {
    @Autowired
    private JMJkEduArticleService jmJkEduArticleService;
    @Autowired
    private ThirdJkEduArticleService thirdJkEduArticleService;
    @RequestMapping(value = "fetchArticlePushedList", method = RequestMethod.GET)
    @ApiOperation("居民获取被推送文章列表 ")
@ -183,4 +186,20 @@ public class PatientJMJkEduArticleController extends BaseController {
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "saveBehavior", method = RequestMethod.POST)
    @ApiOperation("添加 浏览、转发、分享、点赞 ")
    public String saveBehavior(
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "cName", value = "用户名称", required = true) @RequestParam(value = "cName", required = true) String cName,
            @ApiParam(name = "userId", value = "用户ID", required = true) @RequestParam(value = "userId", required = false) String  userId){
        try {
            thirdJkEduArticleService.saveBehavior(articleId,cName,userId);
//            Long count = healthEducationArticleService.pushArticleLogsCount("ece5c665b16542b0847e52b4a9fee44a");
            return write(200,"保存成功!");
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"保存失败!");
        }
    }
}

+ 41 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/HealthEduArticlePatientModel.java

@ -25,8 +25,12 @@ public class HealthEduArticlePatientModel {
    private String articleType;//文章类别
    @ApiModelProperty(value = "1级类别", required = false, access = "response")
    private String level1Type;//1级类别
    @ApiModelProperty(value = "1级类别名称", required = false, access = "response")
    private String level1TypeName;//1级类别
    @ApiModelProperty(value = "2级类别", required = false, access = "response")
    private String level2Type;//2级类别
    @ApiModelProperty(value = "2级类别名称", required = false, access = "response")
    private String level2TypeName;//2级类别
    @ApiModelProperty(value = "等级", required = false, access = "response")
    private String level;//等级
    @ApiModelProperty(value = "所有的推送数目", required = false, access = "response")
@ -43,8 +47,12 @@ public class HealthEduArticlePatientModel {
    private Integer sendType = 0;//发送类型 1医生发送 2卫纪委发送
    @ApiModelProperty(value = "已读未读标识:1已读,0未读", required = false, access = "response")
    private String isread;//已读未读
    @ApiModelProperty(value = "", required = false, access = "response")
    @ApiModelProperty(value = "医生留言", required = false, access = "response")
    private String leaveWords;//医生留言
    @ApiModelProperty(value = "收藏数", required = false, access = "response")
    private Integer collectionNumber;//收藏数
    @ApiModelProperty(value = "文章来源", required = false, access = "response")
    private String articleSource;//文章来源
    
    private String computeTime;//时间
    private String photo;//医生头像
@ -217,4 +225,36 @@ public class HealthEduArticlePatientModel {
    public void setLeaveWords(String leaveWords) {
        this.leaveWords = leaveWords;
    }
    
    public String getLevel1TypeName() {
        return level1TypeName;
    }
    
    public void setLevel1TypeName(String level1TypeName) {
        this.level1TypeName = level1TypeName;
    }
    
    public String getLevel2TypeName() {
        return level2TypeName;
    }
    
    public void setLevel2TypeName(String level2TypeName) {
        this.level2TypeName = level2TypeName;
    }
    public Integer getCollectionNumber() {
        return collectionNumber;
    }
    public void setCollectionNumber(Integer collectionNumber) {
        this.collectionNumber = collectionNumber;
    }
    
    public String getArticleSource() {
        return articleSource;
    }
    
    public void setArticleSource(String articleSource) {
        this.articleSource = articleSource;
    }
}

+ 29 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkEduArticle/ThirdJkEduArticleController.java

@ -83,7 +83,7 @@ public class ThirdJkEduArticleController extends BaseController {
                                           @ApiParam(name = "patient", value = "居民CODE")
                                           @RequestParam(value = "patient", required = false) String patient){
        try {
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"rll201703150222",userType,myArticle);
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getRepUID(),userType,myArticle);
//            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"812f75071f434fde9a1fb64c6213a897",userType,myArticle);
    
            //判断文章列表是否有推送过该居民
@ -117,9 +117,16 @@ public class ThirdJkEduArticleController extends BaseController {
    @RequestMapping(value = "getArticalById",method = RequestMethod.GET)
    @ApiOperation("获取文章详情")
    public String getArticalById(@ApiParam(name = "articleId", value = "文章id",defaultValue = "1")
                                 @RequestParam(value = "articleId", required = true) String articleId){
                                 @RequestParam(value = "articleId", required = true) String articleId,
                                 @ApiParam(name = "userType", value = "用户类型:1医生,2居民",defaultValue = "1")
                                 @RequestParam(value = "userType", required = false) String userType){
        try {
            com.alibaba.fastjson.JSONObject response = thirdJkEduArticleService.getArticalById(articleId,getRepUID());
            com.alibaba.fastjson.JSONObject response = thirdJkEduArticleService.getArticalById(articleId,getUID());
            
            if("2".equals(userType)){
                jmJkEduArticleService.readPatientArticle(getRepUID(),articleId);
            }
            
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
@ -242,6 +249,10 @@ public class ThirdJkEduArticleController extends BaseController {
    ){
        try {
            boolean flag = thirdJkEduArticleService.checkCategory(categoryName,categoryLevel);
            if(flag){
                return error(-2,"文章分类名称重复!");
            }
            thirdJkEduArticleService.addCategory(categoryName,categoryLevel,firstlevelId,secondLevelId,getUID(),getCurrentRoleCode());
            return success("添加成功!");
        }catch (Exception e){
@ -250,6 +261,21 @@ public class ThirdJkEduArticleController extends BaseController {
        }
    }
    @RequestMapping(value = "checkCategory",method = RequestMethod.POST)
    @ApiOperation("添加二级分类-仅向市级管理员开放编辑权限")
    public String checkCategory(@ApiParam(name = "categoryName", value = "文章分类名称")
                              @RequestParam(value = "categoryName", required = true) String categoryName,
                              @ApiParam(name = "categoryLevel", value = "分类级别-默认二级")
                              @RequestParam(value = "categoryLevel", required = true,defaultValue = "2") Integer categoryLevel){
        try {
            thirdJkEduArticleService.checkCategory(categoryName,categoryLevel);
            return success("添加成功!");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"添加失败!");
        }
    }
    @RequestMapping(value = "updateCategory",method = RequestMethod.POST)
    @ApiOperation("更新二级分类-仅向市级管理员开放编辑权限")
    public String updateCategory(@ApiParam(name = "categoryId", value = "文章分类code")

+ 2 - 2
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -101,11 +101,11 @@ pushMes:
  redis_prescription_title: redisMessage
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test3
    HealthEduArticlePatient: health_edu_article_patient_test5
    FollowUp: wlyy_followup
    Statistics: wlyy_quota_test
  type:
    HealthEduArticlePatient: health_edu_article_patient_test3
    HealthEduArticlePatient: health_edu_article_patient_test5
    FollowUpContent: wlyy_followup_content
    Statistics: wlyy_quota_test
  host:  http://172.19.103.68:9200

+ 3 - 3
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -119,9 +119,9 @@ jkEdu:
#消息队列
activemq:
  username: admin
  password: admin
  url: tcp://172.19.103.87:61616
  username: jkzl
  password: jkzlehr
  url: tcp://192.168.120.153:61616
  queue:
    healtHarticleQueue: healthArticleChannel  #健康文章推送

+ 3 - 8
pom.xml

@ -11,15 +11,10 @@
    <!--deploy 的时候发布到这个服务器-->
    <distributionManagement>
        <repository>
            <id>releases</id>
            <name>Releases</name>
            <url>http://172.19.103.43:8081/nexus/content/repositories/releases/</url>
            <id>test</id>
            <name>testRespository</name>
            <url>http://172.19.103.43:8081/nexus/content/repositories/test/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshots</name>
            <url>http://172.19.103.43:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <properties>