|
@ -10,6 +10,7 @@ import com.yihu.iot.dao.device.IotPatientDeviceDao;
|
|
|
import com.yihu.iot.datainput.util.ConstantUtils;
|
|
|
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
|
|
|
import com.yihu.iot.service.common.OrgUserService;
|
|
|
import com.yihu.iot.service.common.PermissionService;
|
|
|
import com.yihu.iot.service.dict.IotSystemDictService;
|
|
|
import com.yihu.iot.service.useragent.UserAgent;
|
|
|
import com.yihu.iot.util.conceal.ConcealUtil;
|
|
@ -710,60 +711,56 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
|
|
|
String deviceSn, String deviceName, String categoryCode, String patientName,
|
|
|
String hospitalName, Integer isDel, Integer page, Integer pageSize,
|
|
|
String propertyName, String propertyCombination, String propertyUse, String propertyNetwork, String propertyLocation, String deviceStatus) {
|
|
|
String sql = "SELECT DISTINCT\n" +
|
|
|
"(SELECT q.`dict_value` FROM `iot-base`.wlyy_hospital_sys_dict q WHERE q.dict_name='Device_common_name' AND q.`dict_code`=a.`name` )\"propertyName\",\n" +
|
|
|
"(SELECT q.`dict_value` FROM `iot-base`.wlyy_hospital_sys_dict q WHERE q.dict_name='Combination_method' AND q.`dict_code`=a.`combination` )\"propertyCombination\",\n" +
|
|
|
"(SELECT q.`dict_value` FROM `iot-base`.wlyy_hospital_sys_dict q WHERE q.dict_name='device_use' AND q.`dict_code`=a.`device_use` )\"propertyUse\",\n" +
|
|
|
"(SELECT q.`dict_value` FROM `iot-base`.wlyy_hospital_sys_dict q WHERE q.dict_name='Network_transmission' AND q.`dict_code`=a.`network` )\"propertyNetwork\",\n" +
|
|
|
"(SELECT q.`dict_value` FROM `iot-base`.wlyy_hospital_sys_dict q WHERE q.dict_name='Drop_location' AND q.`dict_code`=a.`location` )\"propertyLocation\", " +
|
|
|
" d.*\n" +
|
|
|
"FROM\n" +
|
|
|
" `iot_patient_device` d\n" +
|
|
|
" LEFT JOIN iot_device b ON b.device_sn=d.device_sn\n" +
|
|
|
" LEFT JOIN iot_product_base_info_property a ON a.product_id =b.product_id\n" +
|
|
|
"WHERE\n" +
|
|
|
String countSql = " select count(DISTINCT d.id)";
|
|
|
String sql = "SELECT DISTINCT d.*,a.`name` propertyName,a.combination propertyCombination,a.device_use propertyUse" +
|
|
|
",a.network propertyNetwork,a.location propertyLocation,a.dictionaries propertyDataAcquisitionDict,a.product_id productId";
|
|
|
String filter = " FROM" +
|
|
|
" `iot_patient_device` d" +
|
|
|
" LEFT JOIN iot_device b ON b.device_sn=d.device_sn" +
|
|
|
" LEFT JOIN iot_product_base_info_property a ON a.product_id =b.product_id" +
|
|
|
" WHERE" +
|
|
|
" 1 = 1 ";
|
|
|
if (isDel != null && isDel == 1) {
|
|
|
sql += " and d.del != 1 ";
|
|
|
filter += " and d.del != 1 ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(deviceSn)) {
|
|
|
sql += " and d.device_sn like '%" + deviceSn + "%' ";
|
|
|
filter += " 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 + "%' ";
|
|
|
filter += "and AES_DECRYPT(from_base64(d.patient_name),'jkzl2021ZJXL*#%a') like '%" + patientName + "%' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(deviceName)) {
|
|
|
sql += " and d.device_name like '%" + deviceName + "%' ";
|
|
|
filter += " and d.device_name like '%" + deviceName + "%' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(categoryCode)) {
|
|
|
sql += " and d.category_code = '" + categoryCode + "' ";
|
|
|
filter += " and d.category_code = '" + categoryCode + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(hospitalName)) {
|
|
|
sql += " and d.hospital_name like '%" + hospitalName + "%' ";
|
|
|
filter += " and d.hospital_name like '%" + hospitalName + "%' ";
|
|
|
}
|
|
|
//设备状态
|
|
|
if (StringUtils.isNotBlank(deviceStatus)) {
|
|
|
sql += " and d.status like '%" + deviceStatus + "%' ";
|
|
|
filter += " and d.status like '%" + deviceStatus + "%' ";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通用查询 补充字段
|
|
|
*/
|
|
|
if (StringUtils.isNotBlank(propertyName)) {
|
|
|
sql += " and a.name like '%" + propertyName + "%' ";
|
|
|
filter += " and a.name = '" + propertyName + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(propertyCombination)) {
|
|
|
sql += " and a.combination like '%" + propertyCombination + "%' ";
|
|
|
filter += " and a.combination = '" + propertyCombination + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(propertyUse)) {
|
|
|
sql += " and a.`device_use` like '%" + propertyUse + "%' ";
|
|
|
filter += " and a.`device_use` = '" + propertyUse + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(propertyNetwork)) {
|
|
|
sql += " and a.network like '%" + propertyNetwork + "%' ";
|
|
|
filter += " and a.network = '" + propertyNetwork + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(propertyLocation)) {
|
|
|
sql += " and a.location like '%" + propertyLocation + "%' ";
|
|
|
filter += " and a.location = '" + propertyLocation + "' ";
|
|
|
}
|
|
|
|
|
|
//数据权限过滤
|
|
@ -774,37 +771,66 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
sql += "order by d.update_time desc ";
|
|
|
//判断是否需要分页
|
|
|
List<IotPatientDeviceVO> deviceVOList = null;
|
|
|
Long count = null;
|
|
|
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);
|
|
|
count = jdbcTempalte.queryForObject(countSql+filter,Long.class);
|
|
|
sql += filter + "limit " + (page - 1) * pageSize + "," + pageSize;
|
|
|
deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
|
|
|
} 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()));
|
|
|
});
|
|
|
deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
|
|
|
}
|
|
|
|
|
|
Map<String,String> propertyNameMap = getHostpitalDictMap("Device_common_name");
|
|
|
Map<String,String> propertyCombinationMap = getHostpitalDictMap("Combination_method");
|
|
|
Map<String,String> propertyUseMap = getHostpitalDictMap("device_use");
|
|
|
Map<String,String> propertyNetworkMap = getHostpitalDictMap("Network_transmission");
|
|
|
Map<String,String> propertyLocationMap = getHostpitalDictMap("Drop_location");
|
|
|
Map<String,String> propertyDataAcquisitionDictMap = getHostpitalDictMap("Data_acquisition_dict");
|
|
|
|
|
|
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()));
|
|
|
one.setPropertyName(propertyNameMap.get(one.getPropertyName()));
|
|
|
one.setPropertyCombination(propertyCombinationMap.get(one.getPropertyCombination()));
|
|
|
one.setPropertyLocation(propertyLocationMap.get(one.getPropertyLocation()));
|
|
|
one.setPropertyNetwork(propertyNetworkMap.get(one.getPropertyNetwork()));
|
|
|
one.setPropertyUse(propertyUseMap.get(one.getPropertyUse()));
|
|
|
one.setPropertyDataAcquisitionDict(propertyDataAcquisitionDictMap.get(one.getPropertyDataAcquisitionDict()));
|
|
|
});
|
|
|
|
|
|
if(count==null){
|
|
|
return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, deviceVOList);
|
|
|
}else {
|
|
|
return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceVOList, page, pageSize, count);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
private PermissionService permissionService;
|
|
|
|
|
|
public List<Map<String, Object>> getHostpitalDictList(String dictNmae){
|
|
|
String sql = "SELECT dict_code code,dict_value name from "+permissionService.getDbName()+".wlyy_hospital_sys_dict " +
|
|
|
"WHERE dict_name = '"+dictNmae+"' order by sort ";
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
public Map<String,String> getHostpitalDictMap(String dictNmae){
|
|
|
List<Map<String, Object>> list = getHostpitalDictList(dictNmae);
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
for (Map<String, Object> tmp:list){
|
|
|
map.put(tmp.get("code")+"",tmp.get("name")+"");
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
public IotPatientDeviceDO changePatientDevice(String id, String newDeviceSn, String newDeviceId) {
|
|
|
IotPatientDeviceDO patientDeviceDO = iotPatientDeviceDao.findOne(id);
|