Prechádzať zdrojové kódy

之前取消了id自动增长的代码,现已放开,隐藏不必要的菜单

郭超 4 rokov pred
rodič
commit
2766d62907

+ 63 - 68
src/main/java/com/mooctest/listener/SaveEventListener.java

@@ -1,68 +1,63 @@
-//package com.mooctest.listener;
-//
-//import java.lang.annotation.Annotation;
-//import java.lang.reflect.Field;
-//
-//import com.mooctest.annotation.AutoValue;
-//import com.mooctest.model.SequenceId;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-//import org.springframework.data.mongodb.core.FindAndModifyOptions;
-//import org.springframework.data.mongodb.core.MongoTemplate;
-//import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener;
-//import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
-//import org.springframework.data.mongodb.core.mapping.event.BeforeSaveEvent;
-//import org.springframework.data.mongodb.core.query.Criteria;
-//import org.springframework.data.mongodb.core.query.Query;
-//import org.springframework.data.mongodb.core.query.Update;
-//import org.springframework.stereotype.Component;
-//import org.springframework.util.ReflectionUtils;
-//
-//import javax.annotation.Resource;
-//
-//@Component
-//public class SaveEventListener extends AbstractMongoEventListener<Object> {
-//    @Resource(name = "mongoTemplate1")
-//    private MongoTemplate mongo;
-//
-//    @Override
-//    public void onBeforeConvert(BeforeConvertEvent<Object> event) {
-//        Object source = event.getSource();
-//        if (source != null) {
-//            ReflectionUtils.doWithFields(source.getClass(), new ReflectionUtils.FieldCallback() {
-//                public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
-//                    ReflectionUtils.makeAccessible(field);
-//                    // 如果字段添加了我们自定义的AutoValue注解
-//                    if (field.isAnnotationPresent(AutoValue.class) && field.get(source) instanceof Number
-//                            && field.getLong(source) == 0) {
-//                        // field.get(source) instanceof Number &&
-//                        // field.getLong(source)==0
-//                        // 判断注解的字段是否为number类型且值是否等于0.如果大于0说明有ID不需要生成ID
-//                        // 设置自增ID
-//
-//                        field.set(source, getNextId(event.getCollectionName()));
-//
-//                    }
-//                }
-//            });
-//        }
-//    }
-//
-//    /**
-//     * 获取下一个自增ID
-//     *
-//     * @param collName
-//     *            集合(这里用类名,就唯一性来说最好还是存放长类名)名称
-//     * @return 序列值
-//     */
-//    private Long getNextId(String collName) {
-//        Query query = new Query(Criteria.where("collName").is(collName));
-//        Update update = new Update();
-//        update.inc("seqId", 1);
-//        FindAndModifyOptions options = new FindAndModifyOptions();
-//        options.upsert(true);
-//        options.returnNew(true);
-//        SequenceId seq = mongo.findAndModify(query, update, options, SequenceId.class);
-//        return seq.getSeqId();
-//    }
-//}
+package com.mooctest.listener;
+
+import com.mooctest.annotation.AutoValue;
+import com.mooctest.model.SequenceId;
+import org.springframework.data.mongodb.core.FindAndModifyOptions;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener;
+import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ReflectionUtils;
+
+import javax.annotation.Resource;
+import java.lang.reflect.Field;
+
+@Component
+public class SaveEventListener extends AbstractMongoEventListener<Object> {
+    @Resource(name = "mongoTemplate1")
+    private MongoTemplate mongo;
+
+    @Override
+    public void onBeforeConvert(BeforeConvertEvent<Object> event) {
+        Object source = event.getSource();
+        if (source != null) {
+            ReflectionUtils.doWithFields(source.getClass(), new ReflectionUtils.FieldCallback() {
+                public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
+                    ReflectionUtils.makeAccessible(field);
+                    // 如果字段添加了我们自定义的AutoValue注解
+                    if (field.isAnnotationPresent(AutoValue.class) && field.get(source) instanceof Number
+                            && field.getLong(source) == 0) {
+                        // field.get(source) instanceof Number &&
+                        // field.getLong(source)==0
+                        // 判断注解的字段是否为number类型且值是否等于0.如果大于0说明有ID不需要生成ID
+                        // 设置自增ID
+
+                        field.set(source, getNextId(event.getCollectionName()));
+
+                    }
+                }
+            });
+        }
+    }
+
+    /**
+     * 获取下一个自增ID
+     *
+     * @param collName
+     *            集合(这里用类名,就唯一性来说最好还是存放长类名)名称
+     * @return 序列值
+     */
+    private Long getNextId(String collName) {
+        Query query = new Query(Criteria.where("collName").is(collName));
+        Update update = new Update();
+        update.inc("seqId", 1);
+        FindAndModifyOptions options = new FindAndModifyOptions();
+        options.upsert(true);
+        options.returnNew(true);
+        SequenceId seq = mongo.findAndModify(query, update, options, SequenceId.class);
+        return seq.getSeqId();
+    }
+}

