| | |
| | | import com.whyc.dto.A200ResDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.ResultA200Dto; |
| | | import com.whyc.factory.ThreadPoolExecutorFactory; |
| | | import com.whyc.mapper.DevA200TestparamMapper; |
| | | import com.whyc.mapper.DevInfMapper; |
| | | import com.whyc.pojo.db_lithium_ram_db.DevA200Testparam; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.CountDownLatch; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Service |
| | | public class DevA200TestparamService { |
| | |
| | | return dto; |
| | | } |
| | | |
| | | //批量控制a200均衡仪 |
| | | public Response controllA200ParamPl(List<Integer> devIds) { |
| | | //批量启动a200均衡仪 |
| | | public Response startA200ParamPl(List<Integer> devIds,int type) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | try { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(devIds.size()); |
| | | for (int devId:devIds) { |
| | | poolExecutor.execute(() -> { |
| | | ResultA200Dto dto= (ResultA200Dto) startA200Param(devId,type); |
| | | map.put(devId,dto); |
| | | latch.countDown(); |
| | | }); |
| | | } |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return new Response().set(1,true,"批量控制a200均衡仪"); |
| | | } |
| | | |
| | | //批量启动a200均衡仪 |
| | | public Response stopA200ParamPl(List<Integer> devIds) { |
| | | Map<Integer,Object> map=new HashMap<>(); |
| | | try { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(devIds.size()); |
| | | for (int devId:devIds) { |
| | | poolExecutor.execute(() -> { |
| | | ResultA200Dto dto= (ResultA200Dto) stopA200Param(devId); |
| | | map.put(devId,dto); |
| | | latch.countDown(); |
| | | }); |
| | | } |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return new Response().set(1,true,"批量控制a200均衡仪"); |
| | | } |
| | | |