Merge branch 'master' of http://121.40.234.130:8899/root/hl_one
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package org.nl.wms.ext.bigScreen.autoTask;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AutoAgvStatus {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
public void run() {
|
||||
|
||||
WQLObject agv_status = WQLObject.getWQLObject("DS_AGV_AgvStatus");
|
||||
WQLObject agv_point = WQLObject.getWQLObject("DS_AGV_PointCoordinateRelate");
|
||||
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
String device_code = String.valueOf(i);
|
||||
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("device_code").is(device_code));
|
||||
List<JSONObject> avg_all = mongoTemplate.find(query, JSONObject.class, "agv_test");
|
||||
|
||||
JSONObject jsonAgv = agv_status.query("agv_code = '" + device_code + "'").uniqueResult(0);
|
||||
String real_x_coor = "";
|
||||
String real_y_coor = "";
|
||||
for (JSONObject json : avg_all) {
|
||||
String key = json.getString("key");
|
||||
|
||||
switch (key) {
|
||||
case "pic_name" :
|
||||
jsonAgv.put("pic_name",json.getString("value"));
|
||||
break;
|
||||
case "agv_power" :
|
||||
jsonAgv.put("agv_power",json.getString("value"));
|
||||
break;
|
||||
case "agv_stateType" :
|
||||
jsonAgv.put("agv_statetype",json.getString("value"));
|
||||
break;
|
||||
case "x_coordinate" :
|
||||
String value = NumberUtil.div(json.getString("value"), "100").toString();
|
||||
real_x_coor = NumberUtil.round(value, 0).toString();
|
||||
break;
|
||||
case "y_coordinate" :
|
||||
String value2 = NumberUtil.div(json.getString("value"), "100").toString();
|
||||
real_y_coor = NumberUtil.round(value2, 0).toString();
|
||||
break;
|
||||
case "error_status" :
|
||||
jsonAgv.put("error_status",json.getString("value"));
|
||||
break;
|
||||
case "error_info" :
|
||||
jsonAgv.put("error_info",json.getString("value"));
|
||||
break;
|
||||
case "direction_type" :
|
||||
jsonAgv.put("direction_type",json.getString("value"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
JSONObject jsonPoint = agv_point.query("real_x_coor = '" + real_x_coor + "' and real_y_coor = '" + real_y_coor + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonPoint)) {
|
||||
jsonAgv.put("x_coordinate", jsonPoint.getString("web_x_coor"));
|
||||
jsonAgv.put("y_coordinate", jsonPoint.getString("web_y_coor"));
|
||||
}
|
||||
jsonAgv.put("update_datetime", DateUtil.now());
|
||||
agv_status.update(jsonAgv);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
ArrayList<Integer> objects = new ArrayList<>();
|
||||
objects.add(null);
|
||||
LinkedList<Object> objects1 = new LinkedList<>();
|
||||
objects1.add(4);
|
||||
objects1.add(4.4);
|
||||
objects1.add(null);
|
||||
|
||||
ArrayDeque<Object> objects2 = new ArrayDeque<>();
|
||||
System.out.println(objects1);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.ext.bigScreen.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mongodb.MongoClient;
|
||||
@@ -14,6 +15,7 @@ import org.nl.wql.core.bean.WQLObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@@ -33,7 +35,7 @@ public class AgvBigScreenServiceImpl implements AgvBigScreenService {
|
||||
map.put("today", "%"+today+"%");
|
||||
JSONObject jsonAll = WQL.getWO("AGVBIGSCREEN01").addParamMap(map).process().uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonAll)) {
|
||||
param.put("all_task_number",jsonAll.getString("jsonAllTsk"));
|
||||
param.put("all_task_number",jsonAll.getString("all_task_number"));
|
||||
} else {
|
||||
param.put("all_task_number","0");
|
||||
}
|
||||
@@ -77,38 +79,53 @@ public class AgvBigScreenServiceImpl implements AgvBigScreenService {
|
||||
|
||||
@Override
|
||||
public JSONObject getAgvMsg(JSONObject whereJson) {
|
||||
|
||||
// 连接到 mongodb 服务并连接到数据库
|
||||
MongoClient mongoClient = new MongoClient( "47.111.78.178" , 27017 );
|
||||
MongoDatabase db = mongoClient.getDatabase("device_log");
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject agvTab = WQLObject.getWQLObject("DS_AGV_AgvStatus");
|
||||
try {
|
||||
WQLObject agvTab = WQLObject.getWQLObject("DS_AGV_AgvStatus");
|
||||
JSONObject srb = new JSONObject();
|
||||
JSONArray errorArr = new JSONArray();
|
||||
|
||||
JSONArray agv_info = new JSONArray();
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
JSONObject json = new JSONObject();
|
||||
String agv_code = String.valueOf(i);
|
||||
JSONObject jsonAgv = agvTab.query("agv_code = '" + agv_code + "'").uniqueResult(0);
|
||||
// 1.车号
|
||||
json.put("agv_code", agv_code);
|
||||
// 2.任务: 0为无任务、1为有任务
|
||||
json.put("agv_stateType", jsonAgv.getString("agv_stateType"));
|
||||
// 3.电量
|
||||
json.put("agv_power", jsonAgv.getString("agv_power"));
|
||||
// 4.预警: 0为正常,1为报警
|
||||
|
||||
// 5.预警信息
|
||||
JSONArray agv_info = new JSONArray();
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
JSONObject json = new JSONObject();
|
||||
String agv_code = String.valueOf(i);
|
||||
JSONObject jsonAgv = agvTab.query("agv_code = '" + agv_code + "'").uniqueResult(0);
|
||||
// 1.车号
|
||||
json.put("agv_code", agv_code);
|
||||
// 2.任务: 0为无任务、1为有任务
|
||||
json.put("agv_statetype", jsonAgv.getString("agv_statetype"));
|
||||
// 3.电量
|
||||
json.put("agv_power", jsonAgv.getString("agv_power"));
|
||||
// 4.预警: 0为正常,1为报警
|
||||
String error_status = jsonAgv.getString("error_status");
|
||||
if (StrUtil.equals(error_status,"1")) {
|
||||
// 只要有一辆车有报警信息 状态则为1
|
||||
srb.put("error_status", "1");
|
||||
// 5.预警信息
|
||||
errorArr.add(jsonAgv.getString("error_info"));
|
||||
}
|
||||
// 6.agv名称
|
||||
json.put("agv_name", jsonAgv.getString("agv_name"));
|
||||
// 7.x坐标
|
||||
json.put("x_coordinate", jsonAgv.getString("x_coordinate"));
|
||||
// 8.y坐标
|
||||
json.put("y_coordinate", jsonAgv.getString("y_coordinate"));
|
||||
// 9.方向类型
|
||||
json.put("direction_type", jsonAgv.getString("direction_type"));
|
||||
|
||||
agv_info.add(json);
|
||||
agv_info.add(json);
|
||||
}
|
||||
srb.put("agv_info_arr", agv_info);
|
||||
srb.put("agv_error_arr", errorArr);
|
||||
|
||||
result.put("srb", srb);
|
||||
result.put("code", "1");
|
||||
result.put("desc", "查询成功");
|
||||
} catch (Exception e) {
|
||||
result.put("code", "0");
|
||||
result.put("desc", "查询失败:"+e.getMessage());
|
||||
}
|
||||
|
||||
result.put("agv_info_arr", agv_info);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
count(task.task_id) AS cancel_task_number
|
||||
count(task.task_id) AS not_finish_task_number
|
||||
FROM
|
||||
SCH_BASE_Task task
|
||||
WHERE
|
||||
|
||||
@@ -757,9 +757,10 @@ public class AgvServiceImpl implements AgvService {
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
};
|
||||
log.info("下发删除AGV指令--{}", Bytes2HexString(b));
|
||||
|
||||
NDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发删除agv指令数据:" + Bytes2HexString(b));
|
||||
if (ObjectUtil.isNotEmpty(b)){
|
||||
NDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发删除agv指令数据:" + Bytes2HexString(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,20 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
int weight = 0;
|
||||
String device_code = "";
|
||||
int phase = 0;
|
||||
|
||||
int x = 0; //x坐标
|
||||
int y = 0; //y坐标
|
||||
int angle = 0; //角度
|
||||
int electric_qty = 0; //电量
|
||||
int status = 0; //三色灯状态
|
||||
int error = 0; //车辆故障
|
||||
|
||||
int last_x = 0;
|
||||
int last_y = 0;
|
||||
int last_angle = 0;
|
||||
int last_electric_qty = 0;
|
||||
int last_status = 0;
|
||||
int last_error = 0;
|
||||
public synchronized void processSocket(int[] arr) throws Exception {
|
||||
device_code = this.getDeviceCode();
|
||||
byte[] data = null;
|
||||
@@ -423,6 +437,36 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
}
|
||||
logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data);
|
||||
|
||||
} else if (phase == 0x71){
|
||||
x = ikey;
|
||||
if (x != last_x){
|
||||
logServer.deviceLog(this.device_code, "x", String.valueOf(x));
|
||||
}
|
||||
} else if (phase == 0x72){
|
||||
y = ikey;
|
||||
if (y != last_y){
|
||||
logServer.deviceLog(this.device_code, "y", String.valueOf(y));
|
||||
}
|
||||
} else if (phase == 0x73){
|
||||
angle = last_angle;
|
||||
if (angle != last_angle){
|
||||
logServer.deviceLog(this.device_code, "angle", String.valueOf(angle));
|
||||
}
|
||||
} else if (phase == 0x74){
|
||||
electric_qty = ikey;
|
||||
if (electric_qty != last_electric_qty){
|
||||
logServer.deviceLog(this.device_code, "electric_qty", String.valueOf(electric_qty));
|
||||
}
|
||||
} else if (phase == 0x75){
|
||||
status = ikey;
|
||||
if (status != last_status){
|
||||
logServer.deviceLog(this.device_code, "status", String.valueOf(status));
|
||||
}
|
||||
} else if (phase == 0x76){
|
||||
error = ikey;
|
||||
if (error != last_error){
|
||||
logServer.deviceLog(this.device_code, "error", String.valueOf(error));
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data);
|
||||
|
||||
@@ -55,7 +55,19 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
String device_code = "";
|
||||
int phase = 0;
|
||||
|
||||
int x = 0; //x坐标
|
||||
int y = 0; //y坐标
|
||||
int angle = 0; //角度
|
||||
int electric_qty = 0; //电量
|
||||
int status = 0; //三色灯状态
|
||||
int error = 0; //车辆故障
|
||||
|
||||
int last_x = 0;
|
||||
int last_y = 0;
|
||||
int last_angle = 0;
|
||||
int last_electric_qty = 0;
|
||||
int last_status = 0;
|
||||
int last_error = 0;
|
||||
public synchronized void processSocket(int[] arr) throws Exception {
|
||||
device_code = this.getDeviceCode();
|
||||
logServer.deviceLogToacs(this.device_code,"","","接收AGV上报信息:" + arr);
|
||||
@@ -686,6 +698,36 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
data = AgvService.sendAgvTwoModeInst(143, index, 0);
|
||||
logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data);
|
||||
|
||||
} else if (phase == 0x71){
|
||||
x = ikey;
|
||||
if (x != last_x){
|
||||
logServer.deviceLog(this.device_code, "x", String.valueOf(x));
|
||||
}
|
||||
} else if (phase == 0x72){
|
||||
y = ikey;
|
||||
if (y != last_y){
|
||||
logServer.deviceLog(this.device_code, "y", String.valueOf(y));
|
||||
}
|
||||
} else if (phase == 0x73){
|
||||
angle = last_angle;
|
||||
if (angle != last_angle){
|
||||
logServer.deviceLog(this.device_code, "angle", String.valueOf(angle));
|
||||
}
|
||||
} else if (phase == 0x74){
|
||||
electric_qty = ikey;
|
||||
if (electric_qty != last_electric_qty){
|
||||
logServer.deviceLog(this.device_code, "electric_qty", String.valueOf(electric_qty));
|
||||
}
|
||||
} else if (phase == 0x75){
|
||||
status = ikey;
|
||||
if (status != last_status){
|
||||
logServer.deviceLog(this.device_code, "status", String.valueOf(status));
|
||||
}
|
||||
} else if (phase == 0x76){
|
||||
error = ikey;
|
||||
if (error != last_error){
|
||||
logServer.deviceLog(this.device_code, "error", String.valueOf(error));
|
||||
}
|
||||
}
|
||||
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
|
||||
@@ -191,7 +191,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceLog(this.device_code, "packer_ready", String.valueOf(packer_ready));
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号packer_ready:" + last_packer_ready + "->" + packer_ready);
|
||||
}
|
||||
if (lack_req != last_lack_req) {
|
||||
if (lack_req != last_lack_req) {
|
||||
if (lack_req == 0) {
|
||||
this.setRequireSucess(false);
|
||||
}
|
||||
@@ -228,14 +228,14 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号order_now:" + last_order_now + "->" + order_now);
|
||||
}
|
||||
|
||||
if (open_ready_time != last_open_ready_time) {
|
||||
/* if (open_ready_time != last_open_ready_time) {
|
||||
logServer.deviceLog(this.device_code, "open_ready_time", String.valueOf(open_ready_time));
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号open_ready_time:" + last_open_ready_time + "->" + open_ready_time);
|
||||
}
|
||||
if (device_running_time != last_device_running_time) {
|
||||
}*/
|
||||
/* if (device_running_time != last_device_running_time) {
|
||||
logServer.deviceLog(this.device_code, "device_running_time", String.valueOf(device_running_time));
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号device_running_time:" + last_device_running_time + "->" + device_running_time);
|
||||
}
|
||||
}*/
|
||||
if (await_time != last_await_time) {
|
||||
logServer.deviceLog(this.device_code, "await_time", String.valueOf(await_time));
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号await_time:" + last_await_time + "->" + await_time);
|
||||
|
||||
Reference in New Issue
Block a user