|
@ -4,10 +4,16 @@ import cn.hutool.core.collection.CollectionUtil; |
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
import cn.hutool.core.util.ArrayUtil; |
|
|
import cn.hutool.core.util.ArrayUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.ccsens.tall.bean.dto.PluginDto; |
|
|
import com.ccsens.tall.bean.dto.PluginDto; |
|
|
import com.ccsens.tall.bean.po.*; |
|
|
import com.ccsens.tall.bean.po.*; |
|
|
|
|
|
import com.ccsens.tall.bean.vo.FileVo; |
|
|
import com.ccsens.tall.bean.vo.PluginVo; |
|
|
import com.ccsens.tall.bean.vo.PluginVo; |
|
|
import com.ccsens.tall.persist.dao.*; |
|
|
import com.ccsens.tall.persist.dao.*; |
|
|
|
|
|
import com.ccsens.util.JsonResponse; |
|
|
|
|
|
import com.ccsens.util.PropUtil; |
|
|
|
|
|
import com.ccsens.util.RestTemplateUtil; |
|
|
import com.ccsens.util.WebConstant; |
|
|
import com.ccsens.util.WebConstant; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
@ -21,6 +27,7 @@ import org.springframework.web.context.ContextLoaderListener; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
@ -90,15 +97,41 @@ public class SysPluginService implements ISysPluginService{ |
|
|
public List<PluginVo.PluginByTaskAdded> findPluginOfAdded(PluginDto.FindPluginByTask param) { |
|
|
public List<PluginVo.PluginByTaskAdded> findPluginOfAdded(PluginDto.FindPluginByTask param) { |
|
|
List<PluginVo.PluginByTaskAdded> plugins = taskPluginDao.findPluginOfAdded(param.getTaskId(),param.getRoleId(),param.getPluginName(),param.getPluginType()); |
|
|
List<PluginVo.PluginByTaskAdded> plugins = taskPluginDao.findPluginOfAdded(param.getTaskId(),param.getRoleId(),param.getPluginName(),param.getPluginType()); |
|
|
plugins.forEach(plugin -> { |
|
|
plugins.forEach(plugin -> { |
|
|
ProPluginPreviewFileExample example = new ProPluginPreviewFileExample(); |
|
|
if (plugin.getFileIdList().contains(",")){ |
|
|
example.createCriteria().andPluginIdEqualTo(plugin.getPluginId()).andRecStatusEqualTo((byte)0); |
|
|
String[] split = plugin.getFileIdList().split(","); |
|
|
List<ProPluginPreviewFile> proPluginPreviewFiles = proPluginPreviewFileDao.selectByExample(example); |
|
|
List<String> splits =new ArrayList<>(Arrays.asList(split)); |
|
|
proPluginPreviewFiles.forEach(previewFile -> { |
|
|
//获取文件项目的路径
|
|
|
PluginVo.ImgByTaskAdded img = new PluginVo.ImgByTaskAdded(); |
|
|
String requestUrl = PropUtil.filedeal; |
|
|
img.setPreviewId(previewFile.getId()); |
|
|
//通过文件id查询文件信息
|
|
|
img.setPreviewDescription(previewFile.getPreviewDescription()); |
|
|
String c = RestTemplateUtil.postBody1(requestUrl,splits); |
|
|
plugin.getPreviewImgs().add(img); |
|
|
JsonResponse a = JSONObject.parseObject(c, JsonResponse.class); |
|
|
}); |
|
|
//遍历区分是图标还是预览图
|
|
|
|
|
|
List<FileVo.FilePosition> filePositions = JSONArray.parseArray(a.getData().toString(), FileVo.FilePosition.class); |
|
|
|
|
|
if(ObjectUtil.isNotNull(filePositions) && ObjectUtil.isNotNull(filePositions)){ |
|
|
|
|
|
for (int i = 0; i < filePositions.size(); i++) { |
|
|
|
|
|
if (filePositions.get(i).getId().equals(plugin.getPluginIcon())){ |
|
|
|
|
|
plugin.setIconUrl(filePositions.get(i)); |
|
|
|
|
|
filePositions.remove(filePositions.get(i)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
plugin.setPreviewImgs(filePositions); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
//不包含逗号说明没有预览图,只有图标
|
|
|
|
|
|
List<String> id = new ArrayList<>(); |
|
|
|
|
|
id.add(plugin.getFileIdList()); |
|
|
|
|
|
//获取文件项目的路径
|
|
|
|
|
|
String requestUrl = PropUtil.filedeal; |
|
|
|
|
|
//通过文件id查询文件信息
|
|
|
|
|
|
String c = RestTemplateUtil.postBody1(requestUrl,id); |
|
|
|
|
|
JsonResponse a = JSONObject.parseObject(c, JsonResponse.class); |
|
|
|
|
|
|
|
|
|
|
|
List<FileVo.FilePosition> filePositions = JSONArray.parseArray(a.getData().toString(), FileVo.FilePosition.class); |
|
|
|
|
|
if(ObjectUtil.isNotNull(filePositions) && ObjectUtil.isNotNull(filePositions) && !filePositions.isEmpty()){ |
|
|
|
|
|
plugin.setIconUrl(filePositions.get(0)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
return plugins; |
|
|
return plugins; |
|
|
} |
|
|
} |
|
@ -113,15 +146,41 @@ public class SysPluginService implements ISysPluginService{ |
|
|
PageHelper.startPage(param.getPageNum(),param.getPageSize()); |
|
|
PageHelper.startPage(param.getPageNum(),param.getPageSize()); |
|
|
List<PluginVo.PluginByTaskAdded> plugins = taskPluginDao.findPluginOfNoAdded(param.getTaskId(),param.getRoleId(),param.getPluginName(),param.getPluginType()); |
|
|
List<PluginVo.PluginByTaskAdded> plugins = taskPluginDao.findPluginOfNoAdded(param.getTaskId(),param.getRoleId(),param.getPluginName(),param.getPluginType()); |
|
|
plugins.forEach(plugin -> { |
|
|
plugins.forEach(plugin -> { |
|
|
ProPluginPreviewFileExample example = new ProPluginPreviewFileExample(); |
|
|
if (plugin.getFileIdList().contains(",")){ |
|
|
example.createCriteria().andPluginIdEqualTo(plugin.getPluginId()).andRecStatusEqualTo((byte)0); |
|
|
String[] split = plugin.getFileIdList().split(","); |
|
|
List<ProPluginPreviewFile> proPluginPreviewFiles = proPluginPreviewFileDao.selectByExample(example); |
|
|
List<String> splits =new ArrayList<>(Arrays.asList(split)); |
|
|
proPluginPreviewFiles.forEach(previewFile -> { |
|
|
//获取文件项目的路径
|
|
|
PluginVo.ImgByTaskAdded img = new PluginVo.ImgByTaskAdded(); |
|
|
String requestUrl = PropUtil.filedeal; |
|
|
img.setPreviewId(previewFile.getId()); |
|
|
//通过文件id查询文件信息
|
|
|
img.setPreviewDescription(previewFile.getPreviewDescription()); |
|
|
String c = RestTemplateUtil.postBody1(requestUrl,splits); |
|
|
plugin.getPreviewImgs().add(img); |
|
|
JsonResponse a = JSONObject.parseObject(c, JsonResponse.class); |
|
|
}); |
|
|
//遍历区分是图标还是预览图
|
|
|
|
|
|
List<FileVo.FilePosition> filePositions = JSONArray.parseArray(a.getData().toString(), FileVo.FilePosition.class); |
|
|
|
|
|
if(ObjectUtil.isNotNull(filePositions) && ObjectUtil.isNotNull(filePositions)){ |
|
|
|
|
|
for (int i = 0; i < filePositions.size(); i++) { |
|
|
|
|
|
if (filePositions.get(i).getId().equals(plugin.getPluginIcon())){ |
|
|
|
|
|
plugin.setIconUrl(filePositions.get(i)); |
|
|
|
|
|
filePositions.remove(filePositions.get(i)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
plugin.setPreviewImgs(filePositions); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
//不包含逗号说明没有预览图,只有图标
|
|
|
|
|
|
List<String> id = new ArrayList<>(); |
|
|
|
|
|
id.add(plugin.getFileIdList()); |
|
|
|
|
|
//获取文件项目的路径
|
|
|
|
|
|
String requestUrl = PropUtil.filedeal; |
|
|
|
|
|
//通过文件id查询文件信息
|
|
|
|
|
|
String c = RestTemplateUtil.postBody1(requestUrl,id); |
|
|
|
|
|
JsonResponse a = JSONObject.parseObject(c, JsonResponse.class); |
|
|
|
|
|
|
|
|
|
|
|
List<FileVo.FilePosition> filePositions = JSONArray.parseArray(a.getData().toString(), FileVo.FilePosition.class); |
|
|
|
|
|
if(ObjectUtil.isNotNull(filePositions) && ObjectUtil.isNotNull(filePositions) && !filePositions.isEmpty()){ |
|
|
|
|
|
plugin.setIconUrl(filePositions.get(0)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
return new PageInfo<>(plugins); |
|
|
return new PageInfo<>(plugins); |
|
|
} |
|
|
} |
|
|