From 7d64716cb0d406f21cde03976fd273bd07fdc06f Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期二, 28 九月 2021 11:44:28 +0800
Subject: [PATCH] 更新用户-角色-菜单-权限

---
 src/main/java/com/whyc/service/TestPlanService.java |   36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/whyc/service/TestPlanService.java b/src/main/java/com/whyc/service/TestPlanService.java
index 1691d11..faed7d6 100644
--- a/src/main/java/com/whyc/service/TestPlanService.java
+++ b/src/main/java/com/whyc/service/TestPlanService.java
@@ -2,21 +2,16 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
 import com.whyc.dto.Response;
 import com.whyc.mapper.TestPlanMapper;
-import com.whyc.pojo.DeviceManage;
 import com.whyc.pojo.TestPlan;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.Date;
-import java.util.List;
 
 @Service
 @Slf4j
@@ -28,6 +23,7 @@
         testPlan.setCreator("admin");
         testPlan.setCreateTime(new Date());
         testPlan.setState(0);//璇曢獙鐘舵�侊細鏈紑濮�
+        testPlan.setTestCount(0);//娴嬭瘯娴嬭瘯榛樿涓�0
         mapper.insert(testPlan);
         return new Response().setMsg(1,"娣诲姞鎴愬姛");
     }
@@ -49,8 +45,14 @@
     public Response startPlan(Integer num){
         TestPlan testPlan = mapper.selectById(num);
         //鑾峰彇璁″垝閲嶅娆℃暟
-        int planCount = testPlan.getPlanCount();
-        int testCount = testPlan.getTestCount();
+        int planCount = 0;
+        int testCount = 0;
+        if (testPlan.getPlanCount()!=null){
+            planCount = testPlan.getPlanCount();
+        }
+        if (testPlan.getTestCount()!=null){
+            testCount= testPlan.getTestCount();
+        }
         if (planCount!=0 && testCount==planCount){
             return new Response().setMsg(0,"宸茶揪鍒拌鍒掗噸澶嶆鏁版渶澶у��");
         }
@@ -68,10 +70,24 @@
     }
     public Response stopPlan(Integer num){
         TestPlan testPlan = mapper.selectById(num);
-        testPlan.setState(2);
+        //鑾峰彇璁″垝閲嶅娆℃暟
+        int planCount = testPlan.getPlanCount();
+        int testCount = testPlan.getTestCount();
+        if (planCount!=0 && testCount==planCount){
+            testPlan.setState(3);//宸茬粨鏉�
+            int k = (int)(Math.random()*2);
+            if (k==1){
+                testPlan.setConclusion("鍚堟牸");
+            }else{
+                testPlan.setConclusion("涓嶅悎鏍�");
+            }
+        }else {
+            testPlan.setState(2);//宸插仠姝�
+        }
         mapper.updateById(testPlan);
         return new Response().setMsg(1,"鍋滄鎴愬姛");
     }
+
     public Response verifiedPlan(Integer num,String verifier){
         TestPlan testPlan = mapper.selectById(num);
         testPlan.setState(6);
@@ -90,7 +106,7 @@
     public Response<IPage<TestPlan>> getPageByCondition(int pageNum, int pageSize, TestPlan testPlan){
         QueryWrapper<TestPlan> queryWrapper = new QueryWrapper<>(testPlan);
         //鍘婚櫎宸插簾姝㈢殑璁″垝
-        queryWrapper.in("state",0,1,2,6,8);
+        queryWrapper.in("state",0,1,2,3,6,8);
         IPage<TestPlan> page = mapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper);
         return new Response<IPage<TestPlan>>().set(1,page);
 
@@ -99,7 +115,7 @@
     public Response<IPage<TestPlan>> getConclusion(int pageNum, int pageSize, TestPlan testPlan){
         QueryWrapper<TestPlan> queryWrapper = new QueryWrapper<>(testPlan);
         //6銆�8涓虹粨鏋滃鏍哥姸鎬侊紝2锛氳鍒掑凡缁撴潫锛岀粨璁烘湭瀹℃牳
-        queryWrapper.in("state",2,6,8);
+        queryWrapper.in("state",3,6,8);
         IPage<TestPlan> page = mapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper);
         return new Response<IPage<TestPlan>>().set(1,page);
 

--
Gitblit v1.9.1