|
|
|
@@ -6,11 +6,11 @@ import com.ruoyi.platform.mapper.ActiveLearnDao; |
|
|
|
import com.ruoyi.platform.mapper.ActiveLearnInsDao; |
|
|
|
import com.ruoyi.platform.service.ActiveLearnInsService; |
|
|
|
import com.ruoyi.platform.service.ResourceOccupyService; |
|
|
|
import com.ruoyi.platform.utils.DateUtils; |
|
|
|
import com.ruoyi.platform.utils.HttpUtils; |
|
|
|
import com.ruoyi.platform.utils.JsonUtils; |
|
|
|
import com.ruoyi.platform.utils.*; |
|
|
|
import com.ruoyi.system.api.constant.Constant; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.PageImpl; |
|
|
|
@@ -24,12 +24,16 @@ import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ActiveLearnInsServiceImpl.class); |
|
|
|
|
|
|
|
@Value("${argo.url}") |
|
|
|
private String argoUrl; |
|
|
|
@Value("${argo.workflowStatus}") |
|
|
|
private String argoWorkflowStatus; |
|
|
|
@Value("${argo.workflowTermination}") |
|
|
|
private String argoWorkflowTermination; |
|
|
|
@Value("${minio.endpointIp}") |
|
|
|
String endpoint; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ActiveLearnInsDao activeLearnInsDao; |
|
|
|
@@ -37,6 +41,8 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { |
|
|
|
private ActiveLearnDao activeLearnDao; |
|
|
|
@Resource |
|
|
|
private ResourceOccupyService resourceOccupyService; |
|
|
|
@Resource |
|
|
|
private MinioUtil minioUtil; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Page<ActiveLearnIns> queryByPage(Long activeLearnId, PageRequest pageRequest) throws IOException { |
|
|
|
@@ -168,6 +174,7 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { |
|
|
|
if (Constant.Running.equals(activeLearnIns.getStatus()) || Constant.Pending.equals(activeLearnIns.getStatus())) { |
|
|
|
activeLearnIns = queryStatusFromArgo(activeLearnIns); |
|
|
|
} |
|
|
|
getTrialList(activeLearnIns); |
|
|
|
return activeLearnIns; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -260,4 +267,40 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { |
|
|
|
public List<ActiveLearnIns> queryActiveLearnInsIsNotTerminated() { |
|
|
|
return activeLearnInsDao.queryActiveLearnInsIsNotTerminated(); |
|
|
|
} |
|
|
|
|
|
|
|
public void getTrialList(ActiveLearnIns ins) { |
|
|
|
String directoryPath = ins.getResultPath(); |
|
|
|
|
|
|
|
ins.setResultPath(endpoint + "/" + directoryPath); |
|
|
|
try { |
|
|
|
String bucketName = directoryPath.substring(0, directoryPath.indexOf("/")); |
|
|
|
String prefix = directoryPath.substring(directoryPath.indexOf("/") + 1, directoryPath.length()) + "/"; |
|
|
|
List<Map> fileMaps = minioUtil.listALFilesInDirectory(bucketName, prefix); |
|
|
|
|
|
|
|
if (!fileMaps.isEmpty()) { |
|
|
|
String trialJson = minioUtil.readObjectAsString(bucketName, prefix + "trial.json"); |
|
|
|
List<Map<String, Object>> trialList = JacksonUtil.parseJSONStr2MapList(trialJson); |
|
|
|
ins.setTrialList(trialList); |
|
|
|
|
|
|
|
String dataJson = minioUtil.readObjectAsString(bucketName, prefix + "data.json"); |
|
|
|
Map<String, Object> dataMap = JacksonUtil.parseJSONStr2Map(dataJson); |
|
|
|
ins.setDataMap(dataMap); |
|
|
|
|
|
|
|
for (Map<String, Object> trial : trialList) { |
|
|
|
Integer trialId = (Integer) trial.get("trial_id"); |
|
|
|
for (Map fileMap : fileMaps) { |
|
|
|
String[] split = fileMap.get("name").toString().split("_"); |
|
|
|
if (split.length > 2) { |
|
|
|
String idx = fileMap.get("name").toString().split("_")[2]; |
|
|
|
if (idx.equals(String.valueOf(trialId))) { |
|
|
|
trial.put("file", fileMap); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("未找到结果文件"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |