| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.AbeStateMapper; |
| | | import com.whyc.pojo.db_abe_ram.AbeState; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class AbeStateService { |
| | | |
| | | public static final int CMD_StopHuoHua_Test = 0x20; //停止活化测试 |
| | | public static final int CMD_StopHuoHua_TestAck = 0x21; //停止活化测试成功 |
| | | |
| | | @Resource |
| | | private AbeStateMapper mapper; |
| | |
| | | AbeState abeState = mapper.selectOne(query); |
| | | return new Response<AbeState>().set(1,abeState); |
| | | } |
| | | |
| | | public Response stopHuoHua() { |
| | | boolean flag = sendCmdToDev(CMD_StopHuoHua_Test); |
| | | return new Response().set(1,flag,flag?"停止活化测试成功":"停止活化测试失败"); |
| | | } |
| | | |
| | | public boolean sendCmdToDev(int opCmd) { |
| | | int m_cmd = opCmd; |
| | | int m_cmd_ack = opCmd; |
| | | switch(m_cmd) { |
| | | case CMD_StopHuoHua_Test: m_cmd_ack = CMD_StopHuoHua_TestAck; break; |
| | | default: |
| | | return false; |
| | | } |
| | | //更新op_cmd |
| | | UpdateWrapper<AbeState> updateWrapper = Wrappers.update(); |
| | | updateWrapper.set("op_cmd",m_cmd); |
| | | int flag=mapper.update((AbeState) ActionUtil.objeNull,updateWrapper); |
| | | boolean res_exe = false; |
| | | if(flag>0) |
| | | { |
| | | QueryWrapper<AbeState> queryWrapper = Wrappers.query(); |
| | | queryWrapper.last(" limit 1"); |
| | | for(int n=0; n<80; n++) |
| | | { |
| | | |
| | | AbeState param=mapper.selectOne(queryWrapper); |
| | | if(param!=null){ |
| | | if(param.getOpCmd()==m_cmd_ack){ |
| | | res_exe = true; |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(250); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return res_exe; |
| | | } |
| | | } |