Merge branch 'master' of http://1.14.125.6:3000/mianbin/ops-pro
This commit is contained in:
commit
14fbff2dc0
@ -13,16 +13,16 @@ public class ReportAssetTaskReq {
|
||||
private ReportAdvancedSearch advancedSearch;
|
||||
|
||||
//报告维度 5-组件,默认为5-组件
|
||||
private Integer dimension;
|
||||
private Integer dimension = 5;
|
||||
|
||||
//报告模板id,可选,默认为默认模板
|
||||
private Integer reportTemplateId;
|
||||
private Integer reportTemplateId = 1;
|
||||
|
||||
//检测任务ID
|
||||
private Integer scaTaskId;
|
||||
|
||||
//报告类型 5-excel 1-word 2-pdf 3-html 4-json,默认为5-excel
|
||||
private Integer type;
|
||||
private Integer type = 2;
|
||||
|
||||
//报告名称,如果不填则会自动生成
|
||||
private String reportName;
|
||||
|
@ -135,24 +135,7 @@ public class ApplicationWorker extends HttpWorker {
|
||||
Integer scaTaskId = data.getInteger("scaTaskId");
|
||||
append(context,"任务执行成功,scaTaskId为" + scaTaskId);
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
applicationConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
applicationConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(applicationConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
pollTaskStatus(restTemplate, scaTaskId,context);
|
||||
pollTaskStatus(restTemplate, scaTaskId,context,applicationConfigInfo,pipTask);
|
||||
} else if (message.equals("应用已经存在")) {
|
||||
append(context,message);
|
||||
Integer oldScaTaskId = (Integer) applicationConfigInfo.get("scaTaskId");
|
||||
@ -163,7 +146,7 @@ public class ApplicationWorker extends HttpWorker {
|
||||
append(context,"重新启动任务失败");
|
||||
return;
|
||||
}
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context);
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context, applicationConfigInfo, pipTask);
|
||||
} else {
|
||||
append(context,"==================SCA接口异常,调用失败=================");
|
||||
append(context,message);
|
||||
@ -195,10 +178,13 @@ public class ApplicationWorker extends HttpWorker {
|
||||
|
||||
/**
|
||||
* 轮询请求任务状态
|
||||
* @param restTemplate RestTemplate
|
||||
* @param scaTaskId 任务ID
|
||||
*
|
||||
* @param restTemplate RestTemplate
|
||||
* @param scaTaskId 任务ID
|
||||
* @param applicationConfigInfo
|
||||
* @param pipTask
|
||||
*/
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId,BaseRunContext context) {
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId, BaseRunContext context, Map<String, Object> applicationConfigInfo, PipTask pipTask) {
|
||||
int currentPollingTimes = 0;
|
||||
while (currentPollingTimes < MAX_POLLING_TIMES) {
|
||||
try {
|
||||
@ -218,6 +204,25 @@ public class ApplicationWorker extends HttpWorker {
|
||||
System.out.println("任务已完成,停止轮询。");
|
||||
log.info("任务已完成,停止轮询。");
|
||||
append(context,"任务已完成,停止状态获取。" );
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
applicationConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
applicationConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(applicationConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -111,25 +111,8 @@ public class CodingWorker extends HttpWorker {
|
||||
Integer scaTaskId = data.getInteger("scaTaskId");
|
||||
append(context,"SCA-代码仓库管理节点执行成功,SCA任务ID为:" + scaTaskId);
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
codingConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
codingConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(codingConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
//轮询请求状态
|
||||
pollTaskStatus(restTemplate, scaTaskId,context);
|
||||
pollTaskStatus(restTemplate, scaTaskId,context,codingConfigInfo,pipTask);
|
||||
} else if (response.getString("message").equals("应用已经存在")){
|
||||
append(context,response.getString("message"));
|
||||
Integer oldScaTaskId = (Integer) codingConfigInfo.get("scaTaskId");
|
||||
@ -141,7 +124,7 @@ public class CodingWorker extends HttpWorker {
|
||||
localVariables.put("statusCode", "-1");
|
||||
}
|
||||
//轮询请求状态
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context);
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context, codingConfigInfo, pipTask);
|
||||
} else {
|
||||
//基于第三方文档表明500状态基本属于无镜像配置,对比失败,于是打印日志为无法对比镜像
|
||||
append(context,"==================SCA校验失败=================");
|
||||
@ -178,8 +161,10 @@ public class CodingWorker extends HttpWorker {
|
||||
*
|
||||
* @param restTemplate
|
||||
* @param scaTaskId
|
||||
* @param codingConfigInfo
|
||||
* @param pipTask
|
||||
*/
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId,BaseRunContext context) {
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId, BaseRunContext context, Map<String, Object> codingConfigInfo, PipTask pipTask) {
|
||||
int currentPollingTimes = 0;
|
||||
while (currentPollingTimes < MAX_POLLING_TIMES) {
|
||||
try {
|
||||
@ -199,6 +184,25 @@ public class CodingWorker extends HttpWorker {
|
||||
System.out.println("任务已完成,停止轮询。");
|
||||
log.info("任务已完成,停止轮询。");
|
||||
append(context,"任务已完成,停止状态获取。" );
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
codingConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
codingConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(codingConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -143,25 +143,7 @@ public class ScaBinaryWorker extends HttpWorker {
|
||||
Integer scaTaskId = data.getInteger("scaTaskId");
|
||||
append(context,"SCA-BINARY节点上传成功,SCA任务ID为:" + scaTaskId);
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
scaBinaryConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
scaBinaryConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(scaBinaryConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
|
||||
pollTaskStatus(restTemplate, scaTaskId,context);
|
||||
pollTaskStatus(restTemplate, scaTaskId,context,scaBinaryConfigInfo, pipTask);
|
||||
} else if (message.equals("应用已经存在")) {
|
||||
append(context,message);
|
||||
Integer oldScaTaskId = (Integer) scaBinaryConfigInfo.get("scaTaskId");
|
||||
@ -172,7 +154,7 @@ public class ScaBinaryWorker extends HttpWorker {
|
||||
append(context,"重新启动任务失败");
|
||||
return;
|
||||
}
|
||||
pollTaskStatus(restTemplate, oldScaTaskId, context);
|
||||
pollTaskStatus(restTemplate, oldScaTaskId, context, scaBinaryConfigInfo,pipTask);
|
||||
} else {
|
||||
append(context,"==================SCA接口异常,调用失败=================");
|
||||
append(context,message);
|
||||
@ -207,8 +189,10 @@ public class ScaBinaryWorker extends HttpWorker {
|
||||
* @param restTemplate
|
||||
* @param scaTaskId
|
||||
* @param context
|
||||
* @param scaBinaryConfigInfo
|
||||
* @param pipTask
|
||||
*/
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId, BaseRunContext context) {
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId, BaseRunContext context, Map<String, Object> scaBinaryConfigInfo, PipTask pipTask) {
|
||||
int currentPollingTimes = 0;
|
||||
while (currentPollingTimes < MAX_POLLING_TIMES) {
|
||||
try {
|
||||
@ -228,6 +212,25 @@ public class ScaBinaryWorker extends HttpWorker {
|
||||
System.out.println("任务已完成,停止轮询。");
|
||||
log.info("任务已完成,停止轮询。");
|
||||
append(context,"任务已完成,停止状态获取。" );
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
scaBinaryConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
scaBinaryConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(scaBinaryConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -140,25 +140,7 @@ public class ScaMirrorWorker extends HttpWorker {
|
||||
Integer scaTaskId = data.getInteger("scaTaskId");
|
||||
append(context,"SCA-MIRROR节点执行成功,SCA任务ID为:" + scaTaskId);
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
scaMirrorConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
scaMirrorConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(scaMirrorConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
|
||||
pollTaskStatus(restTemplate, scaTaskId,context);
|
||||
pollTaskStatus(restTemplate, scaTaskId,context,scaMirrorConfigInfo,pipTask);
|
||||
} else if (message.equals("应用已经存在")) {
|
||||
append(context,message);
|
||||
Integer oldScaTaskId = (Integer) scaMirrorConfigInfo.get("scaTaskId");
|
||||
@ -169,7 +151,7 @@ public class ScaMirrorWorker extends HttpWorker {
|
||||
append(context,"SCA-MIRROR节点执行失败");
|
||||
return;
|
||||
}
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context);
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context, scaMirrorConfigInfo, pipTask);
|
||||
} else {
|
||||
append(context,"==================SCA接口异常,调用失败=================");
|
||||
append(context,message);
|
||||
@ -210,8 +192,10 @@ public class ScaMirrorWorker extends HttpWorker {
|
||||
*
|
||||
* @param restTemplate
|
||||
* @param scaTaskId
|
||||
* @param scaMirrorConfigInfo
|
||||
* @param pipTask
|
||||
*/
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId,BaseRunContext context) {
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId, BaseRunContext context, Map<String, Object> scaMirrorConfigInfo, PipTask pipTask) {
|
||||
int currentPollingTimes = 0;
|
||||
while (currentPollingTimes < MAX_POLLING_TIMES) {
|
||||
try {
|
||||
@ -231,6 +215,25 @@ public class ScaMirrorWorker extends HttpWorker {
|
||||
System.out.println("任务已完成,停止轮询。");
|
||||
log.info("任务已完成,停止轮询。");
|
||||
append(context,"任务已完成,停止状态获取。" );
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
scaMirrorConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
scaMirrorConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(scaMirrorConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -137,25 +137,8 @@ public class ScaSbomWorker extends HttpWorker {
|
||||
Integer scaTaskId = data.getInteger("scaTaskId");
|
||||
append(context,"上传完毕获取scaTaskId:"+scaTaskId);
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
scaSbomConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
scaSbomConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(scaSbomConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
append(context,"任务正在运行中,正在查询执行状态,当前scaTaskId :"+scaTaskId);
|
||||
pollTaskStatus(restTemplate, scaTaskId,context);
|
||||
pollTaskStatus(restTemplate, scaTaskId,context,scaSbomConfigInfo,pipTask);
|
||||
} else if (message.equals("应用已经存在")) {
|
||||
append(context,message);
|
||||
Integer oldScaTaskId = (Integer) scaSbomConfigInfo.get("scaTaskId");
|
||||
@ -166,7 +149,7 @@ public class ScaSbomWorker extends HttpWorker {
|
||||
if (restartResult != 0) {
|
||||
return;
|
||||
}
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context);
|
||||
pollTaskStatus(restTemplate, oldScaTaskId,context, scaSbomConfigInfo, pipTask);
|
||||
} else {
|
||||
append(context,"==================SCA接口异常,调用失败=================");
|
||||
append(context,message);
|
||||
@ -201,8 +184,10 @@ public class ScaSbomWorker extends HttpWorker {
|
||||
*
|
||||
* @param restTemplate
|
||||
* @param scaTaskId
|
||||
* @param scaSbomConfigInfo
|
||||
* @param pipTask
|
||||
*/
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId,BaseRunContext context) {
|
||||
public void pollTaskStatus(RestTemplate restTemplate, Integer scaTaskId, BaseRunContext context, Map<String, Object> scaSbomConfigInfo, PipTask pipTask) {
|
||||
int currentPollingTimes = 0;
|
||||
while (currentPollingTimes < MAX_POLLING_TIMES) {
|
||||
try {
|
||||
@ -222,6 +207,25 @@ public class ScaSbomWorker extends HttpWorker {
|
||||
System.out.println("任务已完成,停止轮询。");
|
||||
log.info("任务已完成,停止轮询。");
|
||||
append(context,"任务已完成,停止状态获取。" );
|
||||
|
||||
//回调报告生成接口
|
||||
ReportAssetTaskReq req = new ReportAssetTaskReq();
|
||||
req.setScaTaskId(scaTaskId);
|
||||
ReportResp reportResp = reportService.assetReportTask(req);
|
||||
if (!ObjectUtils.isEmpty(reportResp)){
|
||||
if (reportResp.getMessage().equals("success")){
|
||||
append(context,"回调报告生成接口成功");
|
||||
scaSbomConfigInfo.put("reportId",reportResp.getId());
|
||||
}else {
|
||||
append(context,"回调报告生成接口失败,scaTaskId = " + scaTaskId + "=====错误原因=====" + reportResp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//更新scaTaskId数据到task表
|
||||
scaSbomConfigInfo.put("scaTaskId",scaTaskId);
|
||||
pipTask.setTaskProperties(scaSbomConfigInfo);
|
||||
pipTaskDao.updateById(pipTask);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user