|  | @ -21,6 +21,7 @@ import com.yihu.jw.entity.iot.device.IotDeviceOverhaulDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.patient.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.util.AesEncryptUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.rm.iot.IotRequestMapping;
 | 
	
	
		
			
				|  | @ -42,6 +43,7 @@ import org.springframework.jdbc.core.RowCallbackHandler;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.management.ObjectName;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
	
		
			
				|  | @ -265,7 +267,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |             JSONObject location = JSONObject.parseObject(map.get("location").toString());
 | 
	
		
			
				|  |  |             GeoPoint geoPoint = new GeoPoint(Double.parseDouble(location.get("lat").toString()),Double.parseDouble(location.get("lon").toString()));
 | 
	
		
			
				|  |  |             locationDataVO.setId(map.get("id").toString());
 | 
	
		
			
				|  |  |             locationDataVO.setIdCard(map.get("idCard").toString());
 | 
	
		
			
				|  |  |             locationDataVO.setIdCard(AesEncryptUtils.decrypt(map.get("idCard").toString()));
 | 
	
		
			
				|  |  |             locationDataVO.setCategoryCode(map.get("categoryCode").toString());
 | 
	
		
			
				|  |  |             locationDataVO.setDeviceSn(map.get("deviceSn").toString());
 | 
	
		
			
				|  |  |             locationDataVO.setLocation(geoPoint);
 | 
	
	
		
			
				|  | @ -327,7 +329,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |                 List<Map<String,Object>> nameList = new ArrayList<>();
 | 
	
		
			
				|  |  |                 List<Map<String,Object>> deviceList = new ArrayList<>();
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotEmpty(idCard)){
 | 
	
		
			
				|  |  |                     sql = sql +" and t.idcard = '"+idCard+"'";
 | 
	
		
			
				|  |  |                     sql = sql +" and t.idcard = '"+AesEncryptUtils.decrypt(idCard)+"'";
 | 
	
		
			
				|  |  |                     nameList = jdbcTempalte.queryForList(sql);
 | 
	
		
			
				|  |  |                 }if (StringUtils.isNoneBlank(snCoed)){
 | 
	
		
			
				|  |  |                     sqlEqt = sqlEqt +" and t.device_code = '"+snCoed+"'";
 | 
	
	
		
			
				|  | @ -336,8 +338,9 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |                 if(nameList.size()>0){
 | 
	
		
			
				|  |  |                     String code = null==nameList.get(0).get("code")?"":nameList.get(0).get("code").toString();
 | 
	
		
			
				|  |  |                     String name = null==nameList.get(0).get("name")?"": ConcealUtil.nameOrAddrConceal(nameList.get(0).get("name").toString());
 | 
	
		
			
				|  |  |                     locationDataVO.setIdCard(AesEncryptUtils.decrypt(idCard));
 | 
	
		
			
				|  |  |                     locationDataVO.setCode(code);
 | 
	
		
			
				|  |  |                     locationDataVO.setName(name);
 | 
	
		
			
				|  |  |                     locationDataVO.setName(AesEncryptUtils.decrypt(name));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (deviceList.size()>0){
 | 
	
		
			
				|  |  |                     String equipmentName = null==deviceList.get(0).get("device_name")?"":deviceList.get(0).get("device_name").toString();
 | 
	
	
		
			
				|  | @ -467,6 +470,15 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |                 "FROM `iot_patient_device` p, iot_device d LEFT JOIN iot_company c on d.manufacturer_id = c.id and c.status = 1 " +
 | 
	
		
			
				|  |  |                 "where p.device_sn = '" + deviceSn + "' and p.del =  1 and p.device_id= d.id GROUP BY p.device_sn ";
 | 
	
		
			
				|  |  |         List<IotPatientDeviceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
 | 
	
		
			
				|  |  |         list.forEach(one->{
 | 
	
		
			
				|  |  |             one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
 | 
	
		
			
				|  |  |             one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
 | 
	
		
			
				|  |  |             one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
 | 
	
		
			
				|  |  |             one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
 | 
	
		
			
				|  |  |             one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
 | 
	
		
			
				|  |  |             one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
 | 
	
		
			
				|  |  |             one.setUpdateUserName(AesEncryptUtils.decrypt(one.getUpdateUserName()));
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -509,10 +521,29 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |         if (page != null && pageSize != null) {
 | 
	
		
			
				|  |  |             Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
 | 
	
		
			
				|  |  |             sql += "limit " +(page-1)* pageSize + "," +pageSize;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<IotPatientDeviceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
 | 
	
		
			
				|  |  |             list.forEach(one->{
 | 
	
		
			
				|  |  |                 one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
 | 
	
		
			
				|  |  |                 one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
 | 
	
		
			
				|  |  |                 one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
 | 
	
		
			
				|  |  |                 one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
 | 
	
		
			
				|  |  |                 one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
 | 
	
		
			
				|  |  |                 one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
 | 
	
		
			
				|  |  |                 one.setUpdateUserName(AesEncryptUtils.decrypt(one.getUpdateUserName()));
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |             return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Device.message_success_find, list,page, pageSize,count);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<IotPatientDeviceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
 | 
	
		
			
				|  |  |         list.forEach(one->{
 | 
	
		
			
				|  |  |             one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
 | 
	
		
			
				|  |  |             one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
 | 
	
		
			
				|  |  |             one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
 | 
	
		
			
				|  |  |             one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
 | 
	
		
			
				|  |  |             one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
 | 
	
		
			
				|  |  |             one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
 | 
	
		
			
				|  |  |             one.setUpdateUserName(AesEncryptUtils.decrypt(one.getUpdateUserName()));
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_find, list);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -560,6 +591,13 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |             Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
 | 
	
		
			
				|  |  |             sql += "limit " + (page - 1) * pageSize + "," + pageSize;
 | 
	
		
			
				|  |  |             List<IotPatientDeviceVO> deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
 | 
	
		
			
				|  |  |             for (int i=0;i<deviceVOList.size();i++){
 | 
	
		
			
				|  |  |                 deviceVOList.get(i).setPatientName(AesEncryptUtils.decrypt(deviceVOList.get(i).getPatientName()));
 | 
	
		
			
				|  |  |                 deviceVOList.get(i).setIdcard(AesEncryptUtils.decrypt(deviceVOList.get(i).getIdcard()));
 | 
	
		
			
				|  |  |                 deviceVOList.get(i).setMobile(AesEncryptUtils.decrypt(deviceVOList.get(i).getMobile()));
 | 
	
		
			
				|  |  |                 deviceVOList.get(i).setCreateUserName(AesEncryptUtils.decrypt(deviceVOList.get(i).getCreateUserName()));
 | 
	
		
			
				|  |  |                 deviceVOList.get(i).setUpdateUserName(AesEncryptUtils.decrypt(deviceVOList.get(i).getUpdateUserName()));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceVOList, page, pageSize, count);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             List<IotPatientDeviceVO> deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
 | 
	
	
		
			
				|  | @ -577,7 +615,8 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |             sql += "and d.device_sn like '%" + deviceSn + "%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(patientName)){
 | 
	
		
			
				|  |  |             sql += "and d.patient_name like '%" + patientName + "%' ";
 | 
	
		
			
				|  |  |             sql += "and AES_DECRYPT(from_base64(d.patient_name),'jkzl2021ZJXL*#%a') like '%" + patientName + "%' ";
 | 
	
		
			
				|  |  |             //AES_DECRYPT(from_base64(t.name),'jkzl2021ZJXL*#%a')
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(deviceName)){
 | 
	
		
			
				|  |  |             sql += "and d.device_name like '%" + deviceName + "%' ";
 | 
	
	
		
			
				|  | @ -589,19 +628,37 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
 | 
	
		
			
				|  |  |             sql += "and d.hospital_name like '%" + hospitalName + "%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据权限过滤
 | 
	
		
			
				|  |  |         List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
 | 
	
		
			
				|  |  |         if(!orgList.contains(userAgent.commonHospital)){
 | 
	
		
			
				|  |  |             sql += " and d.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | //        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
 | 
	
		
			
				|  |  | //        if(!orgList.contains(userAgent.commonHospital)){
 | 
	
		
			
				|  |  | //            sql += " and d.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |         sql += "order by d.update_time desc ";
 | 
	
		
			
				|  |  |         //判断是否需要分页
 | 
	
		
			
				|  |  |         if (page != null && pageSize != null) {
 | 
	
		
			
				|  |  |             Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
 | 
	
		
			
				|  |  |             sql += "limit " + (page - 1) * pageSize + "," + pageSize;
 | 
	
		
			
				|  |  |             List<IotPatientDeviceVO> deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
 | 
	
		
			
				|  |  |             deviceVOList.forEach(one->{
 | 
	
		
			
				|  |  |                 one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
 | 
	
		
			
				|  |  |                 one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
 | 
	
		
			
				|  |  |                 one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
 | 
	
		
			
				|  |  |                 one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
 | 
	
		
			
				|  |  |                 one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
 | 
	
		
			
				|  |  |                 one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
 | 
	
		
			
				|  |  |                 one.setUpdateUserName(AesEncryptUtils.decrypt(one.getUpdateUserName()));
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |             return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceVOList, page, pageSize, count);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             List<IotPatientDeviceVO> deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
 | 
	
		
			
				|  |  |             deviceVOList.forEach(one->{
 | 
	
		
			
				|  |  |                 one.setIdcard(AesEncryptUtils.decrypt(one.getIdcard()));
 | 
	
		
			
				|  |  |                 one.setMobile(AesEncryptUtils.decrypt(one.getMobile()));
 | 
	
		
			
				|  |  |                 one.setPatientName(AesEncryptUtils.decrypt(one.getPatientName()));
 | 
	
		
			
				|  |  |                 one.setContactsName(AesEncryptUtils.decrypt(one.getContactsName()));
 | 
	
		
			
				|  |  |                 one.setContactsMobile(AesEncryptUtils.decrypt(one.getContactsMobile()));
 | 
	
		
			
				|  |  |                 one.setCreateUserName(AesEncryptUtils.decrypt(one.getCreateUserName()));
 | 
	
		
			
				|  |  |                 one.setUpdateUserName(AesEncryptUtils.decrypt(one.getUpdateUserName()));
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |             return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, deviceVOList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 |