Prechádzať zdrojové kódy

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

chenweida 7 rokov pred
rodič
commit
654c885798
33 zmenil súbory, kde vykonal 2052 pridanie a 3 odobranie
  1. 237 0
      common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceDO.java
  2. 182 0
      common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceOrderDO.java
  3. 181 0
      common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDevicePurchaseDO.java
  4. 182 0
      common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceQualityInspectionPlanDO.java
  5. 87 0
      common/common-entity/src/main/java/com/yihu/jw/iot/dict/IotDeviceDictDO.java
  6. 194 0
      common/common-entity/src/main/java/com/yihu/jw/iot/supplier/IotDeviceSupplierDO.java
  7. 137 0
      common/common-entity/src/main/java/com/yihu/jw/iot/supplier/IotSupplyDeviceDO.java
  8. 93 0
      common/common-entity/src/main/java/com/yihu/jw/iot/supplier/IotSupplyDeviceDataTypeDO.java
  9. 34 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  10. 1 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/CommonContants.java
  11. 1 0
      common/common-util/pom.xml
  12. 1 0
      svr/readme.MD
  13. 68 0
      svr/svr-iot/pom.xml
  14. 10 0
      svr/svr-iot/src/main/java/com/yihu/iot/IOTApplication.java
  15. 50 0
      svr/svr-iot/src/main/java/com/yihu/iot/config/SwaggerConfig.java
  16. 29 0
      svr/svr-iot/src/main/java/com/yihu/iot/config/jpa/HibernateProperties.java
  17. 55 0
      svr/svr-iot/src/main/java/com/yihu/iot/config/jpa/IotJpa.java
  18. 101 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/supplier/IotDeviceSupplierController.java
  19. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java
  20. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceOrderDao.java
  21. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDevicePurchaseDao.java
  22. 14 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java
  23. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/dict/IotDeviceDictDao.java
  24. 16 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotDeviceSupplierDao.java
  25. 13 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotSupplyDeviceDao.java
  26. 13 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/supplier/IotSupplyDeviceDataTypeDao.java
  27. 44 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/supplier/IotDeviceSupplierService.java
  28. 29 2
      svr/svr-iot/src/main/resources/application.yml
  29. 1 1
      svr/svr-iot/src/main/resources/bootstrap.yml
  30. 20 0
      web-gateway/src/main/java/com/yihu/jw/commnon/iot/SupplierContants.java
  31. 115 0
      web-gateway/src/main/java/com/yihu/jw/controller/iot/supplier/IotDeviceSupplierController.java
  32. 50 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/supplier/IotDeviceSupplierFeignFallbackFactory.java
  33. 46 0
      web-gateway/src/main/java/com/yihu/jw/feign/iot/supplier/IotDeviceSupplierFeign.java

+ 237 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceDO.java

@ -0,0 +1,237 @@
package com.yihu.jw.iot.device;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * @author yeshijie on 2017/12/1.
 */
@Entity
@Table(name = "iot_device")
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;//设备名称
    @Column(name = "device_model")
    private String deviceModel;//设备型号
    @Column(name = "device_sn")
    private String deviceSn;//设备sn码
    @Column(name = "is_composite")
    private Integer isComposite;//是否复合型(1是,0否即设备为单一功能)
    @Column(name = "is_platform")
    private Integer isPlatform;//是否平台型(1是,0否)
    @Column(name = "device_type")
    private String deviceType;//设备种类
    @Column(name = "device_source")
    private String deviceSource;//设备来源(1采购订单关联,2居民绑定,3管理员新增)
    @Column(name = "supplier_code")
    private String supplierCode;//供应商code
    @Column(name = "supplier_name")
    private String supplierName;//供应商名称
    @Column(name = "manufacturer_code")
    private String manufacturerCode;//厂商code
    @Column(name = "manufacturer_name")
    private String manufacturerName;//厂商名称
    @Column(name = "order_code")
    private String orderCode;//订单code
    @Column(name = "order_no")
    private String orderNo;//订单编号
    @Column(name = "status")
    private String status;//设备状态(正常、报废、检修)
    @Column(name = "next_quality_time")
    private Date nextQualityTime;//下次质检时间
    @Column(name = "purchase_code")
    private String purchaseCode;//采购code
    @Column(name = "sim_no")
    private String simNo;//sim卡号
    @Column(name = "del")
    private Integer del;//删除标志(1有效,0删除)
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public Integer getIsComposite() {
        return isComposite;
    }
    public void setIsComposite(Integer isComposite) {
        this.isComposite = isComposite;
    }
    public Integer getIsPlatform() {
        return isPlatform;
    }
    public void setIsPlatform(Integer isPlatform) {
        this.isPlatform = isPlatform;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public String getDeviceSource() {
        return deviceSource;
    }
    public void setDeviceSource(String deviceSource) {
        this.deviceSource = deviceSource;
    }
    public String getSupplierCode() {
        return supplierCode;
    }
    public void setSupplierCode(String supplierCode) {
        this.supplierCode = supplierCode;
    }
    public String getSupplierName() {
        return supplierName;
    }
    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }
    public String getManufacturerCode() {
        return manufacturerCode;
    }
    public void setManufacturerCode(String manufacturerCode) {
        this.manufacturerCode = manufacturerCode;
    }
    public String getManufacturerName() {
        return manufacturerName;
    }
    public void setManufacturerName(String manufacturerName) {
        this.manufacturerName = manufacturerName;
    }
    public String getOrderCode() {
        return orderCode;
    }
    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }
    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public Date getNextQualityTime() {
        return nextQualityTime;
    }
    public void setNextQualityTime(Date nextQualityTime) {
        this.nextQualityTime = nextQualityTime;
    }
    public String getPurchaseCode() {
        return purchaseCode;
    }
    public void setPurchaseCode(String purchaseCode) {
        this.purchaseCode = purchaseCode;
    }
    public String getSimNo() {
        return simNo;
    }
    public void setSimNo(String simNo) {
        this.simNo = simNo;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 182 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceOrderDO.java

@ -0,0 +1,182 @@
package com.yihu.jw.iot.device;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * @author yeshijie on 2017/12/1.
 */
@Entity
@Table(name = "iot_device_order")
public class IotDeviceOrderDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "order_no")
    private String orderNo;//订单编号
    @Column(name = "order_status")
    private String orderStatus;//订单状态
    @Column(name = "purchase_time")
    private Date purchaseTime;//采购时间
    @Column(name = "order_contract_name")
    private String orderContractName;//订单合同名称
    @Column(name = "order_contract_url")
    private String orderContractUrl;//订单合同链接
    @Column(name = "purchase_unit_code")
    private String purchaseUnitCode;//采购单位编码
    @Column(name = "purchase_unit_name")
    private String purchaseUnitName;//采购单位名称
    @Column(name = "purchaser_name")
    private String purchaserName;//采购负责人
    @Column(name = "purchaser_phone")
    private String purchaserPhone;//采购负责人联系方式
    @Column(name = "supplier_code")
    private String supplierCode;//供应商code
    @Column(name = "supplier_name")
    private String supplierName;//供应商名称
    @Column(name = "supplier_type")
    private String supplierType;//供应商类型
    @Column(name = "supplier_leader")
    private String supplierLeader;//供应商负责人
    @Column(name = "supplier_leader_phone")
    private String supplierLeaderPhone;//供应商负责人联系方式
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    public String getOrderStatus() {
        return orderStatus;
    }
    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }
    public Date getPurchaseTime() {
        return purchaseTime;
    }
    public void setPurchaseTime(Date purchaseTime) {
        this.purchaseTime = purchaseTime;
    }
    public String getOrderContractName() {
        return orderContractName;
    }
    public void setOrderContractName(String orderContractName) {
        this.orderContractName = orderContractName;
    }
    public String getOrderContractUrl() {
        return orderContractUrl;
    }
    public void setOrderContractUrl(String orderContractUrl) {
        this.orderContractUrl = orderContractUrl;
    }
    public String getPurchaseUnitCode() {
        return purchaseUnitCode;
    }
    public void setPurchaseUnitCode(String purchaseUnitCode) {
        this.purchaseUnitCode = purchaseUnitCode;
    }
    public String getPurchaseUnitName() {
        return purchaseUnitName;
    }
    public void setPurchaseUnitName(String purchaseUnitName) {
        this.purchaseUnitName = purchaseUnitName;
    }
    public String getPurchaserName() {
        return purchaserName;
    }
    public void setPurchaserName(String purchaserName) {
        this.purchaserName = purchaserName;
    }
    public String getPurchaserPhone() {
        return purchaserPhone;
    }
    public void setPurchaserPhone(String purchaserPhone) {
        this.purchaserPhone = purchaserPhone;
    }
    public String getSupplierCode() {
        return supplierCode;
    }
    public void setSupplierCode(String supplierCode) {
        this.supplierCode = supplierCode;
    }
    public String getSupplierName() {
        return supplierName;
    }
    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }
    public String getSupplierType() {
        return supplierType;
    }
    public void setSupplierType(String supplierType) {
        this.supplierType = supplierType;
    }
    public String getSupplierLeader() {
        return supplierLeader;
    }
    public void setSupplierLeader(String supplierLeader) {
        this.supplierLeader = supplierLeader;
    }
    public String getSupplierLeaderPhone() {
        return supplierLeaderPhone;
    }
    public void setSupplierLeaderPhone(String supplierLeaderPhone) {
        this.supplierLeaderPhone = supplierLeaderPhone;
    }
}

+ 181 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDevicePurchaseDO.java

@ -0,0 +1,181 @@
package com.yihu.jw.iot.device;
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/1.
 */
