psh 2 years ago
parent
commit
358191d905
  1. 5
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/initial/ApplicationAutoInitialExecuter.java
  2. 16
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/AutoRunServiceImpl.java
  3. 3
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
  4. 18
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java
  5. 11
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDeviceDriver.java
  6. 27
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java
  7. 8
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java
  8. 3
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  9. 6
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceAppServiceImpl.java
  10. 3
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java
  11. 22
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java
  12. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java
  13. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

5
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/initial/ApplicationAutoInitialExecuter.java

@ -10,9 +10,6 @@ import java.util.List;
@Component @Component
public class ApplicationAutoInitialExecuter { public class ApplicationAutoInitialExecuter {
/**
* 获取所有实现ApplicationAutoInitial接口的bean对象
*/
@Autowired(required = false) @Autowired(required = false)
List<ApplicationAutoInitial> applicationAutoInitial; List<ApplicationAutoInitial> applicationAutoInitial;
//是否启动 //是否启动
@ -28,7 +25,7 @@ public class ApplicationAutoInitialExecuter {
while (it.hasNext()) { while (it.hasNext()) {
ApplicationAutoInitial service = (ApplicationAutoInitial) it.next(); ApplicationAutoInitial service = (ApplicationAutoInitial) it.next();
service.autoInitial(); // 执行实现的autoInitial方法 service.autoInitial();
} }

16
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/AutoRunServiceImpl.java

@ -13,18 +13,15 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
/**
* 初始化启动线程
*/
@Service @Service
@Slf4j @Slf4j
public class AutoRunServiceImpl implements AutoRunService, ApplicationAutoInitial { public class AutoRunServiceImpl implements AutoRunService, ApplicationAutoInitial {
@Autowired(required = false) @Autowired(required = false)
private List<AbstractAutoRunnable> abstractAutoRunnableList; private List<AbstractAutoRunnable> abstractAutoRunnableList;
private List<AbstractAutoRunnable> thread_autoRun = new ArrayList(); // 线程类 private List<String> autoRun_code_index = new ArrayList();
private List<String> autoRun_code_index = new ArrayList(); // key private List<Thread> threads = new ArrayList();
private List<Thread> threads = new ArrayList(); // 运行线程 private List<AbstractAutoRunnable> thread_autoRun = new ArrayList();
private List<String> thread_code_index = new ArrayList(); // key private List<String> thread_code_index = new ArrayList();
@Override @Override
public synchronized void startThread(String threadCode) { public synchronized void startThread(String threadCode) {
@ -175,13 +172,8 @@ public class AutoRunServiceImpl implements AutoRunService, ApplicationAutoInitia
: new LinkedList(); : new LinkedList();
} }
/**
* 自动初始化线程
* @throws Exception
*/
@Override @Override
public void autoInitial() throws Exception { public void autoInitial() throws Exception {
// 获取所有的类型为AbstractAutoRunnable的bean
List<AbstractAutoRunnable> list = this.getAllAutoThread(); List<AbstractAutoRunnable> list = this.getAllAutoThread();
Iterator it = list.iterator(); Iterator it = list.iterator();

3
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java

@ -1776,9 +1776,6 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
this.reload(); this.reload();
} }
/**
* 加载货位信息
*/
@Override @Override
public void reload() { public void reload() {
this.storageCells = queryAllStorageCell(); this.storageCells = queryAllStorageCell();

18
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java

@ -10,9 +10,11 @@ import java.util.List;
public class ItemProtocol { public class ItemProtocol {
public static String item_heartbeat = "heartbeat"; public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode"; public static String item_mode = "mode";
public static String item_state = "state";
public static String item_action = "action"; public static String item_action = "action";
public static String item_error = "error"; public static String item_error = "error";
public static String item_to_command = "to_command"; public static String item_to_command = "to_command";
public static String item_to_state ="to_state";
private StandardAutodoorDeviceDriver driver; private StandardAutodoorDeviceDriver driver;
@ -41,6 +43,10 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_command); return this.getOpcIntegerValue(item_to_command);
} }
public int getToState() {
return this.getOpcIntegerValue(item_to_state);
}
public int getOpcIntegerValue(String protocol) { public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol); Integer value = this.driver.getIntegeregerValue(protocol);
@ -55,16 +61,18 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); list.add(new ItemDto(item_mode, "工作模式", "DB600.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); list.add(new ItemDto(item_state, "工作状态", "DB600.B2"));
list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); list.add(new ItemDto(item_action, "动作信号", "DB600.B3"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B4"));
return list; return list;
} }
public static List<ItemDto> getWriteableItemDtos() { public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_state, "下发状态", "DB601.W3", Boolean.valueOf(true)));
return list; return list;
} }

11
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDeviceDriver.java

@ -53,6 +53,8 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
int move = 0; int move = 0;
int task = 0; int task = 0;
int state = 0;
int last_state = 0;
int last_action = 0; int last_action = 0;
int last_mode = 0; int last_mode = 0;
int last_error = 0; int last_error = 0;
@ -135,9 +137,8 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
} }
public void writeing(int command) { public void writing(String param,int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() String to_command = String.format("%s.%s.%s.%s", this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.getDevice().getDevice_code(), param);
+ "." + ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id(); String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid); Server server = ReadUtil.getServer(opcservcerid);
@ -153,9 +154,9 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
//开门 //开门
if ("1".equals(type)) { if ("1".equals(type)) {
writeing(1); writing(ItemProtocol.item_to_command,1);
} else { } else {
writeing(2); writing(ItemProtocol.item_to_command,2);
} }
} }

27
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java

@ -15,12 +15,15 @@ public class ItemProtocol {
public static String item_mode = "mode"; public static String item_mode = "mode";
public static String item_move = "move"; public static String item_move = "move";
public static String item_action = "action"; public static String item_action = "action";
public static String item_io_action = "io_action";
public static String item_error = "error"; public static String item_error = "error";
public static String item_task = "task"; public static String item_task = "task";
public static String item_to_command = "to_command"; public static String item_to_command = "to_command";
public static String item_to_target = "to_target"; public static String item_to_target = "to_target";
public static String item_to_task = "to_task"; public static String item_to_task = "to_task";
public static String item_weight = "weight"; public static String item_weight = "weight";
public static String item_material_type = "material_type";
public static String item_barcode = "barcode";
private StandardInspectSiteDeviceDriver driver; private StandardInspectSiteDeviceDriver driver;
@ -44,6 +47,10 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_action); return this.getOpcIntegerValue(item_action);
} }
public int getIoAction() {
return this.getOpcIntegerValue(item_io_action);
}
public int getError() { public int getError() {
return this.getOpcIntegerValue(item_error); return this.getOpcIntegerValue(item_error);
} }
@ -52,6 +59,13 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_task); return this.getOpcIntegerValue(item_task);
} }
public int getMaterialType() {
return this.getOpcIntegerValue(item_material_type);
}
public int getBarcode() {
return this.getOpcIntegerValue(item_barcode);
}
public int getToCommand() { public int getToCommand() {
return this.getOpcIntegerValue(item_to_command); return this.getOpcIntegerValue(item_to_command);
} }
@ -87,11 +101,14 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3"));
list.add(new ItemDto(item_move, "动作信号", "DB600.B3")); list.add(new ItemDto(item_action, "取放信号", "DB600.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); list.add(new ItemDto(item_io_action, "进出信号", "DB600.B5"));
list.add(new ItemDto(item_task, "任务号", "DB600.D8")); list.add(new ItemDto(item_task, "任务号", "DB600.D6"));
list.add(new ItemDto(item_material_type, "任务号", "DB600.D6"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B7"));
list.add(new ItemDto(item_barcode, "条码", "DB600.D8"));
return list; return list;
} }

8
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java

@ -78,6 +78,13 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
String message = null; String message = null;
Boolean iserror = false; Boolean iserror = false;
int io_action = 0;
int last_io_action = 0;
int material_type = 0;
int last_material_type = 0;
int barcode = 0;
int last_barcode =0;
boolean hasVehicle = false; boolean hasVehicle = false;
boolean isReady = false; boolean isReady = false;
@ -141,6 +148,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
task = this.itemProtocol.getTask(); task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove(); hasGoods = this.itemProtocol.getMove();
action = this.itemProtocol.getAction(); action = this.itemProtocol.getAction();
io_action = this.itemProtocol.getIoAction();
if (mode != last_mode) { if (mode != last_mode) {
this.setRequireSucess(false); this.setRequireSucess(false);
} }

3
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -159,9 +159,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
} }
}*/ }*/
/**
* 加载指令数据
*/
@Override @Override
public void autoInitial() { public void autoInitial() {
this.reload(); this.reload();

6
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceAppServiceImpl.java

@ -20,8 +20,8 @@ import java.util.*;
@Slf4j @Slf4j
@Service @Service
public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoInitial { public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoInitial {
private List<Device> devices = new ArrayList(); // 所有设备链表 private List<Device> devices = new ArrayList();
private List<String> code_indexs = new ArrayList(); // 设备对应的下表 private List<String> code_indexs = new ArrayList();
@Autowired @Autowired
private DeviceManageService deviceManageService; private DeviceManageService deviceManageService;
@Autowired @Autowired
@ -315,7 +315,7 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
} }
public synchronized void reload() { public synchronized void reload() {
List<DeviceManageDto> deviceManageDtos = deviceManageService.queryAllWithExtra(); List<DeviceManageDto> deviceManageDtos = this.deviceManageService.queryAllWithExtra();
this.devices = new ArrayList(); this.devices = new ArrayList();
Collections.synchronizedList(this.devices); Collections.synchronizedList(this.devices);
this.code_indexs = new ArrayList(); this.code_indexs = new ArrayList();

3
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java

@ -42,16 +42,13 @@ public class DeviceManageServiceImpl implements DeviceManageService {
@Override @Override
public List<DeviceManageDto> queryAllWithExtra() { public List<DeviceManageDto> queryAllWithExtra() {
// JSONArray arr = WQLObject.getWQLObject("acs_device").query().getResultJSONArray(0); // JSONArray arr = WQLObject.getWQLObject("acs_device").query().getResultJSONArray(0);
// 获取所有的设备
List<Device> deviceList= new LambdaQueryChainWrapper<>(deviceMapper).list(); List<Device> deviceList= new LambdaQueryChainWrapper<>(deviceMapper).list();
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList));
// 获取列表扩展
// JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query().getResultJSONArray(0); // JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query().getResultJSONArray(0);
List<DeviceExtra> deviceExtraList= new LambdaQueryChainWrapper<>(deviceExtraMapper).list(); List<DeviceExtra> deviceExtraList= new LambdaQueryChainWrapper<>(deviceExtraMapper).list();
JSONArray extArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList)); JSONArray extArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList));
// 设备+扩展DTO
List<DeviceExtraManageDto> extras = extArr.toJavaList(DeviceExtraManageDto.class); List<DeviceExtraManageDto> extras = extArr.toJavaList(DeviceExtraManageDto.class);
// WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint"); // WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint");

22
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java

@ -31,24 +31,19 @@ import java.util.Map;
public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial { public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial {
private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class);
@Autowired @Autowired OpcServerManageService opcServerManageService;
OpcServerManageService opcServerManageService;
Map<String, OpcServerManageDto> opcServerManageDtos = new HashMap(); Map<String, OpcServerManageDto> opcServerManageDtos = new HashMap();
Map<String, Server> servers = Collections.synchronizedMap(new HashMap()); Map<String, Server> servers = Collections.synchronizedMap(new HashMap());
Map<String, Group> groups = Collections.synchronizedMap(new HashMap()); Map<String, Group> groups = Collections.synchronizedMap(new HashMap());
public OpcServerServiceImpl() { public OpcServerServiceImpl() {}
}
/**
* 加载opc服务启动opc线程
* @throws Exception
*/
public void autoInitial() throws Exception { public void autoInitial() throws Exception {
this.reload(); // 加载opc服务 this.reload();
if (OpcConfig.auto_start_opc) { if (OpcConfig.auto_start_opc) {
Thread t = Thread t =
new Thread(() -> { new Thread() {
public void run() {
Iterator var1 = OpcServerServiceImpl.this.opcServerManageDtos.values().iterator(); Iterator var1 = OpcServerServiceImpl.this.opcServerManageDtos.values().iterator();
while (var1.hasNext()) { while (var1.hasNext()) {
@ -61,7 +56,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
OpcServerServiceImpl.log.warn("启动无法载入servers", var4); OpcServerServiceImpl.log.warn("启动无法载入servers", var4);
} }
} }
}); }
};
t.start(); t.start();
} }
} }
@ -133,13 +129,13 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
public synchronized void clearServer(String code) { public synchronized void clearServer(String code) {
try { try {
Server server = (Server) this.servers.get(code); Server server = (Server) this.servers.get(code);
if (server != null) { if (server!=null){
server.disconnect(); server.disconnect();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("清理server异常,", e.getMessage()); log.error("清理server异常,",e.getMessage());
} }
this.servers.remove(code); this.servers.remove(code);

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java

@ -514,10 +514,6 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
return false; return false;
} }
/**
* 加载路由路线
* @throws SQLException
*/
@Override @Override
public void reload() throws SQLException { public void reload() throws SQLException {
Object[] param = new Object[0]; Object[] param = new Object[0];

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -246,10 +246,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
}*/ }*/
/**
* 获取未完成任务
* @throws Exception
*/
@Override @Override
public void autoInitial() throws Exception { public void autoInitial() throws Exception {
Class var1 = TaskInstructionLock.class; Class var1 = TaskInstructionLock.class;

Loading…
Cancel
Save