add:AGV信息

This commit is contained in:
2026-03-24 09:41:44 +08:00
parent d6ed94fd0c
commit 0cbba7e8e3
49 changed files with 5074 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package org.nl.common.utils;
public class IdUtil {
public static Long getLongId() {
return cn.hutool.core.util.IdUtil.getSnowflake(1, 1).nextId();
}
public static String getStringId() {
return String.valueOf(IdUtil.getLongId());
}
}

View File

@@ -0,0 +1,20 @@
package org.nl.common.utils;
import java.io.Serializable;
import java.util.HashMap;
/*
* @author ZZQ
* @Date 2022/11/29 2:55 下午
*/
public class MapOf implements Serializable {
public static <K> HashMap of(K... key) {
HashMap map = new HashMap<>();
for (int i = 0; i < (key.length & ~1); i = i + 2) {
map.put(key[i], key[i + 1]);
}
return map;
}
}

View File

@@ -0,0 +1,80 @@
package org.nl.common.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* 表格分页数据对象
*
* @author Lion Li
*/
@Data
@NoArgsConstructor
public class TableDataInfo<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 列表数据
*/
/**
* 消息状态码
*/
private Integer status;
private String timestamp = DateUtil.now();
/**
* 消息内容
*/
private String message;
/**
* 反馈数据
*/
private Object data;
/**
* 分页
*
* @param list 列表数据
* @param total 总记录数
*/
public TableDataInfo(List<T> list, long total) {
this.data = list;
}
public static <T> TableDataInfo<T> build(IPage<T> page) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setStatus(HttpStatus.HTTP_OK);
rspData.setMessage("操作成功");
rspData.setData(page.getRecords());
return rspData;
}
public static <T> TableDataInfo<T> build(List<T> list) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setStatus(HttpStatus.HTTP_OK);
rspData.setMessage("操作成功");
rspData.setData(list);
return rspData;
}
public static <T> TableDataInfo<T> build() {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setStatus(HttpStatus.HTTP_OK);
rspData.setMessage("操作成功");
return rspData;
}
public static <T> TableDataInfo<T> buildJson(Object result) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setStatus(HttpStatus.HTTP_OK);
rspData.setData(result);
rspData.setMessage("操作成功");
return rspData;
}
}

View File

@@ -0,0 +1,89 @@
package org.nl.common.utils.query;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
import com.baomidou.mybatisplus.core.toolkit.support.ColumnCache;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.utils.MapOf;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
import java.lang.reflect.Type;
import java.util.Map;
/**
* 泛型必须为数据tb对应do:由mybatis管理
* @author ZZQ
* @Date 2022/12/14 6:33 下午
*/
@Data
public class BaseQuery<T> {
/**
* 模糊查询
*/
private String blurry;
/**
* 是否启用
*/
private String is_used;
/**
* 创建时间范围查询
*/
private String start_time;
private String end_time;
/**
* 字段映射Map:指定字段对应QueryWrapper的查询类型
* 字段与数据库字段对应,不支持驼峰
* @see org.nl.common.enums.QueryTEnum
* 通过buid构建
*/
public Map<String, QParam> doP = MapOf.of("blurry", QParam.builder().k(new String[]{"name"}).type(QueryTEnum.LK).build()
,"startTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LT).build()
,"endTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LE).build()
,"sort", QParam.builder().k(new String[]{"sort"}).type(QueryTEnum.BY).build()
);
public QueryWrapper<T> build(){
this.paramMapping();
QueryWrapper<T> wrapper = new QueryWrapper<>();
JSONObject json = (JSONObject)JSONObject.toJSON(this);
Type[] types = ((ParameterizedTypeImpl) this.getClass().getGenericSuperclass()).getActualTypeArguments();
Map<String, ColumnCache> columnMap = LambdaUtils.getColumnMap((Class<?>) types[0]);
String dopStr = "doP";
json.forEach((key, vel) -> {
if (vel != null && !key.equals(dopStr)){
if (vel instanceof String){
if (StringUtils.isNotEmpty((CharSequence) vel)){
QParam qParam = doP.get(key);
if (qParam != null){
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
}else {
ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(key));
if (columnCache!=null){
wrapper.eq(columnCache.getColumn(),vel);
}
}
}
}else {
QParam qParam = doP.get(key);
if (qParam != null){
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
}else {
ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(key));
if (columnCache!=null){
wrapper.eq(columnCache.getColumn(),vel);
}
}
}
}
});
return wrapper;
}
public void paramMapping(){};
}