@Entity
@Table(name = "iot_device_purchase")
public class IotDevicePurchaseDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "order_code")
    private String orderCode;//订单code
    @Column(name = "order_no")
    private String orderNo;//订单编号
    @Column(name = "supplier_code")
    private String supplierCode;//供应商code
    @Column(name = "supplier_name")
    private String supplierName;//供应商名称
    @Column(name = "device_name")
    private String deviceName;//采购设备名称
    @Column(name = "device_model")
    private String deviceModel;//采购设备型号
    @Column(name = "device_type")
    private String deviceType;//设备种类
    @Column(name = "manufacturer_code")
    private String manufacturerCode;//厂商code
    @Column(name = "manufacturer_name")
    private String manufacturerName;//厂商名称
    @Column(name = "purchase_num")
    private Long purchaseNum;//采购数量
    @Column(name = "quality_cycle")
    private String qualityCycle;//质检周期
    @Column(name = "associated_num")
    private Long associatedNum;//已关联设备数量
    @Column(name = "unassociated_num")
    private Long unassociatedNum;//未关联设备数量
    @Column(name = "del")
    private Integer del;//删除标志
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getOrderCode() {
        return orderCode;
    }
    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }
    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    public String getSupplierCode() {
        return supplierCode;
    }
    public void setSupplierCode(String supplierCode) {
        this.supplierCode = supplierCode;
    }
    public String getSupplierName() {
        return supplierName;
    }
    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public String getManufacturerCode() {
        return manufacturerCode;
    }
    public void setManufacturerCode(String manufacturerCode) {
        this.manufacturerCode = manufacturerCode;
    }
    public String getManufacturerName() {
        return manufacturerName;
    }
    public void setManufacturerName(String manufacturerName) {
        this.manufacturerName = manufacturerName;
    }
    public Long getPurchaseNum() {
        return purchaseNum;
    }
    public void setPurchaseNum(Long purchaseNum) {
        this.purchaseNum = purchaseNum;
    }
    public String getQualityCycle() {
        return qualityCycle;
    }
    public void setQualityCycle(String qualityCycle) {
        this.qualityCycle = qualityCycle;
    }
    public Long getAssociatedNum() {
        return associatedNum;
    }
    public void setAssociatedNum(Long associatedNum) {
        this.associatedNum = associatedNum;
    }
    public Long getUnassociatedNum() {
        return unassociatedNum;
    }
    public void setUnassociatedNum(Long unassociatedNum) {
        this.unassociatedNum = unassociatedNum;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 182 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceQualityInspectionPlanDO.java

@ -0,0 +1,182 @@
package com.yihu.jw.iot.device;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * @author yeshijie on 2017/12/1.
 */
@Entity
@Table(name = "iot_device_quality_inspection_plan")
public class IotDeviceQualityInspectionPlanDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "purchase_code")
    private String purchaseCode;//采购code
    @Column(name = "order_code")
    private String orderCode;//订单code
    @Column(name = "order_no")
    private String orderNo;//订单编号
    @Column(name = "device_code")
    private String deviceCode;//设备code
    @Column(name = "device_name")
    private String deviceName;//设备名称
    @Column(name = "device_model")
    private String deviceModel;//设备型号
    @Column(name = "device_type")
    private String deviceType;//设备种类
    @Column(name = "purchase_num")
    private Long purchaseNum;//采购数量
    @Column(name = "quality_leader")
    private String qualityLeader;//质检负责人
    @Column(name = "quality_leader_phone")
    private String qualityLeaderPhone;//质检负责人联系方式
    @Column(name = "plan_time")
    private Date planTime;//计划质检时间
    @Column(name = "actual_time")
    private Date actualTime;//实际质检时间
    @Column(name = "status")
    private String status;//质检状态(1未检,2已检)
    @Column(name = "del")
    private Integer del;//删除标志
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getPurchaseCode() {
        return purchaseCode;
    }
    public void setPurchaseCode(String purchaseCode) {
        this.purchaseCode = purchaseCode;
    }
    public String getOrderCode() {
        return orderCode;
    }
    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }
    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    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 getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public Long getPurchaseNum() {
        return purchaseNum;
    }
    public void setPurchaseNum(Long purchaseNum) {
        this.purchaseNum = purchaseNum;
    }
    public String getQualityLeader() {
        return qualityLeader;
    }
    public void setQualityLeader(String qualityLeader) {
        this.qualityLeader = qualityLeader;
    }
    public String getQualityLeaderPhone() {
        return qualityLeaderPhone;
    }
    public void setQualityLeaderPhone(String qualityLeaderPhone) {
        this.qualityLeaderPhone = qualityLeaderPhone;
    }
    public Date getPlanTime() {
        return planTime;
    }
    public void setPlanTime(Date planTime) {
        this.planTime = planTime;
    }
    public Date getActualTime() {
        return actualTime;
    }
    public void setActualTime(Date actualTime) {
        this.actualTime = actualTime;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 87 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/dict/IotDeviceDictDO.java

@ -0,0 +1,87 @@
package com.yihu.jw.iot.dict;
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/1.
 */
@Entity
@Table(name = "iot_device_dict")
public class IotDeviceDictDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "device_type")
    private String deviceType;//设备种类
    @Column(name = "name")
    private String name;//设备种类名称
    @Column(name = "data_type")
    private String dataType;//测量数据种类
    @Column(name = "data_type_name")
    private String dataTypeName;//测量数据种类名称
    @Column(name = "del")
    private Integer del;//删除标志
    public IotDeviceDictDO() {
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDataType() {
        return dataType;
    }
    public void setDataType(String dataType) {
        this.dataType = dataType;
    }
    public String getDataTypeName() {
        return dataTypeName;
    }
    public void setDataTypeName(String dataTypeName) {
        this.dataTypeName = dataTypeName;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 194 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/supplier/IotDeviceSupplierDO.java

@ -0,0 +1,194 @@
package com.yihu.jw.iot.supplier;
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/1.
 */
@Entity
@Table(name = "iot_device_supplier")
public class IotDeviceSupplierDO extends IdEntityWithOperation implements Serializable{
    private static final long serialVersionUID = 41357656279822210L;
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "supplier_name")
    private String supplierName;//供应商名称
    @Column(name = "organization_code")
    private String organizationCode;//组织机构代码/统一社会信用代码
    @Column(name = "juridical_person_name")
    private String juridicalPersonName;//法定代表人/负责人姓名
    @Column(name = "organization_address")
    private String organizationAddress;//机构地址
    @Column(name = "office_phone")
    private String officePhone;//办公电话
    @Column(name = "contacts_name")
    private String contactsName;//联系人姓名
    @Column(name = "contacts_mobile")
    private String contactsMobile;//联系人手机号码
    @Column(name = "contacts_phone")
    private String contactsPhone;//联系人座机
    @Column(name = "contacts_idcard")
    private String contactsIdcard;//联系人身份证号
    @Column(name = "contacts_email")
    private String contactsEmail;//联系人邮件
    @Column(name = "type")
    private String type;//类型 1、供应商,2、厂商
    @Column(name = "organization_code_img")
    private String organizationCodeImg;//组织机构代码证照片
    @Column(name = "contacts_idcard_img")
    private String contactsIdcardImg;//联系人身份证照片
    @Column(name = "data_transmission_mode")
    private String dataTransmissionMode;//数据传输方式
    @Column(name = "del")
    private Integer del;//删除标志(1有效,0删除)
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getSupplierName() {
        return supplierName;
    }
    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }
    public String getOrganizationCode() {
        return organizationCode;
    }
    public void setOrganizationCode(String organizationCode) {
        this.organizationCode = organizationCode;
    }
    public String getJuridicalPersonName() {
        return juridicalPersonName;
    }
    public void setJuridicalPersonName(String juridicalPersonName) {
        this.juridicalPersonName = juridicalPersonName;
    }
    public String getOrganizationAddress() {
        return organizationAddress;
    }
    public void setOrganizationAddress(String organizationAddress) {
        this.organizationAddress = organizationAddress;
    }
    public String getOfficePhone() {
        return officePhone;
    }
    public void setOfficePhone(String officePhone) {
        this.officePhone = officePhone;
    }
    public String getContactsName() {
        return contactsName;
    }
    public void setContactsName(String contactsName) {
        this.contactsName = contactsName;
    }
    public String getContactsMobile() {
        return contactsMobile;
    }
    public void setContactsMobile(String contactsMobile) {
        this.contactsMobile = contactsMobile;
    }
    public String getContactsPhone() {
        return contactsPhone;
    }
    public void setContactsPhone(String contactsPhone) {
        this.contactsPhone = contactsPhone;
    }
    public String getContactsIdcard() {
        return contactsIdcard;
    }
    public void setContactsIdcard(String contactsIdcard) {
        this.contactsIdcard = contactsIdcard;
    }
    public String getContactsEmail() {
        return contactsEmail;
    }
    public void setContactsEmail(String contactsEmail) {
        this.contactsEmail = contactsEmail;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getOrganizationCodeImg() {
        return organizationCodeImg;
    }
    public void setOrganizationCodeImg(String organizationCodeImg) {
        this.organizationCodeImg = organizationCodeImg;
    }
    public String getContactsIdcardImg() {
        return contactsIdcardImg;
    }
    public void setContactsIdcardImg(String contactsIdcardImg) {
        this.contactsIdcardImg = contactsIdcardImg;
    }
    public String getDataTransmissionMode() {
        return dataTransmissionMode;
    }
    public void setDataTransmissionMode(String dataTransmissionMode) {
        this.dataTransmissionMode = dataTransmissionMode;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 137 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/supplier/IotSupplyDeviceDO.java

@ -0,0 +1,137 @@
package com.yihu.jw.iot.supplier;
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/1.
 */
@Entity
@Table(name = "iot_supply_device")
public class IotSupplyDeviceDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "name")
    private String name;//'设备名称
    @Column(name = "device_model")
    private String deviceModel;//型号
    @Column(name = "devie_type")
    private String deviceType;//设备种类
    @Column(name = "is_composite")
    private Integer isComposite;//是否复合型
    @Column(name = "is_platform")
    private Integer isPlatform;//是否平台型
    @Column(name = "device_sn")
    private String deviceSn;//设备编码
    @Column(name = "supplier_type")
    private String supplierType;//供应商类型
    @Column(name = "supplier_code")
    private String supplierCode;//供应商code
    @Column(name = "supplier_name")
    private String supplierName;//供应商名称
    @Column(name = "del")
    private Integer del;//删除标志(1有效,0删除)
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public Integer getIsComposite() {
        return isComposite;
    }
    public void setIsComposite(Integer isComposite) {
        this.isComposite = isComposite;
    }
    public Integer getIsPlatform() {
        return isPlatform;
    }
    public void setIsPlatform(Integer isPlatform) {
        this.isPlatform = isPlatform;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getSupplierType() {
        return supplierType;
    }
    public void setSupplierType(String supplierType) {
        this.supplierType = supplierType;
    }
    public String getSupplierCode() {
        return supplierCode;
    }
    public void setSupplierCode(String supplierCode) {
        this.supplierCode = supplierCode;
    }
    public String getSupplierName() {
        return supplierName;
    }
    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 93 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/supplier/IotSupplyDeviceDataTypeDO.java

@ -0,0 +1,93 @@
package com.yihu.jw.iot.supplier;
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/1.
 */
@Entity
@Table(name = "iot_supply_device_data_type")
public class IotSupplyDeviceDataTypeDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "supplier_device_code")
    private String supplierDeviceCode;//供应商设备code',
    @Column(name = "device_model")
    private String deviceModel;//设备型号',
    @Column(name = "device_type")
    private String deviceType;//设备种类',
    @Column(name = "data_type")
    private String dataType;//测量数据种类',
    @Column(name = "data_type_name")
    private String dataTypeName;//测量数据种类名称',
    @Column(name = "del")
    private Integer del;//
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getSupplierDeviceCode() {
        return supplierDeviceCode;
    }
    public void setSupplierDeviceCode(String supplierDeviceCode) {
        this.supplierDeviceCode = supplierDeviceCode;
    }
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public String getDataType() {
        return dataType;
    }
    public void setDataType(String dataType) {
        this.dataType = dataType;
    }
    public String getDataTypeName() {
        return dataTypeName;
    }
    public void setDataTypeName(String dataTypeName) {
        this.dataTypeName = dataTypeName;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

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

@ -0,0 +1,34 @@
package com.yihu.jw.rm.iot;
/**
 * @author yeshijie on 2017/12/5.
 */
public class IotRequestMapping {
    public static final String api_iot_common = "svr-iot";
    //协议模块常量
    public static class DeviceSupplier {
        public static final String api_create = "deviceSupplier";
        public static final String api_delete = "deviceSupplier";
        public static final String api_getById = "getDeviceSupplierById";
        public static final String api_update = "deviceSupplier";
        public static final String api_queryPage = "queryDeviceSupplierPage";
        public static final String api_getList = "getDeviceSupplierList";
        public static final String message_success_update = "deviceSupplier update success";
        public static final String message_success_delete = "deviceSupplier delete success";
        public static final String message_success_find = "deviceSupplier find success";
        public static final String message_success_create = "deviceSupplier create success";
        public static final String message_success_find_functions = "deviceSupplier find success";
        public static final String message_fail_name_is_null = "name is null";
        public static final String message_fail_price_is_null = "price is null";
        public static final String message_fail_iotDeviceSupplier_is_no_exist = "iotDeviceSupplier 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";
    }
}

+ 1 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/CommonContants.java

@ -7,6 +7,7 @@ public class CommonContants {
    //微服务的id start
    public static final String svr_base = "svr-base";
    public static final String svr_iot = "svr-iot";
    public static final String svr_wlyy = "svr-wlyy";
    public static final String svr_gateway = "svr-gateway";

+ 1 - 0
common/common-util/pom.xml

@ -9,6 +9,7 @@
        <version>1.0.0</version>
        <relativePath>../../common-lib-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>common-util</artifactId>
    <version>1.0.0</version>

+ 1 - 0
svr/readme.MD

@ -3,4 +3,5 @@ svr 相关的db设计
    svr-base 基础扩展服务,部分基础服务用ehr的
    svr-quota 统计相关服务
    svr-wlyy i健康公共业务后台
    svr-iot 医疗物联网服务
    svr-manage 基卫后台管理系统   (独立的系统不注册到发现服务)

+ 68 - 0
svr/svr-iot/pom.xml

@ -14,6 +14,38 @@
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-request-mapping</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-mysql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-log</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
@ -30,5 +62,41 @@
            <groupId>com.yihu.base</groupId>
            <artifactId>common-quartz</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>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
    </dependencies>
</project>

+ 10 - 0
svr/svr-iot/src/main/java/com/yihu/iot/IOTApplication.java

@ -1,7 +1,17 @@
package com.yihu.iot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
/**
 * Created by chenweida on 2017/11/27.
 */
@EnableJpaAuditing
@SpringBootApplication
public class IOTApplication {
    public static void main(String[] args) {
        SpringApplication.run(IOTApplication.class, args);
    }
}

+ 50 - 0
svr/svr-iot/src/main/java/com/yihu/iot/config/SwaggerConfig.java

@ -0,0 +1,50 @@
package com.yihu.iot.config;
import com.yihu.jw.rm.iot.IotRequestMapping;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableSwagger2
@ComponentScan("com.yihu.iot.**")
public class SwaggerConfig {
    public static final String Iot_API = "iot";
    @Bean
    public Docket iotAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(Iot_API)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(false)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/" + IotRequestMapping.api_iot_common + "/.*")
                ))
                .build()
                .apiInfo(iotApiInfo());
    }
    private ApiInfo iotApiInfo() {
        ApiInfo iotInfo = new ApiInfo("基卫2.0API",
                "基卫2.0API,提供医疗物联网相关服务。",
                "1.0",
                "No terms of service",
                "wenfujian@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return iotInfo;
    }
}

+ 29 - 0
svr/svr-iot/src/main/java/com/yihu/iot/config/jpa/HibernateProperties.java

@ -0,0 +1,29 @@
package com.yihu.iot.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
@RefreshScope
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 55 - 0
svr/svr-iot/src/main/java/com/yihu/iot/config/jpa/IotJpa.java

@ -0,0 +1,55 @@
package com.yihu.iot.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "iotEntityManagerFactory",
        transactionManagerRef = "iotTransactionManager",
        basePackages = {"com.yihu.iot.dao"})   //设置Repository所在位置
public class IotJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "iotEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.jw.iot");
        emfb.setPersistenceUnitName("iot");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "iotTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("iotEntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

