opt:增加返回点功能。

This commit is contained in:
2024-05-12 13:51:13 +08:00
parent 7b9c11f011
commit 4662007fe9
3 changed files with 66 additions and 27 deletions

View File

@@ -15,7 +15,7 @@
*/ */
package org.nl.agv.service.impl; package org.nl.agv.service.impl;
import cn.hutool.core.date.StopWatch; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
@@ -37,6 +37,7 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil; import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL; import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@@ -58,6 +59,10 @@ import static org.nl.common.utils.LangUtils.getLanguage;
@RequiredArgsConstructor @RequiredArgsConstructor
@EnableScheduling @EnableScheduling
public class TaskServiceServiceImpl implements TaskService { public class TaskServiceServiceImpl implements TaskService {
@Value("${spring.profiles.active}")
private String isProd;
public static JSONObject pointJson = new JSONObject(); public static JSONObject pointJson = new JSONObject();
/** /**
@@ -68,6 +73,8 @@ public class TaskServiceServiceImpl implements TaskService {
JSONObject returnjo = new JSONObject(); JSONObject returnjo = new JSONObject();
try { try {
String rest_pointcode = ""; String rest_pointcode = "";
JSONArray arr = new JSONArray();
if ("prod".equals(isProd)) {
ServiceResponse response = sendToAgvUtil.send("GetStationFloorIndexTable"); ServiceResponse response = sendToAgvUtil.send("GetStationFloorIndexTable");
String result_info = JSONObject.parseObject(response.toString()).getString("ROS_String_Output"); String result_info = JSONObject.parseObject(response.toString()).getString("ROS_String_Output");
if (StringUtils.isBlank(result_info)) { if (StringUtils.isBlank(result_info)) {
@@ -76,24 +83,59 @@ public class TaskServiceServiceImpl implements TaskService {
return returnjo; return returnjo;
} }
String[] split = result_info.split("\\n"); String[] split = result_info.split("\\n");
for (int i = 0; i < split.length; i++) { for (String row : split) {
String row = split[i];
String[] rowArr = row.split("\\s+"); String[] rowArr = row.split("\\s+");
pointJson.put(rowArr[3], rowArr[4].contains("<") ? "" : rowArr[4]); pointJson.put(rowArr[3], rowArr[4].contains("<") ? "" : rowArr[4]);
} }
JSONArray arr = new JSONArray(); for (String key : pointJson.keySet()) {
for (Object key : pointJson.keySet()) {
String value = (String) pointJson.get(key); String value = (String) pointJson.get(key);
System.out.println("Key = " + key + ", Value = " + value); //System.out.println("Key = " + key + ", Value = " + value);
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("point_code", key); row.put("point_code", key);
row.put("point_name", value); row.put("point_name", value);
row.put("code_name", key + "-" + value); row.put("code_name", key + "-" + value);
if (StrUtil.equals("休息", value)) { if (StrUtil.equals("休息", value)) {
rest_pointcode = (String) key; rest_pointcode = key;
} }
arr.add(row); arr.add(row);
} }
} else {
JSONObject row = new JSONObject();
row.put("point_code", "1");
row.put("point_name", "点位1");
row.put("code_name", "点位1");
JSONObject row1 = new JSONObject();
row1.put("point_code", "2");
row1.put("point_name", "点位2");
row1.put("code_name", "点位2");
JSONObject row2 = new JSONObject();
row2.put("point_code", "3");
row2.put("point_name", "点位3");
row2.put("code_name", "点位3");
JSONObject row3 = new JSONObject();
row3.put("point_code", "4");
row3.put("point_name", "点位4");
row3.put("code_name", "点位4");
JSONObject row4 = new JSONObject();
row4.put("point_code", "5");
row4.put("point_name", "二楼中间层休息点位与茶水间的充电桩交叉点1");
row4.put("code_name", "二楼中间层休息点位与茶水间的充电桩交叉点1");
JSONObject row5 = new JSONObject();
row5.put("point_code", "6");
row5.put("point_name", "二楼中间层休息点位充电桩1");
row5.put("code_name", "二楼中间层休息点位充电桩1");
JSONObject row6 = new JSONObject();
row6.put("point_code", "7");
row6.put("point_name", "一楼休息点位充电桩2");
row6.put("code_name", "一楼休息点位充电桩2");
arr.add(row);
arr.add(row1);
arr.add(row2);
arr.add(row3);
arr.add(row4);
arr.add(row5);
arr.add(row6);
}
returnjo.put("code", "1"); returnjo.put("code", "1");
returnjo.put("desc", LangUtils.getMsgLanguage("QuerySuccess", null)); returnjo.put("desc", LangUtils.getMsgLanguage("QuerySuccess", null));
returnjo.put("rest_pointcode", rest_pointcode); returnjo.put("rest_pointcode", rest_pointcode);
@@ -176,7 +218,7 @@ public class TaskServiceServiceImpl implements TaskService {
if (ObjectUtil.isNotEmpty(taskrow)) { if (ObjectUtil.isNotEmpty(taskrow)) {
seq_num = taskrow.getInteger("seq_num") + 1; seq_num = taskrow.getInteger("seq_num") + 1;
} }
if(StringUtils.isNotBlank(jsonObject.get("next_point_code"))) { if (StringUtils.isNotBlank(jsonObject.get("next_point_code"))) {
taskjo.put("next_point_code2", jsonObject.get("next_point_code")); taskjo.put("next_point_code2", jsonObject.get("next_point_code"));
} }
taskjo.put("task_type", type); taskjo.put("task_type", type);

View File

@@ -93,7 +93,6 @@ public class SendHomeWebSocketServer {
} }
public Session getSession() { public Session getSession() {
Integer d = 1;
return session; return session;
} }
// 发送消息,在定时任务中会调用此方法 // 发送消息,在定时任务中会调用此方法

View File

@@ -1527,13 +1527,11 @@ public class WQLObject implements Serializable, Cloneable {
this.wo.addParam(whereArgNames.get(i), whereArgs[i]); this.wo.addParam(whereArgNames.get(i), whereArgs[i]);
} }
rb = this.wo.process(); rb = this.wo.process();
} catch (WDKException e) { } catch (WDKException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new WDKException("wqlobject delete exception", e); throw new WDKException("wqlobject delete exception", e);
} }
return rb; return rb;
} }