Pārlūkot izejas kodu

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

wujunjie 7 gadi atpakaļ
vecāks
revīzija
1fd6cada56
20 mainītis faili ar 233 papildinājumiem un 138 dzēšanām
  1. 10 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientVO.java
  2. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java
  3. 2 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/UserDao.java
  4. 11 4
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java
  5. 3 3
      patient-co/patient-co-statistics-es/doc/sql/统计相关表数据备份20171121.txt
  6. 2 2
      patient-co/patient-co-statistics-es/src/main/resources/application.yml
  7. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/FinishConsultJob.java
  8. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  9. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  10. 98 68
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  11. 6 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java
  12. 5 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java
  13. 4 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  14. 10 24
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  15. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/call/CustomerService.java
  16. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  17. 50 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  18. 5 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  19. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  20. 4 4
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml

+ 10 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/vo/PatientVO.java

@ -52,8 +52,9 @@ public class PatientVO {
	private String streetName;
	// 地址
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	// 疾病类型,0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
	private String disease;
	private Integer diseasesum;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
@ -392,4 +393,12 @@ public class PatientVO {
	public void setDisease(String disease) {
		this.disease = disease;
	}
	
	public Integer getDiseasesum() {
		return diseasesum;
	}
	
	public void setDiseasesum(Integer diseasesum) {
		this.diseasesum = diseasesum;
	}
}

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

@ -266,7 +266,7 @@ public class CustomerController extends BaseController {
                                 @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,recipientNumber,answerStatus,serviceType,userName,jobNo,startDate,endDate,page,size));
            return write(200,"查询成功","data",customerService.getCallRecords(callerNumber,recipientNumber,seat,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,6 +34,8 @@ 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);
	List<User> findBySeat(String seat);
	User findByJobNo(String jobNo);
}

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

