wangyi преди 2 години
родител
ревизия
9da308b3a8
променени са 16 файла, в които са добавени 198 реда и са изтрити 9 реда
  1. 1 1
      src/main/java/io/renren/modules/generator/controller/ApplicationsController.java
  2. 8 0
      src/main/java/io/renren/modules/generator/controller/EdgenodesController.java
  3. 9 0
      src/main/java/io/renren/modules/generator/controller/ImagesController.java
  4. 17 0
      src/main/java/io/renren/modules/generator/dao/ApplicationVoDao.java
  5. 1 1
      src/main/java/io/renren/modules/generator/dao/ApplicationsDao.java
  6. 5 0
      src/main/java/io/renren/modules/generator/entity/ApplicationsEntity.java
  7. 60 0
      src/main/java/io/renren/modules/generator/entity/ApplicationsEntity_Vo.java
  8. 4 0
      src/main/java/io/renren/modules/generator/service/ApplicationsService.java
  9. 2 3
      src/main/java/io/renren/modules/generator/service/impl/AlgorithmServiceImpl.java
  10. 51 1
      src/main/java/io/renren/modules/generator/service/impl/ApplicationsServiceImpl.java
  11. 6 0
      src/main/java/io/renren/modules/minio/controller/MinioAlgorithmController.java
  12. 2 0
      src/main/java/io/renren/modules/minio/mapper/MinioAlgorithmMapper.java
  13. 2 0
      src/main/java/io/renren/modules/minio/service/MinioAlgorithmService.java
  14. 5 0
      src/main/java/io/renren/modules/minio/service/impl/MinioAlgorithmServiceImpl.java
  15. 8 3
      src/main/resources/mapper/generator/ApplicationsDao.xml
  16. 17 0
      src/main/resources/mapper/minio/MinioAlgorithmMapper.xml

+ 1 - 1
src/main/java/io/renren/modules/generator/controller/ApplicationsController.java

