rev:修复一些bug
This commit is contained in:
@@ -106,7 +106,6 @@ public class DevelopServiceImpl implements DevelopService {
|
||||
} while (ObjectUtil.isEmpty(HomeServiceImpl.debugInfoJson));
|
||||
JSONObject returnjo = new JSONObject();
|
||||
JSONObject map = HomeServiceImpl.debugInfoJson;
|
||||
|
||||
Iterator iter = map.entrySet().iterator();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (iter.hasNext()) {
|
||||
@@ -147,10 +146,10 @@ public class DevelopServiceImpl implements DevelopService {
|
||||
if (StrUtil.isEmpty(password)) {
|
||||
throw new BadRequestException("密码不能为空!");
|
||||
}
|
||||
JSONObject row = WQLObject.getWQLObject("st_system_param").query("1=1").uniqueResult(0);
|
||||
JSONObject row = WQLObject.getWQLObject("ST_SYSTEM_PARAM").query("1=1").uniqueResult(0);
|
||||
row.put("max_task_num", maxTaskNun);
|
||||
row.put("password", password);
|
||||
WQLObject.getWQLObject("st_system_param").update(row);
|
||||
WQLObject.getWQLObject("ST_SYSTEM_PARAM").update(row);
|
||||
JSONObject returnjo = new JSONObject();
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "更新成功");
|
||||
@@ -159,7 +158,7 @@ public class DevelopServiceImpl implements DevelopService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryPassword(Map<String, String> jsonObject) {
|
||||
JSONObject jo = WQLObject.getWQLObject("st_system_param").query("1=1").uniqueResult(0);
|
||||
JSONObject jo = WQLObject.getWQLObject("ST_SYSTEM_PARAM").query("1=1").uniqueResult(0);
|
||||
JSONObject returnjo = new JSONObject();
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "查询成功!");
|
||||
|
||||
@@ -21,9 +21,11 @@ import edu.wpi.rail.jrosbridge.Ros;
|
||||
import edu.wpi.rail.jrosbridge.Topic;
|
||||
import edu.wpi.rail.jrosbridge.callback.TopicCallback;
|
||||
import edu.wpi.rail.jrosbridge.messages.Message;
|
||||
import jline.internal.Log;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.agv.service.ErrorService;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -36,11 +38,11 @@ import java.util.Map;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ErrorServiceImpl implements ErrorService {
|
||||
|
||||
public class ErrorServiceImpl implements ErrorService{
|
||||
@Override
|
||||
public Map<String, Object> querryError(Map<String, String> jsonObject) {
|
||||
public Map<String,Object> querryError(Map<String,String> jsonObject) {
|
||||
String error_status = "无故障";
|
||||
try {
|
||||
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
|
||||
int Warning_Code = debugInfoJson.getInteger("Warning_Code");
|
||||
//int Warning_Code = 524305;
|
||||
@@ -48,83 +50,127 @@ public class ErrorServiceImpl implements ErrorService {
|
||||
JSONArray ja = new JSONArray();
|
||||
String error_code = "";
|
||||
//bit0 障碍物报警 barrier
|
||||
if (Warning_Code % 2 == 1) {
|
||||
error_status="有故障";
|
||||
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="有故障";
|
||||
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="有故障";
|
||||
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="有故障";
|
||||
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="有故障";
|
||||
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="是";
|
||||
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="有故障";
|
||||
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="有故障";
|
||||
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);
|
||||
row.put("error_content",debugInfoJson.getString("PWR_Warn"));
|
||||
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);
|
||||
}
|
||||
//CURTIS异常 CURTIS
|
||||
if ((Warning_Code >> 24) % 2 == 1) {
|
||||
error_status="有故障";
|
||||
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);
|
||||
row.put("error_content",debugInfoJson.getString("Curtis_Warning_Code_Speed"));
|
||||
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);
|
||||
}
|
||||
|
||||
//CAN通讯异常 CAN
|
||||
if ((Warning_Code >> 19) % 2 == 1) {
|
||||
error_status="有故障";
|
||||
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);
|
||||
row.put("error_content",debugInfoJson.getString("VehicleCtrl_CAN_Err_Info"));
|
||||
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);
|
||||
}
|
||||
JSONObject returnjo = new JSONObject();
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "查询成功");
|
||||
returnjo.put("result", ja);
|
||||
returnjo.put("error_status",error_status);
|
||||
returnjo.put("error_status", error_status);
|
||||
return returnjo;
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,12 +53,14 @@ public class HomeServiceImpl implements HomeService{
|
||||
|
||||
public void QueryDebuggerInfo() {
|
||||
try {
|
||||
|
||||
Map<String, String> urlInfo = RosUtil.getRosHostInfo();
|
||||
Map<String,String> urlInfo = RosUtil.getRosHostInfo();
|
||||
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("VehicleCtrlExpThrottle", jo.getString("VehicleCtrlExpThrottle"));
|
||||
@@ -105,18 +107,23 @@ 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);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:"+e.getMessage());
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -130,7 +137,10 @@ 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"));
|
||||
@@ -177,12 +187,17 @@ 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);
|
||||
@@ -230,27 +245,41 @@ public class HomeServiceImpl implements HomeService{
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryHomePage(Map<String,String> jsonObject) {
|
||||
String button_code = "";
|
||||
String button_name = "";
|
||||
Integer electric = 0;
|
||||
JSONObject returnjo = new JSONObject();
|
||||
JSONObject row = new JSONObject();
|
||||
JSONObject tasking = WQLObject.getWQLObject("st_task_info").query("is_delete= 0 and task_status='01' and task_type='1'").uniqueResult(0);
|
||||
try {
|
||||
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 button_code = "";
|
||||
String button_name = "";
|
||||
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);
|
||||
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 = "执行中";
|
||||
}
|
||||
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 = "确认完成";
|
||||
@@ -268,29 +297,45 @@ 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 ,则返回休息电
|
||||
int electric = debugInfoJson.getInteger("PWR_Percent");
|
||||
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;
|
||||
@@ -313,15 +358,22 @@ public class HomeServiceImpl implements HomeService{
|
||||
returnjo.put("result", row);
|
||||
return returnjo;
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> clickSave(Map<String,String> jsonObject) {
|
||||
//1确认完成 2确认完成继续下个任务 3继续搬运,4返回休息点
|
||||
WQLObject taskTable = WQLObject.getWQLObject("st_task_info");
|
||||
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
||||
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("未找到任务");
|
||||
}
|
||||
@@ -329,7 +381,9 @@ 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", "未找到任务");
|
||||
@@ -338,7 +392,9 @@ 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", "未找到任务");
|
||||
@@ -352,7 +408,9 @@ 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");
|
||||
@@ -361,7 +419,9 @@ 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("未找到任务");
|
||||
}
|
||||
@@ -374,7 +434,9 @@ 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");
|
||||
@@ -385,13 +447,18 @@ 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"));
|
||||
@@ -420,7 +487,9 @@ 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", "操作成功");
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.agv.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
@@ -26,6 +27,7 @@ import edu.wpi.rail.jrosbridge.Topic;
|
||||
import edu.wpi.rail.jrosbridge.callback.TopicCallback;
|
||||
import edu.wpi.rail.jrosbridge.messages.Message;
|
||||
import edu.wpi.rail.jrosbridge.services.ServiceResponse;
|
||||
import jline.internal.Log;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.agv.service.DevelopService;
|
||||
@@ -46,30 +48,33 @@ import java.util.Map;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TaskServiceServiceImpl implements TaskService {
|
||||
public class TaskServiceServiceImpl implements TaskService{
|
||||
public static JSONObject pointJson = new JSONObject();
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryPoint(Map<String, String> jsonObject) {
|
||||
public Map<String,Object> queryPoint(Map<String,String> jsonObject) {
|
||||
JSONObject returnjo = new JSONObject();
|
||||
String rest_pointcode = "";
|
||||
try {
|
||||
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");
|
||||
String[] split = result_info.split("\\n");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
for(int i = 0; i < split.length; i++) {
|
||||
String row = split[i];
|
||||
String[] rowArr = row.split("\\s+");
|
||||
pointJson.put(rowArr[3], rowArr[4].contains("<") ? "" : rowArr[4]);
|
||||
}
|
||||
JSONArray arr = new JSONArray();
|
||||
for (Object key : pointJson.keySet()) {
|
||||
for(Object key : pointJson.keySet()) {
|
||||
String value = (String) pointJson.get(key);
|
||||
System.out.println("Key = " + key + ", Value = " + value);
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("point_code", key);
|
||||
row.put("point_name", value);
|
||||
row.put("code_name", key + "-" + value);
|
||||
if (StrUtil.equals("休息", value)) {
|
||||
if(StrUtil.equals("休息", value)) {
|
||||
rest_pointcode = (String) key;
|
||||
}
|
||||
arr.add(row);
|
||||
@@ -82,19 +87,29 @@ public class TaskServiceServiceImpl implements TaskService {
|
||||
returnjo.put("result", arr);
|
||||
return returnjo;
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> confirmPoint(Map<String, String> jsonObject) {
|
||||
public Map<String,Object> confirmPoint(Map<String,String> jsonObject) {
|
||||
String point_code = (String) jsonObject.get("point_code");
|
||||
JSONObject returnjo = new JSONObject();
|
||||
if (StrUtil.isEmpty(point_code)) {
|
||||
if(StrUtil.isEmpty(point_code)) {
|
||||
throw new BadRequestException("站点不能为空!");
|
||||
}
|
||||
//查询未完成的指令有多少条
|
||||
int num = WQL.getWO("QAGVERROR").addParam("flag", "3").process().uniqueResult(0).getInteger("num");
|
||||
int num = WQL.getWO("QAGVERROR")
|
||||
.addParam("flag", "3").process()
|
||||
.uniqueResult(0).getInteger("num");
|
||||
//查询最多的任务数量
|
||||
int max_task_num = WQLObject.getWQLObject("ST_SYSTEM_PARAM").query("1=1").uniqueResult(0).getInteger("max_task_num");
|
||||
if (num >= max_task_num) {
|
||||
int max_task_num = WQLObject
|
||||
.getWQLObject("ST_SYSTEM_PARAM")
|
||||
.query("1=1").uniqueResult(0)
|
||||
.getInteger("max_task_num");
|
||||
if(num >= max_task_num) {
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "未执行的任务数量达到上限!");
|
||||
return returnjo;
|
||||
@@ -104,26 +119,25 @@ public class TaskServiceServiceImpl implements TaskService {
|
||||
String task_status = "00";
|
||||
String task_status_name = "生成未执行";
|
||||
//查询未完成最大的顺序号
|
||||
JSONObject taskrow = WQLObject.getWQLObject("ST_TASK_INFO").query("is_manualfinished=0", "seq_num desc").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskrow)) {
|
||||
JSONObject taskrow = WQLObject
|
||||
.getWQLObject("ST_TASK_INFO")
|
||||
.query("is_manualfinished=0", "seq_num desc")
|
||||
.uniqueResult(0);
|
||||
if(ObjectUtil.isNotEmpty(taskrow)) {
|
||||
seq_num = taskrow.getInteger("seq_num") + 1;
|
||||
|
||||
}
|
||||
if (ObjectUtil.isEmpty(taskrow)) {
|
||||
|
||||
if(ObjectUtil.isEmpty(taskrow)) {
|
||||
//只有第一条下发给agv
|
||||
String a ="HMIStepOrRTPathFollow:0;"+point_code+";1#";
|
||||
String a = "HMIStepOrRTPathFollow:0;" + point_code + ";1#";
|
||||
ServiceResponse send = sendToAgvUtil.send(a);
|
||||
JSONObject resjo = JSONObject.parseObject(send.toString());
|
||||
if (StrUtil.equals("0",resjo.getString("result"))){
|
||||
if(StrUtil.equals("0", resjo.getString("result"))) {
|
||||
task_status_name = "执行中";
|
||||
task_status = "01";
|
||||
}
|
||||
JSONObject change = sendToAgvUtil.change(point_code);
|
||||
//sendToAgvUtil.sendtask(change.getString("first"), change.getString("last"));
|
||||
}
|
||||
|
||||
|
||||
taskjo.put("task_uuid", IdUtil.simpleUUID());
|
||||
taskjo.put("task_code", CodeUtil.getNewCode("TASK_NO"));
|
||||
taskjo.put("task_status", task_status);
|
||||
@@ -136,57 +150,64 @@ public class TaskServiceServiceImpl implements TaskService {
|
||||
taskjo.put("create_time", DateUtil.now());
|
||||
taskjo.put("is_agvfinished", "0");
|
||||
taskjo.put("is_manualfinished", "0");
|
||||
WQLObject.getWQLObject("ST_TASK_INFO").insert(taskjo);
|
||||
WQLObject.getWQLObject("ST_TASK_INFO")
|
||||
.insert(taskjo);
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "新增成功!");
|
||||
return returnjo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryTaskList(Map<String, String> jsonObject) {
|
||||
JSONArray resultJSONArray = WQL.getWO("QAGVERROR").addParam("flag", "2").process().getResultJSONArray(0);
|
||||
public Map<String,Object> queryTaskList(Map<String,String> jsonObject) {
|
||||
JSONArray resultJSONArray = WQL
|
||||
.getWO("QAGVERROR")
|
||||
.addParam("flag", "2").process()
|
||||
.getResultJSONArray(0);
|
||||
JSONObject returnjo = new JSONObject();
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "查询成功!");
|
||||
returnjo.put("result", resultJSONArray);
|
||||
|
||||
return returnjo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> deleteTask(Map<String, String> jsonObject) {
|
||||
public Map<String,Object> deleteTask(Map<String,String> jsonObject) {
|
||||
String task_num = (String) jsonObject.get("task_num");
|
||||
if (StrUtil.isEmpty(task_num)) {
|
||||
if(StrUtil.isEmpty(task_num)) {
|
||||
throw new BadRequestException("任务号不能为空");
|
||||
}
|
||||
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
||||
JSONObject taskjo = taskTable.query("task_code='" + task_num + "'").uniqueResult(0);
|
||||
JSONObject taskjo = taskTable
|
||||
.query("task_code='" + task_num + "'")
|
||||
.uniqueResult(0);
|
||||
taskjo.put("is_delete", "1");
|
||||
taskTable.update(taskjo);
|
||||
JSONObject returnjo = new JSONObject();
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "删除成功!");
|
||||
return returnjo;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateTask(Map<String, String> jsonObject) {
|
||||
public Map<String,Object> updateTask(Map<String,String> jsonObject) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(jsonObject.get("param")));
|
||||
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
||||
//更新之前删除之前的所有未完成任务
|
||||
JSONArray taskrows = taskTable.query("task_status='00' or task_status='01'").getResultJSONArray(0);
|
||||
for (int i = 0; i < taskrows.size(); i++) {
|
||||
JSONArray taskrows = taskTable
|
||||
.query("task_status='00' or task_status='01'")
|
||||
.getResultJSONArray(0);
|
||||
for(int i = 0; i < taskrows.size(); i++) {
|
||||
JSONObject taskrow = taskrows.getJSONObject(i);
|
||||
taskrow.put("is_delete", "1");
|
||||
taskTable.update(taskrow);
|
||||
}
|
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
for(int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject taskjo = jsonArray.getJSONObject(i);
|
||||
String task_num = taskjo.getString("task_num");
|
||||
String seq_num = taskjo.getString("seq_num");
|
||||
JSONObject taskrow = taskTable.query("task_code='" + task_num + "'").uniqueResult(0);
|
||||
JSONObject taskrow = taskTable
|
||||
.query("task_code='" + task_num + "'")
|
||||
.uniqueResult(0);
|
||||
/* String task_status = taskjo.getString("task_status");
|
||||
if (StrUtil.equals(task_status,"01")){
|
||||
taskrow.put("seq_num", 1);
|
||||
@@ -194,7 +215,7 @@ public class TaskServiceServiceImpl implements TaskService {
|
||||
taskrow.put("seq_num", i + 2);
|
||||
}*/
|
||||
taskrow.put("seq_num", i + 1);
|
||||
taskrow.put("is_delete","0");
|
||||
taskrow.put("is_delete", "0");
|
||||
taskTable.update(taskrow);
|
||||
}
|
||||
JSONObject returnjo = new JSONObject();
|
||||
@@ -204,27 +225,28 @@ public class TaskServiceServiceImpl implements TaskService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> check(Map<String, String> jsonObject) {
|
||||
public Map<String,Object> check(Map<String,String> jsonObject) {
|
||||
String password = (String) jsonObject.get("password");
|
||||
if (StrUtil.isEmpty(password)) {
|
||||
if(StrUtil.isEmpty(password)) {
|
||||
throw new BadRequestException("密码不能空!");
|
||||
}
|
||||
//1代表正确,2 代表不正确
|
||||
String is_correct;
|
||||
JSONObject paramjo = WQLObject.getWQLObject("st_system_param").query("1=1").uniqueResult(0);
|
||||
JSONObject paramjo = WQLObject
|
||||
.getWQLObject("ST_SYSTEM_PARAM")
|
||||
.query("1=1").uniqueResult(0);
|
||||
String super_password = paramjo.getString("super_password");
|
||||
String passworddb = paramjo.getString("password");
|
||||
JSONObject returnjo = new JSONObject();
|
||||
if (StrUtil.equals(password, super_password) || StrUtil.equals(passworddb, password)) {
|
||||
if(StrUtil.equals(password, super_password) || StrUtil.equals(passworddb, password)) {
|
||||
is_correct = "1";
|
||||
returnjo.put("code", "1");
|
||||
returnjo.put("desc", "密码校验成功!");
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
returnjo.put("code", "0");
|
||||
returnjo.put("desc", "密码不正确!");
|
||||
}
|
||||
|
||||
return returnjo;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ 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;
|
||||
@@ -27,6 +28,7 @@ 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;
|
||||
@@ -152,8 +154,9 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
|
||||
@Override
|
||||
public Map<String,Object> queryVehicleStatus(Map<String,String> jsonObject) {
|
||||
JSONObject row = new JSONObject();
|
||||
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
|
||||
JSONObject returnjo = new JSONObject();
|
||||
try {
|
||||
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
|
||||
//错误码为Warning_Code,为0表示正常,不为0表示异常
|
||||
String Warning_Code = debugInfoJson.getString("Warning_Code");
|
||||
String working_status = "";
|
||||
@@ -201,6 +204,10 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
|
||||
returnjo.put("desc", "查询成功!");
|
||||
returnjo.put("result", row);
|
||||
return returnjo;
|
||||
} catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,12 +223,7 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
|
||||
|
||||
@Override
|
||||
public Map<String,Object> querrySensor(Map<String,String> jsonObject) {
|
||||
JSONObject returnjo = new JSONObject();
|
||||
JSONObject row = new JSONObject();
|
||||
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
|
||||
int ObstacleTouchState = debugInfoJson.getInteger("ObstacleTouchState");
|
||||
int ObstacleDetectState = debugInfoJson.getInteger("ObstacleDetectState");
|
||||
int VehicleCtrlRealCustomStateByte0 = debugInfoJson.getInteger("VehicleCtrlRealCustomStateByte0");
|
||||
|
||||
//急停按钮
|
||||
String stopButton_status = "0";
|
||||
//避障减速
|
||||
@@ -237,6 +239,18 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
|
||||
//ObstacleTouchState bit2 为 两侧急停按钮触发信号 1 触发 0 未触发
|
||||
//ObstacleTouchState bit3 为 上位机请求急停触发信号 1 触发 0 未触发
|
||||
//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";
|
||||
@@ -272,6 +286,10 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
|
||||
returnjo.put("desc", "查询成功!");
|
||||
returnjo.put("result", row);
|
||||
return returnjo;
|
||||
} catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,4 +8,5 @@ public class DictConstantPool {
|
||||
|
||||
public static final String DICT_SYS_CODE = "system_type";
|
||||
public static final String DICT_SYS_NAME = "所属系统";
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,12 @@ public class SysRole implements Serializable {
|
||||
@TableId(value = "role_id")
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 菜单id
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String menuId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@@ -103,5 +109,11 @@ public class SysRole implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private List<String> menus;
|
||||
|
||||
/**
|
||||
* 角色菜单扩展提供给前端
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<String> menus1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.system.service.role.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
import org.nl.system.service.role.dao.SysRole;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -22,7 +23,7 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
void deleteRoleMenuBatchRoleIds(Collection<String> ids);
|
||||
|
||||
List<String> selectMenuIdsByRoles(String roleId);
|
||||
List<SysMenu> selectMenuIdsByRoles(String roleId);
|
||||
|
||||
/**
|
||||
* 插入角色/菜单表
|
||||
|
||||
@@ -26,7 +26,17 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="selectMenuIdsByRoles" resultType="java.lang.String">
|
||||
SELECT DISTINCT menu_id FROM sys_roles_menus WHERE role_id = #{roleId}
|
||||
<select id="selectMenuIdsByRoles" resultType="org.nl.system.service.menu.dao.SysMenu">
|
||||
SELECT m.menu_id, m.LEVEL FROM sys_menu m,
|
||||
( SELECT r.menu_id AS menu_id FROM sys_roles_menus r WHERE r.role_id =#{roleId}) t
|
||||
WHERE FIND_IN_SET(m.menu_id,t.menu_id)
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -47,28 +47,38 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper,SysRole> imple
|
||||
|
||||
@Override
|
||||
public List<SysRole> query(PageQuery page) {
|
||||
/*
|
||||
String blurry = null;
|
||||
if (ObjectUtil.isNotEmpty(param.get("blurry"))) blurry = param.get("blurry").toString();
|
||||
LambdaQueryWrapper<SysRole> lam = new LambdaQueryWrapper<>();
|
||||
lam.like(ObjectUtil.isNotEmpty(blurry), SysRole::getName, blurry);
|
||||
IPage<SysRole> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
*/
|
||||
QueryWrapper<SysRole> roleQueryWrapper = new QueryWrapper<>();
|
||||
List<SysRole> roleList = roleMapper.selectList(roleQueryWrapper);
|
||||
roleList.forEach(sysRole -> sysRole.setMenus(roleMapper.selectMenuIdsByRoles(sysRole.getRoleId())));
|
||||
roleList.forEach(r -> {
|
||||
List<SysMenu> queryMenuList = roleMapper.selectMenuIdsByRoles(r.getRoleId());
|
||||
//角色菜单id
|
||||
List<String> menus = queryMenuList
|
||||
.stream()
|
||||
.map(SysMenu::getMenuId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//角色菜单id,不含父级
|
||||
List<String> menusExtend = queryMenuList.stream()
|
||||
.filter(l -> l.getLevel() == 2).map(SysMenu::getMenuId)
|
||||
.collect(Collectors.toList());
|
||||
r.setMenus(menus);
|
||||
r.setMenus1(menusExtend);
|
||||
});
|
||||
return roleList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenu> menuQuery() {
|
||||
|
||||
QueryWrapper<SysMenu> queryWrapper = new QueryWrapper<>();
|
||||
List<SysMenu> sysMenuList = sysMenuMapper.selectList(queryWrapper);
|
||||
// key = deep
|
||||
Map<Integer,List<SysMenu>> sysMenuMap = sysMenuList.stream().collect(Collectors.groupingBy(SysMenu::getLevel));
|
||||
Map<Integer,List<SysMenu>> sysMenuMap = sysMenuList
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(SysMenu::getLevel));
|
||||
// key = id
|
||||
Map<String,SysMenu> cityMap = sysMenuList.stream().collect(Collectors.toMap(SysMenu::getMenuId, Function.identity()));
|
||||
Map<String,SysMenu> cityMap = sysMenuList
|
||||
.stream()
|
||||
.collect(Collectors.toMap(SysMenu::getMenuId, Function.identity()));
|
||||
//最底部的子节点层级 0 1 2 3
|
||||
int start = Collections.max(sysMenuMap.keySet());
|
||||
Map<String,List<SysMenu>> map;
|
||||
@@ -79,7 +89,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper,SysRole> imple
|
||||
break;
|
||||
}
|
||||
// 根据菜单id排序并根据父级id分组聚合
|
||||
map = children.stream().sorted(Comparator.comparing(SysMenu::getMenuId)).collect(Collectors.groupingBy(SysMenu::getPid));
|
||||
map = children.stream()
|
||||
.sorted(Comparator.comparing(SysMenu::getMenuId))
|
||||
.collect(Collectors.groupingBy(SysMenu::getPid));
|
||||
map.forEach((parentId, c) -> {
|
||||
//根据父级id获取父级菜单
|
||||
SysMenu parent = cityMap.get(parentId);
|
||||
@@ -93,11 +105,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper,SysRole> imple
|
||||
sysMenuMap.remove(start);
|
||||
start--;
|
||||
}
|
||||
return sysMenuMap.values().stream().flatMap(Collection::stream).sorted(Comparator.comparing(SysMenu::getMenuId)).collect(Collectors.toList());
|
||||
return sysMenuMap.values().stream()
|
||||
.flatMap(Collection::stream)
|
||||
.sorted(Comparator.comparing(SysMenu::getMenuId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(JSONObject param) {
|
||||
@@ -115,7 +128,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper,SysRole> imple
|
||||
String userId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
// 插入
|
||||
sysRole.setRoleId(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
sysRole.setRoleId(IdUtil
|
||||
.getSnowflake(1, 1).nextIdStr());
|
||||
sysRole.setCreateId(userId);
|
||||
sysRole.setCreateName(nickName);
|
||||
sysRole.setCreateTime(new Date());
|
||||
@@ -135,7 +149,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper,SysRole> imple
|
||||
throw new BadRequestException("角色名字不能为空!");
|
||||
}
|
||||
//判断角色名字是否存在
|
||||
SysRole role = roleMapper.selectOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getName, sysRole.getName()).ne(SysRole::getRoleId, sysRole.getRoleId()));
|
||||
SysRole role = roleMapper.selectOne(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getName, sysRole.getName())
|
||||
.ne(SysRole::getRoleId, sysRole.getRoleId()));
|
||||
if(ObjectUtil.isNotEmpty(role)) {
|
||||
throw new BadRequestException("角色【" + name + "】已存在!");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ spring:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3310}/${DB_NAME:nl_agv}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
#url: jdbc:log4jdbc:mysql://${DB_HOST:43.139.166.161}:${DB_PORT:3310}/${DB_NAME:nl_agv}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:43.139.166.161}:${DB_PORT:3310}/${DB_NAME:nl_agv}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
#url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
username: ${DB_USER:root}
|
||||
#password: ${DB_PWD:P@ssw0rd}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
server:
|
||||
port: 8099
|
||||
port: 8018
|
||||
#配置数据源
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
username: ${DB_USER:root}
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:nl_agv}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
#url: jdbc:log4jdbc:mysql://${DB_HOST:43.139.166.161}:${DB_PORT:3310}/${DB_NAME:nl_agv}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
#url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
username: ${DB_USER:generallu}
|
||||
#password: ${DB_PWD:P@ssw0rd}
|
||||
password: ${DB_PWD:123456}
|
||||
#password: ${DB_PWD:Root.123456}
|
||||
# 初始连接数
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
Reference in New Issue
Block a user