forked from I3-YF/i3plus-mes-pcn-yfai
报工问题修改
parent
d32640909e
commit
77b8304de0
@ -0,0 +1,6 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.test;
|
||||||
|
|
||||||
|
public interface TestService {
|
||||||
|
|
||||||
|
void insertList();
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.test;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentLogDetail;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentLogDetailRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentLogRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TestServiceImpl implements TestService{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesEquipmentLogRepository equipmentLogRepository;
|
||||||
|
@Autowired
|
||||||
|
private MesEquipmentLogDetailRepository equipmentLogDetailRepository;
|
||||||
|
@Autowired
|
||||||
|
private SnowflakeIdMaker snowflakeIdMaker;
|
||||||
|
|
||||||
|
private static ExecutorService executorService = new ThreadPoolExecutor(1, 10,
|
||||||
|
0L, TimeUnit.MILLISECONDS,
|
||||||
|
new LinkedBlockingQueue<>(200), r -> {
|
||||||
|
Thread thread = new Thread(r);
|
||||||
|
thread.setName("executorService--"+r.hashCode());
|
||||||
|
return thread;
|
||||||
|
},new ThreadPoolExecutor.DiscardPolicy());
|
||||||
|
|
||||||
|
private static ExecutorService executorService2 = new ThreadPoolExecutor(1, 10,
|
||||||
|
0L, TimeUnit.MILLISECONDS,
|
||||||
|
new LinkedBlockingQueue<>(200), r -> {
|
||||||
|
Thread thread = new Thread(r);
|
||||||
|
thread.setName("executorService--"+r.hashCode());
|
||||||
|
return thread;
|
||||||
|
},new ThreadPoolExecutor.DiscardPolicy());
|
||||||
|
public void insertList() {
|
||||||
|
executorService = new ThreadPoolExecutor(1, 10,
|
||||||
|
0L, TimeUnit.MILLISECONDS,
|
||||||
|
new LinkedBlockingQueue<>(200), r -> {
|
||||||
|
Thread thread = new Thread(r);
|
||||||
|
thread.setName("executorService--"+r.hashCode());
|
||||||
|
return thread;
|
||||||
|
},new ThreadPoolExecutor.DiscardPolicy());
|
||||||
|
|
||||||
|
executorService2 = new ThreadPoolExecutor(1, 10,
|
||||||
|
0L, TimeUnit.MILLISECONDS,
|
||||||
|
new LinkedBlockingQueue<>(200), r -> {
|
||||||
|
Thread thread = new Thread(r);
|
||||||
|
thread.setName("executorService--"+r.hashCode());
|
||||||
|
return thread;
|
||||||
|
},new ThreadPoolExecutor.DiscardPolicy());
|
||||||
|
List<MesEquipmentLogDetail> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i= 1; i< 10; i ++) {
|
||||||
|
executorService.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (int j = 1; j < 500; j++) {
|
||||||
|
|
||||||
|
executorService2.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MesEquipmentLogDetail equipmentLogDetail = new MesEquipmentLogDetail();
|
||||||
|
ConvertBean.serviceModelInitialize(equipmentLogDetail, "test");
|
||||||
|
equipmentLogDetail.setId(snowflakeIdMaker.nextId());
|
||||||
|
equipmentLogDetail.setEquipVariableId(123123l);
|
||||||
|
equipmentLogDetail.setEquipVariableName("aaa");
|
||||||
|
equipmentLogDetail.setReadWriteFlag(1);
|
||||||
|
equipmentLogDetail.setDataType("40");
|
||||||
|
equipmentLogDetail.setEquipId(7);
|
||||||
|
equipmentLogDetail.setEquipmentCode("Foaming5#");
|
||||||
|
list.add(equipmentLogDetail);
|
||||||
|
/* try {
|
||||||
|
Thread.sleep(50);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
Thread.sleep(10000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
equipmentLogDetailRepository.saveAll(list);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue