Ver código fonte

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

wangjun 4 anos atrás
pai
commit
91d8b16287
14 arquivos alterados com 331 adições e 348 exclusões
  1. 2 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 115 0
      common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithOperatorAES.java
  3. 2 1
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistServiceItemDO.java
  4. 2 1
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistServiceItemOperateLogDO.java
  5. 2 2
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/GuidanceMessageLogDO.java
  6. 2 2
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationPlanTemplateDO.java
  7. 2 2
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationTemplateDetailDO.java
  8. 0 9
      common/common-entity/src/main/java/com/yihu/jw/entity/util/AesEncryptUtils.java
  9. 84 0
      common/common-entity/src/main/java/com/yihu/jw/entity/util/TransforSqlUtl.java
  10. 0 13
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java
  11. 91 95
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java
  12. 2 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistServiceItemService.java
  13. 24 177
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java
  14. 3 45
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

+ 2 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -1258,7 +1258,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            for (int i = 0; i < res.size(); i++) {
                JSONObject card = res.getJSONObject(i);
                String cardStat = card.getString("CARD_STAT");
                if ("激活".equals(cardStat)) {
                String name = card.getString("name");
                if ("激活".equals(cardStat)&&name.equalsIgnoreCase(patientDO.getName())) {
                    rs.add(card);
                }
            }

+ 115 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithOperatorAES.java

@ -0,0 +1,115 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.util.StringFStringEncryptConverter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.util.Date;
/**
 * 统一定义id的entity基类.
 * 主键生成策略是UUID
 * 还包含业务表用的 创建人,创建时间 创建人名  修改人,修改时间 修改人名
 * @author calvin
 */
// JPA 基类的标识
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class UuidIdentityEntityWithOperatorAES extends UuidIdentityEntity {
    //创建时间
	@CreatedDate
	protected Date createTime;
	//创建者
    @CreatedBy
	protected String createUser;
    //创建者
    @CreatedBy
    protected String createUserName;
    //更新时间
    @LastModifiedDate
	protected Date updateTime;
	//更新者
    @LastModifiedBy
	protected String updateUser;
	//更新者
    @LastModifiedBy
	protected String updateUserName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time", nullable = false, length = 0,updatable = false)
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user",updatable = false)
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name",updatable = false)
	@Convert(converter = StringFStringEncryptConverter.class)
	public String getCreateUserName() {
		return createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "update_user")
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name")
	@Convert(converter = StringFStringEncryptConverter.class)
	public String getUpdateUserName() {
		return updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
}

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistServiceItemDO.java

@ -3,6 +3,7 @@ package com.yihu.jw.entity.specialist;/**
 */
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperatorAES;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -17,7 +18,7 @@ import java.io.Serializable;
 **/
@Entity
@Table(name = "wlyy_service_item")
public class SpecialistServiceItemDO extends UuidIdentityEntityWithOperator implements Serializable {
public class SpecialistServiceItemDO extends UuidIdentityEntityWithOperatorAES implements Serializable {
    @Column(name = "saas_id")
    private String saasId; // saasId

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistServiceItemOperateLogDO.java

@ -3,6 +3,7 @@ package com.yihu.jw.entity.specialist;/**
 */
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperatorAES;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -16,7 +17,7 @@ import java.io.Serializable;
 **/
@Entity
@Table(name = "wlyy_service_item_operate_log")
public class SpecialistServiceItemOperateLogDO extends UuidIdentityEntityWithOperator implements Serializable {
public class SpecialistServiceItemOperateLogDO extends UuidIdentityEntityWithOperatorAES implements Serializable {
    @Column(name = "saas_id")
    private String saasId;

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/GuidanceMessageLogDO.java

@ -1,6 +1,6 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperatorAES;
import com.yihu.jw.entity.util.StringFStringEncryptConverter;
import javax.persistence.Column;
@ -14,7 +14,7 @@ import java.io.Serializable;
 */
@Entity
@Table(name = "wlyy_guidance_message_log")
public class GuidanceMessageLogDO extends UuidIdentityEntityWithOperator implements Serializable {
public class GuidanceMessageLogDO extends UuidIdentityEntityWithOperatorAES implements Serializable {
    private String saasId;
    private String messageId;

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationPlanTemplateDO.java

@ -1,7 +1,7 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperatorAES;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -12,7 +12,7 @@ import java.io.Serializable;
 */
@Entity
@Table(name = "wlyy_rehabilitation_plan_template")
public class RehabilitationPlanTemplateDO extends UuidIdentityEntityWithOperator implements Serializable {
public class RehabilitationPlanTemplateDO extends UuidIdentityEntityWithOperatorAES implements Serializable {
    @Column(name = "saas_id")
    private String saasId;

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationTemplateDetailDO.java

@ -1,7 +1,7 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperatorAES;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -14,7 +14,7 @@ import java.io.Serializable;
 */
@Entity
@Table(name = "wlyy_rehabilitation_template_detail")
public class RehabilitationTemplateDetailDO extends UuidIdentityEntityWithOperator implements Serializable {
public class RehabilitationTemplateDetailDO extends UuidIdentityEntityWithOperatorAES implements Serializable {
    @Column(name = "saas_id")
    private String saasId;

+ 0 - 9
common/common-entity/src/main/java/com/yihu/jw/entity/util/AesEncryptUtils.java

@ -31,15 +31,6 @@ public class AesEncryptUtils {
        return decrypt(str,KEY);
    }
    public static String decryptMysql(String name,String alias){
        return decryptMysql(name)+" as "+alias+" ";
    }
    public static String decryptMysql(String name){
        return ","+decryptMysqlNo(name);
    }
    public static String decryptMysqlNo(String name){
        return "CAST(AES_DECRYPT(from_base64("+name+"), '"+KEY+"') AS char)";
    }

+ 84 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/util/TransforSqlUtl.java

@ -8,6 +8,40 @@ package com.yihu.jw.entity.util;
 */
public class TransforSqlUtl {
    public static String wlyySpecialistPatientRelationLike(String sql,String ...replaceName){
        for (String tmp :replaceName){
            String str = "AES_DECRYPT(from_base64("+replaceName+"),'jkzl2021ZJXL*#%a')";
            sql = sql.replaceAll(tmp,str);
        }
        return  sql;
    }
    public static String wlyySpecialistPatientRelationReplay(String sql,String ...replaceName){
        for (String tmp :replaceName){
            String str = "CAST(AES_DECRYPT(from_base64("+replaceName+"),'jkzl2021ZJXL*#%a') AS CHAR ) ";
            sql = sql.replaceAll(tmp,str);
        }
        return  sql;
    }
    public static String wlyy_service_itemAll(String sql){
        String sqlTmp = " *,CAST(AES_DECRYPT(from_base64(create_user_name),'jkzl2021ZJXL*#%a')AS CHAR ) AS create_user_name,\n" +
                "CAST( AES_DECRYPT(from_base64(update_user_name),'jkzl2021ZJXL*#%a')AS CHAR) AS update_user_name\n";
        sql = sql.replace("*", sqlTmp);
        return sql;
    }
    public static String specialistPatientRelationAll(String sql) {
        String sqlTmp = " *,CAST(AES_DECRYPT(from_base64(doctor_name),'jkzl2021ZJXL*#%a')AS CHAR ) AS doctor_name,\n" +
                "CAST( AES_DECRYPT(from_base64(patient_name),'jkzl2021ZJXL*#%a')AS CHAR) AS patient_name,\n" +
                "CAST(AES_DECRYPT(from_base64(health_assistant_name),'jkzl2021ZJXL*#%a') AS CHAR) AS health_assistant_name,\n" +
                "CAST(AES_DECRYPT(from_base64(sign_doctor_name),'jkzl2021ZJXL*#%a') AS CHAR) AS sign_doctor_name,\n" +
                "CAST(AES_DECRYPT(from_base64(health_doctor_name),'jkzl2021ZJXL*#%a') AS CHAR) AS health_doctor_name,\n" +
                "CAST(AES_DECRYPT(from_base64(create_user_name),'jkzl2021ZJXL*#%a')AS CHAR)AS create_user_name,\n" +
                "CAST(AES_DECRYPT(from_base64(update_user_name),'jkzl2021ZJXL*#%a')AS CHAR)AS update_user_name \n" ;
        sql = sql.replace("*", sqlTmp);
        return sql;
    }
    public static String deviceGrantDoctorName(String sql){
        return sql.replaceAll("d.grant_doctor_name","CAST(AES_DECRYPT(from_base64(d.grant_doctor_name),'jkzl2021ZJXL*#%a')AS char)");
    }
@ -20,4 +54,54 @@ public class TransforSqlUtl {
    public static String wlyyPatientDeviceLocationIdCard(String sql){
        return sql.replaceAll("idcard","CAST(AES_DECRYPT(from_base64(idcard),'jkzl2021ZJXL*#%a')AS char)");
    }
    public static String wlyy_patient_rehabilitation_planName(String sql){
        String str = "CAST(AES_DECRYPT(from_base64(p.name),'jkzl2021ZJXL*#%a') AS CHAR ) AS name ";
        return sql.replaceAll("p.name",str);
    }
    public static String wlyy_patient_rehabilitation_planName2(String sql){
        String str = "CAST(AES_DECRYPT(from_base64(p.name),'jkzl2021ZJXL*#%a') AS CHAR ) ";
        return sql.replaceAll("p.name",str);
    }
    public static String wlyy_patient_rehabilitation_planAll2(String sql){
        String str = "p.*,CAST(AES_DECRYPT(from_base64(p.name),'jkzl2021ZJXL*#%a') AS CHAR ) AS name,CAST(AES_DECRYPT(from_base64(p.create_user_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS create_user_name,CAST(AES_DECRYPT(from_base64(p.update_user_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS update_user_name";
        return sql.replace("p.*",str);
    }
    public static String wlyy_patient_rehabilitation_planCreateName(String sql){
        String str = "CAST(AES_DECRYPT(from_base64(p.create_user_name),'jkzl2021ZJXL*#%a') AS CHAR ) ";
        return sql.replaceAll("p.create_user_name",str);
    }
    public static String wlyy_plan_detail_appointmentAll(String sql){
        String str = "*,CAST(AES_DECRYPT(from_base64(doctor_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS doctor_name,CAST(AES_DECRYPT(from_base64(appointment_doctor_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS appointment_doctor_name";
        return sql.replace("*",str);
    }
    public static String wlyy_rehabilitation_operate_recordsDoctorName(String sql){
        String str = "CAST(AES_DECRYPT(from_base64(r.doctor_name),'jkzl2021ZJXL*#%a') AS CHAR ) ";
        return sql.replaceAll("r.doctor_name",str);
    }
    public static String wlyy_rehabilitation_plan_detailAll(String sql){
        String str = "*,CAST(AES_DECRYPT(from_base64(doctor_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS doctor_name,CAST(AES_DECRYPT(from_base64(create_user_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS create_user_name,CAST(AES_DECRYPT(from_base64(update_user_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS update_user_name";
        return sql.replace("*",str);
    }
    public static String wlyy_rehabilitation_plan_detailAll2(String sql){
        String str = "d.*,CAST(AES_DECRYPT(from_base64(d.doctor_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS doctor_name,CAST(AES_DECRYPT(from_base64(d.create_user_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS create_user_name,CAST(AES_DECRYPT(from_base64(d.update_user_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS update_user_name";
        return sql.replace("d.*",str);
    }
    public static String wlyy_rehabilitation_plan_detailDoctorName(String sql){
        String str = "CAST(AES_DECRYPT(from_base64(d.doctor_name),'jkzl2021ZJXL*#%a') AS CHAR ) ";
        return sql.replaceAll("d.doctor_name",str);
    }
    public static String wlyy_rehabilitation_plan_detailDoctorName2(String sql){
        String str = "CAST(AES_DECRYPT(from_base64(d.doctor_name),'jkzl2021ZJXL*#%a') AS CHAR ) as doctor_name";
        return sql.replaceAll("d.doctor_name",str);
    }
}

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 13
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java


+ 91 - 95
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -10,7 +10,7 @@ import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanLogDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.restmodel.specialist.*;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -73,23 +73,21 @@ public class SpecialistService{
    public MixEnvelop<SpecialistPatientRelationVO, SpecialistPatientRelationVO> findSpecialistPatientRelation(String doctor, Integer page, Integer size)throws ParseException {
        String sql = "SELECT " +
                " r.id, " +
                " r.doctor " +
                AesEncryptUtils.decryptMysql("r.doctor_name","doctor_name") +
                " r.doctor ,r.doctor_name AS doctor_name " +
                " ,r.saas_id AS sassId, " +
                " r.patient " +
                 AesEncryptUtils.decryptMysql("r.patient_name","patient_name") +
                " ,r.health_doctor AS healthDoctor " +
                AesEncryptUtils.decryptMysql("r.health_doctor_name","healthDoctorName") +
                " r.patient ,r.patient_name AS patient_name" +
                " ,r.health_doctor AS healthDoctor ,r.health_doctor_name AS healthDoctorName" +
                " ,r.sign_code AS signCode, " +
                " r.sign_year AS signYear, " +
                " r.sign_doctor AS sign_doctor " +
                AesEncryptUtils.decryptMysql("r.sign_doctor_name","signDoctorName") +
                " r.sign_doctor AS sign_doctor ,r.sign_doctor_name AS signDoctorName" +
                " ,r.create_time AS createTime," +
                " r.status " +
                "FROM " +
                " wlyy_specialist_patient_relation r " +
                "WHERE " +
                " r.doctor = '"+doctor+"' AND r.status >=0  AND r.sign_status >0 ORDER BY r.create_time DESC LIMIT "+(page-1)*size+","+size;
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.doctor_name","r.patient_name","r.health_doctor_name","r.sign_doctor_name");
        List<SpecialistPatientRelationVO> specialistPatientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationVO.class));
        String sqlcount = "SELECT count(1) AS total " +
@ -134,8 +132,7 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> findNoLabelPatientRelation(String doctor){
        String sql ="SELECT " +
                " r.patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " r.patient ,r.patient_name as patientName" +
                " ,IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo, " +
                " rd.create_time AS createTime ," +
@ -155,6 +152,8 @@ public class SpecialistService{
                "   i.label_type = '7' AND " +
                "   i.status = 1 " +
                " )";
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name");
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRelationVOs);
@ -174,8 +173,7 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> findPatientRelatioByAssistant(String doctor , String assistant, Integer page, Integer size){
        String sql ="SELECT " +
                " r.patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " r.patient ,r.patient_name as patientName" +
                " ,IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo ," +
                " p.sex," +
@ -198,6 +196,7 @@ public class SpecialistService{
                "  r.doctor = '"+doctor+"' AND r.status >=0  AND r.sign_status >0 "+
                " AND r.health_assistant = '"+assistant+"' LIMIT "+(page-1)*size+","+size;
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name");
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRelationVOs);
@ -206,8 +205,7 @@ public class SpecialistService{
    public MixEnvelop<PatientLabelVO, PatientLabelVO> getPatientByLabel(String doctor, String labelType,String teamCode, String labelCode, Integer page, Integer size,String shareDoctor){
        String sql="SELECT " +
                " p. CODE " +
                AesEncryptUtils.decryptMysql("s.patient_name","name") +
                " p. CODE ,s.patient_name as name," +
                " p.sex," +
                " IFNULL( " +
                "  YEAR ( " +
@ -221,8 +219,7 @@ public class SpecialistService{
                " p.photo, " +
                " lb.labelName as health, " +
                " lb.label AS healthcode ," +
                " s.health_assistant AS healthAssistant" +
                AesEncryptUtils.decryptMysql("s.health_assistant_name","healthAssistantName") +
                " s.health_assistant AS healthAssistant,s.health_assistant_name as healthAssistantName " +
//                " s.health_assistant_name AS healthAssistantName," +
                " ,s.is_manage AS isManage," +
                " s.id AS specialCode" +
@ -242,6 +239,7 @@ public class SpecialistService{
                " ) lb " +
                " JOIN "+basedb+".wlyy_patient p ON p. CODE = lb.patient " +
                " JOIN wlyy_specialist_patient_relation s ON s.patient = lb.patient ";
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"s.patient_name","s.health_assistant_name");
        if(StringUtils.isNotBlank(shareDoctor)){
            sql = sql + " JOIN "+basedb+".wlyy_doctor_special_share sp ON s.id = sp.special_code and sp.doctor = '"+shareDoctor+"' ";
        }
@ -251,8 +249,7 @@ public class SpecialistService{
        System.out.print("日志:"+sql);
        if("7".equals(labelType)){
            sql = "SELECT " +
                    "c.CODE" +
                    AesEncryptUtils.decryptMysql("a.patient_name","name") +
                    "c.CODE,a.patient_name as name" +
//                    "c.NAME," +
                    ",c.sex," +
                    "IFNULL(YEAR (from_days(datediff(now(),c.birthday))),'未知') age," +
@ -260,8 +257,7 @@ public class SpecialistService{
                    "b.disease_name AS labelName," +
                    "d.label_name AS health," +
                    "d.label AS healthcode," +
                    "a.health_assistant AS healthAssistant" +
                    AesEncryptUtils.decryptMysql("a.health_assistant_name","healthAssistantName") +
                    "a.health_assistant AS healthAssistant,a.health_assistant_name AS healthAssistantName," +
//                    "a.health_assistant_name AS healthAssistantName, " +
                    ",a.is_manage AS isManage, " +
                    "a.id AS specialCode " +
@ -276,18 +272,17 @@ public class SpecialistService{
//                    "AND a.doctor='"+doctor+"' OR a.health_assistant= '"+doctor+
                    " AND a.team_code ='" +teamCode+"' "+
                    " LIMIT "+(page-1)*size+","+size;
            sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"a.patient_name","a.health_assistant_name");
        }
        
        if("pending".equals(labelType)){
            sql = "SELECT " +
                    "c.CODE" +
                    AesEncryptUtils.decryptMysql("a.patient_name","name") +
                    "c.CODE, a.patient_name as name" +
//                    "c.NAME," +
                    ",c.sex," +
                    "IFNULL(YEAR (from_days(datediff(now(),c.birthday))),'未知') age," +
                    "c.photo," +
                    "a.health_assistant AS healthAssistant" +
                    AesEncryptUtils.decryptMysql("a.health_assistant_name","healthAssistantName") +
                    "a.health_assistant AS healthAssistant,a.health_assistant_name as healthAssistantName" +
//                    "a.health_assistant_name AS healthAssistantName, " +
                    ",a.is_manage AS isManage " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
@ -295,8 +290,8 @@ public class SpecialistService{
                    " WHERE a.sign_status> 0 AND a.`status`>=0 AND (a.is_manage = 0 or a.is_manage is null)" +
                    " AND a.team_code ='" +teamCode+"' "+
                    " LIMIT "+(page-1)*size+","+size;
            sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"a.patient_name","a.health_assistant_name");
        }
        
        List<PatientLabelVO> PatientLabelVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientLabelVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,PatientLabelVOs);
    }
@ -345,8 +340,7 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> getDoctorPatientByName(String doctor, String nameKey,String teamCode, Integer page, Integer size){
        String sql ="SELECT " +
                " p.code AS patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " p.code AS patient,r.patient_name as patientName  " +
//                " p.`name` AS patientName, " +
                " ,p.photo, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
@ -362,8 +356,9 @@ public class SpecialistService{
                "  t.label_name, " +
                "  t.patient " +
                " FROM " +
                "  "+basedb+".wlyy_sign_patient_label_info t " +
                " WHERE " +
                "  "+basedb+".wlyy_sign_patient_label_info t ";
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name");
        String tmpSql = " WHERE " +
                "  t.label_type = '8' " +
                " AND t.`status` = '1' " +
                " ) h ON h.patient = r.patient " +
@ -371,9 +366,10 @@ public class SpecialistService{
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy.wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                "' ) " +
                " AND r.status >=0  AND r.sign_status >0 " +
                " AND " + AesEncryptUtils.decryptMysqlNo("r.patient_name") + " LIKE '%"+nameKey+"%' "+
                " AND " + "r.patient_name" + " LIKE '%"+nameKey+"%' "+
                " LIMIT "+(page-1)*size+","+size;
        tmpSql = TransforSqlUtl.wlyySpecialistPatientRelationLike(tmpSql,"r.patient_name");
        sql = sql+tmpSql;
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRelationVOs);
@ -382,8 +378,7 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO, PatientRelationVO> getDoctorPatientByNameOrIdCard(String doctor, String filter,String teamCode, Integer page, Integer size){
        String sql ="SELECT " +
                " p.code AS code " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " p.code AS code,r.patient_name as patientName " +
//                " p.`name` AS name, " +
                " ,p.photo, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
@ -400,8 +395,9 @@ public class SpecialistService{
                "  t.label_name, " +
                "  t.patient " +
                " FROM " +
                "  "+basedb+".wlyy_sign_patient_label_info t " +
                " WHERE " +
                "  "+basedb+".wlyy_sign_patient_label_info t " ;
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name");
        String sqlTmp=  " WHERE " +
                "  t.label_type = '8' " +
                " AND t.`status` = '1' " +
                " ) h ON h.patient = r.patient " +
@ -409,9 +405,10 @@ public class SpecialistService{
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy.wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                "' ) " +
                " AND r.status >=0  AND r.sign_status >0 " +
                " AND (" +  AesEncryptUtils.decryptMysqlNo("r.patient_name")  + " LIKE '%"+filter+"%' OR p.idcard LIKE '%"+filter+"%') "+
                " AND (" +  "r.patient_name"  + " LIKE '%"+filter+"%' OR p.idcard LIKE '%"+filter+"%') "+
                " LIMIT "+(page-1)*size+","+size;
        sqlTmp = TransforSqlUtl.wlyySpecialistPatientRelationLike(sqlTmp,"r.patient_name");
        sql = sql+sqlTmp;
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRelationVOs);
@ -448,8 +445,8 @@ public class SpecialistService{
        }
        String sql ="SELECT " +
                " p.code AS patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " p.code AS patient ,r.patient_name as patientName" +
                //AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " p.`name` AS patientName, " +
                " ,p.photo, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
@ -475,6 +472,7 @@ public class SpecialistService{
                " AND r.status >=0  AND r.sign_status >0 " +
                " AND r.health_assistant IS NULL "+
                " LIMIT "+(page-1)*size+","+size;
        sql  = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name");
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
        return MixEnvelop.getSuccessList(SpecialistMapping.api_success,patientRelationVOs,total.intValue());
@ -486,14 +484,14 @@ public class SpecialistService{
        //1.查询该居民是否已经与该专科医生签约
        String checkDoctorSql = "SELECT " +
                " r.id AS relationCode," +
                " r.patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " r.patient ,r.patient_name as patientName " +
                //AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
                " ,r.team_code AS teamCode, " +
                " t.`name`, " +
                " d.photo ," +
                " d.code AS doctor" +
                AesEncryptUtils.decryptMysql("r.doctor_name","doctorName") +
                " d.code AS doctor, r.doctor_name as doctorName" +
               // AesEncryptUtils.decryptMysql("r.doctor_name","doctorName") +
//                " d.name AS doctorName" +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
@ -505,6 +503,7 @@ public class SpecialistService{
                " AND r.`status` >= 0 " +
                " AND r.sign_status >=0 " +
                " AND t.available = '1' ";
        checkDoctorSql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(checkDoctorSql,"r.patient_name","r.doctor_name");
        List<SpecialistTeamVO> specialistTeamVOs = jdbcTemplate.query(checkDoctorSql,new BeanPropertyRowMapper(SpecialistTeamVO.class));
        if(specialistTeamVOs!=null&&specialistTeamVOs.size()>0){
@ -519,8 +518,7 @@ public class SpecialistService{
        //验证团队是否已经签约
        String checkTeamSql = "SELECT " +
                " r.id AS relationCode," +
                " r.patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " r.patient ,r.patient_name as patientName" +
//                " r.patient_name AS patientName, " +
                " ,r.team_code AS teamCode, " +
                " t.`name`, " +
@ -535,6 +533,7 @@ public class SpecialistService{
                " AND r.`status` >=0 " +
                " AND r.sign_status >=0 " +
                " AND t.available = '1' ";
        checkTeamSql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(checkTeamSql,"r.patient_name");
        List<SpecialistTeamVO> teamVOs = jdbcTemplate.query(checkTeamSql,new BeanPropertyRowMapper(SpecialistTeamVO.class));
        if(teamVOs!=null&&teamVOs.size()>0){
@ -565,8 +564,7 @@ public class SpecialistService{
    public List<AdminTeamMemberVO> findTeamMember(Long teamId){
        String menberSql = "SELECT " +
                " m.doctor_code AS doctorCode " +
                AesEncryptUtils.decryptMysql("d.name","doctorName") +
//                        " d.`name` AS doctorName " +
                        " d.`name` AS doctorName " +
                " FROM " +
                " "+basedb+".wlyy_admin_team_member m " +
                " JOIN "+basedb+".wlyy_doctor d ON m.doctor_code = d.`code` " +
@ -600,11 +598,11 @@ public class SpecialistService{
    public MixEnvelop<PatientSignInfoVO, PatientSignInfoVO> findPatientSigninfo(String code){
        String sql = "SELECT " +
                " r.patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " r.patient ,r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
                " ,r.doctor " +
                AesEncryptUtils.decryptMysql("r.doctor_name","doctorName") +
                " ,r.doctor ,r.doctor_name as doctorName" +
                //AesEncryptUtils.decryptMysql("r.doctor_name","doctorName") +
//                " r.doctor_name AS doctorName, " +
                " ,d.hospital, " +
                " d.hospital_name AS hospitalName, " +
@ -623,6 +621,7 @@ public class SpecialistService{
                " JOIN "+basedb+".wlyy_admin_team t ON t.id = r.team_code " +
                " WHERE " +
                " r.id = '"+code+"'";
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name","r.doctor_name");
        List<PatientSignInfoVO> patientSignInfoVOs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(PatientSignInfoVO.class));
        PatientSignInfoVO patientSignInfoVO = (null != patientSignInfoVOs && patientSignInfoVOs.size() > 0 ? patientSignInfoVOs.get(0) : new PatientSignInfoVO());
        return MixEnvelop.getSuccess(SpecialistMapping.api_success, patientSignInfoVO);
@ -631,14 +630,14 @@ public class SpecialistService{
    public MixEnvelop<SpecialistTeamVO, SpecialistTeamVO> findPatientTeamList(String patient){
        String sql = "SELECT " +
                " r.id AS relationCode, " +
                " r.patient " +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " r.patient r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
                " ,r.team_code,r.sign_date , " +
                " t.`name` AS name," +
                " d.photo," +
                " md.code AS doctor" +
                AesEncryptUtils.decryptMysql("md.name","doctorName") +
                " md.code AS doctor,md.name as doctorName" +
              //  AesEncryptUtils.decryptMysql("md.name","doctorName") +
//                " md.name AS doctorName," +
                ",d.hospital,d.hospital_name " +
                " FROM " +
@ -650,6 +649,7 @@ public class SpecialistService{
                " r.patient = '"+patient+"' " +
                " AND r.`status` >=0  " +
                " AND r.sign_status >0";
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name");
        List<SpecialistTeamVO> specialistTeamVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistTeamVO.class));
        if(specialistTeamVOs!=null&&specialistTeamVOs.size()>0){
@ -665,11 +665,12 @@ public class SpecialistService{
        String sql = "SELECT " +
                " r.id AS relationCode, " +
                " r.patient, " +
                " r.team_code AS teamCode" +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " r.team_code AS teamCode,r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
//                " d.name AS doctorName, " +
                AesEncryptUtils.decryptMysql("d.name","doctorName") +
                ",d.name as doctorName"+
               // AesEncryptUtils.decryptMysql("d.name","doctorName") +
                " ,d.code AS doctor, " +
                " d.photo, " +
                " d.dept, " +
@ -686,6 +687,7 @@ public class SpecialistService{
                " r.patient ='"+patient+"' " +
                " AND r.`status`>=0 " +
                " AND r.sign_status >0";
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name");
        List<PatientSignInfoVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientSignInfoVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientSignInfoVOs);
    }
@ -697,15 +699,13 @@ public class SpecialistService{
                "(SELECT " +
                " r.id AS relationCode," +
                " r.patient, " +
                " r.team_code AS teamCode" +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
                " ,r.health_assistant AS healthAssistant" +
                AesEncryptUtils.decryptMysql("r.health_assistant_name","healthAssistantName") +
//                " r.health_assistant_name AS healthAssistantName," +
                " ,r.create_time AS createTime" +
                AesEncryptUtils.decryptMysql("d.name","doctorName") +
//                " d.name AS doctorName, " +
                " r.team_code AS teamCode,r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " ,r.health_assistant AS healthAssistant,r.health_assistant_name as healthAssistantName" +
                //AesEncryptUtils.decryptMysql("r.health_assistant_name","healthAssistantName") +
                " ,r.create_time AS createTime," +
//                AesEncryptUtils.decryptMysql("d.name","doctorName") +
                " d.name AS doctorName, " +
                " ,d.code AS doctor, " +
                " d.photo, " +
                " d.dept, " +
@ -725,6 +725,7 @@ public class SpecialistService{
                "  WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1')" +
//                " AND r.`status`>=0 " +
                " AND r.sign_status >0 ) r join "+basedb+".wlyy_patient p on r.patient = p.code order by p.czrq DESC ";
        sql = TransforSqlUtl.wlyySpecialistPatientRelationReplay(sql,"r.patient_name","r.health_assistant_name");
        List<PatientSignInfoVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientSignInfoVO.class));
        PatientSignInfoVO patientSignInfoVO = (null != patientSignInfoVOs && patientSignInfoVOs.size() > 0 )? patientSignInfoVOs.get(0):null;
        return MixEnvelop.getSuccess(SpecialistMapping.api_success, patientSignInfoVO);
@ -737,8 +738,8 @@ public class SpecialistService{
        if(StringUtils.isNotBlank(name)){
            sql = "SELECT " +
                    "doctor.CODE AS CODE" +
                    AesEncryptUtils.decryptMysql("doctor.name","name") +
//                    "doctor.NAME AS NAME," +
//                    AesEncryptUtils.decryptMysql("doctor.name","name") +
                    ",doctor.NAME AS NAME" +
                    ",doctor.sex AS sex," +
                    "doctor.birthday AS birthday," +
                    "doctor.photo AS photo," +
@ -762,12 +763,12 @@ public class SpecialistService{
                    "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                    ") " +
                    "t ON doctor.CODE=t.doctorcode and " + AesEncryptUtils.decryptMysqlNo("doctor.name")  + "  like '%"+name+"%'";
                    "t ON doctor.CODE=t.doctorcode and doctor.NAME like '%"+name+"%'";
        }else{
            sql = "SELECT " +
                    "doctor.CODE AS CODE" +
                    AesEncryptUtils.decryptMysql("doctor.name","name") +
//                    "doctor.NAME AS NAME," +
//                    AesEncryptUtils.decryptMysql("doctor.name","name") +
                    ",doctor.NAME AS NAME" +
                    ",doctor.sex AS sex," +
                    "doctor.birthday AS birthday," +
                    "doctor.photo AS photo," +
@ -817,8 +818,8 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO,PatientRelationVO> getSpecialistSignFamilyPatientByName(String specialdoctor, String familydoctor, String nameKey, Integer page, Integer size) {
        String sql ="SELECT " +
                "p.CODE AS patient" +
                AesEncryptUtils.decryptMysql("p.name","patientName") +
//                "p.`name` AS patientName," +
//                AesEncryptUtils.decryptMysql("p.name","patientName") +
                ",p.`name` AS patientName" +
                ",p.photo," +
                "IFNULL(YEAR (from_days(datediff(now(),p.birthday))),'未知') age," +
                "p.sex " +
@ -829,8 +830,8 @@ public class SpecialistService{
                "  AND doctor='"+specialdoctor+"') " +
                "  AND (a.doctor='"+familydoctor+"' OR a.doctor_health='"+familydoctor+"') ";
        if(StringUtils.isNotBlank(nameKey)){
            sql= sql + " AND " + AesEncryptUtils.decryptMysqlNo("a.name") + " LIKE '%"+nameKey+"%' ";
            sql= sql + " AND  a.name LIKE '%"+nameKey+"%' ";
//            sql= sql + " AND " + AesEncryptUtils.decryptMysqlNo("a.name") + " LIKE '%"+nameKey+"%' ";
        }
        sql= sql +" AND a.`status`=1 AND a.expenses_status=1) s ON p.CODE=s.patient" +
                " LIMIT "+(page-1)*size+","+size;
@ -847,7 +848,8 @@ public class SpecialistService{
                "IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                "p.birthday, " +
                "p.photo " +
                "FROM (SELECT s.disease,s.disease_name,s.patient" + AesEncryptUtils.decryptMysql("s.patient_name","patient_name") + ",r.team_code from " +
//                "FROM (SELECT s.disease,s.disease_name,s.patient" + AesEncryptUtils.decryptMysql("s.patient_name","patient_name") + ",r.team_code from " +
                "FROM (SELECT s.disease,s.disease_name,s.patient s.patient_name,r.team_code from " +
                "(SELECT id, team_code FROM wlyy_specialist_patient_relation WHERE doctor='" + doctor + "' and sign_status > 0 and `status` >= 0) r " +
                "JOIN "+basedb+".wlyy_patient_disease_server s on r.id = s.specialist_relation_code WHERE s.del = 1) s " +
                "JOIN "+basedb+".wlyy_patient p on s.patient = p.`code` where p.`status` >0 ";
@ -967,7 +969,7 @@ public class SpecialistService{
        jsonObject.put("doctorInfo", jdbcTemplate.queryForMap(doctorSql));
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code" + AesEncryptUtils.decryptMysql("wd.name","doctorName") + "  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
@ -1018,7 +1020,7 @@ public class SpecialistService{
        jsonObject.put("specialistPatientRelationId", null == specialistPatientRelationDO ? null : specialistPatientRelationDO.getId());
        jsonObject.put("signCertificate", null == specialistPatientRelationDO ? null : specialistPatientRelationDO.getSignCertificate());
        //1、获取居民基础信息
        String preSql = "SELECT p.photo as photo" +  AesEncryptUtils.decryptMysql("p.name","name") + ", p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
        String preSql = "SELECT p.name as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wd.name is null THEN '无' ELSE wd.name END as doctorName,CASE  WHEN wd.hospital_name is NULL THEN '无' ELSE wd.hospital_name END as hospitalName,CASE  WHEN wd.mobile is NULL THEN '无' ELSE wd.mobile END as doctorMobole ";
        String patientSql = " from " + basedb + ".wlyy_patient p LEFT JOIN " + basedb + ".wlyy_sign_family wsf " +
                " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
@ -1039,9 +1041,9 @@ public class SpecialistService{
        jsonObject.put("patientInfo", map);
        //2、获取医生信息(所属医院、科室、姓名)
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName"+AesEncryptUtils.decryptMysql("wd.name","name")+" FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";;
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";;
        if("0".equals(signStatus)){
            doctorSql="SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName"+AesEncryptUtils.decryptMysql("wd.name","name")+" FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + specialistPatientRelationDO.getDoctor() + "'";
            doctorSql="SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + specialistPatientRelationDO.getDoctor() + "'";
        }
        Map<String,Object> result =jdbcTemplate.queryForMap(doctorSql);
        if ("0".equals(signStatus) && !(doctorCode.equals(specialistPatientRelationDO.getDoctor()))) {
@ -1052,8 +1054,7 @@ public class SpecialistService{
        jsonObject.put("doctorInfo", result);
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code" + AesEncryptUtils.decryptMysql("wd.name","doctorName") + "  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
@ -1174,13 +1175,8 @@ public class SpecialistService{
    public List<SpecialistPatientRelationDO> selectByAssistant(String patient,String doctor){
        String sql = "select *" +
                AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                AesEncryptUtils.decryptMysql("r.doctor_name","doctorName") +
                AesEncryptUtils.decryptMysql("r.health_assistant_name","healthAssistantName") +
                AesEncryptUtils.decryptMysql("r.health_doctor_name","healthDoctorName") +
                AesEncryptUtils.decryptMysql("r.sign_doctor_name","signDoctorName") +
                AesEncryptUtils.decryptMysql("r.create_user_name","createUserName") +
                " from wlyy_specialist_patient_relation r where r.health_assistant = '"+doctor+"' and r.patient = '"+patient+"' ";
        sql = TransforSqlUtl.specialistPatientRelationAll(sql);
        List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
        return relationDOS;
    }
@ -1192,8 +1188,7 @@ public class SpecialistService{
     */
    public MixEnvelop searchPatientInSpecialistNew(String doctorCode,String keywords,Integer page,Integer pageSize) throws Exception{
        String sql1 = " select count(1) as num ";
        String sql2 = " select p.idcard" + AesEncryptUtils.decryptMysql("p.name","name")  + ",p.code,p.photo";
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo";
        String whereSql ="";
        if(!StringUtils.isEmpty(keywords)){
            whereSql+=" and  p.mobile ='"+keywords+"'";
@ -1267,6 +1262,7 @@ public class SpecialistService{
                " SELECT m.doctor_code  FROM wlyy.wlyy_admin_team_member m " +
                " WHERE  m.team_id IN ( SELECT dt.id  FROM  wlyy.wlyy_admin_team dt LEFT JOIN wlyy.wlyy_admin_team_member watm ON dt.id = watm.team_id   WHERE " +
                " dt.available = '1' AND watm.available = '1'  AND watm.doctor_code = '"+doctor+"') AND m.available = '1'  ) and r.patient = '"+patient+"' and r.sign_status=0";
        sql  = TransforSqlUtl.specialistPatientRelationAll(sql);
        List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
        SpecialistPatientRelationDO specialistPatientRelationDO=null!=relationDOS&&relationDOS.size()>0?relationDOS.get(0):new SpecialistPatientRelationDO();
        return specialistPatientRelationDO;
@ -1310,10 +1306,10 @@ public class SpecialistService{
        }
        String sql =" select name from wlyy.wlyy_doctor where code='"+toDoctorCode+"'";
        String toDoctorName = jdbcTemplate.queryForObject(sql,String.class);
        toDoctorName = AesEncryptUtils.decrypt(toDoctorName);
//        toDoctorName = AesEncryptUtils.decrypt(toDoctorName);
        sql =" select name from wlyy.wlyy_doctor where code='"+doctorCode+"'";
        String doctorName = jdbcTemplate.queryForObject(sql,String.class);
        doctorName = AesEncryptUtils.decrypt(doctorName);
//        doctorName = AesEncryptUtils.decrypt(doctorName);
        JSONObject result = new JSONObject();
        JSONArray planObject = new JSONArray();
        JSONArray planDetailObject = new JSONArray();
@ -1322,7 +1318,7 @@ public class SpecialistService{
        for (String patientCode:patient){
            sql ="select name from wlyy.wlyy_patient where code='"+patientCode+"' ";
            String patientName = jdbcTemplate.queryForObject(sql,String.class);
            patientName = AesEncryptUtils.decrypt(patientName);
//            patientName = AesEncryptUtils.decrypt(patientName);
            List<PatientRehabilitationPlanDO> planList  = patientRehabilitationPlanDao.findByPatientAndCreateUserAndTeamCode(patientCode,doctorCode,Integer.parseInt(teamCode));{
                for (PatientRehabilitationPlanDO plan:planList){
                    plan.setCreateUser(toDoctorCode);

+ 2 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistServiceItemService.java

@ -10,6 +10,7 @@ import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.SpecialistEvaluateDO;
import com.yihu.jw.entity.specialist.SpecialistServiceItemDO;
import com.yihu.jw.entity.specialist.SpecialistServiceItemOperateLogDO;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
@ -168,6 +169,7 @@ public class SpecialistServiceItemService {
    public MixEnvelop<SpecialistServiceItemDO,SpecialistServiceItemDO> selectByHospital(String hospital){
        MixEnvelop<SpecialistServiceItemDO,SpecialistServiceItemDO> envelop = new MixEnvelop<>();
        String sql = "select * from wlyy_service_item where status = 1 AND imediate = 1 ";
        sql = TransforSqlUtl.wlyy_service_itemAll(sql);
        List<SpecialistServiceItemDO> specialistServiceItemDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistServiceItemDO.class));
        List<SpecialistServiceItemDO> specialistServiceItemDOList = new ArrayList<>();
        for (int i =0;i<specialistServiceItemDOS.size();i++){

+ 24 - 177
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -7,6 +7,7 @@ import com.yihu.jw.dao.rehabilitation.*;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -88,12 +89,8 @@ public class RehabilitationManageService {
     */
    public MixEnvelop<Map<String,Object>, Map<String,Object>> findRehabilitationPlan(Integer doctorType,String doctorCode, String diseaseCode, Integer planType,Integer todaybacklog, String patientCondition,Integer page, Integer pageSize) throws Exception{
//        if(StringUtils.isNotEmpty(diseaseCode)){
//            leftSql += " left join "+basedb+".wlyy_patient_disease_server s on p.patient=s.patient and s.del=1 and s.disease ='"+diseaseCode+"'" ;
//        }
        String leftSql = "";
        String sql = " select p.*" + AesEncryptUtils.decryptMysql("p.name","patientName") + "  from wlyy_specialist.wlyy_patient_rehabilitation_plan p  " ;
        String sql = " select p.*  from wlyy_specialist.wlyy_patient_rehabilitation_plan p  " ;
        if(doctorType==2){//家医是根据签约关系过滤
            leftSql =" join "+basedb+".wlyy_sign_family f on f.patient=p.patient and f.expenses_status='1' and f.status=1 ";
@ -110,8 +107,9 @@ public class RehabilitationManageService {
        }
        if(StringUtils.isNotEmpty(patientCondition)){
            sql += " and " + AesEncryptUtils.descryptMysqlNo("p.name") + " like '%"+patientCondition+"%' ";
            sql += " and " + AesEncryptUtils.decryptMysqlNo("p.name") + " like '%"+patientCondition+"%' ";
        }
        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll2(sql);
        String finalSql = "";
        String todayStart = DateUtil.getStringDateShort()+" "+"00:00:00";
@ -123,16 +121,7 @@ public class RehabilitationManageService {
        }
        finalSql =" select DISTINCT b.* from (select  plan_id,doctor from wlyy_specialist.wlyy_rehabilitation_plan_detail where  1=1 "+condition+") a " +
                " JOIN ("+sql+") b on a.plan_id=b.id ";
//        if(todaybacklog!=null&&todaybacklog==1){
//            finalSql = " select DISTINCT b.* from (select DISTINCT plan_id from wlyy_specialist.wlyy_rehabilitation_plan_detail where execute_time>='"+todayStart+"' and execute_time<='"+todayEnd+"') a "+
//                    "LEFT JOIN ("+sql+") b on a.plan_id=b.id";
//        }else{
//            finalSql = " select b.* from ("+sql+") b ";
//        }
        if(doctorType==1){//专科医生是根据计划的创建者字段过滤
//            sql+=" and (p.create_user in (select r.doctor assistant from " +
//                    " wlyy_specialist.wlyy_specialist_patient_relation r where r.health_assistant ='"+doctorCode+"') " +
//                    " or p.create_user='"+doctorCode+"') ";
            finalSql += " where  b.create_user = '"+doctorCode+"' or a.doctor ='"+doctorCode+"'";
        }
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(finalSql);
@ -211,6 +200,7 @@ public class RehabilitationManageService {
     */
    public ObjEnvelop findRehabilitationPlanDetailList(String currentDoctorCode,String patientCode) throws Exception{
        String sql = " select DISTINCT r.* from wlyy_specialist.wlyy_specialist_patient_relation r join wlyy_patient_rehabilitation_plan p on r.patient=p.patient where r.sign_status ='1' and r.status in('0','1') and r.patient='"+patientCode+"' ";
        sql = TransforSqlUtl.specialistPatientRelationAll(sql);
        List<Map<String,Object>> specialistPatientRelationList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> temp: specialistPatientRelationList){
@ -226,6 +216,7 @@ public class RehabilitationManageService {
            resultMap.put("healthyConditionType",healthyConditionType);
            //专科医生
            String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName from wlyy_specialist.wlyy_specialist_patient_relation r left join "+basedb+".wlyy_admin_team t on r.team_code=t.id left join "+basedb+".dm_hospital h on t.org_code=h.code where r.sign_status ='1' and r.status in('0','1') and r.patient='"+patientCode+"' and r.doctor='"+doctorCode+"'";
            specialistRelationSql = TransforSqlUtl.specialistPatientRelationAll(specialistRelationSql);
            List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
            Map<String,Object> specialistMap = specialistRelationList.get(0);
            resultMap.put("specialistAdminTeamName",specialistMap.get("teamName"));
@ -242,7 +233,7 @@ public class RehabilitationManageService {
            resultMap.put("specialistFinishItemCount",specialistFinishCount1-specialistUnfinishCount1+specialistFinishCount2-specialistUnfinishCount2);//完成项目
            resultMap.put("specialistServiceRecordCount",specialistServiceCount1+specialistServiceCount2);//服务次数
            //家庭医生(包括全科医生、健管师)
            String signFamilySql = "SELECT f.*,t.name as teamName" + AesEncryptUtils.decryptMysql("f.name","patientName") + " FROM "+basedb+".wlyy_sign_family f LEFT JOIN "+basedb+".wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='"+patientCode+"'";
            String signFamilySql = "SELECT f.*,t.name as teamName FROM "+basedb+".wlyy_sign_family f LEFT JOIN "+basedb+".wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='"+patientCode+"'";
            List<Map<String,Object>> signFamilyList = jdbcTemplate.queryForList(signFamilySql);
            if(signFamilyList != null && signFamilyList.size() >0 ) {
                Map<String, Object> signFamilyMap = signFamilyList.get(0);
@ -371,6 +362,7 @@ public class RehabilitationManageService {
            sql+= " and d.status="+status;
        }
        sql += " ORDER BY d.execute_time ";
        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
        List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
//        List<RehabilitationDetailDO> rehabilitationDetailList = rehabilitationDetailDao.findByPlanId(DateUtil.strToDate(executeStartTime),DateUtil.strToDate(executeEndTime),planId);
        Map<String,Map<String,Object>> map = new LinkedHashMap<>();
@ -515,113 +507,11 @@ public class RehabilitationManageService {
            sql+= "and d.status="+status;
        }
        sql +="  order by d.execute_time desc ";
        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(sql);
        List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationDetailList);
    }
    /**
     * 多个康复计划服务项目内容列表
     * @param planDetailIds
     * @return
     * @throws Exception
     */
  /*  public ObjEnvelop serviceItemList(String planDetailIds,String doctorCode) throws Exception{
        String[] s = planDetailIds.split(",");
        String planDetailList = "";
        for(String one:s){
            planDetailList +=",'"+one+"'";
        }
        String planDetailResult = StringUtils.isNotEmpty(planDetailList)?planDetailList.substring(1):"";
        String sql = "select i.title,i.content,i.type as itemType,i.reserve,d.id,d.execute_time,d.hospital_name,d.status,d.type as detailType,d.expense,d.doctor as executeDoctor," +
                " d.doctor_name as executeDoctorName,p.patient ,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus  " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_specialist.wlyy_service_item i on i.id = h.service_item_id " +
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
                " where d.id in ("+planDetailResult+") order BY d.execute_time ASC ";
        List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
//        if(serviceItemList.size()>0){
//            Map<String,Object> serviceItem = serviceItemList.get(0);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> one:serviceItemList){
            Map<String,Object> resultMap = new HashMap<>();
            Integer isMyTask = 0;
            if(StringUtils.isNotEmpty(doctorCode)&&doctorCode.equals(one.get("executeDoctor")+"")){
                isMyTask=1;
            }
            resultMap.put("isMyTask",isMyTask);//0不是自己的任务,1是自己的任务
//            if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
//                executeDoctorList.add(one.get("create_user_name")+"");
//            }
            List<String> executeDoctorList = new ArrayList<>();
            executeDoctorList.add(one.get("executeDoctorName")+"");
            resultMap.put("executeDoctorList",executeDoctorList);//执行医生名称列表
            resultMap.put("executeDoctorCode",one.get("executeDoctor")+"");//执行医生code
            resultMap.put("executeDoctorName",one.get("executeDoctorName")+"");//执行医生code
            resultMap.put("specialistDoctorCode",one.get("createDoctor")+"");//创建人(专科)医生code
            resultMap.put("specialistDoctorName",one.get("createDoctorName")+"");//创建人(专科)医生名字
            resultMap.put("title",one.get("title"));//项目标题
            resultMap.put("planDetaiId",one.get("id"));//计划服务项目id
            resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
            resultMap.put("content",one.get("content"));//项目内容
            resultMap.put("hospitalName",one.get("hospital_name"));//地点
            resultMap.put("executeTime",one.get("execute_time"));//执行时间
            DecimalFormat df = new DecimalFormat("0.00");
            resultMap.put("expense",df.format(((Integer)one.get("expense")*1.00)/100.00));//收费
            resultMap.put("reserve",one.get("reserve"));//是否需要预约(1预约、0不预约)
            resultMap.put("planStatus",one.get("planStatus"));//计划的状态
            Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
            String statusName = "";
            switch (status){
                case 0:{statusName="未完成";break;}
                case 1:{statusName="已完成";break;}
                case 2:{statusName="已预约";break;}
            }
            resultMap.put("statusName",statusName);//状态
            //指导与汇报
            List<GuidanceMessageLogDO> messageList = guidanceMessageLogDao.findByPlanDetailId(one.get("id").toString());
            List<Map<String,Object>> messageMapList = new ArrayList<>();
            for(GuidanceMessageLogDO one2:messageList){
                Map<String,Object> map = new HashMap<>();
                map.put("doctorName",one2.getDoctorName());
                map.put("adminTeamName",one2.getAdminTeamName());
                map.put("content",one2.getContent());
                map.put("contentType",one2.getContentType());
                map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
                messageMapList.add(map);
            }
            Integer itemType = (Integer) one.get("itemType");
            resultMap.put("messageList",messageMapList);//指导与汇报记录
            resultMap.put("patient",one.get("patient"));
            resultMap.put("itemType",itemType);
            resultMap.put("detaiType",one.get("detaiType"));
            resultMap.put("status",status);//状态
            //是否完成任务
            List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
            Integer operate = 0;
            if(operateList.size()>0){
                operate =1;
                RehabilitationOperateRecordsDO temp = operateList.get(0);
                operate =1;
                Date completeTime = temp.getCompleteTime();
                String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
                resultMap.put("completeTime",completeTimeStr);//完成时间
                resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
                resultMap.put("node",temp.getNode());
                resultMap.put("relationRecordImg",(temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg()))?(new JSONArray(temp.getRelationRecordImg())):null);//json格式
                if(itemType!=1&&itemType!=0){
                    resultMap.put("relationRecordCode",temp.getRelationRecordCode());
                    resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
                }
            }
            resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
            resultList.add(resultMap);
         }
            return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
//        }
//        return MixEnvelop.getError("没有该服务项详情信息!");
    }*/
    /**
     * 多个康复计划服务项目内容列表
     * @param planDetailIds
@ -641,6 +531,8 @@ public class RehabilitationManageService {
                " LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
                " where d.id in ("+planDetailResult+") order BY d.execute_time ASC ";
        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName(sql);
        List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
//        if(serviceItemList.size()>0){
//            Map<String,Object> serviceItem = serviceItemList.get(0);
@ -740,6 +632,10 @@ public class RehabilitationManageService {
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
                " LEFT JOIN wlyy_specialist.wlyy_plan_detail_appointment a on d.id=.a.rehabilitation_plan_detail_id " +
                " where d.id = '"+planDetailId+"'";
        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
        sql = TransforSqlUtl.wlyy_plan_detail_appointmentAll(sql);
        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName(sql);
        List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
        if (serviceItemList.size()==0){
            return ObjEnvelop.getSuccess(SpecialistMapping.api_success,new HashMap<>());
@ -907,8 +803,8 @@ public class RehabilitationManageService {
            serviceDoctorList.add(generalDoctorMap);
        }
//        String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status >=0  ";
        String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 and  p.patient='"+patientCode+"'";
        specialistRelationSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName2(specialistRelationSql);
        List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
        for(Map<String,Object> one:specialistRelationList){
            String doctor = one.get("doctor")+"";
@ -964,11 +860,7 @@ public class RehabilitationManageService {
            //已完成
            Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.getId());
            map.put("allFinishCount",allFinishCount);//已完成
//            //未完成
//            Integer notstartedCount = rehabilitationDetailDao.completenessCount(1,one.getId());//未开始
//            Integer underwayCount = rehabilitationDetailDao.completenessCount(1,one.getId());//进行中
//            Integer unfinishedCount = notstartedCount+underwayCount;
//            map.put("unfinishedCount",unfinishedCount);//未完成
            //完成度(已完成/(已完成+未完成))
            Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.getId());
            map.put("allCount",allCount);//总数
@ -989,51 +881,6 @@ public class RehabilitationManageService {
        //康复计划-已完成、进行中
        resultMap.put("planUnderway",planUnderway);//进行中
        resultMap.put("planFinish",planFinish);//已完成
//        //近期康复相关记录
////        String currentTime = DateUtil.getStringDate();
//        String planDetailSql = " select d.*,i.content,i.title from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_hospital_service_item h on d.hospital_service_item_id=h.id" +
//                " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"' and d.executeTime<='"+currentTime+"' order by executeTime desc";
//        List<Map<String,Object>> planDetails = jdbcTemplate.queryForList(planDetailSql);
//        List<Map<String,Object>> planDetailList = new ArrayList<>();
//        for(Map<String,Object> one:planDetails){
//            Date executeTimeDate = (Date)one.get("execute_time");
//            String executeTime = DateUtil.dateToStr(executeTimeDate,"yyyy/MM/dd HH:mm");
//            String content = one.get("content").toString();
//            String title = one.get("title").toString();
//            Integer status = (Integer)one.get("status");
//            String statusName = "";
//            switch (status){
//                case 0:{statusName="未完成";break;}
//                case 1:{statusName="已完成";break;}
//                case 2:{statusName="已预约";break;}
//            }
//            String id = one.get("id").toString();
//            Map<String,Object> map = new HashMap<>();
//            map.put("id",id);//id
//            map.put("executeTime",executeTime);//执行时间
//            map.put("title",title);//项目标题
//            map.put("content",content);//项目内容
//            map.put("statusName",statusName);//状态名称
//            planDetailList.add(map);
//        }
//        resultMap.put("planDetailList",planDetailList);//康复相关记录列表
//        String planDetailCountSql = " select d.status as num from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_hospital_service_item h on d.hospital_service_item_id=h.id" +
//                " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"'";
//        List<Map<String,Object>> planDetailList2 = jdbcTemplate.queryForList(planDetailCountSql);
//        Integer planDetailFinish = 0;
//        Integer planDetailUnfinish = 0;
//        for(Map<String,Object> one:planDetailList2){
//
//            Integer status = (Integer)one.get("status");
//            if(status==1){
//                planDetailFinish+=1;
//            }else{
//                planDetailUnfinish+=1;
//            }
//        }
//        resultMap.put("planDetailFinish",planDetailFinish);//已完成
//        resultMap.put("planDetailUnfinish",planDetailUnfinish);//未完成
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
    }
@ -1058,12 +905,8 @@ public class RehabilitationManageService {
            planDetailSql += "  and d.execute_time<='"+endTime+"' ";
        }
        //        List<Map<String,Object>> planDetailsCount = jdbcTemplate.queryForList(planDetailSql);
//        int count = 0;
//        if(planDetailsCount!=null&&planDetailsCount.size()>0){
//            count = planDetailsCount.size();
//        }
        planDetailSql += " ORDER BY s.complete_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
        planDetailSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(planDetailSql);
        List<Map<String,Object>> planDetails = jdbcTemplate.queryForList(planDetailSql);
        List<Map<String,Object>> planDetailList = new ArrayList<>();
        for(Map<String,Object> one:planDetails){
@ -1210,8 +1053,8 @@ public class RehabilitationManageService {
            serviceDoctorList.add(healthDoctorMap);
        }
//        String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status='1'";
        String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 AND d.doctor IS  NOT  NULL and  d.doctor <> ''  and  p.patient='"+patientCode+"'";
        specialistRelationSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName2(specialistRelationSql);
        List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
        for(Map<String,Object> one:specialistRelationList){
            String doctor = one.get("doctor")+"";
@ -1360,6 +1203,7 @@ public class RehabilitationManageService {
            }
            //如果整个计划的服务项都完成了,整个计划也完成了
            String allSql ="SELECT * FROM wlyy_rehabilitation_plan_detail where plan_id = (SELECT plan_id FROM `wlyy_rehabilitation_plan_detail` WHERE id='"+planDeatilId+"')";
            allSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(allSql);
            List<RehabilitationDetailDO> rehabilitationDetailDOList = jdbcTemplate.query(allSql,new BeanPropertyRowMapper<>(RehabilitationDetailDO.class));
            int allCount=0;
            String planId="";
@ -1566,6 +1410,7 @@ public class RehabilitationManageService {
        }
        buffer.deleteCharAt(buffer.length()-1);
        String sql = "select * from wlyy_rehabilitation_plan_detail where id in("+buffer+")";
        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(sql);
        List<RehabilitationDetailDO> rehabilitationDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(RehabilitationDetailDO.class));
        envelop.setObj(rehabilitationDetailDOS);
        return envelop;
@ -1575,7 +1420,7 @@ public class RehabilitationManageService {
        Map<String,Object> reslutMap = new HashMap<>();
        String sql ="SELECT" +
                " p.patient," +
                " p.`name`," +
                " p.name," +
                " p.title," +
                " p.disease_name,p.abort_reason,p.abort_time,p.create_time,p.patient_img," +
                " a.*" +
@ -1603,6 +1448,8 @@ public class RehabilitationManageService {
                " ) a ON p.id = a.plan_id" +
                " WHERE" +
                " p.id = '"+planId+"'";
        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
        sql = TransforSqlUtl.wlyy_rehabilitation_operate_recordsDoctorName(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
        Integer finishCount = list.size();//完成服务项目数

+ 3 - 45
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

@ -8,7 +8,7 @@ import com.yihu.jw.entity.rehabilitation.RehabilitationPlanningDO;
import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.RehabilitationServiceItemDO;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.restmodel.specialist.PatientSignInfoVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -326,49 +326,6 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
    }
    public MixEnvelop<String,String> createServiceQrCode(String planDetailId,String doctorCode,String imageUrl){
        /*RehabilitationDetailDO rehabilitationDetailDO = rehabilitationDetailDao.findById(planDetailId);
        String fileUrl = "";
        if (rehabilitationDetailDO!=null) {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(rehabilitationDetailDO.getServiceQrCode())) {
                fileUrl = rehabilitationDetailDO.getServiceQrCode();
            } else {
                //String contentJsonStr="{\"planDetailId\":\""+planDetailId+"\",\"sessionId\":\""+sessionId+"\"}";
                String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wechat_base_url+"/wx/html/kfgl/html/confirm-service.html"+"?paramStr="+planDetailId+","+doctorCode+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
                InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
                if (isneiwang) {
                    // 圖片列表
                    List<String> tempPaths = new ArrayList<String>();
                    try {
                        ObjectNode imgNode = fastDFSHelper.upload(ipt, "png", "plan_service_qrcode" + System.currentTimeMillis());
                        com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
                        tempPaths.add(json.getString("fileId"));
                        String urls = "";
                        for (String image : tempPaths) {
                            if (urls.length() == 0) {
                                urls = image;
                            } else {
                                urls += "," + image;
                            }
                        }
                        fileUrl = fastdfs_file_url + urls;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    try {
                        UploadVO uploadVO = fileUploadService.request(request, ipt, "png");
                        if (uploadVO!=null){
                            fileUrl = uploadVO.getFullUrl();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                //更新到康复计划居民关系表中
                String sql = "update wlyy_rehabilitation_plan_detail set service_qr_code='" + fileUrl + "' where id='" + planDetailId + "'";
                jdbcTemplate.update(sql);
            }
        }*/
        //更新到康复计划居民关系表中
        String sql = "update wlyy_rehabilitation_plan_detail set service_qr_code='" + imageUrl + "' where id='" + planDetailId + "'";
        jdbcTemplate.update(sql);
@ -379,7 +336,8 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
        Map<String,Object> map = new HashedMap();
        int result = 0;
        String name= "";
        String sql ="SELECT rp.patient" + AesEncryptUtils.decryptMysql("rp.name","name") + " FROM `wlyy_rehabilitation_plan_detail` pd LEFT JOIN wlyy_patient_rehabilitation_plan rp ON pd.plan_id = rp.id WHERE pd.id='"+planDetailId+"'";
        String sql ="SELECT p.patient,p.name FROM `wlyy_rehabilitation_plan_detail` pd LEFT JOIN wlyy_patient_rehabilitation_plan p ON pd.plan_id = p.id WHERE pd.id='"+planDetailId+"'";
        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if (list!=null && list.size()>0){
            if (String.valueOf(list.get(0).get("patient")).equals(patietCode)){