+ 101 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/supplier/IotDeviceSupplierController.java

@ -0,0 +1,101 @@
package com.yihu.iot.controller.supplier;
import com.yihu.iot.service.supplier.IotDeviceSupplierService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.iot.supplier.IotDeviceSupplierDO;
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 2017/12/5.
 */
@RestController
@RequestMapping(IotRequestMapping.api_iot_common)
@Api(value = "供应商管理相关操作", description = "供应商管理相关操作")
public class IotDeviceSupplierController extends EnvelopRestController {
    @Autowired
    private IotDeviceSupplierService iotDeviceSupplierService;
    @PostMapping(value = IotRequestMapping.DeviceSupplier.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建供应商", notes = "创建供应商")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            IotDeviceSupplierDO iotDeviceSupplier = toEntity(jsonData, IotDeviceSupplierDO.class);
            return Envelop.getSuccess(IotRequestMapping.DeviceSupplier.message_success_create, iotDeviceSupplierService.create(iotDeviceSupplier));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceSupplier.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.DeviceSupplier.message_success_find, iotDeviceSupplierService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = IotRequestMapping.DeviceSupplier.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取供应商")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,patientCode,signCode,kpiCode,agreementCode,kpiName")
            @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,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<IotDeviceSupplierDO> list = iotDeviceSupplierService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=iotDeviceSupplierService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<IotDeviceSupplierDO> iotDeviceSuppliers = convertToModels(list, new ArrayList<>(list.size()), IotDeviceSupplierDO.class, fields);
        return Envelop.getSuccessListWithPage(IotRequestMapping.DeviceSupplier.message_success_find_functions,iotDeviceSuppliers, page, size,count);
    }
    @GetMapping(value = IotRequestMapping.DeviceSupplier.api_getList)
    @ApiOperation(value = "获取供应商列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,patientCode,signCode,kpiCode,agreementCode,kpiName")
            @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<IotDeviceSupplierDO> list = iotDeviceSupplierService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDeviceSupplierDO> iotDeviceSuppliers = convertToModels(list, new ArrayList<>(list.size()), IotDeviceSupplierDO.class, fields);
        return Envelop.getSuccessList(IotRequestMapping.DeviceSupplier.message_success_find_functions,iotDeviceSuppliers);
    }
}

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

