Explorar el Código

Merge branch 'dev' of https://github.com/EverybodyGitHub/jw2.0 into dev

LiTaohong hace 7 años
padre
commit
5f10298368
Se han modificado 61 ficheros con 1418 adiciones y 332 borrados
  1. 10 1
      base/common-data-es/src/main/java/com/yihu/base/es/config/ElasticFactory.java
  2. 47 0
      base/common-data-es/src/main/java/com/yihu/base/es/config/ElastricSearchHelper.java
  3. 2 1
      base/common-data-es/src/main/resources/template.yml
  4. 3 0
      base/common-data-hbase/src/main/java/com/yihu/base/hbase/HBaseHelper.java
  5. 1 12
      common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceDO.java
  6. 88 0
      common/common-entity/src/main/java/com/yihu/jw/iot/label/IotDeviceLabelDO.java
  7. 78 0
      common/common-entity/src/main/java/com/yihu/jw/iot/label/IotDeviceLabelInfoDO.java
  8. 52 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  9. 0 12
      svr-lib-parent-pom/pom.xml
  10. 30 17
      svr/svr-iot/pom.xml
  11. 84 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java
  12. 83 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java
  13. 84 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDevicePurchaseController.java
  14. 83 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityInspectionPlanController.java
  15. 100 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/label/IotDeviceLabelController.java
  16. 100 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/label/IotDeviceLabelInfoController.java
  17. 72 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/supplier/IotSupplyDeviceDataTypeController.java
  18. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java
  19. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceOrderDao.java
  20. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDevicePurchaseDao.java
  21. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java
  22. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/dict/IotDeviceDictDao.java
  23. 16 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/label/IotDeviceLabelDao.java
  24. 15 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/label/IotDeviceLabelInfoDao.java
  25. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotDeviceSupplierDao.java
  26. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotSupplyDeviceDao.java
  27. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotSupplyDeviceDataTypeDao.java
  28. 4 0
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/controller/DataSearchController.java
  29. 24 14
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataInputService.java
  30. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataProcessLogService.java
  31. 35 0
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataSearchService.java
  32. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/util/ConstantUtils.java
  33. 11 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java
  34. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDevicePurchaseService.java
  35. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java
  36. 11 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java
  37. 34 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/label/IotDeviceLabelInfoService.java
  38. 33 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/label/IotDeviceLabelService.java
  39. 5 14
      svr/svr-iot/src/main/resources/application.yml
  40. 16 21
      web-gateway/pom.xml
  41. 1 1
      web-gateway/src/main/java/com/yihu/jw/aspect/LogAspect.java
  42. 21 18
      web-gateway/src/main/java/com/yihu/jw/commnon/base/user/BaseUserContants.java
  43. 6 6
      web-gateway/src/main/java/com/yihu/jw/commnon/iot/DataConstants.java
  44. 40 40
      web-gateway/src/main/java/com/yihu/jw/config/security/ClientService.java
  45. 48 48
      web-gateway/src/main/java/com/yihu/jw/config/security/RbasService.java
  46. 61 61
      web-gateway/src/main/java/com/yihu/jw/config/security/UserService.java
  47. 4 4
      web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseMenuController.java
  48. 2 2
      web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseRoleController.java
  49. 2 2
      web-gateway/src/main/java/com/yihu/jw/controller/base/version/UserVersionController.java
  50. 32 32
      web-gateway/src/main/java/com/yihu/jw/controller/login/LoginController.java
  51. 1 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseMenuFeign.java
  52. 1 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseRoleFeign.java
  53. 1 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployFeign.java
  54. 2 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/version/UserVersionFeign.java
  55. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseMenuFeignFallbackFactory.java
  56. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseRoleFeignFallbackFactory.java
  57. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/EmployeeFeignFallbackFactory.java
  58. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/version/UserVersionFeignFallbackFactory.java
  59. 2 1
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataInputFeignFallbackFactory.java
  60. 2 1
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataStandardConvertFeignFallbackFactory.java
  61. 18 1
      web-gateway/src/main/resources/application.yml

+ 10 - 1
base/common-data-es/src/main/java/com/yihu/base/es/config/ElasticFactory.java

@ -2,6 +2,7 @@ package com.yihu.base.es.config;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.ClientConfig;
import io.searchbox.client.config.HttpClientConfig;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
@ -9,10 +10,14 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
@ -28,6 +33,7 @@ public class ElasticFactory {
    private String clusterNodes; // 120.25.194.233:9300,120.25.194.233:9300,120.25.194.233:9300
    @Value("${spring.elasticsearch.jest.uris}")
    private String jestHost; // http://192.168.226.133:9200
//-----------------------------------jestClient----------------------------------------
    /**
@ -48,8 +54,11 @@ public class ElasticFactory {
    public synchronized void init() {
        // Construct a new Jest client according to configuration via factory
        factory = new JestClientFactory();
        Set<String> serverList = new LinkedHashSet<>();
        String[] uris = jestHost.split(",");
        serverList.addAll(CollectionUtils.arrayToList(uris));
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder(jestHost)
                .Builder(serverList)
                .multiThreaded(true)
                .maxTotalConnection(50)// 最大链接
                .maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间

+ 47 - 0
base/common-data-es/src/main/java/com/yihu/base/es/config/ElastricSearchHelper.java

@ -1,8 +1,10 @@
package com.yihu.base.es.config;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.yihu.base.es.config.model.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestResult;
import io.searchbox.core.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -155,4 +157,49 @@ public class ElastricSearchHelper {
            }
        }
    }
    /**
     * 查询
     */
    public String search(String index, String type, String queryStr) {
        JestClient jestClient = null;
        JestResult result = null;
        try {
            jestClient = elasticFactory.getJestClient();
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(index).defaultType(type);
//            for (SaveModel obj : saveModels) {
//                Search indexObj = new Search.Builder(obj.getId()).build();
//                bulk.addAction(indexObj);
//            }
            BulkResult br = jestClient.execute(bulk.build());
            Search search = (Search) new Search.Builder(queryStr)
                    // multiple index or types can be added.
                    .addIndex("articles")
                    .addType("article")
                    .build();
            result = jestClient.execute(search);
            JSONObject resultJsonObject = (JSONObject)JSONObject.parse(result.getJsonString());
            JSONObject jsonObject = (JSONObject)resultJsonObject.get("hits");
            logger.info("delete data count:" + jsonObject.get("total"));
            logger.info("delete flag:" + br.isSucceeded());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return result.getJsonString();
    }
    public static void main(String args[]){
        String json = "";
        JSONObject resultJsonObject = (JSONObject)JSONObject.parse(json);
        JSONObject jsonObject = (JSONObject)resultJsonObject.get("hits");
        System.out.println(jsonObject.get("total"));
    }
}

+ 2 - 1
base/common-data-es/src/main/resources/template.yml

@ -13,11 +13,12 @@ spring:
      cluster-nodes: 120.25.194.233:9300,120.25.194.233:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      local: false ##是否本地连接
      properties: # Additional properties used to configure the client.
        enable: true
  # JEST (Elasticsearch HTTP client) (JestProperties)
  elasticsearch:
    jest:
      uris: http://192.168.226.133:9200
      uris: http://172.17.110.217:9200,http://172.17.110.128:9200
      connection-timeout: # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
      username: # Login user.

+ 3 - 0
base/common-data-hbase/src/main/java/com/yihu/base/hbase/HBaseHelper.java

@ -203,6 +203,9 @@ public class HBaseHelper extends AbstractHBaseClient {
                    for (String qualifier : map.keySet())
                    {
                        String value = map.get(qualifier);
                        if(value == null){
                            continue;
                        }
                        p.add(familyName.getBytes(), qualifier.getBytes(), value.getBytes());
                    }
                }

+ 1 - 12
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceDO.java

@ -18,9 +18,6 @@ public class IotDeviceDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "code")
    private String code;
    @Column(name = "name")
    private String name;//设备名称
@ -54,7 +51,7 @@ public class IotDeviceDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "manufacturer_name")
    private String manufacturerName;//厂商名称
    @Column(name = "manufacturer_tel")
    @Column(name = "manufacture_tel")
    private String manufactureTel;//厂商名称
    @Column(name = "order_code")
