whyclxw
2024-09-03 ecf48a2c6d5752809e5810f35a33ba65cd843c13
src/main/java/com/whyc/service/DevA200TestparamService.java
@@ -6,6 +6,7 @@
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;
@@ -23,6 +24,9 @@
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 {
@@ -97,8 +101,43 @@
        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均衡仪");
    }