Merge branch 'master' into master_merge

This commit is contained in:
2024-07-15 09:11:28 +08:00
36 changed files with 906 additions and 673 deletions

View File

@@ -209,6 +209,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
PluggingUnpluggingMachineDeviceDriver pluggingUnpluggingMachineDeviceDriver;
SiemensWeightConveyorDeviceDriver siemensWeightConveyorDeviceDriver;
if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) {
hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver();
hongXiangStationDeviceDriver.writing(code, value);
@@ -225,7 +226,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
pluggingUnpluggingMachineDeviceDriver = (PluggingUnpluggingMachineDeviceDriver) device.getDeviceDriver();
pluggingUnpluggingMachineDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof SiemensWeightConveyorDeviceDriver) {
siemensWeightConveyorDeviceDriver = (SiemensWeightConveyorDeviceDriver) device.getDeviceDriver();
siemensWeightConveyorDeviceDriver.writing(code, value);
}
}
response.setStatus(200);

View File

@@ -3,6 +3,7 @@ package org.nl;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
import org.mybatis.spring.annotation.MapperScan;
import org.nl.config.SpringContextHolder;
import org.springframework.boot.SpringApplication;
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@EnableAsync
@RestController
@EnableDynamicTp
@SpringBootApplication(exclude = {
QuartzAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
@@ -33,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
@EnableMethodCache(basePackages = "org.nl")
@EnableCreateCacheAnnotation
@MapperScan("org.nl.**.mapper")
public class AppRun {
public static void main(String[] args) {

View File

@@ -50,7 +50,7 @@ public class AgvWaitUtil {
ManipulatorAgvStationDeviceDriver manipulatorAgvStationDeviceDriver;
BoxSubvolumesConveyorDeviceDriver boxSubvolumesConveyorDeviceDriver;
//agv诺宝对接位安全信号交互
if (startDevice.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
if (startDevice.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) startDevice.getDeviceDriver();
if (manipulatorAgvStationDeviceDriver.getTo_command() != 2) {
manipulatorAgvStationDeviceDriver.writing(2);

View File

@@ -86,9 +86,11 @@ public class QueryAGVStatus {
if (StrUtil.isNotEmpty(instructionCode)){
Device carCode = deviceAppService.findDeviceByCode(instructionCode);
XgAgvCarDeviceDriver xgAgvCarDeviceDriver;
if (carCode.getDeviceDriver() instanceof XgAgvCarDeviceDriver){
xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) carCode.getDeviceDriver();
xgAgvCarDeviceDriver.setTaskType(AgvActionTypeEnum.getStatus(instruction.getAgv_action_type()));
if (null != carCode) {
if (carCode.getDeviceDriver() instanceof XgAgvCarDeviceDriver) {
xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) carCode.getDeviceDriver();
xgAgvCarDeviceDriver.setTaskType(AgvActionTypeEnum.getStatus(instruction.getAgv_action_type()));
}
}
}

View File

@@ -796,15 +796,16 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
//放货前二次分配
if (address.contains("WAIT")) {
String newPointCode = applyCCAgvTask(task_code, instructionDto);
LuceneLogDto logDto = LuceneLogDto.builder()
.content("叉车允许放货" + "新点位:" + newPointCode)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
JSONObject map = new JSONObject();
map.put("status", 200);
map.put("message", "允许叉车放货!" + "点位" + newPointCode);
log.info("允许仙工AGV放货设备号 - {}", newPointCode);
LuceneLogDto logDto = LuceneLogDto.builder()
.content("叉车允许放货" + "新点位:" + newPointCode + map )
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
return map;
}
//放货前等待
@@ -859,6 +860,8 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
//二次分配更新点位
updataTask(instructionDto, jo.getString("data"));
//请求成功调用叉车追加动作块
sendAddSequencesToCCAgv(instructionDto.getInstruction_code(), jo.getString("data"), instructionDto);
return jo.getString("data");
@@ -882,7 +885,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
//追加订单封口
jo.put("complete", true);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("追加叉车运单")
.device_code(instructionDto.getCarno())
.content("指令号:" + instructionCode + ",追加叉车运单参数:" + jo)
.build();
logDto.setLog_level(4);
@@ -903,8 +906,8 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
.timeout(20000)
.execute();
LuceneLogDto logDto1 = LuceneLogDto.builder()
.device_code("叉车追加运单响应")
.content("指令号:" + instructionCode + ",下发追加诺宝叉车运单反馈参数:" + jo)
.device_code(instructionDto.getCarno())
.content("指令号:" + instructionCode + ",下发追加诺宝叉车运单反馈参数:" + result)
.build();
logDto1.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);

View File

@@ -69,7 +69,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
final ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
TwoAgvPhase twoAgvPhase = new TwoAgvPhase();
String error_code = "0";
@@ -260,12 +259,11 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
luceneExecuteLogService.deviceExecuteLog(logDto);
}
} else {
log.info("等待LMS系统进行确认允许取货设备号{},指令号{}", device_code, ikey);
message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey;
log.info("等待LMS系统进行确认允许取货设备号{},option值{}", standardOrdinarySiteDeviceDriver.getDevice_code(), standardOrdinarySiteDeviceDriver.getOption());
logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey)
.device_code(standardOrdinarySiteDeviceDriver.getDevice_code())
.content("等待LMS系统进行确认允许取货,设备号" + standardOrdinarySiteDeviceDriver.getDevice_code() + ",option当前值" + standardOrdinarySiteDeviceDriver.getOption())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -306,7 +304,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
}
} else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
try {
manipulatorAgvStationDeviceDriver.writing(2);
} catch (Exception e) {
@@ -321,11 +318,10 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "行架不允许取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", manipulatorAgvStationDeviceDriver.getDeviceCode(), manipulatorAgvStationDeviceDriver.getAction(), ikey);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content(message)
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -767,12 +763,12 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
luceneExecuteLogService.deviceExecuteLog(logDto);
}
} else {
log.info("等待LMS系统进行确认允许取货设备号{},指令号{}", device_code, ikey);
message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey;
logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code());
log.info("等待LMS系统进行确认允许取货设备号{},option值{}", standardOrdinarySiteDeviceDriver.getDeviceCode(), standardOrdinarySiteDeviceDriver.getOption());
message = "等待LMS系统进行确认允许取货,设备号:" + standardOrdinarySiteDeviceDriver.getDeviceCode() + ",option值:" + standardOrdinarySiteDeviceDriver.getOption();
logServer.deviceExecuteLog(standardOrdinarySiteDeviceDriver.getDeviceCode(), "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code());
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content(message)
.device_code(standardOrdinarySiteDeviceDriver.getDeviceCode())
.content(standardOrdinarySiteDeviceDriver.getDevice_code() + "option值不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -805,7 +801,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.device_code(manipulatorAgvStationDeviceDriver.getDevice_code())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
@@ -946,7 +942,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
luceneExecuteLogService.deviceExecuteLog(logDto);
}
} else if (phase == 0x77) {
} else if (phase == 0x4D) {
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
@@ -998,6 +994,60 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
} catch (Exception e) {
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
}
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, next_device_code)) {
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
try {
manipulatorAgvStationDeviceDriver.writing(4);
} catch (Exception e) {
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
}
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, start_device_code2)) {
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
try {
manipulatorAgvStationDeviceDriver.writing(4);
} catch (Exception e) {
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
@@ -1015,88 +1065,35 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, next_device_code)) {
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
}
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, next_device_code2)) {
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
try {
manipulatorAgvStationDeviceDriver.writing(4);
} catch (Exception e) {
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
try {
manipulatorAgvStationDeviceDriver.writing(2);
} catch (Exception e) {
e.printStackTrace();
}
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, start_device_code2)) {
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
try {
manipulatorAgvStationDeviceDriver.writing(4);
} catch (Exception e) {
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
}
} else if (ObjectUtil.isNotEmpty(start_device_code) && StrUtil.equals(device_code, next_device_code2)) {
if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver();
try {
manipulatorAgvStationDeviceDriver.writing(2);
} catch (Exception e) {
e.printStackTrace();
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
message = "设备号:" + manipulatorAgvStationDeviceDriver.getDevice_code() + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
}
}
// else {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
// LuceneLogDto logDto = LuceneLogDto.builder()
@@ -1106,7 +1103,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
// logDto.setLog_level(4);
// luceneExecuteLogService.deviceExecuteLog(logDto);
// }
}
}
// 取货完毕
@@ -1434,8 +1430,8 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content(message)
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -1862,8 +1858,8 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件";
log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content(message)
.device_code(manipulatorAgvStationDeviceDriver.getDeviceCode())
.content(manipulatorAgvStationDeviceDriver.getDevice_code() + "动作信号不为1")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);

View File

@@ -11,6 +11,10 @@ import org.openscada.opc.lib.da.ItemState;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
UnifiedDataAccessor opcUdw;
@@ -35,201 +39,223 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
public void checkcontrol(Map<String, Object> itemValues) throws Exception {
Group group = opcServerService.getServer(this.getOpcServer());
Map<String, Object> write = new HashMap();
Map<String, Item> readitems = new LinkedHashMap();
List<String> itemsString = new ArrayList();
itemsString = new ArrayList<>(itemValues.keySet());
Iterator is = itemsString.iterator();
while (is.hasNext()) {
String string = (String) is.next();
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
try {
readitems.put(string, group.addItem(string));
} catch (Exception e) {
e.printStackTrace();
}
}
int i = 0;
while (true) {
//下发信号
try {
if (i == 0) {
control(itemValues);
} else {
controlByNewConn(itemValues);
}
Group group = opcServerService.getServer(this.getOpcServer());
Map<String, Object> write = new HashMap();
Map<String, Item> readitems = new LinkedHashMap();
List<String> itemsString = new ArrayList();
itemsString = new ArrayList<>(itemValues.keySet());
Iterator is = itemsString.iterator();
} catch (Exception e) {
e.printStackTrace();
}
Map<String, Object> read = new HashMap();
Map<Item, ItemState> itemStatus = null;
boolean check = true;
try {
if (i > 0) {
group = opcServerService.getServer(this.getOpcServer());
itemsString = new ArrayList<>(itemValues.keySet());
Iterator nis = itemsString.iterator();
while (nis.hasNext()) {
String string = (String) nis.next();
try {
readitems.put(string, group.addItem(string));
} catch (Exception e) {
e.printStackTrace();
}
while (is.hasNext()) {
String string = (String) is.next();
try {
readitems.put(string, group.addItem(string));
} catch (Exception e) {
e.printStackTrace();
}
itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0]));
} else {
itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0]));
}
Set<Item> items = itemStatus.keySet();
Iterator var15 = items.iterator();
while (var15.hasNext()) {
Item item = (Item) var15.next();
ItemState itemState = (ItemState) itemStatus.get(item);
Object value = OpcUtl.getValue(item, itemState);
read.put(item.getId(), value);
}
int i = 0;
while (true) {
//下发信号
Iterator var24 = itemsString.iterator();
try {
if (i == 0) {
control(itemValues);
} else {
controlByNewConn(itemValues);
}
while (var24.hasNext()) {
String itemString = (String) var24.next();
if (!ObjectUtl.isEquals(String.valueOf(itemValues.get(itemString)), String.valueOf(read.get(itemString)))) {
} catch (Exception e) {
e.printStackTrace();
}
Map<String, Object> read = new HashMap();
Map<Item, ItemState> itemStatus = null;
boolean check = true;
try {
if (i > 0) {
group = opcServerService.getServer(this.getOpcServer());
itemsString = new ArrayList<>(itemValues.keySet());
Iterator nis = itemsString.iterator();
while (nis.hasNext()) {
String string = (String) nis.next();
try {
readitems.put(string, group.addItem(string));
} catch (Exception e) {
e.printStackTrace();
}
}
itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0]));
} else {
itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0]));
}
Set<Item> items = itemStatus.keySet();
Iterator var15 = items.iterator();
while (var15.hasNext()) {
Item item = (Item) var15.next();
ItemState itemState = (ItemState) itemStatus.get(item);
Object value = OpcUtl.getValue(item, itemState);
read.put(item.getId(), value);
}
Iterator var24 = itemsString.iterator();
while (var24.hasNext()) {
String itemString = (String) var24.next();
if (!ObjectUtl.isEquals(String.valueOf(itemValues.get(itemString)), String.valueOf(read.get(itemString)))) {
check = false;
}
}
} catch (Exception e) {
e.printStackTrace();
check = false;
}
if (check) {
return "";
}
if (i > 0) {
ThreadUtl.sleep(100L);
}
if (i >= 3) {
// log.info("写入次数超过3次而失败");
throw new RuntimeException("写入次数超过3次而失败");
}
++i;
}
} catch (Exception e) {
e.printStackTrace();
check = false;
Thread.currentThread().interrupt();
throw new IllegalStateException("Interrupted", e);
}
if (check) {
return;
});
try {
String result = future.get(2, TimeUnit.SECONDS); // 设置超时时间为2秒
System.out.println(result);
} catch (CompletionException e) {
Throwable cause = e.getCause();
if (cause instanceof TimeoutException) {
System.out.println("Operation timed out");
} else {
throw e; // rethrow other exceptions
}
if (i > 0) {
ThreadUtl.sleep(100L);
}
if (i >= 3) {
// log.info("写入次数超过3次而失败");
throw new RuntimeException("写入次数超过3次而失败");
}
++i;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
public boolean controlByNewConn(Map<String, Object> itemValues) {
public boolean controlByNewConn (Map < String, Object > itemValues){
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue[] p2;
p2 = new ItemValue[itemValues.size()];
int i = 0;
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue());
p2[i] = new ItemValue();
p2[i].setItem_code(entry.getKey());
p2[i].setItem_value(entry.getValue());
i++;
}
return this.controlByNewConn(p2);
}
public boolean control(Map<String, Object> itemValues) {
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue[] p2;
p2 = new ItemValue[itemValues.size()];
int i = 0;
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue());
p2[i] = new ItemValue();
p2[i].setItem_code(entry.getKey());
p2[i].setItem_value(entry.getValue());
i++;
}
return this.control(p2);
}
public boolean control(ItemValue[] itemValues) {
if (itemValues != null && itemValues.length != 0) {
String this_items = JsonUtl.parseWithoutException(itemValues);
boolean need_write = false;
StringBuilder sb = new StringBuilder();
ItemValue[] var5 = itemValues;
int var6 = itemValues.length;
for (int var7 = 0; var7 < var6; ++var7) {
ItemValue itemValue = var5[var7];
String code = itemValue.getItem_code();
Object udw_value = this.getUdwValue(code);
Object write_value = itemValue.getItem_value();
sb.append(code);
sb.append(":");
sb.append(JsonUtl.parseWithoutException(udw_value));
sb.append(";");
if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
need_write = true;
} else {
//log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
ItemValue[] p2;
p2 = new ItemValue[itemValues.size()];
int i = 0;
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue());
p2[i] = new ItemValue();
p2[i].setItem_code(entry.getKey());
p2[i].setItem_value(entry.getValue());
i++;
}
}
// need_write = true;
if (need_write) {
Date date = new Date();
return this.controlByNewConn(p2);
}
public boolean control (Map < String, Object > itemValues){
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue[] p2;
p2 = new ItemValue[itemValues.size()];
int i = 0;
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue());
p2[i] = new ItemValue();
p2[i].setItem_code(entry.getKey());
p2[i].setItem_value(entry.getValue());
i++;
}
return this.control(p2);
}
public boolean control (ItemValue[]itemValues){
if (itemValues != null && itemValues.length != 0) {
String this_items = JsonUtl.parseWithoutException(itemValues);
boolean need_write = false;
StringBuilder sb = new StringBuilder();
ItemValue[] var5 = itemValues;
int var6 = itemValues.length;
for (int var7 = 0; var7 < var6; ++var7) {
ItemValue itemValue = var5[var7];
String code = itemValue.getItem_code();
Object udw_value = this.getUdwValue(code);
Object write_value = itemValue.getItem_value();
sb.append(code);
sb.append(":");
sb.append(JsonUtl.parseWithoutException(udw_value));
sb.append(";");
if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
need_write = true;
} else {
//log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
}
}
// need_write = true;
if (need_write) {
Date date = new Date();
/*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) {
log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check);
return false;
}*/
this.last_items = this_items;
this.sendTime = date;
this.last_items = this_items;
this.sendTime = date;
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
opcServerService.writeInteger(this.getOpcServer(), itemValues);
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
ItemValue[] var17 = itemValues;
int var18 = itemValues.length;
opcServerService.writeInteger(this.getOpcServer(), itemValues);
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
ItemValue[] var17 = itemValues;
int var18 = itemValues.length;
for (int var19 = 0; var19 < var18; ++var19) {
ItemValue itemValue = var17[var19];
String code = itemValue.getItem_code();
Object value = itemValue.getItem_value();
opcValueAccessor.setValue(code, value);
for (int var19 = 0; var19 < var18; ++var19) {
ItemValue itemValue = var17[var19];
String code = itemValue.getItem_code();
Object value = itemValue.getItem_value();
opcValueAccessor.setValue(code, value);
}
}
return true;
} else {
throw new RuntimeException("下发 无内容");
}
}
return true;
} else {
throw new RuntimeException("下发 无内容");
}
}
public boolean controlByNewConn(ItemValue[] itemValues) {
if (itemValues != null && itemValues.length != 0) {
String this_items = JsonUtl.parseWithoutException(itemValues);
boolean need_write = false;
StringBuilder sb = new StringBuilder();
ItemValue[] var5 = itemValues;
int var6 = itemValues.length;
public boolean controlByNewConn (ItemValue[]itemValues){
if (itemValues != null && itemValues.length != 0) {
String this_items = JsonUtl.parseWithoutException(itemValues);
boolean need_write = false;
StringBuilder sb = new StringBuilder();
ItemValue[] var5 = itemValues;
int var6 = itemValues.length;
// for (int var7 = 0; var7 < var6; ++var7) {
// ItemValue itemValue = var5[var7];
// String code = itemValue.getItem_code();
@@ -245,36 +271,36 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
// log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
// }
// }
need_write = true;
if (need_write) {
Date date = new Date();
need_write = true;
if (need_write) {
Date date = new Date();
/*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) {
log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check);
return false;
}*/
this.last_items = this_items;
this.sendTime = date;
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
this.last_items = this_items;
this.sendTime = date;
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
opcServerService.writeIntegerByNewConn(this.getOpcServer(), itemValues);
opcServerService.writeIntegerByNewConn(this.getOpcServer(), itemValues);
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
ItemValue[] var17 = itemValues;
int var18 = itemValues.length;
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
ItemValue[] var17 = itemValues;
int var18 = itemValues.length;
for (int var19 = 0; var19 < var18; ++var19) {
ItemValue itemValue = var17[var19];
String code = itemValue.getItem_code();
Object value = itemValue.getItem_value();
opcValueAccessor.setValue(code, value);
for (int var19 = 0; var19 < var18; ++var19) {
ItemValue itemValue = var17[var19];
String code = itemValue.getItem_code();
Object value = itemValue.getItem_value();
opcValueAccessor.setValue(code, value);
}
}
return true;
} else {
throw new RuntimeException("下发 无内容");
}
}
return true;
} else {
throw new RuntimeException("下发 无内容");
}
}
}

View File

@@ -45,7 +45,6 @@ import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.openscada.opc.lib.da.Server;
import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 一楼木箱入库站点
@@ -54,7 +53,6 @@ import java.util.concurrent.ThreadPoolExecutor;
@Data
@RequiredArgsConstructor
public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
protected ItemProtocol itemProtocol = new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@@ -231,30 +229,6 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
log.debug("设备运转模式:等待工作");
break;
case 2:
//申请任务
if (move > 0 && task == 0 && !requireSucess) {
instruction_require();
}else {
String remark = "";
;
if (mode != 2) {
remark = "universal_remark2";
}
if (move != 0) {
remark = "universal_remark3";
}
if (task != 0) {
remark = "universal_remark4";
if (ObjectUtil.isNotEmpty(this.inst)) {
this.inst = null;
}
}
if (requireSucess) {
remark = "universal_remark5";
}
this.setNotCreateInstMessage(remark);
//}
}
break;
case 25:
if ( StrUtil.isEmpty(material_barcode)) {

View File

@@ -44,6 +44,7 @@ import org.nl.system.service.param.ISysParamService;
import org.openscada.opc.lib.da.Server;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
@@ -53,7 +54,7 @@ import java.util.concurrent.ThreadPoolExecutor;
@Data
@RequiredArgsConstructor
public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
private final static Executor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
protected ItemProtocol itemProtocol = new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);

View File

@@ -53,7 +53,6 @@ import java.util.concurrent.ThreadPoolExecutor;
@Data
@RequiredArgsConstructor
public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
protected ItemProtocol itemProtocol = new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);

