| | |
| | | public Object setActmParamPl2(@RequestBody ActmResDto param){ |
| | | return service.setActmParamPl2(param); |
| | | } |
| | | |
| | | /** |
| | | * @param devId |
| | | * @param index |
| | | * @param type 1:启动 2:暂停 3:继续 4:停止 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "启动,暂停,继续,停止actm均衡仪") |
| | | @GetMapping("controllerActmParam") |
| | | public Object controlActmParam(@RequestParam int devId,@RequestParam int index,@RequestParam int type){ |
| | |
| | | import com.whyc.pojo.db_lithium_ram_db.DevInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.JsonUtil; |
| | | import com.whyc.util.TestparamHttpUtil; |
| | | import com.whyc.util.TestParamHttpUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | |
| | | //param转json字符串 |
| | | String paramJson = JsonUtil.getGson().toJson(param); |
| | | paramMap.add("testParameter",paramJson); |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_dataA200(restTemplate,url,paramMap); |
| | | ResultA200Dto dto= (ResultA200Dto) TestParamHttpUtil.postForFormDataA200(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("testType",type); |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_dataA200(restTemplate,url,paramMap); |
| | | ResultA200Dto dto= (ResultA200Dto) TestParamHttpUtil.postForFormDataA200(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | //a200一体机暂停/继续 |
| | |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("controlType",type);//1 暂停测试 ,2继续测试 |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_dataA200(restTemplate,url,paramMap); |
| | | ResultA200Dto dto= (ResultA200Dto) TestParamHttpUtil.postForFormDataA200(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | //停止a200一体机放电/充电 |
| | |
| | | import com.whyc.mapper.DevInfMapper; |
| | | import com.whyc.pojo.db_lithium_ram_db.DevActmTestParam; |
| | | import com.whyc.pojo.db_lithium_ram_db.DevInf; |
| | | import com.whyc.util.TestparamHttpUtil; |
| | | import com.whyc.util.TestParamHttpUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("batteryStorageIndex",index); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_dataActm(restTemplate,url,paramMap); |
| | | ResultActmDto dto= (ResultActmDto) TestParamHttpUtil.postForFormDataActm(restTemplate,url,paramMap); |
| | | if(dto.getCode().equals("200")){ |
| | | DevActmTestParam actmParam=new DevActmTestParam(); |
| | | copyActmDTO(dto.getData(),actmParam); |
| | |
| | | paramMap.add("testBatteryArray",param.getTestBatteryArray()); |
| | | paramMap.add("voltage",param.getVoltage()); |
| | | paramMap.add("current",param.getCurrent()); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_dataActm(restTemplate,url,paramMap); |
| | | ResultActmDto dto= (ResultActmDto) TestParamHttpUtil.postForFormDataActm(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | //批量设置Actm均衡仪参数 |
| | | public Object setActmParamPl(ActmResDto param) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | int size=param.getDevIds().size(); |
| | | for (Integer devId:param.getDevIds()) { |
| | | param.setDevId(devId); |
| | | ResultActmDto dto= (ResultActmDto) setActmParam(param); |
| | |
| | | case 4:url=url+"/stopTest";break; //停止 |
| | | } |
| | | paramMap.add("batteryStorageIndex",index); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_dataActm(restTemplate,url,paramMap); |
| | | Object dto= TestParamHttpUtil.postForFormDataActm(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("batteryStorageNumber",param.getBatteryStorageNumber()); |
| | | paramMap.add("batteryNumber",param.getBatteryNumber()); |
| | | ResultActmDto dto= (ResultActmDto) TestparamHttpUtil.postforform_dataActm(restTemplate,url,paramMap); |
| | | ResultActmDto dto= (ResultActmDto) TestParamHttpUtil.postForFormDataActm(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | //批量设设置电池组数与电池节数 |
File was renamed from src/main/java/com/whyc/util/TestparamHttpUtil.java |
| | |
| | | |
| | | import com.whyc.dto.ResultA200Dto; |
| | | import com.whyc.dto.ResultActmDto; |
| | | import com.whyc.dto.ResultActmDto2; |
| | | import org.springframework.http.*; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestClientException; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | public class TestparamHttpUtil { |
| | | public class TestParamHttpUtil { |
| | | |
| | | |
| | | |
| | | //post请求传入form-data 格式 |
| | | public static Object postforform_dataA200( RestTemplate restTemplate,String url, MultiValueMap<String, Object> paramMap){ |
| | | public static Object postForFormDataA200( RestTemplate restTemplate,String url, MultiValueMap<String, Object> paramMap){ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpMethod method = HttpMethod.POST; |
| | | // 设置以表单的方式提交 |
| | |
| | | } |
| | | |
| | | //post请求传入form-data 格式 |
| | | public static Object postforform_dataActm( RestTemplate restTemplate,String url, MultiValueMap<String, Object> paramMap){ |
| | | public static Object postForFormDataActm( RestTemplate restTemplate,String url, MultiValueMap<String, Object> paramMap){ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpMethod method = HttpMethod.POST; |
| | | // 设置以表单的方式提交 |
| | |
| | | " \"count\": 0\n" + |
| | | " }"; |
| | | } |
| | | Object dto= ActionUtil.getGson().fromJson(results, ResultActmDto.class); |
| | | //对results字符串进行去空格处理,查看是否存在"code":200的字符串 |
| | | String resultsAfter = results.replaceAll("\\s*",""); |
| | | Object dto; |
| | | if(resultsAfter.contains("code\":200")){ |
| | | dto= ActionUtil.getGson().fromJson(results, ResultActmDto.class); |
| | | }else{ |
| | | dto= ActionUtil.getGson().fromJson(results, ResultActmDto2.class); |
| | | } |
| | | |
| | | |
| | | return dto; |
| | | } |
| | | |