@ -0,0 +1,12 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.iot.device.IotDeviceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceDao extends PagingAndSortingRepository<IotDeviceDO, Long>, JpaSpecificationExecutor<IotDeviceDO> {
}

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

@ -0,0 +1,12 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.iot.device.IotDeviceOrderDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceOrderDao extends PagingAndSortingRepository<IotDeviceOrderDO,Long>,JpaSpecificationExecutor<IotDeviceOrderDO> {
}

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

@ -0,0 +1,12 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.iot.device.IotDevicePurchaseDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDevicePurchaseDao extends PagingAndSortingRepository<IotDevicePurchaseDO,Long>,JpaSpecificationExecutor<IotDevicePurchaseDO> {
}

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

@ -0,0 +1,14 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.iot.device.IotDeviceQualityInspectionPlanDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceQualityInspectionPlanDao extends PagingAndSortingRepository<IotDeviceQualityInspectionPlanDO
        ,Long>,JpaSpecificationExecutor<IotDeviceQualityInspectionPlanDO> {
}

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

@ -0,0 +1,12 @@
package com.yihu.iot.dao.dict;
import com.yihu.jw.iot.dict.IotDeviceDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceDictDao extends PagingAndSortingRepository<IotDeviceDictDO,Long>,JpaSpecificationExecutor<IotDeviceDictDO> {
}

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