View File

@@ -26,7 +26,6 @@ import java.util.concurrent.ThreadPoolExecutor;
@Slf4j
@Data
public class ManipulatorCacheDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
protected ItemProtocol itemProtocol = new ItemProtocol(this);
//当前指令

View File

@@ -28,6 +28,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.device_driver.led.led_screen.LedScreenDeviceDriver;
import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO;
import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver;
import org.nl.acs.device_driver.two_conveyor.manipulator_agv_station.ManipulatorAgvStationDeviceDriver;
import org.nl.acs.enums.StorageTypeEnum;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
@@ -298,9 +299,9 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
List toInstructions;
//木箱入库申请入库任务
if (mode == 6 && !requireSucess) {
if (StrUtil.isEmpty(barcode)||StrUtil.isEmpty(material_barcode)) {
if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) {
message = "托盘条码为空、或者子卷码为空";
}else {
} else {
applyIn(StorageTypeEnum.BOX_IN.getType(), mode);
}
@@ -310,7 +311,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (mode == 7 && move == 1 && !requireSucess) {
if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) {
message = "托盘条码为空、或者子卷码为空";
}else {
} else {
applyIn(StorageTypeEnum.STORAGE.getType(), mode);
}
@@ -321,7 +322,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (mode == 9 && move == 1 && !requireSucess) {
if (container_type == 0 || StrUtil.isEmpty(barcode)) {
message = "托盘类型为空";
}else {
} else {
applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode);
}
}
@@ -330,7 +331,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (mode == 18 && move == 1 && !requireSucess) {
if (StrUtil.isEmpty(barcode)) {
message = "托盘条码为空";
}else {
} else {
applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), mode);
}
@@ -339,7 +340,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (mode == 23 && !requireSucess) {
if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) {
message = "条码为空";
}else {
} else {
applyErrorHeight();
}
@@ -406,7 +407,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)&&(barcode.startsWith("A")||barcode.startsWith("B"))) {
if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
@@ -473,7 +474,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)&&(barcode.startsWith("A")||barcode.startsWith("B"))) {
if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
@@ -589,7 +590,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)&&(barcode.startsWith("A")||barcode.startsWith("B"))) {
if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) {
param.put("vehicle_code", barcode);
}
param.put("type", type);
@@ -645,7 +646,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)&&(barcode.startsWith("A")||barcode.startsWith("B"))) {
if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
@@ -654,7 +655,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (StrUtil.isNotEmpty(hand_material_barcode)) {
param.put("material_barcode", hand_material_barcode);
}
if (mode == 7 && weight != 0){
if (mode == 7 && weight != 0) {
param.put("weight", weight);
}
param.put("type", type);
@@ -796,21 +797,32 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
//判断有无出入库任务是相同路线
//判断有没有DDJ对接位出入库的指令
List<Instruction> byCodeAndExcute = instructionService.findByCodeAndExcute(next_device_code);
if (CollUtil.isNotEmpty(byCodeAndExcute)){
Iterator<Instruction> iterator = byCodeAndExcute.iterator();
while (iterator.hasNext()) {
Instruction instruction = iterator.next();
Device nextDevice = deviceAppService.findDeviceByCode(instruction.getNext_device_code());
if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.storage.name())){
iterator.remove();
}
}
}
if (CollUtil.isNotEmpty(byCodeAndExcute)){
this.message="有DDJ对接位出入库的指令";
if (CollUtil.isNotEmpty(byCodeAndExcute)) {
this.message = "有DDJ对接位出入库的指令";
requireSucess = false;
return true;
}
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
//判断对接位和关联站点光电信号
getDeviceCodeList = beltConveyorDeviceDriver.getExtraDeviceCodes("link_device_code");
if (CollUtil.isNotEmpty(getDeviceCodeList)) {
String linkDeviceCode = getDeviceCodeList.get(0);
Device linkDevice = deviceAppService.findDeviceByCode(linkDeviceCode);
BeltConveyorDeviceDriver linkDeviceDriver;
if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver();
if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) && (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) {
this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机";
requireSucess = false;
return true;
}
}
}
}
TaskDto dto = taskserver.findByCodeAndExcute(taskdto.getNext_device_code(), taskdto.getStart_device_code());
if (ObjectUtil.isNotEmpty(dto)) {
requireSucess = false;

View File

@@ -51,7 +51,6 @@ import java.util.concurrent.ThreadPoolExecutor;
@Data
@RequiredArgsConstructor
public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
protected ItemProtocol itemProtocol = new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);

View File

