add:agv模块看板
This commit is contained in:
114
nl-agv/pom.xml
114
nl-agv/pom.xml
@@ -14,120 +14,6 @@
|
||||
<description>nl-agv</description>
|
||||
<url/>
|
||||
<dependencies>
|
||||
|
||||
<!-- nashorn-core -->
|
||||
<dependency>
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- aop -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- processor -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-trans -->
|
||||
<dependency>
|
||||
<groupId>com.fhs-opensource</groupId>
|
||||
<artifactId>easy-trans-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-trans-mybatis-plus-extend -->
|
||||
<dependency>
|
||||
<groupId>com.fhs-opensource</groupId>
|
||||
<artifactId>easy-trans-mybatis-plus-extend</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- pinyin4j -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ip2region -->
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-poi -->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- sm-crypto -->
|
||||
<dependency>
|
||||
<groupId>com.antherd</groupId>
|
||||
<artifactId>sm-crypto</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easyexcel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
<!--业务依赖-->
|
||||
<dependency>
|
||||
<groupId>org.nl</groupId>
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.agv.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.nl.agv.service.AgvCarService;
|
||||
import org.nl.agv.service.entity.AgvCar;
|
||||
import org.nl.agv.service.query.AgvCarQuery;
|
||||
import org.nl.common.page.PageQuery;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.agv.service.dto.AgvStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Tag(name = "AGV模块")
|
||||
@RestController()
|
||||
@RequestMapping("/api/agv")
|
||||
@Validated
|
||||
public class AgvCarController {
|
||||
static {
|
||||
System.out.println("初始化AGV模块------------");
|
||||
}
|
||||
@Autowired
|
||||
private AgvCarService agvCarService;
|
||||
|
||||
@GetMapping("status")
|
||||
public CommonResult<List> status() {
|
||||
List<AgvStatus> list = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
AgvStatus build = AgvStatus.builder().status(2)
|
||||
.carId(String.valueOf(i + 1))
|
||||
.statusInfo("运行中").type("1")
|
||||
.action("请求取货")
|
||||
.icon("/Users/mima0000/Desktop/car.png")
|
||||
.actionInfo("申请取货")
|
||||
.x(String.valueOf(new Random().nextInt(1189) + 100))
|
||||
.y(String.valueOf(new Random().nextInt(889) + 100)).power("67")
|
||||
.angle("180").build();
|
||||
list.add(build);
|
||||
}
|
||||
return CommonResult.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* agv列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public CommonResult list(AgvCarQuery query, PageQuery pageQuery) {
|
||||
return CommonResult.data(agvCarService.page(pageQuery.build(), query.build()));
|
||||
}
|
||||
|
||||
/**
|
||||
* agv列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("save")
|
||||
public CommonResult save(AgvCar car) {
|
||||
agvCarService.save(car);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 车俩基础信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("agvCar")
|
||||
public CommonResult<AgvCar> agvCar(String carId) {
|
||||
AgvCar car = agvCarService.getOne(new LambdaQueryWrapper<AgvCar>().eq(AgvCar::getCarId, carId));
|
||||
return CommonResult.data(car);
|
||||
}
|
||||
|
||||
}
|
||||
11
nl-agv/src/main/java/org/nl/agv/service/AgvCarService.java
Normal file
11
nl-agv/src/main/java/org/nl/agv/service/AgvCarService.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package org.nl.agv.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.agv.service.entity.AgvCar;
|
||||
import org.nl.agv.service.mapper.AgvCarMapper;
|
||||
import org.nl.layout.service.dto.MapLayout;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
|
||||
public interface AgvCarService extends IService<AgvCar> {
|
||||
|
||||
}
|
||||
@@ -1,18 +1,27 @@
|
||||
package org.nl.server.dto;
|
||||
package org.nl.agv.service.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AgvStatus {
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private String agvId;
|
||||
private String carId;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 图标
|
||||
* 图标地址
|
||||
*/
|
||||
private String icon;
|
||||
private String icon="/Users/mima0000/Desktop/car.png";
|
||||
/**
|
||||
* 电量
|
||||
*/
|
||||
@@ -28,7 +37,7 @@ public class AgvStatus {
|
||||
* 故障中
|
||||
* 低电量
|
||||
*/
|
||||
private String statusType;
|
||||
private String statusInfo;
|
||||
/**
|
||||
* 状态类型:1.休息 2.正常运行 3.异常
|
||||
*/
|
||||
@@ -40,7 +49,7 @@ public class AgvStatus {
|
||||
/**
|
||||
* 动作交互信息
|
||||
*/
|
||||
private String actionMsg;
|
||||
private String actionInfo;
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
35
nl-agv/src/main/java/org/nl/agv/service/entity/AgvCar.java
Normal file
35
nl-agv/src/main/java/org/nl/agv/service/entity/AgvCar.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package org.nl.agv.service.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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 Long id;
|
||||
/**
|
||||
* 车辆ID项目初始化的时创建
|
||||
*/
|
||||
private String carId;
|
||||
/**
|
||||
* 车辆类型:ps车 NT车...
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 车辆图片
|
||||
*/
|
||||
private String icon;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.agv.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.nl.agv.service.AgvCarService;
|
||||
import org.nl.agv.service.entity.AgvCar;
|
||||
import org.nl.agv.service.mapper.AgvCarMapper;
|
||||
import org.nl.common.localStorage.service.LocalStorageService;
|
||||
import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.layout.service.AgvLayoutService;
|
||||
import org.nl.layout.service.dto.DeviceLayout;
|
||||
import org.nl.layout.service.dto.MapLayout;
|
||||
import org.nl.layout.service.entity.AgvLayoutDevice;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
import org.nl.layout.service.mapper.AgvLayoutDeviceMapper;
|
||||
import org.nl.layout.service.mapper.AgvLayoutMapMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class AgvCarServiceImpl extends ServiceImpl<AgvCarMapper, AgvCar> implements AgvCarService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.nl.agv.service.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.agv.service.entity.AgvCar;
|
||||
|
||||
@Mapper
|
||||
public interface AgvCarMapper extends BaseMapper<AgvCar> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.nl.agv.service.query;
|
||||
|
||||
import org.nl.agv.service.entity.AgvCar;
|
||||
import org.nl.common.page.BaseQuery;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
|
||||
public class AgvCarQuery extends BaseQuery<AgvCar> {
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.layout.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.nl.agv.service.AgvCarService;
|
||||
import org.nl.common.exception.CommonException;
|
||||
import org.nl.common.page.PageQuery;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.agv.service.dto.AgvStatus;
|
||||
import org.nl.layout.service.AgvLayoutService;
|
||||
import org.nl.layout.service.dto.MapLayout;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
import org.nl.layout.service.query.MapLayoutQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Tag(name = "AGV模块")
|
||||
@RestController()
|
||||
@RequestMapping("/api/agv/map")
|
||||
@Validated
|
||||
@SaIgnore
|
||||
public class AgvLayoutController {
|
||||
static {
|
||||
System.out.println("初始化AGV模块------------");
|
||||
}
|
||||
@Autowired
|
||||
private AgvLayoutService agvLayoutService;
|
||||
|
||||
@GetMapping("status")
|
||||
public CommonResult<List> status() {
|
||||
List<AgvStatus> list = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
AgvStatus build = AgvStatus.builder().status(2)
|
||||
.carId(String.valueOf(i + 1))
|
||||
.statusInfo("运行中").type("1")
|
||||
.action("请求取货")
|
||||
.actionInfo("申请取货")
|
||||
.x(String.valueOf(new Random().nextInt(1189) + 100))
|
||||
.y(String.valueOf(new Random().nextInt(889) + 100)).power("67")
|
||||
.angle("180").build();
|
||||
list.add(build);
|
||||
}
|
||||
return CommonResult.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图列表
|
||||
* @param query
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public CommonResult queruList(MapLayoutQuery query, PageQuery pageQuery) {
|
||||
Page<AgvLayoutMap> page = agvLayoutService.page(pageQuery.build(), query.build());
|
||||
return CommonResult.data(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存地图
|
||||
* @param mapLayout
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("save")
|
||||
public CommonResult save(@RequestBody MapLayout mapLayout) {
|
||||
agvLayoutService.saveLayout(mapLayout);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用地图
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("enable")
|
||||
public CommonResult queruList(Long id) {
|
||||
agvLayoutService.update(new LambdaUpdateWrapper<AgvLayoutMap>()
|
||||
.set(AgvLayoutMap::getEnable,false));
|
||||
agvLayoutService.update(new LambdaUpdateWrapper<AgvLayoutMap>()
|
||||
.set(AgvLayoutMap::getEnable,true).eq(AgvLayoutMap::getId,id));
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化地图数据,没传ID
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("initLayout")
|
||||
public CommonResult initLayout(Long id) {
|
||||
if (id==null){
|
||||
//如果没有传则返回最新版本
|
||||
AgvLayoutMap one = agvLayoutService.getOne(new LambdaQueryWrapper<AgvLayoutMap>()
|
||||
.orderByDesc(AgvLayoutMap::getVersion)
|
||||
.eq(AgvLayoutMap::getEnable, Boolean.TRUE).last("limit 1"));
|
||||
if (one == null){
|
||||
throw new CommonException("地图未启用");
|
||||
}
|
||||
id = one.getId();
|
||||
}
|
||||
MapLayout mapLayout = agvLayoutService.initLayoutMap(id);
|
||||
return CommonResult.data(mapLayout);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.layout.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.layout.service.dto.MapLayout;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
|
||||
public interface AgvLayoutService extends IService<AgvLayoutMap> {
|
||||
|
||||
void saveLayout(MapLayout layout);
|
||||
|
||||
/**
|
||||
* 初始化地图获取布局信息
|
||||
*/
|
||||
MapLayout initLayoutMap(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.layout.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceLayout {
|
||||
private Long id;
|
||||
private String code;
|
||||
private String name;
|
||||
private String type;
|
||||
private String icon;
|
||||
private Integer x;
|
||||
private Integer y;
|
||||
private Integer angle;
|
||||
private Integer size;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.layout.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MapLayout {
|
||||
private Long mapId;
|
||||
private Integer width;
|
||||
private Integer height;
|
||||
private MapOrigin origin;
|
||||
private String url;
|
||||
private List<DeviceLayout> devices;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.nl.layout.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MapOrigin {
|
||||
private Integer x;
|
||||
private Integer y;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.nl.layout.service.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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("agv_layout_device")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AgvLayoutDevice implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private Long mapLayoutId;
|
||||
private Long deviceId;
|
||||
private String code;
|
||||
private String name;
|
||||
private String type;
|
||||
private Integer x;
|
||||
private Integer y;
|
||||
private Integer angle;
|
||||
private String icon;
|
||||
private Integer size;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nl.layout.service.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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 Long Id;
|
||||
private Long mapId;
|
||||
private String mapName;
|
||||
/**
|
||||
* 通过触发器实现
|
||||
*/
|
||||
private Integer version;
|
||||
private String url;
|
||||
private Integer height;
|
||||
private Integer width;
|
||||
private Integer x;
|
||||
private Integer y;
|
||||
private Boolean enable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.nl.layout.service.impl;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.nl.common.exception.CommonException;
|
||||
import org.nl.common.localStorage.service.LocalStorageService;
|
||||
import org.nl.common.localStorage.service.mapper.LocalStorageMapper;
|
||||
import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.common.util.FileProperties;
|
||||
import org.nl.common.util.FileUtil;
|
||||
import org.nl.layout.service.AgvLayoutService;
|
||||
import org.nl.layout.service.dto.DeviceLayout;
|
||||
import org.nl.layout.service.dto.MapLayout;
|
||||
import org.nl.layout.service.entity.AgvLayoutDevice;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
import org.nl.layout.service.mapper.AgvLayoutDeviceMapper;
|
||||
import org.nl.layout.service.mapper.AgvLayoutMapMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
@Service
|
||||
public class AgvLayoutServiceImpl extends ServiceImpl<AgvLayoutMapMapper, AgvLayoutMap> implements AgvLayoutService {
|
||||
@Autowired
|
||||
private LocalStorageService localStorageService;
|
||||
@Resource
|
||||
private AgvLayoutDeviceMapper agvLayoutDeviceMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveLayout(MapLayout layout) {
|
||||
LocalStorage storage = localStorageService.getById(layout.getMapId());
|
||||
AgvLayoutMap layoutMap = AgvLayoutMap.builder()
|
||||
.mapId(layout.getMapId())
|
||||
.mapName(storage.getName())
|
||||
.url(storage.getPath())
|
||||
.width(layout.getWidth())
|
||||
.height(layout.getHeight())
|
||||
.x(layout.getOrigin().getX())
|
||||
.y(layout.getOrigin().getY()).build();
|
||||
this.baseMapper.insertUseGeneratedKeys(layoutMap);
|
||||
List<DeviceLayout> deviceLayout = layout.getDevices();
|
||||
if (!CollectionUtils.isEmpty(deviceLayout)){
|
||||
for (DeviceLayout device : deviceLayout) {
|
||||
AgvLayoutDevice layoutDevice = AgvLayoutDevice.builder()
|
||||
.deviceId(device.getId())
|
||||
.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()).build();
|
||||
agvLayoutDeviceMapper.insert(layoutDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapLayout initLayoutMap(Long id) {
|
||||
return this.baseMapper.initLayoutMap(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.layout.service.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.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.layout.service.entity.AgvLayoutDevice;
|
||||
|
||||
@Mapper
|
||||
public interface AgvLayoutDeviceMapper extends BaseMapper<AgvLayoutDevice> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.nl.layout.service.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.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.layout.service.dto.MapLayout;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
|
||||
@Mapper
|
||||
public interface AgvLayoutMapMapper extends BaseMapper<AgvLayoutMap> {
|
||||
|
||||
@Insert("INSERT INTO agv_layout_map (mapId, url, height, width, x, y) VALUES (#{mapId}, #{url}, #{height}, #{width}, #{x}, #{y})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
void insertUseGeneratedKeys(AgvLayoutMap map);
|
||||
|
||||
MapLayout initLayoutMap(Long id);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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.layout.service.mapper.AgvLayoutMapMapper">
|
||||
|
||||
|
||||
<resultMap id="mapLayoutResultMap" type="org.nl.layout.service.dto.MapLayout">
|
||||
<result property="mapId" column="mapId"/>
|
||||
<result property="width" column="width"/>
|
||||
<result property="height" column="height"/>
|
||||
<result property="url" column="url"/>
|
||||
<!-- 映射origin对象 -->
|
||||
<association property="origin" javaType="org.nl.layout.service.dto.MapOrigin">
|
||||
<result property="x" column="origin_x"/>
|
||||
<result property="y" column="origin_y"/>
|
||||
</association>
|
||||
<!-- 映射设备列表 -->
|
||||
<collection property="devices" ofType="org.nl.layout.service.dto.DeviceLayout">
|
||||
<id property="id" column="device_id"/>
|
||||
<result property="code" column="device_code"/>
|
||||
<result property="name" column="device_name"/>
|
||||
<result property="type" column="device_type"/>
|
||||
<result property="icon" column="device_icon"/>
|
||||
<result property="x" column="device_x"/>
|
||||
<result property="y" column="device_y"/>
|
||||
<result property="angle" column="device_angle"/>
|
||||
<result property="size" column="device_size"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<select id="initLayoutMap" resultMap="mapLayoutResultMap">
|
||||
SELECT
|
||||
m.map_id as mapId,
|
||||
m.width,
|
||||
m.height,
|
||||
m.url,
|
||||
m.x AS origin_x,
|
||||
m.y AS origin_y,
|
||||
d.id AS device_id,
|
||||
d.code AS device_code,
|
||||
d.name AS device_name,
|
||||
d.type AS device_type,
|
||||
d.icon AS device_icon,
|
||||
d.x AS device_x,
|
||||
d.y AS device_y,
|
||||
d.angle AS device_angle,
|
||||
d.size AS device_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>
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.nl.layout.service.query;
|
||||
|
||||
import org.nl.common.page.BaseQuery;
|
||||
import org.nl.layout.service.entity.AgvLayoutMap;
|
||||
|
||||
public class MapLayoutQuery extends BaseQuery<AgvLayoutMap> {
|
||||
}
|
||||
25
nl-base-data/pom.xml
Normal file
25
nl-base-data/pom.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-tool-platform</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-base-data</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>nl-base-data</name>
|
||||
<description>nl-base-data</description>
|
||||
<url/>
|
||||
<dependencies>
|
||||
<!--业务依赖-->
|
||||
<dependency>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
13
nl-base-data/src/main/java/org/nl/NlBaseDataApplication.java
Normal file
13
nl-base-data/src/main/java/org/nl/NlBaseDataApplication.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package org.nl;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class NlBaseDataApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NlBaseDataApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.device.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.device.service.dto.DeviceInfo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Tag(name = "设备模块")
|
||||
@RestController()
|
||||
@RequestMapping("/api/device")
|
||||
@Validated
|
||||
@SaIgnore
|
||||
public class DeviceController {
|
||||
static {
|
||||
System.out.println("初始化AGV模块------------");
|
||||
}
|
||||
@GetMapping("list")
|
||||
public CommonResult<List> status() {
|
||||
List<DeviceInfo> list = new ArrayList<>();
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("action","action");
|
||||
object.put("signal","signal");
|
||||
object.put("power","power");
|
||||
for (int i = 0; i < 20; i++) {
|
||||
DeviceInfo build = DeviceInfo.builder()
|
||||
.name("设备1"+i)
|
||||
.code(i + "sdfsdf")
|
||||
.id(String.valueOf(i))
|
||||
.icon("/Users/mima0000/Desktop/car.png")
|
||||
.description("设备介绍")
|
||||
.editParam(object)
|
||||
.type(i%2==1?"货架":"专机")
|
||||
.build();
|
||||
list.add(build);
|
||||
}
|
||||
return CommonResult.data(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.nl.device.service.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DeviceInfo {
|
||||
/**
|
||||
* 设备Id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 设备Id
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 设备描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 设备编辑时存储信息
|
||||
*/
|
||||
private JSONObject editParam;
|
||||
/**
|
||||
* 设备图标
|
||||
*/
|
||||
private String icon="/Users/mima0000/Desktop/car.png";
|
||||
|
||||
}
|
||||
@@ -10,31 +10,42 @@
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package org.nl.controller;
|
||||
package org.nl.point;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.nl.language.LangBehavior;
|
||||
import org.nl.point.dto.PointStatus;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Tag(name = "AGV模块")
|
||||
@RestController()
|
||||
@RequestMapping("/api/agv")
|
||||
@RequestMapping("/api/baseData/point")
|
||||
@Validated
|
||||
public class AgvStatusController {
|
||||
@SaIgnore
|
||||
public class PointStatusController {
|
||||
static {
|
||||
System.out.println("初始化AGV模块------------");
|
||||
}
|
||||
@GetMapping("status")
|
||||
public CommonResult<JSONObject> status() {
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
return CommonResult.ok();
|
||||
public CommonResult<List<PointStatus>> status() {
|
||||
List<PointStatus> list = new ArrayList<>();
|
||||
for (int i = 0; i < new Random().nextInt(100)+10; i++) {
|
||||
PointStatus build = PointStatus.builder().pointCode("A1_1" + i)
|
||||
.pointName("货位" + i)
|
||||
.x(new Random().nextInt(1280))
|
||||
.y(new Random().nextInt(960)).status(String.valueOf(i / 2)).build();
|
||||
list.add(build);
|
||||
}
|
||||
return CommonResult.data(list);
|
||||
}
|
||||
}
|
||||
33
nl-base-data/src/main/java/org/nl/point/dto/PointStatus.java
Normal file
33
nl-base-data/src/main/java/org/nl/point/dto/PointStatus.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package org.nl.point.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PointStatus {
|
||||
/**
|
||||
* 点位编码
|
||||
*/
|
||||
private String pointCode;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String pointName;
|
||||
/**
|
||||
* 坐标X
|
||||
*/
|
||||
private int x;
|
||||
/**
|
||||
* 坐标Y
|
||||
*/
|
||||
private int y;
|
||||
/**
|
||||
* 点位状态 0无货1有货
|
||||
*/
|
||||
private String status;
|
||||
}
|
||||
1
nl-base-data/src/main/resources/application.properties
Normal file
1
nl-base-data/src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
spring.application.name=nl-base-data
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
package org.nl.common.localStorage.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.localStorage.service.LocalStorageService;
|
||||
import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/localStorage"})
|
||||
@SaIgnore
|
||||
public class LocalStorageController {
|
||||
|
||||
@Autowired
|
||||
private LocalStorageService localStorageService;
|
||||
|
||||
@GetMapping
|
||||
public CommonResult<Object> query(@RequestParam String annex) {
|
||||
List<LocalStorage> list = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(annex)){
|
||||
String[] split = annex.split(",");
|
||||
list = localStorageService.listByIds(Arrays.asList(split));
|
||||
}
|
||||
return CommonResult.data(list);
|
||||
}
|
||||
@PostMapping({"/upload"})
|
||||
public CommonResult<Object> upload(@RequestParam MultipartFile file) {
|
||||
LocalStorage localStorage = localStorageService.upload(file);
|
||||
return CommonResult.data(localStorage);
|
||||
}
|
||||
@GetMapping({"/download"})
|
||||
public void download(@RequestParam Long storageId , HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
this.localStorageService.downloadFile(this.localStorageService.getById(storageId),request, response);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
public CommonResult delete(@RequestBody Long[] ids) {
|
||||
localStorageService.removeByIds(Arrays.asList(ids));
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.nl.common.localStorage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface LocalStorageService extends IService<LocalStorage> {
|
||||
|
||||
LocalStorage upload(MultipartFile file);
|
||||
List<LocalStorage> batchUpload(MultipartFile[] file);
|
||||
|
||||
void download(List<LocalStorage> localStorageDtos, HttpServletResponse response) throws IOException;
|
||||
void downloadFile(LocalStorage localStorage, HttpServletRequest request, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.nl.common.localStorage.service.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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("local_storage")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LocalStorage implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private String name;
|
||||
private String suffix;
|
||||
private String path;
|
||||
private String type;
|
||||
private String size;
|
||||
private Integer orderCode;
|
||||
private Date createTime;
|
||||
private String createName;
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.nl.common.localStorage.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.nl.common.localStorage.service.LocalStorageService;
|
||||
import org.nl.common.localStorage.service.mapper.LocalStorageMapper;
|
||||
import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.common.util.FileProperties;
|
||||
import org.nl.common.util.FileUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
@Service
|
||||
public class LocalStorageServiceImpl extends ServiceImpl<LocalStorageMapper, LocalStorage> implements LocalStorageService {
|
||||
@Autowired
|
||||
private FileProperties fileProperties;
|
||||
|
||||
|
||||
@Override
|
||||
public LocalStorage upload(MultipartFile multipartFile) {
|
||||
String filename = multipartFile.getOriginalFilename();
|
||||
String suffix = FileUtil.getExtensionName(filename);
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(multipartFile, this.fileProperties.getPath().getPath() + type + File.separator);
|
||||
LocalStorage storage = LocalStorage.builder().name(filename)
|
||||
.path(file.getPath())
|
||||
.size(FileUtil.getSize(multipartFile.getSize()))
|
||||
.suffix(type)
|
||||
.type(type).createTime(new Date()).build();
|
||||
this.baseMapper.insertUseGeneratedKeys(storage);
|
||||
return storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalStorage> batchUpload(MultipartFile[] multipartFile) {
|
||||
List<LocalStorage> result = new ArrayList<>();
|
||||
if (multipartFile!=null){
|
||||
for (MultipartFile item : multipartFile) {
|
||||
String filename = item.getOriginalFilename();
|
||||
String suffix = FileUtil.getExtensionName(filename);
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(item, this.fileProperties.getPath().getPath() + type + File.separator);
|
||||
LocalStorage storage = LocalStorage.builder().name(filename)
|
||||
.path(file.getPath())
|
||||
.size(FileUtil.getSize(item.getSize()))
|
||||
.suffix(type)
|
||||
.type(type).createTime(new Date()).build();
|
||||
result.add(storage);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(result)){
|
||||
this.saveBatch(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public void download(List<LocalStorage> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList();
|
||||
Iterator var4 = queryAll.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
LocalStorage localStorageDTO = (LocalStorage)var4.next();
|
||||
Map<String, Object> map = new LinkedHashMap();
|
||||
map.put("文件名", localStorageDTO.getName());
|
||||
map.put("备注名", localStorageDTO.getName());
|
||||
map.put("文件类型", localStorageDTO.getType());
|
||||
map.put("文件大小", localStorageDTO.getSize());
|
||||
map.put("创建者", localStorageDTO.getCreateName());
|
||||
map.put("创建日期", localStorageDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadFile(LocalStorage localStorage, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
String path = localStorage.getPath();
|
||||
File file = new File(path);
|
||||
FileUtil.downloadFile(request, response,file,false);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.common.localStorage.service.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.common.localStorage.service.entity.LocalStorage;
|
||||
|
||||
@Mapper
|
||||
public interface LocalStorageMapper extends BaseMapper<LocalStorage> {
|
||||
|
||||
@Insert("INSERT INTO local_storage (name, suffix, path, type, size, order_code, create_time, create_name, update_time) VALUES (#{name}, #{suffix}, #{path}, #{type}, #{size}, #{orderCode}, #{createTime}, #{createName}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
void insertUseGeneratedKeys(LocalStorage user);
|
||||
}
|
||||
73
nl-common/src/main/java/org/nl/common/page/BaseQuery.java
Normal file
73
nl-common/src/main/java/org/nl/common/page/BaseQuery.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package org.nl.common.page;
|
||||
|
||||
import cn.hutool.core.lang.ParameterizedTypeImpl;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import org.nl.common.util.MapOf;
|
||||
|
||||
/**
|
||||
* 泛型必须为数据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.page.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)){
|
||||
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(){};
|
||||
}
|
||||
19
nl-common/src/main/java/org/nl/common/page/LConsumer.java
Normal file
19
nl-common/src/main/java/org/nl/common/page/LConsumer.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package org.nl.common.page;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
135
nl-common/src/main/java/org/nl/common/page/PageQuery.java
Normal file
135
nl-common/src/main/java/org/nl/common/page/PageQuery.java
Normal file
@@ -0,0 +1,135 @@
|
||||
package org.nl.common.page;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
14
nl-common/src/main/java/org/nl/common/page/QParam.java
Normal file
14
nl-common/src/main/java/org/nl/common/page/QParam.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package org.nl.common.page;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
/**
|
||||
* s
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/15 1:41 下午
|
||||
*/
|
||||
@Builder
|
||||
public class QParam {
|
||||
public String[] k;
|
||||
public QueryTEnum type;
|
||||
}
|
||||
81
nl-common/src/main/java/org/nl/common/page/QueryTEnum.java
Normal file
81
nl-common/src/main/java/org/nl/common/page/QueryTEnum.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package org.nl.common.page;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
242
nl-common/src/main/java/org/nl/common/util/FileProperties.java
Normal file
242
nl-common/src/main/java/org/nl/common/util/FileProperties.java
Normal file
@@ -0,0 +1,242 @@
|
||||
package org.nl.common.util;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(
|
||||
prefix = "file"
|
||||
)
|
||||
public class FileProperties {
|
||||
private Long maxSize;
|
||||
private Long avatarMaxSize;
|
||||
private ElPath mac;
|
||||
private ElPath linux;
|
||||
private ElPath windows;
|
||||
|
||||
public ElPath getPath() {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.toLowerCase().startsWith("win")) {
|
||||
return this.windows;
|
||||
} else {
|
||||
return os.toLowerCase().startsWith("mac") ? this.mac : this.linux;
|
||||
}
|
||||
}
|
||||
|
||||
public FileProperties() {
|
||||
}
|
||||
|
||||
public Long getMaxSize() {
|
||||
return this.maxSize;
|
||||
}
|
||||
|
||||
public Long getAvatarMaxSize() {
|
||||
return this.avatarMaxSize;
|
||||
}
|
||||
|
||||
public ElPath getMac() {
|
||||
return this.mac;
|
||||
}
|
||||
|
||||
public ElPath getLinux() {
|
||||
return this.linux;
|
||||
}
|
||||
|
||||
public ElPath getWindows() {
|
||||
return this.windows;
|
||||
}
|
||||
|
||||
public void setMaxSize(final Long maxSize) {
|
||||
this.maxSize = maxSize;
|
||||
}
|
||||
|
||||
public void setAvatarMaxSize(final Long avatarMaxSize) {
|
||||
this.avatarMaxSize = avatarMaxSize;
|
||||
}
|
||||
|
||||
public void setMac(final ElPath mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public void setLinux(final ElPath linux) {
|
||||
this.linux = linux;
|
||||
}
|
||||
|
||||
public void setWindows(final ElPath windows) {
|
||||
this.windows = windows;
|
||||
}
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
} else if (!(o instanceof FileProperties)) {
|
||||
return false;
|
||||
} else {
|
||||
FileProperties other = (FileProperties)o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
} else {
|
||||
label71: {
|
||||
Object this$maxSize = this.getMaxSize();
|
||||
Object other$maxSize = other.getMaxSize();
|
||||
if (this$maxSize == null) {
|
||||
if (other$maxSize == null) {
|
||||
break label71;
|
||||
}
|
||||
} else if (this$maxSize.equals(other$maxSize)) {
|
||||
break label71;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$avatarMaxSize = this.getAvatarMaxSize();
|
||||
Object other$avatarMaxSize = other.getAvatarMaxSize();
|
||||
if (this$avatarMaxSize == null) {
|
||||
if (other$avatarMaxSize != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$avatarMaxSize.equals(other$avatarMaxSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
label57: {
|
||||
Object this$mac = this.getMac();
|
||||
Object other$mac = other.getMac();
|
||||
if (this$mac == null) {
|
||||
if (other$mac == null) {
|
||||
break label57;
|
||||
}
|
||||
} else if (this$mac.equals(other$mac)) {
|
||||
break label57;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$linux = this.getLinux();
|
||||
Object other$linux = other.getLinux();
|
||||
if (this$linux == null) {
|
||||
if (other$linux != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$linux.equals(other$linux)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$windows = this.getWindows();
|
||||
Object other$windows = other.getWindows();
|
||||
if (this$windows == null) {
|
||||
if (other$windows == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$windows.equals(other$windows)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FileProperties;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
boolean PRIME = true;
|
||||
int result = 1;
|
||||
Object $maxSize = this.getMaxSize();
|
||||
result = result * 59 + ($maxSize == null ? 43 : $maxSize.hashCode());
|
||||
Object $avatarMaxSize = this.getAvatarMaxSize();
|
||||
result = result * 59 + ($avatarMaxSize == null ? 43 : $avatarMaxSize.hashCode());
|
||||
Object $mac = this.getMac();
|
||||
result = result * 59 + ($mac == null ? 43 : $mac.hashCode());
|
||||
Object $linux = this.getLinux();
|
||||
result = result * 59 + ($linux == null ? 43 : $linux.hashCode());
|
||||
Object $windows = this.getWindows();
|
||||
result = result * 59 + ($windows == null ? 43 : $windows.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "FileProperties(maxSize=" + this.getMaxSize() + ", avatarMaxSize=" + this.getAvatarMaxSize() + ", mac=" + this.getMac() + ", linux=" + this.getLinux() + ", windows=" + this.getWindows() + ")";
|
||||
}
|
||||
|
||||
public static class ElPath {
|
||||
private String path;
|
||||
private String avatar;
|
||||
|
||||
public ElPath() {
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return this.avatar;
|
||||
}
|
||||
|
||||
public void setPath(final String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setAvatar(final String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
} else if (!(o instanceof ElPath)) {
|
||||
return false;
|
||||
} else {
|
||||
ElPath other = (ElPath)o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
} else {
|
||||
Object this$path = this.getPath();
|
||||
Object other$path = other.getPath();
|
||||
if (this$path == null) {
|
||||
if (other$path != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$path.equals(other$path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$avatar = this.getAvatar();
|
||||
Object other$avatar = other.getAvatar();
|
||||
if (this$avatar == null) {
|
||||
if (other$avatar != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$avatar.equals(other$avatar)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ElPath;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
boolean PRIME = true;
|
||||
int result = 1;
|
||||
Object $path = this.getPath();
|
||||
result = result * 59 + ($path == null ? 43 : $path.hashCode());
|
||||
Object $avatar = this.getAvatar();
|
||||
result = result * 59 + ($avatar == null ? 43 : $avatar.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "FileProperties.ElPath(path=" + this.getPath() + ", avatar=" + this.getAvatar() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
273
nl-common/src/main/java/org/nl/common/util/FileUtil.java
Normal file
273
nl-common/src/main/java/org/nl/common/util/FileUtil.java
Normal file
@@ -0,0 +1,273 @@
|
||||
package org.nl.common.util;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.poi.excel.BigExcelWriter;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.nl.common.exception.CommonException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.security.MessageDigest;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
|
||||
public static final String SYS_TEM_DIR;
|
||||
private static final int GB = 1073741824;
|
||||
private static final int MB = 1048576;
|
||||
private static final int KB = 1024;
|
||||
private static final DecimalFormat DF;
|
||||
public static final String IMAGE = "图片";
|
||||
public static final String TXT = "文档";
|
||||
public static final String MUSIC = "音乐";
|
||||
public static final String VIDEO = "视频";
|
||||
public static final String OTHER = "其他";
|
||||
|
||||
public FileUtil() {
|
||||
}
|
||||
|
||||
public static File toFile(MultipartFile multipartFile) {
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
String prefix = "." + getExtensionName(fileName);
|
||||
File file = null;
|
||||
|
||||
try {
|
||||
file = new File(SYS_TEM_DIR + IdUtil.simpleUUID() + prefix);
|
||||
multipartFile.transferTo(file);
|
||||
} catch (IOException var5) {
|
||||
IOException e = var5;
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
public static String getExtensionName(String filename) {
|
||||
if (filename != null && filename.length() > 0) {
|
||||
int dot = filename.lastIndexOf(46);
|
||||
if (dot > -1 && dot < filename.length() - 1) {
|
||||
return filename.substring(dot + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
public static String getFileNameNoEx(String filename) {
|
||||
if (filename != null && filename.length() > 0) {
|
||||
int dot = filename.lastIndexOf(46);
|
||||
if (dot > -1 && dot < filename.length()) {
|
||||
return filename.substring(0, dot);
|
||||
}
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
public static String getSize(long size) {
|
||||
String resultSize;
|
||||
if (size / 1073741824L >= 1L) {
|
||||
resultSize = DF.format((double)((float)size / 1.07374182E9F)) + "GB ";
|
||||
} else if (size / 1048576L >= 1L) {
|
||||
resultSize = DF.format((double)((float)size / 1048576.0F)) + "MB ";
|
||||
} else if (size / 1024L >= 1L) {
|
||||
resultSize = DF.format((double)((float)size / 1024.0F)) + "KB ";
|
||||
} else {
|
||||
resultSize = size + "B ";
|
||||
}
|
||||
|
||||
return resultSize;
|
||||
}
|
||||
|
||||
static File inputStreamToFile(InputStream ins, String name) throws Exception {
|
||||
File file = new File(SYS_TEM_DIR + name);
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
} else {
|
||||
OutputStream os = new FileOutputStream(file);
|
||||
int len = 8192;
|
||||
byte[] buffer = new byte[len];
|
||||
|
||||
int bytesRead;
|
||||
while((bytesRead = ins.read(buffer, 0, len)) != -1) {
|
||||
os.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
os.close();
|
||||
ins.close();
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
public static File upload(MultipartFile file, String filePath) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||
String name = getFileNameNoEx(file.getOriginalFilename());
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
String nowStr = "-" + format.format(date);
|
||||
|
||||
try {
|
||||
String fileName = name + nowStr + "." + suffix;
|
||||
String path = filePath + fileName;
|
||||
File dest = (new File(path)).getCanonicalFile();
|
||||
if (!dest.getParentFile().exists() && !dest.getParentFile().mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
|
||||
file.transferTo(dest);
|
||||
return dest;
|
||||
} catch (Exception var10) {
|
||||
Exception e = var10;
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
|
||||
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
|
||||
File file = new File(tempPath);
|
||||
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
|
||||
writer.write(list, true);
|
||||
SXSSFSheet sheet = (SXSSFSheet)writer.getSheet();
|
||||
sheet.trackAllColumnsForAutoSizing();
|
||||
writer.autoSizeColumnAll();
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
file.deleteOnExit();
|
||||
writer.flush(out, true);
|
||||
IoUtil.close(out);
|
||||
}
|
||||
|
||||
public static String getFileType(String type) {
|
||||
String documents = "txt doc pdf ppt pps xlsx xls docx";
|
||||
String music = "mp3 wav wma mpa ram ra aac aif m4a";
|
||||
String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg";
|
||||
String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg svg";
|
||||
if (image.contains(type)) {
|
||||
return "图片";
|
||||
} else if (documents.contains(type)) {
|
||||
return "文档";
|
||||
} else if (music.contains(type)) {
|
||||
return "音乐";
|
||||
} else {
|
||||
return video.contains(type) ? "视频" : "其他";
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkSize(long maxSize, long size) {
|
||||
int len = 1048576;
|
||||
if (size > maxSize * (long)len) {
|
||||
throw new CommonException("文件超出规定大小");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean check(File file1, File file2) {
|
||||
String img1Md5 = getMd5(file1);
|
||||
String img2Md5 = getMd5(file2);
|
||||
return img1Md5.equals(img2Md5);
|
||||
}
|
||||
|
||||
public static boolean check(String file1Md5, String file2Md5) {
|
||||
return file1Md5.equals(file2Md5);
|
||||
}
|
||||
|
||||
private static byte[] getByte(File file) {
|
||||
byte[] b = new byte[(int)file.length()];
|
||||
|
||||
try {
|
||||
InputStream in = new FileInputStream(file);
|
||||
|
||||
try {
|
||||
System.out.println(in.read(b));
|
||||
} catch (IOException var4) {
|
||||
IOException e = var4;
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return b;
|
||||
} catch (FileNotFoundException var5) {
|
||||
FileNotFoundException e = var5;
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getMd5(byte[] bytes) {
|
||||
char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
|
||||
try {
|
||||
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
|
||||
mdTemp.update(bytes);
|
||||
byte[] md = mdTemp.digest();
|
||||
int j = md.length;
|
||||
char[] str = new char[j * 2];
|
||||
int k = 0;
|
||||
byte[] var7 = md;
|
||||
int var8 = md.length;
|
||||
|
||||
for(int var9 = 0; var9 < var8; ++var9) {
|
||||
byte byte0 = var7[var9];
|
||||
str[k++] = hexDigits[byte0 >>> 4 & 15];
|
||||
str[k++] = hexDigits[byte0 & 15];
|
||||
}
|
||||
|
||||
return new String(str);
|
||||
} catch (Exception var11) {
|
||||
Exception e = var11;
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit) {
|
||||
response.setCharacterEncoding(request.getCharacterEncoding());
|
||||
response.setContentType("application/octet-stream");
|
||||
FileInputStream fis = null;
|
||||
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
|
||||
IOUtils.copy(fis, response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
} catch (Exception var14) {
|
||||
Exception e = var14;
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
if (deleteOnExit) {
|
||||
file.deleteOnExit();
|
||||
}
|
||||
} catch (IOException var13) {
|
||||
IOException e = var13;
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getMd5(File file) {
|
||||
return getMd5(getByte(file));
|
||||
}
|
||||
|
||||
static {
|
||||
SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator;
|
||||
DF = new DecimalFormat("0.00");
|
||||
}
|
||||
}
|
||||
20
nl-common/src/main/java/org/nl/common/util/MapOf.java
Normal file
20
nl-common/src/main/java/org/nl/common/util/MapOf.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.nl.common.util;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -12,119 +12,9 @@
|
||||
<name>nl-system</name>
|
||||
<description>nl-system</description>
|
||||
<dependencies>
|
||||
|
||||
<!-- nashorn-core -->
|
||||
<dependency>
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- aop -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- processor -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-trans -->
|
||||
<dependency>
|
||||
<groupId>com.fhs-opensource</groupId>
|
||||
<artifactId>easy-trans-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-trans-mybatis-plus-extend -->
|
||||
<dependency>
|
||||
<groupId>com.fhs-opensource</groupId>
|
||||
<artifactId>easy-trans-mybatis-plus-extend</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- pinyin4j -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ip2region -->
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-poi -->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- sm-crypto -->
|
||||
<dependency>
|
||||
<groupId>com.antherd</groupId>
|
||||
<artifactId>sm-crypto</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- easyexcel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 接口地址
|
||||
VITE_API_BASEURL = http://127.0.0.1:82
|
||||
VITE_API_BASEURL = http://127.0.0.1:8081
|
||||
|
||||
# 本地端口
|
||||
VITE_PORT = 81
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 接口地址
|
||||
VITE_API_BASEURL = http://127.0.0.1:82
|
||||
VITE_API_BASEURL = http://127.0.0.1:8081
|
||||
|
||||
# 本地端口
|
||||
VITE_PORT = 81
|
||||
|
||||
29
nl-vue/src/api/agv/carApi.js
Normal file
29
nl-vue/src/api/agv/carApi.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* AGV车辆管理API
|
||||
*/
|
||||
import { baseRequest } from '@/utils/request'
|
||||
|
||||
const request = (url, ...arg) => baseRequest(`/api/agv/` + url, ...arg)
|
||||
|
||||
export default {
|
||||
// 获取车辆信息列表
|
||||
list(data) {
|
||||
return request('list', data, 'get')
|
||||
},
|
||||
// 新增车辆信息
|
||||
save(data) {
|
||||
return request('save', data)
|
||||
},
|
||||
// 编辑车辆信息
|
||||
edit(data) {
|
||||
return request('edit', data)
|
||||
},
|
||||
// 删除车辆信息
|
||||
delete(data) {
|
||||
return request('delete', data)
|
||||
},
|
||||
// 获取车辆详情
|
||||
detail(data) {
|
||||
return request('detail', data, 'get')
|
||||
}
|
||||
}
|
||||
260
nl-vue/src/views/nl_agv/car/form.vue
Normal file
260
nl-vue/src/views/nl_agv/car/form.vue
Normal file
@@ -0,0 +1,260 @@
|
||||
<template>
|
||||
<xn-form-container
|
||||
:title="formData.carId ? '编辑车辆信息' : '新增车辆信息'"
|
||||
:width="900"
|
||||
:visible="visible"
|
||||
:destroy-on-close="true"
|
||||
@close="onClose"
|
||||
>
|
||||
<div class="form-content">
|
||||
<!-- 左侧:图片预览区域 -->
|
||||
<div class="image-preview-section" v-if="formData.carId && formData.icon">
|
||||
<div class="preview-title">车辆图片预览</div>
|
||||
<div class="preview-container">
|
||||
<a-image :src="formData.icon" :preview="true" class="car-image" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:表单区域 -->
|
||||
<div class="form-section" :class="{ 'full-width': !formData.carId || !formData.icon }">
|
||||
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
|
||||
<a-form-item label="车辆ID:" name="carId">
|
||||
<a-input
|
||||
v-model:value="formData.carId"
|
||||
placeholder="请输入车辆ID"
|
||||
:disabled="!!formData.carId"
|
||||
allow-clear
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="车辆类型:" name="type">
|
||||
<a-input
|
||||
v-model:value="formData.type"
|
||||
placeholder="请输入车辆类型(如:PS车、NT车等)"
|
||||
allow-clear
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="车辆图片:" name="icon">
|
||||
<a-upload
|
||||
v-model:file-list="fileList"
|
||||
name="file"
|
||||
list-type="picture-card"
|
||||
class="car-uploader"
|
||||
:show-upload-list="true"
|
||||
:before-upload="beforeUpload"
|
||||
:custom-request="handleUpload"
|
||||
@remove="handleRemove"
|
||||
:max-count="1"
|
||||
>
|
||||
<div v-if="fileList.length < 1">
|
||||
<plus-outlined />
|
||||
<div style="margin-top: 8px">上传图片</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
<div class="upload-tip">支持jpg、png格式,建议尺寸200x200像素</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<a-button class="xn-mr8" @click="onClose">关闭</a-button>
|
||||
<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
|
||||
</template>
|
||||
</xn-form-container>
|
||||
</template>
|
||||
|
||||
<script setup name="nlAgvCarForm">
|
||||
import { required } from '@/utils/formRules'
|
||||
import carApi from '@/api/agv/carApi'
|
||||
import fileApi from '@/api/dev/fileApi'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
// 默认是关闭状态
|
||||
const visible = ref(false)
|
||||
const emit = defineEmits({ successful: null })
|
||||
const formRef = ref()
|
||||
|
||||
// 表单数据
|
||||
const formData = ref({})
|
||||
const submitLoading = ref(false)
|
||||
const fileList = ref([])
|
||||
|
||||
// 打开抽屉
|
||||
const onOpen = (record) => {
|
||||
visible.value = true
|
||||
formData.value = {}
|
||||
fileList.value = []
|
||||
|
||||
if (record) {
|
||||
submitLoading.value = true
|
||||
const param = {
|
||||
carId: record.carId
|
||||
}
|
||||
carApi
|
||||
.detail(param)
|
||||
.then((data) => {
|
||||
formData.value = Object.assign({}, data)
|
||||
// 如果有图片,设置文件列表
|
||||
if (data.icon) {
|
||||
fileList.value = [
|
||||
{
|
||||
uid: '-1',
|
||||
name: 'car-image.png',
|
||||
status: 'done',
|
||||
url: data.icon
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
submitLoading.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭抽屉
|
||||
const onClose = () => {
|
||||
formRef.value.resetFields()
|
||||
fileList.value = []
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
// 默认要校验的
|
||||
const formRules = {
|
||||
carId: [required('请输入车辆ID')],
|
||||
type: [required('请输入车辆类型')]
|
||||
}
|
||||
|
||||
// 上传前校验
|
||||
const beforeUpload = (file) => {
|
||||
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
|
||||
if (!isJpgOrPng) {
|
||||
message.error('只能上传 JPG/PNG 格式的图片!')
|
||||
return false
|
||||
}
|
||||
const isLt5M = file.size / 1024 / 1024 < 5
|
||||
if (!isLt5M) {
|
||||
message.error('图片大小不能超过 5MB!')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 自定义上传
|
||||
const handleUpload = ({ file, onSuccess, onError }) => {
|
||||
const uploadFormData = new FormData()
|
||||
uploadFormData.append('file', file)
|
||||
|
||||
fileApi
|
||||
.fileUploadDynamicReturnUrl(uploadFormData)
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
// 保存文件URL到表单数据
|
||||
formData.value.icon = res
|
||||
message.success('上传成功')
|
||||
onSuccess(res)
|
||||
} else {
|
||||
message.error('上传失败')
|
||||
onError(new Error('上传失败'))
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
message.error('上传失败: ' + error.message)
|
||||
onError(error)
|
||||
})
|
||||
}
|
||||
|
||||
// 删除图片
|
||||
const handleRemove = () => {
|
||||
formData.value.icon = ''
|
||||
}
|
||||
|
||||
// 验证并提交数据
|
||||
const onSubmit = () => {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
submitLoading.value = true
|
||||
const apiMethod = formData.value.carId && formData.value.id ? carApi.edit : carApi.save
|
||||
apiMethod(formData.value)
|
||||
.then(() => {
|
||||
message.success('保存成功')
|
||||
onClose()
|
||||
emit('successful')
|
||||
})
|
||||
.finally(() => {
|
||||
submitLoading.value = false
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
// 调用这个函数将子组件的一些数据和方法暴露出去
|
||||
defineExpose({
|
||||
onOpen
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.form-content {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
.image-preview-section {
|
||||
flex: 0 0 350px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.preview-title {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 16px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.preview-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f5f5;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
|
||||
.car-image {
|
||||
max-width: 100%;
|
||||
max-height: 400px;
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-section {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
&.full-width {
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.car-uploader {
|
||||
:deep(.ant-upload-select-picture-card) {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
:deep(.ant-upload-list-picture-card-container) {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
</style>
|
||||
149
nl-vue/src/views/nl_agv/car/index.vue
Normal file
149
nl-vue/src/views/nl_agv/car/index.vue
Normal file
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<a-card :bordered="false" :body-style="{ 'padding-bottom': '0px' }" class="mb-2">
|
||||
<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="6">
|
||||
<a-form-item label="关键词" name="searchKey">
|
||||
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入车辆ID或类型" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<a-form-item label="车辆类型" name="type">
|
||||
<a-input v-model:value="searchFormState.type" placeholder="请输入车辆类型" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<a-button type="primary" @click="tableRef.refresh(true)">查询</a-button>
|
||||
<a-button class="xn-mg08" @click="reset">重置</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-card>
|
||||
<a-card :bordered="false">
|
||||
<s-table
|
||||
ref="tableRef"
|
||||
:columns="columns"
|
||||
:data="loadData"
|
||||
:alert="options.alert.show"
|
||||
bordered
|
||||
:row-key="(record) => record.carId"
|
||||
:tool-config="toolConfig"
|
||||
:row-selection="options.rowSelection"
|
||||
>
|
||||
<template #operator class="table-operator">
|
||||
<a-space>
|
||||
<a-button type="primary" @click="formRef.onOpen()">
|
||||
<template #icon><plus-outlined /></template>
|
||||
新增车辆
|
||||
</a-button>
|
||||
<xn-batch-button
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
buttonDanger
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@batchCallBack="deleteBatchCar"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'icon'">
|
||||
<a-image v-if="record.icon" :width="50" :src="record.icon" />
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
<a @click="formRef.onOpen(record)">编辑</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm title="确定要删除此车辆吗?" @confirm="deleteCar(record)">
|
||||
<a-button type="link" danger size="small">删除</a-button>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</s-table>
|
||||
</a-card>
|
||||
<Form ref="formRef" @successful="tableRef.refresh(true)" />
|
||||
</template>
|
||||
|
||||
<script setup name="nlAgvCar">
|
||||
import Form from './form.vue'
|
||||
import carApi from '@/api/agv/carApi'
|
||||
|
||||
const searchFormState = ref({})
|
||||
const searchFormRef = ref()
|
||||
const tableRef = ref()
|
||||
const formRef = ref()
|
||||
const toolConfig = { refresh: true, height: true, columnSetting: false, striped: false }
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: '车辆ID',
|
||||
dataIndex: 'carId',
|
||||
width: '150px'
|
||||
},
|
||||
{
|
||||
title: '车辆类型',
|
||||
dataIndex: 'type',
|
||||
width: '150px'
|
||||
},
|
||||
{
|
||||
title: '车辆图片',
|
||||
dataIndex: 'icon',
|
||||
width: '120px'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
align: 'center',
|
||||
width: '180px'
|
||||
}
|
||||
]
|
||||
|
||||
let selectedRowKeys = ref([])
|
||||
|
||||
// 列表选择配置
|
||||
const options = {
|
||||
alert: {
|
||||
show: false,
|
||||
clear: () => {
|
||||
selectedRowKeys = ref([])
|
||||
}
|
||||
},
|
||||
rowSelection: {
|
||||
onChange: (selectedRowKey, selectedRows) => {
|
||||
selectedRowKeys.value = selectedRowKey
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const loadData = (parameter) => {
|
||||
return carApi.list(Object.assign(parameter, searchFormState.value)).then((res) => {
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
searchFormRef.value.resetFields()
|
||||
tableRef.value.refresh(true)
|
||||
}
|
||||
|
||||
// 删除
|
||||
const deleteCar = (record) => {
|
||||
let params = [
|
||||
{
|
||||
carId: record.carId
|
||||
}
|
||||
]
|
||||
carApi.delete(params).then(() => {
|
||||
tableRef.value.refresh(true)
|
||||
})
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
const deleteBatchCar = (params) => {
|
||||
carApi.delete(params).then(() => {
|
||||
tableRef.value.clearRefreshSelected()
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -54,6 +54,12 @@
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-base-data</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.nl</groupId>
|
||||
<artifactId>nl-plugin-biz</artifactId>
|
||||
|
||||
@@ -109,6 +109,10 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
||||
"/",
|
||||
/*AGV*/
|
||||
"/api/agv/status",
|
||||
"/api/device/**",
|
||||
"/api/agv/map/**",
|
||||
"/api/localStorage/**",
|
||||
"/api/baseData/point/status",
|
||||
"/api/language/**",
|
||||
/* 静态资源 */
|
||||
"/favicon.ico",
|
||||
|
||||
@@ -19,7 +19,7 @@ spring:
|
||||
public-key: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMWiTVtdXFVrgFHDDKELZM0SywkWY3KjugN90eY5Sogon1j8Y0ClPF7nx3FuE7pAeBKiv7ChIS0vvx/59WUpKmUCAwEAAQ==
|
||||
druid:
|
||||
initial-size: 5
|
||||
max-active: 20
|
||||
max-active: 208081
|
||||
min-idle: 5
|
||||
max-wait: 60000
|
||||
pool-prepared-statements: true
|
||||
@@ -164,3 +164,16 @@ i18n:
|
||||
- zh
|
||||
- vi
|
||||
fallback-to-classpath: true
|
||||
file:
|
||||
mac:
|
||||
path: /Users/mima0000/Desktop/file/
|
||||
avatar: /Users/mima0000/Desktop/avatar/
|
||||
linux:
|
||||
path: /home/eladmin/file/
|
||||
avatar: /home/eladmin/avatar/
|
||||
windows:
|
||||
path: C:\eladmin\file\
|
||||
avatar: C:\eladmin\avatar\
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
||||
|
||||
Reference in New Issue
Block a user