| | |
| | | private ExperimentService service; |
| | | |
| | | @GetMapping("exist") |
| | | @ApiOperation(value = "查询是否当前有试验",notes = "如果有,code=1,返回试验的基础数据;如果没有,code=-1") |
| | | @ApiOperation(value = "查询当前是否有正在进行的试验",notes = "如果有,code=1,返回试验的基础数据;如果没有,code=-1") |
| | | public Response exist(){ |
| | | return service.exist(); |
| | | } |
| | |
| | | @ApiModelProperty("开始时间-最晚时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") |
| | | private Date startTime2; |
| | | @ApiModelProperty("状态:-1-取消,0-未开始,1-进行中,2-完成") |
| | | private Integer status; |
| | | |
| | | public String getType() { |
| | | return type; |
| | |
| | | public void setStartTime2(Date startTime2) { |
| | | this.startTime2 = startTime2; |
| | | } |
| | | |
| | | public Integer getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(Integer status) { |
| | | this.status = status; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.whyc.dto.ExperimentConditionDTO; |
| | | import com.whyc.pojo.Experiment; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Update; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public interface ExperimentMapper extends CustomMapper<Experiment>{ |
| | | List<Experiment> getPage(ExperimentConditionDTO condition); |
| | | List<Experiment> getList(ExperimentConditionDTO condition); |
| | | |
| | | int updateFlag(Experiment experiment); |
| | | |
| | | @Update("update `db_3.5mw_web`.`tb_experiment` set status =1,${timeField}=#{date} where id=#{experimentId} ") |
| | | int updateStatusAndTime(String experimentId, int status,String timeField, Date date); |
| | | } |
| | |
| | | private CommonMapper commonMapper; |
| | | |
| | | public Response exist() { |
| | | QueryWrapper<Experiment> wrapper = Wrappers.query(); |
| | | wrapper.eq("status",1); |
| | | List<Experiment> experiments = mapper.selectList(wrapper); |
| | | ExperimentConditionDTO condition = new ExperimentConditionDTO(); |
| | | condition.setStatus(1); |
| | | List<Experiment> experiments = mapper.getList(condition); |
| | | //不存在试验 |
| | | if (experiments.isEmpty()){ |
| | | return new Response().set(-1,"暂无试验"); |
| | | return new Response().setMsg(-1,"暂无试验"); |
| | | } |
| | | Experiment experiment = experiments.get(0); |
| | | String url = null; |
| | |
| | | }else{ |
| | | url ="不存在呀"; |
| | | } |
| | | return new Response().set(1,url); |
| | | return new Response().set(1,experiments.get(0),url); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 检查中置条件-当前功率和当前定子温度,如果符合标准,返回当前值 |
| | | */ |
| | | public Response checkPreconditionStep1(String type){ |
| | | public Response checkPreconditionStep1(String experimentId){ |
| | | String type = experimentId.split("_")[0].toLowerCase(); |
| | | QueryWrapper<ExperimentPrecondition> wrapper = Wrappers.query(); |
| | | wrapper.eq("type",type+"_1"); |
| | | List<ExperimentPrecondition> preconditions = preconditionMapper.selectList(wrapper); |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //设置试验整体状态为1,启动时间更新 |
| | | mapper.updateStatusAndTime(experimentId,1,"start_time",new Date()); |
| | | return new Response().set(1,preconditions); |
| | | } |
| | | |
| | |
| | | /*======History======*/ |
| | | |
| | | public Response<PageInfo<Experiment>> getPage(Integer pageNum, Integer pageSize, ExperimentConditionDTO condition) { |
| | | condition.setStatus(2); |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<Experiment> experimentList = mapper.getPage(condition); |
| | | List<Experiment> experimentList = mapper.getList(condition); |
| | | //查询结果的duration是分钟,转换为 x时x分格式 |
| | | experimentList.stream().forEach(experiment -> { |
| | | int duration = Integer.parseInt(experiment.getDuration()); |
| | |
| | | String type = experimentId.split("_")[0].toLowerCase(); |
| | | try { |
| | | //检查步骤1,属于正式实验前的环境稳定性校验 |
| | | session.getBasicRemote().sendObject(service.checkPreconditionStep1(type)); |
| | | session.getBasicRemote().sendObject(service.checkPreconditionStep1(experimentId)); |
| | | |
| | | //正式测试点的数据返回 |
| | | //1.返回整体试验点 |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.whyc.mapper.ExperimentMapper" > |
| | | |
| | | <select id="getPage" resultType="com.whyc.pojo.Experiment"> |
| | | <select id="getList" resultType="com.whyc.pojo.Experiment"> |
| | | select |
| | | e.start_time, |
| | | e.end_time, |
| | | TIMESTAMPDIFF(MINUTE,e.start_time,e.end_time) as duration, |
| | | e.id, |
| | | e.name, |
| | | e.type, |
| | | e.project_id, |
| | | e.device_id, |
| | | e.create_time, |
| | | e.start_time, |
| | | e.end_time, |
| | | e.status, |
| | | TIMESTAMPDIFF(MINUTE,e.start_time,e.end_time) as duration, |
| | | u.name as username |
| | | from |
| | | tb_experiment e, |
| | |
| | | <if test="startTime1 !=null"> |
| | | and start_time between #{startTime1} and #{startTime2} |
| | | </if> |
| | | and status = 2 |
| | | <if test="status!=null"> |
| | | and status = #{status} |
| | | </if> |
| | | </select> |
| | | |
| | | <update id="updateFlag" parameterType="com.whyc.pojo.Experiment"> |