@@ -168,7 +168,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
}
// 更新指令状态
if (mode == 3 && task > 0) {
if (null!=inst) {
if (null != inst) {
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code();
}
updateInstructionStatus();
@@ -261,10 +261,10 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
}
//放货完成
if ( action == 4 && move == 0) {
if (action == 4 && move == 0) {
if (inst != null) {
try {
logServer.deviceExecuteLog(this.device_code,"","","放货完成");
logServer.deviceExecuteLog(this.device_code, "", "", "放货完成");
finish_instruction(inst);
Map<String, Object> map1 = new HashMap<>();
List list = new ArrayList();
@@ -278,19 +278,19 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
e.printStackTrace();
}
feedMessage = "";
}else {
} else {
feedMessage = "universal_feedMessage5";
if (mode != 3) {
feedMessage = "universal_feedMessage1";
feedMessage = "universal_feedMessage1";
}
if (action != 8) {
feedMessage = "universal_feedMessage2";
feedMessage = "universal_feedMessage2";
}
if (move != 0) {
feedMessage = "universal_feedMessage3";
feedMessage = "universal_feedMessage3";
}
if (task == 0) {
feedMessage = "universal_feedMessage4";
feedMessage = "universal_feedMessage4";
}
}
}
@@ -312,20 +312,27 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
if (ObjectUtil.isEmpty(putDeviceCodeList)) {
putDeviceCodeList = this.getExtraDeviceCodes("put_device_code");
}
//找终点为入库输送线工位任务类型为行架的任务
for (int i = 0; i < getDeviceCodeList.size(); i++) {
String startDeviceCode = getDeviceCodeList.get(i);
//先查指令
List<TaskDto> taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode);
List<TaskDto> taskDtoStream = taskDtoInstruction.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(taskDtoStream)) {
TaskDto taskDtoIns = taskDtoStream.get(0);
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) {
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code());
String interactionJson = taskDtoIns.getInteraction_json();
//先查指令
List<Instruction> instructionList = instructionService.findReadyIns();
if (CollUtil.isNotEmpty(instructionList)) {
List<Instruction> instructionsReady = new ArrayList<>();
Instruction instructionReady = null;
for (Instruction instruction : instructionList) {
if (getDeviceCodeList.contains(instruction.getStart_device_code())) {
instructionsReady.add(instruction);
}
}
if (CollUtil.isNotEmpty(instructionsReady)) {
List<Instruction> instructions = instructionsReady.stream().sorted(Comparator.comparing(Instruction::getCreate_time)).collect(Collectors.toList());
instructionReady = instructions.get(0);
}
if (ObjectUtil.isNotEmpty(instructionReady)) {
TaskDto byTaskCode = taskserver.findByTaskCode(instructionReady.getTask_code());
String interactionJson = byTaskCode.getInteraction_json();
if (StrUtil.isNotEmpty(interactionJson)) {
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
String start_device_code = taskDtoIns.getStart_device_code();
String next_device_code = taskDtoIns.getNext_device_code();
String start_device_code = byTaskCode.getStart_device_code();
String next_device_code = byTaskCode.getNext_device_code();
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
String start_addr = startDevice.getExtraValue().get("address").toString();
@@ -350,108 +357,108 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
Map<String, Object> map10 = new HashMap<>();
Map<String, Object> map11 = new HashMap<>();
try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10,map11,instruction.getVehicle_code());
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instructionReady.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9, map10, map11, instructionReady.getVehicle_code());
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
+ ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
+ instructionReady.getInstruction_code() + ",指令起点:" + instructionReady.getStart_device_code()
+ ",指令终点:" + instructionReady.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
}
this.setRequireSucess(true);
return true;
}
} else {
List<TaskDto> taskDtos = taskserver.findByTrappedManipulatorReady();
List<TaskDto> taskDtosReady = new ArrayList<>();
TaskDto taskDto = null;
if (CollUtil.isNotEmpty(taskDtos)) {
for (TaskDto taskDto1 : taskDtos) {
if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) {
taskDtosReady.add(taskDto1);
}
}
} else {
List<TaskDto> taskDtos = taskserver.findByTrappedManipulatorReady();
List<TaskDto> taskDtosReady = new ArrayList<>();
TaskDto taskDto = null;
if (CollUtil.isNotEmpty(taskDtos)) {
for (TaskDto taskDto1 : taskDtos) {
if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) {
taskDtosReady.add(taskDto1);
}
}
if (CollUtil.isNotEmpty(taskDtosReady)) {
List<TaskDto> taskDtoList = taskDtosReady.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)).collect(Collectors.toList());
taskDto = taskDtoList.get(0);
}
if (CollUtil.isNotEmpty(taskDtosReady)) {
List<TaskDto> taskDtoList = taskDtosReady.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)).collect(Collectors.toList());
taskDto = taskDtoList.get(0);
}
if (ObjectUtil.isNotEmpty(taskDto)) {
String interactionJson = taskDto.getInteraction_json();
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
String start_device_code = taskDto.getStart_device_code();
String next_device_code = taskDto.getNext_device_code();
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
if (ObjectUtil.isEmpty(start_addr)) {
notCreateInstMessage = "universal_notCreateInstMessage1";
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
}
if (ObjectUtil.isEmpty(next_addr)) {
notCreateInstMessage = "universal_notCreateInstMessage1";
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
}
if (ObjectUtil.isNotEmpty(taskDto)) {
String interactionJson = taskDto.getInteraction_json();
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
String start_device_code = taskDto.getStart_device_code();
String next_device_code = taskDto.getNext_device_code();
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
if (ObjectUtil.isEmpty(start_addr)) {
notCreateInstMessage = "universal_notCreateInstMessage1";
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
}
if (ObjectUtil.isEmpty(next_addr)) {
notCreateInstMessage = "universal_notCreateInstMessage1";
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
}
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver();
if (beltConveyorDeviceDriver.getMove() != 1&&beltConveyorDeviceDriver.getMode() != 2) {
notCreateInstMessage = "universal_notCreateInstMessage2";
return false;
}
}
String taskid = taskDto.getTask_id();
String taskcode = taskDto.getTask_code();
String start_point_code = taskDto.getStart_point_code();
String route_plan_code = taskDto.getRoute_plan_code();
String next_point_code = taskDto.getNext_point_code();
Instruction instdto = new Instruction();
packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code);
try {
instructionService.create(instdto);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(device_code+"创建指令时出现异常:" + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver();
if (beltConveyorDeviceDriver.getMove() != 1 && beltConveyorDeviceDriver.getMode() != 2) {
notCreateInstMessage = "universal_notCreateInstMessage2";
return false;
}
//创建指令后修改任务状态
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskserver.update(taskDto);
requireSucess = true;
Map<String, Object> map1 = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map4 = new HashMap<>();
Map<String, Object> map5 = new HashMap<>();
Map<String, Object> map6 = new HashMap<>();
Map<String, Object> map7 = new HashMap<>();
Map<String, Object> map8 = new HashMap<>();
Map<String, Object> map9 = new HashMap<>();
Map<String, Object> map10 = new HashMap<>();
Map<String, Object> map11 = new HashMap<>();
try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10, map11, taskDto.getVehicle_code());
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(device_code+"创建指令时出现异常:" + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
this.setRequireSucess(true);
return true;
} else {
notCreateInstMessage = "universal_notCreateInstMessage";
}
String taskid = taskDto.getTask_id();
String taskcode = taskDto.getTask_code();
String start_point_code = taskDto.getStart_point_code();
String route_plan_code = taskDto.getRoute_plan_code();
String next_point_code = taskDto.getNext_point_code();
Instruction instdto = new Instruction();
packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code);
try {
instructionService.create(instdto);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(device_code + "创建指令时出现异常:" + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
//创建指令后修改任务状态
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskserver.update(taskDto);
requireSucess = true;
Map<String, Object> map1 = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map4 = new HashMap<>();
Map<String, Object> map5 = new HashMap<>();
Map<String, Object> map6 = new HashMap<>();
Map<String, Object> map7 = new HashMap<>();
Map<String, Object> map8 = new HashMap<>();
Map<String, Object> map9 = new HashMap<>();
Map<String, Object> map10 = new HashMap<>();
Map<String, Object> map11 = new HashMap<>();
try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9, map10, map11, taskDto.getVehicle_code());
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(device_code + "创建指令时出现异常:" + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
this.setRequireSucess(true);
return true;
} else {
notCreateInstMessage = "universal_notCreateInstMessage";
}
}
return true;
@@ -459,7 +466,6 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
}
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8, Map<String, Object> map9, Map<String, Object> map10, Map<String, Object> map11, String vehicleCode) {
List list = new ArrayList();
@@ -511,7 +517,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
map11.put("value", vehicleCode);
list.add(map11);
}
Map<String, Object> map12 = new HashMap<>();
Map<String, Object> map12 = new HashMap<>();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBindingTimes())) {
map12.put("code", "to_binding_times");
map12.put("value", interactionJsonDTO.getBindingTimes());
@@ -522,22 +528,23 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
this.writing(list);
}
private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) {
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(next_point_code);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(device_code);
}
private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) {
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(next_point_code);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(device_code);
}
/**
* 完成指令
*
* @param inst
* @return
* @throws Exception
@@ -549,6 +556,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
/**
* 下发信号
*
* @param list
*/
public void writing(List list) {
@@ -591,6 +599,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();

View File

@@ -133,6 +133,8 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
//行架机械手申请任务成功标识
boolean requireSucess = false;
//行架请求动作标识
boolean actionRequireSucess = false;
private int instruction_finished_time_out;
int branchProtocol = 0;
@@ -185,9 +187,12 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
to_type = this.itemProtocol.getTo_type();
if (mode != last_mode) {
requireSucess = false;
}
if (action != last_action) {
actionRequireSucess = false;
}
// 更新指令状态
if (mode == 3 && task > 0) {
if (null!=inst) {
@@ -196,13 +201,13 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
updateInstructionStatus();
}
//四个点行架任务满轴放货完成后调lms生成rgv任务
if (action == 6 && task > 0 ){
if (action == 6 && task > 0 && !actionRequireSucess ){
Integer actionType = ActionTypeEnum.RELEASE_FINISHING.getCode();
creatAGV(actionType,action);
}
//空载具取货完成
if (action == 7 && task > 0 ){
if (action == 7 && task > 0 && !actionRequireSucess ){
Integer actionType = ActionTypeEnum.IN_FINISHING.getCode();
creatAGV(actionType, action);
}
@@ -304,7 +309,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
map1.put("value", toCommand);
list.add(map1);
this.writing(list);
this.actionRequireSucess = true;
} else {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)

View File

@@ -833,9 +833,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
map4.put("value", "0");
list.add(map4);
Map map5 = new HashMap<>();
map4.put("code", "to_task");
map4.put("value", "0");
list.add(map4);
map5.put("code", "to_task");
map5.put("value", "0");
list.add(map5);
this.writing(list);
message = null;

View File

@@ -48,7 +48,7 @@ import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.Executor;
/**
* 烘箱-行架机械手
@@ -79,7 +79,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
@Autowired
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
final ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
final Executor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
//工作模式
int mode = 0;
@@ -325,7 +325,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
if (ObjectUtil.isEmpty(putDeviceCodeList)) {
putDeviceCodeList = this.getExtraDeviceCodes("put_device_code");
}
if(CollUtil.isEmpty(getDeviceCodeList) || getDeviceCodeList.size() == 0){
if (CollUtil.isEmpty(getDeviceCodeList) || getDeviceCodeList.size() == 0) {
notCreateInstMessage = "未设置取货点";
}
TaskDto task = null;
@@ -463,16 +463,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
list.add(map2);
list.add(map3);
this.writing(list);
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
EXECUTOR.submit(() -> {
toOpenDoor(startdevice);
});
}
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
EXECUTOR.submit(() -> {
toOpenDoor(nextdevice);
});
}
this.setRequireSucess(true);
return true;
} else {
@@ -671,16 +661,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
list.add(map2);
list.add(map3);
this.writing(list);
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
EXECUTOR.submit(() -> {
toOpenDoor(startdevice);
});
}
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
EXECUTOR.submit(() -> {
toOpenDoor(nextdevice);
});
}
this.setRequireSucess(true);
notCreateInstMessage = "";
notCreateTaskMessage = "";
@@ -702,6 +682,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing("to_close_door", "1");
}
/**
* 判断经过的烘箱是否关门
*/
@@ -875,6 +856,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
EXECUTOR.execute(() -> {
toOpenDoor(device);
});
int mode = hongXiangConveyorDeviceDriver.getMode();
int door = hongXiangConveyorDeviceDriver.getDoor();
int action = hongXiangConveyorDeviceDriver.getAction();
@@ -914,19 +898,19 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
}
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 1) {
feedMessage = feedMessage + "动作信号(action)不为取货中状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 1) {
feedMessage = feedMessage + "动作信号(action)不为取货中状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
//取货完成关闭烘箱门
@@ -938,15 +922,46 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
EXECUTOR.submit(() -> {
EXECUTOR.execute(() -> {
toCloseDoor(device);
});
int mode = hongXiangConveyorDeviceDriver.getMode();
int door = hongXiangConveyorDeviceDriver.getDoor();
int action = hongXiangConveyorDeviceDriver.getAction();
int error1 = hongXiangConveyorDeviceDriver.getError1();
int error = hongXiangConveyorDeviceDriver.getError();
int move = hongXiangConveyorDeviceDriver.getMove();
if (mode == 1 && door == 2 && action == 2 && error == 0 && error1 == 0 && move == 0) {
map.put("code", "to_command");
map.put("value", "3");
list.add(map);
this.writing(list);
this.setRequireActionSucess(true);
} else {
feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code();
if (mode != 1) {
feedMessage = feedMessage + "工作模式(mode)信号未联机,";
}
if (door != 2) {
feedMessage = feedMessage + "门状态(door)信号未关门,";
}
if (action != 1) {
feedMessage = feedMessage + "允许取放(action)信号未允许取放,";
}
if (move != 0) {
feedMessage = feedMessage + "取货位光电信号move不应该为有货状态,";
}
if (error1 != 0) {
feedMessage = feedMessage + "故障(error1)信号出现故障,故障值:" + error1 + "";
}
}
} else {
map.put("code", "to_command");
map.put("value", "3");
list.add(map);
this.writing(list);
this.setRequireActionSucess(true);
}
map.put("code", "to_command");
map.put("value", "3");
list.add(map);
this.writing(list);
this.setRequireActionSucess(true);
}
} else {
feedMessage = "行架机械手:";
@@ -973,6 +988,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
// EXECUTOR.submit(() -> {
toOpenDoor(nextDevice);
// });
int mode = hongXiangConveyorDeviceDriver.getMode();
int door = hongXiangConveyorDeviceDriver.getDoor();
int action = hongXiangConveyorDeviceDriver.getAction();
@@ -1040,7 +1058,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
EXECUTOR.submit(() -> {
EXECUTOR.execute(() -> {
toCloseDoor(nextDevice);
});
if (StrUtil.isNotEmpty(taskDto.getOven_time())) {
@@ -1052,60 +1070,96 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
map.put("to_time_min", String.valueOf(minutes));
hongXiangConveyorDeviceDriver.writing(map);
}
}
if (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver||nextDevice.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
if (!StrUtil.startWith(taskDto.getTask_code(), "-")) {
if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))) {
String lamp = nextDevice.getExtraValue().get("link_three_lamp").toString();
Device lampDevice = deviceAppService.findDeviceByCode(lamp);
if (ObjectUtil.isEmpty(lampDevice)) {
return;
}
if (lampDevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lampDevice.getDeviceDriver();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(lampDevice.getDeviceDriver().getDeviceCode())
.content("下发报警灯" + lamp + "报警信号")
.build();
logDto.setLog_level(3);
luceneExecuteLogService.deviceExecuteLog(logDto);
lampThreecolorDeviceDriver.writing("to_command", "1");
}
int mode = hongXiangConveyorDeviceDriver.getMode();
int door = hongXiangConveyorDeviceDriver.getDoor();
int action = hongXiangConveyorDeviceDriver.getAction();
int error1 = hongXiangConveyorDeviceDriver.getError1();
int error = hongXiangConveyorDeviceDriver.getError();
int move = hongXiangConveyorDeviceDriver.getMove();
if (mode == 1 && door == 2 && action == 2 && error == 0 && error1 == 0 && move == 1) {
map.put("code", "to_command");
map.put("value", "5");
list.add(map);
this.writing(list);
this.setRequireActionSucess(true);
try {
finish_instruction(inst2);
} catch (Exception e) {
e.printStackTrace();
}
feedMessage = "";
} else {
feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code();
if (mode != 1) {
feedMessage = feedMessage + "工作模式(mode)信号未联机,";
}
if (door != 2) {
feedMessage = feedMessage + "门状态(door)信号未关门,";
}
if (action != 1) {
feedMessage = feedMessage + "允许取放(action)信号未允许取放,";
}
if (move != 1) {
feedMessage = feedMessage + "放货位光电信号不应该为无货状态";
}
if (error1 != 0) {
feedMessage = feedMessage + "故障(error1)信号出现故障。";
}
}
} else {
map.put("code", "to_command");
map.put("value", "5");
list.add(map);
this.writing(list);
this.setRequireActionSucess(true);
try {
finish_instruction(inst2);
} catch (Exception e) {
e.printStackTrace();
}
feedMessage = "";
}
// if (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver||nextDevice.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) {
// if (!StrUtil.startWith(taskDto.getTask_code(), "-")) {
// if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))) {
// String lamp = nextDevice.getExtraValue().get("link_three_lamp").toString();
// Device lampDevice = deviceAppService.findDeviceByCode(lamp);
// if (ObjectUtil.isEmpty(lampDevice)) {
// return;
// }
// if (lampDevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
// lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lampDevice.getDeviceDriver();
// LuceneLogDto logDto = LuceneLogDto.builder()
// .device_code(lampDevice.getDeviceDriver().getDeviceCode())
// .content("下发报警灯" + lamp + "报警信号")
// .build();
// logDto.setLog_level(3);
// luceneExecuteLogService.deviceExecuteLog(logDto);
// lampThreecolorDeviceDriver.writing("to_command", "1");
// }
// }
// }
//
}
map.put("code", "to_command");
map.put("value", "5");
list.add(map);
this.writing(list);
this.setRequireActionSucess(true);
try {
finish_instruction(inst2);
} catch (Exception e) {
e.printStackTrace();
}
feedMessage = "";
}
}
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 4) {
feedMessage = feedMessage + "动作信号(action)不为放货完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 4) {
feedMessage = feedMessage + "动作信号(action)不为放货完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
}
}
}
public synchronized boolean finish_instruction(Instruction inst) throws Exception {
instructionService.finish(inst);
@@ -1153,8 +1207,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
this.setMessage("信号连接异常!");
}
String requireActionSucess = LangProcess.msg("universal_directives") + ":" + LangProcess.msg("universal_actionMessage4");
if(this.requireActionSucess){
requireActionSucess = LangProcess.msg("universal_directives") + ":" + LangProcess.msg("universal_actionMessage5");
if (this.requireActionSucess) {
requireActionSucess = LangProcess.msg("universal_directives") + ":" + LangProcess.msg("universal_actionMessage5");
}
map.put("device_name", this.getDevice().getDevice_name());
map.put("mode", mode);

View File

@@ -187,7 +187,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
x_position = this.itemProtocol.getX_position();
y_position = this.itemProtocol.getY_position();
if (mode != last_mode) {
if (action != last_action) {
requireSucess = false;
}

View File

@@ -479,17 +479,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
luceneLogService.interfaceExecuteLog(luceneLogDto);
} catch (Exception e) {
JSONObject jsonObject = JSONObject.parseObject(result);
log.info("向lms申请套管工位请求----返回参数{}", result);
log.info("向lms申请套管工位请求----返回参数{}", e.getMessage());
applyPlugPullSitResponse = JSONObject.toJavaObject(jsonObject, ApplyPlugPullSitResponse.class);
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "applyPlugPullSiteRequest", String.valueOf(applyPlugPullSitResponse.getstatus()),
JSON.toJSONString(param), String.valueOf(result), "ACS向LMS申请失败");
JSON.toJSONString(param),
String.valueOf(result), "向lms申请套管工位请求失败");
luceneLogService.interfaceExecuteLog(luceneLogDto);
JSONObject map = new JSONObject();
map.put("status", 400);
map.put("message", e.getMessage());
return JSONObject.toJavaObject(map, ApplyPlugPullSitResponse.class);
}
}
return applyPlugPullSitResponse;
} finally {
@@ -517,12 +513,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
log.info("向LMS反馈子卷重量----返回参数{}", result);
applyfeedbackSubVolumeWeightResponse = JSONObject.toJavaObject(jsonObject, ApplyfeedbackSubVolumeWeightResponse.class);
} catch (Exception e) {
String message = e.getMessage();
JSONObject jsonObject = JSONObject.parseObject(result);
log.info("向LMS反馈子卷重量----返回参数{}", result);
JSONObject map = new JSONObject();
map.put("status", 400);
map.put("message", e.getMessage());
return JSONObject.toJavaObject(map, ApplyfeedbackSubVolumeWeightResponse.class);
applyfeedbackSubVolumeWeightResponse = JSONObject.toJavaObject(jsonObject, ApplyfeedbackSubVolumeWeightResponse.class);
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "applyManipulatorAction", String.valueOf(applyfeedbackSubVolumeWeightResponse.getCode()),
JSON.toJSONString(param), message, "向LMS反馈子卷重量");
luceneLogService.interfaceExecuteLog(luceneLogDto);
}
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"applyfeedbackSubVolumeWeightRequest", String.valueOf(applyfeedbackSubVolumeWeightResponse.getCode()),
JSON.toJSONString(param), String.valueOf(applyfeedbackSubVolumeWeightResponse.getMessage()), "ACS反馈LMS子卷重量");
@@ -550,16 +547,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
log.info("RGV工位上有货申请行架任务----返回参数{}", result);
applyManipulatorActionResponse = JSONObject.toJavaObject(jsonObject, ApplyManipulatorActionResponse.class);
} catch (Exception e) {
String message = e.getMessage();
JSONObject jsonObject = JSONObject.parseObject(result);
log.info("RGV工位上有货申请行架任务----返回参数{}", result);
applyManipulatorActionResponse = JSONObject.toJavaObject(jsonObject, ApplyManipulatorActionResponse.class);
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "applyManipulatorAction", String.valueOf(applyManipulatorActionResponse.getCode()),
JSON.toJSONString(param), String.valueOf(applyManipulatorActionResponse), "RGV工位上有货申请行架任务失败");
JSON.toJSONString(param), message, "RGV工位上有货申请行架任务失败");
luceneLogService.interfaceExecuteLog(luceneLogDto);
JSONObject map = new JSONObject();
map.put("status", 400);
map.put("message", e.getMessage());
return JSONObject.toJavaObject(map, ApplyManipulatorActionResponse.class);
}
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "applyManipulatorAction", String.valueOf(applyManipulatorActionResponse.getCode()),
JSON.toJSONString(param), String.valueOf(applyManipulatorActionResponse), "RGV工位上有货申请行架任务");
@@ -692,11 +686,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("actionFinishRequest2");
String url = wmsurl + addressDto.getMethods_url();
log.info("actionFinishRequest2 - 设备工位取货完成反馈{}", jsonObject);
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"actionFinishRequest2", "",
String.valueOf(jsonObject),
"", jsonObject.getString("task_code") + "设备工位取货完成反馈");
luceneLogService.interfaceExecuteLog(luceneLogDto);
try {
execute = HttpRequest.post(url)
.body(String.valueOf(jsonObject))
@@ -705,7 +694,16 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String msg = e.getMessage();
log.info("feedbackDie-----输出参数{}", msg);
//网络不通
LuceneLogDto luceneLogDto1 = new LuceneLogDto(4,"actionFinishRequest2", String.valueOf(execute.getStatus()),
String.valueOf(jsonObject),
String.valueOf(execute.body()), jsonObject.getString("task_code") + "设备工位取货完成反馈失败");
luceneLogService.interfaceExecuteLog(luceneLogDto1);
}
log.info("actionFinishRequest2 - 设备工位取货完成反馈{}", jsonObject);
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"actionFinishRequest2", "",
String.valueOf(jsonObject),
"", jsonObject.getString("task_code") + "设备工位取货完成反馈");
luceneLogService.interfaceExecuteLog(luceneLogDto);
} catch (Exception e) {
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"actionFinishRequest2", String.valueOf(execute.getStatus()),
JSON.toJSONString(execute.body()),

View File

@@ -493,4 +493,6 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
List<Instruction> findByNextCode(String nextDeviceCode);
List<Instruction> findReadyIns();
}

View File

@@ -54,6 +54,7 @@ import org.nl.acs.task.TaskInstructionLock;
import org.nl.acs.task.domain.Task;
import org.nl.acs.task.enums.AgvSystemTypeEnum;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.common.base.PageInfo;
@@ -498,12 +499,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
String interactionJson = task.getInteraction_json();
if (StrUtil.isEmpty(interactionJson)){
throw new BadRequestException("agv叉车调整长宽参数为空");
if (StrUtil.isEmpty(interactionJson)) {
throw new BadRequestException("agv叉车调整长宽参数为空");
}
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
//仙工叉车
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto,interactionJsonDTO);
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto, interactionJsonDTO);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
@@ -646,12 +647,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
Device deviceByCode = deviceAppService.findDeviceByCode(dto.getStart_device_code());
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
String interactionJson = task.getInteraction_json();
if (StrUtil.isEmpty(interactionJson)){
throw new BadRequestException("agv叉车调整长宽参数为空");
if (StrUtil.isEmpty(interactionJson)) {
throw new BadRequestException("agv叉车调整长宽参数为空");
}
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
//仙工叉车
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto,interactionJsonDTO);
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto, interactionJsonDTO);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
@@ -665,6 +666,24 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
} else {
dto.setSend_status("1");
}
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex())) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
log.warn("下发AGV指令数据," + "指令号:" + dto.getInstruction_code() + ",AGV系统类型:" + dto.getAgv_system_type());
try {
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
dto.setSend_status("1");
} catch (Exception e) {
dto.setSend_status("2");
dto.setRemark(e.getMessage());
e.printStackTrace();
log.warn("下发AGV指令异常:" + e);
LuceneLogDto logDto1 = LuceneLogDto.builder()
.device_code(start_device_code)
.content("下发AGV指令异常")
.build();
logDto1.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);
}
}
}
} catch (Exception e) {
@@ -1199,14 +1218,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
flag = true;
}
else if (ObjectUtil.isNotEmpty(entity.getAgv_system_type()) && entity.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type)
} else if (ObjectUtil.isNotEmpty(entity.getAgv_system_type()) && entity.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type)
&& !StrUtil.equals(entity.getSend_status(), "2")) {
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
flag = true;
}
else {
} else {
flag = true;
}
if (flag) {
@@ -1932,7 +1949,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public List<Instruction> findByCodeAndExcute(String next_code) {
List<Instruction> instructionList = instructions.stream().filter(item -> item.getNext_device_code().equals(next_code) || item.getStart_device_code().equals(next_code)).collect(Collectors.toList());
List<Instruction> instructionList = instructions.stream().filter(item -> item.getNext_device_code().equals(next_code) ).collect(Collectors.toList());
return instructionList;
}
@@ -1940,11 +1957,21 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public List<Instruction> findByNextCode(String next_code) {
List<Instruction> instructionList = instructions.stream().filter(item -> item.getNext_device_code().equals(next_code) ).collect(Collectors.toList());
List<Instruction> instructionList = instructions.stream().filter(item -> item.getNext_device_code().equals(next_code)).collect(Collectors.toList());
return instructionList;
}
@Override
public List<Instruction> findReadyIns() {
//根据时间升序取第一个
List<Instruction> instructionsList = instructions.stream()
.filter(item -> StrUtil.equals(item.getInstruction_type(), TaskTypeEnum.Truss_Task.getIndex())
&& StrUtil.equals(item.getInstruction_status(), TaskStatusEnum.READY.getIndex())).collect(Collectors.toList());
return instructionsList;
}
private boolean regional(String start_device_code, String next_device_code) {
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);

View File

@@ -7,9 +7,12 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.udw.UnifiedDataAccessor;
import org.nl.acs.udw.UnifiedDataAccessorFactory;
import org.nl.config.thread.TheadFactoryName;
import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.*;
@@ -30,7 +33,10 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
int multiple = cache_thread;
int loop_time_millions = 100;
ExecutorService executorService;
@Resource
private ThreadPoolExecutor executorService;
Map<String, BlockedRunable> runs;
public DeviceExecuteAutoRun() {
@@ -43,7 +49,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
new ArrayBlockingQueue<>( queueLength),
new TheadFactoryName()
);*/
this.executorService = new ThreadPoolExecutor(
/*this.executorService = new ThreadPoolExecutor(
50,
100,
1L,
@@ -62,7 +68,8 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
}
}
}
);
);*/
// this.executorService= ThreadPoolExecutorUtil.getPoll();
this.runs = new LinkedHashMap();
this.runs = Collections.synchronizedMap(this.runs);
}
@@ -121,7 +128,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
this.runs.put(deviceDriver.getDeviceCode(), runnable);
}
runnable.setIndex(this.runs);
this.executorService.submit(runnable);
this.executorService.execute(runnable);
}
}

View File

@@ -203,7 +203,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
if (!UnifiedDataAppService.isEquals(value, his)) {
OpcItemDto itemDto = this.getItem(itemId);
if (true) {
this.logItemChanged(itemId, accessor_value, value, itemDto);
// this.logItemChanged(itemId, accessor_value, value, itemDto);
}
if(!ObjectUtil.isEmpty(value) || "".equals(value)){
accessor_value.setValue(itemId, value);
@@ -416,7 +416,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
sb.append("key:" + relate + "value:" + obj + ";");
}
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time") && !itemDto.getItem_code().endsWith("consumption")
&& !itemDto.getItem_code().endsWith("x") && !itemDto.getItem_code().endsWith("y")) {
&& !itemDto.getItem_code().endsWith("x") && !itemDto.getItem_code().endsWith("y")) {
// 存在上次点位值为null情况 则不记录日志
if(!(his instanceof Float) && !(value instanceof Float)){
LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(),4, itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1),

View File

@@ -1,18 +1,24 @@
package org.nl.acs.opc;
import cn.hutool.core.util.ObjectUtil;
import org.dromara.dynamictp.core.support.ThreadPoolBuilder;
import org.nl.acs.auto.run.AbstractAutoRunnable;
import org.nl.acs.opc.service.dto.OpcServerManageDto;
import org.nl.config.thread.TheadFactoryName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static org.dromara.dynamictp.common.em.QueueTypeEnum.MEMORY_SAFE_LINKED_BLOCKING_QUEUE;
/**
* OPC设备同步启动
@@ -22,7 +28,16 @@ import java.util.concurrent.Executors;
public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
public static boolean isRun = false;
ExecutorService executorService = Executors.newCachedThreadPool();
ExecutorService executorService = ThreadPoolBuilder.newBuilder()
.threadPoolName("deviceOpc_thread")
.threadFactory("deviceOpc_thread")
.corePoolSize(80)
.maximumPoolSize(100)
.keepAliveTime(40)
.timeUnit(TimeUnit.SECONDS)
.workQueue(MEMORY_SAFE_LINKED_BLOCKING_QUEUE.getName(), 2000)
.buildDynamic();
@Autowired
private DeviceAppService deviceAppService;
@Autowired
@@ -41,6 +56,7 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
@Override
public void autoRun() throws Exception {
{
//Thread.sleep(10000L);
isRun = true;
Map<String, OpcServerManageDto> servers = this.opcServerManageService.queryAllServerMap();
@@ -80,6 +96,14 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
public void after() {
isRun = false;
this.executorService.shutdownNow();
this.executorService = Executors.newCachedThreadPool();
this.executorService = ThreadPoolBuilder.newBuilder()
.threadPoolName("deviceOpc_thread")
.threadFactory("deviceOpc_thread")
.corePoolSize(80)
.maximumPoolSize(100)
.keepAliveTime(40)
.timeUnit(TimeUnit.SECONDS)
.workQueue(MEMORY_SAFE_LINKED_BLOCKING_QUEUE.getName(), 2000)
.buildDynamic();
}
}

View File

@@ -1,6 +1,7 @@
package org.nl.acs.socket;
import cn.hutool.core.util.StrUtil;
import org.dromara.dynamictp.core.support.ThreadPoolBuilder;
import org.nl.acs.auto.run.AbstractAutoRunnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -14,6 +15,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static org.dromara.dynamictp.common.em.QueueTypeEnum.MEMORY_SAFE_LINKED_BLOCKING_QUEUE;
/**
* @author 20220102CG\noblelift
@@ -22,7 +26,15 @@ import java.util.concurrent.Executors;
public class SocketListenerAutoRun extends AbstractAutoRunnable implements SocketService {
private static final Logger log = LoggerFactory.getLogger(SocketListenerAutoRun.class);
private ServerSocket serverSocket = null;
private ExecutorService threadPool = Executors.newCachedThreadPool();
private ExecutorService threadPool = ThreadPoolBuilder.newBuilder()
.threadPoolName("socketListener_thread")
.threadFactory("socketListener_thread")
.corePoolSize(2)
.maximumPoolSize(7)
.keepAliveTime(40)
.timeUnit(TimeUnit.SECONDS)
.workQueue(MEMORY_SAFE_LINKED_BLOCKING_QUEUE.getName(), 2000)
.buildDynamic();
private Map<String, Socket> sockets = new HashMap();
private Map<String, OutputStream> outputs = new HashMap();
@@ -91,7 +103,15 @@ public class SocketListenerAutoRun extends AbstractAutoRunnable implements Socke
public void after() {
System.out.println("清理工作。。。。。");
this.threadPool.shutdownNow();
this.threadPool = Executors.newCachedThreadPool();
this.threadPool = ThreadPoolBuilder.newBuilder()
.threadPoolName("socketListener_thread")
.threadFactory("socketListener_thread")
.corePoolSize(2)
.maximumPoolSize(7)
.keepAliveTime(40)
.timeUnit(TimeUnit.SECONDS)
.workQueue(MEMORY_SAFE_LINKED_BLOCKING_QUEUE.getName(), 2000)
.buildDynamic();
this.sockets = new HashMap();
this.outputs = new HashMap();
this.closeSocket(this.serverSocket);

View File

@@ -806,14 +806,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
this.addTaskToCache(dto);
//反馈上位系统任务状态
CompletableFuture.runAsync(() -> {
// 异步更新指令状态
try {
this.feedWmsTaskStatus(entity);
} catch (Exception e) {
e.printStackTrace();
}
});
this.feedWmsTaskStatus(entity);
}
@Override
@@ -983,6 +977,29 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
instdto.setAgv_action_type(acsTask.getAgv_action_type());
if (StrUtil.equals(agv_system_type, CommonFinalParam.TWO)) {
// task_type
//1、生箔 Itype=1:取空,取满,放空,放满;
//2、分切 Itype=3取满、取空、放满、放空
//3、普通任务 Itype=2:取货、放货;
//4、叉车任务
//5、输送任务
//6、行架
//7、立库
if (StrUtil.equals(task_type, CommonFinalParam.ONE)) {
instdto.setAgv_inst_type(CommonFinalParam.ONE);
} else if (StrUtil.equals(task_type, "3")) {
instdto.setAgv_inst_type("2");
} else if (StrUtil.equals(task_type, "2")) {
instdto.setAgv_inst_type("3");
} else if (StrUtil.equals(task_type, "8")) {
instdto.setAgv_inst_type("2");
} else {
log.info("未找到对应的AGV指令类型任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type());
}
} else {
instdto.setAgv_inst_type("4");
}
instructionservice.create2(instdto);
acsTask.setTask_status(CommonFinalParam.ONE);
this.update(acsTask);
@@ -1639,17 +1656,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
JSONArray ja = new JSONArray();
ja.add(feed_jo);
//TODO 有需要根据上位系统反馈的信息再做进一步处理
CompletableFuture.runAsync(() -> {
// 异步更新指令状态
try {
acstowmsService.feedTaskStatus(ja);
} catch (Exception e) {
e.printStackTrace();
}
});
acstowmsService.feedTaskStatus(ja);
}
}

View File

@@ -88,6 +88,8 @@ public class LuceneLogDto {
+ home;
}
public LuceneLogDto(final Integer log_level,final String method, final String status,
final String requestparam, final String responseparam, final String content) {
super();

View File

@@ -16,10 +16,12 @@
package org.nl.config.thread;
import org.dromara.dynamictp.core.DtpRegistry;
import org.nl.config.SpringContextHolder;
import org.springframework.stereotype.Component;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -31,8 +33,11 @@ import java.util.concurrent.TimeUnit;
public class ThreadPoolExecutorUtil {
public static ThreadPoolExecutor getPoll(){
AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
public static Executor getPoll(){
return DtpRegistry.getExecutor("dtpExecutor1");
/* AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
return new ThreadPoolExecutor(
properties.getCorePoolSize(),
properties.getMaxPoolSize(),
@@ -40,6 +45,6 @@ public class ThreadPoolExecutorUtil {
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(properties.getQueueCapacity()),
new TheadFactoryName()
);
);*/
}
}

