ソースを参照

物联网修改

LAPTOP-KB9HII50\70708 1 年間 前
コミット
33ca4d6950

+ 10 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java

@ -4,13 +4,16 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.dao.device.IotDeviceImportRecordDao;
import com.yihu.iot.dao.device.IotDeviceImportRecordDao;
import com.yihu.iot.dao.product.IotProductBaseInfoPropertyDao;
import com.yihu.iot.service.device.IotDeviceService;
import com.yihu.iot.service.device.IotDeviceService;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceImportRecordDO;
import com.yihu.jw.entity.iot.device.IotDeviceImportRecordDO;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoPropertyDO;
import com.yihu.jw.restmodel.iot.common.ExistVO;
import com.yihu.jw.restmodel.iot.common.ExistVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceImportRecordVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceImportRecordVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceImportVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceImportVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.iot.product.IotProductBaseInfoPropertyVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -37,7 +40,8 @@ public class IotDeviceController extends EnvelopRestEndpoint {
    private Logger logger = LoggerFactory.getLogger(IotDeviceController.class);
    private Logger logger = LoggerFactory.getLogger(IotDeviceController.class);
    @Autowired
    @Autowired
    private IotDeviceService iotDeviceService;
    private IotDeviceService iotDeviceService;
    @Autowired
    private IotProductBaseInfoPropertyDao productBaseInfoPropertyDao;
    @Autowired
    @Autowired
@ -292,6 +296,11 @@ public class IotDeviceController extends EnvelopRestEndpoint {
                }
                }
            }
            }
            IotDeviceVO iotDeviceVO = convertToModel(iotDeviceDO,IotDeviceVO.class);
            IotDeviceVO iotDeviceVO = convertToModel(iotDeviceDO,IotDeviceVO.class);
            if(iotDeviceDO!=null&&org.apache.commons.lang3.StringUtils.isNotBlank(iotDeviceDO.getProductId())){
                IotProductBaseInfoPropertyDO propertyDO = productBaseInfoPropertyDao.findProductPropertyByProductId(iotDeviceDO.getProductId());
                IotProductBaseInfoPropertyVO propertyVO = convertToModel(propertyDO,IotProductBaseInfoPropertyVO.class);
                iotDeviceVO.setProductBaseInfoPropertyVO(propertyVO);
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_find, iotDeviceVO);
            return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_find, iotDeviceVO);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();

+ 3 - 10
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/WlyyDeviceController.java

