| | |
| | | @Autowired(required = false) |
| | | private DevInfMapper dinfMapper; |
| | | |
| | | @Resource |
| | | private RestTemplate restTemplate; |
| | | private final RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | public DevA200TestparamService(RestTemplate restTemplate) { |
| | | this.restTemplate = restTemplate; |
| | | } |
| | | |
| | | //读取a200一体机参数 |
| | | public Object getA200Param(int devId) { |
| | |
| | | } |
| | | |
| | | |
| | | //设置a200均衡仪参数 |
| | | public Object setA200Param(A200ResDto param,int devId) { |
| | | //设置a200一体机参数 |
| | | public Object setA200Param(A200ResDto param) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("dev_id",devId); |
| | | wrapper.eq("dev_id",param.getDevId()); |
| | | wrapper.last("limit 1"); |
| | | DevInf dinf=dinfMapper.selectOne(wrapper); |
| | | String url="http://"+dinf.getDevIp()+":8080/webService/setTestParameter"; |
| | |
| | | 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; |
| | | } |
| | | |
| | | //启动a200均衡仪放电/充电 |
| | | //批量设置a200一体机参数 |
| | | public Object setA200ParamPl2(A200ResDto param) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | int size=param.getDevIds().size(); |
| | | try { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(size); |
| | | for (int i=0;i<size;i++) { |
| | | int finaldevId=param.getDevIds().get(i); |
| | | poolExecutor.execute(() -> { |
| | | int finalIIdevId=finaldevId; |
| | | param.setDevId(finalIIdevId); |
| | | ResultA200Dto dto= (ResultA200Dto) setA200Param(param); |
| | | map.put(finalIIdevId,dto); |
| | | latch.countDown(); |
| | | }); |
| | | } |
| | | latch.await(4, TimeUnit.MINUTES); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return new Response().setII(1,true,map,"批量设置a200一体机参数"); |
| | | } |
| | | //批量设置a200一体机参数 |
| | | public Object setA200ParamPl(A200ResDto param) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | int size=param.getDevIds().size(); |
| | | for (int i=0;i<size;i++) { |
| | | int finaldevId=param.getDevIds().get(i); |
| | | param.setDevId(finaldevId); |
| | | ResultA200Dto dto= (ResultA200Dto) setA200Param(param); |
| | | map.put(finaldevId,dto); |
| | | } |
| | | return new Response().setII(1,true,map,"批量设置a200一体机参数"); |
| | | } |
| | | |
| | | //启动a200一体机放电/充电 |
| | | public Object startA200Param(int devId,int type) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("dev_id",devId); |
| | |
| | | String url="http://"+dinf.getDevIp()+":8080/webService/startTest"; |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("testType",type); |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_data(restTemplate,url,paramMap); |
| | | paramMap.add("testType",type);//1 放电,2 充电 |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_dataA200(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | //停止a200均衡仪放电/充电 |
| | | //a200一体机暂停/继续 |
| | | public Object pauseA200Param(int devId, int type) { |
| | | 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/pauseTest"; |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
| | | paramMap.add("controlType",type);//1 暂停测试 ,2继续测试 |
| | | ResultA200Dto dto= (ResultA200Dto) TestparamHttpUtil.postforform_dataA200(restTemplate,url,paramMap); |
| | | return dto; |
| | | } |
| | | //停止a200一体机放电/充电 |
| | | public Object stopA200Param(int devId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("dev_id",devId); |
| | |
| | | return dto; |
| | | } |
| | | |
| | | //批量启动a200均衡仪 |
| | | public Response startA200ParamPl(List<Integer> devIds,int type) { |
| | | //批量启动a200一体机 |
| | | public Response startA200ParamPl2(List<Integer> devIds,int type) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | try { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return new Response().set(1,true,"批量控制a200均衡仪"); |
| | | return new Response().set(1,true,"批量控制a200一体机"); |
| | | } |
| | | |
| | | //批量启动a200均衡仪 |
| | | public Response stopA200ParamPl(List<Integer> devIds) { |
| | | //批量启动a200一体机 |
| | | public Response startA200ParamPl(List<Integer> devIds,int type) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | for (int devId:devIds) { |
| | | ResultA200Dto dto= (ResultA200Dto) startA200Param(devId,type); |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("dev_id",devId); |
| | | wrapper.set("batch_state",1); |
| | | dinfMapper.update(null,wrapper); |
| | | map.put(devId,dto); |
| | | } |
| | | return new Response().setII(1,true,map,"批量控制a200一体机"); |
| | | } |
| | | |
| | | //批量停止a200一体机 |
| | | public Response stopA200ParamPl2(List<Integer> devIds) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | try { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return new Response().set(1,true,"批量控制a200均衡仪"); |
| | | return new Response().set(1,true,"批量停止a200一体机"); |
| | | } |
| | | //批量停止a200一体机 |
| | | public Response stopA200ParamPl(List<Integer> devIds) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | for (int devId:devIds) { |
| | | ResultA200Dto dto= (ResultA200Dto) stopA200Param(devId); |
| | | map.put(devId,dto); |
| | | } |
| | | return new Response().setII(1,true,map,"批量停止a200一体机"); |
| | | } |
| | | |
| | | //将dto拷贝至param |
| | |
| | | a200Param.setChargePower(dto.getChargePower()); |
| | | a200Param.setBatteryTemperatureProtect(dto.getBatteryTemperatureProtect()); |
| | | } |
| | | |
| | | |
| | | } |