@ -92,14 +89,6 @@ public class IotDeviceDO extends IdEntityWithOperation implements Serializable {
        this.saasId = saasId;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }

+ 88 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/label/IotDeviceLabelDO.java

@ -0,0 +1,88 @@
package com.yihu.jw.iot.label;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * 设备标签表
 * @author yeshijie on 2017/12/28.
 */
@Entity
@Table(name = "iot_device_label")
public class IotDeviceLabelDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "label_code")
    private String labelCode;//标签标识
    @Column(name = "label_name")
    private String labelName;//标签名称
    @Column(name = "label_type")
    private String labelType;//标签类型
    @Column(name = "is_system")
    private Integer isSystem;//是否系统标签(1是、0否)
    @Column(name = "supplier_code")
    private String supplierCode;//供应商code
    @Column(name = "sort")
    private Long sort;//排序
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelType() {
        return labelType;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public Integer getIsSystem() {
        return isSystem;
    }
    public void setIsSystem(Integer isSystem) {
        this.isSystem = isSystem;
    }
    public String getSupplierCode() {
        return supplierCode;
    }
    public void setSupplierCode(String supplierCode) {
        this.supplierCode = supplierCode;
    }
    public Long getSort() {
        return sort;
    }
    public void setSort(Long sort) {
        this.sort = sort;
    }
}

+ 78 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/label/IotDeviceLabelInfoDO.java

@ -0,0 +1,78 @@
package com.yihu.jw.iot.label;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * 设备标签信息表
 * @author yeshijie on 2017/12/28.
 */
@Entity
@Table(name = "iot_device_label_info")
public class IotDeviceLabelInfoDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "device_code")
    private String deviceCode;//设备code
    @Column(name = "device_name")
    private String deviceName;//设备名称
    @Column(name = "label_code")
    private String labelCode;//标签code
    @Column(name = "label_name")
    private String labelName;//标签名称
    @Column(name = "label_type")
    private String labelType;//标签类型
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getDeviceCode() {
        return deviceCode;
    }
    public void setDeviceCode(String deviceCode) {
        this.deviceCode = deviceCode;
    }
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelType() {
        return labelType;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
}

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

@ -239,4 +239,56 @@ public class IotRequestMapping {
        public static final String message_fail_saasId_is_null = "saasId is null";
    }
    /**
     * 设备标签模块常量
     */
    public static class DeviceLabel{
        public static final String api_create = "deviceLabel";
        public static final String api_delete = "deviceLabel";
        public static final String api_getById = "getDeviceLabelById";
        public static final String api_update = "deviceLabel";
        public static final String api_queryPage = "queryDeviceLabelPage";
        public static final String api_getList = "getDeviceLabelList";
        public static final String message_success_update = "deviceLabel update success";
        public static final String message_success_delete = "deviceLabel delete success";
        public static final String message_success_find = "deviceLabel find success";
        public static final String message_success_create = "deviceLabel create success";
        public static final String message_success_find_functions = "deviceLabel find success";
        public static final String message_fail_name_is_null = "name is null";
        public static final String message_fail_iotDeviceLabel_is_no_exist = "iotDeviceLabel is no exist";
        public static final String message_fail_id_no_exist = "id no exist";
        public static final String message_fail_status_is_null = "status is null";
        public static final String message_fail_id_is_null = "id is null";
        public static final String message_fail_id_exist = "id exist";
        public static final String message_fail_saasId_is_null = "saasId is null";
    }
    /**
     * 设备标签信息模块常量
     */
    public static class DeviceLabelInfo{
        public static final String api_create = "deviceLabelInfo";
        public static final String api_delete = "deviceLabelInfo";
        public static final String api_getById = "getDeviceLabelInfoById";
        public static final String api_update = "deviceLabelInfo";
        public static final String api_queryPage = "queryDeviceLabelInfoPage";
        public static final String api_getList = "getDeviceLabelInfoList";
        public static final String message_success_update = "deviceLabelInfo update success";
        public static final String message_success_delete = "deviceLabelInfo delete success";
        public static final String message_success_find = "deviceLabelInfo find success";
        public static final String message_success_create = "deviceLabelInfo create success";
        public static final String message_success_find_functions = "deviceLabelInfo find success";
        public static final String message_fail_name_is_null = "name is null";
        public static final String message_fail_iotDeviceLabelInfo_is_no_exist = "iotDeviceLabelInfo is no exist";
        public static final String message_fail_id_no_exist = "id no exist";
        public static final String message_fail_status_is_null = "status is null";
        public static final String message_fail_id_is_null = "id is null";
        public static final String message_fail_id_exist = "id exist";
        public static final String message_fail_saasId_is_null = "saasId is null";
    }
}

+ 0 - 12
svr-lib-parent-pom/pom.xml

@ -76,8 +76,6 @@
        <version.hbase>1.1.12</version.hbase>
        <version.hadoop>2.7.4</version.hadoop>
        <version.scala>2.10.6</version.scala>
        <version.elasticsearch>2.4.4</version.elasticsearch>
        <version.jest>2.4.0</version.jest>
        <version.hbase-client>1.1.1</version.hbase-client>
        <version.joda-time>2.8.2</version.joda-time>
        <version.solr>5.5.1</version.solr>
@ -370,16 +368,6 @@
                <artifactId>elasticsearch-sql</artifactId>
                <version>${version.elasticsearch-sql}</version>
            </dependency>
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>${version.elasticsearch}</version>
            </dependency>
            <dependency>
                <groupId>io.searchbox</groupId>
                <artifactId>jest</artifactId>
                <version>${version.jest}</version>
            </dependency>
            <!--elasticsearch end-->
            <!--alibaba  json 包-->
            <dependency>

+ 30 - 17
svr/svr-iot/pom.xml

@ -10,8 +10,10 @@
        <relativePath>../../svr-lib-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.iot</groupId>
    <artifactId>svr-iot</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
@ -21,6 +23,7 @@
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-es</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
@ -62,18 +65,6 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-mysql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
@ -125,11 +116,6 @@
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-es</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-hbase</artifactId>
@ -141,4 +127,31 @@
            <version>1.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-iot</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.yihu.iot.IOTApplication</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

+ 84 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java