@ -1,28 +1,21 @@
package com.yihu.iot.controller.device;
package com.yihu.iot.controller.device;
import com.yihu.iot.controller.common.BaseController;
import com.yihu.iot.controller.common.BaseController;
import com.yihu.iot.dao.message.IotMessageDao;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.device.WlyyDeviceService;
import com.yihu.iot.service.device.WlyyDeviceService;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
import com.yihu.jw.entity.patient.Message;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.entity.patient.PatientDevice;
import com.yihu.jw.entity.patient.PatientDevice;
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
import com.yihu.jw.restmodel.iot.device.WlyyDeviceVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.List;
import java.util.UUID;
/**
/**
 * Created by yeshijie on 2020/7/29.
 * Created by yeshijie on 2020/7/29.
@ -37,7 +30,7 @@ public class WlyyDeviceController extends BaseController {
    @RequestMapping(value="deviceList",method = RequestMethod.GET)
    @RequestMapping(value="deviceList",method = RequestMethod.GET)
    @ApiOperation("设备管理")
    @ApiOperation("设备管理")
    public MixEnvelop<WlyyDeviceVO, WlyyDeviceVO> searchList(
    public Envelop searchList(
            @RequestParam(value = "deviceName",required = false)String deviceName,
            @RequestParam(value = "deviceName",required = false)String deviceName,
            @RequestParam(value = "deviceCode",required = false) String deviceCode,
            @RequestParam(value = "deviceCode",required = false) String deviceCode,
            @RequestParam(value = "orgName",required = false)String orgName,
            @RequestParam(value = "orgName",required = false)String orgName,
@ -71,7 +64,7 @@ public class WlyyDeviceController extends BaseController {
    @RequestMapping(value = "findDeviceById",method = RequestMethod.GET)
    @RequestMapping(value = "findDeviceById",method = RequestMethod.GET)
    @ApiOperation("根据设备id查找设备管理")
    @ApiOperation("根据设备id查找设备管理")
    public MixEnvelop<WlyyDeviceVO,WlyyDeviceVO> getDevice(@RequestParam(value = "id") Long id){
    public Envelop getDevice(@RequestParam(value = "id") String id){
        try {
        try {
            return  wlyyDeviceService.findById(id);
            return  wlyyDeviceService.findById(id);
        }catch (Exception e){
        }catch (Exception e){

+ 74 - 48
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -10,6 +10,7 @@ import com.yihu.iot.dao.device.IotPatientDeviceDao;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.iot.service.common.OrgUserService;
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.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.util.conceal.ConcealUtil;
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 deviceSn, String deviceName, String categoryCode, String patientName,
            String hospitalName, Integer isDel, Integer page, Integer pageSize,
            String hospitalName, Integer isDel, Integer page, Integer pageSize,
            String propertyName, String propertyCombination, String propertyUse, String propertyNetwork, String propertyLocation, String deviceStatus) {
            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 ";
                "	1 = 1 ";
        if (isDel != null && isDel == 1) {
        if (isDel != null && isDel == 1) {
            sql += " and d.del != 1 ";
            filter += " and d.del != 1 ";
        }
        }
        if (StringUtils.isNotBlank(deviceSn)) {
        if (StringUtils.isNotBlank(deviceSn)) {
            sql += " and d.device_sn like '%" + deviceSn + "%' ";
            filter += " and d.device_sn like '%" + deviceSn + "%' ";
        }
        }
        if (StringUtils.isNotBlank(patientName)) {
        if (StringUtils.isNotBlank(patientName)) {
//            sql += "and d.patient_name like '%" + 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)) {
        if (StringUtils.isNotBlank(deviceName)) {
            sql += " and d.device_name like '%" + deviceName + "%' ";
            filter += " and d.device_name like '%" + deviceName + "%' ";
        }
        }
        if (StringUtils.isNotBlank(categoryCode)) {
        if (StringUtils.isNotBlank(categoryCode)) {
            sql += " and d.category_code = '" + categoryCode + "' ";
            filter += " and d.category_code = '" + categoryCode + "' ";
        }
        }
        if (StringUtils.isNotBlank(hospitalName)) {
        if (StringUtils.isNotBlank(hospitalName)) {
            sql += " and d.hospital_name like '%" + hospitalName + "%' ";
            filter += " and d.hospital_name like '%" + hospitalName + "%' ";
        }
        }
        //设备状态
        //设备状态
        if (StringUtils.isNotBlank(deviceStatus)) {
        if (StringUtils.isNotBlank(deviceStatus)) {
            sql += " and d.status like '%" + deviceStatus + "%' ";
            filter += " and d.status like '%" + deviceStatus + "%' ";
        }
        }
        /**
        /**
         * 通用查询 补充字段
         * 通用查询 补充字段
         */
         */
        if (StringUtils.isNotBlank(propertyName)) {
        if (StringUtils.isNotBlank(propertyName)) {
            sql += " and a.name like '%" + propertyName + "%' ";
            filter += " and a.name = '" + propertyName + "' ";
        }
        }
        if (StringUtils.isNotBlank(propertyCombination)) {
        if (StringUtils.isNotBlank(propertyCombination)) {
            sql += " and a.combination like '%" + propertyCombination + "%' ";
            filter += " and a.combination = '" + propertyCombination + "' ";
        }
        }
        if (StringUtils.isNotBlank(propertyUse)) {
        if (StringUtils.isNotBlank(propertyUse)) {
            sql += " and a.`device_use` like '%" + propertyUse + "%' ";
            filter += " and a.`device_use` = '" + propertyUse + "' ";
        }
        }
        if (StringUtils.isNotBlank(propertyNetwork)) {
        if (StringUtils.isNotBlank(propertyNetwork)) {
            sql += " and a.network like '%" + propertyNetwork + "%' ";
            filter += " and a.network = '" + propertyNetwork + "' ";
        }
        }
        if (StringUtils.isNotBlank(propertyLocation)) {
        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) {
        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 {
        } 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);
            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
    @Transactional
    public IotPatientDeviceDO changePatientDevice(String id, String newDeviceSn, String newDeviceId) {
    public IotPatientDeviceDO changePatientDevice(String id, String newDeviceSn, String newDeviceId) {
        IotPatientDeviceDO patientDeviceDO = iotPatientDeviceDao.findOne(id);
        IotPatientDeviceDO patientDeviceDO = iotPatientDeviceDao.findOne(id);

+ 70 - 37
svr/svr-iot/src/main/java/com/yihu/iot/service/device/WlyyDeviceService.java

@ -5,10 +5,8 @@ import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
import com.yihu.jw.restmodel.iot.device.WlyyDeviceVO;
import com.yihu.jw.restmodel.iot.device.WlyyHealthStandardVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.iot.device.*;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
@ -56,37 +54,43 @@ public class WlyyDeviceService {
    private UserAgent userAgent;
    private UserAgent userAgent;
    @Autowired
    @Autowired
    private OrgUserService orgUserService;
    private OrgUserService orgUserService;
    @Autowired
    private IotPatientDeviceService patientDeviceService;
    public MixEnvelop<WlyyDeviceVO,WlyyDeviceVO> searchDeviceList(
    public MixEnvelop<IotDeviceVO,IotDeviceVO> searchDeviceList(
            String deviceName,String deviceCode,String orgName,String linkman,Integer page,Integer pageSize,
            String deviceName,String deviceCode,String orgName,String linkman,Integer page,Integer pageSize,
            String propertyName, String propertyCombination, String propertyUse, String propertyNetwork, String propertyLocation)
            String propertyName, String propertyCombination, String propertyUse, String propertyNetwork, String propertyLocation)
    {
    {
        //补充查询
        //补充查询
        String sql = "SELECT\n" +
        String sql = "SELECT\n" +
                "	a.* ,\n" +
                " distinct	a.* ,\n" +
                "	c.`name` propertyName,\n" +
                "	c.`name` propertyName,\n" +
                "	c.`combination` propertyCombination,\n" +
                "	c.`combination` propertyCombination,\n" +
                "	c.`device_use` propertyUse,\n" +
                "	c.`device_use` propertyUse,\n" +
                "	c.`network` propertyNetwork,\n" +
                "	c.`network` propertyNetwork,\n" +
                "	c.`location` propertyLocation \n" +
                "	c.`location` propertyLocation, \n" +
                "	c.`dictionaries` propertyDataAcquisitionDict, \n" +
                "	d.`sim` sim, \n" +
                "	d.`iot_imsi` iotImsi, \n" +
                "	d.`iot_iccid` iotIccid \n" +
                "FROM\n" +
                "FROM\n" +
                "	device.wlyy_devices a\n" +
                "	INNER JOIN xmiot.iot_device b ON a.device_code = b.device_sn\n" +
                "	INNER JOIN xmiot.iot_product_base_info_property c ON c.id = b.product_id \n" +
                "	iot_device a \n" +
                "	left JOIN iot_product_base_info_property c ON c.product_id = a.product_id \n" +
                "	left JOIN iot_patient_device d ON a.device_sn=d.device_sn \n" +
                "WHERE\n" +
                "WHERE\n" +
                "	1 = 1";
                "	1 = 1";
        if(!StringUtils.isEmpty(orgName)){
        if(!StringUtils.isEmpty(orgName)){
            sql +=" and a.org_name like '%"+orgName+"%' ";
            sql +=" and a.hospital_name like '%"+orgName+"%' ";
        }
        }
        if(!StringUtils.isEmpty(deviceCode)){
        if(!StringUtils.isEmpty(deviceCode)){
            sql +=" and a.device_code = '"+deviceCode+"' ";
            sql +=" and a.device_sn = '"+deviceCode+"' ";
        }
        }
        if(!StringUtils.isEmpty(deviceName)){
        if(!StringUtils.isEmpty(deviceName)){
            sql +=" and a.device_name like '%"+deviceName+"%' ";
        }
        if(!StringUtils.isEmpty(linkman)){
            sql +=" and AES_DECRYPT(from_base64(a.linkman),'jkzl2021ZJXL*#%a') like '%"+linkman+"%' ";//AES_DECRYPT(from_base64(d.patient_name),'jkzl2021ZJXL*#%a')
            sql +=" and a.name like '%"+deviceName+"%' ";
        }
        }
//        if(!StringUtils.isEmpty(linkman)){
//            sql +=" and AES_DECRYPT(from_base64(a.linkman),'jkzl2021ZJXL*#%a') like '%"+linkman+"%' ";//AES_DECRYPT(from_base64(d.patient_name),'jkzl2021ZJXL*#%a')
//        }
        /**
        /**
         * 通用查询 补充字段
         * 通用查询 补充字段
         */
         */
@ -109,37 +113,66 @@ public class WlyyDeviceService {
        //数据权限过滤
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and a.grant_org_code in ("+orgUserService.getUserOrg(orgList)+") ";
            sql += " and a.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        }
        sql += " order by a.id desc ";
        sql += " order by a.id desc ";
        Long count = Long.valueOf(jdbcTemplate.queryForList(sql).size());
        Long count = Long.valueOf(jdbcTemplate.queryForList(sql).size());
        sql += "limit " + (page - 1) * pageSize + "," + pageSize;
        sql += "limit " + (page - 1) * pageSize + "," + pageSize;
        sql = TransforSqlUtl.deviceAll(sql);
        sql = TransforSqlUtl.deviceAll(sql);
        List<WlyyDeviceVO> deviceVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WlyyDeviceVO.class));
//        deviceVOList.forEach(one->{
//            one.setLinkman(AesEncryptUtils.decrypt(one.getLinkman()));
//            one.setTel(AesEncryptUtils.decrypt(one.getTel()));
//            one.setRepresentative(AesEncryptUtils.decrypt(one.getRepresentative()));
//            one.setApplicantName(AesEncryptUtils.decrypt(one.getApplicantName()));
//            one.setApplicantTel(AesEncryptUtils.decrypt(one.getApplicantTel()));
//            one.setApplicantIdentity(AesEncryptUtils.decrypt(one.getApplicantIdentity()));
//        });
        Map<String,String>  propertyNameMap = patientDeviceService.getHostpitalDictMap("Device_common_name");
        Map<String,String>  propertyCombinationMap = patientDeviceService.getHostpitalDictMap("Combination_method");
        Map<String,String>  propertyUseMap = patientDeviceService.getHostpitalDictMap("device_use");
        Map<String,String>  propertyNetworkMap = patientDeviceService.getHostpitalDictMap("Network_transmission");
        Map<String,String>  propertyLocationMap = patientDeviceService.getHostpitalDictMap("Drop_location");
        Map<String,String>  propertyDataAcquisitionDictMap = patientDeviceService.getHostpitalDictMap("Data_acquisition_dict");
        List<IotDeviceVO> deviceVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotDeviceVO.class));
        deviceVOList.forEach(one->{
            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()));
        });
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceVOList, page, pageSize, count);
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceVOList, page, pageSize, count);
    }
    }
    public MixEnvelop<WlyyDeviceVO,WlyyDeviceVO> findById(Long id){
        String sql = "select * from device.wlyy_devices where id = "+id;
    public Envelop findById(String id){
        String sql = "SELECT\n" +
                " distinct	a.* ,\n" +
                "	c.`name` propertyName,\n" +
                "	c.`combination` propertyCombination,\n" +
                "	c.`device_use` propertyUse,\n" +
                "	c.`network` propertyNetwork,\n" +
                "	c.`location` propertyLocation, \n" +
                "	c.`dictionaries` propertyDataAcquisitionDict, \n" +
                "	d.`sim` sim, \n" +
                "	d.`iot_imsi` iotImsi, \n" +
                "	d.`iot_iccid` iotIccid \n" +
                "FROM\n" +
                "	iot_device a \n" +
                "	left JOIN iot_product_base_info_property c ON c.product_id = a.product_id \n" +
                "	left JOIN iot_patient_device d ON a.device_sn=d.device_sn \n" +
                "WHERE a.id = '"+id+"'";
        sql = TransforSqlUtl.deviceAll(sql);
        sql = TransforSqlUtl.deviceAll(sql);
        List<WlyyDeviceVO> deviceVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WlyyDeviceVO.class));
//        deviceVOList.forEach(one->{
//            one.setLinkman(AesEncryptUtils.decrypt(one.getLinkman()));
//            one.setTel(AesEncryptUtils.decrypt(one.getTel()));
//            one.setRepresentative(AesEncryptUtils.decrypt(one.getRepresentative()));
//            one.setApplicantName(AesEncryptUtils.decrypt(one.getApplicantName()));
//            one.setApplicantTel(AesEncryptUtils.decrypt(one.getApplicantTel()));
//            one.setApplicantIdentity(AesEncryptUtils.decrypt(one.getApplicantIdentity()));
//        });
        List<IotDeviceVO> deviceVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotDeviceVO.class));
        Map<String,String>  propertyNameMap = patientDeviceService.getHostpitalDictMap("Device_common_name");
        Map<String,String>  propertyCombinationMap = patientDeviceService.getHostpitalDictMap("Combination_method");
        Map<String,String>  propertyUseMap = patientDeviceService.getHostpitalDictMap("device_use");
        Map<String,String>  propertyNetworkMap = patientDeviceService.getHostpitalDictMap("Network_transmission");
        Map<String,String>  propertyLocationMap = patientDeviceService.getHostpitalDictMap("Drop_location");
        Map<String,String>  propertyDataAcquisitionDictMap = patientDeviceService.getHostpitalDictMap("Data_acquisition_dict");
        deviceVOList.forEach(one->{
            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()));
        });
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,deviceVOList.get(0));
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,deviceVOList.get(0));
    }
    }

