liubing 4 سال پیش
والد
کامیت
2f22f95aba

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

@ -1,5 +1,7 @@
package com.yihu.jw.entity.util;
import java.util.List;
/***
 * @ClassName: TransforSqlUtl
 * @Description:
@ -8,6 +10,36 @@ package com.yihu.jw.entity.util;
 */
public class TransforSqlUtl {
    public static String sqlColumnReplay(String sql, List<String> encryptColumnList, List<String> decryptColumnList){
        if (encryptColumnList!=null){
            for (String tmp:encryptColumnList){
                sql = sql.replaceAll(tmp,"to_base64(AES_ENCRYPT("+tmp+",'jkzl2021ZJXL*#%a'))");
            }
        }
        if (decryptColumnList !=null){
            for (String tmp:decryptColumnList){
                sql = sql.replaceAll(tmp,"AES_DECRYPT(from_base64("+tmp+"),'jkzl2021ZJXL*#%a')");
            }
        }
        return sql;
    }
    public static String specialistPatientRelation(String sql,String replaceString) {
        String sqlTmp = " id,saas_id,discharge_record,doctor,AES_DECRYPT(from_base64(doctor_name),'jkzl2021ZJXL*#%a') doctor_name,patient,\n" +
                "AES_DECRYPT(from_base64(patient_name),'jkzl2021ZJXL*#%a') patient_name,\n" +
                "health_assistant,AES_DECRYPT(from_base64(health_assistant_name),'jkzl2021ZJXL*#%a') health_assistant_name,team_code,disease,disease_name,\n" +
                "sign_status,`status`,remark,pk_code,sign_code,sign_doctor,\n" +
                "AES_DECRYPT(from_base64(sign_doctor_name),'jkzl2021ZJXL*#%a') sign_doctor_name,\n" +
                "health_doctor,AES_DECRYPT(from_base64(health_doctor_name),'jkzl2021ZJXL*#%a') health_doctor_name,\n" +
                "sign_year,sign_date,create_time,create_user,AES_DECRYPT(from_base64(create_user_name),'jkzl2021ZJXL*#%a') create_user_name,\n" +
                "update_time,update_user,AES_DECRYPT(from_base64(update_user_name),'jkzl2021ZJXL*#%a') update_user_name,\n" +
                "health_status_code,disease_code,sign_certificate,is_manage,manage_user,\n" +
                "manage_time,remind_time ";
        sql = sql.replace(replaceString, 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)");
    }

+ 39 - 27
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanLog
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 +74,26 @@ 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;
        List<String> tmpDeList = new ArrayList<>();
        tmpDeList.add("r.doctor_name");
        tmpDeList.add("r.patient_name");
        tmpDeList.add("r.health_doctor_name");
        tmpDeList.add("r.sign_doctor_name");
        sql = TransforSqlUtl.sqlColumnReplay(sql,new ArrayList<>(),tmpDeList);
        List<SpecialistPatientRelationVO> specialistPatientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationVO.class));
        String sqlcount = "SELECT count(1) AS total " +
@ -134,8 +138,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 +158,9 @@ public class SpecialistService{
                "   i.label_type = '7' AND " +
                "   i.status = 1 " +
                " )";
        List<String> tmpDeList = new ArrayList<>();
        tmpDeList.add("r.patient_name");
        sql = TransforSqlUtl.sqlColumnReplay(sql,new ArrayList<>(),tmpDeList);
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRelationVOs);
@ -174,8 +180,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 +203,9 @@ 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;
        List<String> tmpDeList = new ArrayList<>();
        tmpDeList.add("r.patient_name");
        sql = TransforSqlUtl.sqlColumnReplay(sql,new ArrayList<>(),tmpDeList);
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRelationVOs);
@ -206,8 +214,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 +228,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 +248,10 @@ 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 ";
        List<String> tmpDeList = new ArrayList<>();
        tmpDeList.add("s.patient_name");
        tmpDeList.add("s.health_assistant_name");
        sql = TransforSqlUtl.sqlColumnReplay(sql,new ArrayList<>(),tmpDeList);
        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 +261,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 +269,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 +284,20 @@ public class SpecialistService{
//                    "AND a.doctor='"+doctor+"' OR a.health_assistant= '"+doctor+
                    " AND a.team_code ='" +teamCode+"' "+
                    " LIMIT "+(page-1)*size+","+size;
            tmpDeList = new ArrayList<>();
            tmpDeList.add("a.patient_name");
            tmpDeList.add("a.health_assistant_name");
            sql = TransforSqlUtl.sqlColumnReplay(sql,new ArrayList<>(),tmpDeList);
        }
        
        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 +305,11 @@ 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;
            tmpDeList = new ArrayList<>();
            tmpDeList.add("a.patient_name");
            tmpDeList.add("a.health_assistant_name");
            sql = TransforSqlUtl.sqlColumnReplay(sql,new ArrayList<>(),tmpDeList);
        }
        
        List<PatientLabelVO> PatientLabelVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientLabelVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,PatientLabelVOs);
    }
@ -345,8 +358,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, " +

+ 4 - 1
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;
@ -110,7 +111,7 @@ public class RehabilitationManageService {
        }
        if(StringUtils.isNotEmpty(patientCondition)){
            sql += " and " + AesEncryptUtils.descryptMysqlNo("p.name") + " like '%"+patientCondition+"%' ";
            sql += " and " + AesEncryptUtils.decryptMysqlNo("p.name") + " like '%"+patientCondition+"%' ";
        }
        String finalSql = "";
@ -211,6 +212,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.specialistPatientRelation(sql,"r.*");
        List<Map<String,Object>> specialistPatientRelationList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> temp: specialistPatientRelationList){
@ -226,6 +228,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.specialistPatientRelation(specialistRelationSql,"r.*");
            List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
            Map<String,Object> specialistMap = specialistRelationList.get(0);
            resultMap.put("specialistAdminTeamName",specialistMap.get("teamName"));