opt:修改车辆首页信息,车辆信息,故障信息。

This commit is contained in:
2023-09-25 19:25:13 +08:00
parent 17f2e105fa
commit 6a6aeb1702
6 changed files with 351 additions and 311 deletions

View File

@@ -17,9 +17,16 @@ public enum VehicleOperateEnum{
OFF("关机", "1"),
SCREEN("显示屏控制", "2"),
TCS("TCS控制", "3"),
RC("RC控制", "4"),
JOY("Joy控制", "5"),
OTHER("其他", "6");
SCHE("SCHE控制", "4"),
RC("RC控制", "5"),
JOY("Joy控制", "6"),
QUITNOW("退出", "7"),
REBORNINIT("软启动", "8"),
STARTCHECK("跳过起点", "9"),
REBOOT("重启", "10"),
FULL("全屏", "11"),
SKIPPLATE("跳过检测", "12"),
OTHER("其他", "13");
private final String name;
private final String code;

View File

@@ -1,6 +1,5 @@
package org.nl.agv.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -27,85 +26,89 @@ import java.util.Map;
@RequestMapping("/api/vehicle")
@Slf4j
@SaIgnore
public class VehicleInfoController {
private final VehicleInfoService vehicleInfoService;
@PostMapping("/queryRestPoint")
@Log("车辆信息查询初始化坐标")
@ApiOperation("车辆信息查询初始化坐标")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> getIP(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryRestPoint(whereJson), HttpStatus.OK);
}
public class VehicleInfoController{
private final VehicleInfoService vehicleInfoService;
@PostMapping("/restCoordinate")
@Log("初始化坐标确定")
@ApiOperation("初始化坐标确定")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> restCoordinate(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.restCoordinate(whereJson), HttpStatus.OK);
}
@PostMapping("/Shut_down")
@Log("关机")
@ApiOperation("关机")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Shut_down(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.Shut_down(whereJson), HttpStatus.OK);
}
@PostMapping("/queryRestPoint")
@Log("车辆信息查询初始化坐标")
@ApiOperation("车辆信息查询初始化坐标")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> getIP(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryRestPoint(whereJson), HttpStatus.OK);
}
@PostMapping("/queryControlStatus")
@Log("查询车辆控制按钮状态")
@ApiOperation("查询车辆控制按钮状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryControlStatus(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryControlStatus(whereJson), HttpStatus.OK);
}
@PostMapping("/restCoordinate")
@Log("初始化坐标确定")
@ApiOperation("初始化坐标确定")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> restCoordinate(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.restCoordinate(whereJson), HttpStatus.OK);
}
@PostMapping("/Shut_down")
@Log("关机")
@ApiOperation("关机")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Shut_down(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.Shut_down(whereJson), HttpStatus.OK);
}
@PostMapping("/queryControlStatus")
@Log("查询车辆控制按钮状态")
@ApiOperation("查询车辆控制按钮状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryControlStatus(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryControlStatus(whereJson), HttpStatus.OK);
}
// @PostMapping("/skipStartPoint")
// @Log("跳过起点")
// @ApiOperation("跳过起点")
// //@PreAuthorize("@el.check('sect:list')")
// public ResponseEntity<Object> skipStartPoint(@RequestBody Map<String,String> whereJson) {
// return new ResponseEntity<>(vehicleInfoService.skipStartPoint(whereJson), HttpStatus.OK);
// }
// @PostMapping("/softStart")
// @Log("软启动")
// @ApiOperation("软启动")
// //@PreAuthorize("@el.check('sect:list')")
// public ResponseEntity<Object> softStart(@RequestBody Map<String,String> whereJson) {
// return new ResponseEntity<>(vehicleInfoService.softStart(whereJson), HttpStatus.OK);
// }
// @PostMapping("/quitNow")
// @Log("退出")
// @ApiOperation("退出")
// //@PreAuthorize("@el.check('sect:list')")
// public ResponseEntity<Object> quitNow(@RequestBody Map<String,String> whereJson) {
// return new ResponseEntity<>(vehicleInfoService.quitNow(whereJson), HttpStatus.OK);
// }
@PostMapping("/queryVehicleStatus")
@Log("查询车辆状态")
@ApiOperation("查询车辆状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryVehicleStatus(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryVehicleStatus(whereJson), HttpStatus.OK);
}
@PostMapping("/querrySensor")
@Log("查询传感器状态")
@ApiOperation("查询传感器状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> querrySensor(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.querrySensor(whereJson), HttpStatus.OK);
}
@PostMapping("/queryAgv_Status")
@Log("查询agv状态")
@ApiOperation("查询agv状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryAgv_Status(@RequestBody Map<String,String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryAgv_Status(whereJson), HttpStatus.OK);
}
@PostMapping("/skipStartPoint")
@Log("跳过起点")
@ApiOperation("跳过起点")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> skipStartPoint(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.skipStartPoint(whereJson), HttpStatus.OK);
}
@PostMapping("/softStart")
@Log("软启动")
@ApiOperation("软启动")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> softStart(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.softStart(whereJson), HttpStatus.OK);
}
@PostMapping("/quitNow")
@Log("退出")
@ApiOperation("退出")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> quitNow(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.quitNow(whereJson), HttpStatus.OK);
}
@PostMapping("/queryVehicleStatus")
@Log("查询车辆状态")
@ApiOperation("查询车辆状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryVehicleStatus(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryVehicleStatus(whereJson), HttpStatus.OK);
}
@PostMapping("/querrySensor")
@Log("查询传感器状态")
@ApiOperation("查询传感器状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> querrySensor(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.querrySensor(whereJson), HttpStatus.OK);
}
@PostMapping("/queryAgv_Status")
@Log("查询agv状态")
@ApiOperation("查询agv状态")
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryAgv_Status(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(vehicleInfoService.queryAgv_Status(whereJson), HttpStatus.OK);
}
}

