Przeglądaj źródła

Merge branch 'dev' of LiTaohong/jw2.0 into dev

yeshijie 7 lat temu
rodzic
commit
9f370f9340

+ 8 - 2
app/app-iot-server/pom.xml

@ -29,12 +29,12 @@
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>us.codecraft</groupId>
            <artifactId>webmagic-core</artifactId>
@ -75,7 +75,7 @@
        </dependency>
        <dependency>
        <!--<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
@ -93,7 +93,13 @@
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>4.0.0.RELEASE</version>
        </dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-extras</artifactId>

+ 0 - 2
app/app-iot-server/src/main/resources/application.yml

@ -24,8 +24,6 @@ spring:
    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/front/,classpath:/
#    cache-period: 0
permissions:
  info: admin

+ 12 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -21,6 +21,7 @@ public class IotRequestMapping {
        public static final String quality = api_iot_common + "/quality";
        public static final String patientDevice = api_iot_common + "/patientDevice";
        public static final String wlyy = api_iot_common + "/wlyy";
        public static final String figereLabel = api_iot_common + "/figereLabel";
        public static final String message_success_update = "update success";
@ -265,4 +266,15 @@ public class IotRequestMapping {
    }
    /**
     * 居民标签信息模块常量
     */
    public static class FigureLabelInfo{
        public static final String api_getByIdcard = "getLabelByIdcard";
        public static final String api_getByTypeAndCode = "getLabelByTypeAndCode";
        public static final String message_success_find = "FigureLabelInfo find success";
    }
}

+ 90 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/FigureLabelDataModelVO.java

@ -0,0 +1,90 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.searchbox.annotations.JestId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "居民标签信息", description = "居民标签信息")
public class FigureLabelDataModelVO {
    //es ID
    @JestId
    private String id;
    @ApiModelProperty("身份证")
    private String idcard;
    @ApiModelProperty("标签类型")
    private String labelType;
    @ApiModelProperty("标签code")
    private String labelCode;
    @ApiModelProperty("标签名称")
    private String labeName;
    @ApiModelProperty("标签值,仅当标签只有一个分类的时候才有此值,比如生日,体重等")
    private String labelValue;
    @ApiModelProperty("创建时间")
    private String createTime;
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getLabelType() {
        return labelType;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getLabeName() {
        return labeName;
    }
    public void setLabeName(String labeName) {
        this.labeName = labeName;
    }
    public String getLabelValue() {
        return labelValue;
    }
    public void setLabelValue(String labelValue) {
        this.labelValue = labelValue;
    }
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
}

+ 51 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/label/FigureLabelSearchController.java

@ -0,0 +1,51 @@
package com.yihu.iot.controller.label;
import com.yihu.iot.service.label.FigureLabelSerachService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.iot.device.FigureLabelDataModelVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @author lith on 2018/03/16
 */
@RestController
@RequestMapping(IotRequestMapping.Common.figereLabel)
@Api(tags = "居民标签查询控制器", description = "居民标签查询控制器")
public class FigureLabelSearchController extends EnvelopRestController {
    @Autowired
    private FigureLabelSerachService figureLabelSerachService;
    @PostMapping(value = IotRequestMapping.FigureLabelInfo.api_getByIdcard,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据idcard查询居民标签", notes = "根据idcard查询居民标签")
    public Envelop<List<FigureLabelDataModelVO>> findByIdcard(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestBody String jsonData) {
        try {
            return Envelop.getSuccess(IotRequestMapping.FigureLabelInfo.message_success_find, figureLabelSerachService.getFigureLabelByIdcard(jsonData));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = IotRequestMapping.FigureLabelInfo.api_getByTypeAndCode,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据type和code居民标签", notes = "根据type和code居民标签")
    public Envelop<List<FigureLabelDataModelVO>> findByTypeAndCode(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestBody String jsonData) {
        try {
            return Envelop.getSuccess(IotRequestMapping.FigureLabelInfo.message_success_find, figureLabelSerachService.getFigureLabelByLabel(jsonData));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

+ 5 - 0
svr/svr-iot/src/main/java/com/yihu/iot/datainput/util/ConstantUtils.java

@ -20,4 +20,9 @@ public class ConstantUtils {
    public static String deviceLocationIndex = "device_location_index";
    //设备坐标es类型
    public static String deviceLocationType = "device_location_type";
    //居民标签es索引
    public static String figureLabelIndex = "figure_label_index";
    //居民标签es类型
    public static String figureLabelType = "figure_label_type";
}

+ 74 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/label/FigureLabelSerachService.java

@ -0,0 +1,74 @@
package com.yihu.iot.service.label;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.jw.restmodel.iot.device.FigureLabelDataModelVO;
import io.searchbox.client.JestResult;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
 * @author lith on 2018/03/16
 */
@Service
public class FigureLabelSerachService implements Serializable {
    private Logger logger = LoggerFactory.getLogger(FigureLabelSerachService.class);
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    @Autowired
    private ElasticSearchQueryGenerator elasticSearchQueryGenerator;
    /**
     *根据idcard查询标签
     * @param json
     * @return
     */
    public List<FigureLabelDataModelVO> getFigureLabelByIdcard(String json){
        List<FigureLabelDataModelVO> list = new ArrayList<>();
        if(!json.contains("idcard")){
            logger.error("invalid elasticserach query condition,no parameter [idcard]!");
            return list;
        }
        JSONObject jsonObject = JSONObject.parseObject(json);
        //elasticsearch 默认查询上限为10000条,但是我们根据条件查询,不知道数据会有几条,此处给最大值
        jsonObject.put("size",10000);
        SearchSourceBuilder queryStr = elasticSearchQueryGenerator.getQueryBuilder("",jsonObject.toJSONString());
        JestResult jestResult = elastricSearchHelper.search(ConstantUtils.figureLabelIndex,ConstantUtils.figureLabelType,queryStr.toString());
        list = jestResult.getSourceAsObjectList(FigureLabelDataModelVO.class);
        return list;
    }
    /**
     * 根据标签类型和标签code查询标签
     * @param json
     * @return
     */
    public List<FigureLabelDataModelVO> getFigureLabelByLabel(String json){
        List<FigureLabelDataModelVO> list = new ArrayList<>();
        if(!json.contains("labelType") || !json.contains("labelCode")){
            logger.error("invalid elasticserach query condition,no parameter [labelType] or [labelCode]!");
            return list;
        }
        JSONObject jsonObject = JSONObject.parseObject(json);
        //elasticsearch 默认查询上限为10000条,但是我们根据条件查询,不知道数据会有几条,此处给最大值
        jsonObject.put("size",10000);
        SearchSourceBuilder queryStr = elasticSearchQueryGenerator.getQueryBuilder("",jsonObject.toJSONString());
        JestResult jestResult = elastricSearchHelper.search(ConstantUtils.figureLabelIndex,ConstantUtils.figureLabelType,queryStr.toString());
        list = jestResult.getSourceAsObjectList(FigureLabelDataModelVO.class);
        return list;
    }
}