@ -0,0 +1,16 @@
package com.yihu.iot.dao.supplier;
import com.yihu.jw.iot.supplier.IotDeviceSupplierDO;
import com.yihu.jw.wlyy.agreement.WlyyAgreementKpiLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/5.
 */
public interface IotDeviceSupplierDao extends PagingAndSortingRepository<IotDeviceSupplierDO, Long>, JpaSpecificationExecutor<IotDeviceSupplierDO> {
    @Query("from IotDeviceSupplierDO w where w.id =?1")
    IotDeviceSupplierDO findById(String code);
}

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

@ -0,0 +1,13 @@
package com.yihu.iot.dao.supplier;
import com.yihu.jw.iot.supplier.IotSupplyDeviceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/5.
 */
public interface IotSupplyDeviceDao extends PagingAndSortingRepository<IotSupplyDeviceDO, Long>, JpaSpecificationExecutor<IotSupplyDeviceDO> {
}

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

@ -0,0 +1,13 @@
package com.yihu.iot.dao.supplier;
import com.yihu.jw.iot.supplier.IotSupplyDeviceDataTypeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/12/5.
 */
public interface IotSupplyDeviceDataTypeDao extends PagingAndSortingRepository<IotSupplyDeviceDataTypeDO, Long>, JpaSpecificationExecutor<IotSupplyDeviceDataTypeDO> {
}

