更新
This commit is contained in:
@@ -145,7 +145,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
public DeviceDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_device");
|
||||
JSONObject json = wo.query("device_code ='" + code + "'").uniqueResult(0);
|
||||
final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class);
|
||||
final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
dto.setUpdate_by(currentUsername);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_device");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
wo.update(json);
|
||||
}
|
||||
@@ -239,7 +239,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
Iterator<Device> iterator = allDevice.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Device device = iterator.next();
|
||||
if (StrUtil.equals(device.getDevice_code(),device_code)) {
|
||||
if (StrUtil.equals(device.getDevice_code(), device_code)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -920,8 +920,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj);
|
||||
runpointwo.update(updatejson, "device_code = '" + device_code + "'");
|
||||
}
|
||||
}
|
||||
else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setMaterial(material_type);
|
||||
standardInspectSiteDeviceDriver.setBatch(batch);
|
||||
@@ -1130,7 +1129,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
} else {
|
||||
boolean endsWith = json.getString("extra_value").endsWith("]");
|
||||
boolean startsWith = json.getString("extra_value").startsWith("[");
|
||||
if (endsWith && startsWith){
|
||||
if (endsWith && startsWith) {
|
||||
JSONArray extraValue = JSONArray.parseArray(json.getString("extra_value"));
|
||||
extraObj.put(json.getString("extra_code"), extraValue);
|
||||
} else {
|
||||
@@ -1143,7 +1142,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
result.put("form", extraObj);
|
||||
|
||||
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
|
||||
String opc_id = dto.getOpc_server_id();
|
||||
@@ -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 r_arry = new JSONArray();
|
||||
//先获取模板
|
||||
if(ObjectUtil.isNotEmpty(opcDeviceDriverDefination)){
|
||||
if (ObjectUtil.isNotEmpty(opcDeviceDriverDefination)) {
|
||||
List<ItemDto> readableItemDtos = opcDeviceDriverDefination.getReadableItemDtos();
|
||||
List<JSONObject> readableItemJsons = new ArrayList<>();
|
||||
for (int i = 0; i < readableItemDtos.size(); i++) {
|
||||
ItemDto itemDto = readableItemDtos.get(i);
|
||||
JSONObject readableItemJson = new JSONObject();
|
||||
readableItemJson.put("code",itemDto.getCode());
|
||||
readableItemJson.put("name",itemDto.getName());
|
||||
readableItemJson.put("code", itemDto.getCode());
|
||||
readableItemJson.put("name", itemDto.getName());
|
||||
// readableItemJson.put("db",itemDto.getDb());
|
||||
readableItemJsons.add(readableItemJson);
|
||||
}
|
||||
@@ -1192,7 +1191,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
String code = split[split.length - 1];
|
||||
robj.put("code", code);
|
||||
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("db", rs.getJSONObject(i).getString("extra_name"));
|
||||
r_arry.add(robj);
|
||||
@@ -1206,16 +1205,16 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
code = split[split.length - 1];
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", code);
|
||||
jsonObject.put("name",rJson.getString("name"));
|
||||
jsonObject.put("name", rJson.getString("name"));
|
||||
rarry.add(jsonObject);
|
||||
}
|
||||
for (int i = 0; i < readableItemDtos.size(); i++) {
|
||||
ItemDto itemDto = readableItemDtos.get(i);
|
||||
JSONObject readableItemJson = new JSONObject();
|
||||
readableItemJson.put("code",itemDto.getCode());
|
||||
readableItemJson.put("name",itemDto.getName());
|
||||
if (!rarry.contains(readableItemJson)){
|
||||
readableItemJson.put("db",itemDto.getDb());
|
||||
readableItemJson.put("code", itemDto.getCode());
|
||||
readableItemJson.put("name", itemDto.getName());
|
||||
if (!rarry.contains(readableItemJson)) {
|
||||
readableItemJson.put("db", itemDto.getDb());
|
||||
r_arry.add(readableItemJson);
|
||||
}
|
||||
}
|
||||
@@ -1226,8 +1225,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
for (int i = 0; i < writeableItemDtos.size(); i++) {
|
||||
ItemDto itemDto = writeableItemDtos.get(i);
|
||||
JSONObject writeableItemJson = new JSONObject();
|
||||
writeableItemJson.put("code",itemDto.getCode());
|
||||
writeableItemJson.put("name",itemDto.getName());
|
||||
writeableItemJson.put("code", itemDto.getCode());
|
||||
writeableItemJson.put("name", itemDto.getName());
|
||||
//writeableItemJson.put("db",itemDto.getDb());
|
||||
writeableItemJsons.add(writeableItemJson);
|
||||
}
|
||||
@@ -1238,7 +1237,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
JSONObject robj = new JSONObject();
|
||||
robj.put("code", code);
|
||||
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("db", ws.getJSONObject(i).getString("extra_name"));
|
||||
w_arry.add(robj);
|
||||
@@ -1251,17 +1250,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
String[] split = code.split("\\.");
|
||||
code = split[split.length - 1];
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code",code);
|
||||
jsonObject.put("name",wJson.getString("name"));
|
||||
jsonObject.put("code", code);
|
||||
jsonObject.put("name", wJson.getString("name"));
|
||||
warry.add(jsonObject);
|
||||
}
|
||||
for (int i = 0; i < writeableItemDtos.size(); i++) {
|
||||
ItemDto itemDto = writeableItemDtos.get(i);
|
||||
JSONObject writeableItemJson = new JSONObject();
|
||||
writeableItemJson.put("code",itemDto.getCode());
|
||||
writeableItemJson.put("name",itemDto.getName());
|
||||
if (!warry.contains(writeableItemJson)){
|
||||
writeableItemJson.put("db",itemDto.getDb());
|
||||
writeableItemJson.put("code", itemDto.getCode());
|
||||
writeableItemJson.put("name", itemDto.getName());
|
||||
if (!warry.contains(writeableItemJson)) {
|
||||
writeableItemJson.put("db", itemDto.getDb());
|
||||
w_arry.add(writeableItemJson);
|
||||
}
|
||||
}
|
||||
@@ -1582,41 +1581,41 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
JSONArray rss = param.getJSONArray("rs");
|
||||
JSONArray wss = param.getJSONArray("ws");
|
||||
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++) {
|
||||
int dbInterval = db_interval * i;
|
||||
Integer deviceCode = device_code + i;
|
||||
for (int j = 0; j <= rss.size(); j++) {
|
||||
Map<String,Object> map = new ListOrderedMap<>();
|
||||
if (wss.size() > rss.size()){
|
||||
if (j == rss.size()){
|
||||
Map<String, Object> map = new ListOrderedMap<>();
|
||||
if (wss.size() > rss.size()) {
|
||||
if (j == rss.size()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (j == rss.size()){
|
||||
map.put("设备编码","");
|
||||
map.put("读取地址","");
|
||||
map.put("读取意义","");
|
||||
map.put("","");
|
||||
map.put("写入地址","");
|
||||
map.put("写入意义","");
|
||||
if (j == rss.size()) {
|
||||
map.put("设备编码", "");
|
||||
map.put("读取地址", "");
|
||||
map.put("读取意义", "");
|
||||
map.put("", "");
|
||||
map.put("写入地址", "");
|
||||
map.put("写入意义", "");
|
||||
list.add(map);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0 && j ==0){
|
||||
map.put("设备编码","");
|
||||
}else {
|
||||
map.put("设备编码",deviceCode);
|
||||
if (i == 0 && j == 0) {
|
||||
map.put("设备编码", "");
|
||||
} else {
|
||||
map.put("设备编码", deviceCode);
|
||||
}
|
||||
JSONObject rs = rss.getJSONObject(j);
|
||||
String db = rs.getString("db");
|
||||
String name = rs.getString("name");
|
||||
if (i > 0){
|
||||
if (name.equals("心跳")){
|
||||
if (i > 0) {
|
||||
if (name.equals("心跳")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1624,77 +1623,77 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
String startDB = dbs[0];
|
||||
String endDB = dbs[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;
|
||||
db = startDB + "." + endDBFirst + endDBEnd;
|
||||
map.put("读取地址",db);
|
||||
map.put("读取意义",name);
|
||||
Map<String, Object> value = getValue(wss, j, dbInterval,i);
|
||||
map.put("读取地址", db);
|
||||
map.put("读取意义", name);
|
||||
Map<String, Object> value = getValue(wss, j, dbInterval, i);
|
||||
map.putAll(value);
|
||||
list.add(map);
|
||||
System.out.println(map);
|
||||
}
|
||||
if (wss.size() > rss.size()){
|
||||
if (wss.size() > rss.size()) {
|
||||
int s = wss.size() - rss.size();
|
||||
for (int l = 0; l <= s + 1; l++) {
|
||||
Map<String,Object> map = new ListOrderedMap<>();
|
||||
if (l == s + 1){
|
||||
map.put("设备编码","");
|
||||
map.put("读取地址","");
|
||||
map.put("读取意义","");
|
||||
map.put("","");
|
||||
map.put("写入地址","");
|
||||
map.put("写入意义","");
|
||||
Map<String, Object> map = new ListOrderedMap<>();
|
||||
if (l == s + 1) {
|
||||
map.put("设备编码", "");
|
||||
map.put("读取地址", "");
|
||||
map.put("读取意义", "");
|
||||
map.put("", "");
|
||||
map.put("写入地址", "");
|
||||
map.put("写入意义", "");
|
||||
list.add(map);
|
||||
continue;
|
||||
}
|
||||
map.put("设备编码",deviceCode);
|
||||
map.put("读取地址","");
|
||||
map.put("读取意义","");
|
||||
Map<String, Object> value = getValue(wss, rss.size() + l, dbInterval,i);
|
||||
map.put("设备编码", deviceCode);
|
||||
map.put("读取地址", "");
|
||||
map.put("读取意义", "");
|
||||
Map<String, Object> value = getValue(wss, rss.size() + l, dbInterval, i);
|
||||
map.putAll(value);
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if (type.equals("v")){
|
||||
} else if (type.equals("v")) {
|
||||
for (int i = 0; i < numberSize; i++) {
|
||||
int dbInterval = db_interval * i;
|
||||
Integer deviceCode = device_code + i;
|
||||
for (int j = 0; j <= rss.size(); j++) {
|
||||
Map<String,Object> map = new ListOrderedMap<>();
|
||||
if (j == rss.size()){
|
||||
map.put("设备编码","");
|
||||
map.put("读取地址","");
|
||||
map.put("读取意义","");
|
||||
map.put("","");
|
||||
map.put("写入地址","");
|
||||
map.put("写入意义","");
|
||||
Map<String, Object> map = new ListOrderedMap<>();
|
||||
if (j == rss.size()) {
|
||||
map.put("设备编码", "");
|
||||
map.put("读取地址", "");
|
||||
map.put("读取意义", "");
|
||||
map.put("", "");
|
||||
map.put("写入地址", "");
|
||||
map.put("写入意义", "");
|
||||
list.add(map);
|
||||
continue;
|
||||
}
|
||||
if (i == 0 && j ==0){
|
||||
map.put("设备编码","");
|
||||
}else {
|
||||
map.put("设备编码",deviceCode);
|
||||
if (i == 0 && j == 0) {
|
||||
map.put("设备编码", "");
|
||||
} else {
|
||||
map.put("设备编码", deviceCode);
|
||||
}
|
||||
JSONObject rs = rss.getJSONObject(j);
|
||||
String db = rs.getString("db");
|
||||
String name = rs.getString("name");
|
||||
if (i > 0){
|
||||
if (name.equals("心跳")){
|
||||
if (i > 0) {
|
||||
if (name.equals("心跳")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//String[] dbs = db.split("\\.");
|
||||
String startDB = db.substring(0,2);
|
||||
String endDB = db.substring(2,db.length());
|
||||
Integer endDBEnd =Integer.parseInt(endDB) ;
|
||||
String startDB = db.substring(0, 2);
|
||||
String endDB = db.substring(2, db.length());
|
||||
Integer endDBEnd = Integer.parseInt(endDB);
|
||||
endDBEnd = endDBEnd + dbInterval;
|
||||
db = startDB + endDBEnd + "";
|
||||
map.put("读取地址",db);
|
||||
map.put("读取意义",name);
|
||||
Map<String, Object> value = getValue1(wss, j, dbInterval,i);
|
||||
map.put("读取地址", db);
|
||||
map.put("读取意义", name);
|
||||
Map<String, Object> value = getValue1(wss, j, dbInterval, i);
|
||||
map.putAll(value);
|
||||
list.add(map);
|
||||
System.out.println(map);
|
||||
@@ -1706,17 +1705,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
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();
|
||||
Map<String,Object> map = new ListOrderedMap<>();
|
||||
if (i == 0 && j == 0){
|
||||
map.put("","");
|
||||
map.put("写入地址","");
|
||||
map.put("写入意义","");
|
||||
Map<String, Object> map = new ListOrderedMap<>();
|
||||
if (i == 0 && j == 0) {
|
||||
map.put("", "");
|
||||
map.put("写入地址", "");
|
||||
map.put("写入意义", "");
|
||||
return map;
|
||||
}
|
||||
if (i == 0 && j > 0){
|
||||
if (j - 1 < size){
|
||||
if (i == 0 && j > 0) {
|
||||
if (j - 1 < size) {
|
||||
JSONObject ws = wss.getJSONObject(j - 1);
|
||||
String db = ws.getString("db");
|
||||
String name = ws.getString("name");
|
||||
@@ -1724,19 +1723,19 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
String startDB = dbs[0];
|
||||
String endDB = dbs[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;
|
||||
db = startDB + "." + endDBFirst + endDBEnd;
|
||||
map.put("","");
|
||||
map.put("写入地址",db);
|
||||
map.put("写入意义",name);
|
||||
map.put("", "");
|
||||
map.put("写入地址", db);
|
||||
map.put("写入意义", name);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
if ( i > 0){
|
||||
j = j -1;
|
||||
if (i > 0) {
|
||||
j = j - 1;
|
||||
}
|
||||
if (j < size){
|
||||
if (j < size) {
|
||||
JSONObject ws = wss.getJSONObject(j);
|
||||
String db = ws.getString("db");
|
||||
String name = ws.getString("name");
|
||||
@@ -1744,17 +1743,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
String startDB = dbs[0];
|
||||
String endDB = dbs[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;
|
||||
db = startDB + "." + endDBFirst + endDBEnd;
|
||||
map.put("","");
|
||||
map.put("写入地址",db);
|
||||
map.put("写入意义",name);
|
||||
map.put("", "");
|
||||
map.put("写入地址", db);
|
||||
map.put("写入意义", name);
|
||||
return map;
|
||||
} else {
|
||||
map.put("","");
|
||||
map.put("写入地址","");
|
||||
map.put("写入意义","");
|
||||
map.put("", "");
|
||||
map.put("写入地址", "");
|
||||
map.put("写入意义", "");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -1873,67 +1872,92 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List list = read.get(i);
|
||||
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_code", list.get(0).toString());
|
||||
param.put("device_name", list.get(0).toString());
|
||||
param.put("device_type", "conveyor");
|
||||
param.put("is_config", "FALSE");
|
||||
param.put("is_route", "FALSE");
|
||||
param.put("device_code", device_code);
|
||||
param.put("device_name", device_name);
|
||||
param.put("device_type", device_type);
|
||||
param.put("is_config", is_config);
|
||||
param.put("is_route", is_route);
|
||||
param.put("create_by", nickName);
|
||||
param.put("create_time", now);
|
||||
param.put("update_by", nickName);
|
||||
param.put("update_time", now);
|
||||
|
||||
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();
|
||||
Map<String,Object> map = new ListOrderedMap<>();
|
||||
if (i == 0 && j == 0){
|
||||
map.put("","");
|
||||
map.put("写入地址","");
|
||||
map.put("写入意义","");
|
||||
Map<String, Object> map = new ListOrderedMap<>();
|
||||
if (i == 0 && j == 0) {
|
||||
map.put("", "");
|
||||
map.put("写入地址", "");
|
||||
map.put("写入意义", "");
|
||||
return map;
|
||||
}
|
||||
if (i == 0 && j > 0){
|
||||
if (j - 1 < size){
|
||||
if (i == 0 && j > 0) {
|
||||
if (j - 1 < size) {
|
||||
JSONObject ws = wss.getJSONObject(j - 1);
|
||||
String db = ws.getString("db");
|
||||
String name = ws.getString("name");
|
||||
//String[] dbs = db.split("\\.");
|
||||
String startDB = db.substring(0, 2);
|
||||
String endDB = db.substring(2,db.length());
|
||||
Integer endDBEnd =Integer.parseInt(endDB) ;
|
||||
String endDB = db.substring(2, db.length());
|
||||
Integer endDBEnd = Integer.parseInt(endDB);
|
||||
endDBEnd = endDBEnd + dbInterval;
|
||||
db = startDB + endDBEnd + "";
|
||||
map.put("","");
|
||||
map.put("写入地址",db);
|
||||
map.put("写入意义",name);
|
||||
map.put("", "");
|
||||
map.put("写入地址", db);
|
||||
map.put("写入意义", name);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
if ( i > 0){
|
||||
j = j -1;
|
||||
if (i > 0) {
|
||||
j = j - 1;
|
||||
}
|
||||
if (j < size){
|
||||
if (j < size) {
|
||||
JSONObject ws = wss.getJSONObject(j);
|
||||
String db = ws.getString("db");
|
||||
String name = ws.getString("name");
|
||||
String startDB = db.substring(0, 2);
|
||||
String endDB = db.substring(2,db.length());
|
||||
Integer endDBEnd =Integer.parseInt(endDB) ;
|
||||
String endDB = db.substring(2, db.length());
|
||||
Integer endDBEnd = Integer.parseInt(endDB);
|
||||
endDBEnd = endDBEnd + dbInterval;
|
||||
db = startDB + endDBEnd + "";
|
||||
map.put("","");
|
||||
map.put("写入地址",db);
|
||||
map.put("写入意义",name);
|
||||
map.put("", "");
|
||||
map.put("写入地址", db);
|
||||
map.put("写入意义", name);
|
||||
return map;
|
||||
} else {
|
||||
map.put("","");
|
||||
map.put("写入地址","");
|
||||
map.put("写入意义","");
|
||||
map.put("", "");
|
||||
map.put("写入地址", "");
|
||||
map.put("写入意义", "");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public class ItemProtocol {
|
||||
public static String item_walk_y = "walk_y";
|
||||
//报警信号
|
||||
public static String item_error = "error";
|
||||
//任务类型
|
||||
public static String item_type = "type";
|
||||
//前工位任务号
|
||||
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_task2 = "to_task2";
|
||||
//任务类型 1前工位 2后工位 3双工位
|
||||
public static String item_to_type = "to_type";
|
||||
|
||||
|
||||
private SlitTwoManipulatorDeviceDriver driver;
|
||||
@@ -96,6 +100,10 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_walk_y);
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.getOpcIntegerValue(item_type);
|
||||
}
|
||||
|
||||
public int getTask1() {
|
||||
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_walk_y, "行走列", "DB1.B7"));
|
||||
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_task2, "后工位任务号", "DB1.D14"));
|
||||
return list;
|
||||
@@ -161,6 +170,7 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_to_onset2, "后工位下发起始站", "DB2.W12"));
|
||||
list.add(new ItemDto(item_to_target2, "后工位下发目标站", "DB2.W14"));
|
||||
list.add(new ItemDto(item_to_task2, "后工位下发任务号", "DB2.D16"));
|
||||
list.add(new ItemDto(item_to_type, "下发任务类型", "DB2.W20"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
//行走列
|
||||
int walk_y = 0;
|
||||
int last_walk_y = 0;
|
||||
//任务类型
|
||||
int type = 0;
|
||||
int last_type = 0;
|
||||
//前后工位任务号
|
||||
int task1 = 0;
|
||||
int last_task1 = 0;
|
||||
@@ -88,10 +91,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
|
||||
Boolean isonline = true;
|
||||
//后工位申请任务请求标记
|
||||
Boolean requireBackSucess = false;
|
||||
//前工位申请任务请求标记
|
||||
Boolean requireHeadSucess = false;
|
||||
Boolean requireSucess = false;
|
||||
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
@@ -131,17 +132,21 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
action2 = this.itemProtocol.getAction2();
|
||||
walk_y = this.itemProtocol.getWalk_y();
|
||||
error = this.itemProtocol.getError();
|
||||
type = this.itemProtocol.getType();
|
||||
task1 = this.itemProtocol.getTask1();
|
||||
task2 = this.itemProtocol.getTask2();
|
||||
|
||||
if (mode != last_mode) {
|
||||
if (mode == 2) {
|
||||
this.setRequireHeadSucess(false);
|
||||
this.setRequireBackSucess(false);
|
||||
this.setRequireSucess(false);
|
||||
}
|
||||
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(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) {
|
||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(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);
|
||||
}
|
||||
|
||||
//前工位任务就绪->执行
|
||||
if (task1 > 0) {
|
||||
//单任务 前工位任务更新指令状态
|
||||
if (task1 > 0 && type == 1) {
|
||||
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
||||
if (inst1 != null) {
|
||||
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
|
||||
inst1.setInstruction_status("1");
|
||||
instructionService.update(inst1);
|
||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
|
||||
if (!ObjectUtil.isEmpty(taskDto)){
|
||||
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
@@ -196,39 +201,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
array.add(map);
|
||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//前工位放货完成 任务完成
|
||||
if (action1 == 4 && move1 == 0 && task1 > 0) {
|
||||
//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) {
|
||||
//单任务 后工位任务更新指令状态
|
||||
if (task2 > 0 && type == 2) {
|
||||
//inst_message
|
||||
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
||||
if (inst2 != null) {
|
||||
@@ -236,8 +216,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
inst2.setInstruction_status("1");
|
||||
instructionService.update(inst2);
|
||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||
if (!ObjectUtil.isEmpty(taskDto)){
|
||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
|
||||
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());
|
||||
@@ -245,20 +225,46 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
array.add(map);
|
||||
acsToWmsService.feedbackTaskStatusToWms(array);
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
//后工位放货完成 任务完成
|
||||
if (action2 == 4 && move2 == 0 && task2 > 0) {
|
||||
|
||||
//双任务更新指令状态
|
||||
if (task2 > 0 && task1 > 0 && type == 3) {
|
||||
//inst_message
|
||||
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
|
||||
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task1));
|
||||
if (inst2 != null) {
|
||||
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
|
||||
finish_instruction(inst2);
|
||||
if (StrUtil.equals(inst2.getInstruction_status(), "0")) {
|
||||
inst2.setInstruction_status("1");
|
||||
instructionService.update(inst2);
|
||||
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
|
||||
if (!ObjectUtil.isEmpty(taskDto)){
|
||||
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
|
||||
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", "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();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("task_id", taskDto.getExt_task_id());
|
||||
@@ -266,19 +272,88 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
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_command1", "0");
|
||||
this.writing("to_onset1", "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));
|
||||
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);
|
||||
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
|
||||
if (startDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
|
||||
@@ -286,26 +361,21 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
int move = siemensConveyorDeviceDriver.getMove();
|
||||
int mode = siemensConveyorDeviceDriver.getMode();
|
||||
if (mode == 2 && move == 1) {
|
||||
this.writing("to_command1", "2");
|
||||
this.writing("to_command2", "2");
|
||||
} else {
|
||||
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) {
|
||||
this.writing("to_command1", "3");
|
||||
this.writing("to_command2", "3");
|
||||
}
|
||||
|
||||
//前工位允许放货
|
||||
//前工位允许取货
|
||||
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 mode = siemensConveyorDeviceDriver.getMode();
|
||||
if (move == 0 && mode == 2) {
|
||||
this.writing("to_command2", "3");
|
||||
this.writing("to_command1", "3");
|
||||
} else {
|
||||
log.warn("后工位放货位有货,放货位:{},mode:{},move:{}", next_device_code, mode, move);
|
||||
}
|
||||
@@ -348,34 +418,18 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
return;
|
||||
case 2:
|
||||
//后工位申请任务 取空放空
|
||||
//mode == 2 && move2 == 0 && action2 == 0 && !requireBackSucess
|
||||
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) {
|
||||
//申请任务
|
||||
if (mode == 2 && move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -388,231 +442,263 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
last_action1 = action1;
|
||||
last_action2 = action2;
|
||||
last_walk_y = walk_y;
|
||||
last_type = type;
|
||||
last_task1 = task1;
|
||||
last_task2 = task2;
|
||||
}
|
||||
|
||||
//申请前工位任务
|
||||
public synchronized boolean instruction_require() throws Exception {
|
||||
//申请任务
|
||||
public synchronized boolean instruction_require() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time);
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_head_time = date;
|
||||
//后工位取货关联设备
|
||||
//前工位取货关联设备
|
||||
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> putDeviceCodeList = this.getExtraDeviceCodes("back_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);
|
||||
List<String> backGetDeviceCodeList = this.getExtraDeviceCodes("back_get_device_code");
|
||||
TaskDto taskDto = null;
|
||||
//遍历前工位取货点设备
|
||||
for (String getDeviceCode : getDeviceCodeList) {
|
||||
//去任务表中查询是否有前工位关联设备的重新创建指令的任务
|
||||
List<TaskDto> taskDtos = taskserver.queryTaskByStartAndIntStatus(getDeviceCode);
|
||||
//如果有
|
||||
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_onset2", start_addr);
|
||||
this.writing("to_target2", next_addr);
|
||||
this.writing("to_task2", instruction.getInstruction_code());
|
||||
this.writing("to_command2", "1");
|
||||
requireBackSucess = true;
|
||||
taskDto = taskDtos.get(0);
|
||||
this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList);
|
||||
return true;
|
||||
} else {
|
||||
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDtoList)) {
|
||||
task = taskDtoList.get(0);
|
||||
//去任务表中查询是否有前工位关联设备的就绪状态下的任务
|
||||
taskDtos = taskserver.queryTaskByStartDeviceCode(getDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||
taskDto = taskDtos.get(0);
|
||||
break;
|
||||
}
|
||||
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();
|
||||
//如果任务表中起点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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//创建指令后修改任务状态
|
||||
task.setTask_status("1");
|
||||
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_onset2", start_addr);
|
||||
this.writing("to_target2", next_addr);
|
||||
this.writing("to_task2", instdto.getInstruction_code());
|
||||
this.writing("to_command2", "1");
|
||||
requireBackSucess = true;
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(taskDto)) {
|
||||
this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//执行重新生成指令的任务
|
||||
public void executeBusiness(TaskDto taskDto, List<String> getDeviceCodeList, List<String> backGetDeviceCodeList) {
|
||||
//任务类型 1.前工位任务 2.后工位任务 3.双工位任务
|
||||
String type = "";
|
||||
//获取指令信息
|
||||
Instruction instructionDto = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
|
||||
//获取指令表中的取货点1
|
||||
String start_device_code = instructionDto.getStart_device_code();
|
||||
//获取指令表中的取货点2
|
||||
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();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setRemark(remark);
|
||||
instdto.setMaterial(material);
|
||||
instdto.setQuantity(quantity);
|
||||
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);
|
||||
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 {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logServer.deviceExecuteLog(device_code, "", instdto.getInstruction_code(), "指令创建失败,原因->" + e.getMessage());
|
||||
}
|
||||
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status("1");
|
||||
taskDto.setUpdate_time(DateUtil.now());
|
||||
taskserver.update(taskDto);
|
||||
|
||||
//下发电气信号
|
||||
this.sendSignalType(instdto, type);
|
||||
|
||||
//请求任务成功
|
||||
this.setRequireSucess(true);
|
||||
}
|
||||
|
||||
//下发电气信号
|
||||
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 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_target2", next_addr);
|
||||
this.writing("to_task2", dto.getInstruction_code());
|
||||
this.writing("to_command2", "1");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
//判断点位是否设置电气值
|
||||
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() {
|
||||
if (this.error == 0) {
|
||||
@@ -624,7 +710,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
}
|
||||
|
||||
public void writing(String param, String value) {
|
||||
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + param;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
|
||||
@@ -104,6 +104,11 @@ public interface TaskService {
|
||||
*/
|
||||
List<TaskDto> queryTaskByDeviceCode(String device_code);
|
||||
|
||||
/**
|
||||
* 根据设备号查询未执行的任务
|
||||
*/
|
||||
List<TaskDto> queryTaskByStartDeviceCode(String start_device_code);
|
||||
|
||||
/**
|
||||
* 根据设备号和任务状态查询
|
||||
* @param device_code
|
||||
@@ -111,6 +116,20 @@ public interface TaskService {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
@@ -289,6 +302,37 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
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
|
||||
public TaskDto queryTaskByLinkNum(String link_num) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user