wangjun 4 年 前
コミット
52bc4c34c5

+ 30 - 0
common/common-rest-model-es/src/main/java/iot/device/LocationDataVO.java

@ -40,6 +40,36 @@ public class LocationDataVO {
    @ApiModelProperty("创建时间")
    private String createTime;
    @ApiModelProperty("居民姓名")
    private String name;
    @ApiModelProperty("居民编码")
    private String code;
    @ApiModelProperty("设备名称")
    private String equimentName;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getEquimentName() {
        return equimentName;
    }
    public void setEquimentName(String equimentName) {
        this.equimentName = equimentName;
    }
    public String getId() {
        return id;

+ 2 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java

@ -205,6 +205,7 @@ public class IotPatientDeviceController extends EnvelopRestEndpoint {
        try {
            List<LocationDataVO> list = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonData);
            figureLabelSerachService.getFigureLabelByList(list);
            List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(list);
//            list.forEach(one->{
//                JSONArray jsonArray = new JSONArray();
//                JSONObject json = new JSONObject();
@ -235,7 +236,7 @@ public class IotPatientDeviceController extends EnvelopRestEndpoint {
//                }
//
//            });
            return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_create,list,iotPatientDeviceService.getESCount(jsonData));
            return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_create,list2,iotPatientDeviceService.getESCount(jsonData));
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 33 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -11,6 +11,7 @@ import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.util.excel.HibenateUtils;
import com.yihu.jw.device.LocationDataDO;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceOverhaulDO;
@ -30,6 +31,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.provider.HibernateUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -65,6 +67,8 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
    private UserAgent userAgent;
    @Autowired
    private IotCompanyDao iotCompanyDao;
    @Autowired
    private HibenateUtils hibernateUtils;
    /**
     * 新增
@ -257,6 +261,35 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        JestResult esResult = elasticSearchHelper.search(ConstantUtils.deviceLocationIndex,ConstantUtils.deviceLocationType,queryStr.toString());
        return getESResultBeanList(esResult);
    }
    public List<LocationDataVO> addNameAndCodeToList(List<LocationDataVO> list){
        if(null!=list){
            for (LocationDataVO locationDataVO:list){
                String sql = "select t.code as \"code\",t.name as \"name\" from wlyy.wlyy_patient t where 1=1 ";
                String sqlEqt="select t.device_name as\"device_name\" from device.wlyy_devices t where 1=1";
                String idCard = locationDataVO.getIdCard();
                String snCoed = locationDataVO.getDeviceSn();
                if (StringUtils.isNotEmpty(idCard)){
                    sql = sql +" and t.idcard = '"+idCard+"'";
                }if (StringUtils.isNotEmpty(snCoed)){
                    sqlEqt = sqlEqt +" and t.device_code = '"+snCoed+"'";
                }
                List<Map<String,Object>> nameList = hibernateUtils.createSQLQuery(sql);
                List<Map<String,Object>> deviceList = hibernateUtils.createSQLQuery(sqlEqt);
                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")?"":nameList.get(0).get("name").toString();
                    locationDataVO.setCode(code);
                    locationDataVO.setName(name);
                }
                if (deviceList.size()>0){
                    String equipmentName = null==deviceList.get(0).get("device_name")?"":deviceList.get(0).get("device_name").toString();
                    locationDataVO.setEquimentName(equipmentName);
                }
            }
        }
        return list;
    }
    /**
     * 根据设备SN码查询设备地址