Explorar el Código

物联网后台系统 平台接口管理优化、企业管理优化

mengkang hace 5 años
padre
commit
67e8dc4ea0

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyAppDO.java

@ -22,11 +22,12 @@ public class IotCompanyAppDO extends UuidIdentityEntityWithOperator implements S
    @Column(name = "company_id")
    private String companyId;//公司ID
    @Column(name = "company_name")
    private String companyName;
    private String companyName;//公司名称
    @Column(name = "address_ip")
    private String addressIp;//访问IP地址
    @Column(name = "del")
    private String del;//是否删除 0:删除  1:不删除
    public IotCompanyAppDO() {
    }
    public String getSaasId() {

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

@ -370,6 +370,7 @@ public class IotRequestMapping {
        public static final String editInterface ="editInterface";
        public static final String findInterfaceById ="findInterfaceById";
        public static final String findAll ="findAll";
        public static final String findAllApp ="findAllApp";
        public static final String findAllLog ="findAllLog";
        public static final String findInterfaceLog ="findInterfaceLog";
        public static final String conditionQueryPage ="conditionQueryPage";
@ -380,6 +381,8 @@ public class IotRequestMapping {
        public static final String delCompanyById ="delCompanyById";
        public static final String allotInterface ="allotInterface";
        public static final String findAppInterface ="findAppInterface";
        public static final String delAppInterface ="delAppInterface";
        public static final String interfaceDoc ="interfaceDoc";
        public static final String message_success_add = "add success";
        public static final String message_success_edit = "edit success";

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

@ -21,6 +21,18 @@ public class IotCompanyAppVO implements Serializable {
    @ApiModelProperty("访问IP地址")
    private String addressIp;
    @ApiModelProperty("公司名称")
    private String companyName;
    @ApiModelProperty("公司ID")
    private String companyId;
    @ApiModelProperty("联系人电话")
    private String contactsMobile;
    @ApiModelProperty("联系人姓名")
    private String contactsName;
    public String getName() {
        return name;
    }
@ -44,4 +56,36 @@ public class IotCompanyAppVO implements Serializable {
    public void setId(String id) {
        this.id = id;
    }
    public String getCompanyName() {
        return companyName;
    }
    public String getCompanyId() {
        return companyId;
    }
    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }
    public String getContactsMobile() {
        return contactsMobile;
    }
    public void setContactsMobile(String contactsMobile) {
        this.contactsMobile = contactsMobile;
    }
    public String getContactsName() {
        return contactsName;
    }
    public void setContactsName(String contactsName) {
        this.contactsName = contactsName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
}

+ 48 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/platform/IotAppInterfacesVO.java

@ -18,9 +18,22 @@ import java.io.Serializable;
@ApiModel(value = "应用接口集合信息", description = "应用接口集合信息")
public class IotAppInterfacesVO  extends BaseVO implements Serializable {
    @ApiModelProperty("id")
    private String id;
    @ApiModelProperty("应用id")
    private String appId;
    @ApiModelProperty("应用名称")
    private String appName;
    @ApiModelProperty("公司名称")
    private String companyName;
    @ApiModelProperty("公司ID")
    private String companyId;
    @ApiModelProperty("共享接口信息")
    private IotShareInterfaceDO iotShareInterfaceDO;
@ -39,4 +52,39 @@ public class IotAppInterfacesVO  extends BaseVO implements Serializable {
    public void setIotShareInterfaceDO(IotShareInterfaceDO iotShareInterfaceDO) {
        this.iotShareInterfaceDO = iotShareInterfaceDO;
    }
    @Override
    public String getId() {
        return id;
    }
    @Override
    public void setId(String id) {
        this.id = id;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public String getCompanyId() {
        return companyId;
    }
    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }
}

+ 0 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/company/IotCompanyController.java

@ -349,5 +349,4 @@ public class IotCompanyController extends EnvelopRestEndpoint {
        }
    }
}

+ 41 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/platform/IotInterfaceController.java

@ -18,7 +18,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @author HZY
@ -89,7 +89,7 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
    @PostMapping(value = IotRequestMapping.Platform.findAll)
    @ApiOperation(value = "分页查询所有",notes = "分页查询所有")
    @ApiOperation(value = "分页查询所有共享接口",notes = "分页查询所有共享接口")
    public MixEnvelop<IotShareInterfaceDO,IotShareInterfaceDO> findAll(@ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                                           @RequestParam(value = "page", required = false) Integer page,
                                                                       @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
@ -324,4 +324,43 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = IotRequestMapping.Platform.findAllApp)
    @ApiOperation(value = "分页查询应用信息", notes = "分页查询应用信息")
    public MixEnvelop<IotAppInterfacesVO, IotAppInterfacesVO> findAllApp(@ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                                             @RequestParam(value = "page", required = false) Integer page,
                                                                             @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                             @RequestParam(value = "size", required = false) Integer size,
                                                                             @ApiParam(name = "name", value = "应用名称或公司名称", defaultValue = "")
                                                                             @RequestParam(value = "name",required = false) String name) {
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Platform.message_success_find, iotShareInterfaceService.findAllApp(page,size,name));
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Platform.interfaceDoc)
    @ApiOperation(value = "接口文档说明", notes = "接口文档说明")
    public MixEnvelop interfaceDoc( @ApiParam(name = "interfaceName", value = "接口名称", defaultValue = "")
                                        @RequestParam(value = "interfaceName") String interfaceName){
       String url =  iotShareInterfaceService.interfaceDoc(interfaceName);
       return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,url);
    }
}

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