@ -1,10 +1,22 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.device.IotDeviceDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
@ -13,5 +25,75 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "设备管理相关操作", description = "设备管理相关操作")
public class IotDeviceController extends EnvelopRestController{
    @Autowired
    private IotDeviceService iotDeviceService;
    @PostMapping(value = IotRequestMapping.Device.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建设备", notes = "创建设备")
    public Envelop create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestBody String jsonData) {
        try {
            IotDeviceDO iotDevice = toEntity(jsonData, IotDeviceDO.class);
            return Envelop.getSuccess(IotRequestMapping.Device.message_success_create, iotDeviceService.create(iotDevice));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = IotRequestMapping.Device.api_getById)
    @ApiOperation(value = "根据code查找设备", notes = "根据code查找设备")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(IotRequestMapping.Device.message_success_find, iotDeviceService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.Device.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取设备")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
            @RequestParam(value = "filters", required = false,defaultValue = "") String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotDeviceDO> list = iotDeviceService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotDeviceService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotDeviceDO> iotDevices = convertToModels(list, new ArrayList<>(list.size()), IotDeviceDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.Device.message_success_find_functions,iotDevices, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.Device.api_getList)
    @ApiOperation(value = "获取设备列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<IotDeviceDO> list = iotDeviceService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDeviceDO> iotDevices = convertToModels(list, new ArrayList<>(list.size()), IotDeviceDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.Device.message_success_find_functions,iotDevices);
    }
}

+ 83 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java

@ -1,10 +1,22 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceOrderService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.device.IotDeviceOrderDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
@ -13,5 +25,74 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "设备订单管理相关操作", description = "设备订单管理相关操作")
public class IotDeviceOrderController extends EnvelopRestController{
    @Autowired
    private IotDeviceOrderService iotDeviceOrderService;
    @PostMapping(value = IotRequestMapping.DeviceOrder.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建设备订单", notes = "创建设备订单")
    public Envelop create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestBody String jsonData) {
        try {
            IotDeviceOrderDO iotDeviceOrder = toEntity(jsonData, IotDeviceOrderDO.class);
            return Envelop.getSuccess(IotRequestMapping.DeviceOrder.message_success_create, iotDeviceOrderService.create(iotDeviceOrder));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.api_getById)
    @ApiOperation(value = "根据code查找设备订单", notes = "根据code查找设备订单")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(IotRequestMapping.DeviceOrder.message_success_find, iotDeviceOrderService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.DeviceOrder.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取设备订单")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
            @RequestParam(value = "filters", required = false,defaultValue = "") String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotDeviceOrderDO> list = iotDeviceOrderService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotDeviceOrderService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotDeviceOrderDO> iotDeviceOrders = convertToModels(list, new ArrayList<>(list.size()), IotDeviceOrderDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.DeviceOrder.message_success_find_functions,iotDeviceOrders, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.api_getList)
    @ApiOperation(value = "获取设备订单列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<IotDeviceOrderDO> list = iotDeviceOrderService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDeviceOrderDO> iotDeviceOrders = convertToModels(list, new ArrayList<>(list.size()), IotDeviceOrderDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.DeviceOrder.message_success_find_functions,iotDeviceOrders);
    }
}

+ 84 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDevicePurchaseController.java

@ -1,10 +1,22 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDevicePurchaseService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.device.IotDevicePurchaseDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
@ -13,5 +25,75 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "设备采购管理相关操作", description = "设备采购管理相关操作")
public class IotDevicePurchaseController extends EnvelopRestController{
    @Autowired
    private IotDevicePurchaseService iotDevicePurchaseService;
    @PostMapping(value = IotRequestMapping.DevicePurchase.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建设备采购", notes = "创建设备采购")
    public Envelop create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestBody String jsonData) {
        try {
            IotDevicePurchaseDO iotDevicePurchase = toEntity(jsonData, IotDevicePurchaseDO.class);
            return Envelop.getSuccess(IotRequestMapping.DevicePurchase.message_success_create, iotDevicePurchaseService.create(iotDevicePurchase));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = IotRequestMapping.DevicePurchase.api_getById)
    @ApiOperation(value = "根据code查找设备采购", notes = "根据code查找设备采购")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(IotRequestMapping.DevicePurchase.message_success_find, iotDevicePurchaseService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.DevicePurchase.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取设备采购")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
            @RequestParam(value = "filters", required = false,defaultValue = "") String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotDevicePurchaseDO> list = iotDevicePurchaseService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotDevicePurchaseService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotDevicePurchaseDO> iotDevicePurchases = convertToModels(list, new ArrayList<>(list.size()), IotDevicePurchaseDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.DevicePurchase.message_success_find_functions,iotDevicePurchases, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.DevicePurchase.api_getList)
    @ApiOperation(value = "获取设备采购列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<IotDevicePurchaseDO> list = iotDevicePurchaseService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDevicePurchaseDO> iotDevicePurchases = convertToModels(list, new ArrayList<>(list.size()), IotDevicePurchaseDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.DevicePurchase.message_success_find_functions,iotDevicePurchases);
    }
}

+ 83 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityInspectionPlanController.java

@ -1,10 +1,22 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceQualityInspectionPlanService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
@ -13,5 +25,74 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "设备质检管理相关操作", description = "设备质检管理相关操作")
public class IotDeviceQualityInspectionPlanController extends EnvelopRestController{
    @Autowired
    private IotDeviceQualityInspectionPlanService iotDeviceQualityInspectionPlanService;
    @PostMapping(value = IotRequestMapping.DeviceQualityInspectionPlan.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建设备质检", notes = "创建设备质检")
    public Envelop create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestBody String jsonData) {
        try {
            IotDeviceQualityInspectionPlanDO iotDeviceQualityInspectionPlan = toEntity(jsonData, IotDeviceQualityInspectionPlanDO.class);
            return Envelop.getSuccess(IotRequestMapping.DeviceQualityInspectionPlan.message_success_create, iotDeviceQualityInspectionPlanService.create(iotDeviceQualityInspectionPlan));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceQualityInspectionPlan.api_getById)
    @ApiOperation(value = "根据code查找设备质检", notes = "根据code查找设备质检")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(IotRequestMapping.DeviceQualityInspectionPlan.message_success_find, iotDeviceQualityInspectionPlanService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.DeviceQualityInspectionPlan.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取设备质检")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
            @RequestParam(value = "filters", required = false,defaultValue = "") String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotDeviceQualityInspectionPlanDO> list = iotDeviceQualityInspectionPlanService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotDeviceQualityInspectionPlanService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotDeviceQualityInspectionPlanDO> iotDeviceQualityInspectionPlans = convertToModels(list, new ArrayList<>(list.size()), IotDeviceQualityInspectionPlanDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.DeviceQualityInspectionPlan.message_success_find_functions,iotDeviceQualityInspectionPlans, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.DeviceQualityInspectionPlan.api_getList)
    @ApiOperation(value = "获取设备质检列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<IotDeviceQualityInspectionPlanDO> list = iotDeviceQualityInspectionPlanService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDeviceQualityInspectionPlanDO> iotDeviceQualityInspectionPlans = convertToModels(list, new ArrayList<>(list.size()), IotDeviceQualityInspectionPlanDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.DeviceQualityInspectionPlan.message_success_find_functions,iotDeviceQualityInspectionPlans);
    }
}

+ 100 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/label/IotDeviceLabelController.java

@ -0,0 +1,100 @@
package com.yihu.iot.controller.label;
import com.yihu.iot.service.label.IotDeviceLabelService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.label.IotDeviceLabelDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2018/1/4.
 */
@RestController
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "设备标签相关操作", description = "设备标签相关操作")
public class IotDeviceLabelController extends EnvelopRestController {
    @Autowired
    private IotDeviceLabelService iotDeviceLabelService;
    @PostMapping(value = IotRequestMapping.DeviceLabel.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建设备标签", notes = "创建设备标签")
    public Envelop create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestBody String jsonData) {
        try {
            IotDeviceLabelDO iotDevice = toEntity(jsonData, IotDeviceLabelDO.class);
            return Envelop.getSuccess(IotRequestMapping.DeviceLabel.message_success_create, iotDeviceLabelService.create(iotDevice));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceLabel.api_getById)
    @ApiOperation(value = "根据code查找设备标签", notes = "根据code查找设备标签")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(IotRequestMapping.DeviceLabel.message_success_find, iotDeviceLabelService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.DeviceLabel.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取设备标签")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
            @RequestParam(value = "filters", required = false,defaultValue = "") String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotDeviceLabelDO> list = iotDeviceLabelService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotDeviceLabelService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotDeviceLabelDO> iotDevices = convertToModels(list, new ArrayList<>(list.size()), IotDeviceLabelDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.DeviceLabel.message_success_find_functions,iotDevices, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.DeviceLabel.api_getList)
    @ApiOperation(value = "获取设备标签列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<IotDeviceLabelDO> list = iotDeviceLabelService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDeviceLabelDO> iotDevices = convertToModels(list, new ArrayList<>(list.size()), IotDeviceLabelDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.DeviceLabel.message_success_find_functions,iotDevices);
    }
}

+ 100 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/label/IotDeviceLabelInfoController.java

@ -0,0 +1,100 @@
package com.yihu.iot.controller.label;
import com.yihu.iot.service.label.IotDeviceLabelInfoService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.label.IotDeviceLabelInfoDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2018/1/4.
 */
@RestController
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "设备标签信息操作", description = "设备标签信息相关操作")
public class IotDeviceLabelInfoController extends EnvelopRestController {
    @Autowired
    private IotDeviceLabelInfoService iotDeviceLabelInfoService;
    @PostMapping(value = IotRequestMapping.DeviceLabelInfo.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建设备标签信息", notes = "创建设备标签信息")
    public Envelop create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestBody String jsonData) {
        try {
            IotDeviceLabelInfoDO iotDeviceLabelInfo = toEntity(jsonData, IotDeviceLabelInfoDO.class);
            return Envelop.getSuccess(IotRequestMapping.DeviceLabelInfo.message_success_create, iotDeviceLabelInfoService.create(iotDeviceLabelInfo));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceLabelInfo.api_getById)
    @ApiOperation(value = "根据code查找设备标签信息", notes = "根据code查找设备标签信息")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(IotRequestMapping.DeviceLabelInfo.message_success_find, iotDeviceLabelInfoService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.DeviceLabelInfo.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取设备标签信息")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
            @RequestParam(value = "filters", required = false,defaultValue = "") String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotDeviceLabelInfoDO> list = iotDeviceLabelInfoService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotDeviceLabelInfoService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotDeviceLabelInfoDO> iotDeviceLabelInfos = convertToModels(list, new ArrayList<>(list.size()), IotDeviceLabelInfoDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.DeviceLabelInfo.message_success_find_functions,iotDeviceLabelInfos, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.DeviceLabelInfo.api_getList)
    @ApiOperation(value = "获取设备标签信息列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<IotDeviceLabelInfoDO> list = iotDeviceLabelInfoService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDeviceLabelInfoDO> iotDeviceLabelInfos = convertToModels(list, new ArrayList<>(list.size()), IotDeviceLabelInfoDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.DeviceLabelInfo.message_success_find_functions,iotDeviceLabelInfos);
    }
}

+ 72 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/supplier/IotSupplyDeviceDataTypeController.java

@ -1,10 +1,21 @@
package com.yihu.iot.controller.supplier;
import com.yihu.iot.service.supplier.IotSupplyDeviceDataTypeService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.supplier.IotSupplyDeviceDataTypeDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
@ -13,5 +24,64 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "供应设备数据类型管理相关操作", description = "供应设备数据类型管理相关操作")
public class IotSupplyDeviceDataTypeController extends EnvelopRestController{
    