@@ -34,7 +34,7 @@ public class ApplicationsController {
     @RequestMapping("/list")
     //@RequiresPermissions("generator:applications:list")
     public R list(@RequestParam Map<String, Object> params) {
-        PageUtils page = applicationsService.queryPage(params);
+        PageUtils page = applicationsService.queryPageOnUse(params);
 
         return R.ok().put("page", page);
     }

+ 8 - 0
src/main/java/io/renren/modules/generator/controller/EdgenodesController.java

@@ -3,6 +3,7 @@ package io.renren.modules.generator.controller;
 import io.renren.common.utils.PageUtils;
 import io.renren.common.utils.R;
 import io.renren.modules.generator.entity.EdgenodesEntity;
+import io.renren.modules.generator.service.ApplicationsService;
 import io.renren.modules.generator.service.EdgenodesService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +23,8 @@ import java.util.Map;
 public class EdgenodesController {
     @Autowired
     private EdgenodesService edgenodesService;
+    @Autowired
+    private ApplicationsService applicationsService;
 
     /**
      * 列表
@@ -78,6 +81,11 @@ public class EdgenodesController {
     @RequestMapping("/delete")
     @RequiresPermissions("generator:edgenodes:delete")
     public R delete(@RequestBody Integer[] edgenodesIds) {
+        for (int edgenodeId:edgenodesIds){
+            if (applicationsService.selectByDeployDeviceId(edgenodeId)>0){
+                return R.error("该设备正在运行智能应用");
+            }
+        }
         edgenodesService.removeByIds(Arrays.asList(edgenodesIds));
 
         return R.ok();

+ 9 - 0
src/main/java/io/renren/modules/generator/controller/ImagesController.java

@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -46,6 +47,14 @@ public class ImagesController {
         return R.ok().put("page", page);
     }
 
+    @RequestMapping("/listAll")
+    @RequiresPermissions("generator:images:list")
+    public R listAll() {
+        List<ImagesEntity> list=imagesService.list();
+        return R.ok().put("list", list);
+    }
+
+
 
     /**
      * 信息

+ 17 - 0
src/main/java/io/renren/modules/generator/dao/ApplicationVoDao.java

@@ -0,0 +1,17 @@
+package io.renren.modules.generator.dao;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import io.renren.modules.generator.entity.ApplicationsEntity_Vo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+@Mapper
+public interface ApplicationVoDao extends BaseMapper<ApplicationsEntity_Vo> {
+    @Select("SELECT * from applications ${ew.customSqlSegment}")
+    List<ApplicationsEntity_Vo> getAppInfo(@Param(Constants.WRAPPER) Wrapper wrapper);
+}

+ 1 - 1
src/main/java/io/renren/modules/generator/dao/ApplicationsDao.java

@@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface ApplicationsDao extends BaseMapper<ApplicationsEntity> {
-
+    int selectByDeployDeviceId(Integer deployDeviceId);
 }

+ 5 - 0
src/main/java/io/renren/modules/generator/entity/ApplicationsEntity.java

@@ -29,6 +29,11 @@ public class ApplicationsEntity implements Serializable {
      */
     private String applicationType;
 
+    /**
+     * 部署设备id
+     */
+    private Integer deployDeviceId;
+
     /**
      * 应用ID
      */

+ 60 - 0
src/main/java/io/renren/modules/generator/entity/ApplicationsEntity_Vo.java

@@ -0,0 +1,60 @@
+package io.renren.modules.generator.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class ApplicationsEntity_Vo {
+    /**
+     * 名称
+     */
+    private String applicationName;
+
+    /**
+     * 应用类型
+     */
+    private String applicationType;
+
+    /**
+     * 部署设备id
+     */
+    private Integer deployDeviceId;
+
+    /**
+     * 部署设备名称
+     */
+    private String deployDeviceName;
+
+    /**
+     * 应用ID
+     */
+    @TableId
+    private Integer applicationId;
+    /**
+     * 应用版本
+     */
+    private String applicationVersion;
+
+    /**
+     * 应用状态
+     */
+    private String applicationStatus;
+    /**
+     * 所属项目名称
+     */
+    private String parentProjectName;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 创建者姓名
+     */
+    private String creatorName;
+    /**
+     * 描述信息
+     */
+    private String applicationDescription;
+}

+ 4 - 0
src/main/java/io/renren/modules/generator/service/ApplicationsService.java

@@ -16,5 +16,9 @@ import java.util.Map;
 public interface ApplicationsService extends IService<ApplicationsEntity> {
 
     PageUtils queryPage(Map<String, Object> params);
+
+    PageUtils queryPageOnUse(Map<String, Object> params);
+
+    int selectByDeployDeviceId(Integer deployDeviceId);
 }
 

+ 2 - 3
src/main/java/io/renren/modules/generator/service/impl/AlgorithmServiceImpl.java

@@ -36,14 +36,13 @@ public class AlgorithmServiceImpl extends ServiceImpl<AlgorithmDao, AlgorithmEnt
      */
     public PageUtils queryPage(Map<String, Object> params) {
         String categoryId = (String) params.get("categoryId");
-        String algorithmName = (String) params.get("algorithmName");
+        String algorithmName = (String) params.get("search");
+
         IPage<AlgorithmEntity> page = this.page(
                 new Query<AlgorithmEntity>().getPage(params),
                 new QueryWrapper<AlgorithmEntity>()
                         .eq(StringUtils.isNotBlank(categoryId), "category_id", categoryId)
                         .like(StringUtils.isNotBlank(algorithmName), "algorithm_name", algorithmName)
-                        .eq(StringUtils.isNotBlank(categoryId), "category_id", categoryId)
-                        .like(StringUtils.isNotBlank(algorithmName), "algorithm_name", algorithmName)
         );
 
         return new PageUtils(page);

+ 51 - 1
src/main/java/io/renren/modules/generator/service/impl/ApplicationsServiceImpl.java

@@ -1,7 +1,14 @@
 package io.renren.modules.generator.service.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import io.renren.modules.generator.dao.ApplicationVoDao;
+import io.renren.modules.generator.entity.ApplicationsEntity_Vo;
+import io.renren.modules.generator.service.EdgenodesService;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 import java.util.Map;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -16,7 +23,12 @@ import io.renren.modules.generator.service.ApplicationsService;
 
 @Service("applicationsService")
 public class ApplicationsServiceImpl extends ServiceImpl<ApplicationsDao, ApplicationsEntity> implements ApplicationsService {
-
+    @Autowired
+    ApplicationVoDao applicationVoDao;
+    @Autowired
+    ApplicationsDao applicationsDao;
+    @Autowired
+    EdgenodesService edgenodesService;
     @Override
     public PageUtils queryPage(Map<String, Object> params) {
         String applicationName=(String) params.get("applicationName");
@@ -31,4 +43,42 @@ public class ApplicationsServiceImpl extends ServiceImpl<ApplicationsDao, Applic
         return new PageUtils(page);
     }
 
+    @Override
+    public PageUtils queryPageOnUse(Map<String, Object> params) {
+        String applicationName=(String) params.get("applicationName");
+        String deployDeviceIdString=(String) params.get("deployDeviceId");
+        int deployDeviceId=0;
+        if (deployDeviceIdString!=null&&deployDeviceIdString.length()>0){
+            deployDeviceId=Integer.valueOf(deployDeviceIdString);
+        }
+        int pageSize = Integer.valueOf((String) params.get("limit"));
+        int pageIndex = Integer.valueOf((String) params.get("page"));
+
+        List<ApplicationsEntity_Vo> appsInfo;
+        List<ApplicationsEntity_Vo> appsAllInfo;
+        appsInfo=applicationVoDao.getAppInfo(new QueryWrapper<ApplicationsEntity_Vo>()
+                .like(StringUtils.isNotBlank(applicationName),"application_name",applicationName)
+                .eq(deployDeviceIdString!=null&&deployDeviceIdString.length()>0,"deploy_device_id",deployDeviceId)
+                .last("limit " + (pageIndex - 1) * pageSize + "," + pageSize + ";")
+            );
+        appsAllInfo=applicationVoDao.getAppInfo(new QueryWrapper<ApplicationsEntity_Vo>()
+                .like(StringUtils.isNotBlank(applicationName),"application_name",applicationName)
+                .eq(deployDeviceIdString!=null&&deployDeviceIdString.length()>0,"deploy_device_id",deployDeviceId));
+        for (ApplicationsEntity_Vo vo:appsInfo){
+            if (vo.getDeployDeviceId()==0){
+                vo.setDeployDeviceName("中心云");
+            }else {
+                vo.setDeployDeviceName(edgenodesService.getById(vo.getDeployDeviceId()).getEdgenodesName());
+            }
+
+        }
+        return new PageUtils(appsInfo,appsAllInfo.size(),pageSize,pageIndex);
+    }
+
+    @Override
+    public int selectByDeployDeviceId(Integer deployDeviceId) {
+        return applicationsDao.selectByDeployDeviceId(deployDeviceId);
+    }
+
+
 }

+ 6 - 0
src/main/java/io/renren/modules/minio/controller/MinioAlgorithmController.java

@@ -30,4 +30,10 @@ public class MinioAlgorithmController {
         return GsonUtil.toString(list);
     }
 
+    @GetMapping("selectByName")
+    public String selectByName(String algName) {
+        List<MinioAlgorithm> list = minioAlgorithmService.selectByName(algName);
+        return GsonUtil.toString(list);
+    }
+
 }

+ 2 - 0
src/main/java/io/renren/modules/minio/mapper/MinioAlgorithmMapper.java

@@ -17,6 +17,8 @@ public interface MinioAlgorithmMapper {
     // int start, int size
     List<MinioAlgorithm> getMinioAlgorithmList();
 
+    List<MinioAlgorithm> selectByName(String algName);
+
     int getAlgorithmNum();
 
     int findModelByName(String algorithmName);

+ 2 - 0
src/main/java/io/renren/modules/minio/service/MinioAlgorithmService.java

@@ -23,6 +23,8 @@ public interface MinioAlgorithmService {
     // int offset, int size
     List<MinioAlgorithm> getMinioAlgorithmList();
 
+    List<MinioAlgorithm> selectByName(String algName);
+
     int getAlgorithmNum();
 
     String findModelByName(String algorithmName);

+ 5 - 0
src/main/java/io/renren/modules/minio/service/impl/MinioAlgorithmServiceImpl.java

@@ -31,6 +31,11 @@ public class MinioAlgorithmServiceImpl implements MinioAlgorithmService {
         return minioAlgorithmMapper.getMinioAlgorithmList();
     }
 
+    @Override
+    public List<MinioAlgorithm> selectByName(String algName) {
+        return minioAlgorithmMapper.selectByName(algName);
+    }
+
     @Override
     public int getAlgorithmNum() {
         return minioAlgorithmMapper.getAlgorithmNum();

+ 8 - 3
src/main/resources/mapper/generator/ApplicationsDao.xml

@@ -6,17 +6,22 @@
     <!-- 可根据自己的需求,是否要使用 -->
     <resultMap type="io.renren.modules.generator.entity.ApplicationsEntity" id="applicationsMap">
         <result property="applicationName" column="application_name"/>
-        <result property="applicationAlias" column="application_alias"/>
         <result property="applicationId" column="application_id"/>
+        <result property="deployDeviceId" column="deploy_device_id" />
         <result property="applicationVersion" column="application_version"/>
         <result property="lastUpdateTime" column="last_update_time"/>
         <result property="parentClusterId" column="parent_cluster_id"/>
         <result property="applicationStatus" column="application_status"/>
-        <result property="parentProjectId" column="parent_project_id"/>
+        <result property="parentProjectName" column="parent_project_name"/>
         <result property="createTime" column="create_time"/>
-        <result property="creatorId" column="creator_id"/>
+        <result property="creatorName" column="creator_name"/>
         <result property="applicationDescription" column="application_description"/>
     </resultMap>
 
+    <select id="selectByDeployDeviceId" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+        select count(*) from applications
+        where deploy_device_id=#{deployDeviceId,jdbcType=INTEGER}
+    </select>
+
 
 </mapper>

+ 17 - 0
src/main/resources/mapper/minio/MinioAlgorithmMapper.xml

@@ -19,6 +19,23 @@
           and is_approvaled = 1
           and is_preassembled is NULL
     </select>
+    <select id="selectByName" parameterType="java.lang.String" resultMap="minioAlgorithmMapping">
+        select model_id,
+               model_name,
+               classification.name          as classification,
+               sys_user.username            as creator,
+               if(form = 1, '传统算法', '智能算法') as form,
+               remark,
+               construct_message
+        from algorithm_model,
+             classification,
+             sys_user
+        where algorithm_model.category_id = classification.id
+          and algorithm_model.uid = sys_user.user_id
+          and is_approvaled = 1
+          and is_preassembled is NULL
+          and model_name like concat('%','${algName}','%')
+    </select>
 
     <select id="getAlgorithmNum" resultType="Integer">
         select count(*)