Browse Source

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing 2 years ago
parent
commit
9d4a88cb10

+ 23 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/third/ThirdDataInputController.java

@ -83,6 +83,29 @@ public class ThirdDataInputController {
        }
    }
    @PostMapping(value = "searchList2")
    @ApiOperation(value = "查询数据,分页", notes = "根据条件查询数据,分页")
    @IntefaceLogRequired
    public MixEnvelop searchList2(
            @ApiParam(name="startTime",value="开始时间",defaultValue = "")
            @RequestParam(value="startTime",required = false) String startTime,
            @ApiParam(name="endTime",value="结束时间",defaultValue = "")
            @RequestParam(value="endTime",required = false) String endTime,
            @ApiParam(name="sn",value="设备sn",defaultValue = "")
            @RequestParam(value="sn",required = false) String sn,
            @ApiParam(name="ext_code",value="地区",defaultValue = "")
            @RequestParam(value="ext_code",required = false) String ext_code,
            @ApiParam(name="idcard",value="身份证",defaultValue = "")
            @RequestParam(value="idcard",required = false) String idcard,
            @ApiParam(name="itemCode",value="体征指标代码",defaultValue = "")
            @RequestParam(value="itemCode",required = false) String itemCode) throws IOException {
        try{
            return dataSearchService.getDataToBean2(startTime,endTime,sn,ext_code,idcard,itemCode);
        } catch (ApiException e){
            return MixEnvelop.getError("操作失败", e.getErrorCode());
        }
    }
    @PostMapping(value = IotRequestMapping.ThirdOpen.uploadData)
    @ApiOperation(value = "体征数据上传", notes = "数据上传入库")
    @IntefaceLogRequired

+ 77 - 0
svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataSearchService.java

@ -81,6 +81,83 @@ public class DataSearchService {
        return MixEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
    public MixEnvelop getDataToBean2(String startTime, String endTime, String sn, String ext_code,
                                    String idcard, String itemCode) throws IOException {
        logger.info("load data from elasticsearch start:" + org.apache.http.client.utils.DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss));
        String sql = "select * from "+ esIndex + " where  ";
        String countSql = "select count(*) count from "+ esIndex + " where  ";
        boolean firstFilter = true;
        if (StringUtils.isNotBlank(idcard)){
            sql += "  idcard = '"+idcard+"' ";
            countSql += " idcard = '"+idcard+"' ";
            firstFilter = false;
        }
        if(StringUtils.isNotEmpty(startTime)){
            if (firstFilter){
                sql += "  measure_data.measure_time>='"+startTime+"'";
                countSql += "  measure_data.measure_time>='"+startTime+"'";
                firstFilter = false;
            }else {
                sql += " and measure_data.measure_time>='"+startTime+"'";
                countSql += " and measure_data.measure_time>='"+startTime+"'";
            }
        }
        if(StringUtils.isNotEmpty(endTime)){
            if (firstFilter){
                sql += "  measure_data.measure_time<='"+endTime+"'";
                countSql += "  measure_data.measure_time<='"+endTime+"'";
                firstFilter = false;
            }else {
                sql += " and measure_data.measure_time<='"+endTime+"'";
                countSql += " and measure_data.measure_time<='"+endTime+"'";
            }
        }
        if(StringUtils.isNotEmpty(sn)){
            if (firstFilter){
                sql += "  sn='"+sn+"'";
                countSql += "  sn='"+sn+"'";
                firstFilter = false;
            }else {
                sql += " and sn='"+sn+"'";
                countSql += " and sn='"+sn+"'";
            }
        }
        if(StringUtils.isNotEmpty(ext_code)){
            if (firstFilter){
                sql += "  ext_code='"+ext_code+"'";
                countSql += "  ext_code='"+ext_code+"'";
                firstFilter = false;
            }else {
                sql += " and ext_code='"+ext_code+"'";
                countSql += " and ext_code='"+ext_code+"'";
            }
        }
        if(StringUtils.isNotEmpty(itemCode)){
            if (firstFilter){
                sql += "  measure_data.sign_name='"+itemCode+"'";
                countSql += "  measure_data.sign_name='"+itemCode+"'";
                firstFilter = false;
            }else {
                sql += " and measure_data.sign_name='"+itemCode+"'";
                countSql += " and measure_data.sign_name='"+itemCode+"'";
            }
        }
        sql+=" order by measure_data.measure_time desc ";
        List<iot.device.DataBodySignsVO> list = elasticSearchQueryGenerator.excute(sql, iot.device.DataBodySignsVO.class, ConstantUtils.esIndex, ConstantUtils.esType);
        Long count = elasticSearchQueryGenerator.excuteForLong(countSql,ConstantUtils.esType,ConstantUtils.esIndex);
        return MixEnvelop.getSuccessListWithPage("success",list,1,count.intValue()+1,count);
    }
//    @Autowired
//    private HBaseHelper hBaseHelper;