add:主页看板,任务完成情况统计、agv实时监控
This commit is contained in:
@@ -18,7 +18,7 @@ public enum TaskStatusEnum {
|
||||
BUSY("1", "BUSY", "执行中"),
|
||||
FINISHED("2", "FINISHED", "完成"),
|
||||
CANCEL("3", "CANCEL", "取消"),
|
||||
FORCED_COMPLETION("4", "", "强制完成"),
|
||||
FORCED_COMPLETION("4", "FORCED_COMPLETION", "强制完成"),
|
||||
ERROR("99", "ERROR", "异常");
|
||||
|
||||
/**
|
||||
@@ -64,11 +64,30 @@ public enum TaskStatusEnum {
|
||||
|
||||
public static String getName(String code) {
|
||||
for (TaskStatusEnum c : TaskStatusEnum.values()) {
|
||||
if (c.code == code) {
|
||||
if (code.equals(c.code)) {
|
||||
return c.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static String getNameByIndex(String index) {
|
||||
for (TaskStatusEnum c : TaskStatusEnum.values()) {
|
||||
if (index.equals(c.index)) {
|
||||
return c.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getCodeByIndex(String index) {
|
||||
for (TaskStatusEnum c : TaskStatusEnum.values()) {
|
||||
if (index.equals(c.index)) {
|
||||
return c.code;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -591,4 +593,8 @@ public interface TaskService extends CommonService<Task> {
|
||||
TaskDto findByTaskCode(String task_code);
|
||||
|
||||
List<TaskDto> queryAllHJReadyTask();
|
||||
|
||||
List<Map<String, Object>> countByStatusAndCreateTimeBetween(
|
||||
Date start,
|
||||
Date end);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -1760,6 +1761,13 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> countByStatusAndCreateTimeBetween(Date start, Date end) {
|
||||
|
||||
return taskMapper.countByStatusAndCreateTimeBetween(DateUtil.format(start,"yyyy-MM-dd HH:mm:ss.SSS"),
|
||||
DateUtil.format(end,"yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把多个字符串拼接的inst_nextDevice_code解析成集合
|
||||
|
||||
@@ -1,14 +1,30 @@
|
||||
package org.nl.acs.task.service.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.nl.acs.common.base.CommonMapper;
|
||||
import org.nl.acs.task.domain.Task;
|
||||
import org.nl.common.annotation.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jiaolm
|
||||
* @date 2023-05-09
|
||||
*/
|
||||
@Repository
|
||||
public interface TaskMapper extends CommonMapper<Task> {
|
||||
|
||||
/**
|
||||
* 按状态和时间范围统计任务数量
|
||||
*/
|
||||
@Select("SELECT t.task_status AS status, COUNT(1) AS count FROM acs_task t " +
|
||||
"WHERE t.create_time BETWEEN #{start} AND #{end} " +
|
||||
"GROUP BY t.task_status")
|
||||
List<Map<String, Object>> countByStatusAndCreateTimeBetween(
|
||||
@Param("start") String start,
|
||||
@Param("end") String end);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.system.controller.dashboard;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.system.service.dashboard.DashboardService;
|
||||
import org.nl.system.service.dashboard.dto.ApiResponse;
|
||||
import org.nl.system.service.monitor.MonitorService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zhengxuming
|
||||
* @date 2025年8月15日14:12:53
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@RequestMapping("/api/dashboard")
|
||||
public class DashboardController {
|
||||
|
||||
private final DashboardService serverService;
|
||||
|
||||
@GetMapping("/today")
|
||||
public ApiResponse<Object> getTodayTaskStats() {
|
||||
return ApiResponse.success(serverService.getTodayTaskStats());
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/seven-days")
|
||||
public ApiResponse<Object> getSevenDaysTaskStats() {
|
||||
return ApiResponse.success(serverService.getSevenDaysTaskStats());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.system.controller.trajectory;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.system.service.trajectory.TrajectoryBackgroundService;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryBackground;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/trajectoryBackground")
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
public class TrajectoryBackgroundController {
|
||||
|
||||
@Resource
|
||||
private TrajectoryBackgroundService trajectoryBackgroundService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询轨迹背景图")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(trajectoryBackgroundService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增轨迹背景图")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody TrajectoryBackground trajectoryBackground) {
|
||||
trajectoryBackgroundService.create(trajectoryBackground);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改轨迹背景图")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody TrajectoryBackground entity) {
|
||||
trajectoryBackgroundService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除轨迹背景图")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
trajectoryBackgroundService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryAllEnable")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryAllEnable() {
|
||||
return new ResponseEntity<>(TableDataInfo.build(trajectoryBackgroundService.queryAllEnable()), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.system.controller.trajectory;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.system.service.trajectory.TrajectoryConfigurationService;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryConfiguration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/trajectoryConfiguration")
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
public class TrajectoryConfigurationController {
|
||||
|
||||
@Resource
|
||||
private TrajectoryConfigurationService trajectoryConfigurationService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询轨迹设备配置")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(trajectoryConfigurationService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增轨迹设备配置")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody TrajectoryConfiguration trajectoryConfiguration) {
|
||||
trajectoryConfigurationService.create(trajectoryConfiguration);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改轨迹设备配置")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody TrajectoryConfiguration entity) {
|
||||
trajectoryConfigurationService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除轨迹设备配置")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
trajectoryConfigurationService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryAllEnable")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryAllEnable() {
|
||||
return new ResponseEntity<>(TableDataInfo.build(trajectoryConfigurationService.queryAllEnable()), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.nl.system.controller.trajectory;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.system.service.trajectory.TrajectoryService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/trajectory")
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
public class TrajectoryController {
|
||||
|
||||
@Resource
|
||||
private TrajectoryService trajectoryService;
|
||||
|
||||
@PostMapping("/queryDevice")
|
||||
@Log(value = "查询设备状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryDevice(@RequestBody String whereJson) throws Exception {
|
||||
return new ResponseEntity<>(trajectoryService.queryDevice(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.system.service.dashboard;
|
||||
|
||||
import org.nl.system.service.dashboard.dto.DailyTaskStats;
|
||||
import org.nl.system.service.dashboard.dto.TaskSummary;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhengxuming
|
||||
* @date 2025-8-15 14:03:37
|
||||
*/
|
||||
public interface DashboardService {
|
||||
|
||||
/**
|
||||
* 获取当天任务统计数据
|
||||
*/
|
||||
List<TaskSummary> getTodayTaskStats();
|
||||
|
||||
/**
|
||||
* 获取近7天任务统计数据
|
||||
*/
|
||||
List<DailyTaskStats> getSevenDaysTaskStats();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.nl.system.service.dashboard.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiResponse<T> {
|
||||
private int code; // 状态码:200成功,其他失败
|
||||
private String message; // 消息
|
||||
private T data; // 数据
|
||||
|
||||
public static <T> ApiResponse<T> success(T data) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setCode(200);
|
||||
response.setMessage("success");
|
||||
response.setData(data);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String message) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setCode(500);
|
||||
response.setMessage(message);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.system.service.dashboard.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DailyTaskStats {
|
||||
private String date;
|
||||
private long readyCount;
|
||||
private long busyCount;
|
||||
private long finishedCount;
|
||||
private long cancelCount;
|
||||
private long forcedCompletionCount;
|
||||
private long errorCount;
|
||||
private long totalCount;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.nl.system.service.dashboard.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TaskSummary {
|
||||
private String status; // 任务状态
|
||||
private long count; // 数量
|
||||
private double percentage; // 百分比(用于饼图)
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.system.service.dashboard.impl;
|
||||
|
||||
import cn.hutool.core.date.BetweenFormatter;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.common.utils.ElAdminConstant;
|
||||
import org.nl.common.utils.FileUtil;
|
||||
import org.nl.common.utils.StringUtils;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.system.service.dashboard.DashboardService;
|
||||
import org.nl.system.service.dashboard.dto.DailyTaskStats;
|
||||
import org.nl.system.service.dashboard.dto.TaskSummary;
|
||||
import org.nl.system.service.monitor.MonitorService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.hardware.VirtualMemory;
|
||||
import oshi.software.os.FileSystem;
|
||||
import oshi.software.os.OSFileStore;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
import oshi.util.FormatUtil;
|
||||
import oshi.util.Util;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2020-05-02
|
||||
*/
|
||||
@Service
|
||||
public class DashboardServiceImpl implements DashboardService {
|
||||
|
||||
private final DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Override
|
||||
public List<TaskSummary> getTodayTaskStats() {
|
||||
// 获取今天的起始和结束时间
|
||||
Date todayStart = DateUtil.beginOfDay(new Date());
|
||||
Date todayEnd = DateUtil.endOfDay(new Date());
|
||||
|
||||
// 按状态分组统计
|
||||
List<Map<String, Object>> statusCounts = taskService.countByStatusAndCreateTimeBetween(todayStart, todayEnd);
|
||||
|
||||
// 计算总任务数
|
||||
long total = statusCounts.stream()
|
||||
.mapToLong(item -> Long.parseLong(item.get("count").toString()))
|
||||
.sum();
|
||||
|
||||
// 转换为TaskSummary列表
|
||||
return statusCounts.stream()
|
||||
.map(item -> {
|
||||
TaskSummary summary = new TaskSummary();
|
||||
summary.setStatus(TaskStatusEnum.getNameByIndex(item.get("status").toString()));
|
||||
summary.setCount(Long.parseLong(item.get("count").toString()));
|
||||
summary.setPercentage(total > 0 ? (summary.getCount() * 100.0) / total : 0);
|
||||
return summary;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DailyTaskStats> getSevenDaysTaskStats() {
|
||||
List<DailyTaskStats> statsList = new ArrayList<>();
|
||||
|
||||
// 统计过去7天的数据
|
||||
for (int i = 6; i >= 0; i--) {
|
||||
Date date = DateUtil.offsetDay(new Date(),-i);
|
||||
Date start = DateUtil.beginOfDay(date);
|
||||
Date end = DateUtil.endOfDay(date);
|
||||
|
||||
DailyTaskStats dailyStats = new DailyTaskStats();
|
||||
dailyStats.setDate(DateUtil.formatDate(date));
|
||||
|
||||
// 按状态统计
|
||||
List<Map<String, Object>> statusCounts = taskService.countByStatusAndCreateTimeBetween(start, end);
|
||||
|
||||
// 计算各状态数量
|
||||
long ready = 0, busy = 0, finished = 0, cancel = 0, forced_completion = 0, error = 0;
|
||||
|
||||
for (Map<String, Object> item : statusCounts) {
|
||||
String status = item.get("status").toString();
|
||||
long count = Long.parseLong(item.get("count").toString());
|
||||
if(TaskStatusEnum.READY.getIndex().equals(status)){
|
||||
ready = count;
|
||||
}
|
||||
if(TaskStatusEnum.BUSY.getIndex().equals(status)){
|
||||
busy = count;
|
||||
}
|
||||
if(TaskStatusEnum.FINISHED.getIndex().equals(status)){
|
||||
finished = count;
|
||||
}
|
||||
if(TaskStatusEnum.CANCEL.getIndex().equals(status)){
|
||||
cancel = count;
|
||||
}
|
||||
if(TaskStatusEnum.FORCED_COMPLETION.getIndex().equals(status)){
|
||||
forced_completion = count;
|
||||
}
|
||||
if(TaskStatusEnum.ERROR.getIndex().equals(status)){
|
||||
error = count;
|
||||
}
|
||||
}
|
||||
|
||||
dailyStats.setReadyCount(ready);
|
||||
dailyStats.setBusyCount(busy);
|
||||
dailyStats.setFinishedCount(finished);
|
||||
dailyStats.setCancelCount(cancel);
|
||||
dailyStats.setForcedCompletionCount(forced_completion);
|
||||
dailyStats.setErrorCount(error);
|
||||
dailyStats.setTotalCount(ready + busy + finished + cancel + forced_completion +error);
|
||||
|
||||
statsList.add(dailyStats);
|
||||
}
|
||||
|
||||
return statsList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.nl.system.service.trajectory;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.acs.common.base.CommonService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryBackground;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
public interface TrajectoryBackgroundService extends CommonService<TrajectoryBackground> {
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param whereJson
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
IPage<TrajectoryBackground> queryAll(Map whereJson, PageQuery page);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param entity
|
||||
*/
|
||||
void create(TrajectoryBackground entity);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param entity
|
||||
*/
|
||||
void update(TrajectoryBackground entity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 查询所有已启用的配置设备
|
||||
* @return List<TrajectoryConfiguration>
|
||||
*/
|
||||
List<TrajectoryBackground> queryAllEnable();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.nl.system.service.trajectory;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.acs.common.base.CommonService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
public interface TrajectoryConfigurationService extends CommonService<TrajectoryConfiguration> {
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param whereJson
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
IPage<TrajectoryConfiguration> queryAll(Map whereJson, PageQuery page);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param entity
|
||||
*/
|
||||
void create(TrajectoryConfiguration entity);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param entity
|
||||
*/
|
||||
void update(TrajectoryConfiguration entity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 查询所有已启用的配置设备
|
||||
* @return List<TrajectoryConfiguration>
|
||||
*/
|
||||
List<TrajectoryConfiguration> queryAllEnable();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.system.service.trajectory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
public interface TrajectoryService {
|
||||
|
||||
/**
|
||||
* 查询设备状态
|
||||
*
|
||||
* @param jsonObject 条件
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryDevice(String jsonObject) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package org.nl.system.service.trajectory.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author liejiu
|
||||
*/
|
||||
@Data
|
||||
@TableName("trajectory_background")
|
||||
public class TrajectoryBackground implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 背景图标识
|
||||
*/
|
||||
@TableId
|
||||
private String background_uuid;
|
||||
|
||||
/**
|
||||
* 背景图名称
|
||||
*/
|
||||
private String background_code;
|
||||
|
||||
/**
|
||||
* 背景图片编码
|
||||
*/
|
||||
private String image_code;
|
||||
|
||||
/**
|
||||
* 背景图片地址
|
||||
*/
|
||||
private String image_name;
|
||||
|
||||
/**
|
||||
* 缩放比例(0-1之间 百分比)
|
||||
*/
|
||||
private String zoom_ratio;
|
||||
|
||||
/**
|
||||
* 坐标原点(1左上 2左下 3右上 4右下)
|
||||
*/
|
||||
private String coordinate_origin;
|
||||
|
||||
/**
|
||||
* X坐标最大值
|
||||
*/
|
||||
private String max_x;
|
||||
|
||||
|
||||
/**
|
||||
* Y坐标最大值
|
||||
*/
|
||||
private String max_y;
|
||||
|
||||
/**
|
||||
* 刷新时间(秒)
|
||||
*/
|
||||
private Integer refresh_time;
|
||||
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_active;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private String is_delete;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String create_id;
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改者
|
||||
*/
|
||||
private String update_id;
|
||||
private String update_name;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.nl.system.service.trajectory.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author liejiu
|
||||
*/
|
||||
@Data
|
||||
@TableName("trajectory_configuration")
|
||||
public class TrajectoryConfiguration implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 配置标识
|
||||
*/
|
||||
@TableId
|
||||
private String configuration_uuid;
|
||||
|
||||
/**
|
||||
* 配置名称
|
||||
*/
|
||||
private String configuration_code;
|
||||
|
||||
/**
|
||||
* 图标编码
|
||||
*/
|
||||
private String image_code;
|
||||
|
||||
/**
|
||||
* 图标名称
|
||||
*/
|
||||
private String image_name;
|
||||
|
||||
/**
|
||||
* 图标高度
|
||||
*/
|
||||
private String image_height;
|
||||
|
||||
/**
|
||||
* 图标宽度
|
||||
*/
|
||||
private String image_width;
|
||||
|
||||
/**
|
||||
* 绑定设备编码
|
||||
*/
|
||||
private String device_code;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_active;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private String is_delete;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String create_id;
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改者
|
||||
*/
|
||||
private String update_id;
|
||||
private String update_name;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package org.nl.system.service.trajectory.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.nl.acs.common.base.impl.CommonServiceImpl;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.trajectory.TrajectoryBackgroundService;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryBackground;
|
||||
import org.nl.system.service.trajectory.mapper.TrajectoryBackgroundMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
@Service
|
||||
public class TrajectoryBackgroundImpl extends CommonServiceImpl<TrajectoryBackgroundMapper, TrajectoryBackground> implements TrajectoryBackgroundService {
|
||||
|
||||
@Resource
|
||||
private TrajectoryBackgroundMapper trajectoryBackgroundMapper;
|
||||
|
||||
@Override
|
||||
public IPage<TrajectoryBackground> queryAll(Map whereJson, PageQuery page) {
|
||||
LambdaQueryWrapper<TrajectoryBackground> lam = new LambdaQueryWrapper<>();
|
||||
IPage<TrajectoryBackground> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
trajectoryBackgroundMapper.selectPage(pages,lam);
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(TrajectoryBackground entity) {
|
||||
TrajectoryBackground stage = trajectoryBackgroundMapper.selectOne(new LambdaQueryWrapper<TrajectoryBackground>().eq(TrajectoryBackground::getBackground_code, entity.getBackground_code()));
|
||||
if (ObjectUtil.isNotEmpty(stage)) {
|
||||
throw new BadRequestException("背景图名称[" + entity.getBackground_code() + "]已存在");
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
entity.setIs_active("1");
|
||||
entity.setIs_delete("0");
|
||||
entity.setBackground_uuid(IdUtil.simpleUUID());
|
||||
entity.setCreate_id(currentUserId);
|
||||
entity.setCreate_name(nickName);
|
||||
entity.setCreate_time(now);
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
trajectoryBackgroundMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(TrajectoryBackground entity) {
|
||||
TrajectoryBackground trajectoryBackground = trajectoryBackgroundMapper.selectOne(new LambdaQueryWrapper<TrajectoryBackground>().eq(TrajectoryBackground::getBackground_uuid, entity.getBackground_uuid()));
|
||||
if (trajectoryBackground == null) {
|
||||
throw new BadRequestException("未找到这条数据");
|
||||
}
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(currentUsername);
|
||||
trajectoryBackgroundMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Set<String> ids) {
|
||||
trajectoryBackgroundMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrajectoryBackground> queryAllEnable() {
|
||||
return new LambdaQueryChainWrapper<>(trajectoryBackgroundMapper)
|
||||
.apply("is_delete= '0' AND is_active= '1'")
|
||||
.orderByAsc(TrajectoryBackground::getBackground_uuid)
|
||||
.list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.nl.system.service.trajectory.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.nl.acs.common.base.impl.CommonServiceImpl;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.trajectory.TrajectoryConfigurationService;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryConfiguration;
|
||||
import org.nl.system.service.trajectory.mapper.TrajectoryConfigurationMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
@Service
|
||||
public class TrajectoryConfigurationImpl extends CommonServiceImpl<TrajectoryConfigurationMapper, TrajectoryConfiguration> implements TrajectoryConfigurationService {
|
||||
|
||||
@Resource
|
||||
private TrajectoryConfigurationMapper trajectoryConfigurationMapper;
|
||||
|
||||
@Override
|
||||
public IPage<TrajectoryConfiguration> queryAll(Map whereJson, PageQuery page) {
|
||||
LambdaQueryWrapper<TrajectoryConfiguration> lam = new LambdaQueryWrapper<>();
|
||||
IPage<TrajectoryConfiguration> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
trajectoryConfigurationMapper.selectPage(pages,lam);
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(TrajectoryConfiguration entity) {
|
||||
TrajectoryConfiguration stage = trajectoryConfigurationMapper.selectOne(new LambdaQueryWrapper<TrajectoryConfiguration>().eq(TrajectoryConfiguration::getConfiguration_code, entity.getConfiguration_code()));
|
||||
if (ObjectUtil.isNotEmpty(stage)) {
|
||||
throw new BadRequestException("轨迹图配置编码[" + entity.getConfiguration_code() + "]已存在");
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
entity.setIs_delete("0");
|
||||
entity.setConfiguration_uuid(IdUtil.simpleUUID());
|
||||
entity.setCreate_id(currentUserId);
|
||||
entity.setCreate_name(nickName);
|
||||
entity.setCreate_time(now);
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
trajectoryConfigurationMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(TrajectoryConfiguration entity) {
|
||||
TrajectoryConfiguration trajectoryBackground = trajectoryConfigurationMapper.selectOne(new LambdaQueryWrapper<TrajectoryConfiguration>().eq(TrajectoryConfiguration::getConfiguration_uuid, entity.getConfiguration_uuid()));
|
||||
if (trajectoryBackground == null) {
|
||||
throw new BadRequestException("未找到这条数据");
|
||||
}
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(currentUsername);
|
||||
trajectoryConfigurationMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Set<String> ids) {
|
||||
trajectoryConfigurationMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrajectoryConfiguration> queryAllEnable() {
|
||||
return new LambdaQueryChainWrapper<>(trajectoryConfigurationMapper)
|
||||
.apply("is_delete= '0' AND is_active= '1'")
|
||||
.orderByAsc(TrajectoryConfiguration::getConfiguration_uuid)
|
||||
.list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.nl.system.service.trajectory.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.trajectory.TrajectoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/6/19
|
||||
*/
|
||||
@Service
|
||||
public class TrajectoryImpl implements TrajectoryService {
|
||||
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryDevice(String jsonObject) throws Exception {
|
||||
JSONArray backja = new JSONArray();
|
||||
JSONArray datas = JSONArray.parseArray(jsonObject);
|
||||
//agv
|
||||
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
|
||||
|
||||
if (datas.size() == 0) {
|
||||
throw new BadRequestException("缺少输入参数!");
|
||||
}
|
||||
|
||||
// for (int i = 0; i < datas.size(); i++) {
|
||||
// JSONObject jo = new JSONObject();
|
||||
// JSONObject ja = new JSONObject();
|
||||
// JSONObject data = datas.getJSONObject(i);
|
||||
// String device_code = data.getString("device_code");
|
||||
// Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
// if (ObjectUtil.isEmpty(device)) {
|
||||
// throw new Exception("未找到对应设备:" + device_code);
|
||||
// }
|
||||
// if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
// agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
// jo.put("device_code", agvNdcOneDeviceDriver.getDevice().getDevice_code());
|
||||
// jo.put("x", agvNdcOneDeviceDriver.getX());
|
||||
// jo.put("y", agvNdcOneDeviceDriver.getY());
|
||||
// jo.put("angle", agvNdcOneDeviceDriver.getAngle());
|
||||
// ja.put(agvNdcOneDeviceDriver.getDevice().getDevice_code(),jo);
|
||||
// }
|
||||
// backja.add(ja);
|
||||
// }
|
||||
// JSONObject resultJson = new JSONObject();
|
||||
// resultJson.put("status", HttpStatus.OK.value());
|
||||
// resultJson.put("message", "操作成功");
|
||||
// resultJson.put("data", backja);
|
||||
// return resultJson;
|
||||
JSONObject resultJson = new JSONObject();
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
JSONObject jo = new JSONObject();
|
||||
JSONObject data = datas.getJSONObject(i);
|
||||
String device_code = data.getString("device_code");
|
||||
jo.put("x", rand.nextInt(1001));
|
||||
jo.put("y", rand.nextInt(501));
|
||||
jo.put("angle", rand.nextInt(361));
|
||||
jo.put("device_code", device_code);
|
||||
backja.add(jo);
|
||||
}
|
||||
resultJson.put("status", HttpStatus.OK.value());
|
||||
resultJson.put("message", "操作成功");
|
||||
resultJson.put("data", backja);
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.system.service.trajectory.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryBackground;
|
||||
|
||||
/**
|
||||
* @author liejiu
|
||||
*/
|
||||
@Mapper
|
||||
public interface TrajectoryBackgroundMapper extends BaseMapper<TrajectoryBackground> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.nl.system.service.trajectory.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.system.service.trajectory.dto.TrajectoryConfiguration;
|
||||
|
||||
/**
|
||||
* @author liejiu
|
||||
*/
|
||||
public interface TrajectoryConfigurationMapper extends BaseMapper<TrajectoryConfiguration> {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user