@ -23,5 +23,4 @@ public interface IotCompanyAppDao extends PagingAndSortingRepository<IotCompanyA
        IotCompanyAppDO findById(String appId);
        }

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

@ -23,9 +23,10 @@ public interface IotCompanyDao extends PagingAndSortingRepository<IotCompanyDO,
    @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")
    @Query("from IotCompanyDO w where w.enterType =?1 and w.del=1")
    List<IotCompanyDO> findByEnterType(String entryType);
    @Query("from IotCompanyDO w where w.account =?1 and w.del=1")
    IotCompanyDO findByAccount(String account);
}

+ 61 - 59
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -44,7 +44,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
    /**
     * 审核通过 分页查找
     *分页查找
     * @param page
     * @param size
     * @param accountType
@ -87,6 +87,58 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
    }
    /**
     * 按类型分页查找
     * @param page
     * @param size
     * @param status
     * @param accountType
     * @param enterType
     * @return
     */
    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));
        if(accountType.equalsIgnoreCase("1")){
            //得到list数据
            list.forEach(one->{
                findType(one);
            });
        }
        if(accountType.equalsIgnoreCase("0")){
            list.forEach(one->{
                findAppType(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);
    }
    /**
     * 转换
     * @param sources
@ -162,56 +214,6 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        return target;
    }
    /**
     * 按类型分页查找
     * @param page
     * @param size
     * @param status
     * @param accountType
     * @param enterType
     * @return
     */
    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));
        if(accountType.equalsIgnoreCase("1")){
            //得到list数据
            list.forEach(one->{
                findType(one);
            });
        }
        if(accountType.equalsIgnoreCase("0")){
            list.forEach(one->{
                findAppType(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);
    }
    /**
     * 条件分页查找
@ -326,7 +328,6 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            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();
@ -336,7 +337,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
                        //查找该企业下的app
                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(companyDO.getId());
                        //保存注册信息获取CompangId
                         companyTemp = iotCompanyDao.save(iotCompany);
                       iotCompany.setId(getCode());
                        //遍历apps找出与注册相同的app
                        for (IotCompanyAppDO appDO : apps) {
                            if (appDO.getName().equalsIgnoreCase(companyAppDO.getName())){
@ -344,17 +345,17 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
                                iotCompanyAppDao.save(appDO);
                            }
                            //更改公司ID
                            appDO.setCompanyId(companyTemp.getId());
                            appDO.setCompanyId(iotCompany.getId());
                        }
                    }
                    return MixEnvelop.getError("该应用已经注册,请使用注册账号登录");
                }
            }
            //平台接入
            companyTemp.setStatus("0");//待审核
            companyTemp.setSaasId(getCode());
            companyTemp.setDel(1);
            iotCompany = iotCompanyDao.save(companyTemp);
            iotCompany.setStatus("0");//待审核
            iotCompany.setSaasId(getCode());
            iotCompany.setDel(1);
            iotCompany = iotCompanyDao.save(iotCompany);
            //保存应用
            String id = iotCompany.getId();
            IotCompanyAppDO iotCompanyAppDO = new IotCompanyAppDO();
@ -370,7 +371,8 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        iotCompany.setAccount(userAgent.getUNAME());
        iotCompany.setEhrUserId(userAgent.getUID());
        return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create,iotCompany);
        return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create,convertToModelVO(iotCompany));
    }
    /**

+ 8 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java

@ -450,7 +450,14 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
     */
    public MixEnvelop<IotDeviceOrderVO, IotDeviceOrderVO>  findAllOrderBySupplierName(Integer page, Integer size,String supplierName) {
        List<IotDeviceOrderDO> listDO = iotDeviceOrderDao.findAllBySupplierName(supplierName);
        StringBuffer sql = new StringBuffer("SELECT c.* from iot_device_order c  WHERE c.del=1 ");
        sql.append("and c.supplier_name like '%").append(supplierName).append("%'");
        sql.append(" order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotDeviceOrderDO> listDO = jdbcTempalte.query(sql.toString(),new BeanPropertyRowMapper(IotDeviceOrderDO.class));
        //DO转VO
        List<IotDeviceOrderVO> iotDeviceOrderVOList = new ArrayList<>();

+ 4 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java

@ -154,9 +154,11 @@ public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDevi
     */
    public MixEnvelop<IotDeviceSimDO, IotDeviceSimDO> findAllSim(Integer page, Integer size) {
        String sql="SELECT DISTINCT * FROM iot_device_sim ;";
        StringBuffer sql= new StringBuffer("SELECT DISTINCT * FROM iot_device_sim ");
        List<IotDeviceSimDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(IotDeviceSimDO.class));
        sql.append(" limit ").append((page-1)*size).append(",").append(size);
        List<IotDeviceSimDO> list = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(IotDeviceSimDO.class));
        //获取总数

+ 4 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/platform/IotCompanyAppInterfaceService.java

@ -69,6 +69,10 @@ public class IotCompanyAppInterfaceService extends BaseJpaService<IotCompanyAppI
            IotShareInterfaceDO shareInterfaceDO = iotShareInterfaceDao.findOne(shareInterfaceId);
            appInterfacesVO.setAppName(one.getAppName());
            appInterfacesVO.setAppId(one.getAppId());
            appInterfacesVO.setId(one.getId());
            appInterfacesVO.setCompanyId(one.getCompanyId());
            appInterfacesVO.setCompanyName(one.getCompanyName());
            appInterfacesVO.setIotShareInterfaceDO(shareInterfaceDO);
            list.add(appInterfacesVO);

+ 4 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/platform/IotInterfaceAuditService.java

@ -112,9 +112,11 @@ public class IotInterfaceAuditService  extends BaseJpaService<IotInterfaceAuditD
     */
    public MixEnvelop<IotInterfaceAuditDO, IotInterfaceAuditDO> findAllApplyFor(Integer page, Integer size) {
        String sql="SELECT DISTINCT * FROM iot_interface_audit ORDER BY time DESC;";
        StringBuffer sql= new StringBuffer("SELECT DISTINCT * FROM iot_interface_audit ORDER BY time DESC");
        List<IotInterfaceAuditDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(IotInterfaceAuditDO.class));
        sql.append(" limit ").append((page-1)*size).append(",").append(size);
        List<IotInterfaceAuditDO> list = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(IotInterfaceAuditDO.class));
        list.forEach(one->{
            IotCompanyDO company = iotCompanyDao.findOne(one.getCompanyId());

+ 20 - 7
svr/svr-iot/src/main/java/com/yihu/iot/service/platform/IotInterfaceLogService.java

@ -6,8 +6,11 @@ import com.yihu.iot.dao.platform.IotInterfaceLogDao;
import com.yihu.iot.dao.workType.IotWorkTypeDao;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.company.IotCompanyAppDO;
import com.yihu.jw.entity.iot.platform.IotCompanyAppInterfaceDO;
import com.yihu.jw.entity.iot.platform.IotInterfaceLogDO;
import com.yihu.jw.entity.iot.workType.IotWorkTypeDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyAppVO;
import com.yihu.jw.restmodel.iot.platform.IotAppInterfacesVO;
import com.yihu.jw.restmodel.iot.platform.IotInterfaceLogVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -64,10 +67,11 @@ public class IotInterfaceLogService extends BaseJpaService<IotInterfaceLogDO, Io
     */
    public MixEnvelop<IotInterfaceLogVO,IotInterfaceLogVO> findAll(Integer page, Integer size) throws ParseException {
        String sql = "SELECT * FROM (select * from iot_interface_log c where 1=1  ORDER BY c.time desc) b GROUP BY b.interface_name;";
        StringBuffer sql = new StringBuffer("SELECT * FROM (select * from iot_interface_log c where 1=1  ORDER BY c.time desc) b GROUP BY b.interface_name ");
        sql.append(" limit ").append((page-1)*size).append(",").append(size);
        List<IotInterfaceLogDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(IotInterfaceLogDO.class));
        List<IotInterfaceLogDO> list = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(IotInterfaceLogDO.class));
        ArrayList<IotInterfaceLogVO> resultList = new ArrayList<>();
@ -93,8 +97,15 @@ public class IotInterfaceLogService extends BaseJpaService<IotInterfaceLogDO, Io
    public MixEnvelop<IotInterfaceLogVO, IotInterfaceLogVO> findInterfaceLog(Integer page, Integer size, String interfaceName) {
        List<IotInterfaceLogDO> list = iotInterfaceLogDao.findAllByInterfaceName(interfaceName);
        StringBuffer sql =new StringBuffer("SELECT c.* FROM iot_interface_log c WHERE ");
        if (StringUtils.isNotBlank(interfaceName)){
            sql.append(" c.interface_name like'%").append(interfaceName).append("%'");
        }
        sql.append("order by c.time desc limit ").append((page-1)*size).append(",").append(size);
//        List<IotInterfaceLogDO> list = iotInterfaceLogDao.findAllByInterfaceName(interfaceName);
        List<IotInterfaceLogDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(IotInterfaceLogDO.class));
        ArrayList<IotInterfaceLogVO> resultList = new ArrayList<>();
@ -166,12 +177,14 @@ public class IotInterfaceLogService extends BaseJpaService<IotInterfaceLogDO, Io
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Platform.message_success_find,list,page, size,totalCount);*/
        String sql ="SELECT  COALESCE(c.fali,0),b.count,b.app_name,b.interface_name,b.work_type FROM " +
                "                                        (SELECT COUNT(id) fali,app_name,interface_name FROM iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c " +
        StringBuffer sql =new StringBuffer( "SELECT  COALESCE(c.fali,0),b.count,b.app_name,b.interface_name,b.work_type FROM " +
                " (SELECT COUNT(id) fali,app_name,interface_name FROM iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c " +
                                                         "RIGHT JOIN (SELECT count(id) count,app_name,interface_name,work_type FROM iot_interface_log " +
                                                         " GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name;";
                                                         " GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name ");
        sql.append(" limit ").append((page-1)*size).append(",").append(size);
        List<Map<String, Object>> listSql = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> listSql = jdbcTemplate.queryForList(sql.toString());
        List<IotInterfaceLogVO> list = new ArrayList<>();
        listSql.forEach(one->{
            IotInterfaceLogVO iotInterfaceLogVO = new IotInterfaceLogVO();

+ 61 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/platform/IotShareInterfaceService.java

@ -1,13 +1,19 @@
package com.yihu.iot.service.platform;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.company.IotCompanyDao;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.platform.IotShareInterfaceDao;
import com.yihu.jw.entity.iot.company.IotCompanyAppDO;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.platform.IotShareInterfaceDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyAppVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@ -34,6 +40,12 @@ public class IotShareInterfaceService extends BaseJpaService<IotShareInterfaceDO
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private IotCompanyDao iotCompanyDao;
    @Autowired
    private IotSystemDictDao iotSystemDictDao;
    /**
     * 增加接口
     * @param jsonData
@ -135,4 +147,53 @@ public class IotShareInterfaceService extends BaseJpaService<IotShareInterfaceDO
        shareInterfaceDO.setDel("1");
        iotShareInterfaceDao.save(shareInterfaceDO);
    }
    /**
     * 接口文档说明
     * @param interfaceName
     * @return
     */
    public String interfaceDoc(String interfaceName) {
        IotSystemDictDO systemDictDO = iotSystemDictDao.findByDictName(interfaceName).get(0);
        return systemDictDO.getCode();
    }
    /**
     * 分页查询所有应用信息
     * @param page
     * @param size
     * @param name
     * @return
     */
    public  MixEnvelop<IotCompanyAppVO,IotCompanyAppVO> findAllApp(Integer page, Integer size, String name) {
        StringBuffer sql = new StringBuffer("select c.* FROM iot_company_app c WHERE c.del=1 ");
        if(StringUtils.isNotBlank(name)){
            sql.append("and c.`name` like '%").append(name).append("%' OR c.company_name  LIKE  '%").append(name).append("%'");
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotCompanyAppDO> list = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(IotCompanyAppDO.class));
        ArrayList<IotCompanyAppVO> resultList = new ArrayList<>();
        list.forEach(one->{
            IotCompanyAppVO target = new IotCompanyAppVO();
            BeanUtils.copyProperties(one,target);
            IotCompanyDO companyDO = iotCompanyDao.findById(one.getCompanyId());
            target.setContactsMobile(companyDO.getContactsMobile());
            target.setContactsName(companyDO.getContactsName());
            target.setId(one.getId());
            resultList.add(target);
        });
        long count =list.size();
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Platform.message_success_find,resultList,page, size,count);
    }
}