告警JSON文件
This commit is contained in:
parent
928491f16c
commit
2f7bea2518
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.robot;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.warn.RobotWarnCodeMappingVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotWarnCodeMappingService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -13,6 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
@ -94,4 +96,12 @@ public class RobotWarnCodeMappingController {
|
||||
BeanUtils.toBean(list, RobotWarnCodeMappingRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/agv/query")
|
||||
@Operation(summary = "机器人查询告警码值映射")
|
||||
@PreAuthorize("@ss.hasPermission('robot:warn-code-mapping:agvQueryWarnCode')")
|
||||
@PermitAll
|
||||
public void agvQueryWarnCode(HttpServletResponse response) {
|
||||
warnCodeMappingService.agvQueryWarnCode(response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.robot.warn;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RobotWarnCodeMappingVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15754")
|
||||
@ExcelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "告警等级 (1,2,3,4)")
|
||||
@ExcelProperty("告警等级 (1,2,3,4)")
|
||||
private Integer warnLevel;
|
||||
|
||||
@Schema(description = "能不能继续做任务 (0:不能, 1:能)")
|
||||
@ExcelProperty("能不能继续做任务 (0:不能, 1:能)")
|
||||
private Integer doTask;
|
||||
|
||||
@Schema(description = "告警编号")
|
||||
@ExcelProperty("告警编号")
|
||||
private String warnCode;
|
||||
|
||||
@Schema(description = "告警信息")
|
||||
@ExcelProperty("告警信息")
|
||||
private String warnMsg;
|
||||
|
||||
@Schema(description = "告警解决方法")
|
||||
@ExcelProperty("告警解决方法")
|
||||
private String warnSolve;
|
||||
}
|
@ -6,8 +6,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.warn.RobotWarnCodeMappingVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 机器人告警码值映射 Mapper
|
||||
@ -28,4 +31,5 @@ public interface RobotWarnCodeMappingMapper extends BaseMapperX<RobotWarnCodeMap
|
||||
.orderByDesc(RobotWarnCodeMappingDO::getId));
|
||||
}
|
||||
|
||||
List<RobotWarnCodeMappingVO> getAllWarnCodeList();
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.warn.RobotWarnCodeMappingVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
|
||||
/**
|
||||
@ -53,4 +55,5 @@ public interface RobotWarnCodeMappingService {
|
||||
*/
|
||||
PageResult<RobotWarnCodeMappingDO> getWarnCodeMappingPage(RobotWarnCodeMappingPageReqVO pageReqVO);
|
||||
|
||||
void agvQueryWarnCode(HttpServletResponse response);
|
||||
}
|
@ -1,13 +1,35 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.warn.RobotWarnCodeMappingVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnCodeMappingMapper;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -25,11 +47,15 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.WARN_CODE_
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class RobotWarnCodeMappingServiceImpl implements RobotWarnCodeMappingService {
|
||||
|
||||
@Resource
|
||||
private RobotWarnCodeMappingMapper warnCodeMappingMapper;
|
||||
|
||||
@Value("${map.file.warn-path}")
|
||||
private String warnUploadPath;
|
||||
|
||||
@Override
|
||||
public Long createWarnCodeMapping(RobotWarnCodeMappingSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -72,4 +98,60 @@ public class RobotWarnCodeMappingServiceImpl implements RobotWarnCodeMappingServ
|
||||
return warnCodeMappingMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 机器人查询告警码值映射
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void agvQueryWarnCode(HttpServletResponse response) {
|
||||
List<RobotWarnCodeMappingVO> list = warnCodeMappingMapper.getAllWarnCodeList();
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
exportJson(response,list,"warn.json",warnUploadPath);
|
||||
}
|
||||
|
||||
public void exportJson(HttpServletResponse response, Object obj, String fileName, String uploadPath) {
|
||||
try {
|
||||
String jsonString = JSON.toJSONString(obj,
|
||||
SerializerFeature.PrettyFormat,
|
||||
SerializerFeature.WriteMapNullValue,
|
||||
SerializerFeature.WriteDateUseDateFormat);
|
||||
|
||||
//String fullPath = "/" + fileName;
|
||||
File path = new File(uploadPath);
|
||||
if (!path.exists()) {
|
||||
path.mkdirs();
|
||||
}
|
||||
String fullPath = uploadPath + "/" + fileName;
|
||||
File file = new File(fullPath);
|
||||
|
||||
Writer write = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
|
||||
write.write(jsonString);
|
||||
write.flush();
|
||||
write.close();
|
||||
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
// force-download
|
||||
response.setContentType("application/force-download");
|
||||
response.setHeader("Content-Disposition", "attachment;filename="
|
||||
.concat(String.valueOf(URLEncoder.encode(fileName, "UTF-8"))));
|
||||
response.setCharacterEncoding("utf-8");
|
||||
|
||||
OutputStream os = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = fis.read(buf)) != -1) {
|
||||
os.write(buf, 0, len);
|
||||
}
|
||||
fis.close();
|
||||
os.close();
|
||||
boolean delete = file.delete();
|
||||
|
||||
// return file;
|
||||
} catch (Exception e) {
|
||||
log.error("告警码值导出JSON文件失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -217,15 +217,13 @@ justauth:
|
||||
map:
|
||||
file:
|
||||
upload-path: /Users/aikai/Documents/map/ # 地图文件上传路径
|
||||
warn-path: /Users/aikai/Documents/json/ # 告警码值上传路径
|
||||
|
||||
zn:
|
||||
task-no: ZN #任务号开头
|
||||
do_cycle: true #是否开启循环
|
||||
init_height: 0.0 #初始化高度
|
||||
default_scan_height: 0.0 #默认的扫描高度,用于一层扫托盘
|
||||
get_pallet_topic_height: 0.4 #获取托盘位置需要高于托盘的高度
|
||||
default_add_height: 0.1 #默认的添加高度, 车机上报高度加上此高度 = 上一个点位的放托盘高度
|
||||
take_fork_height: 0.1 #托盘高度+此高度=取货的抬叉高度
|
||||
parm: 5000 #等待时间
|
||||
lift_height: 0.1 #抬高托盘高度
|
||||
move_height: 0.1 #行走高度
|
||||
@ -236,15 +234,7 @@ zn:
|
||||
robot_error_level_time: 30 #机器人异常存储时间(秒)
|
||||
task_need_single: true #机器人对同一线库/点位是不是只能有一台机器人做任务 (true:一个点位/线库,只有一台机器人)
|
||||
location_number_reduce: 100000000 #库位排序的差值(下发取货任务,将库位排序减去此值,然后取绝对值)
|
||||
path_planning_distribute_task_time: 10 #10秒内不给PP发两次任务分配
|
||||
robot_doing_action: # 机器人正在做的动作
|
||||
doing_take_msg: 机器人正在取货
|
||||
doing_release_msg: 机器人正在放货
|
||||
complete_task: 机器人完成任务
|
||||
get_pallet_topic: 机器人扫描托盘位置
|
||||
scan: 机器人正在扫描
|
||||
parking_space: 机器人正在前往停车位
|
||||
charge: 机器人正在前往充电位
|
||||
action_entity_cache_time: 172800 #机器人所有动作缓存时间 8小时
|
||||
doing_action_cache_time: 172800 #单个动作缓存时间 8小时
|
||||
robot_chearg: #机器人充电的配置
|
||||
|
@ -9,4 +9,16 @@
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="getAllWarnCodeList"
|
||||
resultType="cn.iocoder.yudao.module.system.controller.admin.robot.warn.RobotWarnCodeMappingVO">
|
||||
select
|
||||
id,
|
||||
warn_level as warnLevel,
|
||||
do_task as doTask,
|
||||
warn_code as warnCode,
|
||||
warn_msg as warnMsg,
|
||||
warn_solve as warnSolve
|
||||
from
|
||||
robot_warn_code_mapping
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user