Browse Source

物联网系统 完善注册、审核、产品功能

mengkang 5 years ago
parent
commit
eb00d3701e
16 changed files with 949 additions and 76 deletions
  1. 68 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyAppDO.java
  2. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java
  3. 61 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductBaseInfoDO.java
  4. 33 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductExtendInfoDO.java
  5. 6 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  6. 47 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyAppVO.java
  7. 31 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyVO.java
  8. 61 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductBaseInfoVO.java
  9. 32 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductExtendInfoVO.java
  10. 92 17
      svr/svr-iot/src/main/java/com/yihu/iot/controller/company/IotCompanyController.java
  11. 2 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java
  12. 18 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyAppDao.java
  13. 10 2
      svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyDao.java
  14. 3 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyCertificateService.java
  15. 333 55
      svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java
  16. 90 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/useragent/UserAgent.java

+ 68 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyAppDO.java

@ -0,0 +1,68 @@
package com.yihu.jw.entity.iot.company;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/27
 */
@Entity
@Table(name = "iot_company_app")
public class IotCompanyAppDO extends UuidIdentityEntityWithOperator implements Serializable {
    @Column(name = "saas_id")
    private String saasId;//
    @Column(name = "name")
    private String name;//应用名称',
    @Column(name = "company_id")
    private String companyId;//公司ID
    @Column(name = "company_name")
    private String companyName;
    @Column(name = "address_ip")
    private String addressIp;//访问IP地址
    @Column(name = "del")
    private String del;//是否删除 0:删除  1:不删除
    public IotCompanyAppDO() {
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saas_id) {
        this.saasId = saas_id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCompanyId() {
        return companyId;
    }
    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }
    public String getAddressIp() {
        return addressIp;
    }
    public void setAddressIp(String addressIp) {
        this.addressIp = addressIp;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
}

+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java

@ -62,6 +62,20 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
    @Transient
    private List<IotCompanyTypeDO> typeList;//类型
    //    新增加的字段
    @Column(name = "enter_type")
    private String enterType;//厂商入驻类型 1:供应商  2:代理商 3:厂商
    @Column(name = "account_type")
    private String accountType;//注册类型(1:厂商注册  0:平台注册)
    @Column(name = "audit_message")
    private String auditMessage;//审核不通过信息说明
    @Column(name = "audit_time")
    private Date auditTime;//审核时间
    @Column(name = "audit_name")
    private String auditName;//审核人姓名
    @Transient
    private List<IotCompanyAppDO> appList;//应用实体
    public String getSaasId() {
        return saasId;
    }
@ -230,4 +244,52 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
    public void setTypeList(List<IotCompanyTypeDO> typeList) {
        this.typeList = typeList;
    }
    public String getEnterType() {
        return enterType;
    }
    public void setEnterType(String enterType) {
        this.enterType = enterType;
    }
    public String getAccountType() {
        return accountType;
    }
    public void setAccountType(String accountType) {
        this.accountType = accountType;
    }
    public String getAuditMessage() {
        return auditMessage;
    }
    public void setAuditMessage(String auditMessage) {
        this.auditMessage = auditMessage;
    }
    public Date getAuditTime() {
        return auditTime;
    }
    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }
    public String getAuditName() {
        return auditName;
    }
    public void setAuditName(String auditName) {
        this.auditName = auditName;
    }
    public List<IotCompanyAppDO> getAppList() {
        return appList;
    }
    public void setAppList(List<IotCompanyAppDO> appList) {
        this.appList = appList;
    }
}

+ 61 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductBaseInfoDO.java