+ 44 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/supplier/IotDeviceSupplierService.java

@ -0,0 +1,44 @@
package com.yihu.iot.service.supplier;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.iot.dao.supplier.IotDeviceSupplierDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.iot.supplier.IotDeviceSupplierDO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.util.Date;
/**
 * @author yeshijie on 2017/12/5.
 */
@Service
public class IotDeviceSupplierService extends BaseJpaService<IotDeviceSupplierDO,IotDeviceSupplierDao>{
    @Autowired
    private IotDeviceSupplierDao iotDeviceSupplierDao;
    @Transient
    public IotDeviceSupplierDO create(IotDeviceSupplierDO iotDeviceSupplier) {
        String saasId = iotDeviceSupplier.getSaasId();
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(IotRequestMapping.DeviceSupplier.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        //Saas saas = saasService.findByCode(saasId);
        //if(saas==null){
        //    throw new ApiException(BaseContants.Saas.message_fail_code_no_exist, ExceptionCode.common_error_params_code);
        //}
        //设置创建时间
        Date date = new Date();
        iotDeviceSupplier.setCreateTime(date);
        return iotDeviceSupplierDao.save(iotDeviceSupplier);
    }
    public IotDeviceSupplierDO findById(String id) {
        return iotDeviceSupplierDao.findById(id);
    }
}

+ 29 - 2
svr/svr-iot/src/main/resources/application.yml

@ -3,13 +3,40 @@ spring:
  application:
    name:  svr-iot  ##注册到发现服务的id 如果id一样 eurika会自动做负载
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 50
    max-idle: 50 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 30000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 50 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
#hibernate 配置
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
  ejb:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
---
spring:
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/xmiot?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: root
    password: 123456
---
spring:
  profiles: test

+ 1 - 1
svr/svr-iot/src/main/resources/bootstrap.yml

@ -20,7 +20,7 @@ eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/
---
spring:

+ 20 - 0
web-gateway/src/main/java/com/yihu/jw/commnon/iot/SupplierContants.java

@ -0,0 +1,20 @@
package com.yihu.jw.commnon.iot;
/**
 * @author yeshijie on 2017/12/5.
 */
public class SupplierContants {
    public static final String iot = "iot";
    //设备供应商常量
    public static class DeviceSupplier {
        public static final String api_common = iot + "/deviceSupplier";
        public static final String api_create = "create";
        public static final String api_update = "update";
        public static final String api_delete = "delete";
        public static final String api_getByCode = "getByCode";
        public static final String api_queryPage = "queryPage";
        public static final String api_getList = "getList";
    }
}

+ 115 - 0
web-gateway/src/main/java/com/yihu/jw/controller/iot/supplier/IotDeviceSupplierController.java

@ -0,0 +1,115 @@
package com.yihu.jw.controller.iot.supplier;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.commnon.iot.SupplierContants;
import com.yihu.jw.feign.iot.supplier.IotDeviceSupplierFeign;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * @author yeshijie on 2017/12/5.
 */
@RestController
@RequestMapping(SupplierContants.DeviceSupplier.api_common)
@Api(value = "供应商相关操作", description = "供应商相关操作")
public class IotDeviceSupplierController extends EnvelopRestController{
    private Logger logger = LoggerFactory.getLogger(IotDeviceSupplierController.class);
    @Autowired
    private IotDeviceSupplierFeign iotDeviceSupplierFeign;
    @Autowired
    private Tracer tracer;
    @PostMapping(value = SupplierContants.DeviceSupplier.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建供应商", notes = "创建供应商")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return iotDeviceSupplierFeign.create(jsonData);
    }
    @PutMapping(value = SupplierContants.DeviceSupplier.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改供应商", notes = "修改供应商")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return iotDeviceSupplierFeign.update(jsonData);
    }
    @DeleteMapping(value =SupplierContants.DeviceSupplier.api_delete)
    @ApiOperation(value = "删除供应商", notes = "删除供应商")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop delete(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        return iotDeviceSupplierFeign.delete(code);
    }
    @GetMapping(value =SupplierContants.DeviceSupplier.api_getByCode)
    @ApiOperation(value = "根据code查找供应商", notes = "根据code查找供应商")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        return iotDeviceSupplierFeign.findByCode(code);
    }
    @RequestMapping(value = SupplierContants.DeviceSupplier.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取供应商")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
            @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,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        return iotDeviceSupplierFeign.queryPage(fields,filters,sorts,size,page);
    }
    @GetMapping(value =SupplierContants.DeviceSupplier.api_getList)
    @ApiOperation(value = "获取供应商列表(不分页)")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
            @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 {
        return iotDeviceSupplierFeign.getList(fields,filters,sorts);
    }
}

