whyczh
2021-04-07 4992d0ea3fb6adaba4331fda37c43e8f0d00a458
src/main/java/com/whyc/service/TestPlanService.java
@@ -11,12 +11,14 @@
import com.whyc.mapper.TestPlanMapper;
import com.whyc.pojo.DeviceManage;
import com.whyc.pojo.TestPlan;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Random;
@Service
@Slf4j
@@ -48,7 +50,14 @@
    public Response startPlan(Integer num){
        TestPlan testPlan = mapper.selectById(num);
        //获取计划重复次数
        int planCount = testPlan.getPlanCount();
        int testCount = testPlan.getTestCount();
        if (planCount!=0 && testCount==planCount){
            return new Response().setMsg(0,"已达到计划重复次数最大值");
        }
        testPlan.setState(1);
        testPlan.setTestCount(++testCount);
        mapper.updateById(testPlan);
        return new Response().setMsg(1,"启动成功");
    }
@@ -61,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);
@@ -82,9 +105,17 @@
    public Response<IPage<TestPlan>> getPageByCondition(int pageNum, int pageSize, TestPlan testPlan){
        QueryWrapper<TestPlan> queryWrapper = new QueryWrapper<>(testPlan);
        //去除已废止的计划,6、8为结果审核状态,计划中仍显示2:已结束
        //去除已废止的计划
        queryWrapper.in("state",0,1,2,6,8);
        List<TestPlan> testPlanList = mapper.selectList(queryWrapper);
        IPage<TestPlan> page = mapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper);
        return new Response<IPage<TestPlan>>().set(1,page);
    }
    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);
        IPage<TestPlan> page = mapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper);
        return new Response<IPage<TestPlan>>().set(1,page);