    @Autowired
    private IotSupplyDeviceDataTypeService iotSupplyDeviceDataTypeService;
    @GetMapping(value = IotRequestMapping.SupplyDeviceDataType.api_getById)
    @ApiOperation(value = "根据code查找供应设备数据类型", notes = "根据code查找供应设备数据类型")
    public Envelop findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(IotRequestMapping.SupplyDeviceDataType.message_success_find, iotSupplyDeviceDataTypeService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.SupplyDeviceDataType.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取供应设备数据类型")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件(supplierName?中 g1;contactsName?中 g1)")
            @RequestParam(value = "filters", required = false,defaultValue = "") String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotSupplyDeviceDataTypeDO> list = iotSupplyDeviceDataTypeService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotSupplyDeviceDataTypeService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotSupplyDeviceDataTypeDO> iotSupplyDeviceDataTypes = convertToModels(list, new ArrayList<>(list.size()), IotSupplyDeviceDataTypeDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.SupplyDeviceDataType.message_success_find_functions,iotSupplyDeviceDataTypes, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.SupplyDeviceDataType.api_getList)
    @ApiOperation(value = "获取供应设备数据类型列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段(id,supplierName,type,contactsName,contactsMobile)", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<IotSupplyDeviceDataTypeDO> list = iotSupplyDeviceDataTypeService.search(fields,filters,sorts);
        //封装返回格式
        List<IotSupplyDeviceDataTypeDO> iotSupplyDeviceDataTypes = convertToModels(list, new ArrayList<>(list.size()), IotSupplyDeviceDataTypeDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.SupplyDeviceDataType.message_success_find_functions,iotSupplyDeviceDataTypes);
    }
}

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceDao extends PagingAndSortingRepository<IotDeviceDO, Long>, JpaSpecificationExecutor<IotDeviceDO> {
public interface IotDeviceDao extends PagingAndSortingRepository<IotDeviceDO, String>, JpaSpecificationExecutor<IotDeviceDO> {
    @Query("from IotDeviceDO w where w.id =?1")
    IotDeviceDO findById(String id);

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceOrderDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceOrderDao extends PagingAndSortingRepository<IotDeviceOrderDO,Long>,JpaSpecificationExecutor<IotDeviceOrderDO> {
public interface IotDeviceOrderDao extends PagingAndSortingRepository<IotDeviceOrderDO,String>,JpaSpecificationExecutor<IotDeviceOrderDO> {
    @Query("from IotDeviceOrderDO w where w.id =?1")
    IotDeviceOrderDO findById(String id);

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDevicePurchaseDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDevicePurchaseDao extends PagingAndSortingRepository<IotDevicePurchaseDO,Long>,JpaSpecificationExecutor<IotDevicePurchaseDO> {
public interface IotDevicePurchaseDao extends PagingAndSortingRepository<IotDevicePurchaseDO,String>,JpaSpecificationExecutor<IotDevicePurchaseDO> {
    @Query("from IotDevicePurchaseDO w where w.id =?1")
    IotDevicePurchaseDO findById(String id);

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceQualityInspectionPlanDao extends PagingAndSortingRepository<IotDeviceQualityInspectionPlanDO,Long>,
public interface IotDeviceQualityInspectionPlanDao extends PagingAndSortingRepository<IotDeviceQualityInspectionPlanDO,String>,
        JpaSpecificationExecutor<IotDeviceQualityInspectionPlanDO> {
    @Query("from IotDeviceQualityInspectionPlanDO w where w.id =?1")

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/dict/IotDeviceDictDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceDictDao extends PagingAndSortingRepository<IotDeviceDictDO,Long>,JpaSpecificationExecutor<IotDeviceDictDO> {
public interface IotDeviceDictDao extends PagingAndSortingRepository<IotDeviceDictDO,String>,JpaSpecificationExecutor<IotDeviceDictDO> {
    @Query("from IotDeviceDictDO w where w.id =?1")
    IotDeviceDictDO findById(String id);

+ 16 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/label/IotDeviceLabelDao.java

@ -0,0 +1,16 @@
package com.yihu.iot.dao.label;
import com.yihu.jw.iot.dict.IotDeviceDictDO;
import com.yihu.jw.iot.label.IotDeviceLabelDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/1/4.
 */
public interface IotDeviceLabelDao extends PagingAndSortingRepository<IotDeviceLabelDO,String>,JpaSpecificationExecutor<IotDeviceLabelDO> {
    @Query("from IotDeviceLabelDO w where w.id =?1")
    IotDeviceLabelDO findById(String id);
}

+ 15 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/label/IotDeviceLabelInfoDao.java

@ -0,0 +1,15 @@
package com.yihu.iot.dao.label;
import com.yihu.jw.iot.label.IotDeviceLabelInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/1/4.
 */
public interface IotDeviceLabelInfoDao extends PagingAndSortingRepository<IotDeviceLabelInfoDO,String>,JpaSpecificationExecutor<IotDeviceLabelInfoDO> {
    @Query("from IotDeviceLabelInfoDO w where w.id =?1")
    IotDeviceLabelInfoDO findById(String id);
}

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotDeviceSupplierDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/5.
 */
public interface IotDeviceSupplierDao extends PagingAndSortingRepository<IotDeviceSupplierDO, Long>, JpaSpecificationExecutor<IotDeviceSupplierDO> {
public interface IotDeviceSupplierDao extends PagingAndSortingRepository<IotDeviceSupplierDO, String>, JpaSpecificationExecutor<IotDeviceSupplierDO> {
    @Query("from IotDeviceSupplierDO w where w.id =?1")
    IotDeviceSupplierDO findById(String id);

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotSupplyDeviceDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/5.
 */
public interface IotSupplyDeviceDao extends PagingAndSortingRepository<IotSupplyDeviceDO, Long>, JpaSpecificationExecutor<IotSupplyDeviceDO> {
public interface IotSupplyDeviceDao extends PagingAndSortingRepository<IotSupplyDeviceDO, String>, JpaSpecificationExecutor<IotSupplyDeviceDO> {
    @Query("from IotSupplyDeviceDO w where w.id =?1")
    IotSupplyDeviceDO findById(String id);

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotSupplyDeviceDataTypeDao.java

@ -8,7 +8,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/5.
 */
public interface IotSupplyDeviceDataTypeDao extends PagingAndSortingRepository<IotSupplyDeviceDataTypeDO, Long>, JpaSpecificationExecutor<IotSupplyDeviceDataTypeDO> {
public interface IotSupplyDeviceDataTypeDao extends PagingAndSortingRepository<IotSupplyDeviceDataTypeDO, String>, JpaSpecificationExecutor<IotSupplyDeviceDataTypeDO> {
    @Query("from IotSupplyDeviceDataTypeDO w where w.id =?1")
    IotSupplyDeviceDataTypeDO findById(String id);

+ 4 - 0
svr/svr-iot/src/main/java/com/yihu/iot/datainput/controller/DataSearchController.java

@ -0,0 +1,4 @@
package com.yihu.iot.datainput.controller;
public class DataSearchController {
}

+ 24 - 14
svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataInputService.java

@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.base.es.config.model.SaveModel;
import com.yihu.base.hbase.HBaseAdmin;
import com.yihu.base.hbase.HBaseHelper;
import com.yihu.iot.datainput.enums.DataOperationTypeEnum;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.datainput.util.RowKeyUtils;
import com.yihu.iot.service.device.IotDeviceService;
import com.yihu.jw.iot.device.IotDeviceDO;
@ -40,12 +42,9 @@ public class DataInputService {
    @Autowired
    private HBaseHelper hBaseHelper;
    @Autowired
    private HBaseAdmin hBaseAdmin;
    private String esIndex = "body_health_data";
    private String esType = "signs_data";
    private String tableName = "body_health_data";
    private String familyA = "column_signs_header";
    private String familyB = "column_signs_data";
@ -53,9 +52,9 @@ public class DataInputService {
     * 居民设备注册及绑定
     */
    public String bindUser(String json){
        List<IotDeviceDO> deviceDOList = new ArrayList<>();
        JSONObject jsonObject = JSONObject.parseObject(json);
        String data_source = jsonObject.getString("data_source");
        List<IotDeviceDO> deviceDOList = new ArrayList<>();
        JSONArray jsonArray = jsonObject.getJSONArray("data");
        try {
            if(null != jsonArray){
@ -68,7 +67,7 @@ public class DataInputService {
                        continue; //表示设备已经绑定过
                    }
                    iotDeviceDO.setDeviceSn(sn);
                    iotDeviceDO.setCode(dataJson.getString("ext_code"));
//                    iotDeviceDO.setCode(dataJson.getString("ext_code"));
                    iotDeviceDO.setName(dataJson.getString("device_name"));
                    iotDeviceDO.setDeviceModel(dataJson.getString("device_model"));
                    iotDeviceDO.setDeviceSource("2"); //设备来源为居民绑定
@ -90,7 +89,6 @@ public class DataInputService {
                iotDeviceService.bindUser(deviceDOList);
                //保存日志
                dataProcessLogService.saveLog("","",data_source,"", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss),"1","4","com.yihu.iot.datainput.service.DataInputService.bindUser",DataOperationTypeEnum.bindUser.getName(),0);
            }
        }catch (Exception e){
            logger.error("注册绑定失败");
@ -109,6 +107,12 @@ public class DataInputService {
        if(null != iotDeviceDO){
            iotDeviceDO.setUpdateUser(idcard);
            iotDeviceDO.setUpdateUserName(username);
        }else{
            iotDeviceDO = new IotDeviceDO();
            iotDeviceDO.setDeviceSource(data_source);
            iotDeviceDO.setDeviceSn(deviveSn);
            iotDeviceDO.setCreateUser(idcard);
            iotDeviceDO.setCreateUserName(username);
        }
        iotDeviceService.save(iotDeviceDO);
        //保存日志
@ -150,10 +154,11 @@ public class DataInputService {
        //将数据存入es
        jsonObject.put("_id", new SaveModel().getId());//es的id继承至jestId
        jsonObject.put("id", rowkey);//hbase的rowkey
        elastricSearchHelper.save(esIndex, esType, jsonObject.toJSONString());
        elastricSearchHelper.save(ConstantUtils.esIndex, ConstantUtils.esType, jsonObject.toJSONString());
        Map<String, Map<String, String>> family = new HashMap<>();
//        List<Map<String, String>> columnsA = new ArrayList<>();
        Map<String, String> columnsA = new HashMap<>();
        Map<String, String> columnsB = new HashMap<>();
        //组装A列
@ -163,7 +168,7 @@ public class DataInputService {
        columnsA.put("ext_code",extCode);
        columnsA.put("device_name",jsonObject.getString("device_name"));
        columnsA.put("device_model",jsonObject.getString("device_model"));
        family.put(familyA,columnsA);
        family.put(ConstantUtils.tableName,columnsA);
        JSONArray jsonArray = jsonObject.getJSONArray("data");
        if(null == jsonArray || jsonArray.size() == 0){
@ -179,17 +184,22 @@ public class DataInputService {
               fileName = data.getString("fileName");
               fileAbsPath = data.getString("filepath");
           }
//            columnsA.add(columnsB);
        }
        family.put(familyB,columnsB);
        family.put(ConstantUtils.familyB, columnsB);
        try {
            hBaseHelper.add(tableName,rowkey,family);
            boolean tableExists = hBaseAdmin.isTableExists(ConstantUtils.tableName);
            if (!tableExists) {
                hBaseAdmin.createTable(ConstantUtils.tableName,ConstantUtils.familyA,ConstantUtils.familyB);
            }
            hBaseHelper.add(ConstantUtils.tableName, rowkey, family);
        } catch (Exception e) {
            e.printStackTrace();
            //保存日志
            dataProcessLogService.saveLog(fileName,fileAbsPath,dataSource,"", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss),"1","3","com.yihu.iot.datainput.service.DataInputService.uploadData", DataOperationTypeEnum.upload1.getName(),1);
            dataProcessLogService.saveLog(fileName, fileAbsPath, dataSource, "", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss), "1", "3", "com.yihu.iot.datainput.service.DataInputService.uploadData", DataOperationTypeEnum.upload1.getName(), 1);
        }
        //保存日志
        dataProcessLogService.saveLog(fileName,fileAbsPath,dataSource,"", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss),"1","4","com.yihu.iot.datainput.service.DataInputService.uploadData",DataOperationTypeEnum.upload1.getName(),0);
        dataProcessLogService.saveLog(fileName, fileAbsPath, dataSource, "", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss), "1", "4", "com.yihu.iot.datainput.service.DataInputService.uploadData", DataOperationTypeEnum.upload1.getName(), 0);
        return "success";
    }

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataProcessLogService.java

@ -31,7 +31,7 @@ public class DataProcessLogService extends BaseJpaService<DataProcessLogDO,DataP
        dataProcessLog.setUploadTime(uploadTime);
        dataProcessLog.setProcessType(processType);
        dataProcessLog.setProcessStatus(status);
        dataProcessLog.setProcessInterface(processInterface);
//        dataProcessLog.setProcessInterface(processInterface);
        dataProcessLog.setProcessDes(desc);
        dataProcessLog.setFileCount(failCount);
        dataProcessLogDao.save(dataProcessLog);

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

@ -0,0 +1,35 @@
package com.yihu.iot.datainput.service;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.base.hbase.HBaseHelper;
import com.yihu.iot.datainput.util.ConstantUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class DataSearchService {
    private Logger logger = LoggerFactory.getLogger(DataSearchService.class);
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    @Autowired
    private HBaseHelper hBaseHelper;
    /**
     * 获取数据
     * @param json
     * @return
     */
  /*  public String getData(String json){
        String result = elastricSearchHelper.search(ConstantUtils.esIndex,ConstantUtils.esType,json);
        if(null == result){
            return "no data";
        }
        return result;
    }*/
}

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

@ -0,0 +1,12 @@
package com.yihu.iot.datainput.util;
public class ConstantUtils {
    public static String esIndex = "body_health_data";
    public static String esType = "signs_data";
    public static String tableName = "body_health_data";
    public static String familyA = "column_signs_header";
    public static String familyB = "column_signs_data";
}

+ 11 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java

@ -15,6 +15,17 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
    @Autowired
    private IotDeviceOrderDao iotDeviceOrderDao;
    /**
     * 新增
     * @param iotDeviceOrder
     * @return
     */
    public IotDeviceOrderDO create(IotDeviceOrderDO iotDeviceOrder) {
        iotDeviceOrder.setSaasId(getCode());
        return iotDeviceOrderDao.save(iotDeviceOrder);
    }
    public IotDeviceOrderDO findById(String id) {
        return iotDeviceOrderDao.findById(id);
    }

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDevicePurchaseService.java

@ -14,6 +14,18 @@ public class IotDevicePurchaseService extends BaseJpaService<IotDevicePurchaseDO
    @Autowired
    private IotDevicePurchaseDao iotDevicePurchaseDao;
    /**
     * 新增
     * @param iotDevicePurchase
     * @return
     */
    public IotDevicePurchaseDO create(IotDevicePurchaseDO iotDevicePurchase) {
        iotDevicePurchase.setSaasId(getCode());
        iotDevicePurchase.setDel(1);
        return iotDevicePurchaseDao.save(iotDevicePurchase);
    }
    public IotDevicePurchaseDO findById(String id) {
        return iotDevicePurchaseDao.findById(id);
    }

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java

@ -15,6 +15,18 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
    @Autowired
    private IotDeviceQualityInspectionPlanDao iotDeviceQualityInspectionPlanDao;
    /**
     * 新增
     * @param iotDeviceQualityInspectionPlan
     * @return
     */
    public IotDeviceQualityInspectionPlanDO create(IotDeviceQualityInspectionPlanDO iotDeviceQualityInspectionPlan) {
        iotDeviceQualityInspectionPlan.setSaasId(getCode());
        iotDeviceQualityInspectionPlan.setDel(1);
        return iotDeviceQualityInspectionPlanDao.save(iotDeviceQualityInspectionPlan);
    }
    public IotDeviceQualityInspectionPlanDO findById(String id) {
        return iotDeviceQualityInspectionPlanDao.findById(id);
    }

+ 11 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -18,6 +18,17 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
    @Autowired
    private IotDeviceDao iotDeviceDao;
    /**
     * 新增
     * @param iotDevice
     * @return
     */
    public IotDeviceDO create(IotDeviceDO iotDevice) {
        iotDevice.setSaasId(getCode());
        return iotDeviceDao.save(iotDevice);
    }
    public IotDeviceDO findById(String id) {
        return iotDeviceDao.findById(id);
    }

+ 34 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/label/IotDeviceLabelInfoService.java

@ -0,0 +1,34 @@
package com.yihu.iot.service.label;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.iot.dao.label.IotDeviceLabelInfoDao;
import com.yihu.jw.iot.label.IotDeviceLabelInfoDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @author yeshijie on 2018/1/4.
 */
@Service
public class IotDeviceLabelInfoService extends BaseJpaService<IotDeviceLabelInfoDO,IotDeviceLabelInfoDao> {
    @Autowired
    private IotDeviceLabelInfoDao iotDeviceLabelInfoDao;
    public IotDeviceLabelInfoDO findById(String id) {
        return iotDeviceLabelInfoDao.findById(id);
    }
    /**
     * 新增
     * @param iotDeviceLabelInfo
     * @return
     */
    public IotDeviceLabelInfoDO create(IotDeviceLabelInfoDO iotDeviceLabelInfo) {
        iotDeviceLabelInfo.setSaasId(getCode());
        return iotDeviceLabelInfoDao.save(iotDeviceLabelInfo);
    }
}

+ 33 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/label/IotDeviceLabelService.java

@ -0,0 +1,33 @@
package com.yihu.iot.service.label;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.iot.dao.label.IotDeviceLabelDao;
import com.yihu.jw.iot.label.IotDeviceLabelDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @author yeshijie on 2018/1/4.
 */
@Service
public class IotDeviceLabelService extends BaseJpaService<IotDeviceLabelDO,IotDeviceLabelDao> {
    @Autowired
    private IotDeviceLabelDao iotDeviceLabelDao;
    public IotDeviceLabelDO findById(String id) {
        return iotDeviceLabelDao.findById(id);
    }
    /**
     * 新增
     * @param iotDeviceLabel
     * @return
     */
    public IotDeviceLabelDO create(IotDeviceLabelDO iotDeviceLabel) {
        iotDeviceLabel.setSaasId(getCode());
        return iotDeviceLabelDao.save(iotDeviceLabel);
    }
}

+ 5 - 14
svr/svr-iot/src/main/resources/application.yml

@ -27,14 +27,15 @@ spring:
  data:
    elasticsearch: #ElasticsearchProperties
      cluster-name: jkzl #默认即为elasticsearch  集群名
      cluster-nodes: 172.17.110.217:9300,172.17.110.128:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      cluster-nodes: 172.19.103.45:9300,172.19.103.68:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      local: false #是否本地连接
#      properties: # Additional properties used to configure the client.
      properties: # Additional properties used to configure the client.
        enable: true
  # JEST (Elasticsearch HTTP client) (JestProperties)
  elasticsearch:
    jest:
      uris: http://localhost:9200
      uris: http://172.19.103.45:9200,http://172.19.103.68:9200
#      uris: http://172.19.103.68:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
#      username: # Login user.
@ -63,16 +64,6 @@ fast-dfs:
    max-size: 20
    wait-time: 500
#es配置
es:
  host:  127.0.0.1
  port: 9200 #默认是9200
  tPort: 9300 #http端口 默认是9300
  clusterName: jkzl
hadoop:
  hbase-properties:

+ 16 - 21
web-gateway/pom.xml

@ -32,10 +32,10 @@
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-security</artifactId>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.yihu.base</groupId>-->
            <!--<artifactId>common-security</artifactId>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
@ -56,24 +56,24 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
      <!--  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
        </dependency>-->
        <!--<dependency>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-starter-security</artifactId>-->
        <!--</dependency>-->
     <!--   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        </dependency>-->
        <dependency>
      <!--  <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
        </dependency>
        </dependency>-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
@ -121,11 +121,11 @@
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
    <!--    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>RELEASE</version>
        </dependency>
        </dependency>-->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
@ -134,11 +134,6 @@
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-security</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/aspect/LogAspect.java

@ -38,7 +38,7 @@ public class LogAspect {
            tracer.getCurrentSpan().tag(GatewayContanrts.ZipkinElasticKey.gateway_input_params,new JSONObject(request.getParameterMap()).toString());
            o = point.proceed();
            //访问后日志
            tracer.getCurrentSpan().tag(GatewayContanrts.ZipkinElasticKey.gateway_out_params,new JSONObject(o.toString()).toString());
            tracer.getCurrentSpan().tag(GatewayContanrts.ZipkinElasticKey.gateway_out_params,new JSONObject(o).toString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }

+ 21 - 18
web-gateway/src/main/java/com/yihu/jw/commnon/base/user/BaseUserContants.java

@ -6,14 +6,16 @@ public class BaseUserContants {
    public static final String api_common = "/bases";
    public static final String api_baseRole = api_common+"/baseRole";
    public static final String api_employ = api_common+"/employee";
    public static final String api_baseMenu= api_common+"/employee";
    public static final String api_baseMenu= api_common+"/baseMenu";
    public static final String api_baseRoleMenu= api_common+"/baseRoleMenu";
    public static final String api_employRole= api_common+"/employeeRole";
    //角色常量
    public static class BaseRole{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_update="/update";
        public static final String api_delete="/delete/{id}";
        public static final String api_getById="/getById/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
    }
@ -21,37 +23,38 @@ public class BaseUserContants {
    //角色菜单常量
    public static class BaseRoleMenu{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_create=api_baseRoleMenu ;
        public static final String api_update=api_baseRoleMenu + "/update";
        public static final String api_delete=api_baseRoleMenu + "/delete/{id}";
        public static final String api_getListNoPage=api_baseRoleMenu + "/listNoPage";
    }
    //用户常量
    public static class Employee{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_update="/update";
        public static final String api_delete="/delete/{id}";
        public static final String api_getById="/getById/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
    }
    //用户角色常量
    public static class EmployeeRole{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_create= api_employRole;
        public static final String api_update= api_employRole + "/update";
        public static final String api_delete= api_employRole +"/delete/{id}";
        public static final String api_getListNoPage= api_employRole +"/listNoPage";
    }
    //菜单常量
    public static class BaseMenu{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_update="/update";
        public static final String api_delete="/delete/{id}";
        public static final String api_getById="/getById/{id}";
        public static final String api_children="/{saasId}/{parentId}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
    }

+ 6 - 6
web-gateway/src/main/java/com/yihu/jw/commnon/iot/DataConstants.java

@ -1,18 +1,18 @@
package com.yihu.jw.commnon.iot;
public class DataConstants {
    public static final String iot = "iot";
    public static final String api_iot_common = "/svr-iot";
    //数据标准转换
    public static class DataConvert{
        public static final String api_common = iot + "/dataConvert";
        public static final String api_convert = "convert";
        public static final String api_common = api_iot_common + "/dataConvert";
        public static final String api_convert = "/convert";
    }
    //数据上传常量
    public static class DataInput {
        public static final String api_common = iot + "/dataInput";
        public static final String api_bind_user = "userBind";
        public static final String api_upload_data = "input";
        public static final String api_common = api_iot_common + "/dataInput";
        public static final String api_bind_user = "/userBind";
        public static final String api_upload_data = "/input";
    }
}

+ 40 - 40
web-gateway/src/main/java/com/yihu/jw/config/security/ClientService.java

@ -1,40 +1,40 @@
package com.yihu.jw.config.security;
import com.yihu.base.security.rbas.ClientServiceProvider;
import org.springframework.context.annotation.Primary;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Set;
/**
 * Created by chenweida on 2017/12/1.
 */
@Component("baseClientDetailsService")
@Primary
public class ClientService implements ClientServiceProvider {
    @Override
    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
//        SaasDO saasDO = saasDao.findByAppId(clientId);
//        if (saasDO == null) {
//            throw new ClientRegistrationException("用户没有注册");
//        }
        BaseClientDetails baseClientDetails = new BaseClientDetails();
        baseClientDetails.setClientId("cwd");
        baseClientDetails.setClientSecret("cwd");
        Set<String> strings = new HashSet<>();
        strings.add("password");
        strings.add("custom_password");
        strings.add("authorization_code");
        strings.add("refresh_token");
        baseClientDetails.setAuthorizedGrantTypes(strings);
        return baseClientDetails;
    }
}
//package com.yihu.jw.config.security;
//
//import com.yihu.base.security.rbas.ClientServiceProvider;
//import org.springframework.context.annotation.Primary;
//import org.springframework.security.oauth2.provider.ClientDetails;
//import org.springframework.security.oauth2.provider.ClientRegistrationException;
//import org.springframework.security.oauth2.provider.client.BaseClientDetails;
//import org.springframework.stereotype.Component;
//
//import java.util.HashSet;
//import java.util.Set;
//
///**
// * Created by chenweida on 2017/12/1.
// */
//@Component("baseClientDetailsService")
//@Primary
//public class ClientService implements ClientServiceProvider {
//
//    @Override
//    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
////        SaasDO saasDO = saasDao.findByAppId(clientId);
////        if (saasDO == null) {
////            throw new ClientRegistrationException("用户没有注册");
////        }
//        BaseClientDetails baseClientDetails = new BaseClientDetails();
//        baseClientDetails.setClientId("cwd");
//        baseClientDetails.setClientSecret("cwd");
//
//        Set<String> strings = new HashSet<>();
//        strings.add("password");
//        strings.add("custom_password");
//        strings.add("authorization_code");
//        strings.add("refresh_token");
//        baseClientDetails.setAuthorizedGrantTypes(strings);
//        return baseClientDetails;
//    }
//
//
//}

+ 48 - 48
web-gateway/src/main/java/com/yihu/jw/config/security/RbasService.java

@ -1,48 +1,48 @@
package com.yihu.jw.config.security;
import com.yihu.base.security.rbas.IRbasService;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import org.springframework.util.AntPathMatcher;
import javax.servlet.http.HttpServletRequest;
import java.util.HashSet;
import java.util.Set;
/**
 * Created by chenweida on 2017/12/5.
 * 判断用户是否有权限访问该路径
 */
@Service("rbasService")
public class RbasService implements IRbasService {
    private AntPathMatcher antPathMatcher = new AntPathMatcher();
    @Override
    public Boolean hasPerssion(HttpServletRequest request, Authentication authentication) {
        Object principal = authentication.getPrincipal();
        boolean hasPerssion = false;
        if (principal instanceof UserDetails) {
            //获取用户名字
            String username = ((UserDetails) principal).getUsername();
            //获取用户全部权限
            Set<String> uris = new HashSet<>();
            for (String uri : uris) {
                if (antPathMatcher.match(uri, request.getRequestURI())) {
                    hasPerssion = true;
                    break;
                }
            }
        }
        return true;
        //  return hasPerssion;
    }
    public Boolean hello() {
        return true;
    }
}
//package com.yihu.jw.config.security;
//
//import com.yihu.base.security.rbas.IRbasService;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.stereotype.Service;
//import org.springframework.util.AntPathMatcher;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.HashSet;
//import java.util.Set;
//
///**
// * Created by chenweida on 2017/12/5.
// * 判断用户是否有权限访问该路径
// */
//@Service("rbasService")
//public class RbasService implements IRbasService {
//
//    private AntPathMatcher antPathMatcher = new AntPathMatcher();
//
//
//    @Override
//    public Boolean hasPerssion(HttpServletRequest request, Authentication authentication) {
//        Object principal = authentication.getPrincipal();
//        boolean hasPerssion = false;
//        if (principal instanceof UserDetails) {
//            //获取用户名字
//            String username = ((UserDetails) principal).getUsername();
//
//
//            //获取用户全部权限
//            Set<String> uris = new HashSet<>();
//            for (String uri : uris) {
//                if (antPathMatcher.match(uri, request.getRequestURI())) {
//                    hasPerssion = true;
//                    break;
//                }
//            }
//        }
//        return true;
//        //  return hasPerssion;
//    }
//
//    public Boolean hello() {
//        return true;
//    }
//}

+ 61 - 61
web-gateway/src/main/java/com/yihu/jw/config/security/UserService.java

@ -1,61 +1,61 @@
package com.yihu.jw.config.security;
import com.yihu.jw.feign.base.user.EmployFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
/**
 * Created by chenweida on 2017/11/29.
 * 处理用户校验
 */
@Component
public class UserService implements UserDetailsService {
    @Autowired
    private PasswordEncoder passwordEncoder;
    @Autowired
    private EmployFeign employFeign;
    /**
     * 我们只需要把用户返回给spring-security 密码框架自己帮我们校验
     *
     * @param userName
     * @return
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
        if ("admin".equals(userName)) {
            System.out.printf("password:" + passwordEncoder.encode("123456"));
            return new User("admin",
                    passwordEncoder.encode("123456"),
                    true,
                    true,
                    true,
                    true
                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
            );
        } else if ((!StringUtils.isEmpty(userName))&&userName.length() == 11) {
            System.out.printf("password:" + passwordEncoder.encode("123456"));
            return new User("admin",
                    passwordEncoder.encode("123456"),
                    true,
                    true,
                    true,
                    true
                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
            );
        } else {
            throw new UsernameNotFoundException("用户不存在");
        }
    }
}
//package com.yihu.jw.config.security;
//
//
//import com.yihu.jw.feign.base.user.EmployFeign;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.authority.AuthorityUtils;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//
///**
// * Created by chenweida on 2017/11/29.
// * 处理用户校验
// */
//@Component
//public class UserService implements UserDetailsService {
//
//    @Autowired
//    private PasswordEncoder passwordEncoder;
//    @Autowired
//    private EmployFeign employFeign;
//
//    /**
//     * 我们只需要把用户返回给spring-security 密码框架自己帮我们校验
//     *
//     * @param userName
//     * @return
//     * @throws UsernameNotFoundException
//     */
//    @Override
//    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
//        if ("admin".equals(userName)) {
//            System.out.printf("password:" + passwordEncoder.encode("123456"));
//            return new User("admin",
//                    passwordEncoder.encode("123456"),
//                    true,
//                    true,
//                    true,
//                    true
//                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
//            );
//        } else if ((!StringUtils.isEmpty(userName))&&userName.length() == 11) {
//            System.out.printf("password:" + passwordEncoder.encode("123456"));
//            return new User("admin",
//                    passwordEncoder.encode("123456"),
//                    true,
//                    true,
//                    true,
//                    true
//                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
//            );
//        } else {
//            throw new UsernameNotFoundException("用户不存在");
//        }
//    }
//
//}

+ 4 - 4
web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseMenuController.java

@ -84,8 +84,8 @@ public class BaseMenuController extends EnvelopRestController {
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.BaseMenu.api_getById)
    @ApiOperation(value = "根据Id查找", notes = "根据uuid查找")
    @GetMapping(value = BaseUserContants.BaseMenu.api_children)
    @ApiOperation(value = "获取子菜单", notes = "根据父菜单id查找")
    public Envelop getChildren(@ApiParam(name = "saasId", value = "saasId") @RequestParam(value = "saasId", required = true) String saasId,
                               @ApiParam(name = "parentId", value = "parentId") @RequestParam(value = "parentId", required = true) String parentId) throws JiWeiException {
        return fegin.getChildren(saasId,parentId);
@ -96,7 +96,7 @@ public class BaseMenuController extends EnvelopRestController {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @RequestMapping(value = BaseUserContants.BaseMenu.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取功能列表(分页)")
    @ApiOperation(value = "获取菜单列表(分页)")
    public Envelop getBaseMenus(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,
@ -125,7 +125,7 @@ public class BaseMenuController extends EnvelopRestController {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.BaseMenu.api_getListNoPage)
    @ApiOperation(value = "获取功能列表,不分页")
    @ApiOperation(value = "获取菜单列表,不分页")
    public Envelop getListNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,

+ 2 - 2
web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseRoleController.java

@ -148,7 +148,7 @@ public class BaseRoleController extends EnvelopRestController {
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @PutMapping(value = BaseUserContants.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PutMapping(value = BaseUserContants.BaseRoleMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改角色菜单", notes = "修改角色菜单")
    public Envelop updateRoleMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
@ -160,7 +160,7 @@ public class BaseRoleController extends EnvelopRestController {
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @DeleteMapping(value = BaseUserContants.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @DeleteMapping(value = BaseUserContants.BaseRoleMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除角色菜单", notes = "删除角色菜单")
    public Envelop deleteRoleMenus(
            @ApiParam(name = "json_data", value = "", defaultValue = "")

+ 2 - 2
web-gateway/src/main/java/com/yihu/jw/controller/base/version/UserVersionController.java

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(BaseContants.api_common)
@Api(description = "灰度发布相关")
public class UserVersionController {
    @Autowired
    private UserVersionFeign userVersionFeign;
//    @Autowired
//    private UserVersionFeign userVersionFeign;
}

+ 32 - 32
web-gateway/src/main/java/com/yihu/jw/controller/login/LoginController.java

@ -1,33 +1,33 @@
package com.yihu.jw.controller.login;
import com.yihu.jw.config.security.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
/**
 * Created by chenweida on 2017/6/16.
 */
@RestController
@Api(value = "登陆相关操作", description = "登陆相关操作")
public class LoginController {
    @Autowired
    private Tracer tracer;
    @Autowired
    private UserService userService;
//    @GetMapping(value = "/employLogin", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "患者登陆", notes = "患者登陆")
//    public Envelop employLogin(
//            @ApiParam(name = "account", value = "账号", defaultValue = "")
//            @RequestParam(name = "account", required = true) String account,
//            @ApiParam(name = "password", value = "密码", defaultValue = "")
//            @RequestParam(name = "password", required = true) String password,
//            @ApiParam(name = "type", value = "登陆方式(默认1):1账号密码 2账号验证码", defaultValue = "")
//            @RequestParam(name = "type", required = false, defaultValue = "1") Integer type) throws Exception {
//package com.yihu.jw.controller.login;
//
//        return null;
//    }
}
//import com.yihu.jw.config.security.UserService;
//import io.swagger.annotations.Api;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.sleuth.Tracer;
//import org.springframework.web.bind.annotation.*;
//
///**
// * Created by chenweida on 2017/6/16.
// */
//@RestController
//@Api(value = "登陆相关操作", description = "登陆相关操作")
//public class LoginController {
//    @Autowired
//    private Tracer tracer;
//    @Autowired
//    private UserService userService;
//
//
////    @GetMapping(value = "/employLogin", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "患者登陆", notes = "患者登陆")
////    public Envelop employLogin(
////            @ApiParam(name = "account", value = "账号", defaultValue = "")
////            @RequestParam(name = "account", required = true) String account,
////            @ApiParam(name = "password", value = "密码", defaultValue = "")
////            @RequestParam(name = "password", required = true) String password,
////            @ApiParam(name = "type", value = "登陆方式(默认1):1账号密码 2账号验证码", defaultValue = "")
////            @RequestParam(name = "type", required = false, defaultValue = "1") Integer type) throws Exception {
////
////        return null;
////    }
//}

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseMenuFeign.java

@ -25,7 +25,7 @@ public interface BaseMenuFeign {
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseMenu.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    Envelop delete(@PathVariable(value = "id") String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseMenu.api_getOne)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseRoleFeign.java

@ -25,7 +25,7 @@ public interface BaseRoleFeign {
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseRole.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    Envelop delete(@PathVariable(value = "id") String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployFeign.java

@ -27,7 +27,7 @@ public interface EmployFeign {
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseEmploy.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    Envelop delete(@PathVariable (value = "id") String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;

+ 2 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/version/UserVersionFeign.java

@ -1,6 +1,7 @@
package com.yihu.jw.feign.base.version;
import com.yihu.jw.feign.fallbackfactory.base.base.SaasFeignFallbackFactory;
import com.yihu.jw.feign.fallbackfactory.base.version.UserVersionFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.rm.base.BaseRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
@ -11,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = SaasFeignFallbackFactory.class
        ,fallbackFactory  = UserVersionFeignFallbackFactory.class
)
@RequestMapping(value = BaseRequestMapping.api_base_common)
public interface UserVersionFeign {

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseMenuFeignFallbackFactory.java

@ -7,12 +7,14 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@Component
public class BaseMenuFeignFallbackFactory implements FallbackFactory<BaseMenuFeign> {
    @Autowired

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseRoleFeignFallbackFactory.java

@ -6,12 +6,14 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@Component
public class BaseRoleFeignFallbackFactory implements FallbackFactory<BaseRoleFeign> {
    @Autowired

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/EmployeeFeignFallbackFactory.java

@ -6,12 +6,14 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by chenweida on 2017/11/29.
 */
@Component
public class EmployeeFeignFallbackFactory  implements FallbackFactory<EmployFeign> {
    @Autowired
    private Tracer tracer;

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/version/UserVersionFeignFallbackFactory.java

@ -2,10 +2,12 @@ package com.yihu.jw.feign.fallbackfactory.base.version;
import com.yihu.jw.feign.base.version.UserVersionFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
 * Created by chenweida on 2017/11/13.
 */
@Component
public class UserVersionFeignFallbackFactory implements FallbackFactory<UserVersionFeign> {
    @Override
    public UserVersionFeign create(Throwable cause) {

+ 2 - 1
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataInputFeignFallbackFactory.java

@ -5,8 +5,9 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
@Component
public class DataInputFeignFallbackFactory implements FallbackFactory<DataInputFeign> {
    @Autowired

+ 2 - 1
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataStandardConvertFeignFallbackFactory.java

@ -8,9 +8,10 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@Component
public class DataStandardConvertFeignFallbackFactory implements FallbackFactory<DataStandardConvertFeign> {
    @Autowired

+ 18 - 1
web-gateway/src/main/resources/application.yml

@ -1,7 +1,7 @@
##如果有配置服务的话,远程服务器和本地服务器配置不一致的情况下,优先远程的为主
spring:
  application:
    name:  web-gateway-lith  #注册到发现服务的id 如果id一样 eurika会自动做负载
    name:  web-gateway  #注册到发现服务的id 如果id一样 eurika会自动做负载
  http:
    multipart:
      enabled: true
@ -19,6 +19,23 @@ management:
  security:
    enabled: false  #关闭 refresh的权限认证
hystrix:
  threadpool:
    default:
      coreSize: 500  #并发执行的最大线程数,默认10
  command:
    paas-file:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 3600000
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 8000  #命令执行超时时间,默认1000ms
#zuul 默认会代理所有的微服务  路径 /{appliction.name}/**