+ 3 - 4
src/main/java/com/mooctest/service/BugDataService.java

@@ -10,7 +10,6 @@ import org.springframework.stereotype.Service;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -90,7 +89,7 @@ public class BugDataService {
         if(bugs.size()!=count){
             // 报告数量不一致 , 重新引入
             List<BugData> savedBugs = bugDataDao.findByExamIdAndCaseId( examId,  caseId);
-            AtomicInteger allCount = new AtomicInteger((int) bugDataDao.count());
+//            AtomicInteger allCount = new AtomicInteger((int) bugDataDao.count());
             // ?
             List<String > bugIds = savedBugs.stream().map(BugData::getBugId).collect(Collectors.toList());
             List<BugData> toSave = new ArrayList<>();
@@ -102,8 +101,8 @@ public class BugDataService {
                             .status(0)
                             .reviewTimeMillis(s.getCreateTimeMillis())
                             .bugId(s.getId()).build();
-                    allCount.getAndIncrement();
-                    tempData.setId(allCount.get() + 1);
+//                    allCount.getAndIncrement();
+//                    tempData.setId(allCount.get() + 1);
                     toSave.add(tempData);
                 }
             });

+ 3 - 4
src/main/java/com/mooctest/service/FinalReportService.java

@@ -61,7 +61,6 @@ public class FinalReportService {
         BeanUtils.copyProperties(dto, report);
         report.setImgUrls(String.join(",", dto.getImgUrls()));
         finalReportDao.save(report);
-
         return dto;
     }
 
