Browse Source

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

zd_123 7 years ago
parent
commit
51e1a047a1
27 changed files with 798 additions and 330 deletions
  1. 1 1
      common/common-entity/pom.xml
  2. 30 15
      common/common-entity/src/main/java/com/yihu/es/entity/HealthEduArticlePatient.java
  3. 8 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  4. 5 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java
  5. 2 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/UserDao.java
  6. 17 5
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java
  7. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/AppealService.java
  8. 3 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java
  9. 5 0
      patient-co/patient-co-statistics-es/pom.xml
  10. 24 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java
  11. 5 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  12. 8 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  13. 62 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  14. 91 55
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java
  15. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  16. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  17. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  18. 8 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/DoctorPrescriptionFollowupContentController.java
  19. 52 31
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java
  20. 2 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java
  21. 304 76
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java
  22. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcLabelService.java
  23. 21 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/HealthEduArticlePatientModel.java
  24. 101 107
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduDoctorArticleController.java
  25. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduLableController.java
  26. 32 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/template/ThirdTemplateController.java
  27. 2 2
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

+ 1 - 1
common/common-entity/pom.xml

@ -66,7 +66,7 @@
        <!--<dependency>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
            <!--<version>1.1.1.RELEASE</version>-->
            <!--<version>1.3.5.RELEASE</version>-->
        <!--</dependency>-->
    </dependencies>

+ 30 - 15
common/common-entity/src/main/java/com/yihu/es/entity/HealthEduArticlePatient.java

@ -1,10 +1,13 @@
package com.yihu.es.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.patient.Patient;
import io.searchbox.annotations.JestId;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Transient;
import java.util.Date;
import java.util.List;
/**
 * 推送记录表
@ -13,7 +16,9 @@ import java.util.Date;
public class HealthEduArticlePatient {
    @JestId
    private String id;
    @Transient
    private String patient; // 患者标识
    @Transient
    private String patientName;    // 患者标识
    private String sendCode;   // 发送人code
    private String sendName;   // 发送人名称
@ -45,6 +50,7 @@ public class HealthEduArticlePatient {
    private Integer allCount;//所有的推送数目
    private String type;//推送类型 1:文章 2:健康课程
    private String articleUrl;//集美宣教,文章的url
    private List<Patient> patients;//被推送文章的患者
    public String getId() {
        return id;
@ -54,21 +60,6 @@ public class HealthEduArticlePatient {
        this.id = id;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getSendCode() {
        return sendCode;
@ -277,4 +268,28 @@ public class HealthEduArticlePatient {
    public void setArticleUrl(String articleUrl) {
        this.articleUrl = articleUrl;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public List<Patient> getPatients() {
        return patients;
    }
    public void setPatients(List<Patient> patients) {
        this.patients = patients;
    }
}

+ 8 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java

@ -449,4 +449,12 @@ public class Patient extends IdEntity implements Serializable {
    public void setStandardStatus(Integer standardStatus) {
        this.standardStatus = standardStatus;
    }
    public Patient(String code, String name) {
        this.code = code;
        this.name = name;
    }
    public Patient(String code) {
        this.code = code;
    }
}

+ 5 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java

@ -254,14 +254,17 @@ public class CustomerController extends BaseController {
    @RequestMapping(value = "/getCallRecords", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "获取通讯记录列表")
    public String getCallRecords(@ApiParam(name="callerNumber",value="呼叫人电话")@RequestParam(required = false)String callerNumber,
                                 @ApiParam(name="recipientNumber",value="客服座机电话")@RequestParam(required = false)String recipientNumber,
                                 @ApiParam(name="answerStatus",value="接听状态: 1.接通,2. 队列中放弃,3.未接通")@RequestParam(required = false)Integer answerStatus,
                                 @ApiParam(name="serviceType",value="服务类型:0.医生咨询,1.预约挂号")@RequestParam(required = false)Integer serviceType ,
                                 @ApiParam(name="serviceType",value="服务类型:1.医生转接 2.代理咨询")@RequestParam(required = false)Integer serviceType ,
                                 @ApiParam(name="userName",value="客服名称(模糊匹配)")@RequestParam(required = false)String  userName ,
                                 @ApiParam(name="jobNo",value="客服工号")@RequestParam(required = false)String jobNo ,
                                 @ApiParam(name="startDate",value="开始时间")@RequestParam(required = false)String startDate,
                                 @ApiParam(name="endDate",value="结束时间")@RequestParam(required = false)String endDate,
                                 @ApiParam(name="page",value="第几页,从1开始")@RequestParam(required = true)Integer page,
                                 @ApiParam(name="size",value="页码大小")@RequestParam(required = true)Integer size){
        try {
            return write(200,"查询成功","data",customerService.getCallRecords(callerNumber,answerStatus,serviceType,startDate,endDate,page,size));
            return write(200,"查询成功","data",customerService.getCallRecords(callerNumber,recipientNumber,answerStatus,serviceType,userName,jobNo,startDate,endDate,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");

+ 2 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/UserDao.java

@ -34,4 +34,6 @@ public interface UserDao extends PagingAndSortingRepository<User, Long>, JpaSpec
    @Query("from User a where a.name like ?1 order by code")
    Page<User> searchUsersByName(String name, Pageable pageRequest);
	User findByJobNo(String jobNo);
}

+ 17 - 5
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -270,7 +270,7 @@ public class CustomerService extends BaseService{
		return "1";
	}
	public Map<String,Object> getCallRecords(String callerNumber,Integer answerStatus,Integer serviceType ,String startDate,String endDate,Integer page,Integer size){
	public Map<String,Object> getCallRecords(String callerNumber,String recipientNumber, Integer answerStatus,Integer serviceType ,String userName,String jobNo,String startDate,String endDate,Integer page,Integer size){
		Map<String,Object> map = new HashedMap();
@ -279,7 +279,7 @@ public class CustomerService extends BaseService{
				" manage_call_record r " +
				" WHERE " +
				" 1 = 1 ";
		sqltotal = setCallRecordSql( sqltotal, callerNumber, answerStatus, serviceType , startDate, endDate);
		sqltotal = setCallRecordSql( sqltotal, callerNumber,recipientNumber, answerStatus, serviceType ,userName,jobNo, startDate, endDate);
		List<Map<String,Object>> rsTotal = jdbcTemplate.queryForList(sqltotal);
		Long total = (Long)rsTotal.get(0).get("total");
@ -301,12 +301,13 @@ public class CustomerService extends BaseService{
				" r.type AS type, " +
				" r.user_name AS userName, " +
				" r.user_code AS userCode," +
				" r.code" +
				" r.code," +
				" r.service_type AS serviceType" +
				" FROM " +
				" manage_call_record r " +
				" WHERE " +
				" 1 = 1 ";
		sql = setCallRecordSql( sql, callerNumber, answerStatus, serviceType , startDate, endDate);
		sql = setCallRecordSql( sqltotal, callerNumber,recipientNumber, answerStatus, serviceType ,userName,jobNo, startDate, endDate);
		sql += " ORDER BY r.call_time DESC LIMIT "+(page-1)*size+","+size;
		List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -319,7 +320,7 @@ public class CustomerService extends BaseService{
		return map;
	}
	public String setCallRecordSql(String sql,String callerNumber,Integer answerStatus,Integer serviceType ,String startDate,String endDate){
	public String setCallRecordSql(String sql,String callerNumber,String recipientNumber,Integer answerStatus,Integer serviceType ,String userName,String jobNo,String startDate,String endDate){
		if(StringUtils.isNotBlank(callerNumber)){
			sql +=" AND r.caller_number = '"+callerNumber+"'";
		}
@ -335,6 +336,17 @@ public class CustomerService extends BaseService{
		if(StringUtils.isNotBlank(endDate)){
			sql +=" AND r.call_time <='"+endDate+" 23:59:59'";
		}
		if(StringUtils.isNotBlank(userName)){
			sql +=" AND r.user_name LIKE '%"+userName+" %'";
		}
		if(StringUtils.isNotBlank(jobNo)){
			User u = userDao.findByJobNo(jobNo);
			sql +=" AND r.user_code = '"+u.getCode()+"'";
		}
		if(StringUtils.isNotBlank(recipientNumber)){
			sql +=" AND r.recipient_number = '"+recipientNumber+" '";
		}
		return sql;
	}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/AppealService.java

@ -261,7 +261,7 @@ public class AppealService extends BaseService {
                //wlyy给医生发送系统消息
                Doctor doctor = doctorDao.findByCode(creater);
                String doctorOpenID = doctor.getOpenid();
                String url = wlyyService + "/doctor/feedback/sendMessage";
                String url = wlyyService + "/third/template/sendMessage";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("receiver", creater));
                params.add(new BasicNameValuePair("title", title));

+ 3 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java

@ -217,8 +217,9 @@ public class FeedbackService extends BaseService {
                String patientName = patient.getName();
                String patientOpendID = patient.getOpenid();
                if (StringUtils.isNotEmpty(patientOpendID)) {
                    String url = wlyyService + "/patient/feedback/sendTemplate";
                    String url = wlyyService + "/third/template/sendTemplate";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "2"));
                    params.add(new BasicNameValuePair("toUser", patientOpendID));
                    params.add(new BasicNameValuePair("url", null));
                    params.add(new BasicNameValuePair("first", "您好!您提交的意见反馈已处理"));
@ -252,7 +253,7 @@ public class FeedbackService extends BaseService {
                //wlyy给医生发送系统消息
                Doctor doctor = doctorDao.findByCode(creater);
                String doctorOpenID = doctor.getOpenid();
                String url = wlyyService + "/doctor/feedback/sendMessage";
                String url = wlyyService + "/third/template/sendMessage";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("receiver", creater));
                params.add(new BasicNameValuePair("title", title));

+ 5 - 0
patient-co/patient-co-statistics-es/pom.xml

@ -450,6 +450,11 @@
            <artifactId>fastjson</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
            <!--<version>1.3.5.RELEASE</version>-->
        <!--</dependency>-->
    </dependencies>
    <build>

+ 24 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java

@ -54,4 +54,28 @@ public class ElastricSearchSave {
        return null;
    }
    public Boolean save(Object obj, String esIndex, String esType) {
        JestClient jestClient = null;
        try {
            //得到链接
            jestClient = elasticFactory.getJestClient();
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            Index index = new Index.Builder(obj).build();
            bulk.addAction(index);
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("save flag:" + br.isSucceeded());
            return br.isSucceeded();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(" save error :" + e.getMessage());
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return null;
    }
}

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -2641,9 +2641,9 @@ public class ConsultTeamService extends ConsultService {
    public void addPrescriptionBloodStatusConsult(String prescriptionCode, String type,String followupid) throws Exception {
        
        if("1".equals(type)){//血压
            prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptionCode,followupid,true);
            prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptionCode,followupid,true,"");
        }else if("2".equals(type)){//血糖
            prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptionCode,followupid,true);
            prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptionCode,followupid,true,"");
        }
        
    }
@ -2668,8 +2668,8 @@ public class ConsultTeamService extends ConsultService {
        contentobj.put("isSendWxTemplate",true);//是否发送咨询回复的微信模板
        //医生发送Im消息
        ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "17", contentobj.toString(), null);
        contentobj.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
        //居民发送Im消息
        ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "17", contentobj.toString(), null);
//        contentobj.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
//        //居民发送Im消息
//        ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "17", contentobj.toString(), null);
    }
}

+ 8 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -927,17 +927,19 @@ public class FollowUpService extends BaseService {
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
            FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
            //删除原有记录
            this.esDeleteFollowUpContent(dataList);
            List<FollowupContentESDO> dataList = new ArrayList<>();
            if(followupContentESDO != null){
                dataList.add(followupContentESDO);
                //删除原有记录
                this.esDeleteFollowUpContent(dataList);
            }
            //保存新的随访详情信息
            List<FollowupContentESDO> newdatalist = new ArrayList<>();
            FollowupContentESDO followupContentESDO = new FollowupContentESDO();
            followupContentESDO = new FollowupContentESDO();
            followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
            followupContentESDO.setFollowup_id(id);
            followupContentESDO.setFollowup_project(followupProject);
            followupContentESDO.setCreate_time(new Date());

+ 62 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -470,9 +470,10 @@ public class PrescriptionExpressageService extends BaseService {
        return rs;
    }
    public List<Map<String, Object>> getEsListByIDCardOrSSC(String keyWord, Integer page, Integer pageSize) {
    public Map<String, Object> getEsListByIDCardOrSSC(String keyWord, Integer page, Integer pageSize) {
        Patient p = null;
        Map<String,Object> map = new HashedMap();
        if (StringUtils.isNotBlank(keyWord)) {
            p = patientDao.findByIdcard(keyWord);
            if (p == null) {
@ -480,6 +481,26 @@ public class PrescriptionExpressageService extends BaseService {
            }
            if (p != null) {
                int start = (page - 1) * pageSize;
                String sqlTotal ="SELECT count(1) AS total" +
                        " FROM " +
                        " wlyy_prescription p " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                        " WHERE " +
                        " p.patient = '" + p.getCode() + "' " +
                        " AND p.`status`>=50 " +
                        " ORDER BY p.`status` ASC ";
                List<Map<String, Object>> totallist = jdbcTemplate.queryForList(sqlTotal);
                Long total = (Long)totallist.get(0).get("total");
                if(total==0){
                    map.put("list",null);
                    map.put("page",page);
                    map.put("total",0);
                    map.put("records",0);
                    return map;
                }
                String sql = "SELECT " +
                        "  py.charge_no AS chargeNo, " +
                        "  p.patient_name AS patientName, " +
@ -497,10 +518,17 @@ public class PrescriptionExpressageService extends BaseService {
                        " ORDER BY p.`status` ASC " +
                        " LIMIT " + start + "," + pageSize;
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                return list;
                map.put("page",page);
                map.put("records",total);
                map.put("list",list);
                double t = (double)total;
                map.put("total",Math.ceil(t/pageSize));
                return map;
            }
        }
        return null;
        return map;
    }
    public String saveDrugDelivery(String doctor, String prescriptionCode, String reasonCode, String reasonName, String reason) {
@ -578,7 +606,29 @@ public class PrescriptionExpressageService extends BaseService {
        return rs;
    }
    public List<Map<String, Object>> getPresEsPayList(String keyWord, String state, String type, String startDate, String endDate, String operator,String flag,Integer page, Integer pageSize) {
    public Map<String, Object> getPresEsPayList(String keyWord, String state, String type, String startDate, String endDate, String operator,String flag,Integer page, Integer pageSize) {
        Map<String, Object> map = new HashedMap();
        String totalSql = "SELECT count(1) AS total " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " WHERE" +
                " 1=1 ";
        totalSql = setSQL( totalSql,keyWord,state,type,startDate,endDate,operator,flag);
        totalSql +=  " AND p.`status`>=50 ";
        List<Map<String, Object>> totallist = jdbcTemplate.queryForList(totalSql);
        Long total = (Long)totallist.get(0).get("total");
        if(total==0){
            map.put("list",null);
            map.put("page",page);
            map.put("total",0);
            map.put("records",0);
            return map;
        }
        int start = (page - 1) * pageSize;
        String sql = "SELECT " +
                "  py.charge_no AS chargeNo, " +
@ -601,7 +651,14 @@ public class PrescriptionExpressageService extends BaseService {
                " ORDER BY py.create_time DESC " +
                " LIMIT " + start + "," + pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
        map.put("page",page);
        map.put("records",total);
        map.put("list",list);
        double t = (double)total;
        map.put("total",Math.ceil(t/pageSize));
        return map;
    }
    public String setSQL(String sql,String keyWord, String state, String type, String startDate, String endDate,String operator,String flag){

+ 91 - 55
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java

@ -3,11 +3,13 @@ package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupDrugs;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionFollowupContent;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.followup.FollowupDrugsDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
@ -55,6 +57,8 @@ public class PrescriptionFollowupContentService extends BaseService {
	private ImUtill ImUtill;
	@Autowired
	JdbcTemplate jdbcTemplate;
	@Autowired
	private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
	
	/**
	 * 根据续方CODE,文件类型获取数据
@ -266,7 +270,7 @@ public class PrescriptionFollowupContentService extends BaseService {
	 * @param prescriptioncode
	 * @param followup_id
	 */
	public void importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
	public void importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM,String healthindexid) throws Exception {
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
@ -284,7 +288,6 @@ public class PrescriptionFollowupContentService extends BaseService {
		
		List<Object> list = healthIndexService.findIndexByPatient2(patientCode, 1, stardate, enddate, 0, 2);
		
		
		String followupProjectData = "";
		
		org.json.JSONObject contentDoctor = new org.json.JSONObject();
@ -302,58 +305,57 @@ public class PrescriptionFollowupContentService extends BaseService {
			contentDoctor.put("deviceMsg","您未绑定血糖智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
		}
		
		if(!list.isEmpty()){
		if(StringUtils.isNotBlank(healthindexid) || !list.isEmpty()){
			
			for (Object o: list) {
				
				JSONObject obj = (JSONObject)o;
				
				imBloodSugarDate = obj.getDate("recordDate");
				
				//餐前
				if(StringUtils.isNotBlank(obj.getString("value1"))){
					followupProjectData = "{'BS_FPG':'"+obj.getString("value1")+"'}";
					imBloodSugarValue = obj.getString("value1");
					break;
				}
				
				if(StringUtils.isNotBlank(obj.getString("value3"))){
					followupProjectData = "{'BS_FPG':'"+obj.getString("value3")+"'}";
					imBloodSugarValue = obj.getString("value3");
					break;
				}
				
				if(StringUtils.isNotBlank(obj.getString("value5"))){
					followupProjectData = "{'BS_FPG':'"+obj.getString("value5")+"'}";
					imBloodSugarValue = obj.getString("value5");
					break;
				}
				//餐后
				if(StringUtils.isNotBlank(obj.getString("value2"))){
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value2")+"'}";
					imBloodSugarValue = obj.getString("value2");
					break;
				}
				
				
				if(StringUtils.isNotBlank(obj.getString("value4"))){
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value4")+"'}";
					imBloodSugarValue = obj.getString("value4");
					break;
				}
				
				if(StringUtils.isNotBlank(obj.getString("value6"))){
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value6")+"'}";
					imBloodSugarValue = obj.getString("value6");
					break;
				}
				
				//随机血糖
				if(StringUtils.isNotBlank(obj.getString("value7"))){
					followupProjectData = "{'RANDOM_BLOOD_SUGAR':'"+obj.getString("value7")+"'}";
					imBloodSugarValue = obj.getString("value7");
					break;
				}
			JSONObject obj = new JSONObject();
			
			//如果有传体征ID,则查体征数据
			if(StringUtils.isNotBlank(healthindexid)){
				DevicePatientHealthIndex devicePatientHealthIndex = devicePatientHealthIndexDao.findOne(new Long(healthindexid));
				obj = (JSONObject)JSON.toJSON(devicePatientHealthIndex);
			}else{
				//如果没传体征ID,则获取最近的一条
				obj = (JSONObject)list.get(0);
			}
			
			imBloodSugarDate = obj.getDate("recordDate");
			
			//餐前
			if(StringUtils.isNotBlank(obj.getString("value1"))){
				followupProjectData = "{'BS_FPG':'"+obj.getString("value1")+"'}";
				imBloodSugarValue = obj.getString("value1");
			}
			
			if(StringUtils.isNotBlank(obj.getString("value3"))){
				followupProjectData = "{'BS_FPG':'"+obj.getString("value3")+"'}";
				imBloodSugarValue = obj.getString("value3");
			}
			
			if(StringUtils.isNotBlank(obj.getString("value5"))){
				followupProjectData = "{'BS_FPG':'"+obj.getString("value5")+"'}";
				imBloodSugarValue = obj.getString("value5");
			}
			//餐后
			if(StringUtils.isNotBlank(obj.getString("value2"))){
				followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value2")+"'}";
				imBloodSugarValue = obj.getString("value2");
			}
			
			
			if(StringUtils.isNotBlank(obj.getString("value4"))){
				followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value4")+"'}";
				imBloodSugarValue = obj.getString("value4");
			}
			
			if(StringUtils.isNotBlank(obj.getString("value6"))){
				followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value6")+"'}";
				imBloodSugarValue = obj.getString("value6");
			}
			
			//随机血糖
			if(StringUtils.isNotBlank(obj.getString("value7"))){
				followupProjectData = "{'RANDOM_BLOOD_SUGAR':'"+obj.getString("value7")+"'}";
				imBloodSugarValue = obj.getString("value7");
			}
			
			followUpService.esSaveFollowupProjectData(followup_id, "3", followupProjectData);
@ -416,7 +418,7 @@ public class PrescriptionFollowupContentService extends BaseService {
	 * @param followup_id
	 * @param sendIM 是否发送IM消息
	 */
	public void importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
	public void importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM,String healthindexid) throws Exception {
		
		Long followupId = Long.valueOf(followup_id);
		
@ -432,7 +434,41 @@ public class PrescriptionFollowupContentService extends BaseService {
		
		String stardate = DateUtil.getNextMonth(new Date(),-1)+" 00:00:00";
		String enddate = DateUtil.getStringDateShort()+" 23:59:59";
		org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
		org.json.JSONArray jsonArray = new org.json.JSONArray();
		
		if(StringUtils.isBlank(healthindexid)){
			
			jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
		}else{
			DevicePatientHealthIndex devicePatientHealthIndex = devicePatientHealthIndexDao.findOne(new Long(healthindexid));
			
			if(devicePatientHealthIndex != null){
				org.json.JSONObject json = new org.json.JSONObject();
				json.put("id", devicePatientHealthIndex.getId());
				json.put("patient",devicePatientHealthIndex.getUser());
				json.put("value1", devicePatientHealthIndex.getValue1());
				json.put("value2", devicePatientHealthIndex.getValue2());
				json.put("value3", devicePatientHealthIndex.getValue3());
				json.put("value4", devicePatientHealthIndex.getValue4());
				json.put("value5", devicePatientHealthIndex.getValue5());
				json.put("value6", devicePatientHealthIndex.getValue6());
				json.put("value7", devicePatientHealthIndex.getValue7());
				json.put("deviceSn",devicePatientHealthIndex.getDeviceSn());
				json.put("type", devicePatientHealthIndex.getType());
				
				Date date = devicePatientHealthIndex.getRecordDate();
				if (devicePatientHealthIndex.getType() == 2) {
					json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
				} else {
					json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
				}
				json.put("sortDate",devicePatientHealthIndex.getSortDate());
				json.put("czrq", devicePatientHealthIndex.getCzrq());
				
				jsonArray.put(json);
			}
		}
		
		String followupProjectData = "";
		

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -670,8 +670,8 @@ public class PrescriptionInfoService extends BaseService {
                //获取智业待结算接口,更新药品金额
                prescriptionService.getPerscriptionInfoCostFromPayInfo(p.getCode());
                //更新随访记录的状态为完成
                followUpDao.updateStatusByPrescriptionCode(p.getCode(),"1");
//                //更新随访记录的状态为完成
//                followUpDao.updateStatusByPrescriptionCode(p.getCode(),"1");
                //发送Im消息
                JSONObject content = new JSONObject();

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -4,6 +4,7 @@ import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.web.quota.vo.SaveModel;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.search.SearchResponse;
@ -52,7 +53,7 @@ public class ElasticsearchUtil {
    public List excute(String sql, Class clazz, String esType, String esIndex) {
        List saveModels = new ArrayList<>();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
        try {
            //解决 group by之后默认是200的问题
            if (sql.toLowerCase().contains("group by")) {
@ -108,7 +109,8 @@ public class ElasticsearchUtil {
                            if (heads.get(i).contains("date_histogram")) {
                                key = "setQuotaDate";
                            }
                            value = DateUtil.strToDate(String.valueOf(value).replace("T00:00:00+0800", " 00:00:00"), "yyyy-MM-dd HH:mm:ss");
                            value = dateFormat.parse(String.valueOf(value));
//                            value = DateUtil.strToDate(String.valueOf(value).replace("T00:00:00+0800", " 00:00:00"), "yyyy-MM-dd HH:mm:ss");
                        }
                        if (value instanceof String) {
@ -119,6 +121,8 @@ public class ElasticsearchUtil {
                            clazz.getMethod(key, Double.class).invoke(saveModel, value);
                        } else if (value instanceof java.util.Date) {
                            clazz.getMethod(key, java.util.Date.class).invoke(saveModel, value);
                        }else if (value instanceof java.util.List) {
                            clazz.getMethod(key, java.util.List.class).invoke(saveModel, value);
                        }
                    } catch (Exception e) {
                        logger.warn(e.getMessage());

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -18,6 +18,8 @@ import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -753,4 +755,5 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
        }
    }
}

+ 8 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/DoctorPrescriptionFollowupContentController.java

@ -101,9 +101,11 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
			@RequestParam(value = "followupid", required = true) String followupid,
			@ApiParam(name = "healthindexid", value = "体征ID", defaultValue = "")
			@RequestParam(value = "healthindexid", required = true) String healthindexid){
		try {
			prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptioncode,followupid,false);
			prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptioncode,followupid,false,healthindexid);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
@ -119,9 +121,11 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
			@RequestParam(value = "followupid", required = true) String followupid,
			@ApiParam(name = "healthindexid", value = "体征ID", defaultValue = "")
			@RequestParam(value = "healthindexid", required = true) String healthindexid){
		try {
			prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptioncode,followupid,false);
			prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptioncode,followupid,false,healthindexid);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息

+ 52 - 31
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java

@ -1,12 +1,11 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.es.entity.HealthEduArticlePatientESModel;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.gateway.service.GcEduArticleService;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
@ -16,9 +15,6 @@ import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -124,15 +120,7 @@ public class GcEduArticleController extends WeixinBaseController {
            @ApiParam(name = "labelType", value = "标签类型  1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = false) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId
    ) {
        try {
            String[] patients = receiveCodes.split(",");//接收人的code
@ -142,7 +130,7 @@ public class GcEduArticleController extends WeixinBaseController {
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            HealthEduArticlePatient healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
@ -157,54 +145,49 @@ public class GcEduArticleController extends WeixinBaseController {
    /**
     * 发送到redis
     *
     * @param healthEduArticlePatients
     */
    public void sender(List<HealthEduArticlePatient> healthEduArticlePatients) {
    public void sender(HealthEduArticlePatient healthEduArticlePatient) {
        //送到到队列
        healthEduArticlePatients.stream().forEach(one -> {
        List<Patient> patients = healthEduArticlePatient.getPatients();
        patients.stream().forEach(one -> {
            healthEduArticlePatient.setPatient(one.getCode());
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
                    textMessage.setText(net.sf.json.JSONObject.fromObject(healthEduArticlePatient).toString());
                    return textMessage;
                }
            });
        });
    }
    /************************************************************************集美健教卫计委相关接口***********************************************************************/
    @RequestMapping(value = "sendPatients", method = RequestMethod.POST)
    @ApiOperation("文章群推送")
    public BaseResultModel sendPatients(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "sendCode", value = "发送人code(医生发送时,必填医生code)", required = false) @RequestParam(value = "sendCode", required = false) String sendCode,
//            @ApiParam(name = "sendCode", value = "发送人code(医生发送时,必填医生code)", required = false) @RequestParam(value = "sendCode", required = false) String sendCode,
            @ApiParam(name = "sendName", value = "发送方名称(如:卫计委发送:集美区;医生发送:医生名称)", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取的url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId
    ){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
//            patientSet.add(patientService.findByCode("ac9e92622e0343c98861d41dfa5e4392"));
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, "", 0L, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            HealthEduArticlePatient healthEduArticlePatient = gcEduArticleService.getSaveArticle(patientSet, getUID(), sendName, sendType, "", 0L, articleId);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
                sender(healthEduArticlePatient);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
@ -212,4 +195,42 @@ public class GcEduArticleController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "pushArticleLogs", method = RequestMethod.GET)
    @ApiOperation("查询卫计委给患者推送记录 ")
    public ResultPageListModel<HealthEduArticlePatientModel> pushArticleLogs(
            @ApiParam(name = "page", value = "当前页 起始1", required = true) @RequestParam(value = "page", required = true) Integer page,
            @ApiParam(name = "pagesize", value = "每页显示条数", required = true) @RequestParam(value = "pagesize", required = true) Integer pagesize){
        try {
            if (pagesize > 1000) {
                pagesize = 1000;
            }
            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.pushArticleLogs(page,pagesize,"wjw00000001000e6badcfa163e424525");
            Long count = gcEduArticleService.pushArticleLogsCount("");
            return new ResultPageListModel(
                    page,
                    pagesize,
                    count.intValue()
                    , eduArticlePatients);
        }catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "pushArticleConfirm",method = RequestMethod.GET)
    public String pushArticleConfirm(@ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
                                   @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
                                   @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
                                   @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
                                   @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
                                   @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId){
        try {
            com.alibaba.fastjson.JSONObject response = gcEduArticleService.pushArticleConfirm(articleId, labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}

+ 2 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -124,11 +124,9 @@ public class GcLableController extends BaseController {
    }
    @RequestMapping(value = "/unitLabels", method = RequestMethod.GET)
    @ApiOperation("根据地区查找卫计委下属单位标签")
    public ResultListModel<List<PatientLabelModel>> unitLabels(
            @ApiParam(name = "areas", value = "地区code,多个地区用逗号分隔", required = true) @RequestParam(value = "areas", required = true) String areas
    ) {
    public ResultListModel<List<PatientLabelModel>> unitLabels() {
        try {
            List<DictModel> dictModels = labelService.getUnitLabels(areas);
            List<DictModel> dictModels = labelService.getUnitLabels();
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());

+ 304 - 76
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -1,14 +1,20 @@
package com.yihu.wlyy.web.third.gateway.service;
//import com.yihu.es.entity.ArticleTest;
import com.alibaba.fastjson.JSONObject;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.es.entity.HealthEduArticlePatientESModel;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import org.springframework.beans.BeanUtils;
@ -20,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -37,6 +44,12 @@ public class GcEduArticleService {
    private HealthEduArticlePatientDao healthEduArticlePatientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    @Autowired
    private PatientService patientService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
@ -65,14 +78,16 @@ public class GcEduArticleService {
        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
            switch (labelType) {
                case "1":{
                    sb.append(" select w.patient FROM wlyy_sign_family w  left join wlyy_sign_family_server s on w.code=s.sign_code " +
                    sb.append(" select w.code FROM wlyy_sign_family w  left join wlyy_sign_family_server s on w.code=s.sign_code " +
                            " left join wlyy_patient p on p.code=w.patient "+
                            "where w.`status` > 0 and s.server_type=? ");
                    params.add(labelCode);
                }
                case "2":
                case "3":
                case "4":{
                    sb.append(" SELECT w.patient FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
                    sb.append(" SELECT w.code FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
                            " left join wlyy_patient p on p.code=w.patient "+
                            "where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
                    params.add(labelType);
                    params.add(labelCode);
@ -88,7 +103,9 @@ public class GcEduArticleService {
        }
        if (patients != null && patients.length > 0) {
            List<String> arrPatient = java.util.Arrays.asList(patients);
            patientSet.addAll(arrPatient);
            for(String str:arrPatient){
                patientSet.add(str);
            }
        }
        if (unPatients != null && unPatients.length > 0) {
            for (String unPatient : unPatients) {
@ -99,6 +116,82 @@ public class GcEduArticleService {
        }
    }
//    /**
//     * 保存发送信息
//     *
//     * @param patientSet   患者set集和
//     * @param sendCode     发送人code、
//     * @param sendName     发送人名称
//     * @param sendMessage  发送人携带的信息
//     * @param teamId       发送人所属团队
//     * @param articleId    文章列表
//     * @param articlePic   文件封面
//     * @param articleTitle 文章主题
//     */
//    @Transactional
//    public List<com.yihu.es.entity.HealthEduArticlePatient> getSaveArticle(Set<String> patientSet,
//                                                                        String sendCode,
//                                                                        String sendName,
//                                                                        Integer sendType,
//                                                                        String sendMessage,
//                                                                        Long teamId,
//                                                                        String articleId,
//                                                                        String articlePic,
//                                                                        String articleTitle,
//                                                                        String articleContent,
//                                                                        String articleType,
//                                                                        String level1Type,
//                                                                        String level2Type,
//                                                                        String level,
//                                                                        String articleUrl) {
//        List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
//
//        Doctor doctor = doctorDao.findByCode(sendCode);
//        String batchNo = UUID.randomUUID().toString();
//        Date createTime = new Date();
//        for (String patient : patientSet) {
//            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
//            if (signFamily == null) {
//                continue;
//            }
//            com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient = new com.yihu.es.entity.HealthEduArticlePatient();
//            healthEduArticlePatient.setSendCode(sendCode);
//            healthEduArticlePatient.setSendName(sendName);
//            healthEduArticlePatient.setSendType(sendType);
////            healthEduArticlePatient.setPatient(patient);
////            healthEduArticlePatient.setPatientName(signFamily.getName());
//            healthEduArticlePatient.setAdminTeamCode(teamId);
//            if (doctor != null) {
//                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(createTime);
//
//            healthEduArticlePatient.setArticleId(articleId);
//            healthEduArticlePatient.setAttachedTitle(articleTitle);
//            healthEduArticlePatient.setAttachedPic(articlePic);
//            healthEduArticlePatient.setAttachedContent(articleContent);
//            healthEduArticlePatient.setAttachedMessage(sendMessage);
//            healthEduArticlePatient.setArticleType(articleType);
//            healthEduArticlePatient.setLevel(level);
//            healthEduArticlePatient.setLevel1Type(level1Type);
//            healthEduArticlePatient.setLevel2Type(level2Type);
//            healthEduArticlePatient.setType("1");//文章
//            healthEduArticlePatient.setArticleUrl(articleUrl);
//            healthEduArticlePatients.add(healthEduArticlePatient);
//
//        }
//        //保存到ES中
//        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
//        return healthEduArticlePatients;
//    }
    /**
     * 保存发送信息
     *
@ -108,78 +201,78 @@ public class GcEduArticleService {
     * @param sendMessage  发送人携带的信息
     * @param teamId       发送人所属团队
     * @param articleId    文章列表
     * @param articlePic   文件封面
     * @param articleTitle 文章主题
     */
    @Transactional
    public List<com.yihu.es.entity.HealthEduArticlePatient> getSaveArticle(Set<String> patientSet,
                                                                        String sendCode,
                                                                        String sendName,
                                                                        Integer sendType,
                                                                        String sendMessage,
                                                                        Long teamId,
                                                                        String articleId,
                                                                        String articlePic,
                                                                        String articleTitle,
                                                                        String articleContent,
                                                                        String articleType,
                                                                        String level1Type,
                                                                        String level2Type,
                                                                        String level,
                                                                        String articleUrl) {
        List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
        Doctor doctor = doctorDao.findByCode(sendCode);
    public HealthEduArticlePatient getSaveArticle(Set<String> patientSet,
                                                        String sendCode,
                                                        String sendName,
                                                        Integer sendType,
                                                        String sendMessage,
                                                        Long teamId,
                                                        String articleId) throws Exception{
        String batchNo = UUID.randomUUID().toString();
        Date createTime = new Date();
        List<Patient> patientList = new ArrayList<>();
        for (String patient : patientSet) {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
            if (signFamily == null) {
                continue;
            }
            com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient = new com.yihu.es.entity.HealthEduArticlePatient();
            patientList.add(new Patient(patient));
        }
        HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient();
        //1、医生,2、卫计委
        //如果是卫计委得区别角色
        Doctor doctor = null;
        if(sendType==2){
            String sql = "select r.code as roleCode from wlyy_user_role u " +
                    "left join wlyy_role r on r.`code`=u.role where u.user='"+sendCode+"'";
            Map<String,Object> result = jdbcTemplate.queryForMap(sql);
            //角色的code值
            healthEduArticlePatient.setSendCode(result.get("roleCode")+"");
        }else{
            doctor = doctorDao.findByCode(sendCode);
            healthEduArticlePatient.setSendCode(sendCode);
            healthEduArticlePatient.setSendName(sendName);
            healthEduArticlePatient.setSendType(sendType);
            healthEduArticlePatient.setPatient(patient);
            healthEduArticlePatient.setPatientName(signFamily.getName());
            healthEduArticlePatient.setAdminTeamCode(teamId);
            if (doctor != null) {
                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(createTime);
            healthEduArticlePatient.setArticleId(articleId);
            healthEduArticlePatient.setAttachedTitle(articleTitle);
            healthEduArticlePatient.setAttachedPic(articlePic);
            healthEduArticlePatient.setAttachedContent(articleContent);
            healthEduArticlePatient.setAttachedMessage(sendMessage);
            healthEduArticlePatient.setArticleType(articleType);
            healthEduArticlePatient.setLevel(level);
            healthEduArticlePatient.setLevel1Type(level1Type);
            healthEduArticlePatient.setLevel2Type(level2Type);
            healthEduArticlePatient.setType("1");//文章
            healthEduArticlePatient.setArticleUrl(articleUrl);
            healthEduArticlePatients.add(healthEduArticlePatient);
        }
        healthEduArticlePatient.setSendName(sendName);
        healthEduArticlePatient.setSendType(sendType);
        healthEduArticlePatient.setAdminTeamCode(teamId);
        if (doctor != null) {
            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 = healthEducationArticleService.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("");
        healthEduArticlePatient.setPatients(patientList);
        //保存到ES中
        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        return healthEduArticlePatients;
        elastricSearchSave.save(healthEduArticlePatient, esIndex, esType);
        return healthEduArticlePatient;
    }
    public List<HealthEduArticlePatientModel> getPatientHealthLogs(String sendCode, String articleType, String level1Type, String level2Type, String level, String attachedTitle, String startTime, String endTime, int page, int pagesize) {
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
        StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from health_edu_article_patient_test  " +
        StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from   " +esType+
                " where  sendCode='" + sendCode + "' ");
        if (!StringUtils.isEmpty(articleType)) {
            sql.append(" and  articleType='" + articleType + "'  ");
@ -219,7 +312,7 @@ public class GcEduArticleService {
    }
    private com.yihu.es.entity.HealthEduArticlePatient findOne(String articleId) {
        String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from health_edu_article_patient_test where articleId='" + articleId + "' order by createTime desc limit 0,1";
        String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from "+esType+" where articleId='" + articleId + "' order by createTime desc limit 0,1";
        com.yihu.es.entity.HealthEduArticlePatient esList = (com.yihu.es.entity.HealthEduArticlePatient) elasticsearchUtil.excuteOneObject(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        return esList;
    }
@ -257,10 +350,45 @@ public class GcEduArticleService {
        return quotaDate + "T00:00:00+0800";
    }
//    public void initPatient(Set<String> patientSet,String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth){
//
//        String tableSql = " select w.patient from wlyy_sign_family w ";
//        String whereSql = " where w.status>0  ";
//
//        if(!StringUtils.isEmpty(labelServe)){
//            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
//            whereSql += " and s.server_type in ("+labelServe+" ) ";
//        }
//        if(!StringUtils.isEmpty(labelHealth)||!StringUtils.isEmpty(labelDisease)){
//            tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
//            whereSql += " and l.status=1 ";
//            whereSql += " and ( ";
//        }
//        if(!StringUtils.isEmpty(labelHealth)){
//            whereSql += " (l.label_type = 2 AND l.label in ("+labelHealth+")) ";
//        }
//        if(!StringUtils.isEmpty(labelDisease)){
//            if(!whereSql.endsWith(" and ( ")) {
//                whereSql += " or (l.label_type = 3 AND l.label in ("+labelDisease+"))) ";
//            }else{
//                whereSql += " (l.label_type = 1 AND l.label in ("+labelDisease+"))) ";
//            }
//        }
//        if(!StringUtils.isEmpty(labelSex)){
//            tableSql += " left join wlyy_patient p on p.code=w.patient ";
//            whereSql += " and p.sex in ("+labelSex+") ";
//        }
//        if(!StringUtils.isEmpty(labelUnit)){
//            whereSql += " and w.hospital in ("+labelUnit+") ";
//        }
//        List<String> groupPatient = jdbcTemplate.queryForList(tableSql+whereSql, String.class);
//        patientSet.addAll(groupPatient);
//    }
    public void initPatient(Set<String> patientSet,String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth){
        String tableSql = " select w.patient from wlyy_sign_family w ";
        String whereSql = " where w.status>0  ";
        String tableSql = " select p.code from wlyy_sign_family w ";
        String whereSql = " where w.status>0 and p.town='350211' ";
        if(!StringUtils.isEmpty(labelServe)){
            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
@ -281,8 +409,8 @@ public class GcEduArticleService {
                whereSql += " (l.label_type = 1 AND l.label in ("+labelDisease+"))) ";
            }
        }
        tableSql += " left join wlyy_patient p on p.code=w.patient ";
        if(!StringUtils.isEmpty(labelSex)){
            tableSql += " left join wlyy_patient p on p.code=w.patient ";
            whereSql += " and p.sex in ("+labelSex+") ";
        }
        if(!StringUtils.isEmpty(labelUnit)){
@ -292,17 +420,117 @@ public class GcEduArticleService {
        patientSet.addAll(groupPatient);
    }
    @Transactional
    public void getSaveArticle(){
//        ArticleTest aa = new ArticleTest();
//        Patient pa = new Patient();
//    /**
//     * 保存发送信息
//     *
//     */
//    @Transactional
//    public List<com.yihu.es.entity.ArticleTest> getSaveArticle2() {
//        List<com.yihu.es.entity.ArticleTest> healthEduArticlePatients = new ArrayList<>();
//
//        String batchNo = UUID.randomUUID().toString();
//        pa.setCode(batchNo);
//        pa.setCity("1212");
//        pa.setName("hukun");
//        batchNo = UUID.randomUUID().toString();
//        aa.setBatchNo(batchNo);
//        aa.setPatients(pa);
//        Date createTime = new Date();
////            com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient = new com.yihu.es.entity.HealthEduArticlePatient();
//            com.yihu.es.entity.ArticleTest healthEduArticlePatient = new ArticleTest();
//            healthEduArticlePatient.setSendCode("123");
//            healthEduArticlePatient.setSendName("123");
//            healthEduArticlePatient.setBatchNo(batchNo);
//            healthEduArticlePatient.setCreateTime(createTime);
//
//            healthEduArticlePatient.setAttachedMessage("5656");
//            healthEduArticlePatient.setType("1");//文章
//
////            People patient1 = new People();
////            patient1.setName("胡坤3");
////            People patient2 = new People();
////            patient2.setName("胡坤4");
////            List<People> a = new ArrayList<>();
////            a.add(patient1);
////            a.add(patient2);
//            List<String> a = new ArrayList<>();
//            a.add("胡坤3");
//        a.add("胡坤4");
////            healthEduArticlePatient.setP
//            healthEduArticlePatients.add(healthEduArticlePatient);
//
//        //保存到ES中
//        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
//        return healthEduArticlePatients;
//    }
    public List<HealthEduArticlePatientModel> pushArticleLogs(int page, int pagesize,String sendCode) throws Exception{
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
        String sql = "select r.code as roleCode from wlyy_user_role u " +
                "left join wlyy_role r on r.`code`=u.role where u.user='"+sendCode+"'";
        Map<String,Object> resultMap = jdbcTemplate.queryForMap(sql);
        sendCode = resultMap.get("roleCode").toString();
        StringBuffer sql2 = new StringBuffer("select *  from   " +esType+
                " where  sendCode='" + sendCode + "' ");
        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);
        List<HealthEduArticlePatientModel> returnList = new ArrayList<>();
        Map<String,HealthEduArticlePatientModel> result = new HashMap<>();
        HealthEduArticlePatientModel heapm = null;
        com.alibaba.fastjson.JSONObject article = null;
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
        for(HealthEduArticlePatient one :esList){
            article = healthEducationArticleService.getArticalById(one.getArticleId());
//            com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
//            if (p != null) {
//                p.setAllCount(one.getAllCount());
//                HealthEduArticlePatientModel heapm = new HealthEduArticlePatientModel();
//                BeanUtils.copyProperties(p, heapm);
//                returnList.add(heapm);
//            }
            if(result.get(one.getArticleId())!=null){
                heapm = result.get(one.getArticleId());
            }else{
                heapm = new HealthEduArticlePatientModel();
            }
            heapm.setSendName(one.getSendName());
            heapm.setSendCode(one.getSendCode());
            heapm.setCreateTime(one.getCreateTime());
            heapm.setArticleId(article.getString("articleId"));
            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.setLevel(article.getString("articlelevel"));
            heapm.setAllCount(heapm.getAllCount()+one.getPatients().size());
            heapm.setBrowseNumbere(article.getInteger("browseNumber"));
            heapm.setCommentNumber(article.getInteger("commentNumber"));
            result.put(one.getArticleId(),heapm);
        };
        List< HealthEduArticlePatientModel > resultList = new ArrayList<>();
        for (Map.Entry< String, HealthEduArticlePatientModel > entry : result.entrySet()) {
            resultList.add(entry.getValue());
        }
        return resultList;
    }
    public Long pushArticleLogsCount(String sendCode) {
        StringBuffer sql = new StringBuffer("select count(distinct articleId) count  from   " +esType+
                " where  sendCode='" + sendCode + "' ");
        return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth) throws Exception{
        JSONObject article = healthEducationArticleService.getArticalById(articleId);
        Set<String> patientSet = new HashSet<>();
        initPatient(patientSet,labelUnit,labelSex,labelServe,labelDisease,labelHealth);
        long num = patientSet.size();
        JSONObject result = new JSONObject();
        result.put("num",num);
        result.put("articleTitle",article.getString("articleTitle"));
        return result;
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcLabelService.java

@ -242,8 +242,8 @@ public class GcLabelService {
        return result;
    }
    public List<DictModel> getUnitLabels(String areas) {
        String sql = "select code, name  from dm_hospital  where level=2 and town in ("+areas+" ) " ;
    public List<DictModel> getUnitLabels() {
        String sql = "select code, name  from dm_hospital  where level=2 and town = '350211'" ;
        List<DictModel> returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
        return returnList;
    }

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

@ -36,7 +36,11 @@ public class HealthEduArticlePatientModel {
    @ApiModelProperty(value = "等级", required = false, access = "response")
    private String level;//等级
    @ApiModelProperty(value = "所有的推送数目", required = false, access = "response")
    private Integer allCount;//所有的推送数目
    private Integer allCount=0;//所有的推送数目
    @ApiModelProperty(value = "文章浏览数", required = false, access = "response")
    private Integer browseNumbere=0;//文章浏览数
    @ApiModelProperty(value = "文章评论数", required = false, access = "response")
    private Integer commentNumber=0;//文章评论数
    public String getSendCode() {
        return sendCode;
@ -125,4 +129,20 @@ public class HealthEduArticlePatientModel {
    public void setAllCount(Integer allCount) {
        this.allCount = allCount;
    }
    public Integer getBrowseNumbere() {
        return browseNumbere;
    }
    public void setBrowseNumbere(Integer browseNumbere) {
        this.browseNumbere = browseNumbere;
    }
    public Integer getCommentNumber() {
        return commentNumber;
    }
    public void setCommentNumber(Integer commentNumber) {
        this.commentNumber = commentNumber;
    }
}

+ 101 - 107
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduDoctorArticleController.java

@ -357,116 +357,109 @@ public class EduDoctorArticleController extends BaseController{
        }
    }
    @RequestMapping(value = "/send", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("文章推送")
    public BaseResultModel send(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "sendCode", value = "发送人code", required = true) @RequestParam(value = "sendCode", required = true) String sendCode,
            @ApiParam(name = "sendName", value = "发送人名", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "sendMessage", value = "发送人信息", required = false) @RequestParam(value = "sendMessage", required = false) String sendMessage,
            @ApiParam(name = "teamId", value = "发送人是医生的时候,医生所属的团队", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
            @ApiParam(name = "labelCode", value = "所选群组,多个用逗号分隔", required = true) @RequestParam(value = "labelCode", required = false, defaultValue = "") String labelCode,
            @ApiParam(name = "labelType", value = "标签类型  1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = false) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ) {
        try {
            String[] patients = receiveCodes.split(",");//接收人的code
            String[] unPatients = unReceiveCodes.split(",");//接收人的code
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
            }).start();
            return new BaseResultModel();
        } catch (Exception e) {
            return new BaseResultModel(-10000, ErrorStateMessage.fail + ":" + e.getMessage());
        }
    }
    /**
     * 发送到redis
     *
     * @param healthEduArticlePatients
     */
    public void sender(List<HealthEduArticlePatient> healthEduArticlePatients) {
        //送到到队列
        healthEduArticlePatients.stream().forEach(one -> {
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
                    return textMessage;
                }
            });
        });
    }
//    @RequestMapping(value = "/send", method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation("文章推送")
//    public BaseResultModel send(
//            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
//            @ApiParam(name = "sendCode", value = "发送人code", required = true) @RequestParam(value = "sendCode", required = true) String sendCode,
//            @ApiParam(name = "sendName", value = "发送人名", required = true) @RequestParam(value = "sendName", required = true) String sendName,
//            @ApiParam(name = "sendMessage", value = "发送人信息", required = false) @RequestParam(value = "sendMessage", required = false) String sendMessage,
//            @ApiParam(name = "teamId", value = "发送人是医生的时候,医生所属的团队", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
//            @ApiParam(name = "labelCode", value = "所选群组,多个用逗号分隔", required = true) @RequestParam(value = "labelCode", required = false, defaultValue = "") String labelCode,
//            @ApiParam(name = "labelType", value = "标签类型  1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = false) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
//            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
//            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
//            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
//            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
//            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
//            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
//            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
//            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
//            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
//            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
//            @ApiParam(name = "articleUrl", value = "宣教文章获取url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
//    ) {
//        try {
//            String[] patients = receiveCodes.split(",");//接收人的code
//            String[] unPatients = unReceiveCodes.split(",");//接收人的code
//            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
//
//            //得到需要发送的患者
//            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
//            //获取保存发送记录
//            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
//            //推送微信模板消息和发送im消息
//            new Thread(() -> {
//                //发送任务到redis
//                sender(healthEduArticlePatients);
//            }).start();
//            return new BaseResultModel();
//        } catch (Exception e) {
//            return new BaseResultModel(-10000, ErrorStateMessage.fail + ":" + e.getMessage());
//        }
//    }
    @RequestMapping(value = "/sendPatients", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("文章群推送")
    public BaseResultModel sendPatients(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "sendCode", value = "发送人code(医生发送时,必填医生code)", required = false) @RequestParam(value = "sendCode", required = false) String sendCode,
            @ApiParam(name = "sendName", value = "发送方名称(如:卫计委发送:集美区;医生发送:医生名称)", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取的url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ){
        try {
//    /**
//     * 发送到redis
//     *
//     * @param healthEduArticlePatients
//     */
//    public void sender(List<HealthEduArticlePatient> healthEduArticlePatients) {
//        //送到到队列
//        healthEduArticlePatients.stream().forEach(one -> {
//            jmsTemplate.send(channelName, new MessageCreator() {
//                @Override
//                public Message createMessage(Session session) throws JMSException {
//                    TextMessage textMessage = session.createTextMessage();
//                    textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
//                    return textMessage;
//                }
//            });
//        });
//    }
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, "", 0L, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息.
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(-10000, ErrorStateMessage.fail + ":" + e.getMessage());
        }
//    @RequestMapping(value = "/sendPatients", method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation("文章群推送")
//    public BaseResultModel sendPatients(
//            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
//            @ApiParam(name = "sendCode", value = "发送人code(医生发送时,必填医生code)", required = false) @RequestParam(value = "sendCode", required = false) String sendCode,
//            @ApiParam(name = "sendName", value = "发送方名称(如:卫计委发送:集美区;医生发送:医生名称)", required = true) @RequestParam(value = "sendName", required = true) String sendName,
//            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
//            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
//            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
//            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
//            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
//            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
//            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
//            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
//            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
//            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
//            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
//            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
//            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
//            @ApiParam(name = "articleUrl", value = "宣教文章获取的url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
//    ){
//        try {
//
//            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
//            //得到需要发送的患者
//            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
//            //获取保存发送记录
//            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, "", 0L, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
//            //推送微信模板消息和发送im消息.
//            new Thread(() -> {
//                //发送任务到redis
//                sender(healthEduArticlePatients);
//            }).start();
//            return new BaseResultModel();
//        }catch (Exception e) {
//            return new BaseResultModel(-10000, ErrorStateMessage.fail + ":" + e.getMessage());
//        }
//
//    }
    }
    @RequestMapping(value = "/saveArticle", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("测试生成数据")
    public void saveArticle(){
    }
    /**
     * 获取要推送的患者
@ -491,4 +484,5 @@ public class EduDoctorArticleController extends BaseController{
        return map;
    }*/
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduLableController.java

@ -128,7 +128,7 @@ public class EduLableController extends BaseController {
            @ApiParam(name = "areas", value = "地区code,多个地区用逗号分隔", required = true) @RequestParam(value = "areas", required = true) String areas
    ) {
        try {
            List<DictModel> dictModels = labelService.getUnitLabels(areas);
            List<DictModel> dictModels = labelService.getUnitLabels();
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());

+ 32 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/template/ThirdTemplateController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.third.template;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import io.swagger.annotations.Api;
@ -24,6 +25,8 @@ public class ThirdTemplateController extends BaseController {
    @Autowired
    private WeiXinTempMsgSendUtils tempMsgSendUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Value("${wechat.message.template_doctor_survey}")
    private String template_doctor_survey;
@ -60,10 +63,35 @@ public class ThirdTemplateController extends BaseController {
        }
    }
    /**
     * 医生端发送系统消息
     * @param receiver 接受者
     * @param title 标题
     * @param content 内容
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ApiOperation(value = "医生端发送系统消息")
    @ResponseBody
    @ObserverRequired
    public String saveFeedback(
            @RequestParam String receiver,
            @RequestParam String title,
            @RequestParam String type,
            @RequestParam String content) {
        try {
            pushMsgTask.put(receiver, type, title, content, "");
            return write(200, "发送成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "发送失败!");
        }
    }
    /**
     * 根据第三方type 匹配对应模板ID
     *
     * @param type 1.代办事项
     * @param type 1.代办事项 2.处理结果通知(模板未定)
     * @return
     */
    private String getTemplateId(String type) throws Exception {
@ -72,6 +100,9 @@ public class ThirdTemplateController extends BaseController {
            case "1":
                templateId = template_doctor_survey;
                break;
            case "2":
                templateId = "";
                break;
            default:
                templateId = template_doctor_survey;
                break;

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

@ -97,11 +97,11 @@ pushMes:
  redis_prescription_title: redisPrescription
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test
    HealthEduArticlePatient: health_edu_article_patient_test2
    FollowUp: wlyy_followup
    Statistics: wlyy_quota_test
  type:
    HealthEduArticlePatient: health_edu_article_patient_test
    HealthEduArticlePatient: health_edu_article_patient_test2
    FollowUpContent: wlyy_followup_content
    Statistics: wlyy_quota_test
  host:  http://172.19.103.68:9200