Shi Kejing vor 4 Jahren
Ursprung
Commit
42a03c9fbf

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

@ -6,6 +6,9 @@ import org.springframework.util.StringUtils;
import javax.crypto.Cipher;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
/**
 * 前后端数据传输加密工具类
 * 前后端数据传输加密工具类
@ -21,6 +24,43 @@ public class AesEncryptUtils {
    //AES_DECRYPT(from_base64(d.patient_name),'jkzl2021ZJXL*#%a')
    //AES_DECRYPT(from_base64(d.patient_name),'jkzl2021ZJXL*#%a')
    /**
     * 针对 GROUP_CONCAT 函数,逗号分隔符进行解密
     * @param str
     * @return
     */
    public static String DHFGF(String str){
        char searchChar = ',';
        int count = 0;
        char[] charArray = str.toCharArray();
        for (char item : charArray) {
            if (item == searchChar) {
                count++;
            }
        }
        StringBuffer sb = new StringBuffer();
        String[] ss = new String[count];
        if (count == 0){
            sb.append(AesEncryptUtils.decrypt(str)); ;
        }else {
            for (int i=0;i<count;i++){
                ss = str.split(",") ;
            }
            List<String> list = new ArrayList<String>();
            Collections.addAll(list,ss);
            for (int j=0;j<list.size();j++){
                str = AesEncryptUtils.decrypt(list.get(j));
                sb.append(str);
                if (j == (list.size()-1)){
                    break;
                }
                sb.append(",");
            }
        }
        return sb.toString();
    }
    /**
    /**
     * 加密
     * 加密
     * @param content 加密的字符串
     * @param content 加密的字符串

+ 41 - 7
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -1,5 +1,6 @@
package com.yihu.iot.service.device;
package com.yihu.iot.service.device;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.elasticsearch.ElasticSearchHelper;
import com.yihu.elasticsearch.ElasticSearchHelper;
import com.yihu.iot.dao.company.IotCompanyDao;
import com.yihu.iot.dao.company.IotCompanyDao;
@ -509,7 +510,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        list.forEach(one->{
        list.forEach(one->{
            one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
            one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
            one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
            one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
            one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
            one.setPatientName(AesEncryptUtils.DHFGF(one.getPatientName()));
            one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
            one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
            one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
            one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
            one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
            one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
@ -548,10 +549,10 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        }
        }
        //数据权限过滤
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and p.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
//        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
//        if(!orgList.contains(userAgent.commonHospital)){
//            sql += " and p.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
//        }
        sql +=" GROUP BY p.device_sn ORDER BY p.update_time desc ";
        sql +=" GROUP BY p.device_sn ORDER BY p.update_time desc ";
        if (page != null && pageSize != null) {
        if (page != null && pageSize != null) {
@ -561,7 +562,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
            list.forEach(one->{
            list.forEach(one->{
                one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
                one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
                one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
                one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
                one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
                one.setPatientName(AesEncryptUtils.DHFGF(one.getPatientName()));
                one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
                one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
                one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
                one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
                one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
                one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
@ -573,7 +574,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        list.forEach(one->{
        list.forEach(one->{
            one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
            one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
            one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
            one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
            one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
            one.setPatientName(AesEncryptUtils.DHFGF(one.getPatientName()));
            one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
            one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
            one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
            one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
            one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
            one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
@ -582,6 +583,39 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_find, list);
        return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_find, list);
    }
    }
    public static void main(String[] args) {
        String str = "wfL8T2aAmlBnZv2S8QwZXQ==,BFPvVzBHgwa7plBHhkcOQw==,BD4ExdUzPKini5xns11z6Q==,IJOA+Ug/mjvF+L64a/Dq5g==";
        char searchChar = ',';
        int count = 0;
        char[] charArray = str.toCharArray();
        for (char item : charArray) {
            if (item == searchChar) {
                count++;
            }
        }
        StringBuffer sb = new StringBuffer();
        String[] ss = new String[count];
        if (count == 0){
            sb.append(AesEncryptUtils.decrypt(str)); ;
        }else {
            for (int i=0;i<count;i++){
                ss = str.split(",") ;
            }
            List<String>list = new ArrayList<String>();
            Collections.addAll(list,ss);
            for (int j=0;j<list.size();j++){
                str = AesEncryptUtils.decrypt(list.get(j));
                sb.append(str);
                if (j == (list.size()-1)){
                    break;
                }
                sb.append(",");
            }
        }
        System.out.println(sb.toString());
    }
    public void deleteRepairDevice(String deviceSn) {
    public void deleteRepairDevice(String deviceSn) {
        List<IotPatientDeviceDO> patientDeviceDOList = iotPatientDeviceDao.findAllByDeviceSn(deviceSn);
        List<IotPatientDeviceDO> patientDeviceDOList = iotPatientDeviceDao.findAllByDeviceSn(deviceSn);
        for(IotPatientDeviceDO patientDeviceDO : patientDeviceDOList){
        for(IotPatientDeviceDO patientDeviceDO : patientDeviceDOList){