| | |
| | | |
| | | @ApiOperation(value = "读取actm一体机参数") |
| | | @GetMapping("getActmParam") |
| | | public Object getActmParam(@RequestParam int devId){ |
| | | return service.getActmParam(devId); |
| | | public Object getActmParam(@RequestParam int devId,@RequestParam int index){ |
| | | return service.getActmParam(devId,index); |
| | | } |
| | | |
| | | @ApiOperation(value = "设置actm均衡仪参数") |
| | |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | String paramJson=JSONObject.toJSONString(param); |
| | | paramMap.add("testParameter",paramJson); |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_data(restTemplate,url,paramMap); |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_dataA200(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("testType",type); |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_data(restTemplate,url,paramMap); |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_dataA200(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | //停止a200均衡仪放电/充电 |
| | |
| | | private RestTemplate restTemplate; |
| | | |
| | | //读取Actm一体机参数 |
| | | public Object getActmParam(int devId) { |
| | | public Object getActmParam(int devId,int index) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("dev_id",devId); |
| | | 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); |
| | | ResultActmDto dto= ActionUtil.getGson().fromJson(results, ResultActmDto.class); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("batteryStorageIndex",index); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_dataActm(restTemplate,url,paramMap); |
| | | if(dto.getCode().equals("200")){ |
| | | DevActmTestparam actmParam=new DevActmTestparam(); |
| | | copyActmDTO(dto.getData(),actmParam); |
| | |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | String paramJson= JSONObject.toJSONString(param); |
| | | paramMap.add("testParameter",paramJson); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_data(restTemplate,url,paramMap); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_dataActm(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | case 4:url=url+"/stopTest";break; //停止 |
| | | } |
| | | paramMap.add("batteryStorageIndex",index); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_data(restTemplate,url,paramMap); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_dataActm(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | package com.whyc.util; |
| | | |
| | | import com.whyc.dto.ResultA200Dto; |
| | | import com.whyc.dto.ResultActmDto; |
| | | import org.springframework.http.*; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | |
| | | |
| | | |
| | | //post请求传入form-data 格式 |
| | | public static Object postforform_data( RestTemplate restTemplate,String url, MultiValueMap<String, Object> paramMap){ |
| | | public static Object postforform_dataA200( RestTemplate restTemplate,String url, MultiValueMap<String, Object> paramMap){ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpMethod method = HttpMethod.POST; |
| | | // 设置以表单的方式提交 |
| | |
| | | Object dto= ActionUtil.getGson().fromJson(results, ResultA200Dto.class); |
| | | return dto; |
| | | } |
| | | |
| | | //post请求传入form-data 格式 |
| | | public static Object postforform_dataActm( RestTemplate restTemplate,String url, MultiValueMap<String, Object> paramMap){ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpMethod method = HttpMethod.POST; |
| | | // 设置以表单的方式提交 |
| | | headers.add("Content-Type", MediaType.MULTIPART_FORM_DATA_VALUE); |
| | | HttpEntity< MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(paramMap, headers); |
| | | ResponseEntity<String> response = restTemplate.exchange(url, method, requestEntity,String.class ); |
| | | String results= response.getBody(); |
| | | Object dto= ActionUtil.getGson().fromJson(results, ResultActmDto.class); |
| | | return dto; |
| | | } |
| | | } |