@@ -626,7 +626,7 @@ public Integer insertScanHistory (Account account) {
626626 return scanHistoryMapper .insertSelective (history );
627627 }
628628
629- public void insertTaskHistory (Task task , Integer scanId ) {
629+ public void insertTaskHistory (Task task , Integer scanId ) throws Exception {
630630 ScanTaskHistoryExample example = new ScanTaskHistoryExample ();
631631 example .createCriteria ().andTaskIdEqualTo (task .getId ()).andScanIdEqualTo (scanId );
632632 List <ScanTaskHistory > list = scanTaskHistoryMapper .selectByExample (example );
@@ -641,22 +641,26 @@ public void insertTaskHistory (Task task, Integer scanId) {
641641 }
642642 }
643643
644- public void updateTaskHistory (Task task , ScanTaskHistoryExample example ) {
645- TaskItemResourceExample taskItemResourceExample = new TaskItemResourceExample ();
646- taskItemResourceExample .createCriteria ().andTaskIdEqualTo (task .getId ());
647- List <TaskItemResourceWithBLOBs > taskItemResources = taskItemResourceMapper .selectByExampleWithBLOBs (taskItemResourceExample );
648- JSONArray jsonArray = new JSONArray ();
649- taskItemResources .stream ().forEach (item ->{
650- ResourceWithBLOBs resource = resourceMapper .selectByPrimaryKey (item .getResourceId ());
651- if (resource !=null ) jsonArray .addAll (JSON .parseArray (resource .getResources ()));
652- });
653- ScanTaskHistory history = new ScanTaskHistory ();
654- history .setResourcesSum (task .getResourcesSum ()!=null ?task .getResourcesSum ():0 );
655- history .setReturnSum (task .getReturnSum ()!=null ?task .getReturnSum ():0 );
656- history .setScanScore (calculateScore (accountMapper .selectByPrimaryKey (task .getAccountId ()), task ));
657- history .setOperation ("修改历史合规扫描" );
658- history .setOutput (jsonArray .toJSONString ());
659- scanTaskHistoryMapper .updateByExampleSelective (history , example );
644+ public void updateTaskHistory (Task task , ScanTaskHistoryExample example ) throws Exception {
645+ try {
646+ TaskItemResourceExample taskItemResourceExample = new TaskItemResourceExample ();
647+ taskItemResourceExample .createCriteria ().andTaskIdEqualTo (task .getId ());
648+ List <TaskItemResourceWithBLOBs > taskItemResources = taskItemResourceMapper .selectByExampleWithBLOBs (taskItemResourceExample );
649+ JSONArray jsonArray = new JSONArray ();
650+ taskItemResources .forEach (item ->{
651+ ResourceWithBLOBs resource = resourceMapper .selectByPrimaryKey (item .getResourceId ());
652+ if (resource !=null ) jsonArray .addAll (JSON .parseArray (!resource .getResources ().isEmpty ()?resource .getResources ():"[]" ));
653+ });
654+ ScanTaskHistory history = new ScanTaskHistory ();
655+ history .setResourcesSum (task .getResourcesSum ()!=null ?task .getResourcesSum ():0 );
656+ history .setReturnSum (task .getReturnSum ()!=null ?task .getReturnSum ():0 );
657+ history .setScanScore (calculateScore (accountMapper .selectByPrimaryKey (task .getAccountId ()), task ));
658+ history .setOperation ("修改历史合规扫描" );
659+ history .setOutput (jsonArray .toJSONString ());
660+ scanTaskHistoryMapper .updateByExampleSelective (history , example );
661+ }catch (Exception e ){
662+ throw new Exception (e .getMessage ());
663+ }
660664 }
661665
662666 public void createQuartzTask (String quartzTaskId ) {
0 commit comments