Pārlūkot izejas kodu

添加导出(查看)搜索引擎报告的功能。

insomniaLee 5 gadi atpakaļ
vecāks
revīzija
7550059b46

+ 7 - 0
src/main/java/com/mooctest/controller/JobController.java

@@ -118,6 +118,13 @@ public class JobController {
         }
     }
 
+    @GetMapping(value = "/export")
+    public String export ( Model model , @RequestParam("id") String id ){
+        JSONArray array = jobService.export(id);
+        model.addAttribute("datas",array);
+        return "exportExcel";
+    }
+
 //    @PostMapping(value = "jobDistribute")
 //    public ResponseDTO jobDistribute (@RequestParam("id")String jobId){
 //        //huoqu fenpei xinxi

+ 14 - 0
src/main/java/com/mooctest/service/JobService.java

@@ -95,6 +95,20 @@ public class JobService {
     }
 
 
+    public JSONArray export ( String caseTakeId){
+        RestTemplate template = new RestTemplate();
+        String url = "http://47.99.140.117:9001/Bug/api/export/exportBug";
+        MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<String, Object>();
+        paramMap.add("case_take_id", caseTakeId);
+        template.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+        HttpHeaders headers = new HttpHeaders();
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(paramMap,headers);
+        ResponseEntity<String> response2 = template.postForEntity(url, httpEntity, String.class);
+        JSONArray tasksJson = JSON.parseArray(response2.getBody());
+        return  tasksJson;
+    }
+
+
     public JSONObject getSinglePaper ( String jobId){
         RestTemplate template = new RestTemplate();
         String url = HTTP+reportHost+"/Bug/api/job/getJob";

+ 217 - 0
src/main/resources/templates/exportExcel.html

@@ -0,0 +1,217 @@
+<!DOCTYPE html>
+<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
+      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
+      layout:decorator="base">
+<head>
+    <link rel="stylesheet" href="/static/css/applications.css" type="text/css"/>
+    <!-- dataTables -->
+    <link rel="stylesheet" type="text/css"
+          href="/static/AdminLTE/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css"/>
+    <!-- Select2 -->
+    <link rel="stylesheet" type="text/css" href="/static/AdminLTE/bower_components/select2/dist/css/select2.min.css"/>
+    <style>
+        .table tbody tr td, .table thead tr th {
+            vertical-align: top;
+        }
+        .t1{
+            width: 71px
+        }
+        .t2{
+            width: 100px
+        }
+        .t3{
+            width: 250px;
+        }
+        .t4{
+            width: 100px;
+        }
+        .t5{
+            max-width: 350px;
+        }
+    </style>
+</head>
+<body>
+<div layout:fragment="mainbody">
+    <aside class="main-sidebar">
+        <section class="sidebar">
+            <div class="user-panel">
+                <div class="pull-left image">
+                    <img src="/static/images/avatar/avatar-admin.jpg" class="img-circle" alt="User Image" />
+                </div>
+                <div class="pull-left info">
+                    <p>Admin</p>
+                    <a href="#">
+                        <i class="fa fa-circle text-success"></i>
+                        Online
+                    </a>
+                </div>
+            </div>
+
+            <!-- Search form -->
+            <form action="#" method="get" class="sidebar-form">
+                <div class="input-group">
+                    <input type="text" name="q" class="form-control" placeholder="Search..." />
+                    <span class="input-group-btn">
+						<button type="submit" name="search" id="search-btn" class="btn btn-flat">
+							<i class="fa fa-search"></i>
+						</button>
+					</span>
+                </div>
+            </form>
+
+            <!-- Sidebar Menu -->
+            <ul class="sidebar-menu tree" data-widget="tree">
+
+
+            </ul>
+        </section>
+    </aside>
+
+    <!-- Main Content -->
+    <div class="content-wrapper" style="min-height: 691px;">
+        <section class="content-header">
+            <h1>111</h1>
+
+            <ol class="breadcrumb">
+                <li class="active">
+                    <a href="/home">
+                        <i class="fa fa-dashboard"></i>
+                        111
+                    </a>
+                </li>
+            </ol>
+        </section>
+
+        <!-- Main Content -->
+        <section class="content container-fluid">
+
+
+
+            <table id="task-list" class="table table-striped" style="margin-top: 10px">
+                <thead>
+                <tr>
+                    <!--<th></th>-->
+                    <th>姓名</th>
+                    <th>关键词个数</th>
+                    <th>总分</th>
+                    <!--<th>版本</th>-->
+<!--                    <th>操作</th>-->
+                    <th>
+                        报告详情
+                    </th>
+                </tr>
+                </thead>
+                <tbody>
+
+                <th:block th:each=" people : ${datas}">
+                        <tr>
+                            <td><b><a   th:text="${people.get('workerName')}"></a></b></td>
+                            <td>
+                                <span  class="label label-success" th:text="${people.get('bugCount')}" ></span>
+                            </td>
+                            <td>
+                                <span  class="label label-success" th:text="${people.get('totalScore')}" ></span>
+
+                            </td>
+                            <td>
+                                <table class="table table-striped">
+                                    <tr>
+                                        <th>评审得分</th>
+                                        <th>搜索引擎</th>
+                                        <th>关键词</th>
+                                        <th>选手评价内容</th>
+                                        <th>选手评分</th>
+                                        <th>图片</th>
+                                    </tr>
+                                    <tr th:each="task : ${people.get('exportBugDTOList')}" >
+
+                                        <td class="t0" th:text="${task.get('score')}">10</td>
+                                        <td class="t1" th:text="${task.get('page2')}">母猪上树</td>
+                                        <td class="t2" th:text="${task.get('title')}">母猪上树</td>
+                                        <td class="t3" th:text="${task.get('description')}">母猪上树</td>
+                                        <td class="t4" th:text="${task.get('page3')}">母猪上树</td>
+                                        <td class="t5"  >
+                                            <th:block th:each="item : ${task.get('imgUrlList')}">
+                                                <img th:src="${item}" th:onclick="'javascript:showimage(this);'" style="max-width: 100px ; max-height: 200px" />
+                                            </th:block>
+                                        </td>
+
+                                    </tr>
+
+                                </table>
+
+                            </td>
+
+                        </tr>
+                </th:block>
+
+
+                </tbody>
+            </table><!-- table -->
+        </section>
+    </div>
+</div>
+</body>
+</html>
+<div class="modal fade bs-example-modal-lg text-center" id="imgModal" tabindex="-1" role="dialog"
+     aria-labelledby="myLargeModalLabel">
+
+    <div class="modal-dialog modal-lg" style="display: inline-block; max-width: 900px; max-height: 600px">
+        <div class="modal-content" style="background:  transparent">
+            <center>
+                <img id="imgInModalID"
+                     class="carousel-inner img-responsive "
+                     onclick="closeImageViewer()"
+                     onmouseover="this.style.cursor='pointer';this.style.cursor='hand'"
+                     onmouseout="this.style.cursor='default'"
+                     style="max-height: 90vh;
+                     max-width: 90vw;
+                     object-fit: contain;"
+                />
+            </center>
+        </div>
+    </div>
+</div>
+
+<script type="text/javascript">
+    //显示大图
+    function showimage(e) {
+        $("#imgModal").find("#imgInModalID").attr("src", $(e).attr('src'));
+        $("#imgModal").modal();
+    }
+
+    //关闭
+    function closeImageViewer() {
+        $("#imgModal").modal('hide');
+    }
+</script>
+<script src="/static/AdminLTE/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
+<script src="/static/AdminLTE/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
+<script src="/static/AdminLTE/bower_components/select2/dist/js/select2.min.js"></script>
+
+<script type="text/javascript">
+    $(document).ready(function(){
+        $('[data-toggle="tooltip"]').tooltip();
+        // var taskListTable = $('#task-list').DataTable({
+        //     searching: true,
+        //     pageLength: 25
+        // });
+    });
+
+
+    delJob = function ( element , id ) {
+        $.ajax({
+            url: 'http://'+reportHost+'/Bug/api/job/delJob?jobId='+id,
+            // data:{
+            //     'id':id
+            // },
+            type: 'POST',
+            success: function (result) {
+                console.log(result);
+                console.log(result['status'])
+                element.parentNode.parentNode.remove();
+            }
+        });
+    }
+
+</script>