@ -62,6 +62,19 @@ public class IotProductBaseInfoDO extends UuidIdentityEntityWithOperator impleme
    private String certificateName;//授权书名称
    @Column(name = "del")
    private Integer del;//删除标志
    //以下为新增的字段
    @Column(name = "register_name")
    private String registerName;//注册名称
    @Column(name = "spec")
    private String spec;//规格
    @Column(name = "unit")
    private String unit;//单位
    @Column(name = "purchase_price")
    private Double purchasePrice;//进货价
    @Column(name = "retail_price")
    private Double retailPrice;//零售价格
    @Column(name = "category_code")
    private String categoryCode;//设备类型标识
    public String getSaasId() {
        return saasId;
@ -246,4 +259,52 @@ public class IotProductBaseInfoDO extends UuidIdentityEntityWithOperator impleme
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getRegisterName() {
        return registerName;
    }
    public void setRegisterName(String registerName) {
        this.registerName = registerName;
    }
    public String getSpec() {
        return spec;
    }
    public void setSpec(String spec) {
        this.spec = spec;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public Double getPurchasePrice() {
        return purchasePrice;
    }
    public void setPurchasePrice(Double purchasePrice) {
        this.purchasePrice = purchasePrice;
    }
    public Double getRetailPrice() {
        return retailPrice;
    }
    public void setRetailPrice(Double retailPrice) {
        this.retailPrice = retailPrice;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
}

+ 33 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductExtendInfoDO.java

@ -6,6 +6,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 产品扩展信息表
@ -36,6 +37,14 @@ public class IotProductExtendInfoDO extends UuidIdentityEntityWithOperator imple
    @Column(name = "del")
    private Integer del;//删除标志
    //以下为增加的字段
    @Column(name = "company_name")
    private String companyName;//生产企业名称
    @Column(name = "ratify_date")
    private Date ratifyDate;//批准日期
    @Column(name = "agency_name")
    private String agencyName;//代理人
    public String getSaasId() {
        return saasId;
    }
@ -115,4 +124,28 @@ public class IotProductExtendInfoDO extends UuidIdentityEntityWithOperator imple
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public Date getRatifyDate() {
        return ratifyDate;
    }
    public void setRatifyDate(Date ratifyDate) {
        this.ratifyDate = ratifyDate;
    }
    public String getAgencyName() {
        return agencyName;
    }
    public void setAgencyName(String agencyName) {
        this.agencyName = agencyName;
    }
}

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

@ -68,6 +68,10 @@ public class IotRequestMapping {
        public static final String findByBusinessLicense = "findByBusinessLicense";
        public static final String updCompany = "updCompany";
        public static final String delCompany = "delCompany";
        public static final String auditCompanyPass = "auditCompanyPass";
        public static final String auditCompanyNoPass = "auditCompanyNoPass";
        public static final String findAll = "findAll";
        public static final String enterType = "enterType";
        public static final String findCompanyCertPage = "findCompanyCertPage";
        public static final String findCompanyCertById = "findCompanyCertById";
@ -88,6 +92,8 @@ public class IotRequestMapping {
        public static final String message_success_find = "find success";
        public static final String message_success_create = "create success";
        public static final String message_success_find_functions = "find success";
        public static final String message_success_audit = "audit success";
        public static final String message_success_enterType = "enter success";
    }

+ 47 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyAppVO.java

@ -0,0 +1,47 @@
package com.yihu.jw.restmodel.iot.company;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
 * 企业应用表
 * @author suhaiwen on 2020/4/24.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "企业应用类", description = "企业应用表")
public class IotCompanyAppVO implements Serializable {
    @ApiModelProperty("应用ID")
    private String id;
    @ApiModelProperty("应用名称")
    private String name;
    @ApiModelProperty("访问IP地址")
    private String addressIp;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddressIp() {
        return addressIp;
    }
    public void setAddressIp(String addressIp) {
        this.addressIp = addressIp;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
}

+ 31 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyVO.java

@ -60,6 +60,13 @@ public class IotCompanyVO extends BaseVO implements Serializable {
    @ApiModelProperty("类型")
    private List<IotCompanyTypeVO> typeList;
    @ApiModelProperty("厂商入驻类型 1:供应商  2:代理商 3:厂商")
    private String enterType;//
    @ApiModelProperty("注册类型(1:厂商注册  0:平台注册)")
    private String accountType;
    @ApiModelProperty("应用")
    private List<IotCompanyAppVO> appList;
    public String getStatus() {
        return status;
    }
@ -219,4 +226,28 @@ public class IotCompanyVO extends BaseVO implements Serializable {
    public void setEhrUserId(String ehrUserId) {
        this.ehrUserId = ehrUserId;
    }
    public String getEnterType() {
        return enterType;
    }
    public void setEnterType(String enterType) {
        this.enterType = enterType;
    }
    public String getAccountType() {
        return accountType;
    }
    public void setAccountType(String accountType) {
        this.accountType = accountType;
    }
    public List<IotCompanyAppVO> getAppList() {
        return appList;
    }
    public void setAppList(List<IotCompanyAppVO> appList) {
        this.appList = appList;
    }
}

+ 61 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductBaseInfoVO.java

@ -71,6 +71,19 @@ public class IotProductBaseInfoVO extends BaseVO implements Serializable {
    private String certificateName;
    @ApiModelProperty("数据传输方式")
    private List<IotProductDataTransmissionVO> dataTransmissionVOList;
    //以下为新增加的字段
    @ApiModelProperty("注册名称")
    private String registerName;
    @ApiModelProperty("规格")
    private String spec;
    @ApiModelProperty("单位")
    private String unit;
    @ApiModelProperty("进货价")
    private Double purchasePrice;
    @ApiModelProperty("零售价格")
    private Double retailPrice;
    @ApiModelProperty("设备类型标识")
    private String categoryCode;
    public String getParentId() {
        return parentId;
@ -279,4 +292,52 @@ public class IotProductBaseInfoVO extends BaseVO implements Serializable {
    public void setOriginTypeName(String originTypeName) {
        this.originTypeName = originTypeName;
    }
    public String getRegisterName() {
        return registerName;
    }
    public void setRegisterName(String registerName) {
        this.registerName = registerName;
    }
    public String getSpec() {
        return spec;
    }
    public void setSpec(String spec) {
        this.spec = spec;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public Double getPurchasePrice() {
        return purchasePrice;
    }
    public void setPurchasePrice(Double purchasePrice) {
        this.purchasePrice = purchasePrice;
    }
    public Double getRetailPrice() {
        return retailPrice;
    }
    public void setRetailPrice(Double retailPrice) {
        this.retailPrice = retailPrice;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
}

+ 32 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductExtendInfoVO.java

@ -33,6 +33,14 @@ public class IotProductExtendInfoVO extends BaseVO implements Serializable {
    @ApiModelProperty("附件列表")
    private List<IotProductAttachmentVO> attachmentVOList;
    //以下为新增加字段
    @ApiModelProperty("生产企业名称")
    private String companyName;
    @ApiModelProperty("批准日期")
    private String ratifyDate;
    @ApiModelProperty("代理人")
    private String agencyName;
    public String getProductImg() {
        return productImg;
    }
@ -96,4 +104,28 @@ public class IotProductExtendInfoVO extends BaseVO implements Serializable {
    public void setAttachmentVOList(List<IotProductAttachmentVO> attachmentVOList) {
        this.attachmentVOList = attachmentVOList;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public String getRatifyDate() {
        return ratifyDate;
    }
    public void setRatifyDate(String ratifyDate) {
        this.ratifyDate = ratifyDate;
    }
    public String getAgencyName() {
        return agencyName;
    }
    public void setAgencyName(String agencyName) {
        this.agencyName = agencyName;
    }
}

+ 92 - 17
svr/svr-iot/src/main/java/com/yihu/iot/controller/company/IotCompanyController.java

@ -11,10 +11,15 @@ import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.ValidateActions;
import org.elasticsearch.common.recycler.Recycler;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@ -35,12 +40,12 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Company.findCompanyPage)
    @ApiOperation(value = "分页查找企业", notes = "分页查找企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findCompanyPage(@ApiParam(name = "name", value = "供应商名称或联系人姓名", defaultValue = "")
                                       @RequestParam(value = "name", required = false) String name,
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findCompanyPage(@ApiParam(name = "accountType", value = "注册类型", defaultValue = "")
                                       @RequestParam(value = "accountType", required = false) String accountType,
                                                    @ApiParam(name = "status", value = "审核状态", defaultValue = "")
                                       @RequestParam(value = "status", required = false) String status,
                                                    @ApiParam(name = "type", value = "企业类型", defaultValue = "")
                                       @RequestParam(value = "type", required = false) String type,
                                                    @ApiParam(name = "enterType", value = "入驻类型", defaultValue = "")
                                       @RequestParam(value = "enterType", required = false) String enterType,
                                                    @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                       @RequestParam(value = "page", required = false) Integer page,
                                                    @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
@ -52,10 +57,10 @@ public class IotCompanyController extends EnvelopRestEndpoint {
            if(size == null){
                size = 10;
            }
            if(StringUtils.isBlank(type)){
                return iotCompanyService.queryPage(page,size,status,name);
            if(StringUtils.isBlank(status)){
                return iotCompanyService.queryPage(page,size,accountType,enterType);
            }else {
                return iotCompanyService.queryPage(page,size,status,name,type);
                return iotCompanyService.queryPage(page,size,status,accountType,enterType);
            }
        } catch (Exception e) {
@ -71,13 +76,79 @@ public class IotCompanyController extends EnvelopRestEndpoint {
        try {
            IotCompanyVO iotCompanyVO = toEntity(jsonData, IotCompanyVO.class);
            IotCompanyDO iotCompany = iotCompanyService.convertToModelDO(iotCompanyVO);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create, iotCompanyService.create(iotCompany));
            iotCompanyService.create(iotCompany);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Company.auditCompanyPass)
    @ApiOperation(value = "通过审核",notes = "通过审核")
    public MixEnvelop<IotCompanyVO,IotCompanyVO> auditCompanyPass(@ApiParam(name = "id",value = "id") @RequestParam(value = "id",required = true)String id){
        try {
            return  iotCompanyService.auditCompany(id);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Company.auditCompanyNoPass)
    @ApiOperation(value = "审核失败",notes = "审核失败")
    public MixEnvelop<IotCompanyVO,IotCompanyVO> auditCompanyNoPass(@ApiParam(name = "id",value = "id") @RequestParam(value = "id",required = true)String id,
                                                                    @ApiParam(name = "msg",value = "拒绝说明") @RequestParam(value = "msg",required = true,defaultValue = "")String msg){
        try {
            return  iotCompanyService.auditCompany(id, msg);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Company.enterType)
    @ApiOperation(value = "根据入驻类型查找企业",notes = "根据入驻类型查找企业")
    public MixEnvelop<IotCompanyVO,IotCompanyVO> findByEnterType(@ApiParam(name = "entryCode",value = "入驻类型") @RequestParam(value = "entryCode",required = true)String entryCode){
        try {
            List<IotCompanyDO>  iotCompanyDOList = iotCompanyService.findByEnterType(entryCode);
            List<IotCompanyVO> iotCompanyVOList = new ArrayList<>();
            for (IotCompanyDO iotCompanyDO : iotCompanyDOList) {
                IotCompanyVO iotCompanyVO = iotCompanyService.convertToModelVO(iotCompanyDO);
                iotCompanyVOList.add(iotCompanyVO);
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_enterType,iotCompanyVOList);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Company.findAll)
    @ApiOperation(value = "查询所有企业", notes = "查询所有企业")
    public MixEnvelop<IotCompanyCertificateVO, IotCompanyCertificateVO> findAll(@ApiParam(name = "accountType", value = "注册类型" )
                                                                                       @RequestParam(value = "accountType", required = true)String accountType) {
        try {
           List<IotCompanyDO> iotCompanyDOList =  iotCompanyService.findAll(accountType);
            List<IotCompanyVO> iotCompanyVOList = new ArrayList<>();
            for (IotCompanyDO iotCompanyDO : iotCompanyDOList) {
                IotCompanyVO iotCompanyVO = iotCompanyService.convertToModelVO(iotCompanyDO);
                iotCompanyVOList.add(iotCompanyVO);
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find, iotCompanyVOList);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Company.findCompanyById)
    @ApiOperation(value = "根据id查找企业", notes = "根据id查找企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findByCode(@ApiParam(name = "id", value = "id")
@ -94,10 +165,12 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Company.findByBusinessLicense)
    @ApiOperation(value = "根据营业执照号查找企业", notes = "根据营业执照号查找企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findByBusinessLicense(@ApiParam(name = "businessLicense", value = "businessLicense")
                                            @RequestParam(value = "businessLicense", required = true) String businessLicense) {
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findByBusinessLicense(@ApiParam(name = "businessLicense", value = "营业执照号")
                                            @RequestParam(value = "businessLicense", required = true) String businessLicense,
                                               @ApiParam(name = "accountType", value = "注册类型")
                                            @RequestParam(value = "accountType", required = true) String accountType) {
        try {
            IotCompanyDO iotCompanyDO = iotCompanyService.findByBusinessLicense(businessLicense);
            IotCompanyDO iotCompanyDO = iotCompanyService.findByBusinessLicense(businessLicense,accountType);
            IotCompanyVO vo = iotCompanyService.convertToModelVO(iotCompanyDO);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find, vo);
        } catch (Exception e) {
@ -112,7 +185,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
                              @RequestParam(value = "id", required = true) String id) {
        try {
            iotCompanyService.delCompany(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -122,12 +195,14 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @PostMapping(value = IotRequestMapping.Company.updCompany)
    @ApiOperation(value = "修改企业信息", notes = "修改企业信息")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> updCompany(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                  @RequestParam(value = "jsonData", required = true)String jsonData) {
                                  @RequestParam(value = "jsonData", required = true)String jsonData,
                                                             @ApiParam(name = "accountType", value = "注册类型", defaultValue = "")
                                                             @RequestParam(value = "accountType", required = true)String accountType) {
        try {
            IotCompanyVO iotCompanyVO = toEntity(jsonData, IotCompanyVO.class);
            IotCompanyDO iotCompany = iotCompanyService.convertToModelDO(iotCompanyVO);
            iotCompanyService.updCompany(iotCompany);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find);
            iotCompanyService.updCompany(iotCompany,accountType);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -161,7 +236,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Company.findCompanyCertById)
    @ApiOperation(value = "根据id查找企业证书", notes = "根据id查找企业证书")
    public MixEnvelop<IotCompanyCertificateVO, IotCompanyCertificateVO> findCompanyCertById(@ApiParam(name = "id", value = "id")
    public MixEnvelop<IotCompanyCertificateVO, IotCompanyCertificateVO> findCompanyCertById(@ApiParam(name = "id", value = "证书ID")
                                            @RequestParam(value = "id", required = true) String id) {
        try {
            IotCompanyCertificateDO iotCompanyCertificateDO = iotCompanyCertificateService.findById(id);
@ -220,7 +295,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
                                                           @RequestParam(value = "id", required = true)String id) {
        try {
            iotCompanyCertificateService.delCompanyCert(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 2 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -179,7 +179,7 @@ public class IotProductController extends EnvelopRestEndpoint {
            if(re==-1){
                return MixEnvelop.getError("该产品已有关联订单,不允许删除",-1);
            }else {
                return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
                return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_delete);
            }
        } catch (Exception e) {
            e.printStackTrace();
@ -194,7 +194,7 @@ public class IotProductController extends EnvelopRestEndpoint {
        try {
            IotProductVO iotProductVO = toEntity(jsonData, IotProductVO.class);
            iotProductBaseInfoService.updProduct(iotProductVO);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 18 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyAppDao.java

@ -0,0 +1,18 @@
package com.yihu.iot.dao.company;
import com.yihu.jw.entity.iot.company.IotCompanyAppDO;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/24
 */
public interface IotCompanyAppDao extends PagingAndSortingRepository<IotCompanyAppDO, String>,
        JpaSpecificationExecutor<IotCompanyAppDO> {
        List<IotCompanyAppDO> findByCompanyId(String companyId);
        }

+ 10 - 2
svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyDao.java

@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 企业表
 * @author yeshijie on 2018/1/15.
@ -15,6 +17,12 @@ public interface IotCompanyDao extends PagingAndSortingRepository<IotCompanyDO,
    @Query("from IotCompanyDO w where w.id =?1 and w.del=1 ")
    IotCompanyDO findById(String id);
    @Query("from IotCompanyDO w where w.businessLicense =?1 and w.del=1")
    IotCompanyDO findByBusinessLicense(String businessLicense);
    @Query("from IotCompanyDO w where w.businessLicense =?1 and w.accountType=?2 and w.del=1")
    IotCompanyDO findByBusinessLicense(String businessLicense,String accountType);
    @Query("from IotCompanyDO w where w.accountType =?1 and w.del=1")
    List<IotCompanyDO> findByAccountType(String accountType);
    @Query("from IotCompanyDO w where w.enterType =?1 and w.status=1 and w.del=1")
    List<IotCompanyDO> findByEnterType(String entryType);
}

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyCertificateService.java

@ -112,6 +112,9 @@ public class IotCompanyCertificateService extends BaseJpaService<IotCompanyCerti
     */
    public void delCompanyCert(String id){
        IotCompanyCertificateDO companyCert = iotCompanyCertificateDao.findById(id);
        if(companyCert==null){
            throw new RuntimeException("证书已删除,请勿重复操作");
        }
        companyCert.setDel(0);
        iotCompanyCertificateDao.save(companyCert);
    }

+ 333 - 55
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -1,11 +1,15 @@
package com.yihu.iot.service.company;
import com.yihu.iot.dao.company.IotCompanyAppDao;
import com.yihu.iot.dao.company.IotCompanyCertificateChangeRecordDao;
import com.yihu.iot.dao.company.IotCompanyDao;
import com.yihu.iot.dao.company.IotCompanyTypeDao;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.company.IotCompanyAppDO;
import com.yihu.jw.entity.iot.company.IotCompanyCertificateChangeRecordDO;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.jw.entity.iot.company.IotCompanyTypeDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyAppVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.iot.company.IotCompanyTypeVO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
@ -38,33 +42,47 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
    private JdbcTemplate jdbcTempalte;
    @Autowired
    private IotCompanyCertificateChangeRecordDao iotCompanyCertificateChangeRecordDao;
    @Autowired
    private IotCompanyAppDao iotCompanyAppDao;
    @Autowired
    private UserAgent userAgent;
    /**
     * 分页查找
     * 审核通过 分页查找
     * @param page
     * @param size
     * @param status
     * @param name
     * @param accountType
     * @param enterType
     * @return
     * @throws ParseException
     */
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String name) throws ParseException {
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String accountType, String enterType) throws ParseException {
        String filters = "del=1;";
        String semicolon = "";
        if(StringUtils.isNotBlank(name)){
            filters += "name?"+name+" g1;contactsName?"+name+" g1";
        if(StringUtils.isNotBlank(accountType)){
            filters += "accountType?"+accountType;
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(status)){
            filters += semicolon +"status="+status;
        if(StringUtils.isNotBlank(enterType)){
            filters += semicolon +"enterType="+enterType;
            semicolon = ";";
        }
        String sorts = "-updateTime";
        //得到list数据
        String sorts = "-updateTime";//按更新时间降序
        List<IotCompanyDO> list = search(null, filters, sorts, page, size);
        list.forEach(one->{
            findType(one);
        });
        if(accountType.equalsIgnoreCase("1")){
            //得到list数据
            list.forEach(one->{
                findType(one);
            });
        }
        if(accountType.equalsIgnoreCase("0")){
            list.forEach(one->{
                findAppType(one);
            });
        }
        //获取总数
        long count = getCount(filters);
@ -84,8 +102,18 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        sources.forEach(one -> {
            IotCompanyVO target = new IotCompanyVO();
            BeanUtils.copyProperties(one, target);
            List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
            target.setTypeList(voList);
            if(target.getTypeList()!=null){
                List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
                target.setTypeList(voList);
            }
            if (target.getAppList()!=null){
                List<IotCompanyAppVO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppVO.class);
                target.setAppList(appList);
            }
//            List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
//            List<IotCompanyAppVO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppVO.class);
//            target.setTypeList(voList);
//            target.setAppList(appList);
            targets.add(target);
        });
        return targets;
@ -107,6 +135,10 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
            target.setTypeList(voList);
        }
        if (target.getAppList()!=null){
            List<IotCompanyAppVO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppVO.class);
            target.setAppList(appList);
        }
        return target;
    }
@ -123,8 +155,15 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        if(StringUtils.isNotBlank(iotCompanyVO.getBusinessStartTime())){
            target.setBusinessStartTime(DateUtil.strToDate(iotCompanyVO.getBusinessStartTime()));
        }
        List<IotCompanyTypeDO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeDO.class);
        target.setTypeList(voList);
        if (iotCompanyVO.getTypeList()!=null){
            List<IotCompanyTypeDO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeDO.class);
            target.setTypeList(voList);
        }
        if (iotCompanyVO.getAppList()!=null){
            List<IotCompanyAppDO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppDO.class);
            target.setAppList(appList);
        }
        return target;
    }
@ -133,11 +172,44 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * @param page
     * @param size
     * @param status
     * @param name
     * @param type
     * @param accountType
     * @param enterType
     * @return
     */
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String name, String type){
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String accountType, String enterType){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_company c WHERE c.del=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_company c  WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(status)){
            sql.append(" and c.status=? ");
            sqlCount.append(" and c.status='").append(status).append("' ");
            args.add(status);
        }
        if(StringUtils.isNotBlank(accountType)){
            sql.append(" and c.account_type=? ");
            sqlCount.append(" and c.account_type='").append(accountType).append("' ");
            args.add(accountType);
        }
        if(StringUtils.isNotBlank(enterType)){
            sql.append(" and c.enter_type=? ");
            sqlCount.append(" and c.enter_type='").append(enterType).append("' ");
            args.add(enterType);
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotCompanyDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotCompanyDO.class));
        list.forEach(one->{
            findType(one);
        });
        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        //DO转VO
        List<IotCompanyVO> iotCompanyVOList = convertToModelVOs(list,new ArrayList<>(list.size()));
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
    }
/*    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String name, String type){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_company c ,iot_company_type t WHERE c.del=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_company c ,iot_company_type t WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
@ -170,7 +242,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        List<IotCompanyVO> iotCompanyVOList = convertToModelVOs(list,new ArrayList<>(list.size()));
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
    }
    }*/
    /**
     * 新增
@ -178,23 +250,100 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * @return
     */
    public IotCompanyDO create(IotCompanyDO iotCompany) {
        iotCompany.setStatus("1");
        iotCompany.setSaasId(getCode());
        iotCompany.setDel(1);
        List<IotCompanyTypeDO> list = iotCompany.getTypeList();
        iotCompany = iotCompanyDao.save(iotCompany);
        String id = iotCompany.getId();
        //新增类型
        List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
        list.forEach(one->{
            IotCompanyTypeDO companyType = new IotCompanyTypeDO();
            companyType.setSaasId(getCode());
            companyType.setCompanyId(id);
            companyType.setType(one.getType());
            companyType.setTypeName(one.getTypeName());
            companyTypes.add(companyType);
        });
        iotCompanyTypeDao.save(companyTypes);
        if("1".equalsIgnoreCase(iotCompany.getAccountType())){
            //产商注册
            //1、判断企业名称是否已经注册
            List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
            for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                //判断营业执照号是否被注册
                if(iotCompany.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense())&&iotCompanyDO.getStatus().equalsIgnoreCase("1")){
                    throw new RuntimeException("该营业执照号已经注册,请使用其他执照");
                }
                if(iotCompany.getName().equalsIgnoreCase(iotCompanyDO.getName())){
                    //该公司重新申请注册,则删除原先注册信息
                    if(iotCompanyDO.getStatus().equalsIgnoreCase("2")){
                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(iotCompanyDO.getId());
                        iotCompanyAppDao.delete(apps);
                        iotCompanyDao.delete(iotCompanyDO);
                    }else {
                        throw new RuntimeException("该企业已经注册,请使用注册账号登录");
                    }
                }
            }
            //保存产商信息
            iotCompany.setStatus("0");//待审核
            iotCompany.setSaasId(getCode());
            iotCompany.setDel(1);
            iotCompany = iotCompanyDao.save(iotCompany);
            String id = iotCompany.getId();
            //新增类型
            List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
            list.forEach(one->{
                IotCompanyTypeDO companyType = new IotCompanyTypeDO();
                companyType.setSaasId(getCode());
                companyType.setCompanyId(id);
                companyType.setType(one.getType());
                companyType.setTypeName(one.getTypeName());
                companyTypes.add(companyType);
            });
            iotCompanyTypeDao.save(companyTypes);
        }
        if("0".equalsIgnoreCase(iotCompany.getAccountType())){
            List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
            for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                //判断营业执照号是否被注册
                if (iotCompany.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense()) && iotCompanyDO.getStatus().equalsIgnoreCase("1")) {
                    throw new RuntimeException("该营业执照号已经注册,请使用其他执照");
                }
            }
            //判断应用是否已经注册
            IotCompanyAppDO companyAppDO = iotCompany.getAppList().get(0);
            //查找所有应用名称
            Iterable<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAll();
            IotCompanyDO companyTemp = new IotCompanyDO();
            for (IotCompanyAppDO app : appDOList) {
                if(app.getName().equalsIgnoreCase(companyAppDO.getName())){
                    String companyId = app.getCompanyId();
                    IotCompanyDO companyDO = iotCompanyDao.findOne(companyId);
                    //该平台重新申请注册
                    if(iotCompany.getName().equalsIgnoreCase(companyDO.getName())&&companyDO.getStatus().equalsIgnoreCase("2")){
                        //查找该企业下的app
                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(companyDO.getId());
                        //保存注册信息获取CompangId
                         companyTemp = iotCompanyDao.save(iotCompany);
                        //遍历apps找出与注册相同的app
                        for (IotCompanyAppDO appDO : apps) {
                            if (appDO.getName().equalsIgnoreCase(companyAppDO.getName())){
                                appDO.setDel("0");
                                iotCompanyAppDao.save(appDO);
                            }
                            //更改公司ID
                            appDO.setCompanyId(companyTemp.getId());
                        }
                    }
                    throw new RuntimeException("该应用已经注册,请使用注册账号登录");
                }
            }
            //平台接入
            companyTemp.setStatus("0");//待审核
            companyTemp.setSaasId(getCode());
            companyTemp.setDel(1);
            iotCompany = iotCompanyDao.save(companyTemp);
            //保存应用
            String id = iotCompany.getId();
            IotCompanyAppDO iotCompanyAppDO = new IotCompanyAppDO();
            iotCompanyAppDO.setSaasId(getCode());
            iotCompanyAppDO.setCompanyId(id);
            iotCompanyAppDO.setCompanyName(iotCompany.getName());
            iotCompanyAppDO.setName(companyAppDO.getName());
            iotCompanyAppDO.setAddressIp(companyAppDO.getAddressIp());
            iotCompanyAppDO.setDel("1");
            iotCompanyAppDao.save(iotCompanyAppDO);
        }
        return iotCompany;
    }
@ -206,7 +355,14 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     */
    public IotCompanyDO findById(String id) {
        IotCompanyDO company = iotCompanyDao.findById(id);
        findType(company);
        String accountType = company.getAccountType();
        if ("1".equalsIgnoreCase(accountType)){
            findType(company);
        }
        if ("0".equalsIgnoreCase(accountType)){
            List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyId(company.getId());
            company.setAppList(appDOList);
        }
        return company;
    }
@ -215,8 +371,8 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * @param businessLincense
     * @return
     */
    public IotCompanyDO findByBusinessLicense(String businessLincense){
        return iotCompanyDao.findByBusinessLicense(businessLincense);
    public IotCompanyDO findByBusinessLicense(String businessLincense,String accountType){
        return iotCompanyDao.findByBusinessLicense(businessLincense,accountType);
    }
    /**
@ -241,6 +397,25 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        company.setTypeList(list);
    }
    public void findAppType(IotCompanyDO company){
        if(company==null){
            return;
        }
        //查找类型
        List<IotCompanyAppDO> appList = iotCompanyAppDao.findByCompanyId(company.getId());
        List<IotCompanyAppDO> list = new ArrayList<>(8);
        if(appList.size()>0){
            appList.forEach(one->{
                IotCompanyAppDO vo = new IotCompanyAppDO();
                vo.setName(one.getName());
                vo.setAddressIp(one.getAddressIp());
                vo.setId(one.getId());
                list.add(vo);
            });
        }
        company.setAppList(appList);
    }
    /**
     * 查找企业类型
     * @param companyId
@ -256,6 +431,9 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     */
    public void delCompany(String id){
        IotCompanyDO company = iotCompanyDao.findById(id);
        if (company==null){
           throw new RuntimeException("该企业已删除,请勿重复操作");
        }
        company.setDel(0);
        iotCompanyDao.save(company);
    }
@ -264,22 +442,38 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * 修改
     * @param iotCompany
     */
    public void updCompany(IotCompanyDO iotCompany){
        //更新类型
        List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
        iotCompanyTypeDao.delete(typeList);
        List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
        iotCompany.getTypeList().forEach(one->{
            IotCompanyTypeDO companyType = new IotCompanyTypeDO();
            companyType.setSaasId(getCode());
            companyType.setCompanyId(iotCompany.getId());
            companyType.setType(one.getType());
            companyType.setTypeName(one.getTypeName());
            companyTypes.add(companyType);
        });
    public void updCompany(IotCompanyDO iotCompany,String accountType){
        
        if(accountType.equalsIgnoreCase("1")){
            //更新类型
            List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
            iotCompanyTypeDao.delete(typeList);
            List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
            iotCompany.getTypeList().forEach(one->{
                IotCompanyTypeDO companyType = new IotCompanyTypeDO();
                companyType.setSaasId(getCode());
                companyType.setCompanyId(iotCompany.getId());
                companyType.setType(one.getType());
                companyType.setTypeName(one.getTypeName());
                companyTypes.add(companyType);
            });
        iotCompanyTypeDao.save(companyTypes);
            iotCompanyTypeDao.save(companyTypes);
        }
        //更新应用
        if(accountType.equalsIgnoreCase("0")){
            IotCompanyAppDO newApp = iotCompany.getAppList().get(0);
            IotCompanyAppDO oldApp = iotCompanyAppDao.findOne(newApp.getId());
            oldApp.setAddressIp(newApp.getAddressIp());
            oldApp.setName(newApp.getName());
            oldApp.setId(newApp.getId());
            oldApp.setCompanyId(iotCompany.getId());
            oldApp.setCompanyName(iotCompany.getName());
            oldApp.setSaasId(getCode());
            iotCompanyAppDao.save(oldApp);
        }
       
        //记录三证变更记录
        IotCompanyDO iotCompanyOld = iotCompanyDao.findById(iotCompany.getId());
@ -328,6 +522,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        }
        //修改企业记录
        iotCompanyOld.setEnterType(iotCompany.getEnterType());
        iotCompanyOld.setName(iotCompany.getName());
        iotCompanyOld.setIsThreeInOne(iotCompany.getIsThreeInOne());
        iotCompanyOld.setBusinessLicense(iotCompany.getBusinessLicense());
@ -361,4 +556,87 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            return true;
        }
    }
    /**
     * 通过审核
     * @param id 企业ID
     * @return
     */
    public MixEnvelop auditCompany(String id) {
        IotCompanyDO companyDO = findById(id);
        if (companyDO==null){
        }
        String uname = userAgent.getUNAME();
        if (uname==null){
            companyDO.setAuditName("system");
        }
        companyDO.setStatus("1");
        companyDO.setAuditTime(DateUtil.getNowDate());
        companyDO.setAuditName(uname);
        iotCompanyDao.save(companyDO);
        return MixEnvelop.getSuccess("审核操作成功");
    }
    /**
     * 审核失败
     * @param id 企业ID
     * @param msg 拒绝说明
     * @return
     */
    public MixEnvelop auditCompany(String id,String msg) {
        IotCompanyDO companyDO = findById(id);
        if (companyDO==null){
            return MixEnvelop.getError("无该企业");
        }
        String uname = userAgent.getUNAME();
        if (uname==null){
            companyDO.setAuditName("system");
        }
        companyDO.setStatus("2");
        companyDO.setAuditTime(DateUtil.getNowDate());
        companyDO.setAuditMessage(msg);
        companyDO.setAuditName(uname);
        iotCompanyDao.save(companyDO);
        return MixEnvelop.getSuccess("审核操作成功");
    }
    /**
     * 根据入驻类型查找企业信息
     * @param entryCode 入驻类型
     * @return
     */
    public List<IotCompanyDO> findByEnterType(String entryCode) {
        List<IotCompanyDO> companyDOList = iotCompanyDao.findByEnterType(entryCode);
        for (IotCompanyDO companyDO : companyDOList) {
            List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(companyDO.getId());
            companyDO.setTypeList(typeList);
        }
        return companyDOList;
    }
    /**
     * 查找所有企业
     * @param accountType 标识 1:厂商 0:平台
     * @return
     */
    public List<IotCompanyDO> findAll(String accountType) {
        List<IotCompanyDO> iotCompanyDOS = new ArrayList<>();
        if("1".equalsIgnoreCase(accountType)){
            iotCompanyDOS = iotCompanyDao.findByAccountType(accountType);
            for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                List<IotCompanyTypeDO> companyTypeDOS = iotCompanyTypeDao.findByCompanyId(iotCompanyDO.getId());
                iotCompanyDO.setTypeList(companyTypeDOS);
            }
        }
        if ("0".equalsIgnoreCase(accountType)){
            Iterable<IotCompanyDO> companyDOS = iotCompanyDao.findByAccountType(accountType);
            for (IotCompanyDO companyDO : companyDOS) {
                List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyId(companyDO.getId());
                companyDO.setAppList(appDOList);
                iotCompanyDOS.add(companyDO);
            }
        }
        return iotCompanyDOS;
    }
}

+ 90 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/useragent/UserAgent.java

@ -0,0 +1,90 @@
package com.yihu.iot.service.useragent;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
 * 用户头部信息获取
 * Created by Trick on 2018/10/30.
 */
@Component
public class UserAgent {
    /**
     * 获取当前登录人ID
     * @return
     */
    public String getUID() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            return json.getString("uid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取登录人姓名
     * @return
     */
    public String getUNAME(){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            String info = json.getString("uname");
            String uname = java.net.URLDecoder.decode(info,"UTF-8");
            return uname;
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取角色ID
     * @return
     */
    public String getROLEID() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            return json.getString("roleid");
        } catch (Exception e) {
            return null;
        }
    }
    public JSONObject getUserAgent(){
        try{
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            JSONObject user = JSON.parseObject(userAgent);
            return user;
        }catch (Exception e){
            return null;
        }
    }
}