View File

@@ -0,0 +1,19 @@
package org.nl.common.utils.query;
/**
* s
* @author ZZQ
* @Date 2022/12/14 8:40 下午
*/
@FunctionalInterface
public interface LConsumer<X,Y,Z> {
/**
* 切面
* @param x 、
* @param y 、
* @param z 、
*/
void accept(X x,Y y,Z z);
}

View File

@@ -0,0 +1,135 @@
package org.nl.common.utils.query;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.Locale;
/**
* <p>
* 分页参数
* </p>
*
* @author generator
* @since 2023-11-16
*/
@Data
public class PageQuery implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 分页大小
*/
private Integer size=100;
/**
* 当前页数
*/
private Integer page=0;
/**
* 排序列menu_sort,desc
*/
private String sort;
/**
* 排序的方向desc或者asc
*/
private Boolean isAsc;
/**
* 当前记录起始索引 默认值
*/
public static final int DEFAULT_PAGE_NUM = 1;
/**
* 每页显示记录数 默认值 默认查全部
*/
public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
public <T> Page<T> build() {
Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
if (pageNum <= 0) {
pageNum = DEFAULT_PAGE_NUM;
}
Page<T> page = new Page<>(pageNum, pageSize);
if (StringUtils.isNotEmpty(sort)){
String[] split = sort.split(",");
for (int i = 0; i < (split.length & ~1); i = i + 2) {
String col = split[i];
OrderItem item = new OrderItem();
item.setColumn(col);
item.setAsc(split[i + 1].toLowerCase(Locale.ROOT).equals("asc"));
page.addOrder(item);
}
}
return page;
}
public static void trimStringFields(Object obj) {
if (obj == null) {
return;
}
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
if (field.getType() == String.class) {
field.setAccessible(true);
try {
String value = (String) field.get(obj);
if (value != null) {
field.set(obj, value.trim().toUpperCase());
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
public <R, T> Page<T> build(Class<R> r) {
Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
if (pageNum <= 0) {
pageNum = DEFAULT_PAGE_NUM;
}
Page<T> page = new Page<>(pageNum, pageSize);
if (StringUtils.isNotEmpty(sort)) {
String[] split = sort.split(",");
for (int i = 0; i < (split.length & ~1); i=i+2) {
String col = split[i];
if ("id".equals(col)){
String mId = mappingId(r);
col = StringUtils.isNotEmpty(mId)?mId:col;
}
OrderItem item = new OrderItem();
item.setColumn(col);
item.setAsc(split[i+1].toLowerCase(Locale.ROOT).equals("asc"));
page.addOrder(item);
}
}
return page;
}
private <R> String mappingId(R r){
if (r instanceof Class){
Field[] fields = ((Class) r).getDeclaredFields();
for (Field field : fields) {
TableId[] byType = field.getAnnotationsByType(TableId.class);
if (byType !=null && byType.length>0){
TableId tableId = byType[0];
return tableId.value();
}
}
}
return null;
}
}

View File

@@ -0,0 +1,14 @@
package org.nl.common.utils.query;
import lombok.Builder;
/**
* s
* @author ZZQ
* @Date 2022/12/15 1:41 下午
*/
@Builder
public class QParam {
public String[] k;
public QueryTEnum type;
}

View File

@@ -0,0 +1,81 @@
package org.nl.common.utils.query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import java.util.Collection;
/**
* s
*
* @author ZZQ
* @Date 2022/12/14 8:26 下午
*/
@Getter
public enum QueryTEnum {
//
EQ((q, k, v) -> {
q.eq(k[0], v);
}),
IN((q, key, o) -> {
if (o instanceof Collection) {
q.in(key[0], (Collection) o);
}
}),
LK((q, keys, o) -> {
for (String key : keys) {
q.like(key, o);
}
}),
ORLK((q, k, o) -> {
q.and(query -> {
QueryWrapper queryWrapper = (QueryWrapper) query;
for (int i = 0; i < k.length; i++) {
queryWrapper.like(k[i], o);
if (i != (k.length - 1)) {
queryWrapper.or();
}
}
});
}),
LE((q, k, v) -> {
q.le(k[0], v);
}),
GE((q, k, v) -> {
q.ge(k[0], v);
}),
BY((q, k, v) -> {
q.orderByDesc(k[0], String.valueOf(v));
}),
NO((q, k, v) -> {
q.isNull(k[0]);
}),
NULL_OR_EMPTY((queryWrapper, k, v) -> {
queryWrapper.nested(a -> a.isNull(k[0]).or().eq(k[0], ""));
}),
LT((q, k, v) -> {
q.lt(k[0], v);
}),
GT((q, k, v) -> {
q.gt(k[0], v);
}),
OREQ((q, k, v) -> {
if (StringUtils.isBlank((String) v)) {
q.isNull(k[0]);
} else {
q.eq(k[0], v);
}
});
private LConsumer<QueryWrapper<T>, String[], Object> doP;
QueryTEnum(LConsumer<QueryWrapper<T>, String[], Object> doP) {
this.doP = doP;
}
public static void build(QueryTEnum type, QueryWrapper q, String[] k, Object v) {
type.getDoP().accept(q, k, v);
}
}

View File

@@ -0,0 +1,83 @@
package org.nl.modules.layout.car.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import org.nl.common.utils.query.PageQuery;
import org.nl.modules.layout.car.dao.AgvCarQuery;
import org.nl.modules.layout.car.dto.AgvCarDto;
import org.nl.modules.layout.car.entity.AgvCar;
import org.nl.modules.layout.car.service.AgvCarService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
/**
* 车辆信息Controller
*/
@RestController
@RequestMapping("/api/agvCar")
@SaIgnore
public class AgvCarController {
@Autowired
private AgvCarService agvCarService;
/**
* 分页查询
*/
@GetMapping("/list")
public ResponseEntity<Object> pageList(AgvCarQuery query, PageQuery pageQuery) {
return new ResponseEntity<>(agvCarService.page(pageQuery.build(), query.build()), HttpStatus.OK);
}
/**
* 查询所有
*/
@GetMapping("/all")
@SaIgnore
public ResponseEntity<Object> list() {
return new ResponseEntity<>(agvCarService.list(), HttpStatus.OK);
}
/**
* 根据ID查询
*/
@GetMapping("/{id}")
public ResponseEntity<Object> getById(@PathVariable Integer id) {
return new ResponseEntity<>(agvCarService.getById(id), HttpStatus.OK);
}
/**
* 新增
*/
@PostMapping
public ResponseEntity<Object> add(@RequestBody AgvCarDto dto) {
AgvCar entity = new AgvCar();
BeanUtils.copyProperties(dto, entity);
agvCarService.save(entity);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
/**
* 修改
*/
@PutMapping
public ResponseEntity<Object> update(@RequestBody AgvCarDto dto) {
AgvCar entity = new AgvCar();
BeanUtils.copyProperties(dto, entity);
agvCarService.updateById(entity);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
/**
* 删除
*/
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
agvCarService.removeByIds(Arrays.asList(ids));
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,41 @@
package org.nl.modules.layout.car.dao;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.utils.query.BaseQuery;
import org.nl.modules.layout.car.entity.AgvCar;
/**
* 车辆信息查询对象
*/
public class AgvCarQuery extends BaseQuery<AgvCar> {
/**
* 车辆ID
*/
private String carId;
/**
* 车辆类型
*/
private String type;
public String getCarId() {
return carId;
}
public void setCarId(String carId) {
if (StringUtils.isNotEmpty(carId)){
this.carId = carId;
}
}
public String getType() {
return type;
}
public void setType(String type) {
if (StringUtils.isNotEmpty(type)){
this.type = type;
}
}
}

View File

@@ -0,0 +1,34 @@
package org.nl.modules.layout.car.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 车辆信息DTO
*/
@Data
public class AgvCarDto implements Serializable {
private Integer id;
/**
* 车辆ID
*/
private String carId;
/**
* 车辆类型
*/
private String type;
/**
* 车辆图标地址
*/
private String icon;
/**
* 图标文件ID
*/
private String fileId;
}

View File

@@ -0,0 +1,47 @@
package org.nl.modules.layout.car.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 车辆信息表
*/
@Data
@TableName("agv_car")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AgvCar implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 车辆ID
*/
@TableField("car_id")
private String carId;
/**
* 车辆类型
*/
private String type;
/**
* 车辆图标地址
*/
private String icon;
/**
* 车辆图标地址
*/
@TableField("file_id")
private String fileId;
}

View File

@@ -0,0 +1,12 @@
package org.nl.modules.layout.car.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.nl.modules.layout.car.entity.AgvCar;
/**
* 车辆信息Mapper
*/
@Mapper
public interface AgvCarMapper extends BaseMapper<AgvCar> {
}

View File

@@ -0,0 +1,10 @@
package org.nl.modules.layout.car.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.modules.layout.car.entity.AgvCar;
/**
* 车辆信息Service
*/
public interface AgvCarService extends IService<AgvCar> {
}

View File

@@ -0,0 +1,14 @@
package org.nl.modules.layout.car.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.modules.layout.car.entity.AgvCar;
import org.nl.modules.layout.car.mapper.AgvCarMapper;
import org.nl.modules.layout.car.service.AgvCarService;
import org.springframework.stereotype.Service;
/**
* 车辆信息ServiceImpl
*/
@Service
public class AgvCarServiceImpl extends ServiceImpl<AgvCarMapper, AgvCar> implements AgvCarService {
}

View File

@@ -0,0 +1,82 @@
package org.nl.modules.layout.device.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import org.nl.common.utils.query.PageQuery;
import org.nl.modules.layout.device.dao.BaseDataDeviceQuery;
import org.nl.modules.layout.device.dto.BaseDataDeviceDto;
import org.nl.modules.layout.device.entity.BaseDataDevice;
import org.nl.modules.layout.device.service.BaseDataDeviceService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Date;
/**
* 设备信息Controller
*/
@RestController
@RequestMapping("/api/baseDevice")
@SaIgnore
public class BaseDataDeviceController {
@Autowired
private BaseDataDeviceService baseDataDeviceService;
/**
* 分页查询
*/
@GetMapping("/list")
public ResponseEntity<Object> pageList(BaseDataDeviceQuery query, PageQuery pageQuery) {
return new ResponseEntity<>(baseDataDeviceService.page(pageQuery.build(), query.build()), HttpStatus.OK);
}
@GetMapping("/component")
@SaIgnore
public ResponseEntity<Object> List() {
return new ResponseEntity<>(baseDataDeviceService.list(), HttpStatus.OK);
}
/**
* 根据ID查询
*/
@GetMapping("/{id}")
public ResponseEntity<Object> getById(@PathVariable Integer id) {
return new ResponseEntity<>(baseDataDeviceService.getById(id), HttpStatus.OK);
}
/**
* 新增
*/
@PostMapping
public ResponseEntity<Object> add(@RequestBody BaseDataDeviceDto dto) {
BaseDataDevice entity = new BaseDataDevice();
BeanUtils.copyProperties(dto, entity);
entity.setCreateTime(new Date());
baseDataDeviceService.save(entity);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
/**
* 修改
*/
@PutMapping
public ResponseEntity<Object> update(@RequestBody BaseDataDeviceDto dto) {
BaseDataDevice entity = new BaseDataDevice();
BeanUtils.copyProperties(dto, entity);
entity.setUpdateTime(new Date());
baseDataDeviceService.updateById(entity);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
/**
* 删除
*/
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
baseDataDeviceService.removeByIds(Arrays.asList(ids));
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,56 @@
package org.nl.modules.layout.device.dao;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.utils.query.BaseQuery;
import org.nl.modules.layout.device.entity.BaseDataDevice;
/**
* 设备信息查询对象
*/
public class BaseDataDeviceQuery extends BaseQuery<BaseDataDevice> {
/**
* 设备编码
*/
private String code;
/**
* 设备类型
*/
private String type;
/**
* 所属区域
*/
private String region;
public String getCode() {
return code;
}
public void setCode(String code) {
if (StringUtils.isNotEmpty(code)){
this.code = code;
}
}
public String getType() {
return type;
}
public void setType(String type) {
if (StringUtils.isNotEmpty(type)){
this.type = type;
}
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
if (StringUtils.isNotEmpty(region)){
this.region = region;
}
}
}

View File

@@ -0,0 +1,100 @@
package org.nl.modules.layout.device.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 设备信息DTO
*/
@Data
public class BaseDataDeviceDto implements Serializable {
private Integer id;
/**
* 编码
*/
private String code;
/**
* 设备名称
*/
private String name;
/**
* 设备类型
*/
private String type;
/**
* 设备描述
*/
private String description;
/**
* 设备扩展信息
*/
private String editParam;
/**
* 图标地址
*/
private String icon;
/**
* 图标文件ID
*/
private String fileId;
/**
* 所属区域
*/
private String region;
/**
* x坐标
*/
private Integer x;
/**
* y坐标
*/
private Integer y;
/**
* 角度
*/
private Integer angle;
/**
* 放大比例
*/
private Integer size;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建用户
*/
private String createName;
/**
* 修改时间
*/
private Date updateTime;
/**
* 修改用户
*/
private String updateName;
/**
* 是否启用
*/
private Boolean isUsed;
}

View File

@@ -0,0 +1,119 @@
package org.nl.modules.layout.device.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 设备信息表
*/
@Data
@TableName("base_data_device")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BaseDataDevice implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 编码
*/
private String code;
/**
* 设备名称
*/
private String name;
/**
* 设备类型
*/
private String type;
/**
* 设备描述
*/
private String description;
/**
* 设备扩展信息
*/
@TableField("edit_param")
private String editParam;
/**
* 图标地址
*/
private String icon;
/**
* 图标文件ID
*/
@TableField("file_id")
private String fileId;
/**
* 所属区域
*/
private String region;
/**
* x坐标
*/
private Integer x;
/**
* y坐标
*/
private Integer y;
/**
* 角度
*/
private Integer angle;
/**
* 放大比例
*/
private Integer size;
/**
* 创建时间
*/
@TableField("create_time")
private Date createTime;
/**
* 创建用户
*/
@TableField("create_name")
private String createName;
/**
* 修改时间
*/
@TableField("update_time")
private Date updateTime;
/**
* 修改用户
*/
@TableField("update_name")
private String updateName;
/**
* 是否启用
*/
@TableField("is_used")
private Boolean isUsed;
}

View File

@@ -0,0 +1,12 @@
package org.nl.modules.layout.device.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.nl.modules.layout.device.entity.BaseDataDevice;
/**
* 设备信息Mapper
*/
@Mapper
public interface BaseDataDeviceMapper extends BaseMapper<BaseDataDevice> {
}

View File

@@ -0,0 +1,10 @@
package org.nl.modules.layout.device.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.modules.layout.device.entity.BaseDataDevice;
/**
* 设备信息Service
*/
public interface BaseDataDeviceService extends IService<BaseDataDevice> {
}

View File

@@ -0,0 +1,14 @@
package org.nl.modules.layout.device.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.modules.layout.device.entity.BaseDataDevice;
import org.nl.modules.layout.device.mapper.BaseDataDeviceMapper;
import org.nl.modules.layout.device.service.BaseDataDeviceService;
import org.springframework.stereotype.Service;
/**
* 设备信息ServiceImpl
*/
@Service
public class BaseDataDeviceServiceImpl extends ServiceImpl<BaseDataDeviceMapper, BaseDataDevice> implements BaseDataDeviceService {
}

View File

@@ -0,0 +1,74 @@
package org.nl.modules.layout.deviceLayout.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import org.nl.common.utils.query.PageQuery;
import org.nl.modules.layout.deviceLayout.dao.AgvLayoutDeviceQuery;
import org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto;
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
import org.nl.modules.layout.deviceLayout.service.AgvLayoutDeviceService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
/**
* 设备布局Controller
*/
@RestController
@RequestMapping("/api/deviceLayout")
@SaIgnore
public class AgvLayoutDeviceController {
@Autowired
private AgvLayoutDeviceService agvLayoutDeviceService;
/**
* 分页查询
*/
@GetMapping("/list")
public ResponseEntity<Object> pageList(AgvLayoutDeviceQuery query, PageQuery pageQuery) {
return new ResponseEntity<>(agvLayoutDeviceService.page(pageQuery.build(), query.build()), HttpStatus.OK);
}
/**
* 根据ID查询
*/
@GetMapping("/{id}")
public ResponseEntity<Object> getById(@PathVariable Integer id) {
return new ResponseEntity<>(agvLayoutDeviceService.getById(id), HttpStatus.OK);
}
/**
* 新增
*/
@PostMapping
public ResponseEntity<Object> add(@RequestBody AgvLayoutDeviceDto dto) {
AgvLayoutDevice entity = new AgvLayoutDevice();
BeanUtils.copyProperties(dto, entity);
agvLayoutDeviceService.save(entity);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
/**
* 修改
*/
@PutMapping
public ResponseEntity<Object> update(@RequestBody AgvLayoutDeviceDto dto) {
AgvLayoutDevice entity = new AgvLayoutDevice();
BeanUtils.copyProperties(dto, entity);
agvLayoutDeviceService.updateById(entity);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
/**
* 删除
*/
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
agvLayoutDeviceService.removeByIds(Arrays.asList(ids));
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,29 @@
package org.nl.modules.layout.deviceLayout.dao;
import lombok.Data;
import org.nl.common.utils.query.BaseQuery;
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
/**
* 设备布局查询对象
*/
@Data
public class AgvLayoutDeviceQuery extends BaseQuery<AgvLayoutDevice> {
/**
* 地图布局ID
*/
private Integer mapLayoutId;
/**
* 设备ID
*/
private Integer deviceId;
/**
* 类型
*/
private String type;
}

View File

@@ -0,0 +1,65 @@
package org.nl.modules.layout.deviceLayout.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 设备布局DTO
*/
@Data
public class AgvLayoutDeviceDto implements Serializable {
private Integer id;
/**
* 地图布局ID
*/
private Integer mapLayoutId;
/**
* 设备ID
*/
private Integer deviceId;
/**
* 编码
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 类型
*/
private String type;
/**
* x坐标
*/
private Integer x;
/**
* y坐标
*/
private Integer y;
/**
* 角度
*/
private Integer angle;
/**
* 放大比例
*/
private Integer size;
/**
* 图标
*/
private String icon;
private String fileId;
}

View File

@@ -0,0 +1,80 @@
package org.nl.modules.layout.deviceLayout.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 设备布局表
*/
@Data
@TableName("agv_layout_device")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AgvLayoutDevice implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 地图布局ID
*/
@TableField("map_layout_id")
private Integer mapLayoutId;
/**
* 设备ID
*/
@TableField("device_id")
private Integer deviceId;
/**
* 编码
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 类型
*/
private String type;
/**
* x坐标
*/
private Integer x;
/**
* y坐标
*/
private Integer y;
/**
* 角度
*/
private Integer angle;
/**
* 放大比例
*/
private Integer size;
/**
* 图标
*/
private String icon;
@TableField("file_id")
private String fileId;
}

View File

@@ -0,0 +1,12 @@
package org.nl.modules.layout.deviceLayout.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
/**
* 设备布局Mapper
*/
@Mapper
public interface AgvLayoutDeviceMapper extends BaseMapper<AgvLayoutDevice> {
}

View File

@@ -0,0 +1,10 @@
package org.nl.modules.layout.deviceLayout.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
/**
* 设备布局Service
*/
public interface AgvLayoutDeviceService extends IService<AgvLayoutDevice> {
}

View File

@@ -0,0 +1,14 @@
package org.nl.modules.layout.deviceLayout.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
import org.nl.modules.layout.deviceLayout.mapper.AgvLayoutDeviceMapper;
import org.nl.modules.layout.deviceLayout.service.AgvLayoutDeviceService;
import org.springframework.stereotype.Service;
/**
* 设备布局ServiceImpl
*/
@Service
public class AgvLayoutDeviceServiceImpl extends ServiceImpl<AgvLayoutDeviceMapper, AgvLayoutDevice> implements AgvLayoutDeviceService {
}

View File

@@ -0,0 +1,107 @@
package org.nl.modules.layout.mapLayout.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.utils.query.PageQuery;
import org.nl.modules.layout.mapLayout.dao.AgvLayoutMapQuery;
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
import org.nl.modules.layout.mapLayout.dto.AgvStatus;
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
import org.nl.modules.layout.mapLayout.service.AgvLayoutMapService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* 地图布局Controller
*/
@RestController
@RequestMapping("/api/mapLayout")
@SaIgnore
public class AgvLayoutMapController {
@Autowired
private AgvLayoutMapService agvLayoutMapService;
/**
* 分页查询
*/
@GetMapping("/list")
@SaIgnore
public ResponseEntity<Object> pageList(AgvLayoutMapQuery query, PageQuery pageQuery) {
return new ResponseEntity<>(agvLayoutMapService.page(pageQuery.build(), query.build()), HttpStatus.OK);
}
/**
* 根据ID查询
*/
@GetMapping("/{id}")
public ResponseEntity<Object> getById(@PathVariable Integer id) {
return new ResponseEntity<>(agvLayoutMapService.getById(id), HttpStatus.OK);
}
/**
* 新增
*/
@PostMapping
public ResponseEntity<Object> add(@RequestBody AgvLayoutMapDto dto) {
agvLayoutMapService.saveLayout(dto);
return new ResponseEntity<>(HttpStatus.OK);
}
/**
* 修改
*/
@PutMapping
public ResponseEntity<Object> update(@RequestBody AgvLayoutMapDto dto) {
AgvLayoutMap entity = new AgvLayoutMap();
BeanUtils.copyProperties(dto, entity);
agvLayoutMapService.updateById(entity);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
/**
* 删除
*/
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
agvLayoutMapService.removeByIds(Arrays.asList(ids));
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("initLayout")
@SaIgnore
public ResponseEntity<AgvLayoutMapDto> initLayout(Long id) {
AgvLayoutMapDto agvLayoutMapDto = agvLayoutMapService.initLayoutMap(id);
return new ResponseEntity<>(agvLayoutMapDto,HttpStatus.OK);
}
@GetMapping("status")
@SaIgnore
public ResponseEntity<List> status(String carId) {
List<AgvStatus> list = new ArrayList<>();
for (int i = 0; i < 4; i++) {
AgvStatus build = AgvStatus.builder()
.status("2")
.carId(String.valueOf(i + 1))
.action("请求取货")
.actionInfo("申请取货中")
.taskCode("33876")
.icon("/Users/mima0000/Desktop/car.png")
.fileId("3029")
.x(new Random().nextInt(1189) + 100)
.y(new Random().nextInt(1189) + 100)
.power(66)
.angle(new Random().nextInt(160) + 10).build();
list.add(build);
}
return new ResponseEntity<>(list,HttpStatus.OK);
}
}

View File

@@ -0,0 +1,28 @@
package org.nl.modules.layout.mapLayout.dao;
import lombok.Data;
import org.nl.common.utils.query.BaseQuery;
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
/**
* 地图布局查询对象
*/
@Data
public class AgvLayoutMapQuery extends BaseQuery<AgvLayoutMap> {
/**
* 地图ID
*/
private String mapId;
/**
* 版本
*/
private String version;
/**
* 是否启用
*/
private Boolean enable;
}

View File

@@ -0,0 +1,64 @@
package org.nl.modules.layout.mapLayout.dto;
import lombok.Data;
import org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto;
import java.io.Serializable;
import java.util.List;
/**
* 地图布局DTO
*/
@Data
public class AgvLayoutMapDto implements Serializable {
private Integer id;
/**
* 地图ID
*/
private String mapId;
/**
* 地图名称
*/
private String mapName;
/**
* 版本
*/
private String version;
/**
* 地图URL
*/
private String url;
/**
* 高度
*/
private Integer height;
/**
* 宽度
*/
private Integer width;
/**
* x坐标
*/
private Integer x;
/**
* y坐标
*/
private Integer y;
/**
* 是否启用
*/
private Boolean enable;
private List<AgvLayoutDeviceDto> device;
}

View File

@@ -0,0 +1,65 @@
package org.nl.modules.layout.mapLayout.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AgvStatus {
/**
* 车辆ID
*/
private String carId;
/**
* 车辆类型
*/
private String type;
/**
* 图标地址
*/
private String icon="/Users/mima0000/Desktop/car.png";
/**
* 车辆图片地址ID
*/
private String fileId;
/**
* 状态类型1.休息 2.正常运行 3.异常
*/
private String status;
/**
* 异常时的异常信息
*/
private String error;
/**
* 动作状态:请求取货/取货完成/请求放货/放货完成
*/
private String action;
/**
* 动作交互信息
*/
private String actionInfo;
/**
* 任务号
*/
private String taskCode;
/**
* 坐标X
*/
private Integer x;
/**
* 坐标Y
*/
private Integer y;
/**
* 航向角
*/
private Integer angle;
/**
* 电量
*/
private Integer power;
}

View File

@@ -0,0 +1,73 @@
package org.nl.modules.layout.mapLayout.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 地图布局表
*/
@Data
@TableName("agv_layout_map")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AgvLayoutMap implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 地图ID
*/
@TableField("map_id")
private String mapId;
/**
* 地图名称
*/
@TableField("map_name")
private String mapName;
/**
* 版本
*/
private String version;
/**
* 地图URL
*/
private String url;
/**
* 高度
*/
private Integer height;
/**
* 宽度
*/
private Integer width;
/**
* x坐标
*/
private Integer x;
/**
* y坐标
*/
private Integer y;
/**
* 是否启用
*/
private Boolean enable;
}

View File

@@ -0,0 +1,21 @@
package org.nl.modules.layout.mapLayout.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
/**
* 地图布局Mapper
*/
@Mapper
public interface AgvLayoutMapMapper extends BaseMapper<AgvLayoutMap> {
@Insert("INSERT INTO agv_layout_map (map_id,map_name, url, height, width, x, y) VALUES (#{mapId},#{mapName}, #{url}, #{height}, #{width}, #{x}, #{y})")
@Options(useGeneratedKeys = true, keyProperty = "id")
void insertUseGeneratedKeys(AgvLayoutMap map);
AgvLayoutMapDto initLayoutMap(Long id);
}

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.modules.layout.mapLayout.mapper.AgvLayoutMapMapper">
<resultMap id="mapLayoutResultMap" type="org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto">
<result property="mapId" column="map_id"/>
<result property="width" column="width"/>
<result property="height" column="height"/>
<result property="url" column="url"/>
<result property="x" column="x"/>
<result property="y" column="y"/>
<!-- 映射设备列表 -->
<collection property="device" ofType="org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto">
<id property="id" column="id"/>
<id property="deviceId" column="device_id"/>
<result property="code" column="code"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="icon" column="icon"/>
<result property="fileId" column="file_id"/>
<result property="x" column="dx"/>
<result property="y" column="dy"/>
<result property="angle" column="angle"/>
<result property="size" column="size"/>
</collection>
</resultMap>
<select id="initLayoutMap" resultMap="mapLayoutResultMap">
SELECT
m.map_id ,
m.width,
m.height,
m.url,
m.x ,
m.y ,
d.id ,
d.device_id ,
d.code ,
d.name,
d.type,
d.icon,
d.file_id,
d.x as dx,
d.y as dy,
d.angle,
d.size
FROM agv_layout_map m
LEFT JOIN agv_layout_device d ON m.id = d.map_layout_id
WHERE m.id = #{id}
</select>
</mapper>

View File

@@ -0,0 +1,14 @@
package org.nl.modules.layout.mapLayout.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
/**
* 地图布局Service
*/
public interface AgvLayoutMapService extends IService<AgvLayoutMap> {
void saveLayout(AgvLayoutMapDto dto);
AgvLayoutMapDto initLayoutMap(Long id);
}

View File

@@ -0,0 +1,64 @@
package org.nl.modules.layout.mapLayout.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto;
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
import org.nl.modules.layout.deviceLayout.mapper.AgvLayoutDeviceMapper;
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
import org.nl.modules.layout.mapLayout.mapper.AgvLayoutMapMapper;
import org.nl.modules.layout.mapLayout.service.AgvLayoutMapService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
/**
* 地图布局ServiceImpl
*/
@Service
public class AgvLayoutMapServiceImpl extends ServiceImpl<AgvLayoutMapMapper, AgvLayoutMap> implements AgvLayoutMapService {
@Resource
private AgvLayoutDeviceMapper agvLayoutDeviceMapper;
@Override
@Transactional
public void saveLayout(AgvLayoutMapDto dto) {
AgvLayoutMap layoutMap = AgvLayoutMap.builder()
.mapId(dto.getMapId())
.mapName(dto.getMapName())
.url(dto.getUrl())
.width(dto.getWidth())
.version("1")
.height(dto.getHeight())
.x(dto.getX())
.y(dto.getY()).build();
this.baseMapper.insertUseGeneratedKeys(layoutMap);
List<AgvLayoutDeviceDto> deviceLayout = dto.getDevice();
if (!CollectionUtils.isEmpty(deviceLayout)){
for (AgvLayoutDeviceDto device : deviceLayout) {
AgvLayoutDevice layoutDevice = AgvLayoutDevice.builder()
.deviceId(device.getDeviceId())
.mapLayoutId(layoutMap.getId())
.name(device.getName())
.code(device.getCode())
.type(device.getType())
.angle(device.getAngle())
.x(device.getX())
.y(device.getY())
.size(device.getSize())
.icon(device.getIcon())
.fileId(device.getFileId()).build();
agvLayoutDeviceMapper.insert(layoutDevice);
}
}
}
@Override
public AgvLayoutMapDto initLayoutMap(Long id) {
return this.baseMapper.initLayoutMap(id);
}
}