+ 50 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/supplier/IotDeviceSupplierFeignFallbackFactory.java

@ -0,0 +1,50 @@
package com.yihu.jw.feign.fallbackfactory.iot.supplier;
import com.yihu.jw.feign.iot.supplier.IotDeviceSupplierFeign;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * @author yeshijie on 2017/12/5.
 */
@Component
public class IotDeviceSupplierFeignFallbackFactory implements FallbackFactory<IotDeviceSupplierFeign> {
    @Override
    public IotDeviceSupplierFeign create(Throwable throwable) {
        return new IotDeviceSupplierFeign() {
            @Override
            public Envelop create(@RequestBody String jsonData) {
                return null;
            }
            @Override
            public Envelop update(@RequestBody String jsonData) {
                return null;
            }
            @Override
            public Envelop delete(@RequestParam(value = "code") String code) {
                return null;
            }
            @Override
            public Envelop findByCode(@RequestParam(value = "code") String code) {
                return null;
            }
            @Override
            public Envelop queryPage(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts, @RequestParam(value = "size", required = false) int size, @RequestParam(value = "page", required = false) int page) {
                return null;
            }
            @Override
            public Envelop getList(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts) {
                return null;
            }
        };
    }
}

+ 46 - 0
web-gateway/src/main/java/com/yihu/jw/feign/iot/supplier/IotDeviceSupplierFeign.java

@ -0,0 +1,46 @@
package com.yihu.jw.feign.iot.supplier;
import com.yihu.jw.feign.fallbackfactory.iot.supplier.IotDeviceSupplierFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * @author yeshijie on 2017/12/5.
 */
@FeignClient(
        name = CommonContants.svr_iot // name值是eurika的实例名字
        ,fallbackFactory  = IotDeviceSupplierFeignFallbackFactory.class
)
@RequestMapping(IotRequestMapping.api_iot_common)
public interface IotDeviceSupplierFeign {
    @PostMapping(value = IotRequestMapping.DeviceSupplier.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop create(@RequestBody String jsonData);
    @PutMapping(value = IotRequestMapping.DeviceSupplier.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop update(@RequestBody String jsonData);
    @DeleteMapping(value = IotRequestMapping.DeviceSupplier.api_delete)
    Envelop delete( @RequestParam(value = "id") String id);
    @RequestMapping(value= IotRequestMapping.DeviceSupplier.api_getById,method = RequestMethod.GET)
    Envelop findByCode( @RequestParam(value = "id" ) String id);
    @RequestMapping(value = IotRequestMapping.DeviceSupplier.api_queryPage, method = RequestMethod.GET)
    Envelop queryPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
    @GetMapping(value = IotRequestMapping.DeviceSupplier.api_getList)
    Envelop getList(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts);
}