+ 2 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/product/IotProductBaseInfoPropertyService.java

@ -2,7 +2,6 @@ package com.yihu.iot.service.product;
import com.yihu.iot.dao.product.IotProductBaseInfoPropertyDao;
import com.yihu.iot.dao.product.IotProductBaseInfoPropertyDao;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoPropertyDO;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoPropertyDO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.iot.product.IotProductBaseInfoPropertyVO;
import com.yihu.jw.restmodel.iot.product.IotProductBaseInfoPropertyVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -94,7 +93,8 @@ public class IotProductBaseInfoPropertyService extends BaseJpaService<IotProduct
                "(SELECT q.`dict_value` FROM `iot-base`.wlyy_hospital_sys_dict q WHERE q.dict_name='Network_transmission' AND q.`dict_code`=a.`network` )\"network\", \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` )\"network\", \n" +
                "a.`location` \"locationCode\",\n" +
                "a.`location` \"locationCode\",\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` )\"location\",\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` )\"location\",\n" +
                "a.dictionaries\n" +
                "a.dictionaries dictionariesCode,\n" +
                "(SELECT q.`dict_value` FROM `iot-base`.wlyy_hospital_sys_dict q WHERE q.dict_name='Data_acquisition_dict' AND q.`dict_code`=a.`dictionaries` )\"dictionaries\" \n" +
                "FROM\n" +
                "FROM\n" +
                "	iot_product_base_info_property a" +
                "	iot_product_base_info_property a" +
                " where 1=1 ";
                " where 1=1 ";