@ -274,7 +274,7 @@ public class CustomerService extends BaseService{
		return "1";
	}
	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){
	public Map<String,Object> getCallRecords(String callerNumber,String recipientNumber,String seat, Integer answerStatus,Integer serviceType ,String userName,String jobNo,String startDate,String endDate,Integer page,Integer size){
		Map<String,Object> map = new HashedMap();
@ -283,7 +283,7 @@ public class CustomerService extends BaseService{
				" manage_call_record r " +
				" WHERE " +
				" 1 = 1 ";
		sqltotal = setCallRecordSql( sqltotal, callerNumber,recipientNumber, answerStatus, serviceType ,userName,jobNo, startDate, endDate);
		sqltotal = setCallRecordSql( sqltotal, callerNumber,seat,recipientNumber, answerStatus, serviceType ,userName,jobNo, startDate, endDate);
		List<Map<String,Object>> rsTotal = jdbcTemplate.queryForList(sqltotal);
		Long total = (Long)rsTotal.get(0).get("total");
@ -311,7 +311,7 @@ public class CustomerService extends BaseService{
				" manage_call_record r " +
				" WHERE " +
				" 1 = 1 ";
		sql = setCallRecordSql( sql, callerNumber,recipientNumber, answerStatus, serviceType ,userName,jobNo, startDate, endDate);
		sql = setCallRecordSql( sql, callerNumber,seat,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);
@ -324,13 +324,20 @@ public class CustomerService extends BaseService{
		return map;
	}
	public String setCallRecordSql(String sql,String callerNumber,String recipientNumber,Integer answerStatus,Integer serviceType ,String userName,String jobNo,String startDate,String endDate){
	public String setCallRecordSql(String sql,String callerNumber,String seat,String recipientNumber,Integer answerStatus,Integer serviceType ,String userName,String jobNo,String startDate,String endDate){
		if(StringUtils.isNotBlank(callerNumber)){
			sql +=" AND r.caller_number = '"+callerNumber+"'";
		}
		if(answerStatus!=null){
			sql += " AND r.answer_status = "+answerStatus ;
		}
		if(StringUtils.isNotBlank(seat)){
			List<User> us = userDao.findBySeat(seat);
			if(us!=null&&us.size()>0){
				User u = us.get(0);
				sql += " AND r.user_code = '"+u.getCode()+"'";
			}
		}
		if(serviceType!=null){
			sql += " AND r.service_type = " +serviceType;
		}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 3 - 3
patient-co/patient-co-statistics-es/doc/sql/统计相关表数据备份20171121.txt


+ 2 - 2
patient-co/patient-co-statistics-es/src/main/resources/application.yml

@ -24,9 +24,9 @@ spring:
    testWhileIdle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    minEvictableIdleTimeMillis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    timeBetweenEvictionRunsMillis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
    poolPreparedStatements: true # 打开PSCache,并且指定每个连接上PSCache的大小
    poolPreparedStatements: false # 打开PSCache,并且指定每个连接上PSCache的大小
    maxPoolPreparedStatementPerConnectionSize: 50
    removeAbandoned: true #超过时间限制是否回收
    removeAbandoned: false #超过时间限制是否回收
    removeAbandonedTimeout: 7200 #超时时间;单位为秒。180秒=3分钟
    logAbandoned: false #关闭abanded连接时输出错误日志
    # REDIS

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/FinishConsultJob.java

@ -40,7 +40,7 @@ public class FinishConsultJob implements Job {
            sql.append("SELECT s.id session_id, s.name session_name, s.create_date session_create_time, s.last_message_time, ")
            .append("t.id topic_id, t.name topic_name, t.create_time topic_create_time, t.start_message_id ")
            .append("FROM ").append(imDb).append(".sessions s,").append(imDb).append(".wlyy_consults t ")
            .append("WHERE s.id = t.session_id  AND t.end_message_id IS NULL AND s.last_content_type in(1,2,3,4,15) and s.last_sender_id IN ( ")
            .append("WHERE s.id = t.session_id  AND t.end_message_id IS NULL AND s.last_content_type in(1,2,3,4,15,16,17) and s.last_sender_id IN ( ")
            .append("SELECT id FROM ").append(imDb).append(".doctors d where d.id<>t.patient) ")
            .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600 ")
            .append("ORDER BY t.create_time");

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -101,7 +101,7 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("from Message a where a.type = 12 and a.del='1' and a.over='1' and receiver = ?1  order by a.createTime desc")
    List<Message> findByReceiverCallService(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 ")
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.over='1' and a.read=1 order by a.createTime desc")
    List<Message> getMessageByType(String doctor, Integer type, Pageable pageRequest);
    @Query("from Message a where a.type = 12 and a.del='1' and a.over='1' and relationCode = ?1  ")

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -66,7 +66,7 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    @Query("select distinct p.openid from Patient p where p.openid is not null and p.openid <> '' ")
    List<String> findOpenids();
    @Query(value=" select p.* from wlyy_patient p  LEFT JOIN wlyy_sign_family s on s.patient = p.code  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code WHERE s.status > 0 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2)  and s.admin_team_code = ?1 and (s.doctor = ?2 or s.doctor_health =?2))",nativeQuery = true)
    @Query(value=" select p.* from wlyy_patient p  LEFT JOIN wlyy_sign_family s on s.patient = p.code  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code WHERE sp.status = 1 and s.status > 0 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2)  and s.admin_team_code = ?1 and (s.doctor = ?2 or s.doctor_health =?2))",nativeQuery = true)
    List<Patient> findAllSignPatientTeamcode(String teamcode, String  doctorcode);
    @Query(value="SELECT DISTINCT t.* FROM wlyy_sign_family t1,wlyy_patient t WHERE t.`code`=t1.patient AND t1.STATUS>0 AND " +

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

@ -326,11 +326,10 @@ public class SignPatientLabelInfoService extends BaseService {
            //慢病管理
            sql = "SELECT " +
                    "    DISTINCT t1.* " +
                    " FROM " +
                    "    wlyy_sign_family t1, " +
                    "    wlyy_sign_patient_label_info t2 ";
                    " FROM  wlyy_sign_family t1 " +
                    "  RIGHT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient ";
            if(StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + ", wlyy_patient p ";
                sql = sql + " LEFT JOIN wlyy_patient p on p.code = t1.patient  ";
            }
            sql = sql + " WHERE t2.label = ?";
    
@ -387,17 +386,6 @@ public class SignPatientLabelInfoService extends BaseService {
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<Map<String,Object>> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                patientDeviceTypeMap.put(user,sum);
            }
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
@ -411,7 +399,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
@ -525,11 +513,7 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                json.put("deviceType",p.getDeviceType());
                boolean epTime = false;
                try {
@ -565,8 +549,24 @@ public class SignPatientLabelInfoService extends BaseService {
                    int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                    //疾病种类
                    int disease1 = o1.has("disease")?o1.getInt("disease"):0;
                    int disease2 = o2.has("disease")?o2.getInt("disease"):0;
                    int disease1 = 0;
                    if(o1.has("disease")){
                        String diseasestr = o1.getString("disease");
                        if(diseasestr.contains(",")){
                            disease1 = 3;
                        }else{
                            disease1 = o1.getInt("disease");
                        }
                    }
                    int disease2 = 0;
                    if(o2.has("disease")){
                        String diseasestr = o2.getString("disease");
                        if(diseasestr.contains(",")){
                            disease2 = 3;
                        }else{
                            disease2 = o2.getInt("disease");
                        }
                    }
                    //颜色标签
                    int diseaseCondition1 = o1.has("diseaseCondition")?o1.getInt("diseaseCondition"):0;
@ -1095,27 +1095,34 @@ public class SignPatientLabelInfoService extends BaseService {
                        args = new Object[]{doctor, doctor};
                    }
                }else if(labelType.equals("3") && isSlowDisease) {
                    sql = " SELECT " +
                            "     count(DISTINCT t1.patient) count" +
                            " FROM" +
                            "     wlyy_sign_family t1, " +
                            "     wlyy_sign_patient_label_info t2, " +
                            "     wlyy_patient t3 " +
                            " WHERE" +
                            "     t1.patient = t2.patient " +
                            "     AND t1.patient = t3.code "+
                            "     AND t2.label = ? " +
                            "     AND t2.label_type = ? " +
                            "     AND t2.status = 1 " +
                            "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                            "     AND t1.status > 0 " +
                            (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                    
                    if("1".equals(label.getLabelCode()) ||  "2".equals(label.getLabelCode())){
                        sql = " SELECT " +
                                "     count(DISTINCT t1.patient) count" +
                                " FROM" +
                                "     wlyy_sign_family t1, " +
                                "     wlyy_sign_patient_label_info t2, " +
                                "     wlyy_patient t3 " +
                                " WHERE" +
                                "     t1.patient = t2.patient " +
                                "     AND t1.patient = t3.code "+
                                "     AND t2.label = ? " +
                                "     AND t2.label_type = ? " +
                                "     AND t2.status = 1 " +
                                "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "")+
                                "     AND t3.disease_condition = ? ";
    
                    if (teamCode > 0) {
                        args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode};
                    } else {
                        args = new Object[]{label.getLabelCode(), labelType, doctor, doctor};
                        if (teamCode > 0) {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode,diseaseCondition};
                        } else {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor,diseaseCondition};
                        }
                    }else{
                        continue;
                    }
                } else {
                    if (label.getLabelCode().equals("0")) {
                        sql = " SELECT " +
@ -1172,7 +1179,12 @@ public class SignPatientLabelInfoService extends BaseService {
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 ";
                if(isSlowDisease){
                    sql += " AND t3.standard_status = 1 ";
                }else{
                    sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 ";
                }
                
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
@ -3815,7 +3827,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 AND status =1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
    
@ -3970,10 +3982,26 @@ public class SignPatientLabelInfoService extends BaseService {
                    //患者預警狀態
                    int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                    int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
    
                    //疾病种类
                    int disease1 = o1.has("disease")?o1.getInt("disease"):0;
                    int disease2 = o2.has("disease")?o2.getInt("disease"):0;
                    int disease1 = 0;
                    if(o1.has("disease")){
                        String diseasestr = o1.getString("disease");
                        if(diseasestr.contains(",")){
                            disease1 = 3;
                        }else{
                            disease1 = o1.getInt("disease");
                        }
                    }
                    int disease2 = 0;
                    if(o2.has("disease")){
                        String diseasestr = o2.getString("disease");
                        if(diseasestr.contains(",")){
                            disease2 = 3;
                        }else{
                            disease2 = o2.getInt("disease");
                        }
                    }
                    //颜色标签
                    int diseaseCondition1 = o1.has("diseaseCondition")?o1.getInt("diseaseCondition"):0;
@ -4192,36 +4220,38 @@ public class SignPatientLabelInfoService extends BaseService {
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_sign_patient_label_info t2 ON t1.patient = t2.patient " +
                " JOIN wlyy_sign_patient_label_info t2 ON t1.patient = t2.patient and t2.status=1 " +
                " JOIN wlyy_patient t3 ON t1.patient = t3.code " +
                (teamCode > 0 ? " join (select * from wlyy_sign_patient_label where label_type != '4' or team_code = " + teamCode + " or (label_type = '4' and (label_code in (1,2)))) lb on t2.label = lb.label_code and t2.label_type = lb.label_type " : "") +
                " WHERE " +
                "    (t1.doctor = ? or t1.doctor_health = ?) " +
                "    AND t1.status > 0 " +
                "    AND t2.status = 1 " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
//                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
//                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "");
        sql = sql + " AND t3.status > 0 and t2.label_type = '3' and ( t2.label =1 or t2.lable = 2) ";
        sql = sql + " AND t3.status > 0 and t2.label_type = '3' and ( t2.label =1 or t2.label = 2) ";
        if (matcher.find()) {
            sql = sql + "  AND (t1.idcard like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%"};
            }
//            if (StringUtils.isNotEmpty(labelCode)) {
//                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
//            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
//                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%"};
//            } else {
//                args = new Object[]{doctor, doctor, "%" + filter + "%"};
//            }
            args = new Object[]{doctor, doctor, "%" + filter + "%"};
        } else {
            sql = sql + "  AND (t1.name like ? or t2.label_name like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
            }
//            if (StringUtils.isNotEmpty(labelCode)) {
//                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
//            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
//                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
//            } else {
//                args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
//            }
            args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
        }
@ -4235,7 +4265,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
@ -4420,7 +4450,7 @@ public class SignPatientLabelInfoService extends BaseService {
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_patiend t2 ON t1.patient = t2.code " +
                " JOIN wlyy_sign_patient_label_info t3 on t1.patient = t3.patient " +
                " RIGHT JOIN wlyy_sign_patient_label_info t3 on t1.patient = t3.patient AND t3.status = 1" +
                " WHERE " +
                (isIdcard ? " t1.patient = t2.code  and " : "") +
                "    t1.status > 0 " +
@ -4439,7 +4469,7 @@ public class SignPatientLabelInfoService extends BaseService {
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        

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

@ -321,33 +321,33 @@ public class PrescriptionFollowupContentService extends BaseService {
				DevicePatientHealthIndex devicePatientHealthIndex = devicePatientHealthIndexDao.findOne(new Long(healthindexid));
				obj = (JSONObject)JSON.toJSON(devicePatientHealthIndex);
				valueType = obj.getInteger("value2");
				imBloodSugarValue = obj.getString("value1");
			}else{
				//如果没传体征ID,则获取最近的一条
				obj = (JSONObject)list.get(0);
				valueType = obj.getInteger("dataType");
				imBloodSugarValue = obj.getString("valuedata");
			}
			
			imBloodSugarDate = obj.getDate("recordDate");
			
			//餐前
			if(StringUtils.isNotBlank(obj.getString("valuedata"))){
			if(StringUtils.isNotBlank(imBloodSugarValue)){
				
				//餐前
				if(1 == valueType || 3 == valueType || 5 == valueType){
					followupProjectData = "{'BS_FPG':'"+obj.getString("valuedata")+"'}";
					followupProjectData = "{'BS_FPG':'"+imBloodSugarValue+"'}";
				}
				
				//参后
				if(2 == valueType || 4 == valueType || 6 == valueType){
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("valuedata")+"'}";
					followupProjectData = "{'NO_BS_FPG':'"+imBloodSugarValue+"'}";
				}
				
				//睡前-随机血糖
				if(7 == valueType ){
					followupProjectData = "{'RANDOM_BLOOD_SUGAR':'"+obj.getString("valuedata")+"'}";
					followupProjectData = "{'RANDOM_BLOOD_SUGAR':'"+imBloodSugarValue+"'}";
				}
				
				imBloodSugarValue = obj.getString("valuedata");
			}
			
			FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectData(followup_id,"3");

+ 5 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -81,7 +81,7 @@ public class DoctorSchemeService {
            sql = sql + " LEFT JOIN wlyy_patient_device dev on dev.user = p.code ";
        }
    
        sql = sql+ " LEFT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code ";
        sql = sql+ " RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.status =1 ";
        sql = sql+ " LEFT JOIN wlyy_sign_family sf on sf.patient = p.code where sf.admin_team_code = "+teamCode;
@ -396,9 +396,9 @@ public class DoctorSchemeService {
//        List<Patient> patients = patientDao.findAllSignPatientTeamcode(teamCode,doctorcode);
    
        List<PatientVO> patients = new ArrayList<>();
        String patientsql = "select p.name,b.deviceType as deviceType,group_concat(sp.label) diseaseType from wlyy_patient p " +
        String patientsql = "select p.*,b.deviceType as deviceType,group_concat(sp.label) diseaseType from wlyy_patient p " +
                "  LEFT JOIN wlyy_sign_family s on s.patient = p.code " +
                "  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.label_type = 3 and (sp.label = 1 or sp.label = 2) " +
                "  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.label_type = 3 and (sp.label = 1 or sp.label = 2) and sp.status =1" +
                "  LEFT JOIN (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on p.code = b.user " +
                "WHERE s.status > 0 and s.admin_team_code ='"+teamCode+"' and (s.doctor = '"+doctorcode+"' or s.doctor_health ='"+doctorcode+"') GROUP BY p.code";
@ -437,7 +437,6 @@ public class DoctorSchemeService {
        if(!patients.isEmpty()){
            for (PatientVO patient : patients) {
                //获取居民颜色标签
                if(1 == getcolor && patient.getDiseaseCondition() != null){
                    switch (patient.getDiseaseCondition()){
@ -459,11 +458,11 @@ public class DoctorSchemeService {
                if(1 == getstands && (patient.getStandardStatus() !=null && patient.getStandardStatus() ==1)){
                    if(patient.getDisease() != null){
                        if( "1" == patient.getDisease() || "1,2" == patient.getDisease()){
                        if( "1".equals(patient.getDisease()) || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())){
                            bloodpressure_patientcodes.add(patient.getCode());
                        }
                        if( "2" == patient.getDisease() || "1,2" == patient.getDisease()){
                        if( "2" == patient.getDisease() || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())){
                            bloodsugar_patientcodes.add(patient.getCode());
                        }
                    }

+ 4 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -2197,7 +2197,7 @@ public class StatisticsService extends BaseService {
                "       WHERE w.czrq>='" + startDate + " 00:00:00' AND w.czrq <='" + endDate + " 23:59:59' AND w.admin_team_code IN( " +
                "       SELECT " +
                "       m.id FROM wlyy_admin_team m " +
                "       WHERE m.org_code ='" + orgcode + "'" +
                "       WHERE w.org_code ='" + orgcode + "'" +
                "       ) " +
                "   GROUP BY w.admin_team_code " +
                "   ORDER BY count DESC " +
@ -2241,12 +2241,12 @@ public class StatisticsService extends BaseService {
        //待预约量排行
        String resrc_sql = "SELECT s.rowno AS reservationRK from " +
                "( " +
                "  SELECT (@rowNum :=@rowNum + 1) AS rowno,t.reservationCount,t.admin_team_code \n" +
                "  SELECT (@rowNum :=@rowNum + 1) AS rowno,t.reservationCount,t.admin_team_code " +
                "   FROM ( " +
                "   SELECT COUNT(1) AS reservationCount,w.admin_team_code " +
                "   FROM wlyy_patient_reservation  w " +
                "   FROM wlyy_patient_reservation  w JOIN wlyy_admin_team t ON w.admin_team_code = t.id " +
                "   WHERE w.czrq>='" + startDate + " 00:00:00' AND w.czrq <='" + endDate + " 23:59:59' AND " +
                "   w.org_code ='" + orgcode + "'" +
                "   t.org_code ='" + orgcode + "'" +
                "   AND w.doctor is not null " +
                "   AND w.admin_team_code IS NOT NULL " +
                "   GROUP BY w.admin_team_code " +

+ 10 - 24
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -2918,7 +2918,7 @@ public class StatisticsESService {
    }
    /**
     * 获取咨询数和未回复数..
     * 获取咨询数和未回复数.(决定用旧版,先弃用17-11-22)
     *
     * @param doctor
     * @param startDate
@ -2995,7 +2995,7 @@ public class StatisticsESService {
    }
    /**
     * 获取团队月或周咨询未回复和总数折线图
     * 获取团队月或周咨询未回复和总数折线图(后面决定用旧版的service先弃用17-11-22)
     *
     * @param teamCode
     * @param startDate
@ -3548,7 +3548,7 @@ public class StatisticsESService {
     * @param level   等级
     * @param area    等级编码
     * @param disease 疾病编码
     * @param type    类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消
     * @param type    类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
     * @return
     */
    public List<Map<String, Object>> getPrescriptionTotalHistogram(int level, String area, String disease, String type) throws Exception {
@ -3574,19 +3574,19 @@ public class StatisticsESService {
        String endTime = DateUtil.dateToStr(new Date(), "YYYY-MM-dd HH:mm:ss");
        List<SaveModel> resultList = new ArrayList<>();
        if (StringUtils.isNotBlank(disease)) {
            //类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消
            if ("0".equals(type)) {
            //类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
            if ("1".equals(type)) {
                //总数
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel2NoSlaveKey2(startTime, endTime, area, level, index58, "1", "3", disease);
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel2NoSlaveKey2(startTime, endTime, area, level, index58,SaveModel.timeLevel_ZL, SaveModel.interval_month, disease);
            } else {
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel2(startTime, endTime, area, level, index58, "1", "3", disease, type);
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel2(startTime, endTime, area, level, index58,SaveModel.timeLevel_ZL, SaveModel.interval_month, disease, type);
            }
        } else {
            if ("0".equals(type)) {
            if ("1".equals(type)) {
                //总数
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel1NoSlaveKey1(startTime, endTime, area, level, index64, "1", "3");
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel1NoSlaveKey1(startTime, endTime, area, level, index64,SaveModel.timeLevel_ZL, SaveModel.interval_month);
            } else {
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel1(startTime, endTime, area, level, index64, "1", "3", type);
                resultList = elasticsearchUtil.findLineChartDateQuotaLevel1(startTime, endTime, area, level, index64,SaveModel.timeLevel_ZL, SaveModel.interval_month, type);
            }
        }
        //把数据设置到初始化的Map里面去
@ -3889,20 +3889,6 @@ public class StatisticsESService {
                }
            }
        }
        Collections.sort(rs, new Comparator<Map<String, Object>>() {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                Double map1value = Double.valueOf(String.valueOf(o1.get("count")));
                Double map2value = Double.valueOf(String.valueOf(o2.get("count")));
                if (map1value - map2value > 0) {
                    return -1;
                } else if (map1value - map2value < 0) {
                    return 1;
                } else {
                    return 0;
                }
            }
        });
        return rs;
    }

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/call/CustomerService.java

@ -18,11 +18,13 @@ import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
@Transactional
public class CustomerService extends BaseService{
	@Autowired
@ -59,7 +61,7 @@ public class CustomerService extends BaseService{
			sql +=" AND (s.patient_name = '"+keyword+"' OR s.ssc ='"+keyword+"' OR s.Idcard ='"+keyword+"')";
		}
		if(serverType!=null){
			sql += " AND s.server_type ='"+serverType+"' " ;
			sql += " AND s.type ='"+serverType+"' " ;
		}
		if(state != null){
			sql +=" AND s.state ='"+state+"'";

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -1082,4 +1082,19 @@ public class PatientService extends TokenService {
        return patientDao.findAllSignPatientTeamcode(teamcode,doctorcode);
    }
    public boolean checkOpenidCount(String openid){
        String sql = "SELECT count(1) as total FROM wlyy_patient p WHERE p.openid = '"+openid+"' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            Map<String,Object> map = list.get(0);
            Long count = (Long)map.get("total");
            if(count>10){
                return false;
            }else{
                return true;
            }
        }
        return true;
    }
}

+ 50 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -322,7 +322,7 @@ public class WechatController extends WeixinBaseController {
            @RequestParam(required = false) String captcha,
            @RequestParam(required = false) String password,
            String openid) {
        System.out.println("login openid : " + openid);
        //System.out.println("login openid : " + openid);
        String errorMessage;
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());
@ -381,9 +381,29 @@ public class WechatController extends WeixinBaseController {
                //判断d登录密码是否正确
                if (loginPassword.equals(p.getPassword())) {
                    // 绑定用户手机号和openid
                    if (!StringUtils.equals(p.getOpenid(), openid) && !"undefined".equals(openid)) {//undefined不更新数据库
                    if (StringUtils.isNotBlank(openid) && !"undefined".equals(openid)) {//undefined不更新数据库
                        //patient.setOpenid(openid);
                        patientService.updatePatient(p, openid);
                        //1.判斷居民OPenid是不是空
                        if(StringUtils.isNotBlank(p.getOpenid())){
                            //如果OPenid与原来用户不相等,则判断登录的openids是否被大于10人登录
                            if(!p.getOpenid().equals(openid)){
                                //判断登录的openids是否被大于10人登录
                                if(!patientService.checkOpenidCount(openid)){
                                    errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
                                    return error(-2, errorMessage);
                                }
                            }
                            patientService.updatePatient(p, openid);
                        }else{
                            // 判断登录的openids是否被大于10人登录
                            if(!patientService.checkOpenidCount(openid)){
                                errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
                                return error(-2, errorMessage);
                            }else{
                                //未达到上限更新用户openid
                                patientService.updatePatient(p, openid);
                            }
                        }
                    }
                    // 用户校验通过,生成token
@ -485,10 +505,35 @@ public class WechatController extends WeixinBaseController {
                    }
                    loginLog.setUserCode(p.getCode());
                    // 绑定用户手机号和openid
                    if (!StringUtils.equals(p.getOpenid(), openid) && !"undefined".equals(openid)) {//undefined不更新数据库
//                    if (!StringUtils.equals(p.getOpenid(), openid) && !"undefined".equals(openid)) {//undefined不更新数据库
//                        //patient.setOpenid(openid);
//                        patientService.updatePatient(p, openid);
//                    }
                    if (StringUtils.isNotBlank(openid) && !"undefined".equals(openid)) {//undefined不更新数据库
                        //patient.setOpenid(openid);
                        patientService.updatePatient(p, openid);
                        //1.判斷居民OPenid是不是空
                        if(StringUtils.isNotBlank(p.getOpenid())){
                            //如果OPenid与原来用户不相等,则判断登录的openids是否被大于10人登录
                            if(!p.getOpenid().equals(openid)){
                                //判断登录的openids是否被大于10人登录
                                if(!patientService.checkOpenidCount(openid)){
                                    errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
                                    return error(-2, errorMessage);
                                }
                            }
                            patientService.updatePatient(p, openid);
                        }else{
                            // 判断登录的openids是否被大于10人登录
                            if(!patientService.checkOpenidCount(openid)){
                                errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
                                return error(-2, errorMessage);
                            }else{
                                //未达到上限更新用户openid
                                patientService.updatePatient(p, openid);
                            }
                        }
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newTxToken(p.getCode(), openid);
                    Map<Object, Object> map = new HashMap<Object, Object>();

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -885,7 +885,7 @@ public class EsStatisticsController extends BaseController {
    }
    /**
     * 获取咨询数和未回复数
     * 获取咨询数和未回复数(决定用旧版的service)
     *
     * @param startDate
     * @param endDate
@ -898,7 +898,7 @@ public class EsStatisticsController extends BaseController {
                                   @RequestParam(required = true) String endDate,
                                   @RequestParam(required = true) String isNow) {
        try {
            return write(200, "查询成功", "data", statisticsESService.getReyStatbyTeamNow(getUID(), startDate, endDate, isNow));
            return write(200, "查询成功", "data", statisticsService.getReyStatbyTeamNow(getUID(), startDate, endDate, isNow));
            //return write(200, "查询成功", "data", statisticsESService.getReyStatbyTeamNow("xh1D2017031502222",startDate,endDate,isNow));
        } catch (Exception e) {
            error(e);
@ -919,7 +919,7 @@ public class EsStatisticsController extends BaseController {
                                        @RequestParam(required = true) String endDate) {
        try {
            return write(200, "查询成功", "data", statisticsService.getServiceRankingList(getUID(), startDate, endDate));
            //return write(200, "查询成功", "data", statisticsService.getServiceRankingList("xh1D201703150222",startDate,endDate));
            //return write(200, "查询成功", "data", statisticsService.getServiceRankingList("xh1D2017031502222",startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
@ -966,7 +966,7 @@ public class EsStatisticsController extends BaseController {
    /**
     * 获取团队月或周咨询未回复和总数折线图
     *
     * 备注:决定用旧版的service(17-11-22)
     * @param teamCode  团队id
     * @param startDate
     * @param endDate
@ -980,7 +980,7 @@ public class EsStatisticsController extends BaseController {
                                      @RequestParam(required = true) String endDate,
                                      @RequestParam(required = true) String type) {
        try {
            return write(200, "查询成功", "data", statisticsESService.getTeamConsultCount(teamCode, startDate, endDate, type));
            return write(200, "查询成功", "data", statisticsService.getTeamConsultCount(teamCode, startDate, endDate, type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");

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

@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
/**
 * Created by lyr on 2016/08/16.
 * Created by lyr on 2016/08/16
 */
@Controller
@RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})

+ 4 - 4
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -96,14 +96,14 @@ pushMes:
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test
    Statistics: wlyy_quota_test
    Statistics: wlyy_quota_prod
    FollowUp: wlyy_followup
  type:
    HealthEduArticlePatient: health_edu_article_patient_test
    Statistics: wlyy_quota_test
    Statistics: wlyy_quota_prod
    FollowUpContent: wlyy_followup_content
  host:  http://59.61.92.90:9065,http://59.61.92.90:9067
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  host:  http://10.95.22.155:9200,http://10.95.22.156:9200
  tHost: 10.95.22.155:9300,10.95.22.156:9300
  clusterName: jkzl
#集美宣教居民端健康文章