| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.google.gson.JsonSyntaxException; |
| | | import com.whyc.dto.A200ResDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.ResultA200Dto; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestClientException; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | public DevA200TestparamService(RestTemplate restTemplate) { |
| | | this.restTemplate = restTemplate; |
| | | } |
| | | |
| | | //批量处理发送接口请求 |
| | | public ResultA200Dto getA200Dto(String url){ |
| | | ResultA200Dto dto= null; |
| | | String results =null; |
| | | try { |
| | | results = restTemplate.postForObject(url, null, String.class); |
| | | } catch (RestClientException e) { |
| | | results=" {\n" + |
| | | " \"code\": \"205\",\n" + |
| | | " \"msg\": \"接口调用出错\",\n" + |
| | | " \"data\": null,\n" + |
| | | " \"count\": 0\n" + |
| | | " }"; |
| | | }finally { |
| | | dto = ActionUtil.getGson().fromJson(results, ResultA200Dto.class); |
| | | } |
| | | return dto; |
| | | } |
| | | //读取a200一体机参数 |
| | | public Object getA200Param(int devId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | |
| | | wrapper.last("limit 1"); |
| | | DevInf dinf=dinfMapper.selectOne(wrapper); |
| | | String url="http://"+dinf.getDevIp()+":8080/webService/getTestParameter"; |
| | | String results = restTemplate.postForObject(url, null, String.class); |
| | | ResultA200Dto dto= ActionUtil.getGson().fromJson(results, ResultA200Dto.class); |
| | | ResultA200Dto dto= getA200Dto(url); |
| | | if(dto.getCode().equals("200")){ |
| | | DevA200Testparam a200Param=new DevA200Testparam(); |
| | | copyA200DTO(dto.getData(),a200Param); |
| | |
| | | wrapper.last("limit 1"); |
| | | DevInf dinf=dinfMapper.selectOne(wrapper); |
| | | String url="http://"+dinf.getDevIp()+":8080/webService/stopTest"; |
| | | String results = restTemplate.postForObject(url, null, String.class); |
| | | ResultA200Dto dto= ActionUtil.getGson().fromJson(results, ResultA200Dto.class); |
| | | ResultA200Dto dto= getA200Dto(url); |
| | | return dto; |
| | | } |
| | | |