View File

@@ -25,12 +25,17 @@ import jline.internal.Log;
import lombok.RequiredArgsConstructor;
import com.alibaba.fastjson.JSONObject;
import org.nl.agv.service.ErrorService;
import org.nl.agv.unit.sendToAgvUtil;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author zhanghouying
@@ -39,8 +44,44 @@ import java.util.Map;
@Service
@RequiredArgsConstructor
public class ErrorServiceImpl implements ErrorService{
@Override
public Map<String,Object> querryError(Map<String,String> jsonObject) {
String error_status = "无故障";
try {
List<String> errorCodeList = new ArrayList<>();
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
int Warning_Code = debugInfoJson.getInteger("Warning_Code");
Warning_Code = 754529;
JSONArray result = new JSONArray();
for (int bitPosition = 0; bitPosition < 28; bitPosition++) {
if ((Warning_Code >> bitPosition) % 2 == 1) {
error_status = "有故障";
String error_code = "bit" + bitPosition;
errorCodeList.add(error_code);
}
}
WQLObject wo = WQLObject.getWQLObject("st_agv_error");
String errorCodes = errorCodeList.stream().collect(Collectors.joining("', '", "'", "'"));
result = wo.query("error_code in ("+errorCodes+") order by error_code").getResultJSONArray(0);
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("desc", "查询成功");
returnjo.put("result", result);
returnjo.put("error_status", error_status);
return returnjo;
}
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "通信失败请检查系统参数中的Ros连接信息" : e.getMessage());
}
}
//@Override
public Map<String,Object> querryError1(Map<String,String> jsonObject) {
String error_status = "无故障";
try {
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
@@ -53,87 +94,55 @@ public class ErrorServiceImpl implements ErrorService{
if(Warning_Code % 2 == 1) {
error_status = "有故障";
error_code = "barrier";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
ja.add(row);
}
//bit1 起点报警 startPoint
if((Warning_Code >> 2) % 2 == 1) {
error_status = "有故障";
error_code = "startPoint";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
ja.add(row);
}
//bit2 急停开关报警 stop
if((Warning_Code >> 10) % 2 == 1) {
error_status = "有故障";
error_code = "stop";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
ja.add(row);
}
//bit3 触边开关报警 touchSwith
if((ObstacleTouchState >> 1) % 2 == 1) {
error_status = "有故障";
error_code = "touchSwith";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
ja.add(row);
}
//bit0 速度异常 speedError
if((Warning_Code >> 6) % 2 == 1) {
error_status = "有故障";
error_code = "speedError";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
ja.add(row);
} //bit0 定位异常 locationError
if((Warning_Code >> 7) % 2 == 1) {
error_status = "";
error_code = "startPoint";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
ja.add(row);
}
//bit0 路径异常 wayError
if((Warning_Code >> 8) % 2 == 1) {
error_status = "有故障";
error_code = "wayError";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
ja.add(row);
}
//电池异常 batteryError
if((Warning_Code >> 11) % 2 == 1) {
error_status = "有故障";
error_code = "batteryError";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
row.put("error_content", debugInfoJson.getString("PWR_Warn"));
ja.add(row);
}
@@ -141,11 +150,7 @@ public class ErrorServiceImpl implements ErrorService{
if((Warning_Code >> 24) % 2 == 1) {
error_status = "有故障";
error_code = "CURTIS";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
row.put("error_content", debugInfoJson.getString("Curtis_Warning_Code_Speed"));
ja.add(row);
}
@@ -153,11 +158,7 @@ public class ErrorServiceImpl implements ErrorService{
if((Warning_Code >> 19) % 2 == 1) {
error_status = "有故障";
error_code = "CAN";
JSONObject row = WQL
.getWO("QAGVERROR")
.addParam("flag", "1")
.addParam("error_code", error_code)
.process().uniqueResult(0);
JSONObject row = WQL.getWO("QAGVERROR").addParam("flag", "1").addParam("error_code", error_code).process().uniqueResult(0);
row.put("error_content", debugInfoJson.getString("VehicleCtrl_CAN_Err_Info"));
ja.add(row);
}
@@ -170,7 +171,7 @@ public class ErrorServiceImpl implements ErrorService{
}
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException( e.getMessage()==null?"通信失败请检查系统参数中的Ros连接信息":e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "通信失败请检查系统参数中的Ros连接信息" : e.getMessage());
}
}
}

View File

@@ -15,6 +15,7 @@
*/
package org.nl.agv.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
@@ -55,15 +56,18 @@ public class HomeServiceImpl implements HomeService{
public void qeryDebuggerInfo() {
try {
Map<String,String> urlInfo = RosUtil.getRosHostInfo();
String result1 = HttpUtil.get(urlInfo.get("javaUrl"));
String result1 = HttpUtil.get("http://localhost:8011/api/pcsIfPurchaseorder/queryApt");
//String result1 = HttpUtil.get(urlInfo.get("javaUrl"));
JSONObject json = JSONObject.parseObject(result1);
JSONObject jo = JSONObject.parseObject(json.getString("Msg_DisplayState"));
debugInfoJson.put("Msg_Timestamp", jo
.getJSONObject("header")
.getJSONObject("stamp")
.getString("sec"));
debugInfoJson.put("Msg_Timestamp", jo.getJSONObject("header").getJSONObject("stamp").getString("sec"));
debugInfoJson.put("AGV_ID", jo.getString("AGV_ID"));
debugInfoJson.put("Sys_Mode", jo.getString("Sys_Mode"));
debugInfoJson.put("screen", jo.getString("Remote_Or_HMI_Ctrl"));
debugInfoJson.put("tcs", jo.getString("CAD_Or_TCS_Ctrl"));
debugInfoJson.put("sche", jo.getString("Sche_JSON_Sche_Enable"));
debugInfoJson.put("rc", jo.getString("VehicleCtrlRealRCEnable"));
debugInfoJson.put("joy", jo.getString("VehicleCtrlRealJoyEnable"));
debugInfoJson.put("VehicleCtrlExpThrottle", jo.getString("VehicleCtrlExpThrottle"));
debugInfoJson.put("Warning_Code", jo.getString("Warning_Code"));
debugInfoJson.put("Car_Global_rx", jo.getString("Car_Global_rx"));
@@ -108,17 +112,12 @@ public class HomeServiceImpl implements HomeService{
debugInfoJson.put("Env_SoftwareVersion", jo.getString("Env_SoftwareVersion"));
String PathFollow_Enable = jo.getString("PathFollow_Enable");
if(StrUtil.equals("0", PathFollow_Enable)) {
JSONObject taskjo = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete='0'and task_status='01'")
.uniqueResult(0);
JSONObject taskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete='0'and task_status='01'").uniqueResult(0);
if(ObjectUtil.isNotEmpty(taskjo)) {
taskjo.put("task_status", "02");
taskjo.put("task_status_name", "任务完成");
taskjo.put("update_time", DateUtil.now());
WQLObject
.getWQLObject("ST_TASK_INFO")
.update(taskjo);
WQLObject.getWQLObject("ST_TASK_INFO").update(taskjo);
}
}
debugInfoJson.put("PathFollow_Enable", PathFollow_Enable);
@@ -138,10 +137,7 @@ public class HomeServiceImpl implements HomeService{
@Override
public void handleMessage(Message message) {
JSONObject jo = JSONObject.parseObject(message.toString());
debugInfoJson.put("Msg_Timestamp", jo
.getJSONObject("header")
.getJSONObject("stamp")
.getString("secs"));
debugInfoJson.put("Msg_Timestamp", jo.getJSONObject("header").getJSONObject("stamp").getString("secs"));
debugInfoJson.put("AGV_ID", jo.getString("AGV_ID"));
debugInfoJson.put("Sys_Mode", jo.getString("Sys_Mode"));
debugInfoJson.put("VehicleCtrlExpThrottle", jo.getString("VehicleCtrlExpThrottle"));
@@ -188,17 +184,12 @@ public class HomeServiceImpl implements HomeService{
debugInfoJson.put("Env_SoftwareVersion", jo.getString("Env_SoftwareVersion"));
String PathFollow_Enable = jo.getString("PathFollow_Enable");
if(StrUtil.equals("false", PathFollow_Enable)) {
JSONObject taskjo = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete='0'and task_status='01'")
.uniqueResult(0);
JSONObject taskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete='0'and task_status='01'").uniqueResult(0);
if(ObjectUtil.isNotEmpty(taskjo)) {
taskjo.put("task_status", "02");
taskjo.put("task_status_name", "任务完成");
taskjo.put("update_time", DateUtil.now());
WQLObject
.getWQLObject("ST_TASK_INFO")
.update(taskjo);
WQLObject.getWQLObject("ST_TASK_INFO").update(taskjo);
}
}
debugInfoJson.put("PathFollow_Enable", PathFollow_Enable);
@@ -226,13 +217,13 @@ public class HomeServiceImpl implements HomeService{
//手自动是Sys_Mode 3 REMA手动 4自动 5 IO手持方式的手动这个车不装
String automatic_status = debugInfoJson.getString("Sys_Mode");
if(StrUtil.equals(automatic_status, "3")) {
automatic_status_name = "REMA手动";
agvrun_status_name = "REMA手动";
}
if(StrUtil.equals(automatic_status, "4")) {
automatic_status_name = "自动";
agvrun_status_name = "自动";
}
if(StrUtil.equals(automatic_status, "5")) {
automatic_status_name = "IO手持方式的手动";
agvrun_status_name = "IO手持方式的手动";
}
result.put("agvrun_status", agvrun_status);
result.put("agvrun_status_name", agvrun_status_name);
@@ -245,42 +236,36 @@ public class HomeServiceImpl implements HomeService{
}
@Override
public Map<String,Object>queryHomePage(Map<String,String> jsonObject) {
public Map<String,Object> queryHomePage(Map<String,String> jsonObject) {
String button_code = "";
String button_name = "";
String agvrun_status_name = "";
String automatic_status_name = "";
String device_info = "";
String task_name = "";
Integer electric = 0;
String speed = "";
String error_name = "正常运行";
JSONObject returnjo = new JSONObject();
JSONObject row = new JSONObject();
try {
JSONObject tasking = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and task_status='01' and task_type='1'")
.uniqueResult(0);
JSONObject tasking = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='01' and task_type='1'").uniqueResult(0);
// 1 无任务 2 有任务未执行 3 执行中
String task_status = "";
//1确认完成 2确认完成继续下个任务 3继续搬运4返回休息点
String date = DateUtil.today();
JSONObject today_task = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and date='" + date + "'and task_type='1'")
.uniqueResult(0);
if(tasking == null) {
task_status = "无任务";
}
JSONObject tasked = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and task_status='00'and task_type='1'")
.uniqueResult(0);
JSONObject tasked = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='00'and task_type='1'").uniqueResult(0);
if(tasked != null) {
task_status = "有任务未执行";
}
if(tasking != null) {
task_status = "执行中";
task_name = "任务号:" + tasking.getString("task_code") + "-" + "目标点:" + tasking.getString("next_point_code");
}
JSONObject unManFinishTask = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and task_status='02' and is_manualfinished='0'and task_type='1'")
.uniqueResult(0);
JSONObject unManFinishTask = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='02' and is_manualfinished='0'and task_type='1'").uniqueResult(0);
if(unManFinishTask != null && tasked == null) {
button_code = "1";
button_name = "确认完成";
@@ -298,62 +283,90 @@ public class HomeServiceImpl implements HomeService{
button_code = "4";
button_name = "返回休息点";
//假如所有的任务都完成,包括返回休息点的任务,且最后一个完成任务的时间是返回休息电的任务也不显示
JSONObject doingtaskjo = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 ", "update_time desc")
.uniqueResult(0);
if(doingtaskjo != null && doingtaskjo
.getString("task_type")
.equals("2")) {
JSONObject doingtaskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 ", "update_time desc").uniqueResult(0);
if(doingtaskjo != null && doingtaskjo.getString("task_type").equals("2")) {
button_code = "";
button_name = "";
}
}
//假如有执行中的任务,则不显示
JSONObject doingtaskjo = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and task_status='01' and is_manualfinished='0'")
.uniqueResult(0);
JSONObject doingtaskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='01' and is_manualfinished='0'").uniqueResult(0);
if(doingtaskjo != null) {
button_code = "";
button_name = "";
}
if(debugInfoJson.size() > 0) {
//假如电量低于30 ,则返回休息电
electric = debugInfoJson.getInteger("PWR_Percent");
if(electric < 30) {
button_code = "4";
button_name = "返回休息点";
}
}
String task_num = "待执行0";
//分母 今天所有的任务,分子今天未完成的任务
JSONArray alltaskja = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and task_type='1' and date ='" + date + "'")
.getResultJSONArray(0);
JSONArray alltaskja = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_type='1' and date ='" + date + "'").getResultJSONArray(0);
if(alltaskja.size() > 0) {
JSONArray todaytaskja = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and task_type='1' and date ='" + date + "' and task_status='00'")
.getResultJSONArray(0);
JSONArray todaytaskja = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_type='1' and date ='" + date + "' and task_status='00'").getResultJSONArray(0);
String alltask_num = String.valueOf(alltaskja.size());
String todaytask_num = String.valueOf(todaytaskja.size());
task_num = "待执行" + todaytask_num + "/" + alltask_num;
}
if(debugInfoJson.size() > 0) {
//车辆运行还是待机是PathFollow_Enable 1为运行 0为待机
String agvrun_status = debugInfoJson.getString("PathFollow_Enable");
if(StrUtil.equals(agvrun_status, "1")) {
automatic_status_name = "运行";
}
if(StrUtil.equals(agvrun_status, "0")) {
automatic_status_name = "待机";
}
//手自动是Sys_Mode 3 REMA手动 4自动 5 IO手持方式的手动这个车不装
String automatic_status = debugInfoJson.getString("Sys_Mode");
if(StrUtil.equals(automatic_status, "3")) {
agvrun_status_name = "REMA手动";
}
if(StrUtil.equals(automatic_status, "4")) {
agvrun_status_name = "自动";
}
if(StrUtil.equals(automatic_status, "5")) {
agvrun_status_name = "IO手持方式的手动";
}
//速度
speed = debugInfoJson.getString("Speedm_Tmp") == null ? "0" : debugInfoJson.getString("Speedm_Tmp");
row.put("speed", speed + "m/s");
//agv状态枚举
row.put("agvrun_status", agvrun_status);
//agv状态名称1为运行 0为待机
row.put("agvrun_status_name", agvrun_status_name);
//agv操纵枚举
row.put("automatic_status", automatic_status);
//agv操纵名称3 REMA手动 4自动
row.put("automatic_status_name", automatic_status_name);
//假如电量低于30 ,则返回休息电
electric = debugInfoJson.getInteger("PWR_Percent");
//电量
row.put("electric", electric);
if(electric < 30) {
button_code = "4";
button_name = "返回休息点";
}
String Env_CustomName = debugInfoJson.getString("Env_CustomName");
String Env_VehicleType = debugInfoJson.getString("Env_VehicleType");
//设备名称
device_info = Env_CustomName + Env_VehicleType;
}
ErrorServiceImpl errorServiceImpl = new ErrorServiceImpl();
//todo 此处检查
Map error = errorServiceImpl.querryError(null);
String Env_CustomName = debugInfoJson.getString("Env_CustomName");
String Env_VehicleType = debugInfoJson.getString("Env_VehicleType");
String device_info = Env_CustomName + Env_VehicleType;
JSONArray errorResult = JSONArray.parseArray(JSON.toJSONString(error.get("result")));
if(errorResult.size() > 0) {
error_name = errorResult.getJSONObject(0).getString("error_name");
}
//row.put("agv_error", (String) error.get("error_status"));
//故障信息
row.put("error_name", error_name);
//设备信息
row.put("device_info", device_info);
//任务状态
row.put("task_status", task_status);
//当前任务
row.put("task_name", task_name);
row.put("task_num", task_num);
row.put("agv_error", (String) error.get("error_status"));
row.put("button_code", button_code);
row.put("button_name", button_name);
row.put("electric", electric);
returnjo.put("code", "1");
returnjo.put("desc", "操作成功");
returnjo.put("result", row);
@@ -361,7 +374,7 @@ public class HomeServiceImpl implements HomeService{
}
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException( e.getMessage()==null?"通信失败请检查系统参数中的Ros连接信息":e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "通信失败请检查系统参数中的Ros连接信息" : e.getMessage());
}
}
@@ -372,9 +385,7 @@ public class HomeServiceImpl implements HomeService{
String button_code = (String) jsonObject.get("button_code");
JSONObject returnjo = new JSONObject();
if(StrUtil.equals(button_code, "1")) {
JSONObject taskjo = taskTable
.query("is_delete='0' and task_status='02' and task_type ='1' and is_manualfinished='0'")
.uniqueResult(0);
JSONObject taskjo = taskTable.query("is_delete='0' and task_status='02' and task_type ='1' and is_manualfinished='0'").uniqueResult(0);
if(ObjectUtil.isEmpty(taskjo)) {
throw new BadRequestException("未找到任务");
}
@@ -382,9 +393,7 @@ public class HomeServiceImpl implements HomeService{
taskTable.update(taskjo);
}
if(StrUtil.equals(button_code, "2")) {
JSONObject taskjo = taskTable
.query("is_delete='0' and task_status='02' and task_type ='1' and is_manualfinished='0'")
.uniqueResult(0);
JSONObject taskjo = taskTable.query("is_delete='0' and task_status='02' and task_type ='1' and is_manualfinished='0'").uniqueResult(0);
if(ObjectUtil.isEmpty(taskjo)) {
returnjo.put("code", "1");
returnjo.put("desc", "未找到任务");
@@ -393,9 +402,7 @@ public class HomeServiceImpl implements HomeService{
taskjo.put("is_manualfinished", "1");
taskTable.update(taskjo);
//下发下一个任务
JSONObject nexttaskjo = taskTable
.query("is_delete='0' and task_status='00' and task_type ='1' ", "seq_num")
.uniqueResult(0);
JSONObject nexttaskjo = taskTable.query("is_delete='0' and task_status='00' and task_type ='1' ", "seq_num").uniqueResult(0);
if(ObjectUtil.isEmpty(nexttaskjo)) {
returnjo.put("code", "1");
returnjo.put("desc", "未找到任务");
@@ -409,9 +416,7 @@ public class HomeServiceImpl implements HomeService{
//改变任务的状态
nexttaskjo.put("task_status", "01");
nexttaskjo.put("task_status_name", "执行中");
WQLObject
.getWQLObject("ST_TASK_INFO")
.update(nexttaskjo);
WQLObject.getWQLObject("ST_TASK_INFO").update(nexttaskjo);
}
else{
returnjo.put("code", "1");
@@ -420,9 +425,7 @@ public class HomeServiceImpl implements HomeService{
}
}
if(StrUtil.equals(button_code, "3")) {
JSONObject nexttaskjo = taskTable
.query("is_delete='0' and task_status='00' and task_type ='1' ", "seq_num")
.uniqueResult(0);
JSONObject nexttaskjo = taskTable.query("is_delete='0' and task_status='00' and task_type ='1' ", "seq_num").uniqueResult(0);
if(ObjectUtil.isEmpty(nexttaskjo)) {
throw new BadRequestException("未找到任务");
}
@@ -435,9 +438,7 @@ public class HomeServiceImpl implements HomeService{
//改变任务的状态
nexttaskjo.put("task_status", "01");
nexttaskjo.put("task_status_name", "执行中");
WQLObject
.getWQLObject("ST_TASK_INFO")
.update(nexttaskjo);
WQLObject.getWQLObject("ST_TASK_INFO").update(nexttaskjo);
}
else{
returnjo.put("code", "1");
@@ -448,18 +449,13 @@ public class HomeServiceImpl implements HomeService{
if(StrUtil.equals(button_code, "4")) {
TaskServiceServiceImpl taskServiceServiceImpl = new TaskServiceServiceImpl();
//查询有没有正在执行的任务,假如有不能返回生成任务
JSONObject doingtaskjo = WQLObject
.getWQLObject("ST_TASK_INFO")
.query("is_delete= 0 and task_status='01' ")
.uniqueResult(0);
JSONObject doingtaskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='01' ").uniqueResult(0);
if(ObjectUtil.isNotEmpty(doingtaskjo)) {
returnjo.put("code", "0");
returnjo.put("desc", "有正在执行的任务,不能生产返回休息点的任务");
return returnjo;
}
String rest_pointcode = (String) taskServiceServiceImpl
.queryPoint(new HashMap<>())
.get("rest_pointcode");
String rest_pointcode = (String) taskServiceServiceImpl.queryPoint(new HashMap<>()).get("rest_pointcode");
JSONObject taskjo = new JSONObject();
taskjo.put("task_uuid", IdUtil.simpleUUID());
taskjo.put("task_code", CodeUtil.getNewCode("TASK_NO"));
@@ -488,9 +484,7 @@ public class HomeServiceImpl implements HomeService{
returnjo.put("desc", TaskSendBackStatusEnum.getName(resultflag));
return returnjo;
}
WQLObject
.getWQLObject("ST_TASK_INFO")
.insert(taskjo);
WQLObject.getWQLObject("ST_TASK_INFO").insert(taskjo);
}
returnjo.put("code", "1");
returnjo.put("desc", "操作成功");

View File

@@ -15,22 +15,18 @@
*/
package org.nl.agv.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import edu.wpi.rail.jrosbridge.Ros;
import edu.wpi.rail.jrosbridge.services.ServiceResponse;
import jline.internal.Log;
import lombok.RequiredArgsConstructor;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esotericsoftware.minlog.Log;
import edu.wpi.rail.jrosbridge.services.ServiceResponse;
import lombok.RequiredArgsConstructor;
import org.nl.agv.enu.VehicleOperateEnum;
import org.nl.agv.unit.RosUtil;
import org.nl.agv.service.VehicleInfoService;
import org.nl.agv.unit.sendToAgvUtil;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -87,28 +83,61 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
return returnjo;
}
@Override
public Map<String,Object> queryControlStatus(Map<String,String> jsonObject) {
return null;
}
@Override
public Map<String,Object> Shut_down(Map<String,String> jsonObject) {
ServiceResponse response = new ServiceResponse();
// 1-关机、2-显示屏控制、3-TCS控制、4-RC控制、5-Joy控制
if(ObjectUtil.isNotEmpty(jsonObject)) {
String enable = "0".equals(jsonObject.get("bool")) ? "(false)" : "(true)";
String enable = "0".equals(jsonObject.get("bool")) ? "false#" : "true#";
VehicleOperateEnum status = VehicleOperateEnum.getType(jsonObject.get("type"));
switch(status) {
//关机
case OFF:
response = sendToAgvUtil.send("PowerOff");
break;
case SCREEN:
response = sendToAgvUtil.send("HMI_Ctrl_Enable" + enable);
response = sendToAgvUtil.send("Remote_Or_HMI_Ctrl:" + enable);
break;
case TCS:
response = sendToAgvUtil.send("TCS_Ctrl_Enable" + enable);
response = sendToAgvUtil.send("CAD_Or_TCS_Ctrl:" + enable);
break;
case SCHE:
response = sendToAgvUtil.send("Sche_JSON_Sche_Enable:" + enable);
break;
case RC:
response = sendToAgvUtil.send("HMI_RCCtrl_Enable" + enable);
response = sendToAgvUtil.send("VehicleCtrlRealRCEnable:" + enable);
break;
case JOY:
response = sendToAgvUtil.send("HMI_joyCtrl_Enable" + enable);
response = sendToAgvUtil.send("VehicleCtrlRealJoyEnable:" + enable);
break;
//退出
case QUITNOW:
response = sendToAgvUtil.send("QuitNow");
break;
//软启动(任务重置)
case REBORNINIT:
response = sendToAgvUtil.send("HMIRebornInitNow");
break;
//跳过起点
case STARTCHECK:
response = sendToAgvUtil.send("HMIStartCheckNow");
break;
//重启
case REBOOT:
response = sendToAgvUtil.send("PowerReboot");
break;
//全屏
case FULL:
response = sendToAgvUtil.send("FullScreenNow");
break;
//跳过托盘检测
case SKIPPLATE:
response = sendToAgvUtil.send("SkipPlateCheckNow");
break;
default:
break;
@@ -204,26 +233,15 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
returnjo.put("desc", "查询成功!");
returnjo.put("result", row);
return returnjo;
} catch(Exception e) {
}
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException( e.getMessage()==null?"通信失败请检查系统参数中的Ros连接信息":e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "通信失败请检查系统参数中的Ros连接信息" : e.getMessage());
}
}
@Override
public Map<String,Object> queryControlStatus(Map<String,String> jsonObject) {
return null;
}
@Override
public Map<String,Object> querrySensor(Map<String,String> jsonObject) {
//急停按钮
String stopButton_status = "0";
//避障减速
@@ -241,54 +259,50 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
//ObstacleTouchState bit4 为导航雷达pfr2000或NAV350 防护触发信号 1 触发 0 未触发
JSONObject returnjo = new JSONObject();
JSONObject row = new JSONObject();
try {
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
int ObstacleTouchState = debugInfoJson.getInteger("ObstacleTouchState");
int ObstacleDetectState = debugInfoJson.getInteger("ObstacleDetectState");
int VehicleCtrlRealCustomStateByte0 = debugInfoJson.getInteger("VehicleCtrlRealCustomStateByte0");
//避障停车
if(ObstacleDetectState % 2 == 1) {
speedStop_status = "1";
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
int ObstacleTouchState = debugInfoJson.getInteger("ObstacleTouchState");
int ObstacleDetectState = debugInfoJson.getInteger("ObstacleDetectState");
int VehicleCtrlRealCustomStateByte0 = debugInfoJson.getInteger("VehicleCtrlRealCustomStateByte0");
//避障停车
if(ObstacleDetectState % 2 == 1) {
speedStop_status = "1";
}
//避障减速
if((ObstacleDetectState >> 1) % 2 == 1) {
speedReduction_status = "1";
}
//复位按钮
if(VehicleCtrlRealCustomStateByte0 % 2 == 1) {
resetButton_status = "1";
}
//安全触边
if((ObstacleTouchState >> 1) % 2 == 1) {
securityTentacle_status = "1";
}
////急停按钮
if((ObstacleTouchState >> 2) % 2 == 1) {
stopButton_status = "1";
}
////
if((ObstacleTouchState >> 3) % 2 == 1) {
}
////
if((ObstacleTouchState >> 4) % 2 == 1) {
}
row.put("stopButton_status", stopButton_status);
row.put("speedReduction_status", speedReduction_status);
row.put("resetButton_status", resetButton_status);
row.put("speedStop_status", speedStop_status);
row.put("securityTentacle_status", securityTentacle_status);
returnjo.put("code", "1");
returnjo.put("desc", "查询成功!");
returnjo.put("result", row);
return returnjo;
}
//避障减速
if((ObstacleDetectState >> 1) % 2 == 1) {
speedReduction_status = "1";
}
//复位按钮
if(VehicleCtrlRealCustomStateByte0 % 2 == 1) {
resetButton_status = "1";
}
//安全触边
if((ObstacleTouchState >> 1) % 2 == 1) {
securityTentacle_status = "1";
}
////急停按钮
if((ObstacleTouchState >> 2) % 2 == 1) {
stopButton_status = "1";
}
////
if((ObstacleTouchState >> 3) % 2 == 1) {
}
////
if((ObstacleTouchState >> 4) % 2 == 1) {
}
row.put("stopButton_status", stopButton_status);
row.put("speedReduction_status", speedReduction_status);
row.put("resetButton_status", resetButton_status);
row.put("speedStop_status", speedStop_status);
row.put("securityTentacle_status", securityTentacle_status);
returnjo.put("code", "1");
returnjo.put("desc", "查询成功!");
returnjo.put("result", row);
return returnjo;
} catch(Exception e) {
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException( e.getMessage()==null?"通信失败请检查系统参数中的Ros连接信息":e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "通信失败请检查系统参数中的Ros连接信息" : e.getMessage());
}
}
@@ -300,9 +314,10 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
String inLineStatus_name;
String UpdateStatus;
String UpdateStatus_name;
String Update_Sch = HomeServiceImpl.debugInfoJson.getString("Update_Sch");
String Auto_In_Line_State = HomeServiceImpl.debugInfoJson.getString("Auto_In_Line_State");
if(StrUtil.equals("true", Auto_In_Line_State)) {
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
String Update_Sch = debugInfoJson.getString("Update_Sch");
String Auto_In_Line_State = debugInfoJson.getString("Auto_In_Line_State");
if(StrUtil.equals("0", Auto_In_Line_State)) {
inLineStatus = "0";
inLineStatus_name = "正常";
}
@@ -318,6 +333,11 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
UpdateStatus = "0";
UpdateStatus_name = "更新中";
}
row.put("screenStatus", debugInfoJson.getString("Remote_Or_HMI_Ctrl"));
row.put("tcsStatus", debugInfoJson.getString("CAD_Or_TCS_Ctrl"));
row.put("scheStatus", debugInfoJson.getString("Sche_JSON_Sche_Enable"));
row.put("rcStatus", debugInfoJson.getString("VehicleCtrlRealRCEnable"));
row.put("joyStatus", debugInfoJson.getString("VehicleCtrlRealJoyEnable"));
row.put("inLineStatus", inLineStatus);
row.put("inLineStatus_name", inLineStatus_name);
row.put("UpdateStatus", UpdateStatus);

View File

@@ -14,7 +14,7 @@
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.error_code TYPEAS s_string
输入.error_code TYPEAS s_string
[临时表]
@@ -91,3 +91,18 @@ ENDIF
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
*
FROM
ST_AGV_ERROR as agv
WHERE
1=1
OPTION 输入.error_code <> ""
agv.error_code = 输入.error_code
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF