| | |
| | | QueryWrapper<ExperimentPoint> wrapper = Wrappers.query(); |
| | | wrapper.eq("experiment_id",experimentId); |
| | | List<ExperimentPoint> experimentPoints = pointMapper.selectList(wrapper); |
| | | //TODO 针对已完成的测试点,计算出这段时间内的平均功率并返回,需要考虑是否将功率字段持久化到表中 |
| | | /*//TODO 针对已完成的测试点,计算出这段时间内的平均功率并返回,需要考虑是否将功率字段持久化到表中 |
| | | experimentPoints.stream().forEach(point -> { |
| | | if(point.getStatus()==2){ |
| | | //计算出平均功率并赋值 |
| | | int power = (int) (100 + Math.random() * 10); |
| | | point.setAveragePower(power); |
| | | } |
| | | }); |
| | | });*/ |
| | | return new Response<List<ExperimentPoint>>().set(1,experimentPoints); |
| | | } |
| | | |
| | |
| | | pointMapper.updateEndTime(point.getId(),new Date()); |
| | | //返回这段时间的测试结果 |
| | | //TODO 这段时间内的数据,需要进行动态计算 |
| | | Map<String,String> resMap = new HashMap<>(); |
| | | int value = (int) (100 + Math.random() * 10); |
| | | resMap.put("平均功率",value+"kW"); |
| | | return new Response().set(1,resMap); |
| | | ExperimentPoint pointTemp = new ExperimentPoint(); |
| | | pointTemp.setId(point.getId()); |
| | | pointTemp.setAveragePower(value); |
| | | pointMapper.updateById(pointTemp); |
| | | return new Response().setMsg(1,"测试点结束"); |
| | | } |
| | | |
| | | |
| | |
| | | return new Response().setMsg(1,"测试点中断信号更新成功"); |
| | | } |
| | | |
| | | public Response restartExperimentPoint(Integer id) { |
| | | ExperimentPoint point = new ExperimentPoint(); |
| | | point.setId(id); |
| | | point.setStatus(0); |
| | | point.setStartTime(null); |
| | | point.setEndTime(null); |
| | | pointMapper.updateById(point); |
| | | return new Response().setMsg(1,"重置测试点成功"); |
| | | } |
| | | |
| | | public Response setPrecondition(Integer id,Integer value) { |
| | | switch (id){ |
| | | case 1:{ |