|
@@ -23,6 +23,7 @@ import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
@Component
|
|
@@ -36,9 +37,40 @@ public class BlockchainService {
|
|
|
BugReportService bugReportService;
|
|
|
@Autowired
|
|
|
TaskService taskService;
|
|
|
+ @Autowired
|
|
|
+ FinalReportService finalReportService;
|
|
|
+
|
|
|
+ public void addFinalReportList2BlockChain(long examId,long caseId) {
|
|
|
+ List<FinalReportDTO> data = finalReportService.getByExamIdAndCaseId(examId,caseId); // 所有的finalReport信息
|
|
|
+ TaskDTO task = taskService.getByExamIdAndCaseId(examId, caseId);
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ for(FinalReportDTO finalReportDTO : data){
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ //Bug bug = bugReportService.getSourceBugById(finalReport.getSourceId());
|
|
|
+ obj.fluentPut("bugId",finalReportDTO.getId());
|
|
|
+ obj.fluentPut("bugName",finalReportDTO.getDescription());
|
|
|
+ array.add(obj);
|
|
|
+ }
|
|
|
+ JSONObject wordObj = new JSONObject();
|
|
|
+ wordObj.fluentPut("reportHash",task.getExamId()+task.getCaseId()+"");
|
|
|
+ wordObj.fluentPut("reportMixer","admin");
|
|
|
+ wordObj.fluentPut("taskId",task.getCaseId()+"-"+task.getExamId());
|
|
|
+ wordObj.fluentPut("taskName",task.getName());
|
|
|
+ wordObj.fluentPut("type",0);
|
|
|
+ wordObj.fluentPut("updateTime",System.currentTimeMillis());
|
|
|
+ wordObj.fluentPut("bugReportList",array);
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
+ String url = HTTP+blockChainHost+"/finalReport"; // 上传最终的报告
|
|
|
+ template.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
+ headers.setContentType(type);
|
|
|
+ HttpEntity<String> entity = new HttpEntity<String>(wordObj.toJSONString(),headers);
|
|
|
+ template.postForEntity(url, entity, String.class);
|
|
|
+ }
|
|
|
|
|
|
@Async
|
|
|
- public void addFinalToBlockChain(FinalReport finalReport) throws InterruptedException{
|
|
|
+ public void addFinalToBlockChain(FinalReport finalReport) {
|
|
|
if(finalReport==null){
|
|
|
return ;
|
|
|
}
|