|
@ -16,6 +16,9 @@ import org.nl.acs.opc.DeviceAppService; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
|
import java.text.DecimalFormat; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询先工AGV设备状态 |
|
|
* 查询先工AGV设备状态 |
|
|
*/ |
|
|
*/ |
|
@ -54,34 +57,41 @@ public class QueryXZAgvDeviceStatus { |
|
|
Boolean is_error = jo.getBoolean("is_error"); |
|
|
Boolean is_error = jo.getBoolean("is_error"); |
|
|
//执行运单信息
|
|
|
//执行运单信息
|
|
|
JSONObject current_order = jo.getJSONObject("current_order"); |
|
|
JSONObject current_order = jo.getJSONObject("current_order"); |
|
|
|
|
|
Integer connectionStatus = jo.getInteger("connection_status"); |
|
|
String inst_code = current_order.getString("id"); |
|
|
String inst_code = current_order.getString("id"); |
|
|
String task_type = "0"; |
|
|
String task_type = "0"; |
|
|
if (StrUtil.isNotEmpty(inst_code)) { |
|
|
if (StrUtil.isNotEmpty(inst_code)) { |
|
|
Instruction inst = instructionService.findByCodeFromCache(inst_code); |
|
|
Instruction inst = instructionService.findByCodeFromCache(inst_code); |
|
|
if (ObjectUtil.isNotEmpty(inst)){ |
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
//任务类型
|
|
|
//任务类型
|
|
|
task_type = inst.getInstruction_type(); |
|
|
task_type = inst.getInstruction_type(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
DecimalFormat hisFormat = new DecimalFormat("########.###"); |
|
|
|
|
|
hisFormat.setRoundingMode(RoundingMode.DOWN); |
|
|
//x坐标
|
|
|
//x坐标
|
|
|
int x = Double.valueOf(rbk_report.getString("x")).intValue(); |
|
|
float x = rbk_report.getFloatValue("x"); |
|
|
//y坐标
|
|
|
//y坐标
|
|
|
int y = Double.valueOf(rbk_report.getString("y")).intValue(); |
|
|
float y = rbk_report.getFloatValue("y"); |
|
|
String status = "0"; |
|
|
String status = "0"; |
|
|
if (procBusiness) { |
|
|
if (connectionStatus == 0) { |
|
|
//工作中
|
|
|
status = "5"; |
|
|
status = "1"; |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
if (charging) { |
|
|
if (procBusiness) { |
|
|
//充电中
|
|
|
//工作中
|
|
|
status = "2"; |
|
|
status = "1"; |
|
|
} else { |
|
|
} else { |
|
|
if (is_error) { |
|
|
if (charging) { |
|
|
//故障
|
|
|
//充电中
|
|
|
status = "3"; |
|
|
status = "2"; |
|
|
} else { |
|
|
} else { |
|
|
//休息中
|
|
|
if (is_error) { |
|
|
status = "4"; |
|
|
//故障
|
|
|
|
|
|
status = "3"; |
|
|
|
|
|
} else { |
|
|
|
|
|
//休息中
|
|
|
|
|
|
status = "4"; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -91,14 +101,14 @@ public class QueryXZAgvDeviceStatus { |
|
|
maGangAgvDeviceDriver = (MaGangAgvDeviceDriver) device.getDeviceDriver(); |
|
|
maGangAgvDeviceDriver = (MaGangAgvDeviceDriver) device.getDeviceDriver(); |
|
|
String kepStatus = String.valueOf(maGangAgvDeviceDriver.getStatus()); |
|
|
String kepStatus = String.valueOf(maGangAgvDeviceDriver.getStatus()); |
|
|
String kepType = String.valueOf(maGangAgvDeviceDriver.getType()); |
|
|
String kepType = String.valueOf(maGangAgvDeviceDriver.getType()); |
|
|
if (!StrUtil.equals(kepStatus,status)){ |
|
|
if (!StrUtil.equals(kepStatus, status)) { |
|
|
maGangAgvDeviceDriver.writing("status", status); |
|
|
maGangAgvDeviceDriver.writing("status", status); |
|
|
} |
|
|
} |
|
|
if (!StrUtil.equals(kepType,task_type)){ |
|
|
if (!StrUtil.equals(kepType, task_type)) { |
|
|
maGangAgvDeviceDriver.writing("type", task_type); |
|
|
maGangAgvDeviceDriver.writing("type", task_type); |
|
|
} |
|
|
} |
|
|
maGangAgvDeviceDriver.writing("x_coordinate", String.valueOf(x)); |
|
|
maGangAgvDeviceDriver.writing("x_coordinate", hisFormat.format(x) + ""); |
|
|
maGangAgvDeviceDriver.writing("y_coordinate", String.valueOf(y)); |
|
|
maGangAgvDeviceDriver.writing("y_coordinate", hisFormat.format(y) + ""); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -110,32 +120,32 @@ public class QueryXZAgvDeviceStatus { |
|
|
try { |
|
|
try { |
|
|
JSONObject map = new JSONObject(); |
|
|
JSONObject map = new JSONObject(); |
|
|
JSONArray blocks = new JSONArray(); |
|
|
JSONArray blocks = new JSONArray(); |
|
|
map.put("blockGroup",blocks); |
|
|
map.put("blockGroup", blocks); |
|
|
JSONArray jsonArray = agvService.blockGroupStatus(map); |
|
|
JSONArray jsonArray = agvService.blockGroupStatus(map); |
|
|
if (ObjectUtil.isNotEmpty(jsonArray)){ |
|
|
if (ObjectUtil.isNotEmpty(jsonArray)) { |
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i); |
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i); |
|
|
Boolean status = jsonObject.getBoolean("status"); |
|
|
Boolean status = jsonObject.getBoolean("status"); |
|
|
if (status){ |
|
|
if (status) { |
|
|
String name = jsonObject.getString("name"); |
|
|
String name = jsonObject.getString("name"); |
|
|
Device device = deviceAppService.findDeviceByCode(name); |
|
|
Device device = deviceAppService.findDeviceByCode(name); |
|
|
MaGangLedDeviceDriver maGangLedDeviceDriver; |
|
|
MaGangLedDeviceDriver maGangLedDeviceDriver; |
|
|
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver){ |
|
|
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver) { |
|
|
maGangLedDeviceDriver = (MaGangLedDeviceDriver) device.getDeviceDriver(); |
|
|
maGangLedDeviceDriver = (MaGangLedDeviceDriver) device.getDeviceDriver(); |
|
|
maGangLedDeviceDriver.writing("D01","1"); |
|
|
maGangLedDeviceDriver.writing("D01", "1"); |
|
|
} |
|
|
} |
|
|
}else { |
|
|
} else { |
|
|
String name = jsonObject.getString("name"); |
|
|
String name = jsonObject.getString("name"); |
|
|
Device device = deviceAppService.findDeviceByCode(name); |
|
|
Device device = deviceAppService.findDeviceByCode(name); |
|
|
MaGangLedDeviceDriver maGangLedDeviceDriver; |
|
|
MaGangLedDeviceDriver maGangLedDeviceDriver; |
|
|
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver){ |
|
|
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver) { |
|
|
maGangLedDeviceDriver = (MaGangLedDeviceDriver) device.getDeviceDriver(); |
|
|
maGangLedDeviceDriver = (MaGangLedDeviceDriver) device.getDeviceDriver(); |
|
|
maGangLedDeviceDriver.writing("D01","0"); |
|
|
maGangLedDeviceDriver.writing("D01", "0"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}catch (Exception e){ |
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|