更新
This commit is contained in:
@@ -239,7 +239,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
Iterator<Device> iterator = allDevice.iterator();
|
Iterator<Device> iterator = allDevice.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Device device = iterator.next();
|
Device device = iterator.next();
|
||||||
if (StrUtil.equals(device.getDevice_code(),device_code)) {
|
if (StrUtil.equals(device.getDevice_code(), device_code)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -920,8 +920,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj);
|
JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj);
|
||||||
runpointwo.update(updatejson, "device_code = '" + device_code + "'");
|
runpointwo.update(updatejson, "device_code = '" + device_code + "'");
|
||||||
}
|
}
|
||||||
}
|
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||||
else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
|
||||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||||
standardInspectSiteDeviceDriver.setMaterial(material_type);
|
standardInspectSiteDeviceDriver.setMaterial(material_type);
|
||||||
standardInspectSiteDeviceDriver.setBatch(batch);
|
standardInspectSiteDeviceDriver.setBatch(batch);
|
||||||
@@ -1130,7 +1129,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
} else {
|
} else {
|
||||||
boolean endsWith = json.getString("extra_value").endsWith("]");
|
boolean endsWith = json.getString("extra_value").endsWith("]");
|
||||||
boolean startsWith = json.getString("extra_value").startsWith("[");
|
boolean startsWith = json.getString("extra_value").startsWith("[");
|
||||||
if (endsWith && startsWith){
|
if (endsWith && startsWith) {
|
||||||
JSONArray extraValue = JSONArray.parseArray(json.getString("extra_value"));
|
JSONArray extraValue = JSONArray.parseArray(json.getString("extra_value"));
|
||||||
extraObj.put(json.getString("extra_code"), extraValue);
|
extraObj.put(json.getString("extra_code"), extraValue);
|
||||||
} else {
|
} else {
|
||||||
@@ -1174,14 +1173,14 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
JSONArray rs = WQLObject.getWQLObject("acs_device_extra").query("filed_type='02' and device_id = '" + device_id + "'", "order_seq").getResultJSONArray(0);
|
JSONArray rs = WQLObject.getWQLObject("acs_device_extra").query("filed_type='02' and device_id = '" + device_id + "'", "order_seq").getResultJSONArray(0);
|
||||||
JSONArray r_arry = new JSONArray();
|
JSONArray r_arry = new JSONArray();
|
||||||
//先获取模板
|
//先获取模板
|
||||||
if(ObjectUtil.isNotEmpty(opcDeviceDriverDefination)){
|
if (ObjectUtil.isNotEmpty(opcDeviceDriverDefination)) {
|
||||||
List<ItemDto> readableItemDtos = opcDeviceDriverDefination.getReadableItemDtos();
|
List<ItemDto> readableItemDtos = opcDeviceDriverDefination.getReadableItemDtos();
|
||||||
List<JSONObject> readableItemJsons = new ArrayList<>();
|
List<JSONObject> readableItemJsons = new ArrayList<>();
|
||||||
for (int i = 0; i < readableItemDtos.size(); i++) {
|
for (int i = 0; i < readableItemDtos.size(); i++) {
|
||||||
ItemDto itemDto = readableItemDtos.get(i);
|
ItemDto itemDto = readableItemDtos.get(i);
|
||||||
JSONObject readableItemJson = new JSONObject();
|
JSONObject readableItemJson = new JSONObject();
|
||||||
readableItemJson.put("code",itemDto.getCode());
|
readableItemJson.put("code", itemDto.getCode());
|
||||||
readableItemJson.put("name",itemDto.getName());
|
readableItemJson.put("name", itemDto.getName());
|
||||||
// readableItemJson.put("db",itemDto.getDb());
|
// readableItemJson.put("db",itemDto.getDb());
|
||||||
readableItemJsons.add(readableItemJson);
|
readableItemJsons.add(readableItemJson);
|
||||||
}
|
}
|
||||||
@@ -1192,7 +1191,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
String code = split[split.length - 1];
|
String code = split[split.length - 1];
|
||||||
robj.put("code", code);
|
robj.put("code", code);
|
||||||
robj.put("name", rs.getJSONObject(i).getString("remark"));
|
robj.put("name", rs.getJSONObject(i).getString("remark"));
|
||||||
if (readableItemJsons.contains(robj)){
|
if (readableItemJsons.contains(robj)) {
|
||||||
robj.put("code", rs.getJSONObject(i).getString("extra_code"));
|
robj.put("code", rs.getJSONObject(i).getString("extra_code"));
|
||||||
robj.put("db", rs.getJSONObject(i).getString("extra_name"));
|
robj.put("db", rs.getJSONObject(i).getString("extra_name"));
|
||||||
r_arry.add(robj);
|
r_arry.add(robj);
|
||||||
@@ -1206,16 +1205,16 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
code = split[split.length - 1];
|
code = split[split.length - 1];
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("code", code);
|
jsonObject.put("code", code);
|
||||||
jsonObject.put("name",rJson.getString("name"));
|
jsonObject.put("name", rJson.getString("name"));
|
||||||
rarry.add(jsonObject);
|
rarry.add(jsonObject);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < readableItemDtos.size(); i++) {
|
for (int i = 0; i < readableItemDtos.size(); i++) {
|
||||||
ItemDto itemDto = readableItemDtos.get(i);
|
ItemDto itemDto = readableItemDtos.get(i);
|
||||||
JSONObject readableItemJson = new JSONObject();
|
JSONObject readableItemJson = new JSONObject();
|
||||||
readableItemJson.put("code",itemDto.getCode());
|
readableItemJson.put("code", itemDto.getCode());
|
||||||
readableItemJson.put("name",itemDto.getName());
|
readableItemJson.put("name", itemDto.getName());
|
||||||
if (!rarry.contains(readableItemJson)){
|
if (!rarry.contains(readableItemJson)) {
|
||||||
readableItemJson.put("db",itemDto.getDb());
|
readableItemJson.put("db", itemDto.getDb());
|
||||||
r_arry.add(readableItemJson);
|
r_arry.add(readableItemJson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1226,8 +1225,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
for (int i = 0; i < writeableItemDtos.size(); i++) {
|
for (int i = 0; i < writeableItemDtos.size(); i++) {
|
||||||
ItemDto itemDto = writeableItemDtos.get(i);
|
ItemDto itemDto = writeableItemDtos.get(i);
|
||||||
JSONObject writeableItemJson = new JSONObject();
|
JSONObject writeableItemJson = new JSONObject();
|
||||||
writeableItemJson.put("code",itemDto.getCode());
|
writeableItemJson.put("code", itemDto.getCode());
|
||||||
writeableItemJson.put("name",itemDto.getName());
|
writeableItemJson.put("name", itemDto.getName());
|
||||||
//writeableItemJson.put("db",itemDto.getDb());
|
//writeableItemJson.put("db",itemDto.getDb());
|
||||||
writeableItemJsons.add(writeableItemJson);
|
writeableItemJsons.add(writeableItemJson);
|
||||||
}
|
}
|
||||||
@@ -1238,7 +1237,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
JSONObject robj = new JSONObject();
|
JSONObject robj = new JSONObject();
|
||||||
robj.put("code", code);
|
robj.put("code", code);
|
||||||
robj.put("name", ws.getJSONObject(i).getString("remark"));
|
robj.put("name", ws.getJSONObject(i).getString("remark"));
|
||||||
if (writeableItemJsons.contains(robj)){
|
if (writeableItemJsons.contains(robj)) {
|
||||||
robj.put("code", ws.getJSONObject(i).getString("extra_code"));
|
robj.put("code", ws.getJSONObject(i).getString("extra_code"));
|
||||||
robj.put("db", ws.getJSONObject(i).getString("extra_name"));
|
robj.put("db", ws.getJSONObject(i).getString("extra_name"));
|
||||||
w_arry.add(robj);
|
w_arry.add(robj);
|
||||||
@@ -1251,17 +1250,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
String[] split = code.split("\\.");
|
String[] split = code.split("\\.");
|
||||||
code = split[split.length - 1];
|
code = split[split.length - 1];
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("code",code);
|
jsonObject.put("code", code);
|
||||||
jsonObject.put("name",wJson.getString("name"));
|
jsonObject.put("name", wJson.getString("name"));
|
||||||
warry.add(jsonObject);
|
warry.add(jsonObject);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < writeableItemDtos.size(); i++) {
|
for (int i = 0; i < writeableItemDtos.size(); i++) {
|
||||||
ItemDto itemDto = writeableItemDtos.get(i);
|
ItemDto itemDto = writeableItemDtos.get(i);
|
||||||
JSONObject writeableItemJson = new JSONObject();
|
JSONObject writeableItemJson = new JSONObject();
|
||||||
writeableItemJson.put("code",itemDto.getCode());
|
writeableItemJson.put("code", itemDto.getCode());
|
||||||
writeableItemJson.put("name",itemDto.getName());
|
writeableItemJson.put("name", itemDto.getName());
|
||||||
if (!warry.contains(writeableItemJson)){
|
if (!warry.contains(writeableItemJson)) {
|
||||||
writeableItemJson.put("db",itemDto.getDb());
|
writeableItemJson.put("db", itemDto.getDb());
|
||||||
w_arry.add(writeableItemJson);
|
w_arry.add(writeableItemJson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1582,41 +1581,41 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
JSONArray rss = param.getJSONArray("rs");
|
JSONArray rss = param.getJSONArray("rs");
|
||||||
JSONArray wss = param.getJSONArray("ws");
|
JSONArray wss = param.getJSONArray("ws");
|
||||||
int numberSize = Integer.parseInt(form.getString("device_number"));
|
int numberSize = Integer.parseInt(form.getString("device_number"));
|
||||||
List<Map<String,Object>> list = new LinkedList<>();
|
List<Map<String, Object>> list = new LinkedList<>();
|
||||||
|
|
||||||
if (type.equals("db")){
|
if (type.equals("db")) {
|
||||||
for (int i = 0; i < numberSize; i++) {
|
for (int i = 0; i < numberSize; i++) {
|
||||||
int dbInterval = db_interval * i;
|
int dbInterval = db_interval * i;
|
||||||
Integer deviceCode = device_code + i;
|
Integer deviceCode = device_code + i;
|
||||||
for (int j = 0; j <= rss.size(); j++) {
|
for (int j = 0; j <= rss.size(); j++) {
|
||||||
Map<String,Object> map = new ListOrderedMap<>();
|
Map<String, Object> map = new ListOrderedMap<>();
|
||||||
if (wss.size() > rss.size()){
|
if (wss.size() > rss.size()) {
|
||||||
if (j == rss.size()){
|
if (j == rss.size()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (j == rss.size()){
|
if (j == rss.size()) {
|
||||||
map.put("设备编码","");
|
map.put("设备编码", "");
|
||||||
map.put("读取地址","");
|
map.put("读取地址", "");
|
||||||
map.put("读取意义","");
|
map.put("读取意义", "");
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址","");
|
map.put("写入地址", "");
|
||||||
map.put("写入意义","");
|
map.put("写入意义", "");
|
||||||
list.add(map);
|
list.add(map);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0 && j ==0){
|
if (i == 0 && j == 0) {
|
||||||
map.put("设备编码","");
|
map.put("设备编码", "");
|
||||||
}else {
|
} else {
|
||||||
map.put("设备编码",deviceCode);
|
map.put("设备编码", deviceCode);
|
||||||
}
|
}
|
||||||
JSONObject rs = rss.getJSONObject(j);
|
JSONObject rs = rss.getJSONObject(j);
|
||||||
String db = rs.getString("db");
|
String db = rs.getString("db");
|
||||||
String name = rs.getString("name");
|
String name = rs.getString("name");
|
||||||
if (i > 0){
|
if (i > 0) {
|
||||||
if (name.equals("心跳")){
|
if (name.equals("心跳")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1624,77 +1623,77 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
String startDB = dbs[0];
|
String startDB = dbs[0];
|
||||||
String endDB = dbs[1];
|
String endDB = dbs[1];
|
||||||
String endDBFirst = endDB.substring(0, 1);
|
String endDBFirst = endDB.substring(0, 1);
|
||||||
Integer endDBEnd =Integer.parseInt(endDB.substring(1, endDB.length())) ;
|
Integer endDBEnd = Integer.parseInt(endDB.substring(1, endDB.length()));
|
||||||
endDBEnd = endDBEnd + dbInterval;
|
endDBEnd = endDBEnd + dbInterval;
|
||||||
db = startDB + "." + endDBFirst + endDBEnd;
|
db = startDB + "." + endDBFirst + endDBEnd;
|
||||||
map.put("读取地址",db);
|
map.put("读取地址", db);
|
||||||
map.put("读取意义",name);
|
map.put("读取意义", name);
|
||||||
Map<String, Object> value = getValue(wss, j, dbInterval,i);
|
Map<String, Object> value = getValue(wss, j, dbInterval, i);
|
||||||
map.putAll(value);
|
map.putAll(value);
|
||||||
list.add(map);
|
list.add(map);
|
||||||
System.out.println(map);
|
System.out.println(map);
|
||||||
}
|
}
|
||||||
if (wss.size() > rss.size()){
|
if (wss.size() > rss.size()) {
|
||||||
int s = wss.size() - rss.size();
|
int s = wss.size() - rss.size();
|
||||||
for (int l = 0; l <= s + 1; l++) {
|
for (int l = 0; l <= s + 1; l++) {
|
||||||
Map<String,Object> map = new ListOrderedMap<>();
|
Map<String, Object> map = new ListOrderedMap<>();
|
||||||
if (l == s + 1){
|
if (l == s + 1) {
|
||||||
map.put("设备编码","");
|
map.put("设备编码", "");
|
||||||
map.put("读取地址","");
|
map.put("读取地址", "");
|
||||||
map.put("读取意义","");
|
map.put("读取意义", "");
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址","");
|
map.put("写入地址", "");
|
||||||
map.put("写入意义","");
|
map.put("写入意义", "");
|
||||||
list.add(map);
|
list.add(map);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
map.put("设备编码",deviceCode);
|
map.put("设备编码", deviceCode);
|
||||||
map.put("读取地址","");
|
map.put("读取地址", "");
|
||||||
map.put("读取意义","");
|
map.put("读取意义", "");
|
||||||
Map<String, Object> value = getValue(wss, rss.size() + l, dbInterval,i);
|
Map<String, Object> value = getValue(wss, rss.size() + l, dbInterval, i);
|
||||||
map.putAll(value);
|
map.putAll(value);
|
||||||
list.add(map);
|
list.add(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if (type.equals("v")){
|
} else if (type.equals("v")) {
|
||||||
for (int i = 0; i < numberSize; i++) {
|
for (int i = 0; i < numberSize; i++) {
|
||||||
int dbInterval = db_interval * i;
|
int dbInterval = db_interval * i;
|
||||||
Integer deviceCode = device_code + i;
|
Integer deviceCode = device_code + i;
|
||||||
for (int j = 0; j <= rss.size(); j++) {
|
for (int j = 0; j <= rss.size(); j++) {
|
||||||
Map<String,Object> map = new ListOrderedMap<>();
|
Map<String, Object> map = new ListOrderedMap<>();
|
||||||
if (j == rss.size()){
|
if (j == rss.size()) {
|
||||||
map.put("设备编码","");
|
map.put("设备编码", "");
|
||||||
map.put("读取地址","");
|
map.put("读取地址", "");
|
||||||
map.put("读取意义","");
|
map.put("读取意义", "");
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址","");
|
map.put("写入地址", "");
|
||||||
map.put("写入意义","");
|
map.put("写入意义", "");
|
||||||
list.add(map);
|
list.add(map);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i == 0 && j ==0){
|
if (i == 0 && j == 0) {
|
||||||
map.put("设备编码","");
|
map.put("设备编码", "");
|
||||||
}else {
|
} else {
|
||||||
map.put("设备编码",deviceCode);
|
map.put("设备编码", deviceCode);
|
||||||
}
|
}
|
||||||
JSONObject rs = rss.getJSONObject(j);
|
JSONObject rs = rss.getJSONObject(j);
|
||||||
String db = rs.getString("db");
|
String db = rs.getString("db");
|
||||||
String name = rs.getString("name");
|
String name = rs.getString("name");
|
||||||
if (i > 0){
|
if (i > 0) {
|
||||||
if (name.equals("心跳")){
|
if (name.equals("心跳")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//String[] dbs = db.split("\\.");
|
//String[] dbs = db.split("\\.");
|
||||||
String startDB = db.substring(0,2);
|
String startDB = db.substring(0, 2);
|
||||||
String endDB = db.substring(2,db.length());
|
String endDB = db.substring(2, db.length());
|
||||||
Integer endDBEnd =Integer.parseInt(endDB) ;
|
Integer endDBEnd = Integer.parseInt(endDB);
|
||||||
endDBEnd = endDBEnd + dbInterval;
|
endDBEnd = endDBEnd + dbInterval;
|
||||||
db = startDB + endDBEnd + "";
|
db = startDB + endDBEnd + "";
|
||||||
map.put("读取地址",db);
|
map.put("读取地址", db);
|
||||||
map.put("读取意义",name);
|
map.put("读取意义", name);
|
||||||
Map<String, Object> value = getValue1(wss, j, dbInterval,i);
|
Map<String, Object> value = getValue1(wss, j, dbInterval, i);
|
||||||
map.putAll(value);
|
map.putAll(value);
|
||||||
list.add(map);
|
list.add(map);
|
||||||
System.out.println(map);
|
System.out.println(map);
|
||||||
@@ -1706,17 +1705,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
FileUtil.downloadExcel(list, response);
|
FileUtil.downloadExcel(list, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Object> getValue(JSONArray wss, int j, Integer dbInterval, int i){
|
public Map<String, Object> getValue(JSONArray wss, int j, Integer dbInterval, int i) {
|
||||||
int size = wss.size();
|
int size = wss.size();
|
||||||
Map<String,Object> map = new ListOrderedMap<>();
|
Map<String, Object> map = new ListOrderedMap<>();
|
||||||
if (i == 0 && j == 0){
|
if (i == 0 && j == 0) {
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址","");
|
map.put("写入地址", "");
|
||||||
map.put("写入意义","");
|
map.put("写入意义", "");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
if (i == 0 && j > 0){
|
if (i == 0 && j > 0) {
|
||||||
if (j - 1 < size){
|
if (j - 1 < size) {
|
||||||
JSONObject ws = wss.getJSONObject(j - 1);
|
JSONObject ws = wss.getJSONObject(j - 1);
|
||||||
String db = ws.getString("db");
|
String db = ws.getString("db");
|
||||||
String name = ws.getString("name");
|
String name = ws.getString("name");
|
||||||
@@ -1724,19 +1723,19 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
String startDB = dbs[0];
|
String startDB = dbs[0];
|
||||||
String endDB = dbs[1];
|
String endDB = dbs[1];
|
||||||
String endDBFirst = endDB.substring(0, 1);
|
String endDBFirst = endDB.substring(0, 1);
|
||||||
Integer endDBEnd =Integer.parseInt(endDB.substring(1, endDB.length())) ;
|
Integer endDBEnd = Integer.parseInt(endDB.substring(1, endDB.length()));
|
||||||
endDBEnd = endDBEnd + dbInterval;
|
endDBEnd = endDBEnd + dbInterval;
|
||||||
db = startDB + "." + endDBFirst + endDBEnd;
|
db = startDB + "." + endDBFirst + endDBEnd;
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址",db);
|
map.put("写入地址", db);
|
||||||
map.put("写入意义",name);
|
map.put("写入意义", name);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( i > 0){
|
if (i > 0) {
|
||||||
j = j -1;
|
j = j - 1;
|
||||||
}
|
}
|
||||||
if (j < size){
|
if (j < size) {
|
||||||
JSONObject ws = wss.getJSONObject(j);
|
JSONObject ws = wss.getJSONObject(j);
|
||||||
String db = ws.getString("db");
|
String db = ws.getString("db");
|
||||||
String name = ws.getString("name");
|
String name = ws.getString("name");
|
||||||
@@ -1744,17 +1743,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
String startDB = dbs[0];
|
String startDB = dbs[0];
|
||||||
String endDB = dbs[1];
|
String endDB = dbs[1];
|
||||||
String endDBFirst = endDB.substring(0, 1);
|
String endDBFirst = endDB.substring(0, 1);
|
||||||
Integer endDBEnd =Integer.parseInt(endDB.substring(1, endDB.length())) ;
|
Integer endDBEnd = Integer.parseInt(endDB.substring(1, endDB.length()));
|
||||||
endDBEnd = endDBEnd + dbInterval;
|
endDBEnd = endDBEnd + dbInterval;
|
||||||
db = startDB + "." + endDBFirst + endDBEnd;
|
db = startDB + "." + endDBFirst + endDBEnd;
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址",db);
|
map.put("写入地址", db);
|
||||||
map.put("写入意义",name);
|
map.put("写入意义", name);
|
||||||
return map;
|
return map;
|
||||||
} else {
|
} else {
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址","");
|
map.put("写入地址", "");
|
||||||
map.put("写入意义","");
|
map.put("写入意义", "");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1873,67 +1872,92 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
for (int i = 0; i < read.size(); i++) {
|
for (int i = 0; i < read.size(); i++) {
|
||||||
List list = read.get(i);
|
List list = read.get(i);
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
|
String device_code = list.get(0).toString();
|
||||||
|
String device_name = list.get(1).toString();
|
||||||
|
String device_type = list.get(2).toString();
|
||||||
|
String is_config = list.get(3).toString();
|
||||||
|
String is_route = list.get(4).toString();
|
||||||
|
if (StrUtil.isEmpty(device_code)) {
|
||||||
|
throw new BadRequestException("设备编号为空!");
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(device_name)) {
|
||||||
|
device_name = device_code;
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(device_type)) {
|
||||||
|
device_type = "conveyor";
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(is_config)) {
|
||||||
|
is_config = "FALSE";
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(is_route)) {
|
||||||
|
is_route = "FALSE";
|
||||||
|
}
|
||||||
|
DeviceDto dto = this.findByCode(device_code);
|
||||||
|
if (ObjectUtil.isNotEmpty(dto)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//按照列获取
|
//按照列获取
|
||||||
param.put("device_id", IdUtil.getSnowflake(1, 1).nextId());
|
param.put("device_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||||
param.put("device_code", list.get(0).toString());
|
param.put("device_code", device_code);
|
||||||
param.put("device_name", list.get(0).toString());
|
param.put("device_name", device_name);
|
||||||
param.put("device_type", "conveyor");
|
param.put("device_type", device_type);
|
||||||
param.put("is_config", "FALSE");
|
param.put("is_config", is_config);
|
||||||
param.put("is_route", "FALSE");
|
param.put("is_route", is_route);
|
||||||
param.put("create_by", nickName);
|
param.put("create_by", nickName);
|
||||||
param.put("create_time", now);
|
param.put("create_time", now);
|
||||||
param.put("update_by", nickName);
|
param.put("update_by", nickName);
|
||||||
param.put("update_time", now);
|
param.put("update_time", now);
|
||||||
|
|
||||||
wo.insert(param);
|
wo.insert(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Object> getValue1(JSONArray wss, int j, Integer dbInterval, int i){
|
public Map<String, Object> getValue1(JSONArray wss, int j, Integer dbInterval, int i) {
|
||||||
int size = wss.size();
|
int size = wss.size();
|
||||||
Map<String,Object> map = new ListOrderedMap<>();
|
Map<String, Object> map = new ListOrderedMap<>();
|
||||||
if (i == 0 && j == 0){
|
if (i == 0 && j == 0) {
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址","");
|
map.put("写入地址", "");
|
||||||
map.put("写入意义","");
|
map.put("写入意义", "");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
if (i == 0 && j > 0){
|
if (i == 0 && j > 0) {
|
||||||
if (j - 1 < size){
|
if (j - 1 < size) {
|
||||||
JSONObject ws = wss.getJSONObject(j - 1);
|
JSONObject ws = wss.getJSONObject(j - 1);
|
||||||
String db = ws.getString("db");
|
String db = ws.getString("db");
|
||||||
String name = ws.getString("name");
|
String name = ws.getString("name");
|
||||||
//String[] dbs = db.split("\\.");
|
//String[] dbs = db.split("\\.");
|
||||||
String startDB = db.substring(0, 2);
|
String startDB = db.substring(0, 2);
|
||||||
String endDB = db.substring(2,db.length());
|
String endDB = db.substring(2, db.length());
|
||||||
Integer endDBEnd =Integer.parseInt(endDB) ;
|
Integer endDBEnd = Integer.parseInt(endDB);
|
||||||
endDBEnd = endDBEnd + dbInterval;
|
endDBEnd = endDBEnd + dbInterval;
|
||||||
db = startDB + endDBEnd + "";
|
db = startDB + endDBEnd + "";
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址",db);
|
map.put("写入地址", db);
|
||||||
map.put("写入意义",name);
|
map.put("写入意义", name);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( i > 0){
|
if (i > 0) {
|
||||||
j = j -1;
|
j = j - 1;
|
||||||
}
|
}
|
||||||
if (j < size){
|
if (j < size) {
|
||||||
JSONObject ws = wss.getJSONObject(j);
|
JSONObject ws = wss.getJSONObject(j);
|
||||||
String db = ws.getString("db");
|
String db = ws.getString("db");
|
||||||
String name = ws.getString("name");
|
String name = ws.getString("name");
|
||||||
String startDB = db.substring(0, 2);
|
String startDB = db.substring(0, 2);
|
||||||
String endDB = db.substring(2,db.length());
|
String endDB = db.substring(2, db.length());
|
||||||
Integer endDBEnd =Integer.parseInt(endDB) ;
|
Integer endDBEnd = Integer.parseInt(endDB);
|
||||||
endDBEnd = endDBEnd + dbInterval;
|
endDBEnd = endDBEnd + dbInterval;
|
||||||
db = startDB + endDBEnd + "";
|
db = startDB + endDBEnd + "";
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址",db);
|
map.put("写入地址", db);
|
||||||
map.put("写入意义",name);
|
map.put("写入意义", name);
|
||||||
return map;
|
return map;
|
||||||
} else {
|
} else {
|
||||||
map.put("","");
|
map.put("", "");
|
||||||
map.put("写入地址","");
|
map.put("写入地址", "");
|
||||||
map.put("写入意义","");
|
map.put("写入意义", "");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public class ItemProtocol {
|
|||||||
public static String item_walk_y = "walk_y";
|
public static String item_walk_y = "walk_y";
|
||||||
//报警信号
|
//报警信号
|
||||||
public static String item_error = "error";
|
public static String item_error = "error";
|
||||||
|
//任务类型
|
||||||
|
public static String item_type = "type";
|
||||||
//前工位任务号
|
//前工位任务号
|
||||||
public static String item_task1 = "task1";
|
public static String item_task1 = "task1";
|
||||||
//后工位任务号
|
//后工位任务号
|
||||||
@@ -52,6 +54,8 @@ public class ItemProtocol {
|
|||||||
public static String item_to_target2 = "to_target2";
|
public static String item_to_target2 = "to_target2";
|
||||||
//后工位下发任务号
|
//后工位下发任务号
|
||||||
public static String item_to_task2 = "to_task2";
|
public static String item_to_task2 = "to_task2";
|
||||||
|
//任务类型 1前工位 2后工位 3双工位
|
||||||
|
public static String item_to_type = "to_type";
|
||||||
|
|
||||||
|
|
||||||
private SlitTwoManipulatorDeviceDriver driver;
|
private SlitTwoManipulatorDeviceDriver driver;
|
||||||
@@ -96,6 +100,10 @@ public class ItemProtocol {
|
|||||||
return this.getOpcIntegerValue(item_walk_y);
|
return this.getOpcIntegerValue(item_walk_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return this.getOpcIntegerValue(item_type);
|
||||||
|
}
|
||||||
|
|
||||||
public int getTask1() {
|
public int getTask1() {
|
||||||
return this.getOpcIntegerValue(item_task1);
|
return this.getOpcIntegerValue(item_task1);
|
||||||
}
|
}
|
||||||
@@ -146,6 +154,7 @@ public class ItemProtocol {
|
|||||||
list.add(new ItemDto(item_action2, "后工位动作信号", "DB2.B6"));
|
list.add(new ItemDto(item_action2, "后工位动作信号", "DB2.B6"));
|
||||||
list.add(new ItemDto(item_walk_y, "行走列", "DB1.B7"));
|
list.add(new ItemDto(item_walk_y, "行走列", "DB1.B7"));
|
||||||
list.add(new ItemDto(item_error, "报警信号", "DB1.B8"));
|
list.add(new ItemDto(item_error, "报警信号", "DB1.B8"));
|
||||||
|
list.add(new ItemDto(item_type, "任务类型", "DB1.B9"));
|
||||||
list.add(new ItemDto(item_task1, "前工位任务号", "DB1.D10"));
|
list.add(new ItemDto(item_task1, "前工位任务号", "DB1.D10"));
|
||||||
list.add(new ItemDto(item_task2, "后工位任务号", "DB1.D14"));
|
list.add(new ItemDto(item_task2, "后工位任务号", "DB1.D14"));
|
||||||
return list;
|
return list;
|
||||||
@@ -161,6 +170,7 @@ public class ItemProtocol {
|
|||||||
list.add(new ItemDto(item_to_onset2, "后工位下发起始站", "DB2.W12"));
|
list.add(new ItemDto(item_to_onset2, "后工位下发起始站", "DB2.W12"));
|
||||||
list.add(new ItemDto(item_to_target2, "后工位下发目标站", "DB2.W14"));
|
list.add(new ItemDto(item_to_target2, "后工位下发目标站", "DB2.W14"));
|
||||||
list.add(new ItemDto(item_to_task2, "后工位下发任务号", "DB2.D16"));
|
list.add(new ItemDto(item_to_task2, "后工位下发任务号", "DB2.D16"));
|
||||||
|
list.add(new ItemDto(item_to_type, "下发任务类型", "DB2.W20"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
//行走列
|
//行走列
|
||||||
int walk_y = 0;
|
int walk_y = 0;
|
||||||
int last_walk_y = 0;
|
int last_walk_y = 0;
|
||||||
|
//任务类型
|
||||||
|
int type = 0;
|
||||||
|
int last_type = 0;
|
||||||
//前后工位任务号
|
//前后工位任务号
|
||||||
int task1 = 0;
|
int task1 = 0;
|
||||||
int last_task1 = 0;
|
int last_task1 = 0;
|
||||||
@@ -88,10 +91,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
|
|
||||||
|
|
||||||
Boolean isonline = true;
|
Boolean isonline = true;
|
||||||
//后工位申请任务请求标记
|
|
||||||
Boolean requireBackSucess = false;
|
|
||||||
//前工位申请任务请求标记
|
//前工位申请任务请求标记
|
||||||
Boolean requireHeadSucess = false;
|
Boolean requireSucess = false;
|
||||||
|
|
||||||
int hasGoods = 0;
|
int hasGoods = 0;
|
||||||
String message = null;
|
String message = null;
|
||||||
@@ -131,17 +132,21 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
action2 = this.itemProtocol.getAction2();
|
action2 = this.itemProtocol.getAction2();
|
||||||
walk_y = this.itemProtocol.getWalk_y();
|
walk_y = this.itemProtocol.getWalk_y();
|
||||||
error = this.itemProtocol.getError();
|
error = this.itemProtocol.getError();
|
||||||
|
type = this.itemProtocol.getType();
|
||||||
task1 = this.itemProtocol.getTask1();
|
task1 = this.itemProtocol.getTask1();
|
||||||
task2 = this.itemProtocol.getTask2();
|
task2 = this.itemProtocol.getTask2();
|
||||||
|
|
||||||
if (mode != last_mode) {
|
if (mode != last_mode) {
|
||||||
if (mode == 2) {
|
if (mode == 2) {
|
||||||
this.setRequireHeadSucess(false);
|
this.setRequireSucess(false);
|
||||||
this.setRequireBackSucess(false);
|
|
||||||
}
|
}
|
||||||
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
|
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||||
}
|
}
|
||||||
|
if (type != last_type) {
|
||||||
|
logServer.deviceItemValue(this.device_code, "type", String.valueOf(type));
|
||||||
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号type:" + last_type + "->" + type);
|
||||||
|
}
|
||||||
if (error != last_error) {
|
if (error != last_error) {
|
||||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||||
@@ -179,15 +184,15 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2);
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//前工位任务就绪->执行
|
//单任务 前工位任务更新指令状态
|
||||||
if (task1 > 0) {
|
if (task1 > 0 && type == 1) {
|
||||||
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
||||||
if (inst1 != null) {
|
if (inst1 != null) {
|
||||||
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
|
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
|
||||||
inst1.setInstruction_status("1");
|
inst1.setInstruction_status("1");
|
||||||
instructionService.update(inst1);
|
instructionService.update(inst1);
|
||||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
||||||
if (!ObjectUtil.isEmpty(taskDto)){
|
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
JSONObject map = new JSONObject();
|
JSONObject map = new JSONObject();
|
||||||
@@ -196,39 +201,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
array.add(map);
|
array.add(map);
|
||||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//前工位放货完成 任务完成
|
//单任务 后工位任务更新指令状态
|
||||||
if (action1 == 4 && move1 == 0 && task1 > 0) {
|
if (task2 > 0 && type == 2) {
|
||||||
//inst_message
|
|
||||||
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
|
||||||
if (inst1 != null) {
|
|
||||||
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
|
|
||||||
this.finish_instruction(inst1);
|
|
||||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
|
||||||
if (!ObjectUtil.isEmpty(taskDto)){
|
|
||||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
|
||||||
JSONArray array = new JSONArray();
|
|
||||||
JSONObject map = new JSONObject();
|
|
||||||
map.put("task_id", taskDto.getExt_task_id());
|
|
||||||
map.put("task_status", "2");
|
|
||||||
array.add(map);
|
|
||||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.writing("to_command1", "0");
|
|
||||||
this.writing("to_onset1", "0");
|
|
||||||
this.writing("to_target1", "0");
|
|
||||||
this.writing("to_task1", "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//后工位任务就绪->执行
|
|
||||||
if (task2 > 0) {
|
|
||||||
//inst_message
|
//inst_message
|
||||||
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
||||||
if (inst2 != null) {
|
if (inst2 != null) {
|
||||||
@@ -236,8 +216,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
inst2.setInstruction_status("1");
|
inst2.setInstruction_status("1");
|
||||||
instructionService.update(inst2);
|
instructionService.update(inst2);
|
||||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||||
if (!ObjectUtil.isEmpty(taskDto)){
|
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
|
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
JSONObject map = new JSONObject();
|
JSONObject map = new JSONObject();
|
||||||
map.put("task_id", taskDto.getExt_task_id());
|
map.put("task_id", taskDto.getExt_task_id());
|
||||||
@@ -245,20 +225,46 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
array.add(map);
|
array.add(map);
|
||||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//后工位放货完成 任务完成
|
|
||||||
if (action2 == 4 && move2 == 0 && task2 > 0) {
|
//双任务更新指令状态
|
||||||
|
if (task2 > 0 && task1 > 0 && type == 3) {
|
||||||
//inst_message
|
//inst_message
|
||||||
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
||||||
if (inst2 != null) {
|
if (inst2 != null) {
|
||||||
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
|
if (StrUtil.equals(inst2.getInstruction_status(), "0")) {
|
||||||
finish_instruction(inst2);
|
inst2.setInstruction_status("1");
|
||||||
|
instructionService.update(inst2);
|
||||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||||
if (!ObjectUtil.isEmpty(taskDto)){
|
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
|
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("task_id", taskDto.getExt_task_id());
|
||||||
|
map.put("task_status", "1");
|
||||||
|
array.add(map);
|
||||||
|
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//单任务前工位放货完成 任务完成
|
||||||
|
if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && type == 1) {
|
||||||
|
//inst_message
|
||||||
|
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
||||||
|
if (inst1 != null) {
|
||||||
|
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
|
||||||
|
this.finish_instruction(inst1);
|
||||||
|
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
||||||
|
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||||
|
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
JSONObject map = new JSONObject();
|
JSONObject map = new JSONObject();
|
||||||
map.put("task_id", taskDto.getExt_task_id());
|
map.put("task_id", taskDto.getExt_task_id());
|
||||||
@@ -266,19 +272,88 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
array.add(map);
|
array.add(map);
|
||||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
this.writing("to_command2", "0");
|
;
|
||||||
this.writing("to_onset2", "0");
|
this.writing("to_command1", "0");
|
||||||
this.writing("to_target2", "0");
|
this.writing("to_onset1", "0");
|
||||||
this.writing("to_task2", "0");
|
this.writing("to_target1", "0");
|
||||||
|
this.writing("to_task1", "0");
|
||||||
|
this.writing("to_type", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//双任务 - 后工位取货时判断取货位光电信号
|
//单任务 后工位放货完成 任务完成
|
||||||
if (mode == 3 && action2 == 1 && move2 == 0 && task1 > 0 && task2 > 0) {
|
if (mode == 3 && action2 == 4 && move2 == 0 && task2 > 0 && type == 2) {
|
||||||
|
//inst_message
|
||||||
|
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
||||||
|
if (inst2 != null) {
|
||||||
|
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
|
||||||
|
finish_instruction(inst2);
|
||||||
|
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||||
|
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||||
|
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("task_id", taskDto.getExt_task_id());
|
||||||
|
map.put("task_status", "2");
|
||||||
|
array.add(map);
|
||||||
|
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
this.writing("to_command2", "0");
|
||||||
|
this.writing("to_onset2", "0");
|
||||||
|
this.writing("to_target2", "0");
|
||||||
|
this.writing("to_task2", "0");
|
||||||
|
this.writing("to_type", "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//双工位 任务完成
|
||||||
|
if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && task2 > 0 && type == 3) {
|
||||||
|
//inst_message
|
||||||
|
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
||||||
|
if (inst1 != null) {
|
||||||
|
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
|
||||||
|
this.finish_instruction(inst1);
|
||||||
|
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
||||||
|
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||||
|
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("task_id", taskDto.getExt_task_id());
|
||||||
|
map.put("task_status", "2");
|
||||||
|
array.add(map);
|
||||||
|
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
this.writing("to_command1", "0");
|
||||||
|
this.writing("to_onset1", "0");
|
||||||
|
this.writing("to_target1", "0");
|
||||||
|
this.writing("to_task1", "0");
|
||||||
|
this.writing("to_command2", "0");
|
||||||
|
this.writing("to_onset2", "0");
|
||||||
|
this.writing("to_target2", "0");
|
||||||
|
this.writing("to_task2", "0");
|
||||||
|
this.writing("to_type", "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//后工位取货时判断取货位光电信号
|
||||||
|
if (mode == 3 && action2 == 1 && move2 == 0 && task2 > 0) {
|
||||||
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
||||||
String start_device_code = inst1.getStart_device_code();
|
String start_device_code = "";
|
||||||
|
if (type == 2){
|
||||||
|
start_device_code = inst1.getStart_device_code();
|
||||||
|
}
|
||||||
|
if (type == 3){
|
||||||
|
start_device_code = inst1.getStart_device_code2();
|
||||||
|
}
|
||||||
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
|
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
|
||||||
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
|
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
|
||||||
if (startDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
|
if (startDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
|
||||||
@@ -286,26 +361,21 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
int move = siemensConveyorDeviceDriver.getMove();
|
int move = siemensConveyorDeviceDriver.getMove();
|
||||||
int mode = siemensConveyorDeviceDriver.getMode();
|
int mode = siemensConveyorDeviceDriver.getMode();
|
||||||
if (mode == 2 && move == 1) {
|
if (mode == 2 && move == 1) {
|
||||||
this.writing("to_command1", "2");
|
this.writing("to_command2", "2");
|
||||||
} else {
|
} else {
|
||||||
log.warn("前工位取货位无货,取货位:{},mode:{},move:{}", start_device_code, mode, move);
|
log.warn("前工位取货位无货,取货位:{},mode:{},move:{}", start_device_code, mode, move);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//单任务 - 后工位直接允许取货
|
|
||||||
if (mode == 3 && action2 == 1 && move2 == 0 && task2 > 0 && task1 == 0) {
|
|
||||||
this.writing("to_command1", "2");
|
|
||||||
}
|
|
||||||
|
|
||||||
//后工位允许放货
|
//后工位允许放货
|
||||||
if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) {
|
if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) {
|
||||||
this.writing("to_command1", "3");
|
this.writing("to_command2", "3");
|
||||||
}
|
}
|
||||||
|
|
||||||
//前工位允许放货
|
//前工位允许取货
|
||||||
if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0) {
|
if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0) {
|
||||||
this.writing("to_command2", "2");
|
this.writing("to_command1", "2");
|
||||||
}
|
}
|
||||||
|
|
||||||
//前工位放货时判断放货位光电信号
|
//前工位放货时判断放货位光电信号
|
||||||
@@ -319,7 +389,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
int move = siemensConveyorDeviceDriver.getMove();
|
int move = siemensConveyorDeviceDriver.getMove();
|
||||||
int mode = siemensConveyorDeviceDriver.getMode();
|
int mode = siemensConveyorDeviceDriver.getMode();
|
||||||
if (move == 0 && mode == 2) {
|
if (move == 0 && mode == 2) {
|
||||||
this.writing("to_command2", "3");
|
this.writing("to_command1", "3");
|
||||||
} else {
|
} else {
|
||||||
log.warn("后工位放货位有货,放货位:{},mode:{},move:{}", next_device_code, mode, move);
|
log.warn("后工位放货位有货,放货位:{},mode:{},move:{}", next_device_code, mode, move);
|
||||||
}
|
}
|
||||||
@@ -348,34 +418,18 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
} else {
|
} else {
|
||||||
this.setIsonline(true);
|
this.setIsonline(true);
|
||||||
this.setIserror(false);
|
this.setIserror(false);
|
||||||
message = "";
|
|
||||||
Instruction instruction = null;
|
|
||||||
List toInstructions;
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 1:
|
case 1:
|
||||||
log.debug("设备运转模式:等待工作");
|
log.debug("设备运转模式:等待工作");
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
//后工位申请任务 取空放空
|
//申请任务
|
||||||
//mode == 2 && move2 == 0 && action2 == 0 && !requireBackSucess
|
if (mode == 2 && move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess) {
|
||||||
if (move2 == 0 && action2 == 0 && !requireBackSucess) {
|
|
||||||
instruction_require2();
|
|
||||||
logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move1:" + move1 + ",action1:" + action1 + ",move2:" + move2 + ",task1:" + task1 + ",requireHeadSucess:" + requireHeadSucess);
|
|
||||||
}
|
|
||||||
//前工位申请任务 取满放满
|
|
||||||
//mode == 2 && move2 == 0 && action2 == 0 && task2 == 0 && move1 == 0 && !requireHeadSucess
|
|
||||||
if (move1 == 0 && action1 == 0 && !requireHeadSucess) {
|
|
||||||
instruction_require();
|
instruction_require();
|
||||||
logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireBackSucess:" + requireBackSucess);
|
logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",action1:" + action1 + ",requireSucess:" + requireSucess);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
//前工位申请任务 取满放满
|
|
||||||
//mode == 3 && move2 == 1 && action2 == 1 && move1 == 0 && !requireHeadSucess
|
|
||||||
// if (mode == 3 && move2 == 1 && action2 == 1 && move1 == 0 && !requireHeadSucess) {
|
|
||||||
// instruction_require();
|
|
||||||
// logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireBackSucess:" + requireBackSucess);
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,186 +442,180 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
last_action1 = action1;
|
last_action1 = action1;
|
||||||
last_action2 = action2;
|
last_action2 = action2;
|
||||||
last_walk_y = walk_y;
|
last_walk_y = walk_y;
|
||||||
|
last_type = type;
|
||||||
last_task1 = task1;
|
last_task1 = task1;
|
||||||
last_task2 = task2;
|
last_task2 = task2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//申请前工位任务
|
//申请任务
|
||||||
public synchronized boolean instruction_require() throws Exception {
|
public synchronized boolean instruction_require() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.instruction_head_time = date;
|
this.instruction_head_time = date;
|
||||||
//后工位取货关联设备
|
//前工位取货关联设备
|
||||||
List<String> getDeviceCodeList = this.getExtraDeviceCodes("head_get_device_code");
|
List<String> getDeviceCodeList = this.getExtraDeviceCodes("head_get_device_code");
|
||||||
//后工位放货关联设备
|
|
||||||
List<String> putDeviceCodeList = this.getExtraDeviceCodes("head_put_device_code");
|
|
||||||
TaskDto task = null;
|
|
||||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
|
||||||
String startDeviceCode = getDeviceCodeList.get(i);
|
|
||||||
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
|
|
||||||
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
|
||||||
TaskDto taskDto = taskDtos.get(0);
|
|
||||||
Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code());
|
|
||||||
instruction.setInstruction_status("1");
|
|
||||||
instruction.setUpdate_time(DateUtil.now());
|
|
||||||
instructionService.update(instruction);
|
|
||||||
Device startDevice = deviceAppservice.findDeviceByCode(instruction.getStart_device_code());
|
|
||||||
Device nextDevice = deviceAppservice.findDeviceByCode(instruction.getNext_device_code());
|
|
||||||
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
|
||||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
|
||||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
|
||||||
this.writing("to_onset1", start_addr);
|
|
||||||
this.writing("to_target1", next_addr);
|
|
||||||
this.writing("to_task1", instruction.getInstruction_code());
|
|
||||||
this.writing("to_command1", "1");
|
|
||||||
requireHeadSucess = true;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
|
|
||||||
if (ObjectUtil.isNotEmpty(taskDtoList)) {
|
|
||||||
task = taskDtoList.get(0);
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isNotEmpty(task)) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ObjectUtil.isEmpty(task)) {
|
|
||||||
String taskid = task.getTask_id();
|
|
||||||
String taskcode = task.getTask_code();
|
|
||||||
String vehiclecode = task.getVehicle_code();
|
|
||||||
String priority = task.getPriority();
|
|
||||||
String start_point_code = task.getStart_point_code();
|
|
||||||
String start_device_code = task.getStart_device_code();
|
|
||||||
String route_plan_code = task.getRoute_plan_code();
|
|
||||||
String next_point_code = task.getNext_point_code();
|
|
||||||
String next_device_code = task.getNext_device_code();
|
|
||||||
|
|
||||||
Instruction instdto = new Instruction();
|
|
||||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
|
||||||
instdto.setRoute_plan_code(route_plan_code);
|
|
||||||
instdto.setRemark(task.getRemark());
|
|
||||||
instdto.setMaterial(task.getMaterial());
|
|
||||||
instdto.setQuantity(task.getQuantity());
|
|
||||||
instdto.setTask_id(taskid);
|
|
||||||
instdto.setTask_code(taskcode);
|
|
||||||
instdto.setVehicle_code(vehiclecode);
|
|
||||||
String now = DateUtil.now();
|
|
||||||
instdto.setCreate_time(now);
|
|
||||||
instdto.setCreate_by("auto");
|
|
||||||
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.setPriority(priority);
|
|
||||||
instdto.setInstruction_status("0");
|
|
||||||
instdto.setExecute_device_code(start_point_code);
|
|
||||||
|
|
||||||
try {
|
|
||||||
instructionService.create(instdto);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建指令后修改任务状态
|
|
||||||
task.setTask_status("1");
|
|
||||||
task.setUpdate_time(DateUtil.now());
|
|
||||||
taskserver.update(task);
|
|
||||||
|
|
||||||
//根据查询的任务起始点位 得出取放工位的电气值 写入后工位电气中
|
|
||||||
Device startDevice = deviceAppservice.findDeviceByCode(instdto.getStart_device_code());
|
|
||||||
Device nextDevice = deviceAppservice.findDeviceByCode(instdto.getNext_device_code());
|
|
||||||
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
|
||||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
|
||||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
|
||||||
this.writing("to_onset1", start_addr);
|
|
||||||
this.writing("to_target1", next_addr);
|
|
||||||
this.writing("to_task1", instdto.getInstruction_code());
|
|
||||||
this.writing("to_command1", "1");
|
|
||||||
requireHeadSucess = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//申请后工位任务
|
|
||||||
public synchronized boolean instruction_require2() throws Exception {
|
|
||||||
Date date = new Date();
|
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
this.instruction_require_time = date;
|
|
||||||
|
|
||||||
//后工位取货关联设备
|
//后工位取货关联设备
|
||||||
List<String> getDeviceCodeList = this.getExtraDeviceCodes("back_get_device_code");
|
List<String> backGetDeviceCodeList = this.getExtraDeviceCodes("back_get_device_code");
|
||||||
//后工位放货关联设备
|
TaskDto taskDto = null;
|
||||||
List<String> putDeviceCodeList = this.getExtraDeviceCodes("back_put_device_code");
|
//遍历前工位取货点设备
|
||||||
|
for (String getDeviceCode : getDeviceCodeList) {
|
||||||
TaskDto task = null;
|
//去任务表中查询是否有前工位关联设备的重新创建指令的任务
|
||||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
List<TaskDto> taskDtos = taskserver.queryTaskByStartAndIntStatus(getDeviceCode);
|
||||||
String startDeviceCode = getDeviceCodeList.get(i);
|
//如果有
|
||||||
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
|
|
||||||
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||||
TaskDto taskDto = taskDtos.get(0);
|
taskDto = taskDtos.get(0);
|
||||||
Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code());
|
this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList);
|
||||||
instruction.setInstruction_status("1");
|
|
||||||
instruction.setUpdate_time(DateUtil.now());
|
|
||||||
instructionService.update(instruction);
|
|
||||||
Device startDevice = deviceAppservice.findDeviceByCode(instruction.getStart_device_code());
|
|
||||||
Device nextDevice = deviceAppservice.findDeviceByCode(instruction.getNext_device_code());
|
|
||||||
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
|
||||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
|
||||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
|
||||||
this.writing("to_onset2", start_addr);
|
|
||||||
this.writing("to_target2", next_addr);
|
|
||||||
this.writing("to_task2", instruction.getInstruction_code());
|
|
||||||
this.writing("to_command2", "1");
|
|
||||||
requireBackSucess = true;
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
|
//去任务表中查询是否有前工位关联设备的就绪状态下的任务
|
||||||
if (ObjectUtil.isNotEmpty(taskDtoList)) {
|
taskDtos = taskserver.queryTaskByStartDeviceCode(getDeviceCode);
|
||||||
task = taskDtoList.get(0);
|
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||||
|
taskDto = taskDtos.get(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotEmpty(task)) break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//如果任务表中起点1或起点2中 无前工位取货点关联设备
|
||||||
|
//就去查询任务表中查找起点1或起点2为后工位取货点关联设备的任务
|
||||||
|
if (ObjectUtil.isEmpty(taskDto)) {
|
||||||
|
for (String backGetDeviceCode : backGetDeviceCodeList) {
|
||||||
|
//去任务表中查询是否有前工位关联设备的重新创建指令的任务
|
||||||
|
List<TaskDto> taskDtos = taskserver.queryTaskByNextAndIntStatus(backGetDeviceCode);
|
||||||
|
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||||
|
taskDto = taskDtos.get(0);
|
||||||
|
this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
//去任务表中查询是否有后工位关联设备的就绪状态下的任务
|
||||||
|
taskDtos = taskserver.queryTaskByStartDeviceCode(backGetDeviceCode);
|
||||||
|
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||||
|
taskDto = taskDtos.get(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||||
|
this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ObjectUtil.isEmpty(task)) {
|
//执行重新生成指令的任务
|
||||||
String taskid = task.getTask_id();
|
public void executeBusiness(TaskDto taskDto, List<String> getDeviceCodeList, List<String> backGetDeviceCodeList) {
|
||||||
String taskcode = task.getTask_code();
|
//任务类型 1.前工位任务 2.后工位任务 3.双工位任务
|
||||||
String vehiclecode = task.getVehicle_code();
|
String type = "";
|
||||||
String priority = task.getPriority();
|
//获取指令信息
|
||||||
String start_point_code = task.getStart_point_code();
|
Instruction instructionDto = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
|
||||||
String start_device_code = task.getStart_device_code();
|
//获取指令表中的取货点1
|
||||||
String route_plan_code = task.getRoute_plan_code();
|
String start_device_code = instructionDto.getStart_device_code();
|
||||||
String next_point_code = task.getNext_point_code();
|
//获取指令表中的取货点2
|
||||||
String next_device_code = task.getNext_device_code();
|
String start_device_code2 = instructionDto.getStart_device_code2();
|
||||||
|
//获取指令表中的放货点1
|
||||||
|
String next_device_code = instructionDto.getNext_device_code();
|
||||||
|
//获取指令表中的放货点2
|
||||||
|
String next_device_code2 = instructionDto.getNext_device_code2();
|
||||||
|
//判断任务点位是否配置电气信号
|
||||||
|
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
|
||||||
|
Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2);
|
||||||
|
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code);
|
||||||
|
Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2);
|
||||||
|
//如果指令表中的取货点1和取货点2 都不为空 则说明时下双工位任务
|
||||||
|
if (StrUtil.isNotEmpty(start_device_code2) && StrUtil.isNotEmpty(start_device_code)) {
|
||||||
|
this.isSetAddress(startDevice);
|
||||||
|
this.isSetAddress(nextDevice);
|
||||||
|
this.isSetAddress(startDevice2);
|
||||||
|
this.isSetAddress(nextDevice2);
|
||||||
|
type = "3";
|
||||||
|
} else {
|
||||||
|
//判断指令表中的起点1 是否是前工位/后工位取货点的关联设备
|
||||||
|
int headGetIndex = getDeviceCodeList.indexOf(start_device_code);
|
||||||
|
int backGetIndex = backGetDeviceCodeList.indexOf(start_device_code);
|
||||||
|
if (headGetIndex != -1) {
|
||||||
|
//前工位
|
||||||
|
type = "1";
|
||||||
|
} else if (backGetIndex != -1) {
|
||||||
|
//后工位
|
||||||
|
type = "2";
|
||||||
|
}
|
||||||
|
this.isSetAddress(startDevice);
|
||||||
|
this.isSetAddress(nextDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改指令状态
|
||||||
|
instructionDto.setInstruction_status("1");
|
||||||
|
instructionDto.setUpdate_time(DateUtil.now());
|
||||||
|
instructionService.update(instructionDto);
|
||||||
|
|
||||||
|
//下发电气信号
|
||||||
|
this.sendSignalType(instructionDto, type);
|
||||||
|
|
||||||
|
//请求任务成功
|
||||||
|
this.setRequireSucess(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//执行就绪状态下的任务
|
||||||
|
public void executeReadyBusiness(TaskDto taskDto, List<String> getDeviceCodeList, List<String> backGetDeviceCodeList) {
|
||||||
|
//任务类型 1.前工位任务 2.后工位任务 3.双工位任务
|
||||||
|
String type = "";
|
||||||
|
//获取任务表中的取货点1
|
||||||
|
String start_device_code = taskDto.getStart_device_code();
|
||||||
|
//获取任务表中的取货点2
|
||||||
|
String start_device_code2 = taskDto.getStart_device_code2();
|
||||||
|
//获取任务表中的放货点1
|
||||||
|
String next_device_code = taskDto.getNext_device_code();
|
||||||
|
//获取任务表中的放货点2
|
||||||
|
String next_device_code2 = taskDto.getNext_device_code2();
|
||||||
|
//判断任务点位是否配置电气信号
|
||||||
|
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
|
||||||
|
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code);
|
||||||
|
Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2);
|
||||||
|
Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2);
|
||||||
|
//如果指令表中的取货点1和取货点2 都不为空 则说明时下双工位任务
|
||||||
|
if (StrUtil.isNotEmpty(start_device_code2) && StrUtil.isNotEmpty(start_device_code)) {
|
||||||
|
type = "3";
|
||||||
|
//判断四个点位是否都设置电气值
|
||||||
|
this.isSetAddress(startDevice);
|
||||||
|
this.isSetAddress(nextDevice);
|
||||||
|
this.isSetAddress(startDevice2);
|
||||||
|
this.isSetAddress(nextDevice2);
|
||||||
|
} else {
|
||||||
|
//判断指令表中的起点1 是否是前工位/后工位取货点的关联设备
|
||||||
|
int headGetIndex = getDeviceCodeList.indexOf(start_device_code);
|
||||||
|
int backGetIndex = backGetDeviceCodeList.indexOf(start_device_code);
|
||||||
|
if (headGetIndex != -1) {
|
||||||
|
type = "1"; //前工位
|
||||||
|
} else if (backGetIndex != -1) {
|
||||||
|
type = "2"; //后工位
|
||||||
|
}
|
||||||
|
//判断单任务下的两个点位是否都设置电气值
|
||||||
|
this.isSetAddress(startDevice);
|
||||||
|
this.isSetAddress(nextDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
String taskid = taskDto.getTask_id();
|
||||||
|
String taskcode = taskDto.getTask_code();
|
||||||
|
String vehiclecode = taskDto.getVehicle_code();
|
||||||
|
String priority = taskDto.getPriority();
|
||||||
|
String start_point_code = taskDto.getStart_point_code();
|
||||||
|
String next_point_code = taskDto.getNext_point_code();
|
||||||
|
String start_point_code2 = taskDto.getStart_point_code2();
|
||||||
|
String next_point_code2 = taskDto.getNext_point_code2();
|
||||||
|
String route_plan_code = taskDto.getRoute_plan_code();
|
||||||
|
String remark = taskDto.getRemark();
|
||||||
|
String material = taskDto.getMaterial();
|
||||||
|
String quantity = taskDto.getQuantity();
|
||||||
|
|
||||||
Instruction instdto = new Instruction();
|
Instruction instdto = new Instruction();
|
||||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
instdto.setRoute_plan_code(route_plan_code);
|
instdto.setRoute_plan_code(route_plan_code);
|
||||||
instdto.setRemark(task.getRemark());
|
instdto.setRemark(remark);
|
||||||
instdto.setMaterial(task.getMaterial());
|
instdto.setMaterial(material);
|
||||||
instdto.setQuantity(task.getQuantity());
|
instdto.setQuantity(quantity);
|
||||||
instdto.setTask_id(taskid);
|
instdto.setTask_id(taskid);
|
||||||
instdto.setTask_code(taskcode);
|
instdto.setTask_code(taskcode);
|
||||||
instdto.setVehicle_code(vehiclecode);
|
instdto.setVehicle_code(vehiclecode);
|
||||||
@@ -581,38 +629,76 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
instdto.setStart_device_code2(start_device_code2);
|
||||||
|
instdto.setStart_point_code2(start_point_code2);
|
||||||
|
instdto.setNext_device_code2(next_device_code2);
|
||||||
|
instdto.setNext_point_code2(next_point_code2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
instructionService.create(instdto);
|
instructionService.create(instdto);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
logServer.deviceExecuteLog(device_code, "", instdto.getInstruction_code(), "指令创建失败,原因->" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
task.setTask_status("1");
|
taskDto.setTask_status("1");
|
||||||
taskserver.update(task);
|
taskDto.setUpdate_time(DateUtil.now());
|
||||||
|
taskserver.update(taskDto);
|
||||||
|
|
||||||
//根据查询的任务起始点位 得出取放工位的电气值 写入后工位电气中
|
//下发电气信号
|
||||||
Device startDevice = deviceAppservice.findDeviceByCode(instdto.getStart_device_code());
|
this.sendSignalType(instdto, type);
|
||||||
Device nextDevice = deviceAppservice.findDeviceByCode(instdto.getNext_device_code());
|
|
||||||
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
|
//请求任务成功
|
||||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
this.setRequireSucess(true);
|
||||||
}
|
|
||||||
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//下发电气信号
|
||||||
|
public void sendSignalType(Instruction dto, String type) {
|
||||||
|
String start_device_code = dto.getStart_device_code();
|
||||||
|
String next_device_code = dto.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 start_addr = startDevice.getExtraValue().get("address").toString();
|
||||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||||
|
if (StrUtil.equals(type, "1")) {
|
||||||
|
this.writing("to_onset1", start_addr);
|
||||||
|
this.writing("to_target1", next_addr);
|
||||||
|
this.writing("to_task1", dto.getInstruction_code());
|
||||||
|
this.writing("to_command1", "1");
|
||||||
|
this.writing("to_type", "1");
|
||||||
|
} else if (StrUtil.equals(type, "2")) {
|
||||||
this.writing("to_onset2", start_addr);
|
this.writing("to_onset2", start_addr);
|
||||||
this.writing("to_target2", next_addr);
|
this.writing("to_target2", next_addr);
|
||||||
this.writing("to_task2", instdto.getInstruction_code());
|
this.writing("to_task2", dto.getInstruction_code());
|
||||||
this.writing("to_command2", "1");
|
this.writing("to_command2", "1");
|
||||||
requireBackSucess = true;
|
this.writing("to_type", "2");
|
||||||
|
} else if (StrUtil.equals(type, "3")) {
|
||||||
|
String start_device_code2 = dto.getStart_device_code2();
|
||||||
|
String next_device_code2 = dto.getNext_device_code2();
|
||||||
|
Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2);
|
||||||
|
Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2);
|
||||||
|
String start_addr2 = startDevice2.getExtraValue().get("address").toString();
|
||||||
|
String next_addr2 = nextDevice2.getExtraValue().get("address").toString();
|
||||||
|
this.writing("to_onset1", start_addr);
|
||||||
|
this.writing("to_target1", next_addr);
|
||||||
|
this.writing("to_task1", dto.getInstruction_code());
|
||||||
|
this.writing("to_command1", "1");
|
||||||
|
this.writing("to_onset2", start_addr2);
|
||||||
|
this.writing("to_target2", next_addr2);
|
||||||
|
this.writing("to_task2", dto.getInstruction_code());
|
||||||
|
this.writing("to_command2", "1");
|
||||||
|
this.writing("to_type", "3");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//判断点位是否设置电气值
|
||||||
|
public void isSetAddress(Device device) {
|
||||||
|
if (ObjectUtil.isEmpty(device.getExtraValue().get("address"))) {
|
||||||
|
logServer.deviceExecuteLog(device_code, "", "task1:" + task1 + ",task2:" + task2, "设备:" + device.getDevice_code() + "未设置电气调度号!");
|
||||||
|
throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean exe_error() {
|
public boolean exe_error() {
|
||||||
if (this.error == 0) {
|
if (this.error == 0) {
|
||||||
@@ -624,7 +710,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writing(String param, String value) {
|
public void writing(String param, String value) {
|
||||||
|
|
||||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
+ "." + param;
|
+ "." + param;
|
||||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ public interface TaskService {
|
|||||||
*/
|
*/
|
||||||
List<TaskDto> queryTaskByDeviceCode(String device_code);
|
List<TaskDto> queryTaskByDeviceCode(String device_code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备号查询未执行的任务
|
||||||
|
*/
|
||||||
|
List<TaskDto> queryTaskByStartDeviceCode(String start_device_code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备号和任务状态查询
|
* 根据设备号和任务状态查询
|
||||||
* @param device_code
|
* @param device_code
|
||||||
@@ -111,6 +116,20 @@ public interface TaskService {
|
|||||||
*/
|
*/
|
||||||
List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code);
|
List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据前工位取货点查找执行中的任务
|
||||||
|
* @param head_start_device_code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TaskDto> queryTaskByStartAndIntStatus(String head_start_device_code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据后工位取货点查找执行中的任务
|
||||||
|
* @param head_next_device_code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TaskDto> queryTaskByNextAndIntStatus(String head_next_device_code);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据关联编号查询非立刻下发的关联任务
|
* 根据关联编号查询非立刻下发的关联任务
|
||||||
|
|||||||
@@ -273,6 +273,19 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TaskDto> queryTaskByStartDeviceCode(String start_device_code) {
|
||||||
|
List<TaskDto> list = new ArrayList<>();
|
||||||
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
TaskDto task = iterator.next();
|
||||||
|
if ((task.getStart_device_code().equals(start_device_code) || task.getStart_device_code2().equals(start_device_code)) && StrUtil.equals(task.getTask_status(), "0")) {
|
||||||
|
list.add(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
|
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
|
||||||
List<TaskDto> list = new ArrayList<>();
|
List<TaskDto> list = new ArrayList<>();
|
||||||
@@ -289,6 +302,37 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<TaskDto> queryTaskByStartAndIntStatus(String head_start_device_code){
|
||||||
|
List<TaskDto> list = new ArrayList<>();
|
||||||
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
TaskDto task = iterator.next();
|
||||||
|
if ((task.getStart_device_code().equals(head_start_device_code) || task.getStart_device_code2().equals(head_start_device_code)) && StrUtil.equals(task.getTask_status(), "1")) {
|
||||||
|
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||||
|
if (ObjectUtil.isNotEmpty(instruction)){
|
||||||
|
list.add(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TaskDto> queryTaskByNextAndIntStatus(String back_start_device_code){
|
||||||
|
List<TaskDto> list = new ArrayList<>();
|
||||||
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
TaskDto task = iterator.next();
|
||||||
|
if ((task.getStart_device_code().equals(back_start_device_code) || task.getStart_device_code2().equals(back_start_device_code)) && StrUtil.equals(task.getTask_status(), "1")) {
|
||||||
|
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||||
|
if (ObjectUtil.isNotEmpty(instruction)){
|
||||||
|
list.add(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskDto queryTaskByLinkNum(String link_num) {
|
public TaskDto queryTaskByLinkNum(String link_num) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user