View File

@@ -52,6 +52,5 @@ public class AutoCleanLucenceLog {
TermRangeQuery termRangeQuery = new TermRangeQuery("logTime", new BytesRef(startDate), new BytesRef(endDate), true, true);
writer.deleteDocuments(termRangeQuery);
writer.commit();
writer.close();
}
}

View File

@@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.common.utils.RedisUtils;
import org.nl.common.utils.ThrowableUtil;
import org.nl.config.SpringContextHolder;
import org.nl.config.thread.AsyncTaskProperties;
import org.nl.config.thread.TheadFactoryName;
import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.nl.system.service.quartz.ISysQuartzJobService;
import org.nl.system.service.quartz.dao.SysQuartzJob;
@@ -21,8 +23,10 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.quartz.QuartzJobBean;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @Author: /
@@ -41,8 +45,16 @@ public class ExecutionJob extends TLogQuartzJobBean {
/* @Autowired
@Qualifier("threadPoolExecutor")
private ThreadPoolExecutor EXECUTOR;*/
static AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
private final static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(
properties.getCorePoolSize(),
properties.getMaxPoolSize(),
properties.getKeepAliveSeconds(),
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(properties.getQueueCapacity()),
new TheadFactoryName()
);;
@Override

View File

@@ -7,7 +7,6 @@ spring:
check-template-location: false
profiles:
active: dev
# active: prod
jackson:
time-zone: GMT+8
data:
@@ -44,7 +43,7 @@ spring:
enable_lazy_load_no_trans: true
dynamic:
tp:
enabled: false # 是否启用 dynamictp默认true
enabled: true # 是否启用 dynamictp默认true
enabledBanner: false # 是否启用 控制台banner默认true
enabledCollect: true # 是否开启监控指标采集默认true
collectorTypes: logging,test_collect # 监控数据采集器类型logging | micrometer | internal_logging默认micrometer
@@ -57,30 +56,23 @@ spring:
keepAliveTime: 60
runTimeout: 10000
queueTimeout: 100
notifyItems: # 报警项,不配置自动会按默认值配置(变更通知、容量报警、活性报警、拒绝报警、任务超时报警)
- type: change
enabled: true
- type: capacity # 队列容量使用率,报警项类型,查看源码 NotifyTypeEnum枚举类
enabled: true
threshold: 80 # 报警阈值默认70意思是队列使用率达到70%告警
interval: 120 # 报警间隔单位s默认120
- type: liveness # 线程池活性
enabled: true
threshold: 80 # 报警阈值,默认 70意思是活性达到70%告警
- type: reject # 触发任务拒绝告警
enabled: true
threshold: 100 # 默认阈值10
- type: run_timeout # 任务执行超时告警
enabled: true
threshold: 100 # 默认阈值10
- type: queue_timeout # 任务排队超时告警
enabled: true
threshold: 100 # 默认阈值10
executors: # 动态线程池配置,都有默认值,采用默认值的可以不配置该项,减少配置量
- threadPoolName: dtpExecutor1 # 线程池名称,必填
threadPoolAliasName: core_thread # 线程池别名,可选
executorType: common # 线程池类型 common、eager、ordered、scheduled、priority默认 common
corePoolSize: 10 # 核心线程数默认1
maximumPoolSize: 30 # 最大线程数默认cpu核数
queueCapacity: 1024 # 队列容量默认1024
queueType: VariableLinkedBlockingQueue # 任务队列查看源码QueueTypeEnum枚举类默认VariableLinkedBlockingQueue
rejectedHandlerType: CallerRunsPolicy # 拒绝策略查看RejectedTypeEnum枚举类默认AbortPolicy
keepAliveTime: 30 # 空闲线程等待超时时间默认60
threadNamePrefix: core_thread # 线程名前缀默认dtp
allowCoreThreadTimeOut: true # 是否允许核心线程池超时默认false
waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计优雅关闭线程池默认true
awaitTerminationSeconds: 5 # 优雅关闭线程池时阻塞等待线程池中任务执行时间默认3单位s
preStartAllCoreThreads: false # 是否预热所有核心线程默认false
runTimeout: 2000 # 任务执行超时阈值单位ms默认0不统计
queueTimeout: 1000 # 任务在队列等待超时阈值单位ms默认0不统计
task:
pool:
# 核心线程池大小
@@ -137,7 +129,7 @@ security:
mybatis-plus:
configuration:
map-underscore-to-camel-case: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
mapper-locations:
- classpath:org.nl.**.mapper/*.xml
global-config:

View File

@@ -69,11 +69,11 @@ https://juejin.cn/post/6844903775631572999
<!--开发环境:打印控制台-->
<springProfile name="dev">
<root level="debug">
<appender-ref ref="asyncLuceneAppender"/>
<appender-ref ref="asyncFileAppender"/>
<!-- <appender-ref ref="asyncLuceneAppender"/>-->
<!-- <appender-ref ref="asyncFileAppender"/>-->
<appender-ref ref="CONSOLE"/>
</root>
<logger name="jdbc" level="ERROR" additivity="true">
<!-- <logger name="jdbc" level="ERROR" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
<logger name="org.springframework" level="ERROR" additivity="true">
@@ -96,7 +96,7 @@ https://juejin.cn/post/6844903775631572999
</logger>
<logger name="org.jinterop" level="ERROR" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
</logger>-->
</springProfile>
<!--测试环境:打印控制台-->

View File

@@ -9,6 +9,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.Scanner;
import java.util.concurrent.*;
/**
* @Author: lyd
@@ -32,9 +33,9 @@ public class ApplicationTest {
System.out.println("请输入第一个数:");
int c = scanner.nextInt();
//求最小值
int min = (((a < b) ? a : b) < c) ?((a < b) ? a : b):c;
int min = (((a < b) ? a : b) < c) ? ((a < b) ? a : b) : c;
//求最大值
int max = (((a > b) ? a : b) > c) ?((a > b) ? a : b):c;
int max = (((a > b) ? a : b) > c) ? ((a > b) ? a : b) : c;
//求中间值
int mid = a + b + c - max - min;
//排序
@@ -50,10 +51,32 @@ public class ApplicationTest {
}
@org.testng.annotations.Test
@Test
void demo1() {
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
try {
Thread.sleep(3000); // 假设这是一个耗时的操作
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Interrupted", e);
}
return "Result";
});
try {
String result = future.get(2, TimeUnit.SECONDS); // 设置超时时间为2秒
System.out.println(result);
} catch (CompletionException e) {
Throwable cause = e.getCause();
if (cause instanceof TimeoutException) {
System.out.println("Operation timed out");
} else {
throw e; // rethrow other exceptions
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -49,6 +49,24 @@
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="关联设备" prop="device_code">
<el-select
v-model="form.link_device_code"
filterable
multiple
clearable
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽略工作模式校验" label-width="150px">
<el-switch v-model="form.ignore_pickup_check" />

View File

@@ -18,7 +18,7 @@
style="width: 200px"
@change="crud.toQuery"
>
<el-option v-for="item in methods" :key="item.value" :label="item.label" :value="item.value" />
<el-option v-for="item in methods" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
<el-input
v-model="query.requestparam"

View File

@@ -340,7 +340,18 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
mp.put("销售订单", json.getString("sale_order_name"));
mp.put("行号", "");
}
// 原销售订单
if (ObjectUtil.isEmpty(jsonSub)) {
try {
mp.put("原销售订单", json.getString("sale_order_name").substring(0, json.getString("sale_order_name").indexOf("-")));
mp.put("原行号", json.getString("sale_order_name").substring(json.getString("sale_order_name").indexOf("-") + 1, json.getString("sale_order_name").length()));
} catch (Exception e) {
mp.put("原销售订单", json.getString("sale_order_name"));
mp.put("原行号", "");
}
}
try {
mp.put("原销售订单", jsonSub.getString("sale_order_name").substring(0, jsonSub.getString("sale_order_name").indexOf("-")));
mp.put("原行号", jsonSub.getString("sale_order_name").substring(jsonSub.getString("sale_order_name").indexOf("-") + 1, jsonSub.getString("sale_order_name").length()));