@@ -158,9 +157,9 @@ public class FinalReportService {
 
         List<FinalReport> finalReports = bugs.parallelStream().map(bug -> {
             FinalReport finalReport = new FinalReport();
-            long count = finalReportDao.count();
-            count = count + 1;
-            finalReport.setId(count);
+//            long count = finalReportDao.count();
+//            count = count + 1;
+//            finalReport.setId(count);
             finalReport.setDescription(bug.getDescription());
             finalReport.setImgUrls(String.join(",", bug.getImgUrls()));
             finalReport.setSeverity(bug.getSeverity());

+ 3 - 3
src/main/resources/application.yml

@@ -1,5 +1,5 @@
-spring.profiles.active: private-cloud
-#spring.profiles.active: private-localhost
+#spring.profiles.active: private-cloud
+spring.profiles.active: private-localhost
 #spring.profiles.active: dev-online
 spring:
   mvc:
@@ -58,7 +58,7 @@ spring:
 mongodb:
   database: test
   host: 121.196.124.158
-  port: 27117
+  port: 27217
   username: mooctest
   password: mooctest
 

+ 1 - 1
src/main/resources/templates/addCrowdTask.html

@@ -43,7 +43,7 @@
         </h1>
         <ol class="breadcrumb">
             <li><a href="/home"><i class="fa fa-dashboard"></i> 主页</a></li>
-            <li><a href="/addCrowdTask">新建众测任务</a></li>
+<!--            <li><a href="/addCrowdTask">新建众测任务</a></li>-->
         </ol>
     </section>
 

+ 82 - 82
src/main/resources/templates/home.html

@@ -44,11 +44,11 @@
                                 <i class="fa fa-align-justify"></i>任务列表
                             </a>
                         </li>
-                        <li id="crowdSidebarMenu-addCrowdTask">
-                            <a href="/addCrowdTask">
-                                <i class="fa fa-plus"></i>新建任务
-                            </a>
-                        </li>
+<!--                        <li id="crowdSidebarMenu-addCrowdTask">-->
+<!--                            <a href="/addCrowdTask">-->
+<!--                                <i class="fa fa-plus"></i>新建任务-->
+<!--                            </a>-->
+<!--                        </li>-->
                         <li id="crowdSidebarMenu-importData">
                             <a href="/importData">
                                 <i class="fa fa-file-excel-o"></i>数据导入
@@ -57,50 +57,50 @@
                     </ul>
                 </li>
 
-                <li class="treeview">
-                    <a href="#">
-                        <i class="fa fa-file-text-o"></i>
-                        <span>
-                            众包审核
-                        </span>
-                    </a>
-
-                    <ul class="treeview-menu">
-                        <li>
-                            <a href="/addPaper">
-                                <i class="glyphicon glyphicon-pencil"></i>
-                                <span>
-                                    新建表单
-                                </span>
-                            </a>
-                        </li>
-                        <li>
-                            <a href="/papers">
-                                <i class="fa fa-reorder "></i>
-                                <span>
-                                    表单列表
-                                </span>
-                            </a>
-                        </li>
-                        <li>
-                            <a href="#">
-                                <i class="fa  fa-plus"></i>
-                                <span>
-                                    新建任务
-                                </span>
-                            </a>
-                        </li>
-                        <li>
-                            <a href="/review/jobs">
-                                <i class="glyphicon glyphicon-tasks"></i>
-                                <span>
-                                    任务列表
-                                </span>
-                            </a>
-                        </li>
-
-                    </ul>
-                </li>
+<!--                <li class="treeview">-->
+<!--                    <a href="#">-->
+<!--                        <i class="fa fa-file-text-o"></i>-->
+<!--                        <span>-->
+<!--                            众包审核-->
+<!--                        </span>-->
+<!--                    </a>-->
+
+<!--                    <ul class="treeview-menu">-->
+<!--                        <li>-->
+<!--                            <a href="/addPaper">-->
+<!--                                <i class="glyphicon glyphicon-pencil"></i>-->
+<!--                                <span>-->
+<!--                                    新建表单-->
+<!--                                </span>-->
+<!--                            </a>-->
+<!--                        </li>-->
+<!--                        <li>-->
+<!--                            <a href="/papers">-->
+<!--                                <i class="fa fa-reorder "></i>-->
+<!--                                <span>-->
+<!--                                    表单列表-->
+<!--                                </span>-->
+<!--                            </a>-->
+<!--                        </li>-->
+<!--                        <li>-->
+<!--                            <a href="#">-->
+<!--                                <i class="fa  fa-plus"></i>-->
+<!--                                <span>-->
+<!--                                    新建任务-->
+<!--                                </span>-->
+<!--                            </a>-->
+<!--                        </li>-->
+<!--                        <li>-->
+<!--                            <a href="/review/jobs">-->
+<!--                                <i class="glyphicon glyphicon-tasks"></i>-->
+<!--                                <span>-->
+<!--                                    任务列表-->
+<!--                                </span>-->
+<!--                            </a>-->
+<!--                        </li>-->
+
+<!--                    </ul>-->
+<!--                </li>-->
             </ul>
         </section>
     </aside>
@@ -156,39 +156,39 @@
                         </div>
                     </div>
                 </div>
-                <div class="col-md-6">
-
-                    <div class="box">
-                        <div class="box-header">
-                            <h3 class="box-title">最近的众审任务</h3>
-                        </div>
-                        <!-- /.box-header -->
-                        <div class="box-body no-padding">
-                            <table class="table table-striped"  style="text-align: center;">
-                                <tr>
-                                    <th style="text-align: center;">测试序号(考试号)</th>
-                                    <th style="text-align: center;">任务序号(题号)</th>
-                                    <th style="text-align: center;">应用名</th>
-                                </tr>
-                                <th:block th:each="task : ${jobs}">
-                                    <tr>
-                                        <td><b><a th:href="'/review/jobDetail?id='+${task.get('id')}"  th:text="${task.get('name')}"></a></b></td>
-                                        <!--<td><img th:src="${task.icon}" style="width: 25px; height: 25px;" /></td>-->
-                                        <td>
-                                            <span th:if="${task.get('group').equals('') and task.get('exam_id').equals('')}" class="label label-warning"  >暂无</span>
-                                            <span th:if="${task.get('group').equals('') and !task.get('exam_id').equals('')}" class="label label-info"  >企业版</span>
-                                            <span th:if="${task.get('exam_id').equals('') and !task.get('group').equals('') }" class="label label-success"  >教育版</span>
-                                        </td>
-                                        <!--                        <td><span  class="label label-info" th:text="${task.caseId}">题号</span></td>-->
-
-                                        <td><span  class=" " th:if="${task.get('create_time')!=null}" th:text="${#dates.format(task.get('create_time'),'yyyy-MM-dd HH:mm:ss')} " ></span></td>
-                                    </tr>
-                                </th:block>
-                            </table>
-
-                        </div>
-                    </div>
-                </div>
+<!--                <div class="col-md-6">-->
+
+<!--                    <div class="box">-->
+<!--                        <div class="box-header">-->
+<!--                            <h3 class="box-title">最近的众审任务</h3>-->
+<!--                        </div>-->
+<!--                        &lt;!&ndash; /.box-header &ndash;&gt;-->
+<!--                        <div class="box-body no-padding">-->
+<!--                            <table class="table table-striped"  style="text-align: center;">-->
+<!--                                <tr>-->
+<!--                                    <th style="text-align: center;">测试序号(考试号)</th>-->
+<!--                                    <th style="text-align: center;">任务序号(题号)</th>-->
+<!--                                    <th style="text-align: center;">应用名</th>-->
+<!--                                </tr>-->
+<!--                                <th:block th:each="task : ${jobs}">-->
+<!--                                    <tr>-->
+<!--                                        <td><b><a th:href="'/review/jobDetail?id='+${task.get('id')}"  th:text="${task.get('name')}"></a></b></td>-->
+<!--                                        &lt;!&ndash;<td><img th:src="${task.icon}" style="width: 25px; height: 25px;" /></td>&ndash;&gt;-->
+<!--                                        <td>-->
+<!--                                            <span th:if="${task.get('group').equals('') and task.get('exam_id').equals('')}" class="label label-warning"  >暂无</span>-->
+<!--                                            <span th:if="${task.get('group').equals('') and !task.get('exam_id').equals('')}" class="label label-info"  >企业版</span>-->
+<!--                                            <span th:if="${task.get('exam_id').equals('') and !task.get('group').equals('') }" class="label label-success"  >教育版</span>-->
+<!--                                        </td>-->
+<!--                                        &lt;!&ndash;                        <td><span  class="label label-info" th:text="${task.caseId}">题号</span></td>&ndash;&gt;-->
+
+<!--                                        <td><span  class=" " th:if="${task.get('create_time')!=null}" th:text="${#dates.format(task.get('create_time'),'yyyy-MM-dd HH:mm:ss')} " ></span></td>-->
+<!--                                    </tr>-->
+<!--                                </th:block>-->
+<!--                            </table>-->
+
+<!--                        </div>-->
+<!--                    </div>-->
+<!--                </div>-->
             </div>
 
 

+ 5 - 5
src/main/resources/templates/task_detail.html

@@ -104,11 +104,11 @@
                     </li>
                 </ul>
             </li>
-            <li id="crowdSidebarMenu-addCrowdTask">
-                <a href="/addCrowdTask">
-                    <i class="fa fa-plus"></i>新建众测任务
-                </a>
-            </li>
+<!--            <li id="crowdSidebarMenu-addCrowdTask">-->
+<!--                <a href="/addCrowdTask">-->
+<!--                    <i class="fa fa-plus"></i>新建众测任务-->
+<!--                </a>-->
+<!--            </li>-->
             <li id="crowdSidebarMenu-importData">
                 <a href="/importData">
                     <i class="fa fa-file-excel-o"></i>数据导入

+ 2 - 2
src/main/resources/templates/task_list.html

@@ -93,8 +93,8 @@
                         <td><span  class="label label-info" th:text="${task.caseId}">题号</span></td>
                         <td><b><a th:href="'/task_detail?examId=' + ${task.examId} + '&amp;caseId=' + ${task.caseId}" id="task-name" th:text="${task.name}">{{ task.name }}</a></b></td>
                         <!--<td th:text="${task.version}"></td>-->
-                        <td th:if="${task.numOfUndeal > 0}"><span  class="label label-info">审核中</span></td>
-                        <td th:if="${task.numOfUndeal == 0}"><span  class="label label-success">未开始</span></td>
+                        <td th:if="${task.numOfTotalBug > 0}"><span  class="label label-info">审核中</span></td>
+                        <td th:if="${task.numOfTotalBug == 0}"><span  class="label label-success">未开始</span></td>
                         <!--<td th:text="${task.startTime}">{{ task.print_start_time }}</td>-->
                         <!--<td th:text="${task.endTime}">{{ task.print_end_time }}</td>-->
                         <td style="width: 200px;">